:root {
  --sand: #f7efe1;
  --sand-2: #f1e6d2;
  --paper: #fffaf2;
  --ink: #2c2620;
  --ink-soft: #6b6258;
  --terra: #c4623d;
  --terra-dark: #a44a29;
  --sage: #5e7359;
  --water: #3f7e8c;
  --water-deep: #2c5b66;
  --sun: #e9a23b;
  --line: #e3d6bf;
  --ok: #5e7359;
  --shadow: 0 18px 40px -22px rgba(60, 40, 20, 0.45);
  --radius: 18px;
  --display: "Fraunces", Georgia, serif;
  --body: "Hanken Grotesk", system-ui, sans-serif;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--body);
  color: var(--ink);
  background:
    radial-gradient(1200px 500px at 80% -10%, #fcefd6 0%, transparent 60%),
    radial-gradient(900px 600px at -10% 10%, #eef3ec 0%, transparent 55%),
    var(--sand);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  padding-bottom: env(safe-area-inset-bottom);
}

.grain {
  position: fixed; inset: 0; z-index: 0; pointer-events: none; opacity: 0.5;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.05'/%3E%3C/svg%3E");
  mix-blend-mode: multiply;
}

/* ---------- Hero ---------- */
.hero {
  position: relative; z-index: 1; overflow: hidden;
  background:
    linear-gradient(165deg, #f6c98a 0%, #e8975a 38%, #c4623d 100%);
  color: #fff7ec;
  padding: clamp(1.6rem, 5vw, 3.2rem) 1.25rem 0;
}
.hero__sun {
  position: absolute; top: -90px; right: -40px; width: 280px; height: 280px;
  border-radius: 50%;
  background: radial-gradient(circle at 50% 50%, #ffe9bf 0%, #ffd27e 45%, rgba(255,210,126,0) 70%);
  opacity: 0.85; animation: float 9s ease-in-out infinite;
}
@keyframes float { 0%,100% { transform: translateY(0); } 50% { transform: translateY(14px); } }
.hero__inner { position: relative; max-width: 920px; margin: 0 auto; padding-bottom: 2.4rem; }
.hero__eyebrow {
  margin: 0 0 0.35rem; font-weight: 600; letter-spacing: 0.14em; text-transform: uppercase;
  font-size: 0.72rem; opacity: 0.92;
}
.hero__title {
  margin: 0; font-family: var(--display); font-weight: 600;
  font-size: clamp(2.6rem, 9vw, 5rem); line-height: 0.95; letter-spacing: -0.02em;
  font-optical-sizing: auto; outline: none;
}
.hero__title:focus-visible { box-shadow: 0 4px 0 rgba(255,255,255,0.5); }
.hero__meta { display: flex; flex-wrap: wrap; align-items: center; gap: 0.6rem; margin-top: 1rem; }
.hero__progress { font-weight: 700; font-size: 0.9rem; opacity: 0.95; }
.hero__sync {
  margin-left: auto; font-size: 0.74rem; font-weight: 600; opacity: 0.85;
  background: rgba(255,255,255,0.18); padding: 0.2rem 0.6rem; border-radius: 999px;
  transition: opacity 0.3s;
}
.hero__sync.is-saving { opacity: 1; }
.wave {
  position: absolute; left: 0; right: 0; bottom: -1px; height: 38px;
  background:
    radial-gradient(38px 38px at 38px 0, transparent 36px, var(--sand) 37px) repeat-x;
  background-size: 76px 38px;
}

/* ---------- Tabs ---------- */
.tabs {
  position: sticky; top: 0; z-index: 5;
  display: flex; gap: 0.4rem; justify-content: center; flex-wrap: wrap;
  padding: 0.7rem 0.75rem; margin: 0 auto;
  background: color-mix(in srgb, var(--sand) 88%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.tab {
  font-family: var(--body); font-weight: 700; font-size: 0.92rem;
  border: 1.5px solid transparent; background: transparent; color: var(--ink-soft);
  padding: 0.5rem 0.95rem; border-radius: 999px; cursor: pointer;
  display: inline-flex; align-items: center; gap: 0.4rem; transition: all 0.18s;
}
.tab span { font-size: 1rem; }
.tab:hover { color: var(--ink); background: rgba(255,255,255,0.6); }
.tab.is-active {
  color: var(--terra-dark); background: var(--paper);
  border-color: var(--line); box-shadow: var(--shadow);
}

/* ---------- App layout ---------- */
.app {
  position: relative; z-index: 1;
  max-width: 920px; margin: 0 auto; padding: 1.4rem 1rem 3rem;
  animation: rise 0.5s ease both;
}
@keyframes rise { from { opacity: 0; transform: translateY(10px); } }

.toolbar {
  display: flex; gap: 0.5rem; flex-wrap: wrap; align-items: center; margin-bottom: 1.1rem;
}
.filters { display: flex; gap: 0.35rem; flex-wrap: wrap; }
.filter {
  font-family: var(--body); font-weight: 600; font-size: 0.82rem;
  border: 1.5px solid var(--line); background: var(--paper); color: var(--ink-soft);
  padding: 0.32rem 0.7rem; border-radius: 999px; cursor: pointer; transition: all 0.15s;
}
.filter.is-on { background: var(--ink); color: var(--sand); border-color: var(--ink); }
.spacer { flex: 1 1 auto; }

.bigbar {
  display: flex; align-items: center; gap: 0.8rem; margin-bottom: 1.4rem;
  background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 0.9rem 1.1rem; box-shadow: var(--shadow);
}
.bigbar__track { flex: 1; height: 12px; border-radius: 999px; background: var(--sand-2); overflow: hidden; }
.bigbar__fill { height: 100%; width: 0; border-radius: 999px;
  background: linear-gradient(90deg, var(--sage), var(--water)); transition: width 0.5s cubic-bezier(.2,.8,.2,1); }
.bigbar__num { font-family: var(--display); font-weight: 600; font-size: 1.5rem; white-space: nowrap; }
.bigbar__num small { font-family: var(--body); font-weight: 600; font-size: 0.8rem; color: var(--ink-soft); }

/* ---------- Cards / groups ---------- */
.group { margin-bottom: 1.5rem; }
.group__head {
  display: flex; align-items: baseline; gap: 0.6rem; margin: 0 0.2rem 0.6rem;
}
.group__title {
  font-family: var(--display); font-weight: 600; font-size: 1.3rem; letter-spacing: -0.01em; margin: 0;
}
.group__title.is-special { color: var(--terra-dark); }
.group__count { font-size: 0.8rem; font-weight: 700; color: var(--ink-soft); }

.list { list-style: none; margin: 0; padding: 0; display: grid; gap: 0.5rem; }
.row {
  display: flex; align-items: flex-start; gap: 0.75rem;
  background: var(--paper); border: 1px solid var(--line); border-radius: 14px;
  padding: 0.7rem 0.8rem; box-shadow: 0 6px 18px -16px rgba(60,40,20,0.5);
  transition: transform 0.12s, opacity 0.2s, background 0.2s;
}
.row:hover { transform: translateY(-1px); }
.row.is-done { opacity: 0.55; background: var(--sand-2); }
.row.is-done .row__name { text-decoration: line-through; text-decoration-color: var(--terra); }

.check {
  appearance: none; -webkit-appearance: none; flex: 0 0 auto;
  width: 24px; height: 24px; margin-top: 1px; border-radius: 8px;
  border: 2px solid var(--sage); background: transparent; cursor: pointer; position: relative;
  transition: all 0.15s;
}
.check:checked { background: var(--sage); border-color: var(--sage); }
.check:checked::after {
  content: ""; position: absolute; left: 7px; top: 3px; width: 6px; height: 11px;
  border: solid #fff; border-width: 0 3px 3px 0; transform: rotate(45deg);
}
.row__body { flex: 1; min-width: 0; }
.row__name {
  font-weight: 600; font-size: 0.98rem; line-height: 1.25; word-break: break-word;
  background: transparent; border: none; outline: none; font-family: var(--body);
  color: var(--ink); width: 100%; padding: 0;
}
.row__meta { display: flex; flex-wrap: wrap; gap: 0.35rem; margin-top: 0.35rem; align-items: center; }
.tag {
  font-size: 0.7rem; font-weight: 700; padding: 0.12rem 0.5rem; border-radius: 999px;
  background: var(--sand-2); color: var(--ink-soft); border: 1px solid var(--line);
}
.tag--who { background: #e8f0ea; color: var(--sage); border-color: #cfe0d3; }
.tag--qty { background: #eaf2f4; color: var(--water-deep); border-color: #cfe4e8; }
.tag--note { background: #fcefd9; color: var(--terra-dark); border-color: #f3dcb0; font-weight: 600; }
.tag--input { cursor: text; }
.tag--input:empty::before { content: attr(data-ph); opacity: 0.6; }
.tag.warn { background: #fde8e1; color: var(--terra-dark); border-color: #f4c9b8; }

.del {
  flex: 0 0 auto; border: none; background: transparent; color: var(--ink-soft);
  cursor: pointer; font-size: 1.1rem; line-height: 1; padding: 0.2rem 0.3rem; border-radius: 8px;
  opacity: 0.45; transition: all 0.15s;
}
.del:hover { opacity: 1; color: var(--terra-dark); background: #fbe6dd; }

/* add row */
.addrow {
  display: flex; gap: 0.5rem; margin-top: 0.5rem;
}
.addrow input {
  flex: 1; font-family: var(--body); font-size: 0.95rem; color: var(--ink);
  background: var(--paper); border: 1.5px dashed var(--line); border-radius: 12px;
  padding: 0.6rem 0.8rem; outline: none; transition: border-color 0.15s;
}
.addrow input:focus { border-color: var(--terra); border-style: solid; }
.btn {
  font-family: var(--body); font-weight: 700; font-size: 0.9rem; cursor: pointer;
  border: none; border-radius: 12px; padding: 0.55rem 1rem;
  background: var(--terra); color: #fff7ec; transition: all 0.15s; white-space: nowrap;
}
.btn:hover { background: var(--terra-dark); transform: translateY(-1px); }
.btn--ghost { background: transparent; color: var(--ink-soft); border: 1.5px solid var(--line); }
.btn--ghost:hover { background: var(--paper); color: var(--ink); }

/* Q&A (before you go) */
.qa { display: grid; gap: 0.4rem; }
.qa__q { display: flex; align-items: flex-start; gap: 0.7rem; }
.qa__a {
  margin-left: calc(24px + 0.75rem); margin-top: 0.1rem;
  font-family: var(--body); font-size: 0.92rem; color: var(--ink);
  background: var(--sand); border: 1px solid var(--line); border-left: 3px solid var(--water);
  border-radius: 10px; padding: 0.5rem 0.7rem; min-height: 1.2rem; outline: none;
}
.qa__a:empty::before { content: "Tap to write what you find out…"; color: var(--ink-soft); opacity: 0.7; }
.qa__a:focus { border-left-color: var(--terra); background: var(--paper); }

.chip {
  font-size: 0.78rem; font-weight: 700; padding: 0.25rem 0.7rem; border-radius: 999px;
  background: rgba(255,255,255,0.2); color: inherit; cursor: pointer; border: 1px solid rgba(255,255,255,0.35);
}
.chip--ghost { background: rgba(255,255,255,0.14); }

.hint {
  font-size: 0.85rem; color: var(--ink-soft); margin: 0 0.2rem 1.1rem; line-height: 1.5;
}
.hint b { color: var(--ink); }

.foot {
  position: relative; z-index: 1; text-align: center; color: var(--ink-soft);
  font-size: 0.78rem; padding: 1rem 1rem 2rem;
}

@media (min-width: 720px) {
  .list--two { grid-template-columns: 1fr 1fr; }
}
