/* Sky blue background, bright yellow highlights. Yellow is too close in
   brightness to sky blue to work as a thin line, so it's used as a fill;
   --ink (navy) carries text and fine outlines. */
:root {
  --bg: #8fd3f4;
  --surface: #ffffff;
  --text: #0b2540;
  --muted: #35546d;
  --line: #c7e3f2;
  --ink: #0b2540;          /* outlines that sit next to yellow */
  --accent: #ffd60a;       /* bright yellow */
  --accent-ink: #0b2540;   /* text on yellow */
  --accent-soft: #fff4b8;
  --score-ink: #0b2540;
  --accent-edge: #e6b800;  /* a darker yellow for edges on white */
  --link: #0b2540;
  --good: #157f3b;
  --good-soft: #e3f5e8;
  --warn-soft: #fff4b8;
  --warn-ink: #5c4300;
  --radius: 14px;
  --shadow: 0 1px 2px rgb(11 37 64 / 0.08), 0 4px 14px rgb(11 37 64 / 0.08);
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0d2f4f;
    --surface: #133d63;
    --text: #eef7ff;
    --muted: #a9c6dd;
    --line: #22527c;
    --ink: #ffd60a;        /* on deep blue, yellow outlines show fine */
    --accent: #ffd60a;
    --accent-ink: #0b2540;
    --accent-soft: #0d2f4f;
    --score-ink: #ffd60a;
    --accent-edge: #ffd60a;
    --link: #ffd60a;
    --good: #5ad08a;
    --good-soft: #17402a;
    --warn-soft: #4a3f0c;
    --warn-ink: #ffe680;
    --shadow: 0 0 #0000;
  }
}

* { 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)
           calc(env(safe-area-inset-right) + 16px) 12px
           calc(env(safe-area-inset-left) + 16px);
}

.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(--ink);
  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: calc(env(safe-area-inset-left) + 16px); right: calc(env(safe-area-inset-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 calc(env(safe-area-inset-right) + 16px) calc(env(safe-area-inset-bottom) + 40px)
           calc(env(safe-area-inset-left) + 16px);
}

.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: 3px solid var(--accent); outline-offset: 0; border-color: var(--ink); }
button:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }

.primary {
  background: var(--accent); color: var(--accent-ink);
  border: 0; border-radius: 10px; padding: 10px 18px; font-weight: 700; cursor: pointer;
  box-shadow: inset 0 -2px 0 rgb(0 0 0 / 0.14);
}
.primary:hover { filter: brightness(1.04); }
.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: var(--accent-edge); box-shadow: inset 4px 0 0 var(--accent), var(--shadow); }

.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 { color: var(--score-ink); 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; }
.title-edit {
  width: calc(100% + 8px); font-weight: 550;
  padding: 6px 8px; margin: -6px 0 -2px -8px;
}
.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; }
}
/* The smallest phones (320–360px): tighten so three buttons still fit. */
@media (max-width: 360px) {
  .item { column-gap: 8px; }
  .icon { width: 32px; }
}

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

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

.done-section { margin-top: 24px; }
.done-section summary {
  cursor: pointer; color: var(--text); font-weight: 700; padding: 6px 0; margin-bottom: 8px;
}
.done-empty { color: var(--muted); font-size: 0.9rem; margin: 0; }
.items.done .item {
  box-shadow: none; background: color-mix(in srgb, var(--surface) 55%, transparent);
}
.items.done .score { background: var(--good-soft); }
.items.done .title { text-decoration: line-through; color: var(--muted); }
.items.done .mine { display: none; }
.items.done .edit { display: none; }

.confetti {
  position: fixed; inset: 0; width: 100vw; height: 100vh;
  pointer-events: none; z-index: 20;
}

/* ------------------------------------------------------------ phones */

/* Some phones (e.g. iPhone Duo with the screen closed) put system controls over
   the top-right corner. Keep tappable things out of it: the account button sits
   next to the title, and Add gets its own full-width row under the text box. */
@media (max-width: 600px) {
  .top-inner { justify-content: flex-start; }
  .who { max-width: 45%; }
  .add { flex-wrap: wrap; }
  .add input { flex-basis: 100%; }
  .add .primary { flex: 1 1 100%; padding: 11px; }
}

/* ------------------------------------------------------------ wide screens */

/* Open items on the left, completed items in a column on the right. */
@media (min-width: 960px) {
  .top-inner, .wallet, main { max-width: 1120px; }
  main { padding-top: 24px; }

  #app {
    display: grid;
    grid-template-columns: minmax(0, 1.7fr) minmax(0, 1fr);
    grid-template-areas:
      "add  done"
      "open done";
    grid-template-rows: auto 1fr;
    column-gap: 28px;
    align-items: start;
  }
  #app[hidden] { display: none; }
  .add { grid-area: add; }
  .open-col { grid-area: open; }

  .done-section {
    grid-area: done; margin-top: 0;
    position: sticky; top: 132px;
    max-height: calc(100dvh - 156px); overflow: auto;
    background: color-mix(in srgb, var(--surface) 35%, transparent);
    border: 1px solid color-mix(in srgb, var(--surface) 60%, transparent);
    border-radius: var(--radius); padding: 10px 14px 14px;
  }
  /* Always open here, so the summary is just a heading. */
  .done-section summary { cursor: default; list-style: none; }
  .done-section summary::-webkit-details-marker { 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(--link); font-weight: 700;
  text-decoration: underline; text-decoration-color: var(--accent-edge);
  text-decoration-thickness: 3px; text-underline-offset: 3px;
}
.signin .field label { display: block; font-weight: 600; font-size: 0.9rem; }
[hidden] { display: none !important; }

/* ------------------------------------------------------------ account dialog */

.account {
  width: min(420px, calc(100vw - 32px));
  max-height: calc(100dvh - 32px); overflow: auto;
  color: var(--text); margin: auto;
}
.account::backdrop { background: rgb(10 10 20 / 0.45); }
.account-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.account h2 { margin: 0; font-size: 1.25rem; }
.account h3 { margin: 0; font-size: 1rem; }
.account-who { margin: 4px 0 18px; color: var(--muted); overflow-wrap: anywhere; }
.account .field label { display: block; font-weight: 600; font-size: 0.9rem; }
.pw-done {
  margin: 0; padding: 10px 12px; border-radius: 10px;
  background: var(--good-soft); color: var(--good); font-size: 0.9rem;
}
.account-foot {
  margin-top: 18px; padding-top: 14px; border-top: 1px solid var(--line); text-align: center;
}
.switch + .switch { margin-top: 6px; }

.danger-zone { margin-top: 14px; }
.danger-zone summary {
  cursor: pointer; color: var(--muted); font-size: 0.9rem; text-align: center; padding: 4px 0;
}
.danger-zone form { margin-top: 10px; }
.danger {
  background: #b3261e; color: #fff; border: 0; border-radius: 10px;
  padding: 12px; font-weight: 700; cursor: pointer;
}
.danger.wide { width: 100%; }
.danger:disabled { opacity: 0.6; cursor: default; }

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

/* The list's name in the header, which opens the Lists panel. */
.list-btn {
  display: inline-flex; align-items: center; gap: 4px; min-width: 0;
  border: 0; background: none; padding: 4px 6px; margin: -4px -6px;
  border-radius: 8px; font: inherit; font-weight: 700; cursor: pointer;
}
.list-btn span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list-btn svg { flex: none; color: var(--muted); }
.list-btn:hover { background: color-mix(in srgb, var(--surface) 50%, transparent); }
h1 { min-width: 0; display: flex; }

.list-pick { list-style: none; margin: 0 0 18px; padding: 0; display: grid; gap: 6px; }
.pick {
  width: 100%; display: flex; align-items: center; gap: 8px; text-align: left;
  border: 1px solid var(--line); background: var(--surface); border-radius: 10px;
  padding: 10px 12px; cursor: pointer; font-weight: 600;
}
.pick span { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.pick.current { border-color: var(--accent-edge); box-shadow: inset 4px 0 0 var(--accent); cursor: default; }
.pick svg { color: var(--good); flex: none; }
.tag {
  font-size: 0.7rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em;
  color: var(--muted); border: 1px solid var(--line); border-radius: 999px; padding: 1px 7px;
}

.cur { display: grid; gap: 10px; }
.cur h3, .join-start h3 { margin: 0; font-size: 1rem; }
.cur .hint, .nolist .hint { margin: 0; }

.invite-box {
  display: grid; gap: 8px; padding: 14px; border-radius: 12px;
  background: var(--accent-soft); border: 1px solid var(--accent-edge);
}
.code-row { display: flex; align-items: center; gap: 10px; }
.code {
  flex: 1; font: 700 1.35rem/1.2 ui-monospace, "SF Mono", Menlo, monospace;
  letter-spacing: 0.08em; user-select: all; overflow-wrap: anywhere;
}
.link.small { font-size: 0.85rem; justify-self: start; }

.members-head { margin-top: 8px !important; }
.members { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }
.members li {
  display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px;
  padding: 8px 0; border-bottom: 1px solid var(--line);
}
.member-name { flex: 1; min-width: 40%; font-weight: 600; overflow-wrap: anywhere; }
.member-name small { color: var(--muted); font-weight: 400; }

.inline-form .field > span, .join-start .field > span { font-weight: 600; font-size: 0.9rem; }
.inline-form .row input { flex: 1; }

.join-start { display: grid; gap: 22px; margin-top: 20px; padding-top: 18px; border-top: 1px solid var(--line); }
.nolist h2 { margin: 0 0 6px; font-size: 1.25rem; }
.nolist .join-start { margin-top: 16px; }
.forgot-help { margin: 10px 0 0; text-align: center; }
#lists-notice, #lists-error { margin-bottom: 14px; overflow-wrap: anywhere; }

/* "Not end-to-end encrypted" reminders. */
.privacy-note { margin: 0; }
.privacy-note::before { content: "⚠︎ "; }
.account-privacy { margin: -8px 0 18px; }

/* "Shared Priorities" next to the name when signed out. */
.tagline { font-size: 0.8rem; font-weight: 500; color: var(--muted); margin-left: 6px; }
