/* Door — one dark theme, quiet and editorial like the other home-screen apps. */
:root {
  color-scheme: dark;
  --bg: #111113;
  --card: #1a1a1e;
  --raise: #222227;
  --line: #2b2b31;
  --track: #24242a;
  --ink: #f2efe8;
  --ink2: #aaa69e;   /* muted text, AA on --bg and --card */
  --ink3: #6c6963;   /* decoration only */
  --gilt: #d9ae5f;
  --gilt-ink: #1a1408;
  --closed: #8fc1aa;
  --open: #eaa43f;
  --alert: #e4704f;
  --plate: #5b2a5c;  /* the app icon's mulberry plate */
  --r: 14px;
  --gutter: 16px;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-variant-numeric: tabular-nums;
  -webkit-tap-highlight-color: transparent;
}
main {
  max-width: 560px;
  margin: 0 auto;
  padding: calc(env(safe-area-inset-top) + 10px) var(--gutter) calc(env(safe-area-inset-bottom) + 40px);
}
[hidden] { display: none !important; }
h1 { font-size: 23px; font-weight: 650; margin: 0 0 8px; letter-spacing: -0.01em; }
h2 { font-size: 18px; font-weight: 650; margin: 0; }
p { margin: 0 0 10px; }
code { font: 13px/1.3 ui-monospace, "Cascadia Mono", Consolas, monospace; word-break: break-all; color: var(--ink); }
b { font-weight: 600; }
.muted { color: var(--ink2); }
.small { font-size: 13px; }
.ic { display: inline-flex; width: 18px; height: 18px; vertical-align: -3px; }
.ic svg, .icon-btn svg, .stepper svg { width: 100%; height: 100%; }
svg { fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

.top { display: flex; align-items: center; gap: 10px; min-height: 44px; margin-bottom: 6px; }
.brand { font-size: 12px; font-weight: 650; letter-spacing: .14em; text-transform: uppercase; color: var(--ink2); }
.live { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--ink2); margin-left: auto; }
.live::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--ink3); }
.live:empty { visibility: hidden; }
.live.ok::before { background: var(--closed); }
.live.warn::before { background: var(--open); }
.live.bad::before { background: var(--alert); }
.icon-btn {
  width: 44px; height: 44px; margin-right: -10px; padding: 11px;
  border: 0; background: none; color: var(--ink2); border-radius: 50%; cursor: pointer;
}
.icon-btn:hover { color: var(--ink); }

.banner { margin: 4px 0 14px; padding: 12px 14px; border-radius: var(--r); background: #2a1d17; color: #f3c9b8; font-size: 14px; border: 1px solid #4a2c20; }
.banner.good { background: #172520; color: #bfe3d2; border-color: #24453a; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 14px 16px; margin-bottom: 14px; }
.intro p { color: var(--ink2); }
.sec-label { font-size: 11px; font-weight: 650; letter-spacing: .12em; text-transform: uppercase; color: var(--ink2); }
.sec-label.pad { margin: 22px 0 8px; }
.row-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; margin-bottom: 10px; }

/* hero */
.hero { padding: 26px 2px 22px; }
.sensor { font-size: 13px; color: var(--ink2); min-height: 19px; }
.state { font-size: 64px; line-height: 1.02; font-weight: 680; letter-spacing: -0.035em; margin: 2px 0 6px; transition: color .25s; }
.hero.closed .state { color: var(--closed); }
.hero.open .state { color: var(--open); }
.hero.alerted .state { color: var(--alert); }
.hero.unknown .state { color: var(--ink3); }
.since { font-size: 16px; color: var(--ink); min-height: 23px; }
.alertline { font-size: 13px; color: var(--ink2); margin-top: 6px; min-height: 19px; display: flex; align-items: center; gap: 6px; }
.alertline .ic { width: 15px; height: 15px; vertical-align: 0; }
.hero.alerted .alertline { color: var(--alert); }

/* today strip */
.strip { position: relative; height: 30px; border-radius: 8px; background: var(--track); overflow: hidden; }
.strip .seg { position: absolute; top: 0; bottom: 0; min-width: 3px; background: var(--open); border-radius: 2px; }
.strip .seg.brief { background: var(--open); opacity: .75; }
.strip .seg.gap { background: repeating-linear-gradient(135deg, transparent 0 4px, rgba(255,255,255,.09) 4px 8px); border-radius: 0; }
.strip .future { position: absolute; top: 0; bottom: 0; right: 0; background: var(--bg); opacity: .55; }
.strip .now { position: absolute; top: 0; bottom: 0; width: 2px; background: var(--ink); opacity: .7; }
.axis { display: flex; justify-content: space-between; font-size: 11px; color: var(--ink2); margin-top: 5px; }

/* history */
.history .day { margin-bottom: 12px; background: var(--card); border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; }
.history .day-head { display: flex; justify-content: space-between; align-items: baseline; padding: 11px 16px 9px; border-bottom: 1px solid var(--line); }
.history .day-head b { font-size: 14px; }
.history .day-head span { font-size: 12px; color: var(--ink2); }
.history .item { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; padding: 10px 16px; border-top: 1px solid var(--line); }
.history .item:first-of-type { border-top: 0; }
.history .when { font-size: 15px; }
.history .dur { font-size: 14px; color: var(--ink2); white-space: nowrap; }
.history .sub { font-size: 12px; color: var(--ink2); margin-top: 2px; display: flex; align-items: center; gap: 5px; }
.history .sub .ic { width: 13px; height: 13px; vertical-align: 0; }
.history .item.ongoing .when, .history .item.ongoing .dur { color: var(--open); }
.history .item.alerted .sub { color: var(--alert); }
.history .item.gap .when { color: var(--ink2); font-size: 14px; }
.history .empty { padding: 14px 16px; color: var(--ink2); font-size: 14px; }
.more { display: block; margin: 6px auto 0; }

/* buttons + forms */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; padding: 10px 16px; border-radius: 12px;
  font: inherit; font-weight: 550; color: var(--ink); background: var(--raise); border: 1px solid var(--line);
  text-decoration: none; cursor: pointer;
}
.btn:hover { border-color: var(--ink3); }
.btn.primary { background: var(--gilt); color: var(--gilt-ink); border-color: var(--gilt); }
.btn.danger { color: #f0a58f; }
.btn:disabled { opacity: .5; cursor: default; }
.link { font: inherit; font-size: 14px; color: var(--gilt); background: none; border: 0; padding: 10px 2px; cursor: pointer; min-height: 44px; }
.btns { display: flex; flex-wrap: wrap; gap: 8px; }
.btns.end { justify-content: flex-end; }
:focus-visible { outline: 2px solid var(--gilt); outline-offset: 2px; }

.steps { list-style: none; counter-reset: step; padding: 0; margin: 0; }
.steps > li { counter-increment: step; position: relative; padding: 0 0 22px 40px; }
.steps > li::before {
  content: counter(step); position: absolute; left: 0; top: -2px; width: 26px; height: 26px; border-radius: 50%;
  display: grid; place-items: center; font-size: 13px; font-weight: 650; background: var(--raise); border: 1px solid var(--line); color: var(--gilt);
}
.kv { display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; margin: 0; font-size: 14px; }
.kv dt { color: var(--ink2); }
.kv dd { margin: 0; }
.kv .link { padding: 0 4px; min-height: 0; }
.creds { display: grid; gap: 12px; margin-top: 6px; }
.creds label { display: grid; gap: 6px; font-size: 13px; color: var(--ink2); }
input:not([type=checkbox]) {
  font: 15px/1.3 ui-monospace, "Cascadia Mono", Consolas, monospace; color: var(--ink);
  background: var(--bg); border: 1px solid var(--line); border-radius: 10px; padding: 12px; min-height: 44px; width: 100%;
}
input:focus { border-color: var(--gilt); outline: none; }

/* settings sheet */
dialog { color: var(--ink); background: var(--card); border: 1px solid var(--line); padding: 0; }
dialog::backdrop { background: rgba(0, 0, 0, .6); }
.sheet {
  width: min(560px, 100%); max-width: 100%; max-height: 92dvh; margin: auto auto 0; border-radius: 20px 20px 0 0;
  padding: 6px var(--gutter) calc(env(safe-area-inset-bottom) + 20px); border-bottom: 0;
}
@media (min-width: 600px) { .sheet { margin: auto; border-radius: 20px; border-bottom: 1px solid var(--line); } }
.sheet-head { display: flex; align-items: center; justify-content: space-between; padding: 8px 0; position: sticky; top: 0; background: var(--card); z-index: 1; }
.group { padding: 16px 0; border-top: 1px solid var(--line); }
.group .sec-label { margin-bottom: 10px; }
.switch-row, .stepper-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 48px; }
input[type=checkbox][role=switch] {
  appearance: none; width: 48px; height: 28px; border-radius: 14px; background: var(--track); border: 1px solid var(--line);
  position: relative; cursor: pointer; flex: none; transition: background .2s;
}
input[type=checkbox][role=switch]::after {
  content: ""; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%; background: var(--ink2); transition: transform .2s, background .2s;
}
input[type=checkbox][role=switch]:checked { background: var(--gilt); border-color: var(--gilt); }
input[type=checkbox][role=switch]:checked::after { transform: translateX(20px); background: var(--gilt-ink); }
.stepper { display: flex; align-items: center; gap: 4px; }
.stepper button { width: 44px; height: 44px; padding: 12px; border-radius: 12px; border: 1px solid var(--line); background: var(--raise); color: var(--ink); cursor: pointer; }
.stepper output { min-width: 72px; text-align: center; font-weight: 600; }
.qr { margin-top: 12px; }
.qr-img { width: min(280px, 100%); aspect-ratio: 1; background: #fff; border-radius: 12px; padding: 20px; margin-bottom: 12px; }
.qr-img svg { width: 100%; height: 100%; display: block; stroke: none; }
.foot { margin-top: 14px; }

.confirm { width: min(380px, calc(100% - 32px)); border-radius: 18px; padding: 20px; }
.confirm p { margin-bottom: 18px; }

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