:root {
  --bg: #f6f6fa;
  --surface: #ffffff;
  --text: #17171f;
  --muted: #64647a;
  --line: #e3e3ec;
  --accent: #4f46e5;
  --accent-ink: #ffffff;
  --accent-soft: #eceafe;
  --good: #15803d;
  --good-soft: #e3f5e8;
  --warn-soft: #fff4d6;
  --warn-ink: #7a5300;
  --radius: 14px;
  --shadow: 0 1px 2px rgb(20 20 40 / 0.06), 0 2px 8px rgb(20 20 40 / 0.04);
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f0f15;
    --surface: #1a1a24;
    --text: #ececf4;
    --muted: #9a9ab0;
    --line: #2b2b3a;
    --accent: #8b85ff;
    --accent-ink: #0f0f15;
    --accent-soft: #26244a;
    --good: #5ad08a;
    --good-soft: #17301f;
    --warn-soft: #3a2f10;
    --warn-ink: #f5d27a;
    --shadow: none;
  }
}

* { box-sizing: border-box; }

html, body { margin: 0; }

body {
  background: var(--bg);
  color: var(--text);
  font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
  min-height: 100dvh;
}

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

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

/* ------------------------------------------------------------ header */

.top {
  position: sticky; top: 0; z-index: 5;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
  padding: calc(env(safe-area-inset-top) + 12px) 16px 12px;
}

.top-inner, .wallet, main {
  max-width: 680px; margin: 0 auto;
}

.top-inner { display: flex; align-items: center; justify-content: space-between; gap: 12px; }

h1 { font-size: 1.15rem; margin: 0; letter-spacing: -0.01em; }

.who {
  border: 1px solid var(--line); background: var(--surface);
  border-radius: 999px; padding: 4px 12px; font-size: 0.875rem; cursor: pointer;
  max-width: 50%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

.wallet { display: flex; align-items: center; gap: 12px; margin-top: 10px; }
.wallet p { margin: 0; color: var(--muted); font-size: 0.875rem; }

.dots { display: flex; gap: 6px; }
.dot {
  width: 14px; height: 14px; border-radius: 50%;
  border: 2px solid var(--accent);
  transition: background-color 0.15s;
}
.dot.full { background: var(--accent); }

/* ------------------------------------------------------------ banner */

/* Floats over the list so it never shifts rows while someone is tapping. */
.banner {
  position: fixed; z-index: 10;
  left: 16px; right: 16px; bottom: calc(env(safe-area-inset-bottom) + 16px);
  max-width: 520px; margin: 0 auto; padding: 12px 16px;
  border-radius: 12px; background: var(--warn-soft); color: var(--warn-ink);
  font-size: 0.9rem; box-shadow: 0 6px 24px rgb(0 0 0 / 0.18);
}
.banner[hidden] { display: none; }

/* ------------------------------------------------------------ main */

main { padding: 16px 16px calc(env(safe-area-inset-bottom) + 40px); }

.card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow);
}

.signin h2 { margin: 0 0 6px; font-size: 1.25rem; }
.signin p { margin: 0 0 16px; color: var(--muted); }
.signin label { display: block; font-weight: 600; margin-bottom: 6px; font-size: 0.9rem; }

.row, .add { display: flex; gap: 8px; }

input {
  flex: 1; min-width: 0;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: 10px; padding: 10px 12px;
}
input:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; border-color: transparent; }

.primary {
  background: var(--accent); color: var(--accent-ink);
  border: 0; border-radius: 10px; padding: 10px 18px; font-weight: 600; cursor: pointer;
}
.primary:active { transform: translateY(1px); }

.add { margin-bottom: 16px; }

/* ------------------------------------------------------------ items */

.items { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }

.item {
  display: grid;
  grid-template-columns: 52px 1fr auto auto;
  grid-template-areas: "score body mine actions";
  align-items: center; gap: 12px;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 12px 12px 12px 10px;
  box-shadow: var(--shadow);
  transition: transform 0.25s ease;
}
.item.mine-has { border-color: color-mix(in srgb, var(--accent) 45%, var(--line)); }

.score {
  grid-area: score;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  height: 52px; border-radius: 10px; background: var(--accent-soft);
}
.score-num { font-size: 1.3rem; font-weight: 700; line-height: 1; font-variant-numeric: tabular-nums; }
.score-label { font-size: 0.7rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; }

.body { grid-area: body; min-width: 0; }
.title { margin: 0; font-weight: 550; overflow-wrap: anywhere; }
.meta { margin: 2px 0 0; color: var(--muted); font-size: 0.8rem; }

.mine {
  grid-area: mine;
  display: flex; align-items: center; gap: 2px;
  border: 1px solid var(--line); border-radius: 999px; padding: 2px;
}
.mine-num { min-width: 22px; text-align: center; font-weight: 600; font-variant-numeric: tabular-nums; }
.step {
  width: 32px; height: 32px; border-radius: 50%; border: 0;
  background: transparent; cursor: pointer; font-size: 1.1rem; line-height: 1;
}
.step.plus { background: var(--accent); color: var(--accent-ink); }
.step:disabled { opacity: 0.3; cursor: default; }

.actions { grid-area: actions; display: flex; gap: 2px; }
.icon {
  width: 36px; height: 36px; border-radius: 10px; border: 0;
  background: transparent; color: var(--muted); cursor: pointer;
  display: grid; place-items: center;
}
.icon:hover { background: var(--bg); color: var(--text); }
.icon.complete:hover { color: var(--good); background: var(--good-soft); }
.icon[hidden] { display: none; }

@media (max-width: 520px) {
  .item {
    grid-template-columns: 52px 1fr auto;
    grid-template-areas:
      "score body body"
      "score mine actions";
    row-gap: 8px;
  }
  .mine { justify-self: start; }
}

.empty { text-align: center; color: var(--muted); padding: 32px 0; }

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

.done-section { margin-top: 24px; }
.done-section summary {
  cursor: pointer; color: var(--muted); font-weight: 600; padding: 6px 0; margin-bottom: 8px;
}
.items.done .item { box-shadow: none; background: transparent; }
.items.done .score { background: var(--good-soft); }
.items.done .title { text-decoration: line-through; color: var(--muted); }
.items.done .mine { display: none; }

/* ------------------------------------------------------------ auth */

.auth { display: grid; gap: 14px; }
.field { display: grid; gap: 6px; }
.field label { margin: 0; }
.field input { width: 100%; }
.hint { color: var(--muted); font-size: 0.8rem; }
.opt { color: var(--muted); font-weight: 400; }
.primary.wide { width: 100%; padding: 12px; }
.primary:disabled { opacity: 0.6; cursor: default; }
.auth-error {
  margin: 0; padding: 10px 12px; border-radius: 10px;
  background: var(--warn-soft); color: var(--warn-ink); font-size: 0.9rem;
}
.switch { margin: 16px 0 0; text-align: center; color: var(--muted); font-size: 0.9rem; }
.link {
  background: none; border: 0; padding: 0; cursor: pointer;
  color: var(--accent); font-weight: 600; text-decoration: underline; text-underline-offset: 2px;
}
.signin .field label { display: block; font-weight: 600; font-size: 0.9rem; }
[hidden] { display: none !important; }
