:root {
  color-scheme: light;
  --canvas: #edf1f2;
  --white: #fcfdfd;
  --ink: #152738;
  --muted: #4d616d;
  --line: #d1dce1;
  --blue: #27465a;
  --dark: #142636;
  --deep: #12212f;
  --lime: #dbf58d;
  --light-text: #cbdae2;
  --digits: "Bahnschrift", "Segoe UI", system-ui, sans-serif;
  font: 16px/1.55 "Segoe UI Variable", "Noto Sans HK", "PingFang HK", "Microsoft JhengHei", system-ui, sans-serif;
  background: var(--canvas);
  color: var(--ink);
}
*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; min-width: 280px; }
a { color: var(--blue); }
button, input, select { font: inherit; }
button, .button { display: inline-flex; justify-content: center; align-items: center; min-height: 44px; padding: .55rem .95rem; border: 1px solid #beccd2; border-radius: .5rem; background: var(--white); color: var(--ink); cursor: pointer; text-decoration: none; font-weight: 680; touch-action: manipulation; }
button:hover, .button:hover { background: #e5edf0; border-color: #90a4af; }
button.primary, .button.primary { border-color: #abc655; background: var(--lime); color: var(--deep); }
button.primary:hover, .button.primary:hover { background: #eaffae; border-color: #789234; }
button.danger { color: #8e3029; }
button:disabled { cursor: default; opacity: .55; }
:focus-visible { outline: 3px solid #286688; outline-offset: 3px; }
h1, h2, h3, p { margin: 0; }
h1, h2, h3 { line-height: 1.22; text-wrap: balance; scroll-margin-top: 1rem; }
h1 { font-size: clamp(2.05rem, 5vw, 3.2rem); font-weight: 780; letter-spacing: -.055em; }
h2 { font-size: 1.28rem; }
h3 { font-size: 1.05rem; }
small, .muted { color: var(--muted); }
.skip { position: fixed; z-index: 10; left: 1rem; top: -6rem; background: white; padding: .6rem 1rem; }
.skip:focus { top: .5rem; }
.site-header { background: var(--deep); border-bottom: 1px solid #3c5361; color: white; }
.site-header :focus-visible { outline-color: var(--lime); }
.header-inner { width: min(1120px, calc(100% - 64px)); min-height: 76px; display: flex; align-items: center; justify-content: space-between; gap: .65rem 1.5rem; margin: 0 auto; }
.brand { color: white; display: inline-flex; align-items: center; gap: .72rem; font-size: 1.05rem; font-weight: 750; text-decoration: none; white-space: nowrap; }
.brand-mark { position: relative; display: grid; place-items: center; width: 32px; height: 32px; border-radius: 9px; background: var(--lime); }
.brand-mark::before { content: ''; width: 17px; height: 12px; border: 2px solid var(--deep); border-radius: 4px; }
.brand-mark::after { content: ''; position: absolute; width: 8px; height: 2px; background: var(--deep); top: 14px; left: 12px; }
.nav { display: flex; align-items: center; gap: .25rem; flex-wrap: wrap; }
.nav a { position: relative; min-height: 46px; display: inline-grid; align-items: center; padding: .45rem .82rem; color: #c4d1d9; border-radius: .35rem; text-decoration: none; font-weight: 650; }
.nav a:hover { background: #263c4d; color: #fff; }
.nav a[aria-current] { color: var(--lime); background: #24394a; }
.nav a[aria-current]::after { content: ''; height: 2px; position: absolute; inset: auto .7rem 3px; border-radius: 2px; background: var(--lime); }
.logout { flex: 0 0 auto; background: transparent; border-color: #5c7180; color: #edf4f7; }
.logout:hover { background: #263d4e; border-color: #9caeb8; }
.layout { width: min(1120px, calc(100% - 64px)); margin: 2.7rem auto 4rem; }
.page-title { margin-bottom: 1.55rem; display: flex; align-items: end; justify-content: space-between; gap: .75rem 1rem; flex-wrap: wrap; }
.page-title p { color: var(--muted); margin-top: .43rem; }
.panel, .next-panel { border: 1px solid var(--line); border-radius: .85rem; padding: clamp(1rem, 3vw, 1.55rem); }
.panel { background: var(--white); }
.next-panel { color: #f0f6f9; border-color: var(--dark); background: linear-gradient(114deg, #142636 34%, #233f51); min-height: 265px; display: grid; grid-template-columns: minmax(0, 1.12fr) minmax(0, .88fr); align-items: center; gap: .6rem; }
.next-copy { display: grid; gap: .55rem; position: relative; z-index: 1; padding-left: clamp(0rem, 1vw, .75rem); }
.next-panel p { color: var(--light-text); overflow-wrap: anywhere; }
.next-panel h2 { color: var(--lime); font-size: .94rem; font-weight: 700; }
.next-time { font: 600 clamp(3.6rem, 8vw, 6.5rem)/.95 var(--digits); letter-spacing: -.07em; font-variant-numeric: tabular-nums; }
.next-med { font-size: 1.2rem; font-weight: 690; overflow-wrap: anywhere; }
.columns { display: grid; grid-template-columns: minmax(0, 2.08fr) minmax(0, 1fr); gap: 1rem; align-items: stretch; }
.device-summary { display: grid; align-content: center; gap: 1.25rem; }
.device-summary .section-head { align-items: start; }
.summary-details { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: .45rem .7rem; padding: .9rem 0; margin: 0; border-block: 1px solid var(--line); }
.summary-details dt { color: var(--muted); }
.summary-details dd { margin: 0; text-align: right; font-weight: 650; overflow-wrap: anywhere; }
.device-link { justify-content: space-between; }
.device-link::after { content: '↗'; font-family: var(--digits); }
.spaced { margin-top: 1.15rem; }
.stack { display: grid; gap: .9rem; }
.stack-tight { display: grid; gap: .45rem; }
.actions { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; }
.section-head { display: flex; gap: .7rem; flex-wrap: wrap; align-items: center; justify-content: space-between; }
.indicator { display: inline-flex; align-items: center; gap: .39rem; color: var(--muted); font-size: .84rem; font-weight: 700; white-space: nowrap; }
.dot { inline-size: .55rem; block-size: .55rem; flex: 0 0 auto; border-radius: 50%; background: #758592; }
.dot.online { background: #2b795a; }
.dose-list, .clean-list { list-style: none; margin: 0; padding: 0; }
.dose-row, .entry-row { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: .8rem 1rem; padding: .85rem 0; }
.entry-row { grid-template-columns: minmax(0, 1fr) auto; }
.dose-row + .dose-row, .entry-row + .entry-row { border-top: 1px solid var(--line); }
.dose-time { color: var(--blue); white-space: nowrap; font: 650 1.23rem/1.3 var(--digits); font-variant-numeric: tabular-nums; min-width: 4.2rem; }
.med-info { overflow-wrap: anywhere; }
.status { display: inline-block; width: fit-content; border-radius: .35rem; padding: .18rem .53rem; background: #e9eff1; color: #344958; font-size: .85rem; font-weight: 650; white-space: nowrap; }
.status.confirmed, .status.applied { background: #e5f0cc; color: #40551e; }
.status.due, .status.queued { background: #e1ecf7; color: #214864; }
.status.missed, .status.skipped, .status.expired { background: #f9ede2; color: #7b3917; }
.warning { padding: .65rem .9rem; border-radius: .65rem; background: #f9ede2; color: #733719; }
.auth-layout { display: grid; grid-template-columns: 1.1fr 1fr; width: min(900px, 100%); margin: 3.25rem auto 0; min-height: 445px; border: 1px solid var(--line); border-radius: .9rem; overflow: hidden; }
.auth-intro { display: grid; align-content: center; gap: .65rem; color: var(--light-text); background: linear-gradient(136deg, #172b3a, #284759); padding: clamp(1.4rem, 5vw, 3.3rem); }
.auth-intro-title { color: #f3f9fd; font-size: clamp(2rem, 4vw, 2.7rem); font-weight: 780; letter-spacing: -.055em; }
.auth-card { border: none; border-radius: 0; display: grid; align-content: center; padding: clamp(1.4rem, 5vw, 3rem); }
.auth-card h1 { font-size: 1.95rem; margin-bottom: .5rem; }
form label { display: grid; gap: .3rem; font-weight: 650; }
input:not([type="checkbox"]), select { width: 100%; color: var(--ink); background: white; border: 1px solid #a6b8c1; border-radius: .5rem; min-height: 44px; padding: .55rem .65rem; }
input[type="checkbox"] { width: 1.2rem; height: 1.2rem; margin: 0; accent-color: var(--blue); }
form label.inline { display: flex; align-items: center; gap: .55rem; min-height: 36px; }
fieldset { border: 1px solid var(--line); border-radius: .55rem; padding: .35rem .75rem; }
legend { font-weight: 650; padding: 0 .3rem; }
dialog { color: var(--ink); border: 1px solid var(--line); border-radius: .85rem; padding: 1.4rem; width: min(540px, calc(100% - 2rem)); max-height: calc(100% - 2rem); overflow: auto; overscroll-behavior: contain; }
dialog::backdrop { background: #14231fd0; }
.hardware-board { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: clamp(1.15rem, 5vw, 4rem); padding: clamp(1.1rem, 3vw, 2.05rem); border-radius: .85rem; color: #f3f7fb; background: linear-gradient(114deg, #142636, #284456); }
.hardware-board .indicator { color: #e0eaf0; }
.hardware-board .dot.online { background: var(--lime); box-shadow: 0 0 9px #ddffa465; }
.board-device { display: grid; gap: .5rem; }
.board-device .box-drawing { width: min(100%, 350px); justify-self: center; }
.details { align-self: center; display: grid; grid-template-columns: minmax(0, 1fr) auto; margin: 0; gap: .55rem 1rem; padding: .25rem 0 .25rem clamp(1.2rem, 4vw, 3rem); border-left: 1px solid #557080; }
.details dt { color: var(--light-text); }
.details dd { margin: 0; text-align: right; overflow-wrap: anywhere; font-weight: 650; font-variant-numeric: tabular-nums; }
.control-panel h2 { margin-bottom: .55rem; }
.control-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: .55rem 1rem; padding: .8rem 0; border-top: 1px solid var(--line); }
.control-row:last-child { padding-bottom: 0; }
.control-description { min-width: 0; display: flex; align-items: center; gap: .8rem; }
.control-icon { flex: 0 0 auto; display: grid; place-items: center; width: 39px; height: 39px; border-radius: .55rem; color: #315164; background: #e8eff2; }
.control-icon.red { color: #ac4e42; background: #f5e9e6; }
.control-icon.green { color: #526c23; background: #edf2df; }
.control-icon.red::before, .control-icon.green::before { content: ''; width: 11px; height: 11px; border-radius: 50%; border: 2px solid currentColor; background: currentColor; box-shadow: inset 0 0 0 2px #ffffffb3; }
.control-icon.buzzer::before { content: '≋'; font: 750 1.3rem/1 var(--digits); }
.control-icon.lid::before { content: ''; width: 17px; height: 12px; border: 2px solid currentColor; border-top-width: 4px; border-radius: 4px; }
.history-list .dose-row { content-visibility: auto; contain-intrinsic-size: auto 76px; }
.box-drawing { position: relative; overflow: hidden; isolation: isolate; width: 100%; max-width: 385px; aspect-ratio: 1.6; }
.box-drawing::before { content: ''; position: absolute; inset: 0; background: radial-gradient(circle, #7595a5 1px, transparent 1.2px) center / 11px 11px; opacity: .62; mask-image: radial-gradient(ellipse, #000 25%, transparent 72%); }
.box-drawing::after { content: ''; position: absolute; inset: 12% 12% 10%; z-index: -1; border-radius: 50%; background: radial-gradient(ellipse, #61898b6e, transparent 68%); }
.box-graphic { position: absolute; inset: 0; transform: rotate(-9deg) skewX(-6deg); }
.box-base, .box-lid, .box-tray, .box-shadow { position: absolute; left: 18%; width: 65%; border-radius: 17% / 28%; }
.box-shadow { top: 54%; height: 27%; background: #06121a99; filter: blur(10px); transform: translate(5%, 23%); }
.box-base { top: 48%; height: 30%; border: 1px solid #9cb2ba; background: linear-gradient(165deg, #b4c8cd 8%, #77939f 48%, #566e79 92%); box-shadow: 0 4px 0 #364f5b, 0 10px 14px #091a23a8; }
.box-tray { top: 36%; height: 29%; border: 1px solid #ddedf1; background: linear-gradient(160deg, #849eab, #4a6775); box-shadow: inset 0 0 0 5px #b7cbd3, inset 0 7px 16px #3d5867; }
.box-lid { top: 32%; height: 32%; border: 1px solid #e6f1f5; background: linear-gradient(151deg, #eef5f4 3%, #c5d9dc 66%, #a7bfc8); box-shadow: 0 4px 0 #9eb7bd, 0 6px 9px #314a558c; transform-origin: 50% 8%; transition: transform .24s ease-out; }
.box-drawing[data-lid='open'] .box-lid { transform: translateY(-26%) rotate(-8deg) scaleY(.74); }
.box-groove { position: absolute; top: 38%; left: 41%; width: 18%; height: 8%; border-radius: 20px; background: #8babb4; box-shadow: 0 1px 0 #edf7f8; }
.signal-red, .signal-green { position: absolute; top: 72%; width: 4%; aspect-ratio: 1; border-radius: 50%; background: #415764; box-shadow: 0 0 0 1px #b1c9d388; }
.signal-red { right: 19%; }
.signal-green { right: 11%; }
.box-drawing[data-red='on'] .signal-red { background: #ff8a7a; box-shadow: 0 0 8px 2px #f97666; }
.box-drawing[data-green='on'] .signal-green { background: #cbfc88; box-shadow: 0 0 8px 2px #c9ef78; }
.signal-buzzer { position: absolute; top: 70%; left: 12%; width: 13%; height: 14%; border-radius: 3px; background: repeating-linear-gradient(90deg, #415764 0 2px, transparent 2px 4px); }
.box-drawing[data-buzzer='on'] .signal-buzzer { background: repeating-linear-gradient(90deg, #f1e098 0 2px, transparent 2px 4px); }
.code { font-family: ui-monospace, monospace; overflow-wrap: anywhere; }
.announcement { position: fixed; z-index: 3; bottom: max(1rem, env(safe-area-inset-bottom)); left: 50%; transform: translateX(-50%); width: max-content; max-width: calc(100% - 2rem); background: var(--dark); color: #fff; padding: .7rem 1rem; border-radius: .55rem; }
.loading { padding-top: 2rem; color: var(--muted); }
@media (max-width: 750px) {
  .header-inner { flex-wrap: wrap; padding: .55rem 0; }
  .nav { order: 3; flex-basis: 100%; }
  .layout { margin-top: 1.6rem; }
  .columns { grid-template-columns: minmax(0, 1fr); }
  .device-summary { gap: .7rem; }
}
@media (max-width: 560px) {
  .header-inner, .layout { width: calc(100% - 28px); padding-left: env(safe-area-inset-left); padding-right: env(safe-area-inset-right); }
  .dose-row { grid-template-columns: auto minmax(0, 1fr); }
  .dose-row > :last-child { grid-column: 2; }
  .entry-row { grid-template-columns: minmax(0, 1fr); gap: .4rem; }
  .next-panel { min-height: 197px; grid-template-columns: minmax(0, 1.25fr) minmax(0, .75fr); }
  .next-panel .box-drawing { min-width: 110px; justify-self: end; }
  .next-time { font-size: clamp(3rem, 13vw, 5rem); }
  .auth-layout, .hardware-board { grid-template-columns: minmax(0, 1fr); }
  .auth-layout { margin-top: 1.2rem; }
  .auth-intro .box-drawing { display: none; }
  .details { padding: 1rem 0 0; border-left: none; border-top: 1px solid #557080; }
  .board-device .box-drawing { width: min(95%, 268px); }
  .nav { gap: .12rem; }
  .nav a { padding-inline: .5rem; }
  .nav a[aria-current]::after { inset-inline: .4rem; }
  .control-row { gap: .65rem .55rem; }
  .control-row .actions { justify-content: end; }
  .control-row button { padding-inline: .65rem; }
}
@media (max-width: 360px) {
  .next-panel .box-drawing { min-width: 85px; }
  .control-row { grid-template-columns: minmax(0, 1fr); }
  .control-row .actions { justify-content: start; }
}
@media (prefers-reduced-motion: reduce) {
  .box-lid { transition: none; }
}
