/* Studio app UI. Its own quiet identity (warm paper, graphite ink, deep teal), separate from the generated sites.
   Light and dark themes from tokens; styled thin scrollbars everywhere; 16 px inputs; 44 px targets; no inline styles
   (the app CSP is style-src 'self'). */

:root {
  --bg: #f5f4f0;
  --surface: #ffffff;
  --surface-2: #efede7;
  --surface-3: #e7e4dc;
  --line: #dcd9d0;
  --line-strong: #bdb8ab;
  --ink: #17181b;
  --ink-2: #44474e;
  --ink-3: #62666f;
  --accent: #1d6b62;
  --accent-hover: #175a52;
  --accent-ink: #ffffff;
  --accent-soft: #dcebe7;
  --accent-text: #175a52;
  --danger: #b42318;
  --danger-soft: #fbe9e6;
  --danger-text: #9a1d14;
  --warn-soft: #fbf0d6;
  --warn-text: #6f4a00;
  --ok-soft: #e1f0e4;
  --ok-text: #1d5c30;
  --focus: #1d6b62;
  --scroll-thumb: #c9c4b8;
  --scroll-thumb-hover: #a9a396;
  --stage: #e9e6df;
  --shadow-1: 0 1px 2px rgb(23 24 27 / 0.06);
  --shadow-2: 0 1px 2px rgb(23 24 27 / 0.05), 0 10px 30px rgb(23 24 27 / 0.08);
  --radius: 10px;
  --radius-sm: 7px;
  --font: ui-sans-serif, system-ui, "Segoe UI Variable Text", "Segoe UI", -apple-system, "Helvetica Neue", Roboto, Arial, sans-serif;
  --font-display: ui-sans-serif, system-ui, "Segoe UI Variable Display", "Segoe UI", -apple-system, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "Cascadia Mono", "SF Mono", Menlo, Consolas, monospace;
  --ease: cubic-bezier(0.2, 0, 0, 1);
  --dur: 160ms;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #111316; --surface: #171a1e; --surface-2: #1e2227; --surface-3: #262b31; --line: #2b3037; --line-strong: #414852;
    --ink: #eceef0; --ink-2: #c3c8ce; --ink-3: #9aa1aa; --accent: #4fb7a8; --accent-hover: #63c6b8; --accent-ink: #0a1f1c;
    --accent-soft: #163330; --accent-text: #7fd3c6; --danger: #f08a7c; --danger-soft: #3a1c19; --danger-text: #ffb4a8;
    --warn-soft: #33290f; --warn-text: #f1cd73; --ok-soft: #15301d; --ok-text: #8fdca2; --focus: #7fd3c6;
    --scroll-thumb: #3a4049; --scroll-thumb-hover: #4c535e; --stage: #0c0e10;
    --shadow-1: 0 1px 2px rgb(0 0 0 / 0.4); --shadow-2: 0 1px 2px rgb(0 0 0 / 0.4), 0 12px 32px rgb(0 0 0 / 0.35);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #111316; --surface: #171a1e; --surface-2: #1e2227; --surface-3: #262b31; --line: #2b3037; --line-strong: #414852;
  --ink: #eceef0; --ink-2: #c3c8ce; --ink-3: #9aa1aa; --accent: #4fb7a8; --accent-hover: #63c6b8; --accent-ink: #0a1f1c;
  --accent-soft: #163330; --accent-text: #7fd3c6; --danger: #f08a7c; --danger-soft: #3a1c19; --danger-text: #ffb4a8;
  --warn-soft: #33290f; --warn-text: #f1cd73; --ok-soft: #15301d; --ok-text: #8fdca2; --focus: #7fd3c6;
  --scroll-thumb: #3a4049; --scroll-thumb-hover: #4c535e; --stage: #0c0e10;
  --shadow-1: 0 1px 2px rgb(0 0 0 / 0.4); --shadow-2: 0 1px 2px rgb(0 0 0 / 0.4), 0 12px 32px rgb(0 0 0 / 0.35);
  color-scheme: dark;
}

/* ---------------------------------------------------------------- base */
*, *::before, *::after { box-sizing: border-box; }
@supports not selector(::-webkit-scrollbar) {
  * { scrollbar-width: thin; scrollbar-color: var(--scroll-thumb) transparent; }
}
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--scroll-thumb); border-radius: 8px; border: 2px solid transparent; background-clip: padding-box; }
::-webkit-scrollbar-thumb:hover { background: var(--scroll-thumb-hover); background-clip: padding-box; }
::-webkit-scrollbar-button { display: none; width: 0; height: 0; }

.security-settings { max-width: 760px; }
.security-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding-block: 14px; border-bottom: 1px solid var(--line); }
.security-row > div { min-width: 0; overflow-wrap: anywhere; }
.security-row > button { flex-shrink: 0; }
@media (max-width: 520px) { .security-row { align-items: flex-start; flex-direction: column; } }

html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  margin: 0; min-height: 100vh; background: var(--bg); color: var(--ink);
  font: 15px/1.5 var(--font); -webkit-font-smoothing: antialiased;
}
h1, h2, h3, h4 { font-family: var(--font-display); line-height: 1.2; margin: 0; letter-spacing: -0.01em; }
h1 { font-size: 1.6rem; font-weight: 650; }
h2 { font-size: 1.15rem; font-weight: 620; }
h3 { font-size: 0.98rem; font-weight: 620; }
p { margin: 0; }
a { color: var(--accent-text); text-underline-offset: 2px; }
a:hover { color: var(--accent-hover); }
img { max-width: 100%; display: block; }
code, .mono { font-family: var(--mono); font-size: 0.86em; }
:focus { outline: none; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: 4px; }
[hidden] { display: none !important; }
.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-link { position: absolute; left: 12px; top: 0; transform: translateY(calc(-100% - 8px)); z-index: 100; min-height: 44px; background: var(--accent); color: var(--accent-ink); padding: 10px 14px; border-radius: var(--radius-sm); }
.skip-link:focus { top: 12px; transform: none; }
.muted { color: var(--ink-2); }
.subtle { color: var(--ink-3); font-size: 0.86rem; }
.label-caps { font-family: var(--mono); font-size: 0.72rem; letter-spacing: 0.08em; text-transform: uppercase; color: var(--ink-3); }
.stack { display: flex; flex-direction: column; gap: 12px; }
.stack-lg { display: flex; flex-direction: column; gap: 20px; }
.row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.grow { flex: 1 1 auto; min-width: 0; }

.boot { min-height: 100vh; display: grid; place-items: center; }
.boot-mark { font-family: var(--mono); letter-spacing: 0.2em; text-transform: uppercase; color: var(--ink-3); }

/* ---------------------------------------------------------------- buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; padding: 0 16px; border-radius: var(--radius-sm); border: 1px solid var(--line-strong);
  background: var(--surface); color: var(--ink); font: 500 0.95rem/1 var(--font); cursor: pointer; text-decoration: none;
  transition: background var(--dur) var(--ease), border-color var(--dur) var(--ease), color var(--dur) var(--ease);
  white-space: nowrap;
}
.btn:hover { background: var(--surface-2); color: var(--ink); }
.btn:disabled, .btn[aria-disabled="true"] { opacity: 0.55; cursor: not-allowed; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); color: var(--accent-ink); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--ink-2); }
.btn-ghost:hover { background: var(--surface-2); color: var(--ink); }
.btn-danger { color: var(--danger-text); border-color: var(--line-strong); }
.btn-danger:hover { background: var(--danger-soft); color: var(--danger-text); }
.btn-small { min-height: 36px; padding: 0 12px; font-size: 0.88rem; }
.btn-block { width: 100%; }
.icon-btn {
  display: inline-grid; place-items: center; width: 44px; height: 44px; border-radius: var(--radius-sm);
  border: 1px solid transparent; background: transparent; color: var(--ink-2); cursor: pointer; flex: none;
}
.icon-btn:hover { background: var(--surface-2); color: var(--ink); }
.icon-btn:disabled { opacity: 0.4; cursor: not-allowed; }
.icon-btn[aria-pressed="true"], .icon-btn[aria-checked="true"] { background: var(--accent-soft); color: var(--accent-text); }
.icon { width: 20px; height: 20px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.btn .icon { width: 18px; height: 18px; }
.link-btn { background: none; border: 0; padding: 0; color: var(--accent-text); font: inherit; text-decoration: underline; text-underline-offset: 2px; cursor: pointer; min-height: 44px; }

/* ---------------------------------------------------------------- forms */
.field { display: flex; flex-direction: column; gap: 6px; }
.field > label, .field-label { font-weight: 560; font-size: 0.92rem; color: var(--ink); }
.input, .textarea, .select {
  width: 100%; min-height: 44px; padding: 10px 12px; border-radius: var(--radius-sm); border: 1px solid var(--line-strong);
  background: var(--surface); color: var(--ink); font: 16px/1.4 var(--font);
  transition: border-color var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
}
.textarea { resize: vertical; min-height: 96px; }
.input:focus-visible, .textarea:focus-visible, .select:focus-visible { outline: none; border-color: var(--focus); box-shadow: 0 0 0 3px color-mix(in srgb, var(--focus) 28%, transparent); }
.input[aria-invalid="true"], .textarea[aria-invalid="true"] { border-color: var(--danger); }
.input-mono { font-family: var(--mono); font-size: 16px; }
.hint { font-size: 0.85rem; color: var(--ink-3); }
.error-text { font-size: 0.88rem; color: var(--danger-text); }
.error-text:empty { display: none; }
.input-group { display: flex; gap: 8px; align-items: stretch; }
.input-group .input { flex: 1 1 auto; min-width: 0; }
.check { display: flex; align-items: center; gap: 10px; min-height: 44px; cursor: pointer; }
.check input { width: 20px; height: 20px; accent-color: var(--accent); }
fieldset { border: 0; margin: 0; padding: 0; min-width: 0; }
legend { padding: 0; font-weight: 600; margin-bottom: 8px; }

/* ---------------------------------------------------------------- notices */
.notice { display: flex; gap: 12px; align-items: flex-start; padding: 12px 14px; border-radius: var(--radius); border: 1px solid var(--line); background: var(--surface); }
.notice .icon { margin-top: 2px; }
.notice-body { display: flex; flex-direction: column; gap: 8px; min-width: 0; flex: 1; }
.notice-info { background: var(--accent-soft); border-color: transparent; color: var(--ink); }
.notice-warn { background: var(--warn-soft); border-color: transparent; color: var(--warn-text); }
.notice-error { background: var(--danger-soft); border-color: transparent; color: var(--danger-text); }
.notice-ok { background: var(--ok-soft); border-color: transparent; color: var(--ok-text); }
.notice .btn { align-self: flex-start; }
.badge { display: inline-flex; align-items: center; gap: 6px; padding: 2px 8px; border-radius: 999px; font-size: 0.78rem; font-weight: 560; background: var(--surface-2); color: var(--ink-2); white-space: nowrap; }
.badge-warn { background: var(--warn-soft); color: var(--warn-text); }
.badge-ok { background: var(--ok-soft); color: var(--ok-text); }
.badge-accent { background: var(--accent-soft); color: var(--accent-text); }
.badge-danger { background: var(--danger-soft); color: var(--danger-text); }
.dot { width: 8px; height: 8px; border-radius: 50%; background: currentColor; flex: none; }

.toasts { position: fixed; z-index: 60; left: 50%; bottom: 16px; transform: translateX(-50%); display: flex; flex-direction: column; gap: 8px; width: min(440px, calc(100vw - 32px)); pointer-events: none; }
.toast { pointer-events: auto; background: var(--ink); color: var(--bg); padding: 12px 14px; border-radius: var(--radius); box-shadow: var(--shadow-2); display: flex; align-items: center; gap: 12px; font-size: 0.92rem; }
.toast .btn { min-height: 36px; background: transparent; color: inherit; border-color: color-mix(in srgb, var(--bg) 40%, transparent); }

/* ---------------------------------------------------------------- auth */
.auth { min-height: 100vh; display: grid; grid-template-columns: minmax(0, 1fr); place-items: center; padding: 32px 16px; }
.auth-card { width: min(420px, 100%); display: flex; flex-direction: column; gap: 20px; }
.auth-brand { display: flex; align-items: center; gap: 10px; font-family: var(--mono); letter-spacing: 0.16em; text-transform: uppercase; font-size: 0.8rem; color: var(--ink-2); }
.auth-panel { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 28px 24px; box-shadow: var(--shadow-1); display: flex; flex-direction: column; gap: 18px; }
.auth-panel form { display: flex; flex-direction: column; gap: 16px; }
.auth-foot { text-align: center; color: var(--ink-2); font-size: 0.92rem; }
.brand-mark { width: 28px; height: 28px; border-radius: 8px; background: var(--accent); display: grid; place-items: center; color: var(--accent-ink); font-family: var(--font-display); font-weight: 700; letter-spacing: 0; font-size: 0.95rem; }

/* Studio authentication: a composition room and an uninterrupted working surface.
   Scoped tokens preserve the signed-in editor's existing identity and component styles. */
@font-face {
  font-family: "Studio Instrument"; font-style: normal; font-weight: 400 700; font-display: swap;
  src: url("./fonts/instrument-sans-latin.woff2") format("woff2");
  unicode-range: U+0000-00FF,U+0131,U+0152-0153,U+02BB-02BC,U+02C6,U+02DA,U+02DC,U+0304,U+0308,U+0329,U+2000-206F,U+20AC,U+2122,U+2191,U+2193,U+2212,U+2215,U+FEFF,U+FFFD;
}
@font-face {
  font-family: "Studio Instrument"; font-style: normal; font-weight: 400 700; font-display: swap;
  src: url("./fonts/instrument-sans-latin-ext.woff2") format("woff2");
  unicode-range: U+0100-02BA,U+02BD-02C5,U+02C7-02CC,U+02CE-02D7,U+02DD-02FF,U+0304,U+0308,U+0329,U+1D00-1DBF,U+1E00-1E9F,U+1EF2-1EFF,U+2020,U+20A0-20AB,U+20AD-20C4,U+2113,U+2C60-2C7F,U+A720-A7FF;
}
.auth-studio {
  --font: "Studio Instrument", "Segoe UI", Arial, sans-serif; --font-display: var(--font);
  --bg: #f8f9fd; --surface: #ffffff; --surface-2: #edf0fa; --surface-3: #e3e8f7;
  --ink: #18213d; --ink-2: #59617a; --ink-3: #59617a; --line: #dfe3ed; --line-strong: #8290aa;
  --accent: #234bdc; --accent-hover: #173bc2; --accent-ink: #ffffff; --accent-text: #234bdc; --accent-soft: #e6ecff;
  --focus: #234bdc; --radius: 10px; --radius-sm: 10px;
  --auth-room: #244ce7; --auth-room-bottom: #2144cd; --auth-art-ink: #284bd1;
  --auth-ease-out: cubic-bezier(.16, 1, .3, 1); --auth-ease-glide: cubic-bezier(.4, 0, .2, 1);
  --auth-dur-micro: 160ms; --auth-dur-panel: 560ms; --auth-dur-hero: 1100ms; --auth-dur-loop: 12000ms;
  display: block; place-items: normal; padding: 0; background: var(--bg); color: var(--ink); font: 16px/1.5 var(--font); color-scheme: light;
}
.auth-studio .auth-layout { display: grid; width: 100%; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); min-height: 100svh; }
.auth-studio .auth-room {
  position: relative; display: flex; flex-direction: column; min-height: max(760px, 100svh); overflow: clip;
  padding: 44px clamp(40px, 4.4vw, 80px) 36px; color: #f5f7ff; background: var(--auth-room);
  background-image: linear-gradient(155deg, transparent 48%, var(--auth-room-bottom));
}
.auth-studio .auth-brand {
  display: inline-flex; align-self: flex-start; align-items: center; gap: 12px; min-height: 44px;
  color: inherit; text-decoration: none; text-transform: none; letter-spacing: -.045em; font: 600 28px/1 var(--font);
}
.auth-studio .auth-brand:focus-visible { outline-color: #f5f7ff; outline-offset: 6px; }
.auth-symbol { display: flex; width: 34px; height: 30px; align-items: center; }
.auth-symbol span { display: block; width: 11px; height: 23px; background: currentColor; transform: skewY(-26deg); }
.auth-symbol span:nth-child(2) { transform: skewY(26deg); opacity: .64; }
.auth-symbol span:nth-child(3) { opacity: .87; }
.auth-room-copy { position: relative; z-index: 1; margin-top: clamp(56px, 8vh, 104px); animation: auth-copy-settle var(--auth-dur-panel) var(--auth-ease-out) both; }
.auth-statement { font-size: clamp(3.5rem, 5.9vw, 5.5rem); font-weight: 500; line-height: 1.02; letter-spacing: -.058em; }
.auth-description { max-width: 340px; margin-top: 24px; font-size: 17px; line-height: 1.6; color: #e2e8ff; }
.auth-art { position: relative; flex: 1; min-height: 310px; margin: 32px -12px 8px; display: grid; align-items: center; }
.auth-fold { position: relative; width: 100%; max-width: 540px; aspect-ratio: 1.5; margin: auto; animation: auth-art-settle var(--auth-dur-hero) var(--auth-ease-out) both; isolation: isolate; }
.auth-sheet { position: absolute; width: 33.3334%; height: 72%; transform-origin: top left; overflow: clip; }
.auth-sheet-one { left: 0; top: 26.6%; transform: skewY(-28deg); background: linear-gradient(110deg, #f5f8ff, #c8d7ff); z-index: 2; }
.auth-sheet-two { left: 33.3333%; top: 0; transform: skewY(28deg); background: linear-gradient(90deg, #acbef2, #e5eeff); z-index: 1; }
.auth-sheet-three { left: 66.6666%; top: 26.6%; transform: skewY(-28deg); background: linear-gradient(100deg, #fcfdff, #ceddff); z-index: 2; }
.auth-sheet-one::after, .auth-sheet-three::after { content: ""; position: absolute; inset: 0; border-left: 1px solid rgb(255 255 255 / .65); border-right: 1px solid rgb(32 60 165 / .18); pointer-events: none; }
.auth-fold-shadow { position: absolute; left: 5%; right: -2%; bottom: -5%; height: 16%; border-radius: 50%; background: #0b2593; opacity: .38; filter: blur(18px); transform: rotate(-9deg); z-index: -1; }
.auth-sheet-circle { position: absolute; width: 38%; aspect-ratio: 1; top: 14%; left: 17%; border: 1px solid rgb(40 75 209 / .5); border-radius: 50%; }
.auth-sheet-circle::after { content: ""; position: absolute; inset: 18%; border-radius: 50%; background: var(--auth-art-ink); }
.auth-sheet-line { position: absolute; left: 17%; top: 65%; width: 66%; height: 3px; background: var(--auth-art-ink); opacity: .7; }
.auth-sheet-line:last-child { top: 73%; width: 43%; opacity: .35; }
.auth-sheet-window { position: absolute; inset: 14% 15%; border: 1px solid rgb(40 75 209 / .32); }
.auth-sheet-window::after { content: ""; position: absolute; inset: 30% 0 0; border-top: 1px solid rgb(40 75 209 / .32); background: linear-gradient(90deg, transparent 48%, rgb(40 75 209 / .16) 48%, rgb(40 75 209 / .16) 49%, transparent 49%); }
.auth-sheet-disc { position: absolute; width: 112%; aspect-ratio: 1; left: 16%; top: 24%; border-radius: 50%; background: var(--auth-art-ink); }
.auth-sheet-disc::after { content: ""; position: absolute; inset: 26%; border: 1px solid rgb(238 244 255 / .65); border-radius: 50%; }
.auth-fold-light { position: absolute; inset: 0; z-index: 3; overflow: clip; pointer-events: none; clip-path: polygon(0 26.6%, 33.333% 0, 66.666% 26.6%, 100% 0, 100% 72%, 66.666% 98.6%, 33.333% 72%, 0 98.6%); }
.auth-fold-light::after { content: ""; position: absolute; inset: -20% -40%; background: linear-gradient(100deg, transparent 39%, rgb(255 255 255 / .2) 50%, transparent 61%); transform: translateX(-70%); animation: auth-light-travel var(--auth-dur-loop) linear infinite; }
.auth-room-foot { color: #dbe4ff; font-size: 14px; }
.auth-workspace { position: relative; display: flex; flex-direction: column; min-width: 0; padding: 32px clamp(32px, 5vw, 88px) 48px; }
.auth-toolbar { display: flex; justify-content: flex-end; min-height: 44px; }
.auth-studio .auth-toolbar .icon-btn { border: 1px solid var(--line); border-radius: 50%; }
.auth-form-wrap { display: flex; flex: 1; align-items: center; justify-content: center; padding-block: 48px 68px; }
.auth-studio .auth-panel { width: 100%; max-width: 400px; padding: 0; gap: 24px; border: 0; border-radius: 0; box-shadow: none; background: transparent; }
.auth-heading { display: flex; flex-direction: column; gap: 12px; margin-bottom: 8px; }
.auth-studio h1 { font-size: clamp(2rem, 2.8vw, 2.5rem); line-height: 1.12; letter-spacing: -.045em; font-weight: 500; text-wrap: balance; }
.auth-studio h1[tabindex="-1"]:focus-visible { outline: none; }
.auth-heading p { line-height: 1.6; overflow-wrap: anywhere; }
.auth-studio .auth-panel form { gap: 20px; }
.auth-studio .field { gap: 8px; }
.auth-studio .field > label { font-size: 14px; font-weight: 600; }
.auth-studio .input { min-height: 54px; padding: 14px 16px; line-height: 1.5; }
.auth-studio .input:hover:not(:focus-visible) { border-color: var(--ink-2); }
.auth-studio .input-group { position: relative; display: block; }
.auth-studio .input-group .input { padding-right: 76px; }
.auth-studio .input-group .btn { position: absolute; right: 5px; top: 5px; min-height: 44px; padding-inline: 12px; color: var(--ink-2); font-size: 14px; border-radius: 7px; }
.auth-studio .hint, .auth-studio .error-text { font-size: 14px; line-height: 1.5; }
.auth-studio .auth-message:empty { display: none; }
.auth-studio .notice { padding: 16px; overflow-wrap: anywhere; font-size: 15px; }
.auth-studio .notice .btn { min-height: 44px; white-space: normal; text-align: left; line-height: 1.3; }
.auth-studio .btn-block { min-height: 54px; font-size: 16px; font-weight: 500; white-space: normal; line-height: 1.35; padding-block: 12px; }
.auth-studio .btn { transition: background var(--auth-dur-micro) var(--auth-ease-glide), border-color var(--auth-dur-micro) var(--auth-ease-glide), color var(--auth-dur-micro) var(--auth-ease-glide), transform var(--auth-dur-micro) var(--auth-ease-out); }
.auth-studio .btn:active:not(:disabled) { transform: translateY(1px); transition-duration: 70ms; }
.auth-studio .btn:disabled { opacity: .7; }
.auth-studio .auth-foot { font-size: 15px; line-height: 1.55; }
.auth-studio .auth-foot a, .auth-forgot a { display: inline-flex; align-items: center; min-height: 44px; color: var(--ink); text-decoration-color: var(--line-strong); text-underline-offset: 4px; }
.auth-studio .auth-foot a:hover, .auth-forgot a:hover { text-decoration-color: currentColor; }
.auth-forgot { align-self: flex-end; margin-top: -12px; margin-bottom: -8px; font-size: 14px; }
.auth-studio .auth-recovery-link { margin-top: -16px; font-size: 14px; }
.auth-studio .auth-recovery-link a { color: var(--ink-2); }
.auth-alternative { display: flex; flex-direction: column; gap: 16px; }
.auth-divider { display: flex; align-items: center; gap: 16px; color: var(--ink-2); font-size: 14px; }
.auth-divider::before, .auth-divider::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.auth-studio input:autofill { color: var(--ink); background-color: var(--surface-2); }
.auth-studio input:-webkit-autofill { -webkit-text-fill-color: var(--ink); -webkit-box-shadow: 0 0 0 1000px var(--surface-2) inset; caret-color: var(--ink); }
.auth-studio input[name="code"] { font: 500 28px/1.2 var(--font); letter-spacing: .25em; }
@keyframes auth-copy-settle { from { transform: translateY(12px); } to { transform: translateY(0); } }
@keyframes auth-art-settle { from { transform: translateY(16px); } to { transform: translateY(0); } }
@keyframes auth-light-travel { from { transform: translateX(-70%); } to { transform: translateX(70%); } }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .auth-studio {
    --bg: #141a2e; --surface: #1b233b; --surface-2: #242e49; --surface-3: #303c5c;
    --ink: #f0f2ff; --ink-2: #bac3de; --ink-3: #bac3de; --line: #364160; --line-strong: #6d7898;
    --accent: #b6c8ff; --accent-hover: #ccd9ff; --accent-ink: #172b66; --accent-text: #b6c8ff; --accent-soft: #263863;
    --focus: #b6c8ff; --auth-room: #1433a8; --auth-room-bottom: #112b8e; color-scheme: dark;
  }
}
:root[data-theme="dark"] .auth-studio {
  --bg: #141a2e; --surface: #1b233b; --surface-2: #242e49; --surface-3: #303c5c;
  --ink: #f0f2ff; --ink-2: #bac3de; --ink-3: #bac3de; --line: #364160; --line-strong: #6d7898;
  --accent: #b6c8ff; --accent-hover: #ccd9ff; --accent-ink: #172b66; --accent-text: #b6c8ff; --accent-soft: #263863;
  --focus: #b6c8ff; --auth-room: #1433a8; --auth-room-bottom: #112b8e; color-scheme: dark;
}
@media (min-width: 1600px) { .auth-studio .auth-layout { grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); } }
@media (max-width: 1050px) and (min-width: 761px) {
  .auth-studio .auth-room { padding-inline: 32px; }
  .auth-statement { font-size: clamp(2.7rem, 5.7vw, 4rem); }
  .auth-description { font-size: 16px; }
  .auth-art { min-height: 240px; }
  .auth-workspace { padding-inline: 32px; }
}
@media (max-width: 760px) {
  .auth-studio .auth-layout { position: relative; grid-template-columns: minmax(0, 1fr); grid-template-rows: auto minmax(0, 1fr); }
  .auth-studio .auth-room { min-height: 0; padding: 20px 6vw 28px; }
  .auth-studio .auth-brand { font-size: 24px; }
  .auth-symbol { transform: scale(.86); transform-origin: left center; width: 28px; }
  .auth-room-copy { margin-top: 24px; max-width: 80%; }
  .auth-statement { font-size: clamp(1.875rem, 4.4vw, 2.5rem); letter-spacing: -.045em; }
  .auth-description, .auth-room-foot { display: none; }
  .auth-art { position: absolute; width: 120px; min-height: 0; margin: 0; right: -28px; bottom: 0; opacity: .68; }
  .auth-fold { width: 120px; }
  .auth-fold-shadow { display: none; }
  .auth-workspace { position: static; padding: 0 6vw 32px; }
  .auth-toolbar { position: absolute; top: 20px; right: 6vw; }
  .auth-studio .auth-toolbar .icon-btn { color: #f5f7ff; border-color: rgb(245 247 255 / .36); }
  .auth-studio .auth-toolbar .icon-btn:hover { background: rgb(245 247 255 / .15); }
  .auth-studio .auth-toolbar .icon-btn:focus-visible { outline-color: #f5f7ff; }
  .auth-form-wrap { padding: 36px 0 8px; align-items: flex-start; }
  .auth-studio .auth-panel { max-width: 440px; gap: 20px; padding: 0; }
  .auth-studio h1 { font-size: 32px; }
  .auth-heading { gap: 10px; margin-bottom: 4px; }
  .auth-studio .auth-recovery-link { margin-top: -12px; }
}
@media (max-width: 360px) {
  .auth-studio .auth-room { padding-bottom: 24px; }
  .auth-room-copy { margin-top: 20px; }
  .auth-statement { font-size: 28px; }
  .auth-studio h1 { font-size: 30px; }
}
@media (prefers-reduced-motion: reduce) {
  .auth-room-copy, .auth-fold, .auth-fold-light::after { animation: none; transform: none; }
  .auth-fold-light::after { opacity: .4; }
  .auth-studio .btn:active:not(:disabled) { transform: none; }
}

/* ---------------------------------------------------------------- app shell */
.shell { min-height: 100vh; display: flex; flex-direction: column; }
.topbar { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 8px; min-height: 60px; padding: 8px 16px; background: color-mix(in srgb, var(--bg) 92%, transparent); border-bottom: 1px solid var(--line); backdrop-filter: blur(8px); }
.topbar .brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--ink); font-weight: 650; min-height: 44px; }
.topbar nav { display: flex; gap: 2px; margin-left: 12px; }
.topbar nav a { display: inline-flex; align-items: center; min-height: 44px; padding: 0 12px; border-radius: var(--radius-sm); color: var(--ink-2); text-decoration: none; font-weight: 520; }
.topbar nav a[aria-current="page"] { color: var(--ink); background: var(--surface-2); }
.topbar .spacer { flex: 1; }
.menu { position: relative; }
.menu-pop { position: absolute; right: 0; top: calc(100% + 6px); min-width: 220px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-2); padding: 6px; display: flex; flex-direction: column; z-index: 30; }
.menu-pop .who { padding: 8px 10px; color: var(--ink-3); font-size: 0.85rem; overflow-wrap: anywhere; }
.menu-pop button { text-align: left; justify-content: flex-start; }
.page { width: min(1160px, 100%); margin: 0 auto; padding: 28px 16px 64px; display: flex; flex-direction: column; gap: 24px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.page-head p { color: var(--ink-2); margin-top: 6px; }

/* ---------------------------------------------------------------- dashboard */
.sites-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 14px; }
.site-card { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 18px; display: flex; flex-direction: column; gap: 12px; box-shadow: var(--shadow-1); }
.site-card h2 { font-size: 1.05rem; overflow-wrap: anywhere; }
.site-card .meta { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; color: var(--ink-3); font-size: 0.85rem; }
.site-card .actions { display: flex; gap: 8px; margin-top: auto; flex-wrap: wrap; }
.empty { border: 1px dashed var(--line-strong); border-radius: 14px; padding: 36px 20px; text-align: center; color: var(--ink-2); display: flex; flex-direction: column; gap: 14px; align-items: center; }

dialog.sheet { width: min(980px, calc(100vw - 24px)); max-height: calc(100vh - 32px); padding: 0; border: 1px solid var(--line); border-radius: 16px; background: var(--surface); color: var(--ink); box-shadow: var(--shadow-2); }
dialog.sheet::backdrop { background: rgb(10 12 14 / 0.45); }
.sheet-inner { display: flex; flex-direction: column; max-height: calc(100vh - 34px); }
.sheet-head { display: flex; align-items: center; gap: 12px; padding: 14px 16px 14px 20px; border-bottom: 1px solid var(--line); }
.sheet-body { padding: 18px 20px; overflow: auto; display: flex; flex-direction: column; gap: 16px; }
.sheet-foot { padding: 12px 20px; border-top: 1px solid var(--line); display: flex; gap: 10px; justify-content: flex-end; flex-wrap: wrap; align-items: center; }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); overflow-x: auto; }
.tab { min-height: 44px; padding: 0 14px; border: 0; background: none; color: var(--ink-2); font: 540 0.93rem var(--font); cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; display: inline-flex; align-items: center; gap: 6px; }
.tab[aria-selected="true"] { color: var(--ink); border-bottom-color: var(--accent); }
.tab:hover { color: var(--ink); }

.tpl-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 12px; }
.tpl { display: flex; flex-direction: column; text-align: left; gap: 0; padding: 0; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); color: var(--ink); cursor: pointer; overflow: hidden; font: inherit; }
.tpl:hover { border-color: var(--line-strong); }
.tpl[aria-pressed="true"] { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent); }
.tpl-thumb { aspect-ratio: 16 / 10; background: var(--surface-2); width: 100%; object-fit: cover; }
.tpl-text { padding: 10px 12px 12px; display: flex; flex-direction: column; gap: 2px; }
.tpl-name { font-weight: 600; font-size: 0.93rem; }
.tpl-meta { color: var(--ink-3); font-size: 0.8rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------------------------------------------------------------- editor */
.editor { height: 100vh; height: 100dvh; display: grid; grid-template-rows: auto auto 1fr; overflow: hidden; }
.ebar { display: flex; align-items: center; gap: 6px; min-height: 60px; padding: 8px 12px; border-bottom: 1px solid var(--line); background: var(--surface); }
.ebar h1 { font-size: 1rem; font-weight: 620; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.ebar .sep { width: 1px; align-self: stretch; margin: 6px 4px; background: var(--line); }
.ebar .grow { display: flex; flex-direction: column; min-width: 0; }
.save-state { font-size: 0.8rem; color: var(--ink-3); display: flex; align-items: center; gap: 6px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.save-state[data-state="saving"] { color: var(--warn-text); }
.save-state[data-state="error"] { color: var(--danger-text); }
.save-state[data-state="saved"] { color: var(--ok-text); }
.devices { display: inline-flex; gap: 2px; }
.ebanner { padding: 8px 12px; border-bottom: 1px solid var(--line); background: var(--warn-soft); color: var(--warn-text); display: flex; gap: 12px; align-items: center; flex-wrap: wrap; font-size: 0.9rem; }
.ebanner .grow { min-width: 220px; }
.ebanner .btn { min-height: 36px; }
.ework { display: grid; grid-template-columns: minmax(0, 1fr) 380px; min-height: 0; }
.stage { position: relative; background: var(--stage); overflow: auto; display: flex; justify-content: center; padding: 16px; min-height: 0; }
.device { position: relative; width: 100%; height: 100%; min-height: 420px; background: var(--surface); border-radius: 10px; box-shadow: var(--shadow-2); overflow: hidden; flex: none; }
.device[data-device="tablet"] { width: 768px; max-width: 100%; }
.device[data-device="phone"] { width: 390px; max-width: 100%; }
.device iframe { width: 100%; height: 100%; border: 0; display: block; background: #fff; }
.sel-chip { position: absolute; z-index: 3; pointer-events: none; transform: translateY(-100%); background: var(--accent); color: var(--accent-ink); font: 600 0.72rem/1 var(--mono); letter-spacing: 0.04em; padding: 5px 7px; border-radius: 5px 5px 5px 0; white-space: nowrap; }
.frame-state { position: absolute; inset: 0; display: grid; place-items: center; background: color-mix(in srgb, var(--surface) 86%, transparent); color: var(--ink-2); z-index: 2; text-align: center; padding: 24px; }
.panel { border-left: 1px solid var(--line); background: var(--surface); display: flex; flex-direction: column; min-height: 0; }
.panel .tabs { padding: 0 8px; flex: none; }
.panel-body { overflow: auto; padding: 16px; display: flex; flex-direction: column; gap: 18px; flex: 1 1 auto; min-height: 0; }
.section { display: flex; flex-direction: column; gap: 10px; }
.section + .section { border-top: 1px solid var(--line); padding-top: 18px; }
.sel-head { display: flex; align-items: center; gap: 10px; }
.sel-kind { width: 36px; height: 36px; border-radius: 8px; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent-text); flex: none; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 4px 12px; font-size: 0.86rem; }
.kv dt { color: var(--ink-3); }
.kv dd { margin: 0; overflow-wrap: anywhere; font-family: var(--mono); font-size: 0.82rem; }
.token-list { display: flex; flex-direction: column; gap: 8px; }
.token-row { display: grid; grid-template-columns: 44px minmax(0, 1fr) minmax(0, 1.1fr); gap: 8px; align-items: center; }
.token-row label { font-family: var(--mono); font-size: 0.8rem; color: var(--ink-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.token-row .input { min-height: 40px; padding: 8px 10px; font-family: var(--mono); }
.swatch { width: 44px; height: 44px; border-radius: 8px; border: 1px solid var(--line-strong); padding: 0; background: none; cursor: pointer; overflow: hidden; }
.swatch input { width: 64px; height: 64px; margin: -10px; border: 0; padding: 0; cursor: pointer; background: none; }
.history { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.history li { display: flex; gap: 10px; align-items: center; padding: 8px 10px; border: 1px solid var(--line); border-radius: var(--radius-sm); }
.history li[aria-current="true"] { border-color: var(--accent); background: var(--accent-soft); }
.history .vnum { font-family: var(--mono); font-size: 0.8rem; color: var(--ink-3); min-width: 34px; }
.history .vtext { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.history .vnote { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 0.9rem; }
.chat { display: flex; flex-direction: column; gap: 10px; }
.chat-log { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.msg { padding: 10px 12px; border-radius: 12px; max-width: 92%; white-space: pre-wrap; overflow-wrap: anywhere; font-size: 0.93rem; }
.msg-user { align-self: flex-end; background: var(--accent-soft); color: var(--ink); border-bottom-right-radius: 4px; }
.msg-assistant { align-self: flex-start; background: var(--surface-2); border-bottom-left-radius: 4px; }
.msg-meta { align-self: flex-start; font-size: 0.82rem; color: var(--ink-3); display: flex; gap: 6px; align-items: center; }
.msg-meta.ok { color: var(--ok-text); }
.msg-meta.bad { color: var(--danger-text); }
.chat-sel { display: flex; align-items: center; gap: 8px; font-size: 0.85rem; color: var(--ink-2); background: var(--surface-2); border-radius: var(--radius-sm); padding: 4px 4px 4px 10px; }
.chat-sel span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; }
.progress { height: 6px; border-radius: 6px; background: var(--surface-3); overflow: hidden; }
.progress > div { height: 100%; width: 0; background: var(--accent); }

/* ---------------------------------------------------------------- publish */
.wizard { display: grid; grid-template-columns: 220px minmax(0, 1fr); gap: 28px; align-items: start; }
.steps { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; position: sticky; top: 84px; }
.steps li { display: flex; align-items: center; gap: 10px; min-height: 40px; color: var(--ink-3); font-weight: 520; }
.steps .n { width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; border: 1px solid var(--line-strong); font: 600 0.78rem var(--mono); flex: none; }
.steps li[aria-current="step"] { color: var(--ink); }
.steps li[aria-current="step"] .n { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.steps li[data-done="true"] .n { background: var(--accent-soft); color: var(--accent-text); border-color: transparent; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 22px; display: flex; flex-direction: column; gap: 16px; box-shadow: var(--shadow-1); }
.choices { display: grid; gap: 10px; }
.choice { display: flex; gap: 12px; align-items: flex-start; padding: 14px; border: 1px solid var(--line); border-radius: 12px; cursor: pointer; background: var(--surface); min-height: 44px; }
.choice:hover { border-color: var(--line-strong); }
.choice:has(input:checked) { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.choice input { width: 20px; height: 20px; margin-top: 2px; accent-color: var(--accent); flex: none; }
.choice .ctext { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.choice .ctitle { font-weight: 600; }
.providers { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 10px; }
.provider { border: 1px solid var(--line); border-radius: 12px; padding: 14px; display: flex; flex-direction: column; gap: 10px; }
.provider h3 { text-transform: capitalize; }
.records { width: 100%; border-collapse: collapse; font-size: 0.88rem; }
.records th { text-align: left; font-weight: 600; color: var(--ink-3); font-size: 0.75rem; letter-spacing: 0.06em; text-transform: uppercase; padding: 8px; border-bottom: 1px solid var(--line); }
.records td { padding: 8px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.records td.val { font-family: var(--mono); font-size: 0.82rem; overflow-wrap: anywhere; }
.copy-cell { display: flex; align-items: center; gap: 4px; }
.copy-cell code { overflow-wrap: anywhere; flex: 1; }
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); }
.status-line { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.live-url { font-family: var(--mono); font-size: 1rem; overflow-wrap: anywhere; }
.warning-box { border-left: 3px solid var(--warn-text); background: var(--warn-soft); color: var(--warn-text); padding: 12px 14px; border-radius: 0 var(--radius-sm) var(--radius-sm) 0; display: flex; flex-direction: column; gap: 8px; }
.warning-box ul { margin: 0; padding-left: 18px; }

/* ---------------------------------------------------------------- responsive */
@media (max-width: 1000px) {
  .ework { grid-template-columns: minmax(0, 1fr) 330px; }
}
@media (max-width: 820px) {
  .editor { height: auto; min-height: 100dvh; overflow: visible; grid-template-rows: auto auto auto auto; }
  .ework { grid-template-columns: minmax(0, 1fr); }
  .stage { height: 62vh; height: 62svh; padding: 8px; }
  .device { min-height: 0; }
  .panel { border-left: 0; border-top: 1px solid var(--line); }
  .panel-body { overflow: visible; }
  .ebar { flex-wrap: wrap; position: sticky; top: 0; z-index: 10; }
  .ebar .devices { display: none; }
  .wizard { grid-template-columns: minmax(0, 1fr); gap: 16px; }
  .steps { position: static; flex-direction: row; overflow-x: auto; gap: 12px; }
  .steps li .t { display: none; }
  .steps li[aria-current="step"] .t { display: inline; }
}
@media (max-width: 560px) {
  .topbar nav { margin-left: 0; }
  .topbar .brand span { display: none; }
  .page { padding: 20px 16px 48px; }
  h1 { font-size: 1.35rem; }
  .ebar { display: grid; grid-template-columns: 44px minmax(0, 1fr) 44px 44px; }
  .ebar .editor-back { grid-area: 1 / 1; }
  .ebar .grow { grid-area: 1 / 2 / 2 / 5; }
  .ebar h1 { max-width: none; }
  .ebar .editor-undo { grid-area: 2 / 1; }
  .ebar .editor-redo { grid-area: 2 / 2; }
  .ebar .editor-theme { grid-area: 2 / 3; }
  .ebar .editor-publish { grid-area: 2 / 4; min-height: 44px; }
  .ebar .sep { display: none; }
  .ebar .label-hide { display: none; }
  .card { padding: 16px; }
  .auth-panel { padding: 22px 16px; }
  .token-row { grid-template-columns: 44px minmax(0, 1fr); }
  .token-row label { grid-column: 1 / -1; }
  .records th:nth-child(4), .records td:nth-child(4) { display: none; }
  dialog.sheet { width: 100vw; max-width: 100vw; max-height: 100dvh; height: 100dvh; border-radius: 0; margin: 0; }
  .sheet-inner { max-height: 100dvh; height: 100%; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation-duration: 0ms !important; scroll-behavior: auto !important; }
}

/* Account security: authenticator setup and one-time recovery codes. */
.security-mfa { --line-strong: #837e72; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .security-mfa { --line-strong: #747c89; }
}
:root[data-theme="dark"] .security-mfa { --line-strong: #747c89; }
.security-mfa .security-mfa-state { font-weight: 600; color: var(--ink); }
.security-mfa .security-mfa-body { min-width: 0; }
.security-mfa .security-mfa-instructions { display: grid; gap: 10px; margin: 0; padding-left: 22px; color: var(--ink-2); line-height: 1.6; }
.security-mfa .security-recovery-codes { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px 16px; list-style: none; margin: 0; padding: 16px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--bg); }
.security-mfa .security-recovery-code { font-size: 1rem; overflow-wrap: anywhere; user-select: all; }
.security-mfa .security-mfa-ack { display: flex; align-items: center; gap: 12px; min-height: 44px; cursor: pointer; line-height: 1.5; }
.security-mfa .security-mfa-ack input { flex: none; width: 20px; height: 20px; accent-color: var(--accent); }
.security-mfa .security-mfa-actions .btn { min-height: 44px; }
@media (max-width: 560px) {
  .security-mfa .security-recovery-codes { grid-template-columns: minmax(0, 1fr); }
  .security-mfa .security-mfa-actions { align-items: stretch; flex-direction: column; }
}
