/* Luby's Health Passport — palette, type and components carried over from
   the phone-mockup sample: warm paper ground, Fraunces/Figtree type,
   pine/marigold/clay/slate as category color, cards over hairline lines. */

:root {
  --ink: #23201B; --ink-soft: #6E675C; --ink-faint: #A69E90;
  --paper: #EFEBE3; --card: #FFFFFF; --line: #E7E1D6;
  --pine: #3F7A6B; --pine-tint: #E7F0EC;
  --marigold: #D98E23; --marigold-tint: #FAF0DC;
  --clay: #CB4235; --clay-tint: #FBE7E3;
  --slate: #5B7A99; --slate-tint: #E9F0F6;

  --radius: 18px; --radius-sm: 12px; --radius-pill: 999px;
  --display: "Fraunces", "Noto Serif TC", serif;
  --body: "Figtree", "Noto Sans TC", system-ui, -apple-system, sans-serif;
  --shadow: 0 1px 2px rgba(35, 32, 27, .04), 0 6px 18px rgba(35, 32, 27, .05);

  /* Kept for continuity with any leftover references. */
  --space-1: 4px; --space-2: 8px; --space-3: 12px; --space-4: 16px; --space-6: 24px; --space-8: 32px;
  --radius-md: var(--radius-sm); --radius-lg: var(--radius);
  --color-divider: var(--line);
}

*, *::before, *::after { box-sizing: border-box; }
body {
  margin: 0; background: var(--paper); color: var(--ink);
  font-family: var(--body); font-size: 15px; line-height: 1.55; font-weight: 400;
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3, h4, h5, h6 { font-family: var(--display); font-weight: 600; line-height: 1.15; margin: 0 0 8px; text-wrap: balance; }
h1 { font-size: 34px; } h2 { font-size: 26px; } h3 { font-size: 20px; }
h4 { font-size: 17px; } h5 { font-size: 15px; }
h6 { font-size: 12px; letter-spacing: 0.06em; text-transform: uppercase; font-family: var(--body); font-weight: 700; }
p { margin: 0 0 12px; }
a { color: var(--pine); text-underline-offset: 3px; }
img { display: block; max-width: 100%; }
figure { margin: 0; }
.text-muted { color: var(--ink-soft); }
:focus { outline: none; }
:focus-visible { outline: 2px solid var(--pine); outline-offset: 2px; }

.plate { border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); object-fit: cover; }

.hr { height: 1px; border: 0; margin: 24px 0; background: var(--line); }

/* — buttons — */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  cursor: pointer; text-decoration: none;
  font-family: var(--body); font-weight: 600; font-size: 14px; line-height: 1.2; color: var(--ink);
  background: var(--card); border: 1px solid var(--line);
  padding: 10px 16px; border-radius: var(--radius-sm);
}
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn-primary { background: var(--pine); border-color: var(--pine); color: #fff; }
.btn-primary:hover { background: color-mix(in srgb, var(--pine) 88%, black); }
.btn-secondary:hover { background: color-mix(in srgb, var(--ink) 6%, transparent); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--pine); padding-inline: 6px; }
.btn-ghost:hover { background: var(--pine-tint); }
.btn-block { width: 100%; margin-top: 8px; }

/* — forms — */
.field { display: flex; flex-direction: column; gap: 0; margin-bottom: 12px; }
.field > label {
  display: block; font-size: 12px; font-weight: 700; margin-bottom: 6px; color: var(--ink-soft);
}
.input, select.input {
  width: 100%; min-height: 40px; padding: 8px 12px; font: inherit;
  font-size: 14px; color: var(--ink); caret-color: var(--pine);
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius-sm);
}
.input:hover { border-color: var(--ink-faint); }
.input:focus-visible { border-color: var(--pine); outline-offset: 0; }
textarea.input { min-height: 70px; resize: vertical; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

.seg {
  display: inline-flex; flex-wrap: wrap; overflow: hidden;
  border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--card);
}
.seg-opt { display: inline-flex; align-items: center; gap: 6px; padding: 8px 12px; font-size: 13px; cursor: pointer; }
.seg-opt input { position: absolute; opacity: 0; width: 0; height: 0; pointer-events: none; }
.seg-opt + .seg-opt { border-left: 1px solid var(--line); }
.seg-opt:has(input:checked) { color: #fff; background: var(--pine); }
.seg-opt:not(:has(input:checked)):hover { background: color-mix(in srgb, var(--ink) 6%, transparent); }
.seg-opt:has(input:focus-visible) { outline: 2px solid var(--pine); outline-offset: -2px; }

/* — cards — */
.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px; box-shadow: var(--shadow);
}
.card-kicker { font-size: 10px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--ink-faint); }
.card-title { font-family: var(--display); font-weight: 600; font-size: 16px; line-height: 1.25; }
.card-meta { display: flex; align-items: center; gap: 6px; font-size: 11.5px; color: var(--ink-soft); }

/* — chips / badges — */
.chip { display: inline-flex; align-items: center; gap: 4px; font-size: 11px; font-weight: 600; padding: 3px 10px; border-radius: var(--radius-pill); background: var(--paper); color: var(--ink-soft); }
.chip.pine { background: var(--pine-tint); color: var(--pine); }
.chip.marigold { background: var(--marigold-tint); color: var(--marigold); }
.chip.clay { background: var(--clay-tint); color: var(--clay); }
.chip.slate { background: var(--slate-tint); color: var(--slate); }
.badge { font-size: 11px; font-weight: 700; padding: 4px 10px; border-radius: var(--radius-pill); letter-spacing: 0.02em; }
.badge.clay { background: var(--clay-tint); color: var(--clay); }
.badge.pine { background: var(--pine-tint); color: var(--pine); }
.badge.marigold { background: var(--marigold-tint); color: var(--marigold); }

/* — navigation — */
.nav { display: flex; align-items: center; gap: 24px; padding: 18px 24px; border-bottom: 1px solid var(--line); }
.nav-brand { font-family: var(--display); font-weight: 600; font-size: 19px; margin-right: auto; color: var(--ink); }
.nav a { color: var(--ink-soft); text-decoration: none; font-family: var(--body); font-weight: 600; font-size: 14px; }
.nav a:hover { color: var(--pine); }
.nav a[aria-current="page"] { color: var(--pine); }
.nav-right { margin-left: auto; display: flex; align-items: center; gap: 14px; }
.nav-name { font-family: var(--display); font-weight: 600; font-size: 14px; }

/* — responsive grids (desktop base; overridden under the mobile breakpoint) — */
.hero-grid { display: grid; grid-template-columns: 280px 1fr; gap: 24px; }
.hero-photo { width: 100%; height: 280px; object-fit: cover; }
.stat-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; }
.split-grid { display: grid; grid-template-columns: 1.3fr 1fr; gap: 24px; }
.case-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }

/* — tables — */
.table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.table th {
  text-align: left; font-size: 10.5px; letter-spacing: 0.06em; text-transform: uppercase; font-weight: 700;
  color: var(--ink-faint); padding: 10px; border-bottom: 1px solid var(--line);
}
.table td { padding: 10px; border-bottom: 1px solid var(--line); }
.table tbody tr:hover { background: color-mix(in srgb, var(--ink) 3%, transparent); }
.table-wrap { overflow-x: auto; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 4px 8px; }

/* — review / alert card — */
.review { background: var(--card); border: 1px solid var(--clay); border-radius: var(--radius); padding: 15px 16px; box-shadow: var(--shadow); position: relative; overflow: hidden; }
.review::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 4px; background: var(--clay); }
.review .rhead { display: flex; align-items: center; gap: 9px; margin-bottom: 6px; }
.review h3 { font-size: 16.5px; margin: 0; }
.review p { font-size: 13px; color: var(--ink-soft); margin: 5px 0 0; line-height: 1.55; }
.review .actions { display: flex; gap: 8px; margin-top: 13px; }

/* — timeline — */
.timeline { margin-top: 4px; display: flex; flex-direction: column; }
.tl-row { display: grid; grid-template-columns: 52px 1fr; gap: 12px; }
.tl-time { text-align: right; padding-top: 15px; font-size: 12.5px; font-weight: 700; color: var(--ink-soft); font-variant-numeric: tabular-nums; }
.tl-track { position: relative; padding: 0 0 14px 20px; }
.tl-track::before { content: ""; position: absolute; left: 5px; top: 6px; bottom: -6px; width: 2px; background: var(--line); }
.tl-row:last-child .tl-track::before { display: none; }
.node { position: absolute; left: 0; top: 16px; width: 12px; height: 12px; border-radius: 50%; background: var(--card); border: 2.5px solid var(--ink-faint); z-index: 1; }
.node.pine { border-color: var(--pine); } .node.marigold { border-color: var(--marigold); }
.node.slate { border-color: var(--slate); } .node.clay { border-color: var(--clay); background: var(--clay); }

.ev { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 13px 15px; box-shadow: var(--shadow); }
.ev .top { display: flex; align-items: flex-start; gap: 11px; }
.glyph { width: 34px; height: 34px; border-radius: 11px; flex: none; display: grid; place-items: center; }
.glyph svg { width: 18px; height: 18px; }
.glyph.pine { background: var(--pine-tint); color: var(--pine); }
.glyph.marigold { background: var(--marigold-tint); color: var(--marigold); }
.glyph.slate { background: var(--slate-tint); color: var(--slate); }
.glyph.clay { background: var(--clay-tint); color: var(--clay); }
.ev .body { flex: 1; min-width: 0; }
.ev .cat { font-size: 11px; font-weight: 700; letter-spacing: 0.04em; color: var(--ink-faint); }
.ev .cat.clay { color: var(--clay); }
.ev h4 { margin: 2px 0 0; font-size: 15.5px; }
.ev .meta { font-size: 12.5px; color: var(--ink-soft); margin-top: 5px; line-height: 1.5; }
.ev .foot { display: flex; align-items: center; gap: 7px; margin-top: 10px; flex-wrap: wrap; }
.big { font-family: var(--display); font-size: 22px; font-weight: 600; line-height: 1; white-space: nowrap; }
.big small { font-size: 12px; font-family: var(--body); color: var(--ink-soft); font-weight: 600; }
.ev .big { margin-left: auto; padding-left: 8px; }
.ev.clay-border { border-color: var(--clay); }

/* — calendar (kept from the month-grid view, reskinned) — */
.lb-cal { display: grid; grid-template-columns: repeat(7, 1fr); }
.lb-cal-head { font-size: 11px; font-weight: 700; text-align: center; padding: 6px 0; color: var(--pine); background: var(--pine-tint); border-radius: var(--radius-sm); }
.lb-day { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 5px; border-radius: var(--radius-sm); cursor: pointer; border: none; background: none; font: inherit; }
.lb-day:hover { background: color-mix(in srgb, var(--ink) 6%, transparent); }
.lb-day.muted .lb-daynum { color: var(--ink-faint); opacity: .6; }
.lb-day.active .lb-daynum { background: var(--ink); color: #fff; border-radius: 50%; }
.lb-daynum { font-family: var(--display); font-weight: 600; font-size: 18px; font-variant-numeric: tabular-nums; width: 32px; height: 32px; display: flex; align-items: center; justify-content: center; }
.lb-dot { width: 5px; height: 5px; border-radius: 50%; background: var(--clay); }
.lb-dot-empty { width: 5px; height: 5px; }

/* — floating action button + bottom sheet — */
.fab {
  position: fixed; right: 24px; bottom: 24px; width: 58px; height: 58px; border-radius: 50%;
  border: none; cursor: pointer; background: var(--pine); color: #fff; display: grid; place-items: center;
  box-shadow: 0 8px 20px -4px rgba(63, 122, 107, .55); z-index: 15;
}
.fab svg { width: 26px; height: 26px; }
.fab:focus-visible { outline: 3px solid var(--ink); outline-offset: 2px; }

.sheet-bg {
  position: fixed; inset: 0; background: rgba(28, 26, 22, .38); opacity: 0; pointer-events: none;
  transition: opacity .22s; z-index: 20;
}
.sheet-bg.open { opacity: 1; pointer-events: auto; }
.sheet-bg[hidden] { display: none; }
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; margin: 0 auto; max-width: 480px;
  background: var(--paper); z-index: 21; max-height: 88vh; overflow-y: auto;
  border-radius: 26px 26px 0 0; padding: 10px 20px 28px; transform: translateY(102%);
  transition: transform .28s cubic-bezier(.32, .72, 0, 1); box-shadow: 0 -10px 40px rgba(0,0,0,.15);
}
.sheet.open { transform: translateY(0); }
.sheet[hidden] { display: none; }
.grab { width: 38px; height: 4px; border-radius: 4px; background: var(--line); margin: 6px auto 14px; }
.sheet h3 { margin-bottom: 14px; }
.sheet-back { display: inline-flex; align-items: center; gap: 4px; font-size: 13px; font-weight: 600; color: var(--ink-soft); background: none; border: none; cursor: pointer; padding: 0; margin-bottom: 10px; }
.sheet-back:hover { color: var(--pine); }

.addgrid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.addbtn {
  display: flex; align-items: center; gap: 11px; background: var(--card); border: 1px solid var(--line);
  border-radius: 14px; padding: 13px; font-family: inherit; font-size: 14px; font-weight: 600;
  color: var(--ink); cursor: pointer; text-align: left;
}
.addbtn:hover { border-color: var(--ink-faint); }
.addbtn:focus-visible { outline: 2px solid var(--pine); outline-offset: 2px; }
.addbtn .g { width: 32px; height: 32px; border-radius: 9px; display: grid; place-items: center; flex: none; }
.addbtn .g svg { width: 17px; height: 17px; }

.lb-skeleton { color: var(--ink-soft); font-size: 13px; padding: 24px 0; }
.lb-avatar { width: 36px; height: 36px; border-radius: 50%; object-fit: cover; }

/* ══════════════════════ Mobile (iPhone-width) layout ══════════════════════
   Covers iPhone SE (375) through Pro Max (430). Every grid above is defined
   as a class specifically so it can be overridden here — media queries
   can't win against inline styles, which is why those grids moved out of
   the page templates and into named classes. */
@media (max-width: 680px) {
  h1 { font-size: 28px; } h2 { font-size: 22px; } h3 { font-size: 18px; }

  .nav { padding: 14px 16px; gap: 14px; flex-wrap: wrap; row-gap: 10px; }
  .nav-brand { font-size: 16px; }
  .nav a { font-size: 13px; }
  .nav-right { gap: 10px; }
  .nav-name { display: none; }

  .hero-grid { grid-template-columns: 1fr; gap: 16px; }
  .hero-photo { height: 220px; }
  .stat-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .split-grid { grid-template-columns: 1fr; gap: 20px; }
  .case-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }

  .card { padding: 13px; }
  .big { font-size: 19px; }

  .addgrid { grid-template-columns: 1fr; }
  .sheet { padding-left: 16px; padding-right: 16px; max-width: 100%; }

  .table th, .table td { padding: 8px 6px; font-size: 12.5px; }

  .fab { right: 16px; bottom: 16px; width: 54px; height: 54px; }
}
