:root {
  color-scheme: light;
  --bg: #ffffff;
  --surface: #f6f6f7;
  --sunk: #eeeef1;
  --fg: #111114;
  --fg-2: #3b3b42;
  --muted: #6c6c75;
  --border: #dcdce1;
  --soft: #ececf0;
  --signal: #3b82f6;
  --signal-ink: #2563eb;
  --signal-soft: #e8f0fe;
  --signal-btn: #2563eb;
  --on-signal: #ffffff;
  --danger: #c2341f;
  --danger-soft: #fdecea;
  --warn: #9a5b00;
  --warn-soft: #fff4e0;
  --ok: #1f7a4d;
  --ok-soft: #e6f5ec;
  --display: "Poppins", system-ui, sans-serif;
  --body: "Roboto", system-ui, sans-serif;
  --mono: "Inconsolata", ui-monospace, monospace;
  --r: 10px;
  --shadow: 0 1px 2px rgba(17, 17, 20, 0.05), 0 12px 32px rgba(17, 17, 20, 0.1);
  --ease: cubic-bezier(0.2, 0, 0, 1);
}
@media screen and (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #0f1012; --surface: #16181b; --sunk: #1d1f23; --fg: #f2f3f5; --fg-2: #c4c7cd; --muted: #8d929a; --border: #2e3137; --soft: #222429;
    --signal: #5b9bff; --signal-ink: #8db7ff; --signal-soft: #17243a; --signal-btn: #8db7ff; --on-signal: #0b1220; --danger: #ff8a75; --danger-soft: #3a1d18; --warn: #f5b950; --warn-soft: #33270f; --ok: #6fd39c; --ok-soft: #12291c;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 12px 32px rgba(0, 0, 0, 0.45);
  }
}
@media screen {
  :root[data-theme="dark"] {
    color-scheme: dark;
    --bg: #0f1012; --surface: #16181b; --sunk: #1d1f23; --fg: #f2f3f5; --fg-2: #c4c7cd; --muted: #8d929a; --border: #2e3137; --soft: #222429;
    --signal: #5b9bff; --signal-ink: #8db7ff; --signal-soft: #17243a; --signal-btn: #8db7ff; --on-signal: #0b1220; --danger: #ff8a75; --danger-soft: #3a1d18; --warn: #f5b950; --warn-soft: #33270f; --ok: #6fd39c; --ok-soft: #12291c;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 12px 32px rgba(0, 0, 0, 0.45);
  }
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; }
body { margin: 0; overflow: hidden; background: var(--bg); color: var(--fg); font: 15px/1.5 var(--body); -webkit-font-smoothing: antialiased; }
h1, h2, h3, p, ul, ol { margin: 0; }
ul, ol { padding: 0; list-style: none; }
a { color: inherit; }
button, input, textarea, select { font: inherit; color: inherit; }
button { padding: 0; background: none; border: 0; cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: 0.45; }
svg { flex: none; }
:focus-visible { outline: 2px solid var(--signal); outline-offset: 2px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- top bar ---------- */
.bar { display: flex; align-items: center; gap: 10px; height: 60px; padding: 0 14px 0 18px; border-bottom: 1px solid var(--border); }
.brand { display: inline-flex; align-items: center; gap: 8px; margin-right: 6px; font: 600 17px/1 var(--display); letter-spacing: -0.035em; text-decoration: none; }
.brand-mark { display: grid; gap: 2px; width: 16px; }
.brand-mark i { display: block; height: 3px; background: var(--fg); border-radius: 1px; }
.brand-mark i:nth-child(2) { width: 11px; }
.brand-mark i:nth-child(3) { width: 6px; }
.brand em { padding: 3px 7px; background: var(--signal-soft); border-radius: 6px; color: var(--signal-ink); font: 600 11px/1 var(--mono); font-style: normal; letter-spacing: 0.08em; text-transform: uppercase; }
.status { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); font-size: 13px; white-space: nowrap; }
.status i { width: 7px; height: 7px; background: var(--ok); border-radius: 50%; }
.status.is-busy i { background: var(--warn); }
.status.is-bad i { background: var(--danger); }
.spacer { flex: 1; }
.tool { display: grid; place-items: center; width: 38px; height: 38px; border: 1px solid transparent; border-radius: 8px; color: var(--fg-2); }
.tool:hover:not(:disabled) { background: var(--surface); border-color: var(--border); color: var(--fg); }
.tool svg { width: 18px; height: 18px; }
.seg { display: inline-flex; padding: 3px; background: var(--surface); border: 1px solid var(--border); border-radius: 9px; }
.seg button { display: inline-flex; align-items: center; gap: 6px; min-height: 30px; padding: 0 10px; border-radius: 6px; color: var(--muted); font-size: 13px; font-weight: 500; white-space: nowrap; }
.seg button svg { width: 16px; height: 16px; }
.seg button[aria-pressed="true"] { background: var(--bg); box-shadow: 0 1px 2px rgba(0, 0, 0, 0.12); color: var(--fg); }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 7px; min-height: 38px; padding: 0 14px; background: var(--bg); border: 1px solid var(--border); border-radius: 9px; font-size: 14px; font-weight: 600; text-decoration: none; white-space: nowrap; transition: border-color 0.15s, background-color 0.15s, transform 0.15s var(--ease); }
.btn svg { width: 16px; height: 16px; }
.btn:hover:not(:disabled) { border-color: var(--fg); }
.btn.primary { background: var(--fg); border-color: var(--fg); color: var(--bg); }
.btn.primary:hover:not(:disabled) { transform: translateY(-1px); }
.btn.signal { background: var(--signal-btn); border-color: var(--signal-btn); color: var(--on-signal); }
.btn.danger { border-color: var(--danger); color: var(--danger); }
.btn.small { min-height: 32px; padding: 0 10px; font-size: 13px; }
.btn.block { width: 100%; }
.viewswitch { display: none; }

/* ---------- layout ---------- */
.shell { display: grid; grid-template-columns: 78px minmax(360px, 430px) minmax(0, 1fr); height: calc(100% - 60px); }
.rail { display: flex; flex-direction: column; gap: 4px; padding: 12px 8px; border-right: 1px solid var(--border); }
.rail button { position: relative; display: grid; justify-items: center; gap: 4px; padding: 10px 2px 8px; border-radius: 10px; color: var(--muted); font-size: 11px; font-weight: 600; }
.rail button svg { width: 22px; height: 22px; }
.rail button:hover { background: var(--surface); color: var(--fg); }
.rail button[aria-selected="true"] { background: var(--signal-soft); color: var(--signal-ink); }
.rail .dot { position: absolute; top: 7px; right: 14px; width: 8px; height: 8px; background: var(--danger); border: 2px solid var(--bg); border-radius: 50%; }
.editor { overflow-y: auto; border-right: 1px solid var(--border); scrollbar-gutter: stable; }
.pane { padding: 22px 22px 80px; }
.pane-head { margin-bottom: 18px; }
.pane-head h1 { font: 600 24px/1.15 var(--display); letter-spacing: -0.03em; }
.pane-head p { margin-top: 6px; color: var(--muted); font-size: 14px; }
.group-title { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin: 26px 0 10px; color: var(--muted); font: 600 12px/1.3 var(--mono); letter-spacing: 0.1em; text-transform: uppercase; }
.group-title:first-of-type { margin-top: 6px; }

/* fields */
.field { display: grid; gap: 6px; margin-bottom: 14px; }
.lab { display: flex; justify-content: space-between; gap: 8px; color: var(--fg-2); font-size: 13px; font-weight: 600; }
.lab small { color: var(--muted); font-weight: 400; }
.lab small.over { color: var(--danger); }
.in, .ta, .sel { width: 100%; min-height: 40px; padding: 8px 11px; background: var(--bg); border: 1px solid var(--border); border-radius: 8px; transition: border-color 0.15s, box-shadow 0.15s; }
.ta { min-height: 92px; resize: vertical; line-height: 1.5; }
.in:hover, .ta:hover, .sel:hover { border-color: color-mix(in srgb, var(--fg) 35%, var(--border)); }
.in:focus, .ta:focus, .sel:focus { outline: 0; border-color: var(--signal); box-shadow: 0 0 0 3px color-mix(in srgb, var(--signal) 22%, transparent); }
.in.bad { border-color: var(--danger); }
.hint { color: var(--muted); font-size: 12.5px; }
.hint.bad { color: var(--danger); }
.row2 { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 10px; }
.row2 .field { margin-bottom: 14px; }
.inline { display: flex; align-items: center; gap: 10px; }

.switch-row { display: flex; align-items: center; justify-content: space-between; gap: 14px; margin-bottom: 12px; padding: 12px 14px; background: var(--surface); border: 1px solid var(--soft); border-radius: var(--r); }
.switch-row b { display: block; font-size: 14px; }
.switch-row small { color: var(--muted); font-size: 12.5px; }
.switch { position: relative; width: 42px; height: 24px; flex: none; background: var(--border); border-radius: 99px; transition: background-color 0.15s; }
.switch::after { position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; background: #fff; border-radius: 50%; box-shadow: 0 1px 2px rgba(0, 0, 0, 0.25); content: ""; transition: transform 0.18s var(--ease); }
.switch[aria-checked="true"] { background: var(--signal-btn); }
.switch[aria-checked="true"]::after { transform: translateX(18px); }

.link-row { display: grid; grid-template-columns: 112px minmax(0, 1fr) 38px; gap: 6px; align-items: center; margin-bottom: 8px; }
.link-row.hl { grid-template-columns: 88px minmax(0, 1fr) 38px; }
.link-row + .confirm, .link-row ~ .confirm { margin: -2px 0 10px; }
.add { margin-top: 2px; }

/* chips */
.chips { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; min-height: 42px; padding: 6px; background: var(--bg); border: 1px solid var(--border); border-radius: 8px; cursor: text; }
.chips:focus-within { border-color: var(--signal); box-shadow: 0 0 0 3px color-mix(in srgb, var(--signal) 22%, transparent); }
.chip { display: inline-flex; align-items: center; gap: 4px; padding: 3px 4px 3px 10px; background: var(--surface); border: 1px solid var(--soft); border-radius: 99px; font-size: 13px; }
.chip button { display: grid; place-items: center; width: 20px; height: 20px; border-radius: 50%; color: var(--muted); }
.chip button:hover { background: var(--sunk); color: var(--fg); }
.chip button svg { width: 12px; height: 12px; }
.chips input { flex: 1; min-width: 120px; min-height: 28px; padding: 0 6px; background: none; border: 0; outline: 0; }

/* cards */
.card { margin-bottom: 10px; background: var(--bg); border: 1px solid var(--border); border-radius: 12px; transition: border-color 0.15s, box-shadow 0.15s; }
.card.is-open { border-color: color-mix(in srgb, var(--signal) 55%, var(--border)); box-shadow: var(--shadow); }
.card-head { display: flex; align-items: center; gap: 10px; padding: 10px 10px 10px 12px; }
.card-head .grip { color: var(--muted); font: 600 12px/1 var(--mono); }
.card-title { flex: 1; min-width: 0; text-align: left; }
.card-title b { display: block; overflow: hidden; font-size: 14.5px; text-overflow: ellipsis; white-space: nowrap; }
.card-title small { display: block; overflow: hidden; color: var(--muted); font-size: 12.5px; text-overflow: ellipsis; white-space: nowrap; }
.card-tools { display: flex; gap: 2px; }
.card-tools .tool { width: 32px; height: 32px; }
.card-tools .tool svg { width: 16px; height: 16px; }
.card-body { padding: 4px 14px 14px; border-top: 1px solid var(--soft); }
.card-body > :first-child { margin-top: 14px; }
.thumb { width: 56px; height: 36px; flex: none; overflow: hidden; border-radius: 6px; background: var(--surface); }
.thumb svg, .thumb img { display: block; width: 100%; height: 100%; object-fit: cover; }
.confirm { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin: 0 10px 10px; padding: 10px 12px; background: var(--danger-soft); border-radius: 8px; color: var(--danger); font-size: 13px; font-weight: 600; }
.confirm div { display: flex; gap: 6px; }
.add { display: flex; align-items: center; justify-content: center; gap: 8px; width: 100%; min-height: 46px; border: 1.5px dashed var(--border); border-radius: 12px; color: var(--fg-2); font-weight: 600; }
.add:hover:not(:disabled) { border-color: var(--signal); color: var(--signal-ink); }
.add svg { width: 18px; height: 18px; }
.filters { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 14px; }
.filters button { min-height: 30px; padding: 0 11px; border: 1px solid var(--border); border-radius: 99px; color: var(--fg-2); font-size: 13px; font-weight: 500; }
.filters button[aria-pressed="true"] { background: var(--fg); border-color: var(--fg); color: var(--bg); }
.filters button span { margin-left: 4px; opacity: 0.6; }
.empty-note { padding: 22px; background: var(--surface); border-radius: 12px; color: var(--muted); text-align: center; font-size: 14px; }
.empty-note b { display: block; margin-bottom: 4px; color: var(--fg); font-size: 15px; }

/* covers + media */
.cover-pick { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.cover-pick button { display: grid; gap: 4px; padding: 4px; border: 1.5px solid var(--border); border-radius: 9px; color: var(--muted); font-size: 12px; font-weight: 600; text-transform: capitalize; }
.cover-pick button[aria-pressed="true"] { border-color: var(--signal); color: var(--signal-ink); }
.cover-pick .thumb { width: 100%; height: auto; aspect-ratio: 8 / 5; }
.media { display: flex; align-items: center; gap: 12px; }
.media .big { width: 120px; height: 75px; flex: none; overflow: hidden; border-radius: 8px; background: var(--surface); }
.media .big img { width: 100%; height: 100%; object-fit: cover; }
.avatar { display: grid; place-items: center; width: 64px; height: 64px; flex: none; overflow: hidden; background: var(--signal-soft); border-radius: 14px; color: var(--signal-ink); font: 700 20px/1 var(--display); }
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.file-btn { position: relative; overflow: hidden; }
.file-btn input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.thumb, .media .big { --cv-bg: color-mix(in srgb, var(--cv-a, #3b82f6) 12%, var(--bg)); }
.cv .k { fill: var(--cv-bg); } .cv .a { fill: var(--cv-a, #3b82f6); } .cv .b { fill: var(--fg); } .cv .c { fill: color-mix(in srgb, var(--fg) 12%, var(--cv-bg)); } .cv .p { fill: var(--bg); } .cv .sa { stroke: var(--cv-a, #3b82f6); } .cv .sb { stroke: var(--fg); } .cv .t { font-family: var(--display); font-weight: 600; }

/* style tab */
.swatches { display: flex; flex-wrap: wrap; gap: 8px; }
.swatches button { width: 36px; height: 36px; border-radius: 10px; box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.12); }
.swatches button[aria-pressed="true"] { outline: 2px solid var(--fg); outline-offset: 2px; }
.color-row { display: flex; gap: 8px; margin-top: 12px; }
.color-row input[type="color"] { width: 44px; height: 40px; padding: 2px; background: var(--bg); border: 1px solid var(--border); border-radius: 8px; cursor: pointer; }
.contrast { display: flex; gap: 10px; margin-top: 12px; padding: 12px; background: var(--surface); border-radius: 10px; font-size: 13px; }
.contrast .sample { display: inline-flex; align-items: center; min-height: 34px; padding: 0 12px; border-radius: 8px; font-weight: 600; white-space: nowrap; }
.contrast p { color: var(--fg-2); }
.fonts { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.fonts button { display: grid; gap: 2px; padding: 12px; border: 1.5px solid var(--border); border-radius: 10px; text-align: left; }
.fonts button[aria-pressed="true"] { border-color: var(--signal); background: var(--signal-soft); }
.fonts .aa { font-size: 30px; font-weight: 600; line-height: 1.05; letter-spacing: -0.02em; }
.fonts b { font-size: 13px; }
.fonts small { color: var(--muted); font-size: 12px; }

/* publish */
.checks { display: grid; gap: 6px; }
.check { display: flex; align-items: flex-start; gap: 10px; padding: 10px 12px; border-radius: 10px; font-size: 13.5px; }
.check svg { width: 18px; height: 18px; margin-top: 1px; }
.check.error { background: var(--danger-soft); color: var(--danger); }
.check.warn { background: var(--warn-soft); color: var(--warn); }
.check.ok { background: var(--ok-soft); color: var(--ok); }
.check p { flex: 1; color: var(--fg); }
.check button { color: inherit; font-weight: 700; text-decoration: underline; text-underline-offset: 2px; white-space: nowrap; }
.serp { margin-top: 4px; padding: 14px; background: var(--surface); border-radius: 10px; }
.serp small { color: var(--muted); font-size: 12px; }
.serp b { display: block; margin: 2px 0; overflow: hidden; color: #1a0dab; font: 400 18px/1.3 Arial, sans-serif; text-overflow: ellipsis; white-space: nowrap; }
:root[data-theme="dark"] .serp b { color: #8ab4f8; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .serp b { color: #8ab4f8; } }
.serp p { color: var(--fg-2); font: 13px/1.5 Arial, sans-serif; }
.actions { display: grid; gap: 8px; }
.actions.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.hosts li { display: flex; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--soft); font-size: 13.5px; }
.hosts li:last-child { border-bottom: 0; }
.hosts span { display: grid; place-items: center; width: 22px; height: 22px; flex: none; background: var(--sunk); border-radius: 6px; font: 600 12px/1 var(--mono); }
.hosts p { color: var(--fg-2); }
.hosts b { color: var(--fg); }

/* ---------- preview ---------- */
.preview { position: relative; display: grid; grid-template-columns: minmax(0, 1fr); grid-template-rows: auto minmax(0, 1fr); min-width: 0; background: radial-gradient(var(--border) 1px, transparent 1px) 0 0 / 18px 18px, var(--surface); }
.preview-bar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 10px; padding: 10px 14px; }
.preview-bar .url { display: inline-flex; align-items: center; gap: 6px; min-width: 0; overflow: hidden; color: var(--muted); font: 600 12px/1 var(--mono); letter-spacing: 0.04em; white-space: nowrap; }
.preview-bar .url i { width: 7px; height: 7px; flex: none; background: var(--ok); border-radius: 50%; }
.stage { position: relative; overflow: hidden; }
.frame-box { position: absolute; top: 0; left: 0; overflow: hidden; background: #fff; border-radius: 10px; box-shadow: var(--shadow); transform-origin: 0 0; }
.frame-box iframe { display: block; width: 100%; height: 100%; border: 0; }
.frame-box.phone { border: 10px solid #15161c; border-radius: 40px; }
.frame-box.tablet { border: 10px solid #15161c; border-radius: 26px; }
.size-note { position: absolute; right: 14px; bottom: 10px; padding: 4px 8px; background: var(--bg); border: 1px solid var(--border); border-radius: 6px; color: var(--muted); font: 600 11px/1 var(--mono); }

/* ---------- dialog + toast ---------- */
.dialog { width: min(560px, calc(100vw - 32px)); padding: 0; background: var(--bg); border: 1px solid var(--border); border-radius: 18px; box-shadow: 0 30px 80px rgba(0, 0, 0, 0.3); color: var(--fg); }
.dialog::backdrop { background: rgba(10, 10, 14, 0.55); backdrop-filter: blur(3px); }
.dialog-body { padding: 28px; }
.dialog h2 { margin-top: 14px; font: 600 28px/1.1 var(--display); letter-spacing: -0.035em; }
.dialog p { margin-top: 8px; color: var(--fg-2); }
.starts { display: grid; gap: 10px; margin-top: 22px; }
.start { display: flex; align-items: center; gap: 14px; padding: 14px; border: 1.5px solid var(--border); border-radius: 12px; text-align: left; transition: border-color 0.15s; }
.start:hover { border-color: var(--signal); }
.start .ic { display: grid; place-items: center; width: 42px; height: 42px; flex: none; background: var(--signal-soft); border-radius: 10px; color: var(--signal-ink); }
.start .ic svg { width: 20px; height: 20px; }
.start b { display: block; }
.start small { color: var(--muted); font-size: 13px; }
.start.file { position: relative; }
.start.file input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.fine { margin-top: 16px; color: var(--muted); font-size: 12.5px; }
.toast { position: fixed; left: 50%; bottom: 22px; z-index: 50; max-width: calc(100vw - 32px); padding: 11px 16px; background: var(--fg); border-radius: 10px; box-shadow: var(--shadow); color: var(--bg); font-size: 14px; font-weight: 500; opacity: 0; pointer-events: none; transform: translate(-50%, 10px); transition: opacity 0.2s, transform 0.2s var(--ease); }
.toast.is-on { opacity: 1; transform: translate(-50%, 0); }

/* ---------- responsive ---------- */
@media (max-width: 1180px) {
  .shell { grid-template-columns: 70px 360px minmax(0, 1fr); }
  .hide-md { display: none; }
}
@media (max-width: 900px) {
  body { overflow: auto; }
  .bar { position: sticky; top: 0; z-index: 10; gap: 6px; padding: 0 10px; background: var(--bg); }
  .bar .hide-sm { display: none; }
  .viewswitch { display: inline-flex; }
  .shell { display: block; height: auto; }
  .rail { position: sticky; top: 60px; z-index: 9; flex-direction: row; gap: 2px; overflow-x: auto; padding: 6px 8px; background: var(--bg); border-right: 0; border-bottom: 1px solid var(--border); }
  .rail button { flex: 1; min-width: 64px; padding: 7px 4px 6px; }
  .rail button svg { width: 20px; height: 20px; }
  .editor { overflow: visible; border-right: 0; }
  .pane { padding: 18px 16px 90px; }
  body[data-view="edit"] .preview { display: none; }
  body[data-view="preview"] .editor, body[data-view="preview"] .rail { display: none; }
  .preview { height: calc(100vh - 60px); height: calc(100dvh - 60px); }
  .preview-bar { padding: 8px 10px; }
  .preview-bar .url { display: none; }
  .preview-bar > .inline { width: 100%; justify-content: space-between; }
}
@media (max-width: 420px) {
  .brand span.word { display: none; }
  .row2 { grid-template-columns: minmax(0, 1fr); gap: 0; }
  .fonts { grid-template-columns: minmax(0, 1fr); }
  .actions.two { grid-template-columns: minmax(0, 1fr); }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { transition: none !important; animation: none !important; } }
/* Touch screens: the wordmark link gets a thumb-sized target. */
@media (pointer: coarse) { .brand { min-height: 44px; } }
