/* PersonalOS Portal – warm, colourful, modern. System fonts only, no external resources.
   Structure: tokens · base · layout · components · pages · motion · print */

/* ---------------------------------------------------------------- tokens */
:root {
  --bg: #fbf6ef;
  --bg-2: #f4ebdf;
  --surface: #ffffff;
  --surface-2: #fbf7f1;
  --surface-3: #f3eadd;
  --text: #1f1a14;
  --text-2: #5b5146;
  --text-3: #8a7e70;
  --line: rgba(74, 48, 20, .10);
  --line-strong: rgba(74, 48, 20, .22);
  --coral: #ff5a36;
  --tangerine: #ff8a3d;
  --sun: #ffb938;
  --mint: #19c39a;
  --leaf: #2fbf6a;
  --berry: #ec4f86;
  --accent-text: #c2410c;
  --ok-text: #0b7a58;
  --warn-text: #9a5b00;
  --danger: #d92d20;
  --danger-soft: #fdecea;
  --ok-soft: #e3f7ef;
  --warn-soft: #fff4dc;
  --info-soft: #fff0e6;
  --on-accent: #2a1305;
  --grad: linear-gradient(135deg, var(--sun) 0%, var(--tangerine) 45%, var(--coral) 100%);
  --grad-mint: linear-gradient(135deg, #43e3b4 0%, var(--mint) 100%);
  --shadow-sm: 0 1px 2px rgba(74, 48, 20, .06), 0 2px 8px rgba(74, 48, 20, .05);
  --shadow-md: 0 2px 6px rgba(74, 48, 20, .06), 0 12px 32px rgba(74, 48, 20, .09);
  --shadow-lg: 0 8px 20px rgba(74, 48, 20, .08), 0 28px 70px rgba(74, 48, 20, .16);
  --shadow-accent: 0 6px 18px rgba(255, 90, 54, .30);
  --ring: 0 0 0 4px rgba(255, 106, 61, .25);
  --aurora-opacity: .55;
  --radius: 22px;
  --radius-md: 16px;
  --radius-sm: 12px;
  --ease: cubic-bezier(.2, .8, .2, 1);
  --spring: cubic-bezier(.34, 1.56, .64, 1);
  --font: ui-rounded, "SF Pro Rounded", "Segoe UI Variable Display", "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "Cascadia Code", "SF Mono", "SFMono-Regular", Menlo, Consolas, monospace;
  --topbar-h: 68px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0d1210; --bg-2: #111815; --surface: #151c19; --surface-2: #1a231f; --surface-3: #212c27;
    --text: #f5efe7; --text-2: #bdb4a8; --text-3: #8d857a;
    --line: rgba(255, 255, 255, .08); --line-strong: rgba(255, 255, 255, .17);
    --coral: #ff6f4e; --tangerine: #ff9650; --sun: #ffc65a; --mint: #34d9aa; --leaf: #4fd87f; --berry: #ff6fa0;
    --accent-text: #ff9a76; --ok-text: #5fe3b4; --warn-text: #ffcb6b; --danger: #ff6b5e;
    --danger-soft: rgba(255, 107, 94, .12); --ok-soft: rgba(52, 217, 170, .12); --warn-soft: rgba(255, 198, 90, .12); --info-soft: rgba(255, 150, 80, .10);
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, .35); --shadow-md: 0 8px 28px rgba(0, 0, 0, .40); --shadow-lg: 0 24px 70px rgba(0, 0, 0, .55);
    --shadow-accent: 0 6px 22px rgba(255, 111, 78, .28);
    --aurora-opacity: .22;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0d1210; --bg-2: #111815; --surface: #151c19; --surface-2: #1a231f; --surface-3: #212c27;
  --text: #f5efe7; --text-2: #bdb4a8; --text-3: #8d857a;
  --line: rgba(255, 255, 255, .08); --line-strong: rgba(255, 255, 255, .17);
  --coral: #ff6f4e; --tangerine: #ff9650; --sun: #ffc65a; --mint: #34d9aa; --leaf: #4fd87f; --berry: #ff6fa0;
  --accent-text: #ff9a76; --ok-text: #5fe3b4; --warn-text: #ffcb6b; --danger: #ff6b5e;
  --danger-soft: rgba(255, 107, 94, .12); --ok-soft: rgba(52, 217, 170, .12); --warn-soft: rgba(255, 198, 90, .12); --info-soft: rgba(255, 150, 80, .10);
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .35); --shadow-md: 0 8px 28px rgba(0, 0, 0, .40); --shadow-lg: 0 24px 70px rgba(0, 0, 0, .55);
  --shadow-accent: 0 6px 22px rgba(255, 111, 78, .28);
  --aurora-opacity: .22;
  color-scheme: dark;
}

/* ---------------------------------------------------------------- base */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; scroll-padding-top: calc(var(--topbar-h) + 16px); }
body {
  margin: 0; min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column;
  font-family: var(--font); font-size: 16px; line-height: 1.55; color: var(--text); background: var(--bg);
  -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; text-rendering: optimizeLegibility;
  overflow-x: hidden;
}
img, svg { display: block; max-width: 100%; }
a { color: inherit; text-decoration: none; }
p a, .prose a, .link { color: var(--accent-text); font-weight: 650; text-decoration: underline; text-decoration-thickness: 1.5px; text-underline-offset: 3px; text-decoration-color: color-mix(in srgb, var(--accent-text) 40%, transparent); transition: text-decoration-color .2s; }
p a:hover, .prose a:hover, .link:hover { text-decoration-color: currentColor; }
h1, h2, h3 { margin: 0; line-height: 1.15; letter-spacing: -.02em; font-weight: 800; }
h1 { font-size: clamp(1.75rem, 1.2rem + 2vw, 2.4rem); }
h2 { font-size: 1.15rem; letter-spacing: -.01em; }
h3 { font-size: 1rem; }
p { margin: 0; }
code, kbd { font-family: var(--mono); font-size: .88em; }
:focus-visible { outline: none; box-shadow: var(--ring); border-radius: 10px; }
::selection { background: color-mix(in srgb, var(--sun) 55%, transparent); color: var(--text); }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.skip { position: fixed; left: 16px; top: -60px; z-index: 100; padding: 10px 16px; border-radius: 12px; background: var(--text); color: var(--bg); font-weight: 700; transition: top .2s var(--ease); }
.skip:focus { top: 12px; }
.icon { width: 20px; height: 20px; flex: none; }
.icon-sm { width: 16px; height: 16px; flex: none; }
.muted { color: var(--text-2); }
.subtle { color: var(--text-3); }
.small { font-size: .875rem; }
.mono { font-family: var(--mono); }
.nowrap { white-space: nowrap; }

/* background: slow-moving colour fields (pure gradients, no filters) */
.aurora { position: fixed; inset: 0; z-index: -1; overflow: hidden; pointer-events: none; opacity: var(--aurora-opacity); }
.aurora span { position: absolute; width: 60vmax; height: 60vmax; border-radius: 50%; will-change: transform; }
.aurora span:nth-child(1) { top: -30vmax; left: -20vmax; background: radial-gradient(circle, color-mix(in srgb, var(--sun) 70%, transparent) 0%, transparent 62%); animation: drift-a 38s ease-in-out infinite alternate; }
.aurora span:nth-child(2) { top: -25vmax; right: -30vmax; background: radial-gradient(circle, color-mix(in srgb, var(--coral) 45%, transparent) 0%, transparent 62%); animation: drift-b 46s ease-in-out infinite alternate; }
.aurora span:nth-child(3) { bottom: -35vmax; left: 10vmax; background: radial-gradient(circle, color-mix(in srgb, var(--mint) 40%, transparent) 0%, transparent 62%); animation: drift-c 52s ease-in-out infinite alternate; }

/* ---------------------------------------------------------------- layout */
.container { width: 100%; max-width: 1140px; margin-inline: auto; padding-inline: clamp(16px, 4vw, 32px); }
main.container { flex: 1; padding-top: clamp(20px, 4vw, 40px); padding-bottom: 64px; }

.topbar {
  position: sticky; top: 0; z-index: 40; height: var(--topbar-h);
  background: color-mix(in srgb, var(--bg) 78%, transparent);
  -webkit-backdrop-filter: saturate(1.5) blur(16px); backdrop-filter: saturate(1.5) blur(16px);
  border-bottom: 1px solid var(--line);
}
.topbar-inner { height: 100%; display: flex; align-items: center; gap: 16px; }
.brand { display: inline-flex; align-items: center; gap: 10px; font-weight: 800; font-size: 1.05rem; letter-spacing: -.01em; white-space: nowrap; }
.brand svg { width: 36px; height: 36px; transition: transform .5s var(--spring); }
.brand:hover svg { transform: rotate(-8deg) scale(1.06); }
.nav { display: flex; align-items: center; gap: 4px; margin-left: 24px; }
.nav a {
  position: relative; display: inline-flex; align-items: center; gap: 8px; height: 40px; padding: 0 14px; border-radius: 999px;
  font-weight: 650; color: var(--text-2); transition: color .2s, background-color .2s;
}
.nav a:hover { color: var(--text); background: var(--surface-3); }
.nav a[aria-current="page"] { color: var(--text); background: var(--surface); box-shadow: var(--shadow-sm), inset 0 0 0 1px var(--line); }
.nav a[aria-current="page"] .icon { color: var(--coral); }
.topbar-actions { margin-left: auto; display: flex; align-items: center; gap: 8px; }

/* user menu (details/summary: works without JavaScript) */
.menu { position: relative; }
.menu > summary { list-style: none; cursor: pointer; }
.menu > summary::-webkit-details-marker { display: none; }
.avatar-btn { display: grid; place-items: center; width: 40px; height: 40px; border-radius: 50%; background: var(--grad); color: var(--on-accent); font-weight: 800; box-shadow: var(--shadow-sm); transition: transform .25s var(--spring), box-shadow .2s; }
.avatar-btn:hover { transform: scale(1.06); }
.menu[open] .avatar-btn { box-shadow: var(--ring); }
.menu-panel {
  position: absolute; right: 0; top: calc(100% + 10px); min-width: 250px; padding: 8px; border-radius: var(--radius-md);
  background: var(--surface); box-shadow: var(--shadow-lg), 0 0 0 1px var(--line); transform-origin: top right;
  animation: pop-in .22s var(--spring);
}
.menu-head { padding: 10px 12px 12px; border-bottom: 1px solid var(--line); margin-bottom: 6px; }
.menu-head strong { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.menu-item { display: flex; width: 100%; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 10px; font: inherit; font-weight: 600; color: var(--text); background: none; border: 0; cursor: pointer; text-align: left; }
.menu-item:hover { background: var(--surface-3); }
.menu-item.danger { color: var(--danger); }

.icon-btn {
  display: inline-grid; place-items: center; width: 40px; height: 40px; border-radius: 50%; border: 0; cursor: pointer;
  background: transparent; color: var(--text-2); transition: background-color .2s, color .2s, transform .25s var(--spring);
}
.icon-btn:hover { background: var(--surface-3); color: var(--text); }
.icon-btn:active { transform: scale(.92); }
.theme-toggle .i-moon { display: none; }
:root[data-theme="dark"] .theme-toggle .i-sun { display: none; }
:root[data-theme="dark"] .theme-toggle .i-moon { display: block; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .theme-toggle .i-sun { display: none; }
  :root:not([data-theme="light"]) .theme-toggle .i-moon { display: block; }
}
.theme-toggle svg { transition: transform .5s var(--spring); }
.theme-toggle:hover svg { transform: rotate(25deg); }

/* mobile tab bar (signed in) */
.tabbar { display: none; }
@media (max-width: 760px) {
  :root { --topbar-h: 60px; }
  .nav { display: none; }
  .brand span { display: none; }
  .tabbar {
    display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; position: fixed; z-index: 45; left: 12px; right: 12px;
    bottom: calc(12px + env(safe-area-inset-bottom)); padding: 6px; border-radius: 22px;
    background: color-mix(in srgb, var(--surface) 86%, transparent); -webkit-backdrop-filter: blur(18px) saturate(1.5); backdrop-filter: blur(18px) saturate(1.5);
    box-shadow: var(--shadow-lg), 0 0 0 1px var(--line);
  }
  .tabbar a { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 8px 4px; border-radius: 16px; font-size: .75rem; font-weight: 700; color: var(--text-3); transition: color .2s, background-color .2s; }
  .tabbar a[aria-current="page"] { color: var(--text); background: var(--surface-3); }
  .tabbar a[aria-current="page"] .icon { color: var(--coral); }
  .has-tabbar main.container { padding-bottom: 120px; }
  .has-tabbar .footer { padding-bottom: 110px; }
}

.footer { border-top: 1px solid var(--line); padding: 22px 0; color: var(--text-3); font-size: .875rem; }
.footer .container { display: flex; gap: 12px 24px; justify-content: space-between; flex-wrap: wrap; align-items: center; }
.footer a { font-weight: 600; color: var(--text-2); }
.footer a:hover { color: var(--text); }
.footer-mark { display: inline-flex; align-items: center; gap: 8px; }
.footer-mark .icon-sm { color: var(--mint); }

.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px 24px; flex-wrap: wrap; margin-bottom: 28px; }
.page-head .eyebrow { margin-bottom: 10px; }
.page-head p { margin-top: 6px; }
.back-link { display: inline-flex; align-items: center; gap: 6px; color: var(--text-2); font-weight: 650; font-size: .92rem; margin-bottom: 14px; transition: color .2s, gap .2s var(--ease); }
.back-link:hover { color: var(--text); gap: 10px; }
.title-row { display: flex; align-items: center; gap: 14px; min-width: 0; }
.title-row h1 { overflow-wrap: anywhere; }

.grid { display: grid; gap: 20px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
@media (max-width: 900px) { .grid-3 { grid-template-columns: 1fr; } }
@media (max-width: 820px) { .grid-2 { grid-template-columns: 1fr; } }
.stack { display: grid; gap: 16px; }
.stack-lg { display: grid; gap: 24px; }
.section { margin-top: 24px; }
.row { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; }
.row-bottom { align-items: flex-end; }
.row-bottom .btn-lg { height: 48px; }
.field-narrow { width: 140px; }
.row-end { display: flex; gap: 12px; flex-wrap: wrap; justify-content: flex-end; align-items: center; }
.narrow { max-width: 480px; margin-inline: auto; }
.medium { max-width: 720px; margin-inline: auto; }

/* ---------------------------------------------------------------- components */
.card {
  position: relative; background: var(--surface); border-radius: var(--radius); padding: clamp(20px, 3vw, 28px);
  box-shadow: var(--shadow-sm), 0 0 0 1px var(--line);
}
.card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 18px; flex-wrap: wrap; }
.card-head > div { min-width: 0; }
.card-head h2 { display: flex; align-items: center; gap: 10px; }
.card-head p { margin-top: 4px; }
.card-icon { display: grid; place-items: center; width: 36px; height: 36px; border-radius: 12px; background: var(--info-soft); color: var(--accent-text); flex: none; }
.card-icon.mint { background: var(--ok-soft); color: var(--ok-text); }
.card-icon.sun { background: var(--warn-soft); color: var(--warn-text); }
.card-icon.danger { background: var(--danger-soft); color: var(--danger); }
.card.danger-zone { box-shadow: var(--shadow-sm), 0 0 0 1px color-mix(in srgb, var(--danger) 35%, transparent); }
.card.elevated { box-shadow: var(--shadow-lg), 0 0 0 1px var(--line); }
.divider { height: 1px; background: var(--line); margin: 20px 0; border: 0; }

.eyebrow {
  display: inline-flex; align-items: center; gap: 8px; padding: 6px 12px 6px 8px; border-radius: 999px;
  background: var(--surface); box-shadow: var(--shadow-sm), 0 0 0 1px var(--line); font-size: .85rem; font-weight: 700; color: var(--text-2);
}
.eyebrow .icon-sm { color: var(--coral); }
.eyebrow-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--leaf); box-shadow: 0 0 0 4px color-mix(in srgb, var(--leaf) 25%, transparent); }

/* buttons */
.btn {
  --btn-bg: var(--surface); --btn-fg: var(--text);
  position: relative; display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 44px; padding: 0 20px;
  border: 0; border-radius: 999px; font: inherit; font-weight: 700; font-size: .95rem; line-height: 1; white-space: nowrap; cursor: pointer;
  color: var(--btn-fg); background: var(--btn-bg); box-shadow: var(--shadow-sm), inset 0 0 0 1px var(--line-strong);
  transition: transform .25s var(--spring), box-shadow .25s var(--ease), background-color .2s, color .2s, opacity .2s;
  -webkit-tap-highlight-color: transparent; user-select: none;
}
.btn:hover { transform: translateY(-2px); box-shadow: var(--shadow-md), inset 0 0 0 1px var(--line-strong); }
.btn:active { transform: translateY(0) scale(.97); transition-duration: .08s; }
.btn:focus-visible { box-shadow: var(--ring), inset 0 0 0 1px var(--line-strong); border-radius: 999px; }
.btn .icon { width: 18px; height: 18px; transition: transform .25s var(--spring); }
.btn:hover .icon-move { transform: translateX(3px); }
.btn-primary { --btn-fg: var(--on-accent); background: var(--grad); background-size: 160% 160%; background-position: 0% 50%; box-shadow: var(--shadow-accent); transition: transform .25s var(--spring), box-shadow .25s var(--ease), background-position .5s var(--ease); }
.btn-primary:hover { background-position: 100% 50%; box-shadow: 0 10px 28px color-mix(in srgb, var(--coral) 40%, transparent); }
.btn-primary:focus-visible { box-shadow: var(--ring), var(--shadow-accent); }
.btn-ghost { --btn-bg: transparent; box-shadow: none; color: var(--text-2); }
.btn-ghost:hover { background: var(--surface-3); color: var(--text); box-shadow: none; }
.btn-danger { --btn-bg: var(--danger); --btn-fg: #fff; box-shadow: 0 6px 18px color-mix(in srgb, var(--danger) 30%, transparent); }
.btn-danger:hover { box-shadow: 0 10px 26px color-mix(in srgb, var(--danger) 40%, transparent); }
.btn-soft-danger { --btn-bg: var(--danger-soft); --btn-fg: var(--danger); box-shadow: none; }
.btn-sm { height: 36px; padding: 0 14px; font-size: .875rem; }
.btn-lg { height: 52px; padding: 0 26px; font-size: 1.02rem; }
.btn-block { width: 100%; }
.btn[disabled], .btn[aria-disabled="true"] { opacity: .45; cursor: not-allowed; transform: none; box-shadow: none; }
.btn.is-loading { color: transparent !important; pointer-events: none; }
.btn.is-loading::after {
  content: ""; position: absolute; width: 18px; height: 18px; border-radius: 50%; border: 2.5px solid var(--btn-fg); border-right-color: transparent;
  animation: spin .7s linear infinite;
}
.btn-primary.is-loading::after { border-color: var(--on-accent); border-right-color: transparent; }
.text-btn { display: inline-flex; align-items: center; gap: 6px; padding: 6px 10px; margin: -6px -10px; border: 0; border-radius: 10px; background: none; font: inherit; font-weight: 700; font-size: .9rem; color: var(--text-2); cursor: pointer; white-space: nowrap; transition: background-color .2s, color .2s; }
.text-btn:hover { background: var(--surface-3); color: var(--text); }
.text-btn.danger { color: var(--danger); }
.text-btn.danger:hover { background: var(--danger-soft); }

/* badges and chips */
.badge { display: inline-flex; align-items: center; gap: 6px; height: 26px; padding: 0 10px; border-radius: 999px; font-size: .78rem; font-weight: 750; white-space: nowrap; background: var(--surface-3); color: var(--text-2); }
.badge-stable { background: var(--ok-soft); color: var(--ok-text); }
.badge-beta { background: var(--warn-soft); color: var(--warn-text); }
.badge-dev { background: color-mix(in srgb, var(--berry) 15%, transparent); color: color-mix(in srgb, var(--berry) 80%, var(--text)); }
.badge-danger { background: var(--danger-soft); color: var(--danger); }
.badge-accent { background: var(--info-soft); color: var(--accent-text); }
.status-pill { display: inline-flex; align-items: center; gap: 8px; font-size: .85rem; font-weight: 700; color: var(--text-3); white-space: nowrap; }
.status-pill .dot { position: relative; width: 9px; height: 9px; border-radius: 50%; background: var(--text-3); flex: none; }
.status-pill.online { color: var(--ok-text); }
.status-pill.online .dot { background: var(--leaf); }
.status-pill.online .dot::after { content: ""; position: absolute; inset: -4px; border-radius: 50%; border: 2px solid var(--leaf); animation: ping 2s var(--ease) infinite; }

/* alerts and toasts */
.alert { display: flex; gap: 12px; align-items: flex-start; padding: 14px 16px; border-radius: var(--radius-md); font-weight: 600; font-size: .95rem; margin-bottom: 22px; animation: shake .45s var(--ease); }
.alert .icon { margin-top: 1px; }
.alert-error { background: var(--danger-soft); color: var(--danger); }
.alert-warn { background: var(--warn-soft); color: var(--warn-text); animation: fade-up .4s var(--ease); }
.alert-info { background: var(--info-soft); color: var(--accent-text); animation: fade-up .4s var(--ease); }
.alert p { color: inherit; }
.toasts { position: fixed; z-index: 60; top: calc(var(--topbar-h) + 14px); left: 50%; transform: translateX(-50%); width: min(460px, calc(100% - 24px)); pointer-events: none; }
.toast {
  pointer-events: auto; position: relative; display: flex; align-items: center; gap: 12px; padding: 14px 14px 14px 16px; border-radius: 18px; overflow: hidden;
  background: var(--surface); box-shadow: var(--shadow-lg), 0 0 0 1px var(--line); font-weight: 650;
  animation: toast-in .5s var(--spring);
}
.toast-icon { display: grid; place-items: center; width: 30px; height: 30px; border-radius: 50%; background: var(--grad-mint); color: #06362a; flex: none; }
.toast-icon .icon-sm { stroke-width: 3; }
.toast p { flex: 1; }
.toast .icon-btn { width: 32px; height: 32px; }
.toast-bar { position: absolute; left: 0; bottom: 0; height: 3px; width: 100%; background: var(--grad-mint); transform-origin: left; animation: toast-timer 6s linear forwards; }
.toast.is-leaving { animation: toast-out .35s var(--ease) forwards; }

/* forms */
.field { display: grid; gap: 8px; }
.field > label, .label { font-weight: 700; font-size: .92rem; }
.hint { color: var(--text-3); font-size: .85rem; }
.input, .select, .field input:not([type="checkbox"]):not([type="file"]):not([type="hidden"]), .field select {
  width: 100%; height: 48px; padding: 0 16px; border-radius: var(--radius-sm); border: 0; font: inherit; font-size: 1rem; color: var(--text);
  background: var(--surface-2); box-shadow: inset 0 0 0 1.5px var(--line-strong); transition: box-shadow .2s, background-color .2s;
  appearance: none; -webkit-appearance: none;
}
.field input:hover, .field select:hover { box-shadow: inset 0 0 0 1.5px color-mix(in srgb, var(--text-3) 70%, transparent); }
.field input:focus, .field select:focus { outline: none; background: var(--surface); box-shadow: inset 0 0 0 2px var(--coral), var(--ring); }
.field input:user-invalid { box-shadow: inset 0 0 0 2px var(--danger); }
.field select {
  padding-right: 44px; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23998b7b' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 14px center; background-size: 18px;
}
.input-wrap { position: relative; }
.input-wrap input { padding-right: 52px !important; }
.input-wrap .icon-btn { position: absolute; right: 4px; top: 4px; }
.input-wrap .i-eye-off { display: none; }
.input-wrap.is-visible .i-eye { display: none; }
.input-wrap.is-visible .i-eye-off { display: block; }
.field input.code, input.code {
  height: 64px; text-align: center; font-family: var(--mono); font-size: 1.7rem; font-weight: 700; letter-spacing: .3em; text-transform: uppercase; padding-left: calc(16px + .3em);
}
.check { display: flex; align-items: flex-start; gap: 12px; font-weight: 550; cursor: pointer; }
.check input {
  appearance: none; -webkit-appearance: none; flex: none; width: 22px; height: 22px; margin: 1px 0 0; border-radius: 7px; cursor: pointer;
  background: var(--surface-2); box-shadow: inset 0 0 0 1.5px var(--line-strong); display: grid; place-items: center; transition: background-color .2s, box-shadow .2s;
}
.check input::after { content: ""; width: 11px; height: 6px; border: solid #fff; border-width: 0 0 2.5px 2.5px; transform: translateY(-1px) rotate(-45deg) scale(0); transition: transform .25s var(--spring); }
.check input:checked { background: var(--coral); box-shadow: none; }
.check input:checked::after { transform: translateY(-1px) rotate(-45deg) scale(1); }
.check input:focus-visible { box-shadow: var(--ring); }
.form-actions { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; margin-top: 4px; }
.form-foot { margin-top: 22px; padding-top: 18px; border-top: 1px solid var(--line); display: flex; justify-content: center; gap: 8px 18px; flex-wrap: wrap; font-size: .92rem; color: var(--text-2); }
.form-foot a { color: var(--text); font-weight: 700; }
.form-foot a:hover { color: var(--accent-text); }

.dropzone {
  position: relative; display: flex; align-items: center; gap: 16px; padding: 22px; border-radius: var(--radius-md); cursor: pointer;
  background: var(--surface-2); border: 2px dashed var(--line-strong); transition: border-color .2s, background-color .2s, transform .25s var(--spring);
}
.dropzone:hover, .dropzone.is-dragging { border-color: var(--coral); background: var(--info-soft); }
.dropzone.is-dragging { transform: scale(1.01); }
.dropzone input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.dropzone:focus-within { box-shadow: var(--ring); }
.dropzone-icon { display: grid; place-items: center; width: 48px; height: 48px; border-radius: 16px; background: var(--grad); color: var(--on-accent); flex: none; }
.dropzone strong { display: block; }
.dropzone .file-name { color: var(--ok-text); font-weight: 700; overflow-wrap: anywhere; }

/* copy fields */
.copy-field { display: flex; align-items: center; gap: 8px; padding: 6px 6px 6px 14px; border-radius: var(--radius-sm); background: var(--surface-2); box-shadow: inset 0 0 0 1.5px var(--line); }
.copy-field code { flex: 1; min-width: 0; overflow-wrap: anywhere; font-size: .9rem; color: var(--text); }
.copy-btn .i-check { display: none; }
.copy-btn.is-copied .i-copy { display: none; }
.copy-btn.is-copied .i-check { display: block; color: var(--ok-text); animation: pop-in .3s var(--spring); }

/* definition lists */
.facts { display: grid; margin: 0; }
.facts > div { display: flex; justify-content: space-between; align-items: center; gap: 16px; padding: 12px 0; border-bottom: 1px solid var(--line); min-width: 0; }
.facts > div:last-child { border-bottom: 0; }
.facts dt { color: var(--text-2); font-size: .92rem; flex: none; }
.facts dd { margin: 0; font-weight: 650; text-align: right; min-width: 0; overflow-wrap: break-word; }
.facts dd.mono { overflow-wrap: anywhere; }

/* tables: stacked cards on small screens */
.table-wrap { overflow-x: auto; margin: 0 -8px; padding: 0 8px; }
.table { width: 100%; border-collapse: collapse; font-size: .92rem; }
.table th { text-align: left; font-size: .78rem; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; color: var(--text-3); padding: 0 12px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.table td { padding: 14px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table tbody tr { transition: background-color .2s; }
.table tbody tr:hover { background: color-mix(in srgb, var(--surface-3) 55%, transparent); }
.table td:first-child, .table th:first-child { padding-left: 4px; }
.table td:last-child, .table th:last-child { padding-right: 4px; text-align: right; }
.table .cell-main { font-weight: 700; }
.table .cell-sub { display: block; color: var(--text-3); font-size: .82rem; margin-top: 2px; font-weight: 500; }
.table tr.is-muted td { opacity: .55; }
@media (max-width: 700px) {
  .table-wrap { overflow: visible; margin: 0; padding: 0; }
  .table.responsive thead { display: none; }
  .table.responsive, .table.responsive tbody, .table.responsive tr, .table.responsive td { display: block; width: 100%; }
  .table.responsive tr { padding: 14px 0; border-bottom: 1px solid var(--line); }
  .table.responsive tr:last-child { border-bottom: 0; }
  .table.responsive td { display: flex; justify-content: space-between; gap: 16px; padding: 5px 0 !important; border: 0; text-align: right !important; }
  .table.responsive td::before { content: attr(data-label); color: var(--text-3); font-family: var(--font); font-weight: 600; text-align: left; flex: none; }
  .table.responsive td[data-label=""]::before { display: none; }
  .table.responsive td[data-label=""] { justify-content: flex-end; }
  .table.responsive td.cell-full { display: block; text-align: left !important; }
  .table.responsive td.cell-full::before { display: none; }
  .table.responsive tbody tr:hover { background: none; }
}

/* timeline (audit) */
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { position: relative; display: grid; grid-template-columns: auto 1fr auto; gap: 4px 14px; padding: 12px 0; border-bottom: 1px solid var(--line); align-items: start; }
.timeline li:last-child { border-bottom: 0; }
.tl-icon { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 12px; background: var(--surface-3); color: var(--text-2); grid-row: span 2; }
.tl-icon.ok { background: var(--ok-soft); color: var(--ok-text); }
.tl-icon.warn { background: var(--danger-soft); color: var(--danger); }
.tl-icon.accent { background: var(--info-soft); color: var(--accent-text); }
.tl-title { font-weight: 700; }
.tl-time { color: var(--text-3); font-size: .85rem; white-space: nowrap; }
.tl-meta { color: var(--text-3); font-size: .85rem; grid-column: 2 / 4; overflow-wrap: anywhere; }

/* steps */
.steps { list-style: none; margin: 0 0 24px; padding: 0; display: grid; gap: 14px; counter-reset: step; }
.steps li { counter-increment: step; display: grid; grid-template-columns: 34px 1fr; gap: 14px; align-items: start; color: var(--text-2); }
.steps li::before { content: counter(step); display: grid; place-items: center; width: 34px; height: 34px; border-radius: 12px; background: var(--grad); color: var(--on-accent); font-weight: 800; }
.steps li strong { color: var(--text); }

/* ---------------------------------------------------------------- pages */
/* hero */
.hero { display: grid; grid-template-columns: 1.1fr .9fr; gap: 40px; align-items: center; padding: clamp(12px, 4vw, 48px) 0 56px; }
.hero h1 { font-size: clamp(2.3rem, 1.4rem + 4vw, 4rem); line-height: 1.02; letter-spacing: -.035em; margin: 18px 0 20px; }
.hero h1 .gradient-text { display: inline-block; }
.gradient-text { background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent; }
.hero .lead { font-size: clamp(1.05rem, 1rem + .3vw, 1.2rem); color: var(--text-2); max-width: 38ch; }
.hero .row { margin-top: 30px; }
.hero-art { position: relative; justify-self: center; width: min(100%, 460px); aspect-ratio: 36 / 30; }
.hero-art > svg { width: 100%; height: 100%; animation: float 7s ease-in-out infinite; filter: drop-shadow(0 30px 40px color-mix(in srgb, var(--coral) 22%, transparent)); }
.hero-badge { position: absolute; display: inline-flex; align-items: center; gap: 8px; padding: 10px 14px; border-radius: 16px; background: var(--surface); box-shadow: var(--shadow-lg), 0 0 0 1px var(--line); font-weight: 700; font-size: .9rem; white-space: nowrap; }
.hero-badge.one { left: -4%; bottom: 14%; animation: float 6s ease-in-out -2s infinite; }
.hero-badge.two { right: 0; top: 4%; animation: float 8s ease-in-out -4s infinite; }
.hero-badge .icon-sm { color: var(--mint); }
@media (max-width: 860px) {
  .hero { grid-template-columns: 1fr; text-align: left; gap: 24px; padding-bottom: 32px; }
  .hero-art { width: min(100%, 340px); order: -1; }
  .hero-badge.one { left: 0; }
}
.features { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 20px; }
@media (max-width: 900px) { .features { grid-template-columns: 1fr; } }
.feature { transition: transform .35s var(--spring), box-shadow .3s var(--ease); }
.feature:hover { transform: translateY(-4px); box-shadow: var(--shadow-md), 0 0 0 1px var(--line); }
.feature-icon { display: grid; place-items: center; width: 48px; height: 48px; border-radius: 16px; margin-bottom: 18px; color: var(--on-accent); }
.feature-icon.sun { background: linear-gradient(135deg, #ffd66b, var(--sun)); }
.feature-icon.mint { background: var(--grad-mint); color: #06362a; }
.feature-icon.coral { background: linear-gradient(135deg, var(--tangerine), var(--coral)); }
.feature h2 { margin-bottom: 8px; }
.feature p { color: var(--text-2); }

/* auth pages */
.auth { display: grid; place-items: start center; padding-top: clamp(0px, 3vw, 24px); }
.auth-card { width: 100%; max-width: 440px; }
.auth-card .card { padding: clamp(24px, 5vw, 36px); box-shadow: var(--shadow-lg), 0 0 0 1px var(--line); }
.auth-icon { display: grid; place-items: center; width: 56px; height: 56px; border-radius: 18px; background: var(--grad); color: var(--on-accent); margin-bottom: 20px; box-shadow: var(--shadow-accent); }
.auth-icon .icon { width: 26px; height: 26px; }
.auth-card h1 { font-size: 1.7rem; margin-bottom: 8px; }
.auth-card .intro { color: var(--text-2); margin-bottom: 24px; }

/* 2FA setup */
.setup { display: grid; grid-template-columns: 250px 1fr; gap: 32px; align-items: start; }
@media (max-width: 720px) { .setup { grid-template-columns: 1fr; } }
.qr { margin: 0; display: grid; gap: 12px; justify-items: center; text-align: center; color: var(--text-3); font-size: .85rem; }
.qr-frame { padding: 14px; border-radius: 22px; background: #fff; box-shadow: var(--shadow-md), 0 0 0 1px var(--line); }
.qr-frame svg { width: 200px; height: 200px; }
.codes { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.codes li { padding: 12px; border-radius: 12px; background: var(--surface-2); box-shadow: inset 0 0 0 1px var(--line); text-align: center; font-family: var(--mono); font-weight: 700; font-size: 1rem; letter-spacing: .04em; }

/* device tiles */
.tiles { list-style: none; margin: 0; padding: 0; display: grid; gap: 20px; grid-template-columns: repeat(auto-fill, minmax(min(100%, 320px), 1fr)); }
.tile {
  position: relative; display: flex; flex-direction: column; gap: 18px; padding: 22px; border-radius: var(--radius);
  background: var(--surface); box-shadow: var(--shadow-sm), 0 0 0 1px var(--line); overflow: hidden;
  transition: transform .35s var(--spring), box-shadow .3s var(--ease);
}
.tile::before { content: ""; position: absolute; inset: 0 0 auto; height: 4px; background: var(--grad); opacity: 0; transition: opacity .3s; }
.tile.is-online::before { opacity: 1; }
.tile:hover { transform: translateY(-4px); box-shadow: var(--shadow-md), 0 0 0 1px var(--line); }
.tile-top { display: flex; gap: 14px; align-items: center; min-width: 0; }
.tile-top h2 { font-size: 1.1rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tile-top > div { min-width: 0; display: grid; gap: 4px; }
.tile-top a:hover h2 { color: var(--accent-text); }
.device-avatar { display: grid; place-items: center; width: 48px; height: 48px; border-radius: 16px; flex: none; font-weight: 800; font-size: 1.2rem; color: var(--on-accent); background: var(--grad); }
.device-avatar.beta { background: linear-gradient(135deg, #ffe08a, var(--sun)); }
.device-avatar.dev { background: linear-gradient(135deg, #ffa3c4, var(--berry)); color: #3a0a1c; }
.device-avatar.stable { background: var(--grad-mint); color: #06362a; }
.device-avatar.lg { width: 60px; height: 60px; border-radius: 20px; font-size: 1.5rem; }
.tile .facts > div { padding: 9px 0; }
.update-banner { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 14px; background: var(--info-soft); color: var(--accent-text); font-weight: 700; font-size: .9rem; }
.update-banner .icon-sm { flex: none; }
.tile-actions { display: flex; gap: 10px; margin-top: auto; }
.tile-actions .btn { flex: 1; }
.tiles > li { display: flex; flex-direction: column; }
.tiles > li > .tile { flex: 1; }
.tile-add {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; min-height: 200px; border-radius: var(--radius);
  border: 2px dashed var(--line-strong); color: var(--text-2); font-weight: 700; transition: border-color .2s, color .2s, background-color .2s, transform .35s var(--spring);
}
.tile-add:hover { border-color: var(--coral); color: var(--accent-text); background: var(--info-soft); transform: translateY(-4px); }
.tile-add-icon { display: grid; place-items: center; width: 52px; height: 52px; border-radius: 50%; background: var(--surface); box-shadow: var(--shadow-md); transition: transform .4s var(--spring); }
.tile-add:hover .tile-add-icon { transform: rotate(90deg) scale(1.08); }

/* empty and status pages */
.empty-state, .status-page { text-align: center; display: grid; justify-items: center; gap: 14px; padding: clamp(32px, 6vw, 64px) 20px; }
.empty-state svg, .status-page .art { width: 210px; height: auto; animation: float 6s ease-in-out infinite; }
.empty-state p, .status-page p { color: var(--text-2); max-width: 46ch; }
.status-page .row { justify-content: center; margin-top: 8px; }
.checklist { list-style: none; margin: 4px 0; padding: 0; display: grid; gap: 10px; text-align: left; }
.checklist li { display: flex; gap: 10px; align-items: flex-start; color: var(--text-2); }
.checklist .icon-sm { color: var(--mint); margin-top: 3px; }
.countdown { font-variant-numeric: tabular-nums; }

/* operator */
.stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 20px; margin-bottom: 20px; }
@media (max-width: 760px) { .stats { grid-template-columns: 1fr; } }
.stat { display: flex; align-items: center; gap: 16px; }
.stat-icon { display: grid; place-items: center; width: 52px; height: 52px; border-radius: 18px; flex: none; }
.stat-icon.sun { background: var(--warn-soft); color: var(--warn-text); }
.stat-icon.mint { background: var(--ok-soft); color: var(--ok-text); }
.stat-icon.coral { background: var(--info-soft); color: var(--accent-text); }
.stat-num { font-size: 2rem; font-weight: 850; letter-spacing: -.03em; line-height: 1; font-variant-numeric: tabular-nums; }
.stat-label { color: var(--text-2); font-weight: 600; font-size: .9rem; margin-top: 4px; }
.rollout { display: flex; align-items: center; gap: 10px; min-width: 150px; }
.meter { position: relative; flex: 1; height: 8px; border-radius: 99px; background: var(--surface-3); overflow: hidden; min-width: 60px; }
.meter span { position: absolute; inset: 0 auto 0 0; border-radius: 99px; background: var(--grad); transform-origin: left; animation: grow 1s var(--ease) both .2s; }
.meter .w-0 { width: 0 } .meter .w-5 { width: 5% } .meter .w-10 { width: 10% } .meter .w-15 { width: 15% } .meter .w-20 { width: 20% } .meter .w-25 { width: 25% } .meter .w-30 { width: 30% } .meter .w-35 { width: 35% } .meter .w-40 { width: 40% } .meter .w-45 { width: 45% } .meter .w-50 { width: 50% } .meter .w-55 { width: 55% } .meter .w-60 { width: 60% } .meter .w-65 { width: 65% } .meter .w-70 { width: 70% } .meter .w-75 { width: 75% } .meter .w-80 { width: 80% } .meter .w-85 { width: 85% } .meter .w-90 { width: 90% } .meter .w-95 { width: 95% } .meter .w-100 { width: 100% }
.inline-form { display: inline-flex; align-items: center; gap: 8px; margin: 0; }
.inline-form select, .inline-form input { height: 36px; border: 0; border-radius: 10px; padding: 0 10px; font: inherit; font-size: .88rem; color: var(--text); background: var(--surface-2); box-shadow: inset 0 0 0 1.5px var(--line-strong); }
.inline-form select { padding-right: 30px; appearance: none; -webkit-appearance: none; cursor: pointer; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23998b7b' stroke-width='2.6' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 8px center; background-size: 14px; }
.inline-form input[type="number"] { width: 70px; }
.inline-form select:focus, .inline-form input:focus { outline: none; box-shadow: inset 0 0 0 2px var(--coral), var(--ring); }

/* prose (privacy) */
.prose { max-width: 760px; }
.prose h2 { margin: 36px 0 12px; font-size: 1.25rem; }
.prose p, .prose li { color: var(--text-2); }
.prose ul { padding-left: 20px; display: grid; gap: 8px; }
.callout { display: flex; gap: 14px; padding: 18px; border-radius: var(--radius-md); background: var(--warn-soft); color: var(--text); margin: 8px 0; }
.callout .icon { color: var(--warn-text); margin-top: 2px; }
.callout p { color: var(--text); }

/* gateway pages on device origins */
.page-gateway main { display: grid; place-items: center; min-height: 100vh; padding: 24px; }
.page-gateway .card { max-width: 480px; box-shadow: var(--shadow-lg), 0 0 0 1px var(--line); }

/* ---------------------------------------------------------------- motion */
@view-transition { navigation: auto; }
::view-transition-old(root) { animation: .18s var(--ease) both vt-out; }
::view-transition-new(root) { animation: .32s var(--ease) both vt-in; }
.theme-switching::view-transition-old(root), .theme-switching::view-transition-new(root) { animation: none; mix-blend-mode: normal; }

.reveal > * { animation: fade-up .6s var(--ease) both; }
.reveal > *:nth-child(2) { animation-delay: .06s; }
.reveal > *:nth-child(3) { animation-delay: .12s; }
.reveal > *:nth-child(4) { animation-delay: .18s; }
.reveal > *:nth-child(5) { animation-delay: .24s; }
.reveal > *:nth-child(6) { animation-delay: .30s; }
.reveal > *:nth-child(n+7) { animation-delay: .34s; }
.pop { animation: pop-in .5s var(--spring) both; }

@keyframes fade-up { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }
@keyframes pop-in { from { opacity: 0; transform: scale(.92); } to { opacity: 1; transform: none; } }
@keyframes toast-in { from { opacity: 0; transform: translateY(-18px) scale(.96); } to { opacity: 1; transform: none; } }
@keyframes toast-out { to { opacity: 0; transform: translateY(-12px) scale(.96); } }
@keyframes toast-timer { from { transform: scaleX(1); } to { transform: scaleX(0); } }
@keyframes float { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-12px); } }
@keyframes ping { 0% { transform: scale(.6); opacity: .9; } 80%, 100% { transform: scale(1.9); opacity: 0; } }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes grow { from { transform: scaleX(0); } }
@keyframes shake { 0%, 100% { transform: none; } 20% { transform: translateX(-6px); } 40% { transform: translateX(5px); } 60% { transform: translateX(-3px); } 80% { transform: translateX(2px); } }
@keyframes vt-out { to { opacity: 0; } }
@keyframes vt-in { from { opacity: 0; transform: translateY(8px); } }
@keyframes drift-a { to { transform: translate(18vmax, 10vmax) scale(1.15); } }
@keyframes drift-b { to { transform: translate(-16vmax, 14vmax) scale(.9); } }
@keyframes drift-c { to { transform: translate(12vmax, -12vmax) scale(1.1); } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; animation-delay: 0s !important; transition-duration: .01ms !important; scroll-behavior: auto !important; }
  .aurora span, .hero-art > svg, .hero-badge, .empty-state svg, .status-page .art { animation: none !important; }
  ::view-transition-old(root), ::view-transition-new(root) { animation: none !important; }
  .btn:hover, .tile:hover, .feature:hover, .tile-add:hover { transform: none; }
}

/* ---------------------------------------------------------------- print */
@media print {
  .topbar, .tabbar, .footer, .aurora, .toasts, .no-print { display: none !important; }
  body { background: #fff; color: #000; }
  .card { box-shadow: none; border: 1px solid #ccc; }
  .codes li { border: 1px solid #999; }
}
