/* 平安守護 — 「屋企嘅照護日誌」 design system.
   Warm paper diary, hand-stitched dashed accents (from doodlepad), calm
   green for safety, honey for daily life, clay red reserved for falls.
   Depth = warm layered shadows + faint card gradients, never grey and flat.
   jf-openhuninn has a single weight: hierarchy comes from size, colour
   and letter-spacing, not font-weight. */

@font-face {
  font-family: "jf-openhuninn";
  src: url("/fonts/jf-openhuninn-2.1.ttf") format("truetype");
  font-display: swap;
}

:root {
  --paper: #fbf7ee;
  --paper-deep: #f3ecdd;
  --card: #fffdf8;
  --ink: #33302a;
  --muted: #7a715f;
  --line: #e7ddc9;
  --line-soft: #efe7d6;

  --brand: #1b6e54;
  --brand-bright: #2a8265;
  --brand-deep: #14523f;
  --honey: #e8a13d;
  --honey-deep: #c07f1f;
  --honey-soft: #fdf3e0;

  --ok-bg: #e3f0e6;
  --ok-ink: #1b6e54;
  --warn-bg: #fbf0da;
  --warn-ink: #96690a;
  --alert-bg: #f9e6e0;
  --alert-ink: #b03427;
  --alert-strong: #c2372a;
  --neutral-bg: #eee9dd;
  --neutral-ink: #7a715f;

  --r-sm: 12px;
  --r-md: 18px;
  --r-lg: 24px;
  --r-pill: 999px;

  /* Warm-tinted layered shadows (never pure black). */
  --shadow-sm: 0 1px 2px rgba(93, 74, 38, 0.05), 0 2px 8px rgba(93, 74, 38, 0.06);
  --shadow-md: 0 2px 4px rgba(93, 74, 38, 0.06), 0 8px 22px rgba(93, 74, 38, 0.1);
  --shadow-lg: 0 4px 10px rgba(93, 74, 38, 0.08), 0 18px 40px rgba(93, 74, 38, 0.14);

  --sp-1: 8px;
  --sp-2: 16px;
  --sp-3: 24px;
  --sp-4: 32px;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  color: var(--ink);
  font-family: "jf-openhuninn", "Microsoft JhengHei", system-ui, sans-serif;
  font-size: 17px;
  line-height: 1.65;
  /* Paper: warm base with softly lit corners — depth without decoration. */
  background:
    radial-gradient(1100px 500px at 8% -5%, rgba(232, 161, 61, 0.07), transparent 60%),
    radial-gradient(900px 480px at 100% 0%, rgba(42, 130, 101, 0.06), transparent 55%),
    var(--paper);
  background-attachment: fixed;
}

a { color: var(--brand); }

h1, h2, h3, h4 { line-height: 1.3; margin: 0 0 12px; color: var(--ink); }
h1 { font-size: 26px; }
h2 { font-size: 19px; }
h3 { font-size: 17px; }
h4 { font-size: 15px; }

/* Card section titles read as diary headings: spaced, with a short
   honey dashed underline — the hand-stitched signature accent. */
.card > h2 {
  font-size: 16px;
  letter-spacing: 0.14em;
  color: var(--brand-deep);
  padding-bottom: 8px;
  margin-bottom: 14px;
  position: relative;
}
.card > h2::after {
  content: "";
  position: absolute;
  left: 1px;
  bottom: 0;
  width: 44px;
  border-bottom: 3px dashed rgba(232, 161, 61, 0.75);
  border-radius: 2px;
}

.muted { color: var(--muted); font-size: 14px; }
.mono { font-family: ui-monospace, Consolas, monospace; font-size: 0.95em; }
code {
  font-family: ui-monospace, Consolas, monospace;
  font-size: 0.9em;
  background: var(--paper-deep);
  padding: 1px 6px;
  border-radius: 6px;
}

svg.ic {
  width: 1.2em;
  height: 1.2em;
  stroke: currentColor;
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  vertical-align: -0.22em;
  flex: none;
}

/* ---------- App shell ---------- */

header.appbar {
  position: sticky;
  top: 0;
  z-index: 30;
  background: rgba(251, 247, 238, 0.92);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line-soft);
  display: flex;
  align-items: center;
  gap: 24px;
  padding: 10px 20px;
}
.brand {
  font-size: 20px;
  color: var(--brand-deep);
  letter-spacing: 0.05em;
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.brand svg.ic { color: var(--honey); width: 1.15em; height: 1.15em; }

nav.mainnav { display: flex; gap: 4px; }
nav.mainnav a.nav-item {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  min-height: 50px;
  min-width: 60px;
  padding: 5px 12px;
  border-radius: var(--r-md);
  color: var(--muted);
  text-decoration: none;
  font-size: 12.5px;
  letter-spacing: 0.06em;
  transition: color 0.15s, background 0.15s;
}
nav.mainnav a.nav-item svg {
  width: 23px;
  height: 23px;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.9;
  stroke-linecap: round;
  stroke-linejoin: round;
}
nav.mainnav a.nav-item.active {
  color: var(--brand-deep);
  background: linear-gradient(180deg, #e9f2e9, #dfeee4);
  box-shadow: inset 0 0 0 1px rgba(27, 110, 84, 0.18);
}
.nav-badge {
  position: absolute;
  top: 3px;
  right: 9px;
  min-width: 17px;
  height: 17px;
  padding: 0 4px;
  border-radius: var(--r-pill);
  background: var(--alert-strong);
  color: #fff;
  font-size: 11px;
  line-height: 17px;
  text-align: center;
  box-shadow: 0 1px 4px rgba(194, 55, 42, 0.5);
}

main {
  width: 100%;
  max-width: 720px;
  margin: 0 auto;
  padding: 20px 16px 48px;
}

@media (max-width: 767px) {
  /* Floating rounded dock, inset from the edges — crafted, not a flat bar. */
  nav.mainnav {
    position: fixed;
    left: 10px;
    right: 10px;
    bottom: calc(10px + env(safe-area-inset-bottom));
    z-index: 40;
    background: rgba(255, 253, 248, 0.96);
    backdrop-filter: blur(10px);
    border: 1px solid var(--line);
    border-radius: 26px;
    box-shadow: var(--shadow-lg);
    justify-content: space-around;
    padding: 7px 6px;
  }
  nav.mainnav a.nav-item { flex: 1; min-width: 0; padding: 5px 4px; }
  body { padding-bottom: calc(96px + env(safe-area-inset-bottom)); }
  main { padding: 16px 14px 32px; }
}
@media (min-width: 768px) {
  main.wide { max-width: 980px; }
}

/* ---------- Alert banner ---------- */

.alert-banner {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 0 0 var(--sp-2);
  padding: 14px 18px;
  border-radius: var(--r-md);
  background: linear-gradient(180deg, #cf4536, var(--alert-strong));
  color: #fff;
  font-size: 17px;
  text-decoration: none;
  box-shadow: 0 4px 14px rgba(194, 55, 42, 0.35);
}
.alert-banner svg.ic { width: 1.35em; height: 1.35em; }
.alert-banner.secondary {
  background: var(--alert-bg);
  color: var(--alert-ink);
  border: 2px dashed #e5b1a6;
  box-shadow: none;
}
.alert-banner[hidden] { display: none; }

/* ---------- Cards ---------- */

.card {
  background: linear-gradient(180deg, #ffffff, var(--card) 65%);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-sm);
  padding: 20px;
  margin: 0 0 var(--sp-2);
  transition: box-shadow 0.2s, border-color 0.2s;
}
.card.heavy { box-shadow: var(--shadow-md); }
@media (hover: hover) {
  .card:hover { box-shadow: var(--shadow-md); border-color: #dccfb2; }
}
.card > h3:first-child { margin-top: 0; }

.storage-note {
  border: 2px dashed #e6c98f;
  background: var(--honey-soft);
  color: var(--warn-ink);
  border-radius: var(--r-md);
  padding: 10px 16px;
  font-size: 14px;
  margin: 0 0 var(--sp-2);
}

/* ---------- Status semantics ---------- */

.pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 5px 15px;
  border-radius: var(--r-pill);
  font-size: 14px;
  background: var(--neutral-bg);
  color: var(--neutral-ink);
  box-shadow: inset 0 0 0 1px rgba(122, 113, 95, 0.16);
  white-space: nowrap;
}
.pill.ok { background: var(--ok-bg); color: var(--ok-ink); box-shadow: inset 0 0 0 1px rgba(27, 110, 84, 0.22); }
.pill.warn { background: var(--warn-bg); color: var(--warn-ink); box-shadow: inset 0 0 0 1px rgba(150, 105, 10, 0.22); }
.pill.alert { background: var(--alert-bg); color: var(--alert-ink); box-shadow: inset 0 0 0 1px rgba(176, 52, 39, 0.24); }
.pill.neutral { background: var(--neutral-bg); color: var(--neutral-ink); }

.dot {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--neutral-ink);
  flex: none;
}
.dot.ok { background: var(--brand-bright); }
.dot.warn { background: var(--honey); }
.dot.alert { background: var(--alert-strong); }

/* 安心環 — the signature. A ring that breathes slowly when all is well
   and pulses urgently on alert. */
.status-ring {
  width: 46px;
  height: 46px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  flex: none;
  background: #fff;
  border: 2px dashed rgba(122, 113, 95, 0.45);
}
.status-ring.ok {
  border-color: rgba(42, 130, 101, 0.5);
  animation: breathe 4.5s ease-in-out infinite;
}
.status-ring.warn { border-color: rgba(232, 161, 61, 0.65); }
.status-ring.alert {
  border-color: rgba(194, 55, 42, 0.75);
  animation: urgent 1.1s ease-in-out infinite;
}
@keyframes breathe {
  0%, 100% { box-shadow: 0 0 0 0 rgba(42, 130, 101, 0.22); }
  50% { box-shadow: 0 0 0 9px rgba(42, 130, 101, 0); }
}
@keyframes urgent {
  0%, 100% { box-shadow: 0 0 0 0 rgba(194, 55, 42, 0.4); }
  50% { box-shadow: 0 0 0 10px rgba(194, 55, 42, 0); }
}

/* ---------- Home: hero ---------- */

.hero {
  position: relative;
  overflow: hidden;
  border-radius: var(--r-lg);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-md);
  padding: 26px 22px 24px;
  margin: 0 0 var(--sp-2);
  background: linear-gradient(180deg, #ffffff, var(--card));
}
.hero::before {
  content: "";
  position: absolute;
  inset: -40% -20% auto -20%;
  height: 150%;
  pointer-events: none;
  background: radial-gradient(closest-side, rgba(122, 113, 95, 0.1), transparent 72%);
  opacity: 0.9;
}
.hero.ok::before { background: radial-gradient(closest-side, rgba(42, 130, 101, 0.16), transparent 72%); }
.hero.warn::before { background: radial-gradient(closest-side, rgba(232, 161, 61, 0.2), transparent 72%); }
.hero.alert::before { background: radial-gradient(closest-side, rgba(194, 55, 42, 0.16), transparent 72%); }
.hero.alert { border-color: #e5b1a6; }
.hero > * { position: relative; }
.hero .headline {
  display: flex;
  align-items: center;
  gap: 14px;
  font-size: 31px;
  line-height: 1.25;
}
.hero.alert .headline { color: var(--alert-ink); }
.hero .sub { margin: 10px 0 0 60px; color: var(--muted); font-size: 14px; }
.hero .sub .offline { color: var(--alert-ink); }
.hero .actions { margin-top: 20px; }

/* ---------- Buttons ---------- */

button, .btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: linear-gradient(180deg, var(--brand-bright), var(--brand));
  color: #fff;
  border: none;
  border-radius: var(--r-md);
  min-height: 48px;
  padding: 10px 24px;
  font-size: 17px;
  font-family: inherit;
  letter-spacing: 0.04em;
  cursor: pointer;
  text-decoration: none;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.22), 0 2px 8px rgba(27, 110, 84, 0.28);
  transition: filter 0.15s, transform 0.05s, box-shadow 0.15s;
}
button:hover, .btn:hover { filter: brightness(1.06); }
button:active, .btn:active { transform: translateY(1px); box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.15), 0 1px 3px rgba(27, 110, 84, 0.25); }
button:disabled { opacity: 0.5; cursor: default; }
.btn.block, button.block { display: flex; width: 100%; }
.btn.secondary, button.secondary {
  background: var(--card);
  color: var(--brand-deep);
  border: 2px dashed rgba(27, 110, 84, 0.4);
  box-shadow: none;
}
.btn.secondary:hover, button.secondary:hover { background: #f2f7f1; filter: none; }
.btn.danger, button.danger {
  background: linear-gradient(180deg, #cf4536, var(--alert-strong));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.2), 0 2px 8px rgba(194, 55, 42, 0.3);
}
.btn.small, button.small { min-height: 38px; padding: 6px 16px; font-size: 15px; }

form { margin: 0; }
form + form { margin-top: 10px; }

:focus-visible {
  outline: 3px solid rgba(232, 161, 61, 0.85);
  outline-offset: 2px;
  border-radius: 6px;
}

/* ---------- Status strip ---------- */

.status-strip {
  position: relative;
  height: 30px;
  border-radius: var(--r-pill);
  background:
    repeating-linear-gradient(90deg, transparent 0, transparent calc(25% - 1px), rgba(93, 74, 38, 0.12) calc(25% - 1px), rgba(93, 74, 38, 0.12) 25%),
    var(--paper-deep);
  box-shadow: inset 0 1px 3px rgba(93, 74, 38, 0.12);
  overflow: hidden;
}
.status-strip .seg { position: absolute; top: 0; bottom: 0; opacity: 0.92; }
.status-strip .seg.ok { background: linear-gradient(180deg, #93c8a8, #7cb894); }
.status-strip .seg.warn { background: linear-gradient(180deg, #ecc27a, #e0ad55); }
.status-strip .seg.alert { background: linear-gradient(180deg, #e07a67, #d5604c); }
.status-strip .seg.neutral { background: linear-gradient(180deg, #d9d2c1, #cec6b2); }
.strip-scale {
  display: flex;
  justify-content: space-between;
  color: var(--muted);
  font-size: 12px;
  margin-top: 5px;
}
.strip-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 16px;
  margin-top: 10px;
  color: var(--muted);
  font-size: 13px;
}
.strip-legend span { display: inline-flex; align-items: center; gap: 6px; }
.strip-legend i { width: 12px; height: 12px; border-radius: 4px; display: inline-block; }
.strip-legend i.ok { background: #7cb894; }
.strip-legend i.warn { background: #e0ad55; }
.strip-legend i.alert { background: #d5604c; }
.strip-legend i.neutral { background: #cec6b2; }

/* ---------- Live view ---------- */

.live-topline {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px 16px;
  margin: 0 0 var(--sp-2);
}
.live-topline .pill { font-size: 16px; padding: 7px 18px; }
.video-wrap {
  position: relative;
  border-radius: var(--r-lg);
  overflow: hidden;
  background: #221f18;
  box-shadow: var(--shadow-lg);
  border: 1px solid #d9cdb4;
}
.video-wrap.alert { outline: 4px solid var(--alert-strong); outline-offset: 2px; }
img.preview {
  width: 100%;
  height: auto;
  display: block;
  min-height: 180px;
  object-fit: contain;
}
.video-placeholder {
  display: grid;
  place-items: center;
  min-height: 220px;
  color: #b3ab99;
  font-size: 15px;
}
.video-controls {
  display: flex;
  gap: 10px;
  margin-top: 14px;
  flex-wrap: wrap;
}
.video-controls button { flex: 1; min-width: 140px; }
button.toggle.off {
  background: var(--card);
  color: var(--muted);
  border: 2px dashed var(--line);
  box-shadow: none;
}

/* ---------- Event rows ---------- */

.event-row {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 0;
  border-bottom: 1px dashed var(--line);
  text-decoration: none;
  color: var(--ink);
}
.event-row:last-child { border-bottom: none; }
.event-row .thumb {
  width: 96px;
  aspect-ratio: 16/9;
  object-fit: cover;
  border-radius: var(--r-sm);
  background: var(--paper-deep);
  box-shadow: var(--shadow-sm);
  flex: none;
}
.event-row .thumb.placeholder {
  display: grid;
  place-items: center;
  color: var(--muted);
  font-size: 12px;
}
.event-row .t { font-size: 21px; }
.event-row .meta { color: var(--muted); font-size: 13px; margin-top: 2px; }
.event-row.unacked {
  border: 2px dashed #e5b1a6;
  border-radius: var(--r-md);
  background: #fdf6f3;
  padding: 12px 14px;
  margin-bottom: 10px;
}

.incident-list { display: block; }
.day-head {
  position: sticky;
  top: 58px;
  z-index: 5;
  background: linear-gradient(180deg, var(--paper) 70%, transparent);
  padding: 8px 2px 10px;
  font-size: 14px;
  letter-spacing: 0.1em;
  color: var(--muted);
}

.empty-state { text-align: center; padding: 30px 16px 26px; color: var(--muted); }
.empty-state .empty-art {
  width: 64px;
  height: 64px;
  margin: 0 auto 12px;
  color: var(--brand-bright);
  display: block;
}
.empty-state .empty-art svg { width: 100%; height: 100%; stroke-width: 1.7; }
.empty-state .big { font-size: 40px; line-height: 1; margin-bottom: 10px; }
.empty-state p { margin: 0; }

/* ---------- Incident detail ---------- */

.incident-photo {
  display: block;
  border-radius: var(--r-lg);
  overflow: hidden;
  box-shadow: var(--shadow-lg);
  border: 1px solid #d9cdb4;
  margin: 0 0 var(--sp-2);
}
.incident-photo img { width: 100%; height: auto; display: block; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 8px 18px; font-size: 15px; }
.kv .k { color: var(--muted); }

.backlink {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin: 0 0 10px;
  color: var(--muted);
  text-decoration: none;
  font-size: 15px;
  min-height: 44px;
}
.backlink:hover { color: var(--brand-deep); }

/* ---------- Calendar ---------- */

.cal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 0 0 var(--sp-2);
}
.cal-head h1 { margin: 0; letter-spacing: 0.04em; }
.cal-nav {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 46px;
  height: 46px;
  border-radius: var(--r-md);
  border: 2px dashed var(--line);
  background: var(--card);
  color: var(--brand-deep);
  text-decoration: none;
  transition: border-color 0.15s, background 0.15s;
}
.cal-nav:hover { border-color: rgba(27, 110, 84, 0.45); background: #f2f7f1; }
.cal-nav.disabled { opacity: 0.3; pointer-events: none; }
.calendar {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 6px;
}
.calendar .dow {
  text-align: center;
  color: var(--muted);
  font-size: 12.5px;
  letter-spacing: 0.1em;
  padding: 4px 0 6px;
}
.calendar .day-cell {
  position: relative;
  min-height: 54px;
  border-radius: var(--r-sm);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  text-decoration: none;
  color: var(--ink);
  font-size: 16px;
}
.calendar .day-cell.blank { visibility: hidden; }
.calendar .day-cell.nodata { color: #c9c1ad; pointer-events: none; }
.calendar a.day-cell {
  background: linear-gradient(180deg, #ffffff, var(--card));
  border: 1px solid var(--line);
  box-shadow: var(--shadow-sm);
  transition: transform 0.12s, box-shadow 0.12s, border-color 0.12s;
}
@media (hover: hover) {
  .calendar a.day-cell:hover {
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
    border-color: rgba(27, 110, 84, 0.4);
  }
}
.calendar .day-cell.today { box-shadow: inset 0 0 0 2px var(--honey), var(--shadow-sm); }
.calendar .marks { display: flex; gap: 4px; height: 7px; }
.calendar .marks i { width: 7px; height: 7px; border-radius: 50%; display: block; }
.calendar .marks i.rec { background: var(--brand-bright); }
.calendar .marks i.fall { background: var(--alert-strong); }
.cal-legend {
  display: flex;
  gap: 18px;
  margin-top: 14px;
  color: var(--muted);
  font-size: 13px;
}
.cal-legend span { display: inline-flex; align-items: center; gap: 6px; }
.cal-legend i { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.cal-legend i.rec { background: var(--brand-bright); }
.cal-legend i.fall { background: var(--alert-strong); }

/* ---------- Day review ---------- */

.day-title {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px 14px;
  margin: 0 0 var(--sp-2);
}
.day-title h1 { margin: 0; }

.count-scroller {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(220px, 260px);
  gap: 12px;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  padding: 4px 2px 12px;
  -webkit-overflow-scrolling: touch;
}
.count-card {
  scroll-snap-align: start;
  background: linear-gradient(180deg, #fffdf6, var(--honey-soft));
  border: 1px solid #eeddb9;
  border-radius: var(--r-md);
  box-shadow: var(--shadow-sm);
  padding: 14px 16px;
}
.count-card .cat { font-size: 14px; letter-spacing: 0.1em; color: var(--honey-deep); }
.count-card .n { font-size: 27px; margin: 3px 0 8px; }
.count-card .why { font-size: 13px; color: var(--muted); margin-top: 10px; }
.evidence { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.evidence a {
  display: inline-flex;
  flex-direction: column;
  gap: 2px;
  font-size: 12px;
  color: var(--brand);
  text-decoration: none;
  text-align: center;
}
.evidence img {
  width: 76px;
  aspect-ratio: 16/9;
  object-fit: cover;
  border-radius: 8px;
  background: var(--paper-deep);
  box-shadow: var(--shadow-sm);
}

/* Timeline as a stitched diary spine: dashed vertical line + knots. */
.timeline { position: relative; }
.timeline::before {
  content: "";
  position: absolute;
  top: 10px;
  bottom: 10px;
  left: 58px;
  border-left: 2px dashed rgba(122, 113, 95, 0.35);
}
.timeline .activity-row {
  position: relative;
  display: grid;
  grid-template-columns: 48px 150px minmax(0, 1fr);
  gap: 12px;
  align-items: center;
  padding: 12px 0;
}
.timeline .activity-row::after {
  content: "";
  position: absolute;
  left: 53px;
  top: 50%;
  width: 12px;
  height: 12px;
  margin-top: -6px;
  border-radius: 50%;
  background: var(--card);
  border: 2px solid var(--brand-bright);
  box-shadow: 0 0 0 3px var(--paper);
}
.timeline .activity-row.quiet::after { border-color: #cdc5b1; }
.timeline .activity-row p { margin: 0 0 2px; }
.activity-time { font-size: 15px; color: var(--brand-deep); }
.activity-thumb {
  width: 132px;
  aspect-ratio: 16/9;
  object-fit: cover;
  display: block;
  border-radius: var(--r-sm);
  background: var(--paper-deep);
  box-shadow: var(--shadow-sm);
  cursor: zoom-in;
  border: 0;
  padding: 0;
  margin-left: 14px;
}
.activity-missing {
  width: 132px;
  aspect-ratio: 16/9;
  display: grid;
  place-items: center;
  border-radius: var(--r-sm);
  background: var(--paper-deep);
  border: 2px dashed var(--line);
  color: var(--muted);
  font-size: 12px;
  text-align: center;
  margin-left: 14px;
}
.timeline.collapsed .activity-row.quiet { display: none; }
.timeline-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  margin: 0 0 8px;
}
.timeline-toolbar h2 {
  margin: 0;
  font-size: 16px;
  letter-spacing: 0.14em;
  color: var(--brand-deep);
  position: relative;
  padding-bottom: 8px;
}
.timeline-toolbar h2::after {
  content: "";
  position: absolute;
  left: 1px;
  bottom: 0;
  width: 44px;
  border-bottom: 3px dashed rgba(232, 161, 61, 0.75);
  border-radius: 2px;
}
@media (max-width: 430px) {
  .timeline::before { left: 50px; }
  .timeline .activity-row { grid-template-columns: 42px 118px minmax(0, 1fr); gap: 8px; }
  .timeline .activity-row::after { left: 45px; }
  .activity-thumb, .activity-missing { width: 104px; margin-left: 12px; }
}

/* ---------- Lightbox ---------- */

.lightbox {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(40, 35, 24, 0.88);
  display: grid;
  place-items: center;
  padding: 20px;
}
.lightbox img { max-width: 100%; max-height: 90vh; border-radius: var(--r-md); box-shadow: var(--shadow-lg); }
.lightbox[hidden] { display: none; }

/* ---------- System ---------- */

.sys-preview {
  width: 100%;
  max-width: 420px;
  border-radius: var(--r-md);
  display: block;
  background: var(--paper-deep);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--line);
  margin: 0 0 12px;
}
.file-label {
  margin: 14px 0 6px;
}
#cal-photo {
  display: block;
  width: 100%;
  margin: 0 0 10px;
  font-family: inherit;
  font-size: 15px;
  color: var(--muted);
}
#btn-calibrate-photo { margin-top: 0; }
.sys-line { display: flex; align-items: center; gap: 10px; padding: 8px 0; font-size: 15px; }
details.advanced { font-size: 14px; color: var(--muted); }
details.advanced summary {
  cursor: pointer;
  letter-spacing: 0.08em;
  min-height: 44px;
  display: flex;
  align-items: center;
}
details.advanced ul { margin: 6px 0; padding-left: 22px; }

/* ---------- Auth ---------- */

main.auth { max-width: 420px; padding-top: 8vh; }
.auth .brand {
  font-size: 28px;
  display: flex;
  justify-content: center;
  text-align: center;
}
.auth .tagline {
  text-align: center;
  color: var(--muted);
  font-size: 14px;
  letter-spacing: 0.28em;
  margin: 6px 0 24px;
}
label {
  display: block;
  font-size: 14px;
  letter-spacing: 0.08em;
  color: var(--muted);
  margin-bottom: 6px;
}
input[type=password] {
  width: 100%;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  min-height: 56px;
  padding: 12px 16px;
  font-size: 18px;
  font-family: inherit;
  box-shadow: inset 0 1px 3px rgba(93, 74, 38, 0.06);
}
input[type=password]:focus {
  outline: 2px solid var(--brand-bright);
  outline-offset: 1px;
}
.err { color: var(--alert-ink); }

/* ---------- Layout helpers ---------- */

.home-grid { display: block; }
@media (min-width: 768px) {
  .home-grid {
    display: grid;
    grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr);
    gap: var(--sp-2);
    align-items: start;
  }
  .home-grid .col > .card:last-child { margin-bottom: 0; }
}

/* Gentle page entrance; one orchestrated moment, then stillness. */
@media (prefers-reduced-motion: no-preference) {
  main > * {
    animation: rise 0.45s ease-out backwards;
  }
  main > *:nth-child(2) { animation-delay: 0.06s; }
  main > *:nth-child(3) { animation-delay: 0.12s; }
  main > *:nth-child(4) { animation-delay: 0.18s; }
  main > *:nth-child(n+5) { animation-delay: 0.24s; }
  @keyframes rise {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: none; }
  }
}
@media (prefers-reduced-motion: reduce) {
  .status-ring.ok, .status-ring.alert { animation: none; }
}
