/* Meus remédios — porta-comprimidos diário.
   Paleta: cobalto (tampa), branco, coral para "agora/atrasado". Fonte do sistema (offline, sem rastreio). */
:root {
  color-scheme: light dark;
  --bg: #f4f6fb; --card: #ffffff; --ink: #111a33; --mute: #5b6584;
  --blue: #1f3a8a; --blue-ink: #ffffff; --blue-soft: #e3e9fb;
  --coral: #d9472d; --line: #d9dff0; --ok: #1f3a8a;
  --radius: 20px;
  --safe-t: env(safe-area-inset-top, 0px); --safe-b: env(safe-area-inset-bottom, 0px);
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #0e1424; --card: #18213a; --ink: #eef2ff; --mute: #9aa6c8; --blue: #8aa4ff; --blue-ink: #0e1424; --blue-soft: #223061; --coral: #ff7a5e; --line: #2a3658; }
}
* { box-sizing: border-box; min-width: 0; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 17px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  overflow-x: clip; -webkit-tap-highlight-color: transparent;
}
main { max-width: 560px; margin: 0 auto; padding: calc(20px + var(--safe-t)) 16px calc(48px + var(--safe-b)); }
h1 { font-size: 32px; line-height: 1.05; margin: 0; }
h2 { font-size: 19px; margin: 0; }
button { font: inherit; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* Topo */
.top { display: flex; justify-content: space-between; align-items: flex-end; gap: 12px; margin-bottom: 16px; }
.date { margin: 4px 0 0; color: var(--mute); font-size: 15px; }
.date::first-letter { text-transform: uppercase; }
.ring { width: 64px; height: 64px; flex: none; position: relative; }
.ring svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.ring circle { fill: none; stroke-width: 4; }
.ring .track { stroke: var(--line); }
.ring .arc { stroke: var(--blue); stroke-linecap: round; transition: stroke-dasharray .4s ease; }
.ring b { position: absolute; inset: 0; display: grid; place-items: center; font-size: 15px; }

/* Próxima dose */
.next { background: var(--blue); color: var(--blue-ink); border-radius: var(--radius); padding: 16px 18px; margin-bottom: 18px; }
.next.late { background: var(--coral); color: #fff; }
.next small { display: block; font-size: 14px; opacity: .9; }
.next strong { display: block; font-size: 22px; line-height: 1.2; margin: 2px 0 12px; }
.next strong:last-child { margin-bottom: 0; }

/* Compartimentos */
.box { background: var(--card); border: 2px solid var(--line); border-radius: var(--radius); margin-bottom: 14px; overflow: hidden; }
.box.now { border-color: var(--coral); }
.box.done { opacity: .72; }
.lid { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 12px 16px; background: var(--blue-soft); }
.lid .t { font-size: 22px; font-weight: 700; white-space: nowrap; color: var(--blue); font-variant-numeric: tabular-nums; }
.box.now .lid { background: var(--coral); color: #fff; }
.box.now .lid .t { color: #fff; }
.pills { padding: 6px 8px; }
.pill {
  display: flex; align-items: center; gap: 14px; width: 100%; min-height: 64px; padding: 10px 8px;
  background: none; border: 0; border-bottom: 1px solid var(--line); color: inherit; text-align: left; cursor: pointer; border-radius: 12px;
}
.pill:last-child { border-bottom: 0; }
.pill:active { background: var(--blue-soft); }
.dot { width: 36px; height: 36px; flex: none; border-radius: 50%; border: 3px solid var(--blue); display: grid; place-items: center; transition: background .15s; }
.dot svg { width: 18px; height: 18px; fill: none; stroke: var(--blue-ink); stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; opacity: 0; }
.pill.taken .dot { background: var(--blue); }
.pill.taken .dot svg { opacity: 1; }
.txt { display: block; }
.n { display: block; font-weight: 700; }
.d { display: block; font-size: 15px; color: var(--mute); }
.pill.taken .n { text-decoration: line-through; text-decoration-thickness: 2px; }

/* Painéis */
.panel { background: var(--card); border: 2px solid var(--line); border-radius: 16px; padding: 14px 16px; margin-top: 14px; }
.panel h2 { margin-bottom: 10px; }
details.panel { padding-block: 4px 14px; }
summary { min-height: 48px; display: flex; align-items: center; font-weight: 700; font-size: 19px; cursor: pointer; list-style: none; }
summary::-webkit-details-marker { display: none; }
summary::after { content: "+"; margin-left: auto; font-size: 24px; color: var(--mute); }
details[open] summary::after { content: "–"; }

.week { display: flex; gap: 6px; list-style: none; margin: 0; padding: 0; }
.week li { flex: 1; text-align: center; font-size: 13px; color: var(--mute); }
.week i { display: block; height: 12px; border-radius: 6px; margin-bottom: 4px; background: linear-gradient(90deg, var(--blue) var(--p, 0%), var(--line) var(--p, 0%)); }

.status { list-style: none; margin: 0 0 12px; padding: 0; }
.status li { display: flex; gap: 10px; align-items: flex-start; padding: 6px 0; font-size: 15px; }
.mark { width: 12px; height: 12px; border-radius: 50%; margin-top: 6px; flex: none; background: var(--line); }
.status .ok .mark { background: var(--ok); }
.status .off .mark { background: var(--coral); }

.actions { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 8px; }
.btn {
  min-height: 48px; padding: 0 18px; border-radius: 14px; border: 2px solid var(--blue);
  background: var(--blue); color: var(--blue-ink); font-weight: 700; cursor: pointer;
}
.btn.ghost { background: none; color: var(--blue); }
.btn.light { background: rgba(255,255,255,.18); border-color: currentColor; color: inherit; min-height: 44px; }
.btn:disabled { opacity: .55; cursor: default; }
.btn[hidden] { display: none; }
:is(.btn, .pill, summary, input):focus-visible { outline: 3px solid var(--coral); outline-offset: 2px; }

.row { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 8px 0; border-top: 1px solid var(--line); }
input[type=time] {
  font: inherit; font-size: 17px; padding: 8px 10px; min-height: 48px; border-radius: 12px;
  border: 2px solid var(--line); background: var(--bg); color: var(--ink); font-variant-numeric: tabular-nums;
}
.help { font-size: 15px; color: var(--mute); margin: 8px 0 12px; }
.help b { color: var(--ink); }
.foot { font-size: 13px; color: var(--mute); margin-top: 22px; }

.update {
  position: sticky; top: 0; z-index: 10; display: flex; justify-content: space-between; align-items: center; gap: 12px;
  padding: calc(10px + var(--safe-t)) 16px 10px; background: var(--blue); color: var(--blue-ink); font-weight: 700;
}
.update[hidden] { display: none; }
.toast {
  position: fixed; left: 50%; bottom: calc(20px + var(--safe-b)); transform: translateX(-50%);
  max-width: calc(100% - 32px); background: var(--ink); color: var(--bg); padding: 12px 18px; border-radius: 14px;
  font-size: 15px; opacity: 0; transition: opacity .2s; pointer-events: none; z-index: 20;
}
.toast.on { opacity: 1; }

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