/* CELA Kindle: one hand-written stylesheet. Component vocabulary (one meaning each):
   .btn    button or button-like link          .field   text input / select
   .card   a book in the results grid          .panel   bordered surface block
   .chip   delivery status pill (icon + word)  .badge   role pill (Admin / User)
   .tag    settings source / status label      .flash   form-level message (.ok / .error)
   .banner full-bleed setup notice             .callout info box inside a panel
   .msg    field-level message (.error / .warn)
   Every colour comes from the tokens below; no inline styles, no external assets. */

/* ---------- tokens ---------- */
:root {
  color-scheme: light dark;
  --bg:#F5F4F0; --surface:#FFFFFF; --surface-2:#ECEAE4;
  --text:#1A1B1E; --text-2:#55595F;
  --border:#D8D5CE; --border-strong:#86857F;
  --accent:#2B59A8; --on-accent:#FFFFFF; --accent-soft:#E3EBF8;
  --ok:#17703A; --ok-soft:#E6F4EA;
  --danger:#B42318; --danger-soft:#FDECEA;
  --warn:#8A5300; --warn-soft:#FFF4DC;
  --tint-1:#E8EDF6; --tint-2:#EEE9DF; --tint-3:#E6EEE8; --tint-4:#F0E8EA;
  --scrim:rgba(20,20,22,.45);
  --shadow-cover:0 1px 2px rgba(0,0,0,.12), 0 4px 12px rgba(0,0,0,.10);
  --shadow-sheet:0 -8px 32px rgba(0,0,0,.18);
  --r-cover:8px; --r-ctl:12px; --r-card:16px; --r-sheet:20px;
  --sp-1:4px; --sp-2:8px; --sp-3:12px; --sp-4:16px; --sp-5:20px; --sp-6:24px; --sp-7:32px; --sp-8:40px;
  --safe-top:env(safe-area-inset-top, 0px); --safe-bottom:env(safe-area-inset-bottom, 0px);
  --safe-left:env(safe-area-inset-left, 0px); --safe-right:env(safe-area-inset-right, 0px);
  --font:-apple-system, BlinkMacSystemFont, "SF Pro Text", "Helvetica Neue", Helvetica, Arial, sans-serif;
  --mono:ui-monospace, "SF Mono", Menlo, monospace;
  /* type scale (base 17px = 1rem) */
  --fs-display:1.647rem; --fs-title:1.294rem; --fs-head:1.176rem; --fs-body:1rem;
  --fs-sub:.882rem; --fs-foot:.765rem; --fs-cap:.706rem;
  --r-pill:999px;
  /* bottom nav height follows the text size: link height = 32px + 1rem, plus padding and the hairline */
  --nav-link:calc(32px + 1rem); --nav-pad:6px;
  --nav-h:calc(var(--nav-link) + 2 * var(--nav-pad) + 1px);
  /* colour behind the iOS status bar (black-translucent keeps its text white) */
  --statusbar:#2B59A8;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg:#131416; --surface:#1D1F23; --surface-2:#2A2D33;
    --text:#EDEEF0; --text-2:#A3A8B0;
    --border:#33373E; --border-strong:#737881;
    --accent:#8DB4F5; --on-accent:#0B1B36; --accent-soft:#223253;
    --ok:#6CCB8A; --ok-soft:#1C3326;
    --danger:#F08A80; --danger-soft:#3A1F1D;
    --warn:#E3B35A; --warn-soft:#3A2F17;
    --tint-1:#242C3A; --tint-2:#302C24; --tint-3:#243028; --tint-4:#33282C;
    --scrim:rgba(0,0,0,.6);
    --shadow-cover:0 1px 2px rgba(0,0,0,.4), 0 4px 12px rgba(0,0,0,.35);
    --shadow-sheet:0 -8px 32px rgba(0,0,0,.6);
    --statusbar:#131416;
  }
}

/* ---------- base ---------- */
*, *::before, *::after { box-sizing: border-box; }
/* 17px everywhere; on iPhone/iPad follow Dynamic Type (the system body size).
   -apple-system-body is 13px in desktop Safari, so it is limited to touch Safari. */
html {
  scroll-padding-top: calc(var(--safe-top) + 12px);
  scroll-padding-bottom: calc(var(--nav-h) + 24px + var(--safe-bottom));
}
html:has(.screen-head.pin) { scroll-padding-top: calc(var(--safe-top) + 2rem + 88px); }
html:has(.savebar) { scroll-padding-bottom: calc(var(--nav-h) + 96px + var(--safe-bottom)); }
html { font-size: 106.25%; font-family: var(--font); -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
@supports (font: -apple-system-body) and (-webkit-touch-callout: none) {
  html { font: -apple-system-body; font-family: var(--font); }
}
body {
  margin: 0; background: var(--bg); color: var(--text); font-size: 1rem; line-height: 1.3;
  padding-top: var(--safe-top);
  padding-bottom: calc(var(--nav-h) + 23px + var(--safe-bottom));
}
body.no-nav { padding-bottom: var(--safe-bottom); }
/* paints the area under the status bar so its (white) text stays readable in both themes */
body::before {
  content: ""; position: fixed; top: 0; left: 0; right: 0; height: var(--safe-top);
  background: var(--statusbar); z-index: 40; pointer-events: none;
}
a { color: var(--accent); }
h1, h2, h3, p { margin: 0; }
h1 { font-size: var(--fs-body); line-height: 1.2; }
h2 { font-size: var(--fs-head); line-height: 1.2; font-weight: 700; }
button, input, select { font: inherit; color: inherit; margin: 0; }
input::placeholder { color: var(--text-2); opacity: 1; }
[hidden] { display: none !important; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
code {
  font-family: var(--mono); font-size: var(--fs-foot); background: var(--surface-2);
  padding: 2px 6px; border-radius: 6px; overflow-wrap: anywhere;
}
.muted { color: var(--text-2); }
.sub { font-size: var(--fs-sub); }
.foot { font-size: var(--fs-foot); }
.center { text-align: center; }
.vh { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- icons (inline SVG sprite in base.html) ---------- */
.i { flex: none; fill: none; stroke: currentColor; stroke-width: var(--sw, 2); stroke-linecap: round; stroke-linejoin: round; }
.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 50px;
  padding: 0 20px; border-radius: var(--r-ctl); border: 1px solid var(--border-strong);
  background: var(--surface); color: var(--text); font-weight: 600; font-size: var(--fs-body);
  cursor: pointer; text-decoration: none; text-align: center;
}
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.btn.small { min-height: 44px; padding: 0 14px; font-size: var(--fs-sub); }
.btn.danger { color: var(--danger); border-color: var(--danger); }
.btn.block { display: flex; width: 100%; }
.btn:disabled, .btn[aria-disabled="true"] { opacity: .45; cursor: not-allowed; }
.btn:active, .card:active { opacity: .7; }
.linklike {
  border: 0; background: none; padding: 0; min-height: 44px; color: var(--accent);
  font-weight: 600; font-size: var(--fs-sub); cursor: pointer; text-align: left;
}

/* ---------- fields ---------- */
.label { display: block; font-size: var(--fs-sub); font-weight: 600; margin-bottom: 6px; }
.opt { font-weight: 400; color: var(--text-2); }
.field {
  display: block; width: 100%; min-height: 52px; padding: 0 14px; border: 1px solid var(--border-strong);
  border-radius: var(--r-ctl); background: var(--surface); color: var(--text); font-size: var(--fs-body);
}
.field.invalid { border-color: var(--danger); box-shadow: inset 0 0 0 1px var(--danger); }
select.field {
  appearance: none; -webkit-appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, currentColor 50%), linear-gradient(135deg, currentColor 50%, transparent 50%);
  background-position: calc(100% - 20px) 50%, calc(100% - 14px) 50%;
  background-size: 6px 6px; background-repeat: no-repeat; padding-right: 40px;
}
.help { font-size: var(--fs-foot); color: var(--text-2); margin: 6px 0 0; line-height: 1.4; }
.stack { display: flex; flex-direction: column; gap: 16px; }
.stack.tight { gap: 12px; }
.row { display: flex; align-items: center; gap: 8px; }

/* Administrator switch: a visually hidden checkbox followed by .switch */
.toggle { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 44px; cursor: pointer; }
.switch { position: relative; display: inline-block; width: 51px; height: 31px; border-radius: 16px; background: var(--border-strong); flex: none; }
.switch::after { content: ""; position: absolute; top: 2px; left: 2px; width: 27px; height: 27px; border-radius: 50%; background: #fff; box-shadow: 0 2px 4px rgba(0,0,0,.25); }
.vh:focus-visible + .switch { outline: 3px solid var(--accent); outline-offset: 2px; }
input:checked + .switch { background: var(--accent); }
input:checked + .switch::after { left: 22px; }

/* ---------- messages ---------- */
/* flash: form-level message above a form. Always icon + words, never colour alone. */
.flash {
  display: flex; gap: 8px; align-items: flex-start; margin: 0; padding: 12px 14px; border-radius: var(--r-ctl);
  font-weight: 600; font-size: var(--fs-sub); line-height: 1.4; overflow-wrap: anywhere;
}
.flash .i { margin-top: 1px; }
.flash.ok { background: var(--ok-soft); color: var(--ok); }
.flash.error { background: var(--danger-soft); color: var(--danger); }
/* msg: field-level message under one input */
.msg { display: flex; gap: 6px; align-items: flex-start; margin: 6px 0 0; font-size: var(--fs-foot); font-weight: 600; line-height: 1.4; }
.msg .i { margin-top: 1px; }
.msg.error { color: var(--danger); }
.msg.warn { color: var(--warn); }
/* callout: neutral information inside a panel */
.callout {
  display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; border-radius: var(--r-ctl);
  background: var(--accent-soft); font-size: var(--fs-sub); line-height: 1.4;
}
.callout .i { margin-top: 1px; color: var(--accent); }
.callout strong { overflow-wrap: anywhere; }

/* setup-needed banner (full bleed, every logged-in page) */
.banner {
  display: flex; gap: 10px; align-items: flex-start; padding: 12px calc(16px + var(--safe-right)) 12px calc(16px + var(--safe-left)); background: var(--warn-soft);
  color: var(--text); border-bottom: 1px solid var(--border); font-size: var(--fs-sub); line-height: 1.35;
}
.banner .i { color: var(--warn); margin-top: 1px; }
.banner p { margin: 0; }
.banner-link { display: flex; align-items: center; min-height: 44px; font-weight: 600; }

/* ---------- panel, chip, badge, tag ---------- */
.panel {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-card);
  padding: 16px; display: flex; flex-direction: column; gap: 14px; min-width: 0;
}
.panel h2 .opt { font-size: var(--fs-sub); }

.chip {
  display: inline-flex; align-items: center; gap: 6px; min-height: 28px; padding: 0 10px 0 8px;
  border-radius: var(--r-pill); font-size: var(--fs-foot); font-weight: 600;
  background: var(--surface-2); color: var(--text-2); white-space: nowrap;
}
.chip .i { --sw: 2.2; }
.chip.busy { background: var(--accent-soft); color: var(--accent); }
.chip.done { background: var(--ok-soft); color: var(--ok); }
.chip.failed { background: var(--danger-soft); color: var(--danger); }

.badge {
  display: inline-flex; align-items: center; gap: 5px; min-height: 26px; padding: 0 9px 0 7px;
  border-radius: var(--r-pill); font-size: var(--fs-foot); font-weight: 600;
  background: var(--surface-2); color: var(--text-2);
}
.badge .i { --sw: 2.4; }
.badge.admin { background: var(--accent-soft); color: var(--accent); }

.tag {
  display: inline-flex; align-items: center; gap: 5px; min-height: 24px; padding: 0 8px; border-radius: 6px;
  background: var(--surface-2); color: var(--text-2); font-weight: 600; font-size: var(--fs-cap); white-space: normal;
}
.tag .i { --sw: 2.6; }
.tag.app { background: var(--accent-soft); color: var(--accent); }
.tag.unset { background: var(--warn-soft); color: var(--warn); }
.src { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; margin: 8px 0 0; font-size: var(--fs-foot); color: var(--text-2); }

/* ---------- toast ---------- */
.toast {
  position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(var(--nav-h) + 35px + var(--safe-bottom)); z-index: 30;
  width: max-content; max-width: calc(100vw - 32px - var(--safe-left) - var(--safe-right));
  padding: 12px 20px; border-radius: var(--r-pill);
  background: var(--surface); color: var(--text); border: 1px solid var(--border);
  box-shadow: var(--shadow-sheet); font-size: var(--fs-sub); font-weight: 600; text-align: center;
  overflow-wrap: anywhere;
}
/* idle: still rendered (so a text change is announced) but not visible */
.toast:not(.show) {
  width: 1px; height: 1px; padding: 0; border: 0; overflow: hidden; clip-path: inset(50%);
  box-shadow: none; opacity: 0; pointer-events: none;
}

/* ---------- motion (opt-in only) ---------- */
@keyframes rise { from { transform: translateY(24px); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes toast-rise { from { transform: translate(-50%, 16px); opacity: 0; } to { transform: translate(-50%, 0); opacity: 1; } }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes sk { 0%, 100% { opacity: 1; } 50% { opacity: .55; } }
@media (prefers-reduced-motion: no-preference) {
  .sheet { animation: rise .22s cubic-bezier(.2,.8,.2,1); }
  .backdrop { animation: fade .18s ease-out; }
  .toast.show { animation: toast-rise .18s cubic-bezier(.2,.8,.2,1); }
  .sk { animation: sk 1.4s ease-in-out infinite; }
  .nav a { transition: background-color .15s; }
}

/* ---------- layout, headers, bottom nav ---------- */
.wrap { max-width: 1000px; margin: 0 auto; padding: 0 calc(16px + var(--safe-right)) 0 calc(16px + var(--safe-left)); }
.wrap.narrow { max-width: 560px; }
.screen-head { max-width: 1000px; margin: 0 auto; padding: 8px calc(16px + var(--safe-right)) 12px calc(16px + var(--safe-left)); display: flex; flex-direction: column; gap: 4px; }
.screen-head.pin { position: sticky; top: var(--safe-top); z-index: 5; background: var(--bg); gap: 12px; }
.title { font-size: var(--fs-display); font-weight: 700; letter-spacing: -.01em; line-height: 1.2; }

/* sub-screens: Back on the left, title in the middle, optional action on the right */
.topbar { display: grid; grid-template-columns: minmax(max-content, 1fr) minmax(0, auto) minmax(max-content, 1fr); align-items: center; min-height: 52px; padding: 0 calc(8px + var(--safe-right)) 0 calc(8px + var(--safe-left)); max-width: 1000px; margin: 0 auto; }
.topbar h1 { font-size: var(--fs-body); font-weight: 600; text-align: center; margin: 0; overflow-wrap: anywhere; }
.topbar > :last-child { justify-self: end; }
.back {
  display: inline-flex; align-items: center; min-height: 44px; min-width: 44px; padding: 0 10px 0 4px;
  border: 0; background: none; color: var(--accent); font-size: var(--fs-body); text-decoration: none;
  border-radius: 10px; justify-self: start;
}
.back .i { --sw: 2.2; }
.topbar-action {
  display: inline-flex; align-items: center; gap: 6px; min-height: 44px; padding: 0 10px; font-weight: 600;
  font-size: var(--fs-body); border-radius: 10px; text-decoration: none; color: var(--accent); white-space: nowrap;
}

.nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10; display: flex; justify-content: center; gap: 4px;
  padding: var(--nav-pad) calc(8px + var(--safe-right)) calc(var(--nav-pad) + var(--safe-bottom)) calc(8px + var(--safe-left));
  background: var(--surface); border-top: 1px solid var(--border);
}
.nav a {
  flex: 1; min-width: 0; max-width: 180px; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 3px; height: var(--nav-link); padding: 0 2px; border-radius: var(--r-ctl); text-decoration: none; color: var(--text-2);
  font-size: min(var(--fs-cap), 15px); font-weight: 600;
}
.nav a > span { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav a:focus-visible { outline-offset: -3px; }
.nav a.on { color: var(--accent); background: var(--accent-soft); }
.nav a:active { opacity: .7; }

/* ---------- search screen ---------- */
.search { position: relative; display: flex; align-items: center; }
.search .search-icon { position: absolute; left: 14px; color: var(--text-2); pointer-events: none; }
.search .field { padding-left: 46px; padding-right: 48px; }
.search input[type="search"]::-webkit-search-cancel-button,
.search input[type="search"]::-webkit-search-decoration { -webkit-appearance: none; appearance: none; }
.search-clear {
  position: absolute; right: 4px; width: 44px; height: 44px; display: flex; align-items: center; justify-content: center;
  border: 0; background: none; color: var(--text-2); border-radius: 10px; cursor: pointer;
}
.status-line { font-size: var(--fs-sub); margin: 0 0 12px; min-height: 1.3em; }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(9em, 1fr)); gap: 20px 16px; }
.card {
  display: flex; flex-direction: column; justify-content: flex-start; align-items: stretch;
  width: 100%; max-width: 240px; min-width: 0; padding: 0; border: 0; background: none;
  text-align: left; color: inherit; cursor: pointer; border-radius: 10px;
}
.cover {
  position: relative; width: 100%; aspect-ratio: 2 / 3; border-radius: var(--r-cover); background: var(--surface-2);
  box-shadow: var(--shadow-cover); display: flex; align-items: center; justify-content: center;
  font-size: 2.4rem; font-weight: 700; color: var(--text-2); overflow: hidden;
}
.cover { flex: none; }
/* dark tints sit close to the page colour; an inset hairline keeps the placeholder cover visible */
@media (prefers-color-scheme: dark) {
  .cover { box-shadow: var(--shadow-cover), inset 0 0 0 1px var(--border-strong); }
  .job .cover { box-shadow: inset 0 0 0 1px var(--border-strong); }
}
.cover::before { content: ""; position: absolute; top: 0; bottom: 0; left: 0; width: 6px; background: rgba(0,0,0,.08); z-index: 1; }
.cover img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.cover.t1 { background: var(--tint-1); } .cover.t2 { background: var(--tint-2); }
.cover.t3 { background: var(--tint-3); } .cover.t4 { background: var(--tint-4); }
.ct {
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; margin-top: 8px;
  font-size: var(--fs-sub); font-weight: 600; line-height: 1.25; overflow-wrap: anywhere;
}
.ca { display: block; margin-top: 2px; font-size: var(--fs-foot); color: var(--text-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.more { display: flex; justify-content: center; }
.more .btn { margin: 20px 0 24px; }

.sk { background: var(--surface-2); border-radius: 8px; }
.sk-cover { aspect-ratio: 2 / 3; }
.sk-line { height: 14px; width: 90%; margin-top: 10px; }
.sk-line.short { height: 12px; width: 60%; margin-top: 6px; }

/* empty / no results / error / nothing yet */
.state { display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; gap: 12px; padding: 48px 16px 80px; }
.well { width: 72px; height: 72px; border-radius: 50%; display: flex; align-items: center; justify-content: center; background: var(--surface-2); color: var(--text-2); }
.well.accent { background: var(--accent-soft); color: var(--accent); }
.well.danger { background: var(--danger-soft); color: var(--danger); }
.state-body { color: var(--text-2); max-width: 28em; overflow-wrap: anywhere; }
.state .btn { margin-top: 8px; }

/* ---------- book bottom sheet ---------- */
.backdrop { position: fixed; inset: 0; background: var(--scrim); z-index: 20; }
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 21; max-height: 85vh; max-height: 85dvh; overflow-y: auto;
  margin: 0 auto; max-width: 600px; background: var(--surface); border-radius: var(--r-sheet) var(--r-sheet) 0 0;
  box-shadow: var(--shadow-sheet); padding: 8px calc(20px + var(--safe-right)) 0 calc(20px + var(--safe-left));
  display: flex; flex-direction: column; gap: 12px;
}
.grabber { flex: none; width: 36px; height: 5px; border-radius: 3px; background: var(--border-strong); opacity: .6; margin: 0 auto; }
.sheet-bar { position: sticky; top: 8px; z-index: 3; height: 0; margin-bottom: -12px; flex: none; }
.close {
  position: absolute; top: 2px; right: calc(-10px - var(--safe-right)); width: 44px; height: 44px; border-radius: 50%; border: 0;
  display: flex; align-items: center; justify-content: center; background: var(--surface-2); color: var(--text-2); cursor: pointer;
}
.close .i { --sw: 2.2; }
.sheet-head { display: flex; align-items: flex-start; gap: 16px; padding-right: 48px; margin-top: 4px; }
.cover.big { width: clamp(84px, 30vw, 112px); flex: none; }
.sheet-meta { min-width: 0; display: flex; flex-direction: column; gap: 4px; padding-top: 4px; }
.sheet-meta h2 { font-size: var(--fs-title); overflow-wrap: anywhere; }
.sheet-meta p { margin: 0; overflow-wrap: anywhere; }
.sheet-meta .foot { margin-top: 0; }
.summary { margin: 0; font-size: var(--fs-body); line-height: 1.45; }
.clamp { display: -webkit-box; -webkit-line-clamp: 5; -webkit-box-orient: vertical; overflow: hidden; }
.sends {
  display: flex; align-items: center; gap: 10px; padding: 12px 14px; border-radius: var(--r-ctl);
  background: var(--bg); font-size: var(--fs-sub);
}
.sends .i { color: var(--text-2); }
.sends strong { overflow-wrap: anywhere; }
.sends > span { min-width: 0; }
.sends .change { flex: none; margin-left: auto; display: inline-flex; align-items: center; min-height: 44px; padding: 0 6px; font-weight: 600; text-decoration: none; }
.actions {
  position: sticky; bottom: 0; z-index: 2; display: flex; flex-direction: column; gap: 10px;
  padding: 8px 0 calc(20px + var(--safe-bottom)); background: var(--surface);
}
#kindle-hint { margin: 0; }

/* ---------- deliveries ---------- */
.jobs { list-style: none; margin: 0; padding: 4px 0 0; display: flex; flex-direction: column; gap: 10px; }
.job { display: flex; gap: 14px; align-items: flex-start; padding: 14px 16px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-card); }
.job .cover { width: 48px; flex: none; border-radius: 6px; font-size: 1.1rem; box-shadow: none; }
.job .cover::before { width: 4px; }
.job-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 6px; }
.job-title { font-size: var(--fs-body); font-weight: 600; line-height: 1.25; overflow-wrap: anywhere; }
.job-meta { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.when { font-size: var(--fs-cap); font-weight: 600; color: var(--text-2); }
.job-msg { font-size: var(--fs-foot); color: var(--text-2); overflow-wrap: anywhere; line-height: 1.4; }
.job-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 2px; }

/* ---------- sign in ---------- */
.signin {
  max-width: 440px; margin: 0 auto; padding: 0 calc(20px + var(--safe-right)) 24px calc(20px + var(--safe-left)); display: flex; flex-direction: column;
  min-height: calc(100vh - var(--safe-top)); min-height: calc(100dvh - var(--safe-top));
}
.signin-brand { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; gap: 16px; padding: 24px 0; }
.app-tile {
  width: 84px; height: 84px; border-radius: 19px; background: var(--accent); color: var(--on-accent);
  box-shadow: var(--shadow-cover); display: flex; align-items: center; justify-content: center;
}
.app-glyph { --sw: 1.8; }
.tagline { max-width: 300px; }

/* ---------- account ---------- */
.who { color: var(--text); }
.wrap.narrow.stack { padding-bottom: 24px; }
.panel .help { margin-top: 6px; }

/* ---------- admin: users ---------- */
.users { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 12px; }
.panel.tight { gap: 12px; }
.user-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.user-name { font-size: var(--fs-head); line-height: 1.2; overflow-wrap: anywhere; }
.any { overflow-wrap: anywhere; }
.panel.tight > .msg { margin: 0; }
.user-actions { display: flex; flex-wrap: wrap; align-items: flex-start; gap: 8px; padding-top: 12px; border-top: 1px solid var(--border); }
.user-actions .delete-form { margin: 0 0 0 auto; }
details.reset > summary { list-style: none; cursor: pointer; }
details.reset > summary::-webkit-details-marker { display: none; }
details.reset[open] { flex: 1 1 100%; }
.reset-form { display: block; margin: 12px 0 0; }
.reset-form.self { margin: 0; padding-top: 12px; border-top: 1px solid var(--border); }
.reset-form .row { flex-wrap: wrap; }
.reset-form .row .btn { flex: none; min-height: 52px; }
.grow { flex: 1 1 12rem; min-width: 0; }

/* ---------- admin: settings ---------- */
.intro { line-height: 1.4; }
.settings { gap: 16px; }
.settings > .panel { gap: 18px; }
.setting { min-width: 0; }
.setting .btn { margin-top: 10px; }
form.revert { display: none; }
.savebar {
  position: sticky; bottom: calc(var(--nav-h) + var(--safe-bottom)); z-index: 6;
  margin: 0 calc(-16px - var(--safe-right)) 0 calc(-16px - var(--safe-left));
  padding: 10px calc(16px + var(--safe-right)) 10px calc(16px + var(--safe-left));
  background: var(--surface); border-top: 1px solid var(--border);
}
.env-list {
  margin: 0; display: flex; flex-direction: column; background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--r-card); overflow: hidden;
}
.env-row { padding: 12px 16px; border-bottom: 1px solid var(--border); }
.env-row:last-child { border-bottom: 0; }
.env-row dt { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 4px 12px; font-weight: 600; font-size: var(--fs-sub); overflow-wrap: anywhere; }
.env-row dd { margin: 4px 0 0; font-size: var(--fs-foot); line-height: 1.4; color: var(--text-2); }
@media (min-width: 640px) {
  .wrap.narrow { max-width: 760px; }
  .setting.has-input { display: grid; grid-template-columns: 16rem 1fr; column-gap: 16px; align-items: start; }
  .setting.has-input > .label { grid-column: 1; padding-top: 16px; margin: 0; }
  .setting.has-input > :not(.label) { grid-column: 2; }
}

/* ---------- short screens (landscape phones, the Flip cover screen) ---------- */
@media (max-height: 420px) {
  :root { --nav-link: 44px; --nav-pad: 2px; }
  .nav { gap: 2px; }
  .nav .i { width: 22px; height: 22px; }
  html:has(.screen-head.pin) { scroll-padding-top: calc(var(--safe-top) + 12px); }
  html:has(.savebar) { scroll-padding-bottom: calc(var(--nav-h) + 24px + var(--safe-bottom)); }
  .screen-head.pin { position: static; }
  .savebar { position: static; }
  .banner { padding-top: 6px; padding-bottom: 0; gap: 8px; }
  .banner .i { display: none; }
  .state { padding: 24px 16px 32px; }
  .signin { justify-content: flex-start; }
  .signin-brand { flex: none; padding: 12px 0; gap: 8px; }
  .sheet { gap: 8px; }
  .grabber { display: none; }
  .sheet .clamp { -webkit-line-clamp: 3; }
  .actions { flex-direction: row; flex-wrap: wrap; gap: 8px; padding: 8px 0 calc(8px + var(--safe-bottom)); }
  .actions .btn { flex: 1 1 9rem; min-height: 44px; }
  .actions .foot { flex: 1 1 100%; }
}
