/* Today — zen warm-paper design system.
   One column, mobile-first; desktop is the same column centered. */

:root {
  --paper:       #F7F2E9;
  --paper-deep:  #EFE7D7;
  --card:        #FDFAF3;
  --ink:         #2C2620;
  --ink-soft:    #6E6455;
  --ink-faint:   #A79C89;
  --line:        #E4DBC8;
  --accent:      #B4552D;
  --accent-soft: #F0DDD2;
  --sage:        #7D8B74;
  --sage-soft:   #E4E8DF;
  --danger:      #A03B2E;

  --font: 'Lora', Georgia, 'Times New Roman', serif;
  --shadow: 0 1px 2px rgba(44, 38, 32, 0.06);
  --radius: 12px;
  --col: 28rem;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html { height: 100%; }

body {
  min-height: 100dvh;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font);
  font-size: 17px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  padding-left: env(safe-area-inset-left);
  padding-right: env(safe-area-inset-right);
}

button {
  font: inherit;
  color: inherit;
  background: none;
  border: none;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

input, textarea {
  font: inherit;
  color: inherit;
}

/* ------------------------------------------------------------------ layout */

#app {
  max-width: var(--col);
  margin: 0 auto;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  /* room for the fixed bottom bar */
  padding-bottom: calc(76px + env(safe-area-inset-bottom));
}

.top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 20px 8px;
  padding-top: calc(20px + env(safe-area-inset-top));
}

.wordmark {
  font-size: 28px;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.wordmark .dot { color: var(--accent); }

.history-actions { display: flex; gap: 4px; }

.icon-btn {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  border-radius: 10px;
  color: var(--ink-soft);
}

.icon-btn:disabled { color: var(--ink-faint); opacity: 0.5; cursor: default; }
.icon-btn:not(:disabled):active { background: var(--paper-deep); }
.icon-btn svg { width: 22px; height: 22px; }

main { flex: 1; padding: 4px 20px 24px; }

.view-sub {
  font-style: italic;
  color: var(--ink-soft);
  font-size: 14px;
  margin: 8px 0 16px;
}

/* -------------------------------------------------------------- bottom bar */

.bottom-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--card);
  border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
}

.bottom-bar-inner {
  max-width: var(--col);
  margin: 0 auto;
  display: flex;
  align-items: stretch;
}

.tab {
  flex: 1;
  min-height: 56px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  font-size: 12px;
  color: var(--ink-soft);
  text-decoration: none;
  position: relative;
}

.tab.active { color: var(--accent); font-weight: 600; }
.tab svg { width: 22px; height: 22px; }

.tab .badge {
  position: absolute;
  top: 6px;
  right: calc(50% - 22px);
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 9px;
  background: var(--accent);
  color: var(--card);
  font-size: 11px;
  font-weight: 600;
  display: grid;
  place-items: center;
  line-height: 1;
}

/* --------------------------------------------------------------- quick add */

.quick-add {
  display: flex;
  gap: 8px;
  margin: 8px 0 20px;
}

.quick-add input {
  flex: 1;
  min-height: 48px;
  padding: 0 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--card);
  box-shadow: var(--shadow);
}

.quick-add input::placeholder { color: var(--ink-faint); font-style: italic; }
.quick-add input:focus { outline: 2px solid var(--accent); outline-offset: -1px; border-color: transparent; }

.quick-add button {
  min-width: 48px;
  min-height: 48px;
  border-radius: var(--radius);
  background: var(--accent);
  color: var(--card);
  font-size: 24px;
  line-height: 1;
}

.quick-add button:active { filter: brightness(0.92); }

/* -------------------------------------------------------------- task lists */

.task-list { list-style: none; display: flex; flex-direction: column; gap: 8px; }

.task-row {
  display: flex;
  align-items: center;
  gap: 4px;
  min-height: 52px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 6px 6px 6px 4px;
}

.task-row.dragging {
  position: relative;
  z-index: 5;
  box-shadow: 0 6px 18px rgba(44, 38, 32, 0.18);
  transition: none;
}

.reordering .task-row { transition: transform 140ms ease; }
.reordering .task-row.dragging { transition: none; }

.check {
  width: 44px;
  height: 44px;
  flex: none;
  display: grid;
  place-items: center;
}

.check .ring {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: 2px solid var(--ink-faint);
  display: grid;
  place-items: center;
  transition: border-color 120ms ease, background 120ms ease;
}

.check:active .ring { border-color: var(--sage); }

.task-row.done .check .ring,
.check.checked .ring {
  border-color: var(--sage);
  background: var(--sage);
}

.check svg { width: 14px; height: 14px; color: var(--card); opacity: 0; }
.task-row.done .check svg, .check.checked svg { opacity: 1; }

.task-body {
  flex: 1;
  min-width: 0;
  text-align: left;
  padding: 4px 0;
}

.task-title { overflow-wrap: break-word; }

.task-row.done .task-title {
  text-decoration: line-through;
  color: var(--ink-faint);
}

.tag-row { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 2px; }

.tag-chip {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 1px 7px;
  border-radius: 7px;
}

/* Muted pigments, assigned by hashing the tag name (classes t0..t5). */
.tag-chip.t0 { color: #9A5F3C; background: rgba(193, 123, 84, 0.14); }
.tag-chip.t1 { color: #6D7A46; background: rgba(138, 154, 91, 0.14); }
.tag-chip.t2 { color: #62658A; background: rgba(123, 126, 156, 0.14); }
.tag-chip.t3 { color: #815F6C; background: rgba(150, 112, 126, 0.14); }
.tag-chip.t4 { color: #94763A; background: rgba(185, 148, 80, 0.16); }
.tag-chip.t5 { color: #617175; background: rgba(124, 139, 143, 0.14); }

.drag-handle {
  width: 44px;
  height: 44px;
  flex: none;
  display: grid;
  place-items: center;
  color: var(--ink-faint);
  cursor: grab;
  touch-action: none;
  border-radius: 8px;
}

.drag-handle:active { cursor: grabbing; color: var(--ink-soft); }
.drag-handle svg { width: 18px; height: 18px; }

/* ------------------------------------------------------ inbox sorting board */

.board { padding-bottom: 8px; }

.board .section-label { margin: 24px 0 8px; }
.board .section-label:first-child { margin-top: 4px; }

/* An empty list is a quiet, always-present shelf — a stable drop target
   whose geometry never changes mid-drag. */
.board .task-list:empty {
  min-height: 52px;
  border: 1px dashed var(--line);
  border-radius: var(--radius);
}

.board.reordering .task-list:empty { border-color: var(--ink-faint); }

/* Landing shadow while dragging: shows exactly where the row will drop.
   Page-coordinate absolute so it survives autoscroll; sits under the
   floating row (z-index 5) but over resting rows. */
.drop-ghost {
  position: absolute;
  z-index: 4;
  pointer-events: none;
  border: 2px dashed var(--accent);
  border-radius: var(--radius);
  background: var(--accent-soft);
  opacity: 0.55;
  transition: top 140ms ease, left 140ms ease, width 140ms ease;
}

/* ------------------------------------------------------------ done section */

.section-label {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-faint);
  margin: 28px 0 8px;
}

.done-day { margin-bottom: 20px; }

/* -------------------------------------------------------------- sort view */

.sort-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: 0 2px 8px rgba(44, 38, 32, 0.08);
  padding: 32px 24px;
  margin: 24px 0 20px;
  text-align: center;
}

.sort-card .origin {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-faint);
  margin-bottom: 12px;
}

.sort-card .title { font-size: 21px; line-height: 1.4; }
.sort-card .tag-row { justify-content: center; margin-top: 10px; }

.sort-actions { display: flex; flex-direction: column; gap: 8px; }

.sort-actions .row { display: flex; gap: 8px; }

.sort-btn {
  flex: 1;
  min-height: 52px;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: var(--card);
  box-shadow: var(--shadow);
  font-weight: 600;
}

.sort-btn:active { background: var(--paper-deep); }
.sort-btn.primary { background: var(--accent); border-color: var(--accent); color: var(--card); }
.sort-btn.quiet { color: var(--ink-soft); font-weight: 400; }
.sort-btn.danger { color: var(--danger); font-weight: 400; }

.sort-progress {
  text-align: center;
  font-size: 13px;
  color: var(--ink-faint);
  margin-bottom: 8px;
}

/* ------------------------------------------------------------ empty states */

.empty-state {
  text-align: center;
  padding: 56px 24px;
  color: var(--ink-soft);
  font-style: italic;
}

.empty-state .enso {
  width: 64px;
  height: 64px;
  margin: 0 auto 16px;
  color: var(--ink-faint);
}

.empty-state .hint { font-size: 14px; color: var(--ink-faint); margin-top: 6px; }

/* ----------------------------------------------------------------- buttons */

.primary, .ghost, .danger-primary, .pill-btn {
  min-height: 48px;
  padding: 0 20px;
  border-radius: var(--radius);
  font-weight: 600;
}

.primary { background: var(--accent); color: var(--card); }
.primary:active { filter: brightness(0.92); }

.ghost { border: 1px solid var(--line); background: var(--card); color: var(--ink-soft); }
.ghost:active { background: var(--paper-deep); }

.danger-primary { background: var(--danger); color: var(--card); }

.block-btn { display: block; width: 100%; margin: 16px 0; }

.link-btn {
  color: var(--accent);
  font-weight: 600;
  min-height: 44px;
  padding: 0 8px;
}

/* ------------------------------------------------------------------ drawer */

.drawer-wrap { position: fixed; inset: 0; z-index: 20; }

.drawer-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(44, 38, 32, 0.28);
}

.drawer {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  max-width: var(--col);
  margin: 0 auto;
  background: var(--card);
  border-radius: 16px 16px 0 0;
  border: 1px solid var(--line);
  border-bottom: none;
  padding: 20px 20px calc(20px + env(safe-area-inset-bottom));
  box-shadow: 0 -4px 24px rgba(44, 38, 32, 0.12);
  max-height: 85dvh;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.drawer h3 { font-size: 18px; margin-bottom: 16px; }

.drawer-menu { display: flex; flex-direction: column; }

.drawer-item {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 52px;
  text-align: left;
  border-bottom: 1px solid var(--line);
  color: var(--ink);
}

.drawer-item:last-child { border-bottom: none; }
.drawer-item:active { background: var(--paper); }
.drawer-item svg { width: 20px; height: 20px; color: var(--ink-soft); flex: none; }
.drawer-item .meta { margin-left: auto; font-size: 13px; color: var(--ink-faint); }
.drawer-item.danger, .drawer-item.danger svg { color: var(--danger); }

.field { margin-bottom: 16px; }

.field label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-faint);
  margin-bottom: 6px;
}

.field input {
  width: 100%;
  min-height: 48px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--paper);
}

.field input:focus { outline: 2px solid var(--accent); outline-offset: -1px; }

.move-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 16px; }

.move-grid .ghost.current { outline: 2px solid var(--accent); color: var(--ink); }

.drawer-footer { display: flex; gap: 8px; margin-top: 8px; }
.drawer-footer .ghost { flex: 1; }

/* ------------------------------------------------------------------- modal */

.modal-wrap { position: fixed; inset: 0; z-index: 30; display: grid; place-items: center; padding: 24px; }

.modal-backdrop { position: absolute; inset: 0; background: rgba(44, 38, 32, 0.32); }

.modal-dialog {
  position: relative;
  width: 100%;
  max-width: 22rem;
  background: var(--card);
  border-radius: 16px;
  padding: 24px;
  box-shadow: 0 8px 32px rgba(44, 38, 32, 0.2);
}

.modal-dialog h3 { margin-bottom: 8px; }
.modal-dialog p { color: var(--ink-soft); font-size: 15px; }

.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 20px; }

/* ------------------------------------------------------------------- toast */

.toast {
  position: fixed;
  bottom: calc(88px + env(safe-area-inset-bottom));
  left: 50%;
  transform: translateX(-50%);
  background: var(--ink);
  color: var(--paper);
  font-size: 14px;
  padding: 10px 18px;
  border-radius: 999px;
  box-shadow: 0 4px 16px rgba(44, 38, 32, 0.25);
  z-index: 40;
  white-space: nowrap;
}

/* ------------------------------------------------------------ activity log */

.log-list { list-style: none; display: flex; flex-direction: column; }

.log-entry {
  display: flex;
  gap: 12px;
  align-items: baseline;
  padding: 10px 4px;
  border-bottom: 1px solid var(--line);
  font-size: 15px;
}

.log-entry:last-child { border-bottom: none; }

.log-time {
  flex: none;
  width: 42px;
  font-size: 12px;
  color: var(--ink-faint);
  font-variant-numeric: tabular-nums;
}

.log-text { color: var(--ink-soft); }

/* --------------------------------------------------------------- utilities */

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}
