/* Sajtredigeraren — "Rail" layout (Claude Design: Site Editor Final, 2026-09-13).
 * One structure, two themes: :root is dark, [data-theme="light"] swaps values only.
 * Fonts are self-hosted: the glass CSP is same-origin only. */

@font-face { font-family: "Instrument Sans"; src: url("/assets/instrument-sans.woff2") format("woff2"); font-weight: 400 700; font-style: normal; font-display: swap; }
@font-face { font-family: "JetBrains Mono"; src: url("/assets/jetbrains-mono.woff2") format("woff2"); font-weight: 400 500; font-style: normal; font-display: swap; }

:root {
  --bg: #0B0E1A; --panel: #141936; --row: #0E1226; --head: #141936; --panel-2: #1B2145; --panel-3: #2A3160; --field: #101532;
  --line: #242B52; --line-2: #2A3160;
  --ink: #E9ECFA; --ink-2: #CDD3EC; --ink-3: #C3CAE6; --muted: #9AA3C6; --faint: #6E77A0;
  --accent: #5B49E0; --accent-hi: #7F6BFF; --accent-soft: rgba(91,73,224,.18); --accent-ink: #fff; --accent-text: #B9AEFF;
  --logo-a: #9C8DFF; --logo-b: #5B49E0;
  --sandbox: #FFC46B; --sandbox-soft: rgba(255,196,107,.18); --sandbox-fade: rgba(255,196,107,.08);
  --live: #43E39B; --live-soft: rgba(67,227,155,.16); --live-fade: rgba(67,227,155,.08);
  --bad: #FF7A8A; --bad-soft: rgba(255,122,138,.14);
  --notice-bg: rgba(255,196,107,.1); --notice-line: rgba(255,196,107,.3); --notice-ink: #FFD99B;
  --shadow-accent: 0 6px 18px rgba(91,73,224,.4);
  --shadow-pop: 0 24px 60px rgba(0,0,0,.5);
  --frame-ring: 0 0 0 1px var(--line);
  --backdrop: rgba(5,7,15,.6);
  --logo-image: none;
  --sans: "Instrument Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  color-scheme: dark;
}
[data-theme="light"] {
  --bg: #F4F5FB; --panel: #FFFFFF; --row: #FFFFFF; --head: #F8F9FD; --panel-2: #EDEFF8; --panel-3: #ECE9FD; --field: #FFFFFF;
  --line: #DFE3F2; --line-2: #D5D9EA;
  --ink: #171A2B; --ink-2: #2C3145; --ink-3: #3C4259; --muted: #5A6183; --faint: #8A90AB;
  --accent: #4B38D6; --accent-hi: #3A2AAF; --accent-soft: #ECE9FD; --accent-ink: #fff; --accent-text: #3A2AAF;
  --logo-a: #8878FF; --logo-b: #4B38D6;
  --sandbox: #A05E00; --sandbox-soft: #FFF1D9; --sandbox-fade: rgba(160,94,0,.1);
  --live: #0E7A52; --live-soft: #E3F4EC; --live-fade: rgba(14,122,82,.1);
  --bad: #B42335; --bad-soft: #FDE8EB;
  --notice-bg: #FFF7E6; --notice-line: #F0DDB4; --notice-ink: #6B4400;
  --shadow-accent: 0 4px 12px rgba(75,56,214,.28);
  --shadow-pop: 0 18px 48px rgba(23,26,43,.18);
  --frame-ring: 0 1px 3px rgba(23,26,43,.1), 0 0 0 1px var(--line);
  --backdrop: rgba(23,26,43,.35);
  color-scheme: light;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body { font: 14px/1.45 var(--sans); color: var(--ink); background: var(--bg); -webkit-font-smoothing: antialiased; }
#app, .view { height: 100%; }
[hidden] { display: none !important; }
button, input, textarea { font: inherit; color: inherit; }
svg { fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.spacer { flex: 1; }
.muted { color: var(--muted); }
.small-text { font-size: 12px; }
.error, .form-error { color: var(--bad); font-size: 13px; margin: .5rem 0 0; }
.hint { color: var(--muted); font-size: 12px; line-height: 1.5; margin: 0; }
:focus-visible { outline: 2px solid var(--accent-hi); outline-offset: 2px; }

/* ---- buttons ---- */
button { cursor: pointer; border: 0; background: none; padding: 0; border-radius: 8px; }
button:disabled { opacity: .45; cursor: not-allowed; }
button.primary { height: 34px; padding: 0 16px; border-radius: 9px; background: var(--accent); color: var(--accent-ink); font-weight: 600; font-size: 13px; box-shadow: var(--shadow-accent); }
button.primary:not(:disabled):hover { filter: brightness(1.08); }
button.primary:disabled { box-shadow: none; }
button.secondary { height: 32px; padding: 0 12px; border-radius: 8px; background: var(--panel-2); color: var(--ink); font-size: 13px; border: 1px solid var(--line); }
button.secondary:not(:disabled):hover { border-color: var(--accent); }
button.small { height: 28px; padding: 0 10px; font-size: 12px; }
button.primary.small { height: 30px; box-shadow: none; }
button.link { color: var(--ink-3); font-size: 13px; padding: 6px 4px; }
button.link:not(:disabled):hover { color: var(--ink); }
button.link.small { font-size: 12px; color: var(--muted); }
.icon-btn { width: 28px; height: 28px; display: grid; place-items: center; color: var(--muted); border-radius: 7px; flex: none; }
.icon-btn:hover { color: var(--ink); background: var(--panel-3); }
.icon-btn svg { width: 15px; height: 15px; }
.button-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.button-row.end { justify-content: flex-end; }

/* ---- shared bits ---- */
.brand { display: flex; align-items: center; gap: 10px; font-size: 14px; font-weight: 600; margin: 0; }
.logo { width: 22px; height: 22px; border-radius: 7px; background: var(--logo-image) center / cover no-repeat, linear-gradient(140deg, var(--logo-a), var(--logo-b)); display: inline-block; flex: none; }
.logo-lg { width: 56px; height: 56px; border-radius: 14px; }
[data-has-logo] .logo { background: var(--logo-image) center / cover no-repeat, var(--panel-2); }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 1.4rem; }
.dot { width: 6px; height: 6px; border-radius: 50%; display: inline-block; flex: none; background: var(--muted); }
.dot.sandbox { background: var(--sandbox); }
.dot.live { background: var(--live); }
.badge { display: inline-flex; align-items: center; gap: 7px; font-size: 12px; color: var(--muted); white-space: nowrap; }
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: .55; }
.badge.ok { color: var(--live); }
.badge.ok::before, .badge.warn::before, .badge.bad::before { opacity: 1; }
.badge.warn { color: var(--sandbox); }
.badge.bad { color: var(--bad); }
.badge:empty { display: none; }

.segmented { display: inline-flex; align-items: center; gap: 2px; padding: 3px; background: var(--panel-2); border-radius: 9px; }
.segmented button { width: 34px; height: 28px; border-radius: 6px; display: grid; place-items: center; color: var(--muted); }
.segmented button.on { background: var(--panel-3); color: var(--ink); }
[data-theme="light"] .segmented button.on { background: var(--panel); box-shadow: 0 1px 2px rgba(23,26,43,.12); }
.vp { display: block; border: 1.5px solid currentColor; border-radius: 2px; }
.vp-desktop { width: 15px; height: 11px; }
.vp-tablet { width: 11px; height: 13px; }
.vp-mobile { width: 8px; height: 14px; }

.theme-switch { display: inline-flex; gap: 2px; padding: 3px; background: var(--panel-2); border-radius: 999px; }
.theme-opt { width: 28px; height: 24px; border-radius: 999px; display: grid; place-items: center; color: var(--muted); }
.theme-opt svg { width: 13px; height: 13px; stroke-width: 1.8; }
:root:not([data-theme="light"]) .theme-opt[data-opt="dark"],
[data-theme="light"] .theme-opt[data-opt="light"] { background: var(--panel-3); color: var(--ink); }
[data-theme="light"] .theme-opt[data-opt="light"] { background: var(--panel); box-shadow: 0 1px 2px rgba(23,26,43,.14); }

/* ---- topbar ---- */
.topbar { height: 56px; flex: none; display: flex; align-items: center; gap: 14px; padding: 0 18px; background: var(--panel); border-bottom: 1px solid var(--line); min-width: 0; }
.divider { width: 1px; height: 22px; background: var(--line); flex: none; }

/* ---- login ---- */
#view-login { display: grid; place-items: center; padding: 16px; }
.login { width: min(22rem, 100%); display: grid; gap: .9rem; box-shadow: var(--shadow-pop); }
.login label { display: grid; gap: .35rem; font-size: 12px; color: var(--muted); }
.login input, .field input, .connector-row input { height: 36px; padding: 0 11px; border: 1px solid var(--line-2); border-radius: 9px; background: var(--field); color: var(--ink); width: 100%; min-width: 0; }
.login input:focus, .field input:focus, .connector-row input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.login button.primary { height: 38px; }

/* ---- sites ---- */
#view-sites { display: flex; flex-direction: column; }
.sites { width: 100%; max-width: 64rem; margin: 0 auto; padding: 28px; display: flex; flex-direction: column; gap: 18px; }
.sites h2 { margin: 0; font-size: 20px; font-weight: 600; letter-spacing: -0.015em; }
.site-table { border: 1px solid var(--line); border-radius: 12px; overflow: hidden; background: var(--row); }
.site-table-head, .site-row { display: grid; grid-template-columns: minmax(0, 1fr) 170px 170px 96px; align-items: center; gap: 12px; }
.site-table-head { padding: 10px 16px; background: var(--head); border-bottom: 1px solid var(--line); color: var(--muted); font-size: 11px; letter-spacing: 0.08em; text-transform: uppercase; }
.site-list { list-style: none; margin: 0; padding: 0; }
.site-row { padding: 14px 16px; }
.site-row + .site-row { border-top: 1px solid var(--line); }
.site-id { display: flex; align-items: center; gap: 12px; min-width: 0; }
.site-avatar { width: 30px; height: 30px; border-radius: 9px; background: linear-gradient(140deg, var(--logo-a), var(--logo-b)); flex: none; display: grid; place-items: center; color: var(--accent-ink); font-size: 12px; font-weight: 700; text-transform: uppercase; }
[data-has-logo] .site-avatar { background: var(--logo-image) center / cover no-repeat, var(--panel-2); color: transparent; }
.site-name { display: flex; flex-direction: column; line-height: 1.25; min-width: 0; }
.site-name strong { font-size: 13px; font-weight: 600; }
.site-name span { color: var(--muted); font-size: 11px; font-family: var(--mono); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.site-row button.primary { justify-self: end; height: 30px; padding: 0 14px; font-size: 12px; box-shadow: none; }
@media (max-width: 700px) {
  .site-table-head { display: none; }
  .site-row { grid-template-columns: minmax(0, 1fr) auto; }
  .site-row .badge { grid-column: 1; }
  .site-row button.primary { grid-column: 2; grid-row: 1; }
  .sites { padding: 20px 16px; }
}

/* ---- editor frame ---- */
.editor { display: flex; flex-direction: column; min-height: 0; }
.env-stripe { height: 3px; flex: none; background: linear-gradient(90deg, var(--sandbox), var(--sandbox-fade)); }
.editor[data-env="live"] .env-stripe { background: linear-gradient(90deg, var(--live), var(--live-fade)); }

.back { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 15px; padding: 4px 6px 4px 2px; min-width: 0; }
.back strong { color: var(--ink); font-weight: 600; letter-spacing: -0.01em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.back:hover strong { color: var(--accent-hi); }

.env-switch { display: flex; align-items: center; gap: 2px; padding: 3px; background: var(--panel-2); border-radius: 999px; flex: none; }
.env-switch button { height: 27px; padding: 0 13px; border-radius: 999px; color: var(--muted); font-size: 12px; display: flex; align-items: center; gap: 7px; border: 1px solid transparent; }
.env-switch button:not(:disabled):hover { color: var(--ink); }
#view-sandbox.on { background: var(--sandbox-soft); color: var(--sandbox); font-weight: 600; }
#view-live.on { background: var(--live-soft); color: var(--live); font-weight: 600; }
[data-theme="light"] #view-live.on { background: var(--panel); border-color: #C9E3D8; }
[data-theme="light"] #view-sandbox.on { background: var(--panel); border-color: #F0DDB4; }

.address { flex: 1; min-width: 8rem; display: flex; align-items: center; gap: 8px; height: 34px; padding: 0 4px 0 12px; background: var(--panel-2); border-radius: 9px; font: 12px var(--mono); }
.address:focus-within { box-shadow: 0 0 0 2px var(--accent-soft); }
.address-host { color: var(--muted); white-space: nowrap; flex: none; max-width: 40%; overflow: hidden; text-overflow: ellipsis; }
.preview-address { flex: 1; min-width: 0; margin: 0; }
.preview-address input { width: 100%; min-width: 0; height: 30px; border: 0; background: transparent; color: var(--ink); font: 12px var(--mono); outline: none; padding: 0; }
.publish-pill { color: var(--muted); font-size: 12px; white-space: nowrap; max-width: 16rem; overflow: hidden; text-overflow: ellipsis; }
.publish-pill.bad { color: var(--bad); }
.publish-pill.warn { color: var(--sandbox); }
#publication-pill.busy::before { content: ""; display: inline-block; width: 10px; height: 10px; margin-right: 6px; vertical-align: -1px; border: 2px solid var(--line-2); border-top-color: var(--accent-hi); border-radius: 50%; animation: spin 1s linear infinite; }

@media (max-width: 1100px) {
  .editor-top { gap: 10px; padding: 0 12px; }
  .publish-pill, .viewport, .editor-top .divider { display: none; }
}
@media (max-width: 760px) {
  .editor-top { height: auto; flex-wrap: wrap; padding: 8px 12px; }
  .address { order: 5; flex-basis: 100%; }
}

.editor-body { flex: 1; display: grid; grid-template-columns: 60px auto minmax(0, 1fr) 380px; min-height: 0; }
/* Explicit columns: the settings panel is display:none when closed and must not shift the others. */
.editor-body > .rail { grid-column: 1; grid-row: 1; }
.editor-body > .side-panel { grid-column: 2; grid-row: 1; }
.editor-body > .preview-pane { grid-column: 3; grid-row: 1; }
.editor-body > .chat { grid-column: 4; grid-row: 1; }

/* rail */
.rail { background: var(--panel); border-right: 1px solid var(--line); display: flex; flex-direction: column; align-items: center; padding: 14px 0; gap: 6px; }
.rail-group { display: flex; flex-direction: column; gap: 6px; }
.rail-btn { width: 38px; height: 38px; border-radius: 10px; display: grid; place-items: center; color: var(--muted); }
.rail-btn svg { width: 17px; height: 17px; stroke-width: 1.5; }
.rail-btn:not(:disabled):hover { color: var(--ink); background: var(--panel-2); }
.rail-btn.on { background: var(--panel-3); color: var(--ink); }
[data-theme="light"] .rail-btn.on { color: var(--accent); }
.rail-divider { width: 26px; height: 1px; background: var(--line); margin: 6px 0; }
.rail .spacer { flex: 1; }
.icon-sun { display: none; }
[data-theme="light"] .icon-sun { display: block; }
[data-theme="light"] .icon-moon { display: none; }

/* settings panel (left) */
.side-panel { width: 340px; background: var(--panel); border-right: 1px solid var(--line); display: flex; flex-direction: column; min-height: 0; }
.panel-head { display: flex; align-items: center; gap: 10px; min-height: 52px; padding: 0 12px 0 16px; }
.panel-head strong { font-size: 13px; font-weight: 600; }
.panel-scroll { flex: 1; overflow: auto; padding: 0 16px 20px; }
.panel-section { padding: 14px 0 16px; border-top: 1px solid var(--line); display: flex; flex-direction: column; gap: 10px; }
.panel-section h3 { margin: 0; font-size: 11px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.section-head { display: flex; align-items: center; justify-content: space-between; }
.status-line { display: flex; flex-wrap: wrap; gap: 6px 16px; }
.field { display: grid; gap: 6px; margin: 0; }
.connector-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 6px; padding: 10px; margin-bottom: 8px; border: 1px solid var(--line); border-radius: 10px; background: var(--field); }
.connector-row input { height: 32px; background: var(--panel-2); border-color: transparent; font-size: 13px; }
.connector-row input[type="url"] { grid-column: 1; font: 12px var(--mono); }
.connector-row button { grid-column: 2; grid-row: 1 / span 2; align-self: center; }
.operator-list > div { font-size: 12px; color: var(--muted); padding: 8px 10px; border: 1px dashed var(--line); border-radius: 10px; margin-bottom: 8px; }
.integration-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; }
.integration-row + .integration-row { margin-top: 8px; }
.integration-row > span { flex: 1; min-width: 8rem; font-size: 13px; }
.integration-row > span.connected { color: var(--live); }

/* webmaster: model + key */
.field-label { font-size: 12px; color: var(--muted); }
.field select { height: 36px; padding: 0 10px; border: 1px solid var(--line-2); border-radius: 9px; background: var(--field); color: var(--ink); font: inherit; font-size: 13px; width: 100%; }
.field select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.key-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 6px; align-items: center; }
.key-row input { height: 32px; padding: 0 10px; border: 1px solid var(--line-2); border-radius: 8px; background: var(--field); color: var(--ink); font: 12px var(--mono); min-width: 0; }
.key-row input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.key-status { display: inline-flex; align-items: center; gap: 7px; font-size: 13px; }
.key-status::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.key-status.site { color: var(--live); }
.key-status.server { color: var(--ink-2); }
.key-status.none { color: var(--bad); }

/* brand logo + colours */
.logo-field { display: flex; align-items: center; gap: 14px; }
.logo-actions { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.file-label { display: inline-flex; align-items: center; height: 28px; padding: 0 10px; border-radius: 8px; background: var(--panel-2); border: 1px solid var(--line); font-size: 12px; cursor: pointer; }
.file-label:hover { border-color: var(--accent); }
.file-label:focus-within { outline: 2px solid var(--accent-hi); outline-offset: 2px; }
.color-field { display: grid; grid-template-columns: 36px minmax(0, 1fr); gap: 10px; align-items: end; }
.color-field input[type="color"] { width: 36px; height: 36px; padding: 0; border: 1px solid var(--line-2); border-radius: 9px; background: var(--field); cursor: pointer; }
.color-field input[type="color"]::-webkit-color-swatch-wrapper { padding: 3px; }
.color-field input[type="color"]::-webkit-color-swatch { border: 0; border-radius: 6px; }
.color-field label { display: grid; gap: 4px; font-size: 12px; color: var(--muted); }
.color-field input[type="text"] { height: 36px; padding: 0 11px; border: 1px solid var(--line-2); border-radius: 9px; background: var(--field); color: var(--ink); font: 12px var(--mono); width: 100%; }
.color-field input[type="text"]:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.color-field input[type="text"][aria-invalid="true"] { border-color: var(--bad); }
.brand-preview { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 10px; border: 1px dashed var(--line); border-radius: 10px; }
.brand-chip { padding: 3px 8px; border-radius: 6px; background: var(--panel-2); color: var(--accent-text); font: 11px var(--mono); }
.brand-bubble { padding: 6px 10px; border-radius: 12px; background: var(--accent); color: var(--accent-ink); font-size: 12px; }
.brand-button { padding: 6px 12px; border-radius: 8px; background: var(--accent); color: var(--accent-ink); font-size: 12px; font-weight: 600; box-shadow: var(--shadow-accent); }

/* preview */
.preview-pane { position: relative; min-width: 0; display: flex; flex-direction: column; min-height: 0; padding: 16px; }
.frame-wrap { flex: 1; position: relative; display: flex; justify-content: center; overflow: hidden; border-radius: 12px; }
.frame-wrap iframe { border: 0; height: 100%; width: 100%; background: #fff; border-radius: 12px; box-shadow: var(--frame-ring); transition: width .2s; }
.frame-wrap[data-vp="tablet"] iframe { width: 820px; max-width: 100%; }
.frame-wrap[data-vp="mobile"] iframe { width: 390px; max-width: 100%; }
.preview-overlay { position: absolute; inset: 0; display: grid; place-items: center; background: var(--bg); border-radius: 12px; }
.preview-overlay .card { text-align: center; display: grid; gap: .7rem; max-width: 24rem; }
.preview-overlay p { margin: 0; color: var(--ink-2); }
.preview-spinner { width: 28px; height: 28px; margin: 0 auto; border: 3px solid var(--line-2); border-top-color: var(--accent-hi); border-radius: 50%; animation: spin 1s linear infinite; }
.annotate-bar { position: absolute; top: 26px; left: 50%; transform: translateX(-50%); z-index: 3; display: flex; gap: 6px; padding: 6px; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow-pop); }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .preview-spinner, #publication-pill.busy::before { animation: none; } }

/* chat */
.chat { display: flex; flex-direction: column; min-height: 0; background: var(--panel); border-left: 1px solid var(--line); }
.chat.dropping { outline: 2px dashed var(--accent-hi); outline-offset: -6px; }
.chat-head { height: 52px; flex: none; display: flex; align-items: center; gap: 10px; padding: 0 16px; }
.chat-head strong { font-size: 13px; font-weight: 600; }
.notice { margin: 0 16px 8px; display: flex; align-items: flex-start; gap: 8px; padding: 9px 12px; border-radius: 10px; background: var(--notice-bg); border: 1px solid var(--notice-line); color: var(--notice-ink); font-size: 12px; line-height: 1.45; }
.notice .dot { margin-top: 6px; }
.messages { list-style: none; margin: 0; padding: 6px 16px 16px; flex: 1; overflow: auto; display: flex; flex-direction: column; gap: 16px; }
.msg { white-space: pre-wrap; word-break: break-word; font-size: 13px; line-height: 1.6; display: flex; flex-direction: column; gap: 8px; }
.msg.user { align-self: flex-end; align-items: flex-end; max-width: 90%; }
.msg.user .text { padding: 11px 14px; border-radius: 14px; background: var(--accent); color: var(--accent-ink); line-height: 1.5; }
.msg.user .text:empty { display: none; }
.msg.assistant { color: var(--ink-2); }
.msg .time { font-size: 11px; color: var(--muted); }
.msg .time:empty { display: none; }
.msg .tools { display: flex; flex-direction: column; gap: 4px; }
.msg .tools:empty { display: none; }
.msg details { font: 11px var(--mono); color: var(--muted); border-left: 2px solid var(--line-2); padding: 2px 0 2px 10px; }
.msg details summary { cursor: pointer; list-style: none; }
.msg details summary::-webkit-details-marker { display: none; }
.msg details[open] summary { color: var(--ink-2); }
.msg details pre { margin: 6px 0 0; white-space: pre-wrap; max-height: 12rem; overflow: auto; color: var(--ink-2); }
.msg .status { font-size: 12px; color: var(--muted); font-style: italic; }
.msg .status:empty { display: none; }
.msg .ctx { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.msg .ctx img { max-height: 80px; border-radius: 8px; border: 1px solid var(--line); }
.msg .ctx .badge { color: var(--accent-text); background: var(--panel-2); padding: 3px 8px; border-radius: 6px; font: 11px var(--mono); }
.msg .ctx .badge::before { display: none; }

.chips { display: flex; gap: 6px; flex-wrap: wrap; padding: 0 16px; max-height: 10rem; overflow-y: auto; flex-shrink: 0; }
.chip { display: inline-flex; gap: 6px; align-items: center; padding: 4px 6px 4px 10px; border-radius: 6px; background: var(--panel-2); color: var(--accent-text); font: 11px var(--mono); max-width: 100%; }
[data-theme="light"] .chip { background: var(--panel-3); }
.chip img { height: 24px; border-radius: 4px; }
.chip code { font: inherit; max-width: 22ch; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chip button { color: var(--muted); font-size: 13px; line-height: 1; padding: 0 2px; }
.chip button:hover { color: var(--ink); }

.composer { flex: none; margin: 10px 16px 16px; border: 1px solid var(--line-2); border-radius: 14px; background: var(--field); padding: 12px 12px 10px 14px; display: flex; flex-direction: column; gap: 10px; }
[data-theme="light"] .composer { box-shadow: 0 1px 2px rgba(23,26,43,.06); }
.composer:focus-within { border-color: var(--accent); }
.composer textarea { width: 100%; resize: none; border: 0; background: transparent; color: var(--ink); font-size: 13px; line-height: 1.5; outline: none; padding: 0; max-height: 12rem; }
.composer textarea::placeholder { color: var(--muted); }
.composer-row { display: flex; align-items: center; gap: 12px; }
.attach { width: 26px; height: 26px; display: grid; place-items: center; border-radius: 7px; color: var(--muted); font-size: 16px; cursor: pointer; }
.attach:hover { color: var(--ink); background: var(--panel-2); }
.send { width: 30px; height: 30px; border-radius: 50%; background: var(--accent); color: var(--accent-ink); font-size: 14px; display: grid; place-items: center; }

/* history drawer + dialog */
.drawer { position: fixed; top: 0; right: 0; bottom: 0; width: min(28rem, 100vw); background: var(--panel); border-left: 1px solid var(--line); padding: 0 16px 16px; overflow: auto; box-shadow: var(--shadow-pop); z-index: 10; display: flex; flex-direction: column; gap: 12px; }
.drawer .panel-head { padding: 0; }
.history-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.history-list li { display: grid; grid-template-columns: 1fr auto; gap: 4px 10px; align-items: center; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; font-size: 13px; }
.history-list li button { height: 28px; padding: 0 10px; font-size: 12px; border-radius: 8px; background: var(--panel-2); border: 1px solid var(--line); }
.history-list .meta { grid-column: 1 / -1; font-size: 11px; color: var(--muted); font-family: var(--mono); }

.dialog { width: min(32rem, calc(100vw - 32px)); color: var(--ink); background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 0 20px 20px; box-shadow: var(--shadow-pop); }
.dialog .panel-head { padding: 0; }
.dialog p { margin: 0 0 12px; }
.dialog::backdrop { background: var(--backdrop); }

.toast { position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); background: var(--ink); color: var(--bg); padding: 9px 14px; border-radius: 10px; max-width: min(40rem, calc(100vw - 32px)); z-index: 20; box-shadow: var(--shadow-pop); font-size: 13px; }
.toast.bad { background: var(--bad); color: #fff; }

@media (max-width: 1200px) { .editor-body { grid-template-columns: 60px auto minmax(0, 1fr) 320px; } }
@media (max-width: 900px) {
  .editor-body { grid-template-columns: 52px minmax(0, 1fr); grid-template-rows: minmax(0, 1fr) minmax(14rem, 42vh); }
  .editor-body > .rail { grid-row: 1 / span 2; }
  .editor-body > .preview-pane { grid-column: 2; grid-row: 1; }
  .editor-body > .chat { grid-column: 2; grid-row: 2; }
  .side-panel { position: fixed; left: 52px; top: 0; bottom: 0; z-index: 9; width: min(340px, calc(100vw - 52px)); box-shadow: var(--shadow-pop); }
  .preview-pane { padding: 8px; }
  .chat { border-left: 0; border-top: 1px solid var(--line); }
}
