:root {
  --bg: #f6f4ef;
  --card: #ffffff;
  --ink: #1a1a1a;
  --muted: #5a5a5a;
  --brand: #1a5fb4;
  --brand-dark: #14487f;
  --good: #217a3c;
  --good-bg: #e4f3e9;
  --warn: #b03500;
  --line: #d9d5cc;
  --radius: 14px;
}
* { box-sizing: border-box; }
html { font-size: 20px; }
body {
  margin: 0;
  font-family: "Segoe UI", system-ui, -apple-system, Arial, sans-serif;
  background: var(--bg);
  color: var(--ink);
  line-height: 1.5;
}
h1, h2, h3 { line-height: 1.25; }
button {
  font: inherit;
  cursor: pointer;
  border: none;
  border-radius: var(--radius);
  padding: 0.7rem 1.2rem;
}
input, select {
  font: inherit;
  padding: 0.65rem 0.8rem;
  border: 2px solid var(--line);
  border-radius: 10px;
  width: 100%;
  background: #fff;
}
input:focus, select:focus, button:focus-visible {
  outline: 3px solid var(--brand);
  outline-offset: 1px;
}
.btn-primary { background: var(--brand); color: #fff; }
.btn-primary:hover { background: var(--brand-dark); }
.btn-quiet { background: #eceae4; color: var(--ink); }
.btn-quiet:hover { background: #e0ddd4; }
.btn-good { background: var(--good); color: #fff; }
.btn-good:hover { background: #185c2d; }
.btn-danger { background: #fff; color: var(--warn); border: 2px solid var(--warn); }
.btn-danger:hover { background: #fdece5; }
.hidden { display: none !important; }

/* ---- Login ---- */
#login-view {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}
.login-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 2rem;
  width: 100%;
  max-width: 26rem;
  box-shadow: 0 4px 18px rgba(0,0,0,0.07);
}
.login-card h1 { margin-top: 0; text-align: center; }
.login-card label { display: block; margin: 0.9rem 0 0.3rem; font-weight: 600; }
.login-card button { width: 100%; margin-top: 1.4rem; font-size: 1.1rem; }
.login-error { color: var(--warn); font-weight: 600; margin-top: 0.9rem; text-align: center; min-height: 1.5rem; }

/* ---- App shell ---- */
header.appbar {
  background: var(--brand);
  color: #fff;
  padding: 0.7rem 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}
header.appbar .title { font-size: 1.25rem; font-weight: 700; }
header.appbar .who { font-size: 0.9rem; opacity: 0.95; }
header.appbar button {
  background: rgba(255,255,255,0.16);
  color: #fff;
  padding: 0.45rem 0.9rem;
}
header.appbar button:hover { background: rgba(255,255,255,0.28); }

nav.tabs {
  display: flex;
  background: var(--card);
  border-bottom: 2px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 10;
}
nav.tabs button {
  flex: 1;
  background: none;
  border-radius: 0;
  padding: 0.85rem 0.4rem;
  font-size: 1.02rem;
  font-weight: 600;
  color: var(--muted);
  border-bottom: 4px solid transparent;
}
nav.tabs button.active {
  color: var(--brand);
  border-bottom-color: var(--brand);
}

main { max-width: 52rem; margin: 0 auto; padding: 1.2rem 1rem 4rem; }
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.1rem 1.2rem;
  margin-bottom: 1rem;
}
.placeholder { color: var(--muted); text-align: center; padding: 2.5rem 1rem; }
.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: 0.6rem;
}
.section-head h2 { margin: 0; }
.subtle { color: var(--muted); font-size: 0.9rem; }
.msg-error { color: var(--warn); font-weight: 600; }

/* ---- Today checklist ---- */
.dose {
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
}
.dose.taken { background: var(--good-bg); border-color: var(--good); }
.dose .dose-time {
  font-size: 1.3rem;
  font-weight: 700;
  min-width: 6.2rem;
}
.dose .dose-info { flex: 1; min-width: 12rem; }
.dose .dose-name { font-size: 1.15rem; font-weight: 700; }
.dose .dose-detail { color: var(--muted); }
.dose .taken-note { color: var(--good); font-weight: 600; }
.dose button { min-width: 10.5rem; font-size: 1.05rem; padding: 0.85rem 1rem; }
.progress { font-size: 1.05rem; font-weight: 600; }
.progress.done { color: var(--good); }

/* ---- My Meds ---- */
.med-row .med-name { font-size: 1.15rem; font-weight: 700; }
.med-row .med-detail { color: var(--muted); margin: 0.15rem 0 0.5rem; }
.med-row .med-actions { display: flex; gap: 0.6rem; flex-wrap: wrap; }
.med-row.inactive { opacity: 0.75; border-style: dashed; }
.badge {
  display: inline-block;
  background: #eceae4;
  border-radius: 8px;
  padding: 0.1rem 0.55rem;
  font-size: 0.85rem;
  margin-right: 0.35rem;
}
#med-form label { display: block; font-weight: 600; margin: 0.8rem 0 0.25rem; }
.time-row { display: flex; gap: 0.6rem; margin-bottom: 0.5rem; align-items: center; }
.time-row input[type="time"] { max-width: 11rem; }
.time-row input.time-label { flex: 1; }
.time-row .remove-time { padding: 0.5rem 0.8rem; }
.form-actions { display: flex; gap: 0.7rem; margin-top: 1.2rem; flex-wrap: wrap; }

/* ---- Look Up ---- */
.search-row { display: flex; gap: 0.7rem; }
.search-row input { flex: 1; font-size: 1.1rem; }
.search-row button { font-size: 1.05rem; min-width: 7rem; }
.result-title { font-size: 1.2rem; font-weight: 700; }
.result-sub { color: var(--muted); margin-bottom: 0.6rem; }
.interaction-alert {
  background: #fdf0e5;
  border: 2px solid var(--warn);
  border-radius: 10px;
  padding: 0.8rem 1rem;
  margin: 0.6rem 0;
  color: #7a2600;
  font-weight: 600;
}
details.label-section {
  border: 1px solid var(--line);
  border-radius: 10px;
  margin: 0.45rem 0;
  background: #fbfaf7;
}
details.label-section summary {
  cursor: pointer;
  font-weight: 700;
  padding: 0.7rem 0.9rem;
  list-style-position: inside;
}
details.label-section[open] summary { border-bottom: 1px solid var(--line); }
details.label-section .section-text { padding: 0.7rem 0.9rem; }
.sources-list { padding-left: 1.2rem; }
.sources-list li { margin: 0.35rem 0; }
.sources-list a { color: var(--brand); font-weight: 600; }
.disclaimer {
  background: #eef3fa;
  border: 1px solid #c4d4ea;
  border-radius: 10px;
  padding: 0.7rem 1rem;
  color: #23406b;
  font-size: 0.92rem;
}

/* ---- News ---- */
.news-filters { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-bottom: 1rem; }
.news-filters button {
  background: #eceae4;
  color: var(--ink);
  padding: 0.45rem 0.9rem;
  font-size: 0.9rem;
  border-radius: 999px;
}
.news-filters button.active { background: var(--brand); color: #fff; }
.news-item .news-source {
  display: inline-block;
  background: #eef3fa;
  color: #23406b;
  border-radius: 8px;
  padding: 0.05rem 0.55rem;
  font-size: 0.82rem;
  font-weight: 600;
  margin-right: 0.5rem;
}
.news-item .news-date { color: var(--muted); font-size: 0.85rem; }
.news-item .news-title { display: block; font-size: 1.1rem; font-weight: 700; color: var(--brand); margin: 0.3rem 0; text-decoration: none; }
.news-item .news-title:hover { text-decoration: underline; }
.news-item .news-summary { color: var(--ink); }
