:root {
  --yellow: #f7c948;
  --yellow-soft: #fdf0c2;
  --bg: #fdf6e3;
  --panel: #ffffff;
  --ink: #2d2a26;
  --ink-soft: #6b655c;
  --line: #e8e0cc;
  --accent: #b7791f;
  --danger: #b54708;
  --radius: 10px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; height: 100%; }
body {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--ink);
  font-size: 16px;
}
#app { height: 100dvh; display: flex; flex-direction: column; }
button { font: inherit; cursor: pointer; }
input, select { font: inherit; }

/* ---------- header / tabs ---------- */
header.topbar {
  background: var(--yellow);
  padding: env(safe-area-inset-top) 0 0;
  box-shadow: 0 1px 4px rgba(0,0,0,.15);
  flex-shrink: 0;
}
.topbar-row { display: flex; align-items: center; gap: 4px; padding: 6px 10px 0; }
.topbar-row h1 { font-size: 18px; margin: 0 auto 0 0; letter-spacing: .3px; }
.icon-btn {
  background: none; border: none; padding: 6px 8px; border-radius: 8px; font-size: 17px;
}
.icon-btn:active { background: rgba(0,0,0,.08); }
nav.tabs { display: flex; }
nav.tabs button {
  flex: 1; background: none; border: none; padding: 10px 4px 12px;
  font-size: 15px; font-weight: 600; color: #5c4d1f; border-bottom: 3px solid transparent;
}
nav.tabs button.active { color: var(--ink); border-bottom-color: var(--ink); }

/* ---------- group bar ---------- */
.module-wrap { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.group-bar { position: relative; background: #faf3da; border-bottom: 1px solid var(--line); flex-shrink: 0; }
.group-bar-row { display: flex; align-items: center; gap: 12px; padding-right: 12px; }
.group-btn {
  flex: 1; min-width: 0; display: flex; align-items: center; gap: 10px;
  background: none; border: none; padding: 10px 14px; text-align: left;
}
.bar-action {
  visibility: visible; width: 42px; height: 42px; flex-shrink: 0;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 17px; padding: 0; background: #fff;
  border: 1px solid var(--line); border-radius: 10px;
}
.bar-action:active { background: var(--yellow-soft); }
.bar-action:disabled { opacity: .35; }
.group-btn .group-label {
  font-size: 11px; text-transform: uppercase; letter-spacing: .8px; color: var(--ink-soft);
}
.group-btn .group-name { font-weight: 700; font-size: 15px; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.group-btn .caret { color: var(--accent); }
.group-drop {
  position: absolute; top: 100%; left: 8px; right: 8px; z-index: 40;
  background: #fff; border: 1px solid var(--line); border-radius: 0 0 12px 12px;
  box-shadow: 0 10px 30px rgba(0,0,0,.18); max-height: 50dvh; overflow-y: auto; padding: 6px;
}
.group-drop .nav-list { padding: 4px; display: flex; flex-direction: column; gap: 10px; }
.group-drop .nav-list li { margin: 0; }
.group-drop .nav-list li > button.name {
  display: block; width: 100%; height: 48px; padding: 0 14px;
  background: #fff; border: 1px solid var(--line); border-radius: 10px;
  font-size: 15px; text-align: left;
}
.group-drop .nav-list li.selected > button.name {
  background: var(--yellow-soft); border-color: var(--yellow); font-weight: 700;
}
.group-drop .nav-list li > button.name:active { background: var(--yellow-soft); }
.group-add {
  width: 100%; background: none; border: none; border-top: 1px solid var(--line);
  padding: 11px; color: var(--accent); font-weight: 700; text-align: left;
}

/* ---------- layout panes ---------- */
main { flex: 1; min-height: 0; display: flex; }
.pane { display: flex; flex-direction: column; min-height: 0; overflow: hidden; }
.pane-lists { width: 230px; border-right: 1px solid var(--line); background: #fcf8ea; }
.pane-title {
  font-size: 12px; text-transform: uppercase; letter-spacing: .8px; color: var(--ink-soft);
  margin: 0; padding: 10px 12px 6px; display: flex; align-items: center; justify-content: space-between;
}
.pane-add { border: none; background: none; color: var(--accent); font-size: 18px; line-height: 1; padding: 0 2px; }
.pane-content { flex: 1; background: var(--panel); }
.pane h2 {
  font-size: 12px; text-transform: uppercase; letter-spacing: .8px; color: var(--ink-soft);
  margin: 0; padding: 10px 12px 6px; display: flex; align-items: center; justify-content: space-between;
}
.pane h2 button { border: none; background: none; color: var(--accent); font-size: 18px; line-height: 1; padding: 0 2px; }
.pane ul.nav-list { list-style: none; margin: 0; padding: 0 6px 10px; overflow-y: auto; flex: 1; }
.pane ul.nav-list li {
  display: flex; align-items: center; border-radius: 8px; margin-bottom: 2px;
}
.pane ul.nav-list li > button.name {
  flex: 1; text-align: left; background: none; border: none; padding: 9px 10px;
  border-radius: 8px; color: var(--ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.pane ul.nav-list li.selected { background: var(--yellow-soft); }
.pane ul.nav-list li.selected > button.name { font-weight: 600; }
.pane ul.nav-list li .row-menu { visibility: hidden; }
.pane ul.nav-list li:hover .row-menu, .pane ul.nav-list li.selected .row-menu { visibility: visible; }
.row-menu { background: none; border: none; color: var(--ink-soft); padding: 4px 8px; font-size: 15px; }

/* mobile: drill-down panes */
.mobile-back {
  display: none; background: none; border: none; color: var(--accent);
  font-size: 14px; font-weight: 600; text-align: left; padding: 10px 12px 0;
}
@media (max-width: 760px) {
  .pane-lists, .pane-content { width: 100%; }
  .pane { display: none; }
  .pane.mobile-visible { display: flex; }
  .mobile-back { display: block; }
}

/* ---------- content area ---------- */
.content-head {
  padding: 10px 14px 8px; border-bottom: 1px solid var(--line);
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
}
.content-head .title { font-weight: 700; font-size: 16px; margin-right: auto; }
.chip {
  border: 1px solid var(--line); background: #fff; border-radius: 999px;
  padding: 4px 12px; font-size: 13px; color: var(--ink-soft);
}
.chip.on { background: var(--yellow-soft); border-color: var(--yellow); color: var(--ink); font-weight: 600; }
.scroll-body { flex: 1; overflow-y: auto; padding: 8px 10px 90px; }

.empty-note { color: var(--ink-soft); text-align: center; padding: 40px 20px; font-size: 14px; }

/* ---------- tasks & items ---------- */
ul.entry-list { list-style: none; margin: 0; padding: 0; }
li.entry { display: flex; align-items: flex-start; gap: 8px; padding: 7px 6px; border-radius: 8px; }
li.entry:hover { background: #fbf7ec; }
li.entry.sub { margin-left: 34px; }
li.entry .text { flex: 1; line-height: 1.35; padding-top: 2px; overflow-wrap: anywhere; }
li.entry .text a { color: var(--accent); text-decoration: underline; overflow-wrap: anywhere; }
li.entry .yt-title { font-weight: 600; margin-right: 6px; }
.status-done > .text { text-decoration: line-through; color: var(--ink-soft); }
.status-cancelled > .text { text-decoration: line-through wavy; color: var(--ink-soft); }

.check {
  width: 24px; height: 24px; flex-shrink: 0; border-radius: 6px; border: 2px solid #cbc2ab;
  background: #fff; display: inline-flex; align-items: center; justify-content: center;
  font-size: 15px; line-height: 1; padding: 0; margin-top: 1px;
}
.check.done { background: var(--yellow); border-color: var(--yellow); }
.entry .actions { display: flex; gap: 2px; visibility: hidden; }
.entry:hover .actions, .entry.menu-open .actions { visibility: visible; }
@media (pointer: coarse) { .entry .actions { visibility: visible; } }
.entry .actions button { background: none; border: none; color: var(--ink-soft); padding: 3px 6px; font-size: 14px; border-radius: 6px; }
.entry .actions button:active { background: var(--yellow-soft); }

/* add row pinned at bottom of content */
.add-row {
  position: sticky; bottom: 0; display: flex; gap: 8px; padding: 10px;
  background: linear-gradient(transparent, var(--panel) 30%);
}
.add-row input[type=text] {
  flex: 1; padding: 11px 12px; border: 1px solid var(--line); border-radius: var(--radius);
  background: #fff; box-shadow: 0 2px 8px rgba(0,0,0,.06);
}
.add-row button.primary { min-width: 46px; }

button.primary {
  background: var(--yellow); color: var(--ink); border: none; border-radius: var(--radius);
  padding: 10px 16px; font-weight: 700; box-shadow: 0 1px 3px rgba(0,0,0,.15);
}
button.primary:disabled { opacity: .5; }
button.ghost { background: none; border: 1px solid var(--line); border-radius: var(--radius); padding: 9px 14px; color: var(--ink); }

/* ---------- reminders ---------- */
.subtabs { display: flex; gap: 6px; padding: 10px 12px 0; }
.subtabs button {
  border: 1px solid var(--line); background: #fff; border-radius: 999px; padding: 6px 16px; font-size: 14px; font-weight: 600; color: var(--ink-soft);
}
.subtabs button.active { background: var(--yellow); border-color: var(--yellow); color: var(--ink); }
.daily-section h3 {
  font-size: 13px; text-transform: uppercase; letter-spacing: .6px; color: var(--ink-soft);
  margin: 18px 6px 6px; border-bottom: 1px solid var(--line); padding-bottom: 4px;
}
.pill { font-size: 11px; border-radius: 999px; padding: 2px 8px; background: var(--yellow-soft); color: #7a6420; margin-left: 8px; white-space: nowrap; }
.pill.overdue { background: #fde3d1; color: var(--danger); }
.entry .meta { font-size: 12px; color: var(--ink-soft); margin-top: 2px; }

/* ---------- forms / modals ---------- */
.modal-back {
  position: fixed; inset: 0; background: rgba(45,42,38,.45); display: flex;
  align-items: center; justify-content: center; z-index: 50; padding: 16px;
}
.modal {
  background: #fff; border-radius: 14px; padding: 18px; width: 100%; max-width: 420px;
  box-shadow: 0 12px 40px rgba(0,0,0,.25); max-height: 90dvh; overflow-y: auto;
}
.modal h3 { margin: 0 0 14px; font-size: 17px; }
.modal label { display: block; font-size: 13px; font-weight: 600; color: var(--ink-soft); margin: 12px 0 4px; }
.modal input[type=text], .modal input[type=password], .modal input[type=date], .modal input[type=time], .modal select {
  width: 100%; padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px; background: #fff;
}
.modal .btn-row { display: flex; gap: 10px; justify-content: flex-end; margin-top: 18px; }
.modal .danger { color: var(--danger); border-color: #f3cdb5; margin-right: auto; }
.error-note { color: var(--danger); font-size: 14px; margin-top: 10px; }
.trash-row { display: flex; align-items: center; gap: 8px; padding: 6px 0; border-bottom: 1px solid var(--line); }
.trash-row .trash-name { flex: 1; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.trash-row button { padding: 5px 10px; font-size: 13px; }
.trash-row .danger { margin-right: 0; }

/* ---------- login ---------- */
.login-wrap { height: 100dvh; display: flex; align-items: center; justify-content: center; background: var(--bg); padding: 20px; }
.postit {
  background: var(--yellow); width: 100%; max-width: 360px; padding: 26px 24px 30px;
  border-radius: 4px; box-shadow: 4px 8px 18px rgba(0,0,0,.25); transform: rotate(-1.2deg);
}
.postit h1 { margin: 0 0 4px; font-size: 26px; }
.postit p { margin: 0 0 18px; color: #5c4d1f; font-size: 14px; }
.postit input {
  width: 100%; padding: 12px; border: none; border-radius: 8px; margin-bottom: 10px;
  background: rgba(255,255,255,.85); font-size: 16px;
}
.postit button { width: 100%; }

/* share banner */
.share-banner {
  background: var(--yellow-soft); border-bottom: 1px solid var(--yellow);
  padding: 10px 14px; font-size: 14px; display: flex; align-items: center; gap: 8px;
}
.share-banner .shared-text { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
.share-banner button { border: none; background: none; color: var(--accent); font-weight: 700; }

.toast {
  position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%);
  background: var(--ink); color: #fff; border-radius: 999px; padding: 9px 18px; font-size: 14px;
  z-index: 60; box-shadow: 0 4px 14px rgba(0,0,0,.3);
}
