:root {
  --bg: #faf7f2;
  --card: #ffffff;
  --ink: #2b2733;
  --ink-soft: #8a8494;
  --line: #e9e4db;
  --accent: #b45a12;
  --accent-ink: #fff6e6;
  --accent-grad: linear-gradient(165deg, #2e1509 0%, #8a4210 55%, #d4831f 100%);
  --today: #b45a12;
  --later: #7695a0;
  --someday: #7d9b76;
  --delete: #b05656;
  --done: #a8a2b0;
  --shadow: 0 2px 12px rgba(43, 39, 51, 0.07);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #17161a;
    --card: #211f26;
    --ink: #eae7ef;
    --ink-soft: #8d8798;
    --line: #322f39;
    --accent: #e89a35;
    --accent-ink: #2a1503;
    --accent-grad: linear-gradient(165deg, #452209 0%, #a85413 55%, #e89a35 100%);
    --today: #c9721a;
    --later: #8fb0ba;
    --someday: #94b48c;
    --delete: #cf7a7a;
    --done: #5c5766;
    --shadow: 0 2px 12px rgba(0, 0, 0, 0.35);
  }
}

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

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}

#app {
  max-width: 480px;
  margin: 0 auto;
  padding: calc(env(safe-area-inset-top) + 20px) 20px 140px;
}

.hidden { display: none !important; }

/* ---- Today ---- */
.day-header { position: relative; margin-bottom: 24px; }
.day-header h1 { font-size: 2rem; font-weight: 700; letter-spacing: -0.02em; }
.day-date { color: var(--ink-soft); font-size: 0.95rem; margin-top: 2px; }
.day-phrase {
  display: block;
  background: none; border: none; cursor: pointer;
  text-align: left; padding: 0;
  margin-top: 14px;
  color: var(--ink-soft);
  font-family: inherit;
  font-size: 0.92rem; font-style: italic; line-height: 1.5;
  max-width: 34ch;
}

.icon-btn {
  position: absolute; top: 4px; right: 0;
  background: none; border: none; color: var(--ink-soft);
  font-size: 1.3rem; padding: 8px; cursor: pointer;
}
.triage-header .icon-btn { position: static; margin-right: 8px; }

.triage-banner, .sweep-banner {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 16px;
  margin-bottom: 20px;
  box-shadow: var(--shadow);
}
.triage-banner p, .sweep-banner p { margin-bottom: 12px; color: var(--ink); }
.sweep-banner p { color: var(--ink-soft); font-size: 0.92rem; }
.sweep-actions { display: flex; gap: 8px; }

.today-list { list-style: none; display: flex; flex-direction: column; gap: 12px; }

.today-item {
  display: flex; align-items: center; gap: 14px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 18px 16px;
  box-shadow: var(--shadow);
}
.today-item .check {
  flex: none;
  width: 28px; height: 28px;
  border: 2px solid var(--ink-soft);
  border-radius: 50%;
  background: none; cursor: pointer;
  font-size: 0.95rem; line-height: 1;
  color: transparent;
}
.today-item.done .check {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-ink);
}
.today-item .text { flex: 1; font-size: 1.05rem; line-height: 1.35; }
.today-item.done .text { color: var(--done); text-decoration: line-through; }
.today-item .tag {
  flex: none; font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.06em;
  color: var(--ink-soft); border: 1px solid var(--line);
  border-radius: 999px; padding: 3px 8px;
}

.empty-note {
  text-align: center; color: var(--ink-soft);
  margin-top: 48px; line-height: 1.6;
}
.done-note { text-align: center; color: var(--accent); margin-top: 28px; font-weight: 600; }

/* ---- Buttons ---- */
.btn {
  display: block; width: 100%;
  border: none; border-radius: 14px;
  padding: 15px; font-size: 1rem; font-weight: 600;
  cursor: pointer;
  color: #fff;
}
.btn + .btn { margin-top: 10px; }
.btn-primary { background: var(--accent-grad); color: #fff6e6; }
.btn-today   { background: var(--accent-grad); color: #fff6e6; }
.btn-later   { background: var(--later); }
.btn-someday { background: var(--someday); }
.btn-delete  { background: none; color: var(--delete); font-weight: 500; }
.btn-ghost   {
  background: none; color: var(--ink-soft);
  border: 1px solid var(--line); font-weight: 500;
}
.sweep-actions .btn, .shelf-footer .btn { width: auto; padding: 10px 16px; font-size: 0.9rem; margin: 0; }

/* ---- Triage ---- */
.triage-header {
  display: flex; align-items: center;
  margin-bottom: 28px;
}
.triage-progress { color: var(--ink-soft); font-size: 0.95rem; }
.triage-header h2 { font-size: 1.3rem; }

.triage-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 32px 24px;
  min-height: 180px;
  display: flex; flex-direction: column; justify-content: space-between; gap: 24px;
  box-shadow: var(--shadow);
  margin-bottom: 24px;
}
.triage-item-text { font-size: 1.35rem; line-height: 1.4; font-weight: 500; overflow-wrap: break-word; }

.chip-rows { display: flex; flex-direction: column; gap: 10px; }
.tag-row { display: flex; gap: 8px; flex-wrap: wrap; }
.triage-note {
  text-align: center; color: var(--ink-soft);
  font-size: 0.88rem; font-style: italic;
  margin-top: 28px;
}
.tag-chip {
  background: none; border: 1px solid var(--line);
  color: var(--ink-soft); border-radius: 999px;
  padding: 6px 14px; font-size: 0.85rem; cursor: pointer;
}
.tag-chip.active {
  background: var(--accent); border-color: var(--accent);
  color: var(--accent-ink);
}

/* ---- Shelf ---- */
.shelf-heading {
  font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.08em;
  color: var(--ink-soft); margin: 20px 0 10px;
}
.shelf-list { list-style: none; display: flex; flex-direction: column; gap: 8px; }
.shelf-item {
  display: flex; align-items: center; gap: 10px;
  background: var(--card); border: 1px solid var(--line);
  border-radius: 12px; padding: 12px 14px;
}
.shelf-item .text { flex: 1; font-size: 0.98rem; line-height: 1.35; overflow-wrap: anywhere; }
.shelf-item .mini {
  flex: none; background: none; border: 1px solid var(--line);
  border-radius: 8px; color: var(--ink-soft);
  padding: 6px 10px; font-size: 0.8rem; cursor: pointer;
}
.shelf-item .mini.up { color: var(--accent); border-color: var(--accent); }
.shelf-item .freq { flex: none; color: var(--ink-soft); font-size: 0.78rem; font-style: italic; }
.shelf-footer { display: flex; gap: 8px; margin-top: 32px; }
.import-label { text-align: center; cursor: pointer; }

/* ---- Capture bar ---- */
.capture-bar {
  position: fixed; bottom: 0; left: 0; right: 0;
  max-width: 480px; margin: 0 auto;
  display: flex; gap: 10px;
  padding: 14px 20px calc(env(safe-area-inset-bottom) + 14px);
  background: linear-gradient(to top, var(--bg) 75%, transparent);
}
.capture-bar input {
  flex: 1;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 14px 20px;
  font-size: 1rem;
  color: var(--ink);
  box-shadow: var(--shadow);
  outline: none;
}
.capture-bar input:focus { border-color: var(--accent); }
.capture-bar input::placeholder { color: var(--ink-soft); }
.capture-btn {
  flex: none; width: 50px; height: 50px;
  border: none; border-radius: 50%;
  background: var(--accent-grad); color: #fff6e6;
  font-size: 1.3rem; cursor: pointer;
}

/* ---- Swap sheet ---- */
.sheet {
  position: fixed; inset: 0;
  background: rgba(0, 0, 0, 0.45);
  display: flex; align-items: flex-end; justify-content: center;
  z-index: 20;
}
.sheet-panel {
  width: 100%; max-width: 480px;
  background: var(--bg);
  border-radius: 20px 20px 0 0;
  padding: 24px 20px calc(env(safe-area-inset-bottom) + 24px);
}
.sheet-title { font-weight: 600; line-height: 1.45; margin-bottom: 16px; }
.swap-list { list-style: none; margin-bottom: 16px; display: flex; flex-direction: column; gap: 8px; }
.swap-list button {
  width: 100%; text-align: left;
  background: var(--card); border: 1px solid var(--line);
  border-radius: 12px; padding: 14px; font-size: 0.95rem;
  color: var(--ink); cursor: pointer;
}
.swap-list .swap-hint { color: var(--ink-soft); font-size: 0.8rem; display: block; margin-top: 2px; }
