:root {
  --board: #6b5344;
  --board-deep: #4f3d32;
  --sticky: #fff7a8;
  --sticky-shadow: #d4c76a;
  --sticky-line: rgba(92, 78, 20, 0.22);
  --ink: #2a2410;
  --muted: #6a5f3a;
  --primary: #2f8f72;
  --primary-deep: #1f735b;
  --danger: #b54a4a;
  --border: rgba(42, 36, 16, 0.14);
  --radius: 14px;
  --font-ui: "Plus Jakarta Sans", system-ui, sans-serif;
  --font-hand: "Caveat", "Segoe Print", cursive;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  font-family: var(--font-ui);
  color: var(--ink);
  background:
    radial-gradient(circle at 20% 10%, rgba(255, 255, 255, 0.08), transparent 40%),
    linear-gradient(145deg, var(--board-deep), var(--board));
}

body.mode-break .sticky-note {
  box-shadow:
    8px 10px 0 var(--sticky-shadow),
    0 28px 60px rgba(0, 0, 0, 0.35),
    inset 0 0 0 2px rgba(120, 140, 220, 0.25);
}

.board {
  min-height: 100vh;
  padding: 1.25rem 1rem 2.5rem;
  display: grid;
  gap: 1.25rem;
  justify-items: center;
  align-content: start;
}

.sticky-note {
  width: min(920px, 96vw);
  min-height: min(78vh, 860px);
  display: grid;
  grid-template-rows: auto 2.2fr 1.4fr 1fr auto;
  gap: 0;
  background: linear-gradient(180deg, #fffadc 0%, var(--sticky) 18%, #fff3a0 100%);
  border-radius: 4px 18px 18px 18px;
  box-shadow:
    8px 10px 0 var(--sticky-shadow),
    0 28px 60px rgba(0, 0, 0, 0.35);
  position: relative;
  overflow: hidden;
}

.sticky-note::before {
  content: "";
  position: absolute;
  inset: 0;
  background: repeating-linear-gradient(
    transparent,
    transparent 27px,
    rgba(92, 78, 20, 0.06) 28px
  );
  pointer-events: none;
}

.sticky-topbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.85rem 1rem 0.65rem;
  border-bottom: 2px dashed var(--sticky-line);
  position: relative;
  z-index: 1;
}

.sticky-brand {
  display: flex;
  align-items: center;
  gap: 0.45rem;
}

.sticky-brand h1 {
  margin: 0;
  font-family: var(--font-hand);
  font-size: 2rem;
  font-weight: 700;
  line-height: 1;
}

.sticky-pin {
  font-size: 1.35rem;
  transform: rotate(-12deg);
}

.sticky-topbar-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.45rem;
}

.mode-toggle {
  display: inline-flex;
  padding: 0.2rem;
  border-radius: 999px;
  background: rgba(42, 36, 16, 0.08);
  border: 1px solid var(--border);
}

.mode-btn {
  border: 0;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 0.82rem;
  font-weight: 800;
  padding: 0.45rem 0.85rem;
  border-radius: 999px;
  cursor: pointer;
}

.mode-btn.is-active[data-mode="working"] {
  background: linear-gradient(130deg, #3aa583, var(--primary-deep));
  color: #fff;
  box-shadow: 0 4px 12px rgba(31, 115, 91, 0.28);
}

.mode-btn.is-active[data-mode="break"] {
  background: linear-gradient(130deg, #8b9fd8, #5a6fb8);
  color: #fff;
  box-shadow: 0 4px 12px rgba(74, 90, 160, 0.28);
}

.btn {
  border: 1px solid var(--border);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.72);
  color: var(--ink);
  font: inherit;
  font-size: 0.82rem;
  font-weight: 700;
  padding: 0.48rem 0.9rem;
  cursor: pointer;
}

.btn:hover:not(:disabled) {
  filter: brightness(1.03);
}

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.btn-primary {
  border-color: var(--primary-deep);
  background: linear-gradient(130deg, var(--primary), var(--primary-deep));
  color: #fff;
}

.btn-secondary {
  background: rgba(255, 255, 255, 0.85);
}

.btn-danger {
  border-color: #d88989;
  background: #fff0f0;
  color: var(--danger);
}

.btn-ghost {
  border-color: transparent;
  background: rgba(255, 255, 255, 0.35);
  min-width: 2rem;
  padding-inline: 0.55rem;
}

.btn-small {
  font-size: 0.76rem;
  padding: 0.38rem 0.72rem;
}

.sticky-zone {
  display: grid;
  grid-template-rows: auto 1fr;
  min-height: 0;
  border-bottom: 2px dashed var(--sticky-line);
  position: relative;
  z-index: 1;
  transition: background 0.2s ease;
}

.sticky-zone {
  cursor: pointer;
}

.sticky-zone.is-selected {
  background: rgba(47, 143, 114, 0.08);
}

body.mode-break .sticky-zone.is-selected {
  background: rgba(90, 111, 184, 0.1);
}

.zone-head {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.45rem 0.75rem 0.25rem;
}

.zone-label {
  font-family: var(--font-hand);
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--muted);
  min-width: 4.2rem;
}

.sticky-zone-giant .zone-label { font-size: 1.55rem; color: #8a4b12; }
.sticky-zone-middle .zone-label { color: #5a6a2a; }
.sticky-zone-bottom .zone-label { font-size: 1.2rem; color: #4a5a72; }

.zone-task-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  flex: 1;
  min-width: 0;
}

.zone-tab {
  border: 1px solid var(--border);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.55);
  color: var(--ink);
  font: inherit;
  font-size: 0.72rem;
  font-weight: 700;
  padding: 0.28rem 0.62rem;
  cursor: pointer;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.zone-tab.is-active {
  border-color: var(--primary-deep);
  background: #fff;
  box-shadow: 0 0 0 2px rgba(47, 143, 114, 0.16);
}

body.mode-break .zone-tab.is-active {
  border-color: #5a6fb8;
  box-shadow: 0 0 0 2px rgba(90, 111, 184, 0.18);
}

.zone-body {
  padding: 0.15rem 1rem 0.65rem;
  display: grid;
  align-content: start;
  gap: 0.35rem;
  min-height: 0;
}

.zone-task-name {
  margin: 0;
  font-family: var(--font-hand);
  font-weight: 700;
  line-height: 1.15;
  outline: none;
  border-radius: 8px;
  padding: 0.15rem 0.25rem;
}

.sticky-zone-giant .zone-task-name { font-size: clamp(2rem, 5vw, 2.8rem); }
.sticky-zone-middle .zone-task-name { font-size: clamp(1.55rem, 3.5vw, 2.1rem); }
.sticky-zone-bottom .zone-task-name { font-size: clamp(1.25rem, 2.8vw, 1.65rem); }

.zone-task-name:focus {
  background: rgba(255, 255, 255, 0.45);
  box-shadow: inset 0 0 0 2px rgba(47, 143, 114, 0.25);
}

.zone-times,
.session-line,
.muted {
  color: var(--muted);
}

.zone-times {
  margin: 0;
  font-size: 0.82rem;
  font-weight: 700;
}

.sticky-footer {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.65rem 1rem 0.85rem;
  position: relative;
  z-index: 1;
}

.session-line {
  margin: 0;
  font-size: 0.84rem;
  font-weight: 700;
}

/* ===== Subtasks (borrowed from Totem) ===== */
.subtasks-section {
  width: min(920px, 96vw);
}

.panel {
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.94);
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.22);
}

.panel-head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.65rem;
  padding: 0.85rem 1rem 0.35rem;
}

.panel-head h2 {
  margin: 0.1rem 0 0;
  font-size: 1.15rem;
}

.kicker {
  margin: 0;
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--primary-deep);
}

.subtasks-context {
  margin: 0;
  padding: 0.55rem 1rem 0;
  font-size: 0.82rem;
  line-height: 1.35;
}

.subtasks-list {
  list-style: none;
  margin: 0;
  padding: 0.85rem 1rem;
  display: grid;
  gap: 0.55rem;
  max-height: 360px;
  overflow: auto;
}

.subtask-row {
  display: grid;
  grid-template-columns: auto auto 1fr;
  gap: 0.55rem;
  align-items: center;
  padding: 0.65rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: #fff;
  cursor: grab;
  text-align: left;
}

.subtask-row.dragging { opacity: 0.55; cursor: grabbing; }
.subtask-row.drop-target { border-color: #7ec4ad; box-shadow: 0 0 0 2px rgba(31, 115, 91, 0.18); }
.subtask-row.selected { border-color: #7ec4ad; box-shadow: 0 0 0 2px rgba(31, 115, 91, 0.14); }
.subtask-row.completed .subtask-text { text-decoration: line-through; color: var(--muted); }
.subtask-row.is-done { opacity: 0.5; }
.subtask-row.is-upcoming { opacity: 0.62; }
.subtask-row.is-current {
  border-color: var(--primary-deep);
  border-left-width: 4px;
  background: linear-gradient(120deg, #f1fbf7 0%, #e6f6ef 100%);
  box-shadow: 0 0 0 2px rgba(47, 143, 114, 0.18);
}
.subtask-row.is-current .subtask-text { font-weight: 800; color: #16493a; }
.subtask-row.is-current::after {
  content: "now";
  margin-left: auto;
  font-size: 0.6rem;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--primary-deep);
}

.subtask-drag-handle {
  color: var(--primary);
  font-weight: 900;
  cursor: grab;
  user-select: none;
}

.subtask-check {
  width: 2rem;
  height: 2rem;
  border-radius: 999px;
  border: 2px solid #a7d5c5;
  background: #f4fbf8;
  font-size: 1.05rem;
  cursor: pointer;
  display: grid;
  place-items: center;
}

.subtask-check.checked {
  background: linear-gradient(130deg, var(--primary), var(--primary-deep));
  border-color: var(--primary-deep);
  color: #fff;
}

.subtask-text {
  font-size: 0.92rem;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.subtasks-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  padding: 0.75rem 1rem 0.9rem;
  border-top: 1px solid var(--border);
}

.subtasks-actions .btn { flex: 1 1 7rem; min-width: 0; }
.subtasks-empty {
  margin: 0;
  padding: 0.5rem 0;
  color: var(--muted);
  font-size: 0.85rem;
  text-align: center;
}

.subtask-import-task-label {
  margin: 0;
  padding: 0.55rem 0.7rem;
  border: 1px dashed #a7d5c5;
  border-radius: 12px;
  background: #f7fcfa;
  font-size: 0.84rem;
  font-weight: 700;
  color: #1d6652;
}

.subtask-import-chunk-row {
  display: grid;
  gap: 0.28rem;
  font-size: 0.8rem;
  color: var(--muted);
  max-width: 10rem;
}

.subtask-import-chunk-row input { width: 100%; }

/* ===== Modals ===== */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  padding: 1rem;
  background: rgba(20, 16, 8, 0.55);
}

.modal-backdrop.hidden { display: none; }

.modal {
  width: min(540px, calc(100vw - 2rem));
  max-height: calc(100vh - 2rem);
  overflow: auto;
  border-radius: 18px;
  background: #fff;
  padding: 1.2rem 1.25rem 1.1rem;
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.28);
}

.modal h2 { margin: 0 0 0.65rem; font-size: 1.25rem; }

.field {
  display: grid;
  gap: 0.35rem;
  font-size: 0.84rem;
  font-weight: 700;
}

.field input,
.transfer-textarea {
  font: inherit;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 0.65rem 0.75rem;
}

.transfer-textarea {
  width: 100%;
  min-height: 220px;
  resize: vertical;
  margin-top: 0.65rem;
}

.modal-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  justify-content: flex-end;
  margin-top: 0.85rem;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 1.25rem;
  transform: translateX(-50%);
  z-index: 120;
  padding: 0.65rem 1rem;
  border-radius: 999px;
  background: rgba(20, 16, 8, 0.92);
  color: #fff;
  font-size: 0.84rem;
  font-weight: 700;
}

.toast.hidden { display: none; }

@media (max-width: 640px) {
  .sticky-note {
    min-height: auto;
    grid-template-rows: auto auto auto auto auto;
  }

  .sticky-topbar {
    flex-direction: column;
    align-items: stretch;
  }

  .sticky-topbar-actions {
    justify-content: space-between;
  }
}
