/* Runway. Brand palette from Yusuf's style guide.
   Mona Sans resolves on his Mac where it is installed; iPhone falls back to
   the system face, which is the right call for a tool used one-handed. */

:root {
  --navy:  #000E35;
  --blue:  #0043FF;
  --red:   #FF1200;
  --grey:  #807771;
  --cream: #F1EFEC;

  --bg:        #F5F4F1;
  --surface:   #FFFFFF;
  --surface-2: #FAF9F7;
  --ink:       var(--navy);
  --ink-soft:  #4A5570;
  --ink-faint: var(--grey);
  --line:      #E3E1DC;
  --shadow:    0 1px 2px rgba(0, 14, 53, .06), 0 6px 20px rgba(0, 14, 53, .05);

  --hot:   var(--red);
  --warm:  #B25A00;
  --calm:  var(--blue);

  --radius: 14px;
  --tap: 44px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg:        #04091C;
    --surface:   #0A1330;
    --surface-2: #0D183A;
    --ink:       #EEF1F8;
    --ink-soft:  #A9B3CC;
    --ink-faint: #7A85A3;
    --line:      #1B2854;
    --shadow:    none;
    --hot:  #FF5941;
    --warm: #FFAE4D;
    --calm: #6E96FF;
  }
}
:root[data-theme="dark"] {
  --bg:        #04091C;
  --surface:   #0A1330;
  --surface-2: #0D183A;
  --ink:       #EEF1F8;
  --ink-soft:  #A9B3CC;
  --ink-faint: #7A85A3;
  --line:      #1B2854;
  --shadow:    none;
  --hot:  #FF5941;
  --warm: #FFAE4D;
  --calm: #6E96FF;
}
:root[data-theme="light"] {
  --bg:        #F5F4F1;
  --surface:   #FFFFFF;
  --surface-2: #FAF9F7;
  --ink:       #000E35;
  --ink-soft:  #4A5570;
  --ink-faint: #807771;
  --line:      #E3E1DC;
  --shadow:    0 1px 2px rgba(0, 14, 53, .06), 0 6px 20px rgba(0, 14, 53, .05);
  --hot:  #FF1200;
  --warm: #B25A00;
  --calm: #0043FF;
}

* { box-sizing: border-box; }

/* A class that sets `display` outranks the user-agent rule for [hidden], so
   without this the gate and the toast stay painted after being dismissed. */
[hidden] { display: none !important; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: "Mona Sans", "Urbanist", system-ui, -apple-system, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: contain;
}
body { font-size: 16px; line-height: 1.45; }

button, input { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; }

/* ---------- device linking ---------- */

.gate {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  padding: 32px 24px calc(32px + env(safe-area-inset-bottom));
  background: var(--navy);
  color: #fff;
  text-align: center;
}
.gate-mark { width: 72px; opacity: .95; }
.gate h1 { margin: 0; font-size: 30px; letter-spacing: -.02em; }
.gate p { margin: 0; max-width: 30ch; color: #A9B3CC; font-size: 15px; }
.gate input {
  width: min(340px, 100%);
  height: var(--tap);
  padding: 0 14px;
  border-radius: 10px;
  border: 1px solid #24325E;
  background: #0A1330;
  color: #fff;
}
.gate button {
  width: min(340px, 100%);
  height: var(--tap);
  border-radius: 10px;
  background: var(--blue);
  color: #fff;
  font-weight: 600;
}
.gate-err { color: #FF8A78; font-size: 14px; }

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

/* Header and tabs stick as one block. Sticking them separately at top:0 makes
   the tab bar slide underneath the header and disappear on scroll. */
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
}

.top {
  background: var(--navy);
  color: #fff;
  padding: calc(10px + env(safe-area-inset-top)) 16px 14px;
}
.top-row { display: flex; align-items: center; gap: 11px; }
.brand-mark { width: 30px; flex: none; }
.top-title { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.2; }
.top-title strong { font-size: 17px; letter-spacing: -.01em; }
.top-title span { font-size: 12.5px; color: #93A0C0; }

.sync {
  width: var(--tap); height: var(--tap);
  margin: calc(var(--tap) / -2 + 15px) -10px calc(var(--tap) / -2 + 15px) 0;
  display: grid; place-items: center; flex: none;
}
.dot { width: 9px; height: 9px; border-radius: 50%; background: #3E7D4F; transition: background .2s; }
.dot.is-busy { background: var(--warm); animation: pulse 1s ease-in-out infinite; }
.dot.is-off  { background: var(--grey); }
.dot.is-bad  { background: var(--hot); }
@keyframes pulse { 50% { opacity: .35; } }

.headline {
  margin: 11px 0 0;
  font-size: 14.5px;
  line-height: 1.4;
  color: #C8D0E4;
}
.headline b { color: #fff; font-weight: 600; }
.headline.is-hot b { color: #FF8A78; }

/* ---------- tabs ---------- */

.tabs {
  display: flex;
  gap: 2px;
  padding: 8px 10px;
  background: var(--bg);
  border-bottom: 1px solid var(--line);
}
.tab {
  flex: 1;
  min-height: 38px;
  padding: 6px 4px;
  border-radius: 9px;
  font-size: 14px;
  font-weight: 550;
  color: var(--ink-faint);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
}
.tab.is-on { background: var(--surface); color: var(--ink); box-shadow: var(--shadow); }
.pill {
  min-width: 19px; padding: 1px 5px;
  border-radius: 20px;
  background: var(--line);
  color: var(--ink-soft);
  font-size: 11.5px; font-weight: 650;
}
.tab.is-on .pill { background: var(--navy); color: #fff; }
.pill.is-hot { background: var(--hot); color: #fff; }
.pill:empty { display: none; }

/* ---------- list ---------- */

main {
  padding: 6px 10px calc(96px + env(safe-area-inset-bottom));
  max-width: 720px;
  margin: 0 auto;
}

.group-head {
  display: flex; align-items: baseline; gap: 8px;
  padding: 16px 6px 7px;
}
.group-head h2 {
  margin: 0;
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: .09em;
  text-transform: uppercase;
  color: var(--ink-faint);
}
.group-head .rule { flex: 1; height: 1px; background: var(--line); }

.card {
  display: flex;
  gap: 11px;
  padding: 12px 13px;
  margin-bottom: 7px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border-left: 3px solid var(--line);
}
.card.t-hot  { border-left-color: var(--hot); }
.card.t-warm { border-left-color: var(--warm); }
.card.t-calm { border-left-color: var(--calm); }
.card.is-done { opacity: .5; }
.card.is-done .title { text-decoration: line-through; }

.check {
  width: 25px; height: 25px;
  margin-top: 1px;
  flex: none;
  border: 2px solid var(--line);
  border-radius: 50%;
  display: grid; place-items: center;
  transition: background .15s, border-color .15s;
}
.check::after {
  content: "";
  width: 11px; height: 6px;
  border-left: 2.5px solid #fff;
  border-bottom: 2.5px solid #fff;
  transform: rotate(-45deg) translate(1px, -1px);
  opacity: 0;
  transition: opacity .15s;
}
.check.is-on { background: #3E7D4F; border-color: #3E7D4F; }
.check.is-on::after { opacity: 1; }

.body { flex: 1; min-width: 0; }
.title { font-size: 15.5px; line-height: 1.35; font-weight: 500; overflow-wrap: anywhere; }
.meta {
  margin-top: 4px;
  font-size: 12.5px;
  color: var(--ink-faint);
  display: flex; flex-wrap: wrap; align-items: center; gap: 4px 7px;
}
.meta .due { font-weight: 650; }
.meta .due.t-hot  { color: var(--hot); }
.meta .due.t-warm { color: var(--warm); }
.meta .sep { opacity: .4; }
.tag {
  padding: 1px 6px;
  border-radius: 5px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .02em;
  color: var(--ink-soft);
}
.thread {
  flex: none;
  width: 34px;
  margin: -4px -6px -4px 0;
  display: grid; place-items: center;
  color: var(--ink-faint);
  text-decoration: none;
  font-size: 15px;
}

.empty {
  padding: 44px 20px;
  text-align: center;
  color: var(--ink-faint);
  font-size: 15px;
}
.empty strong { display: block; color: var(--ink); font-size: 17px; margin-bottom: 5px; }

/* ---------- quick add ---------- */

.composer {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 25;
  display: flex; gap: 8px;
  padding: 9px 12px calc(9px + env(safe-area-inset-bottom));
  background: color-mix(in srgb, var(--bg) 92%, transparent);
  backdrop-filter: blur(12px);
  border-top: 1px solid var(--line);
}
.composer input {
  flex: 1; min-width: 0;
  height: var(--tap);
  padding: 0 14px;
  border-radius: 22px;
  border: 1px solid var(--line);
  background: var(--surface);
}
.composer input::placeholder { color: var(--ink-faint); }
.composer button {
  width: var(--tap); height: var(--tap);
  flex: none;
  border-radius: 50%;
  background: var(--blue);
  color: #fff;
  font-size: 25px; line-height: 1;
}

/* ---------- detail sheet ---------- */

.sheet-scrim {
  position: fixed; inset: 0; z-index: 30;
  background: rgba(0, 14, 53, .45);
  backdrop-filter: blur(2px);
}
.sheet {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 31;
  max-height: 88dvh;
  overflow-y: auto;
  padding: 8px 18px calc(22px + env(safe-area-inset-bottom));
  background: var(--surface);
  border-radius: 20px 20px 0 0;
  box-shadow: 0 -8px 40px rgba(0, 14, 53, .22);
  animation: rise .2s ease-out;
}
@keyframes rise { from { transform: translateY(14px); opacity: .6; } }
@media (min-width: 640px) {
  .sheet { left: 50%; right: auto; bottom: 24px; width: 560px; transform: translateX(-50%); border-radius: 20px; }
}
.grab { width: 38px; height: 4px; border-radius: 4px; background: var(--line); margin: 4px auto 14px; }
.sheet h3 { margin: 0 0 3px; font-size: 19px; line-height: 1.3; letter-spacing: -.01em; overflow-wrap: anywhere; }
.sheet .sub { margin: 0 0 14px; font-size: 13px; color: var(--ink-faint); }
.sheet .notes {
  margin: 0 0 16px; padding: 11px 13px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 10px;
  font-size: 14px; line-height: 1.5;
  color: var(--ink-soft);
  white-space: pre-wrap; overflow-wrap: anywhere;
}
.row { display: flex; gap: 8px; margin-bottom: 8px; }
.row > * { flex: 1; }
.btn {
  min-height: var(--tap);
  padding: 0 12px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--surface-2);
  font-size: 14.5px; font-weight: 550;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  text-decoration: none; color: var(--ink);
}
.btn.primary { background: var(--blue); border-color: var(--blue); color: #fff; }
.btn.danger  { color: var(--hot); }
.sheet-field { margin-bottom: 8px; }
.sheet-field label {
  display: block; margin-bottom: 4px;
  font-size: 11.5px; font-weight: 700; letter-spacing: .07em;
  text-transform: uppercase; color: var(--ink-faint);
}
.sheet-field input {
  width: 100%; height: var(--tap);
  padding: 0 12px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--surface-2);
}

/* ---------- toast ---------- */

.toast {
  position: fixed;
  left: 50%; bottom: calc(74px + env(safe-area-inset-bottom));
  z-index: 40;
  transform: translateX(-50%);
  max-width: calc(100vw - 32px);
  padding: 10px 15px;
  border-radius: 11px;
  background: var(--navy);
  color: #fff;
  font-size: 14px;
  box-shadow: 0 8px 28px rgba(0, 14, 53, .3);
  display: flex; align-items: center; gap: 13px;
  animation: rise .16s ease-out;
}
.toast button { color: #7FA5FF; font-weight: 650; font-size: 14px; }

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}
