:root {
  --bg: #ffffff;
  --ink: #111111;
  --muted: #737373;
  --line: #e5e5e5;
  --late: #c2410c;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0b0b0b;
    --ink: #ededed;
    --muted: #8c8c8c;
    --line: #262626;
    --late: #fb923c;
    color-scheme: dark;
  }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.4 system-ui, -apple-system, "SF Pro Text", "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  font-variant-numeric: tabular-nums;
}
main {
  max-width: 520px;
  margin: 0 auto;
  padding: calc(env(safe-area-inset-top) + 20px) 20px calc(env(safe-area-inset-bottom) + 48px);
}
button { font: inherit; color: inherit; }
h1, h2, p { margin: 0; }
.muted { color: var(--muted); }
.small { font-size: 14px; }

/* Header */
.top { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; padding-bottom: 16px; border-bottom: 1px solid var(--ink); }
.top h1 { font-size: 28px; line-height: 1.1; font-weight: 650; letter-spacing: -0.02em; }
.top p { margin-top: 2px; font-size: 14px; color: var(--muted); }
.day-nav { display: flex; gap: 4px; }
.day-nav button { height: 34px; min-width: 34px; padding: 0 10px; border: 1px solid var(--line); border-radius: 6px; background: none; font-size: 18px; line-height: 1; cursor: pointer; }
.day-nav .today-btn { font-size: 13px; font-weight: 600; }

/* Now */
.now { padding: 28px 0 8px; }
.now-label { font-size: 14px; color: var(--muted); }
.now-time { display: flex; align-items: baseline; gap: 14px; flex-wrap: wrap; font-size: 64px; line-height: 1; font-weight: 600; letter-spacing: -0.045em; margin: 6px 0 20px; }
.now-time span { font-size: 15px; font-weight: 400; letter-spacing: 0; }
.now-time .late { color: var(--late); }
.now-done .now-time { font-size: 28px; letter-spacing: -0.02em; margin: 0 0 6px; }
.drops { border-top: 1px solid var(--line); margin-bottom: 12px; }
.now > .small { margin-top: 4px; }

/* A drop row: tap to check off */
.drop {
  --c: #888;
  display: flex; align-items: center; gap: 14px; width: 100%;
  min-height: 44px; padding: 0; border: 0; background: none;
  text-align: left; cursor: pointer;
}
.drops .drop { min-height: 60px; border-bottom: 1px solid var(--line); }
.tick { flex: none; position: relative; width: 22px; height: 22px; border: 1.5px solid var(--ink); border-radius: 4px; }
.drop.is-done .tick { background: var(--ink); }
.drop.is-done .tick::after { content: ""; position: absolute; left: 6.5px; top: 2.5px; width: 6px; height: 11px; border: solid var(--bg); border-width: 0 2px 2px 0; transform: rotate(45deg); }
.drop-name { flex: 1; min-width: 0; display: flex; align-items: center; gap: 8px; font-weight: 550; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.drop-name::before { content: ""; flex: none; width: 8px; height: 8px; background: var(--c); }
.drop-name small { font-weight: 400; font-size: 14px; color: var(--muted); }
.drops .drop-name { font-size: 18px; }
.drop-status { font-size: 13px; color: var(--muted); white-space: nowrap; }
.drop.is-done .drop-name { color: var(--muted); font-weight: 400; }
.drop.is-wait .drop-status { color: var(--ink); font-weight: 600; }

/* Day list */
.day { margin-top: 36px; }
.day h2 { font-size: 13px; font-weight: 600; color: var(--muted); padding-bottom: 8px; border-bottom: 1px solid var(--ink); }
.moments { list-style: none; margin: 0 0 36px; padding: 0; }
.moment { display: grid; grid-template-columns: 64px 1fr; align-items: start; padding: 6px 0; border-bottom: 1px solid var(--line); }
.moment-time { padding-top: 11px; font-weight: 600; }
.moment-drops { min-width: 0; }
.moment .drop { min-height: 42px; gap: 12px; }
.moment .tick { width: 18px; height: 18px; }
.moment .drop.is-done .tick::after { left: 5px; top: 1.5px; width: 5px; height: 9px; }
.moment .drop-name { font-size: 15px; }
.moment .drop-status { font-size: 12px; }
.moment.is-done .moment-time { color: var(--muted); font-weight: 400; }
.moment.is-missed .moment-time { color: var(--late); }
.moments .empty { padding: 16px 0; border-bottom: 1px solid var(--line); }

/* Extra drops */
.xdrop { --c: #888; display: flex; align-items: center; gap: 12px; width: 100%; min-height: 42px; padding: 0; border: 0; background: none; text-align: left; cursor: pointer; }
.xdrop .plus { flex: none; width: 18px; height: 18px; display: grid; place-items: center; font-size: 15px; font-weight: 600; line-height: 1; color: var(--muted); border: 1.5px dashed var(--muted); border-radius: 4px; }
.xdrop .drop-name { font-size: 15px; font-weight: 400; color: var(--muted); }
.xdrop .drop-status { font-size: 12px; }
.moment.is-extra .moment-time { color: var(--muted); font-weight: 400; }
.extra { margin: -20px 0 36px; padding-top: 12px; }
.extra-form { display: grid; gap: 12px; }
.extra-meds { display: grid; border-top: 1px solid var(--line); }
.extra-med { display: flex; align-items: center; gap: 12px; min-height: 48px; border-bottom: 1px solid var(--line); cursor: pointer; font-weight: 550; }
.extra-med input { appearance: none; -webkit-appearance: none; margin: 0; width: 20px; height: 20px; border: 1.5px solid var(--ink); border-radius: 50%; }
.extra-med input:checked { border-width: 6px; }
.extra-med span { display: flex; align-items: center; gap: 8px; }
.extra-med span::before { content: ""; width: 8px; height: 8px; background: var(--c); }
.extra-form label.small { display: grid; gap: 6px; }
.extra-form input[type="time"] { font: inherit; color: var(--ink); background: none; border: 1px solid var(--line); border-radius: 6px; padding: 0 12px; height: 44px; }

/* Panels */
.panel { border-bottom: 1px solid var(--line); }
.panel:first-of-type { border-top: 1px solid var(--ink); }
.panel summary { list-style: none; cursor: pointer; padding: 16px 0; font-weight: 600; display: flex; justify-content: space-between; align-items: center; }
.panel summary::-webkit-details-marker { display: none; }
.panel summary::after { content: ""; width: 9px; height: 9px; border: solid var(--muted); border-width: 0 1.5px 1.5px 0; margin: -5px 4px 0 0; transform: rotate(45deg); transition: transform 0.15s, margin 0.15s; }
.panel[open] summary::after { margin-top: 5px; transform: rotate(-135deg); }
.panel > :not(summary) { margin: 0 0 16px; }
.row { display: flex; gap: 8px; flex-wrap: wrap; }
.btn { height: 44px; padding: 0 18px; border: 1px solid var(--ink); border-radius: 6px; background: var(--ink); color: var(--bg); font-weight: 600; font-size: 15px; cursor: pointer; }
.btn-line { background: none; color: var(--ink); border-color: var(--line); }
#push-status { margin-bottom: 14px; }

.table-wrap { overflow-x: auto; margin-right: -20px !important; padding-right: 20px; }
#schema { border-collapse: collapse; font-size: 14px; min-width: 640px; }
#schema th, #schema td { padding: 9px 10px 9px 0; text-align: left; border-bottom: 1px solid var(--line); vertical-align: top; }
#schema thead th { font-weight: 400; font-size: 12px; color: var(--muted); line-height: 1.3; border-bottom-color: var(--ink); }
#schema tbody th { font-weight: 550; white-space: nowrap; padding-right: 16px; }
#schema tbody th i { display: inline-block; width: 8px; height: 8px; background: var(--c); margin-right: 8px; }
#schema .is-now { font-weight: 700; color: var(--ink); }
#schema thead .is-now { box-shadow: inset 0 3px 0 var(--ink); }

.settings { display: grid; gap: 14px; }
.settings label { display: grid; gap: 6px; font-size: 13px; color: var(--muted); }
.settings input { font: inherit; color: var(--ink); background: none; border: 1px solid var(--line); border-radius: 6px; padding: 0 12px; height: 44px; }
.settings .btn { justify-self: start; }

footer { margin-top: 24px; }

/* Login */
body.login main { min-height: 100svh; display: flex; flex-direction: column; justify-content: center; padding-top: 0; }
.login-icon { border-radius: 12px; margin-bottom: 20px; width: 48px; height: 48px; }
body.login h1 { font-size: 28px; font-weight: 650; letter-spacing: -0.02em; padding-bottom: 16px; margin-bottom: 20px; border-bottom: 1px solid var(--ink); }
body.login form { display: grid; gap: 10px; }
body.login input { font: inherit; font-size: 20px; letter-spacing: 0.25em; height: 52px; padding: 0 14px; border: 1px solid var(--line); border-radius: 6px; background: none; color: var(--ink); }
body.login input::placeholder { letter-spacing: 0; font-size: 16px; color: var(--muted); }
body.login button { height: 52px; border: 0; border-radius: 6px; background: var(--ink); color: var(--bg); font-weight: 600; cursor: pointer; }
#err { min-height: 1.4em; color: var(--late); font-size: 14px; }
