/* ==========================================================================
   CodexTheme Studio — studio page
   Light paper theme, all sans-serif (Space Grotesk display + Inter body).
   The .workspace-window preview keeps its own dark themed appearance —
   it previews the user's theme, and is embedded in the standalone export.
   ========================================================================== */
:root {
  color-scheme: light;
  --paper: #f7f7f2;
  --panel: #ffffff;
  --panel-2: #fbfbf8;
  --panel-3: #f0f0ea;
  --line: rgba(20, 22, 26, 0.1);
  --line-strong: rgba(20, 22, 26, 0.18);
  --text: #14161a;
  --muted: #4c5158;
  --soft: #82878f;
  --brand: #1fae54;
  --brand-2: #178a42;
  --mint: #e7f6ec;
  --night: #12140f;
  --danger: #d84a52;
  --radius: 18px;
  --shadow: 0 24px 70px rgba(20, 22, 26, 0.16);
  --font-display: Manrope, Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --font-sans: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-family: var(--font-sans);
  background: var(--paper);
  color: var(--text);
  font-synthesis: none;
  text-rendering: optimizeLegibility;
}

* { box-sizing: border-box; }
html { min-width: 320px; background: var(--paper); }
body {
  min-width: 320px; min-height: 100vh; margin: 0;
  background:
    radial-gradient(circle at 8% -12%, rgba(140, 255, 101, .14), transparent 24rem),
    radial-gradient(circle at 92% -12%, rgba(84, 215, 255, .11), transparent 26rem),
    var(--paper);
}
button, input, textarea, select { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
button { color: inherit; }
svg { display: block; }
h1, h2, h3, p { margin-top: 0; }

.app-shell { height: 100vh; display: flex; flex-direction: column; overflow: hidden; }

/* ---------- top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 30;
  height: 64px; padding: 0 22px;
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  background: rgba(247, 247, 242, .82);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(14px);
}
.brand { display: inline-flex; align-items: center; gap: 10px; color: inherit; text-decoration: none; }
.brand-mark { width: 32px; height: 32px; display: grid; place-items: center; overflow: hidden; border-radius: 9px; background: transparent; }
.brand-mark img { width: 32px; height: 32px; display: block; object-fit: cover; }
.brand-word { display: flex; align-items: baseline; gap: 7px; }
.brand-word strong { font-family: var(--font-display); font-size: 16px; font-weight: 700; letter-spacing: -.02em; }
.brand-word small { font-size: 11px; color: var(--soft); text-transform: uppercase; letter-spacing: .12em; }
.topbar-actions { display: flex; align-items: center; gap: 8px; }
.save-state {
  display: inline-flex; align-items: center; gap: 7px;
  margin-right: 6px; color: var(--soft); font-size: 12px; white-space: nowrap;
}
.save-state::before { content: ""; width: 7px; height: 7px; border-radius: 99px; background: var(--brand); box-shadow: 0 0 10px rgba(31, 174, 84, .55); }
.save-state.saving { color: var(--brand-2); }
.save-state.saving::before { background: var(--brand-2); animation: pulse 1s ease infinite; }
@keyframes pulse { 50% { opacity: .4; } }

/* ---------- buttons ---------- */
.button, .icon-button, .text-button {
  border: 0; cursor: pointer;
  transition: transform .16s ease, border-color .16s ease, background .16s ease, color .16s ease, box-shadow .16s ease;
}
.button:active, .icon-button:active, .text-button:active { transform: translateY(1px); }
.button {
  min-height: 40px; padding: 0 17px; white-space: nowrap;
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  border-radius: 999px; font-size: 13px; font-weight: 600; text-decoration: none;
}
.button svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.button-primary { color: #f5f7f2; background: var(--night); box-shadow: 0 8px 22px rgba(18, 20, 15, .18); }
.button-primary:hover { background: #262a20; transform: translateY(-1px); box-shadow: 0 12px 26px rgba(18, 20, 15, .24); }
.button-secondary { color: var(--text); background: #ffffff; border: 1px solid var(--line-strong); }
.button-secondary:hover { background: var(--panel-2); border-color: rgba(20, 22, 26, .3); }
.button-ghost { color: var(--muted); background: transparent; border: 1px solid transparent; }
.button-ghost:hover { color: var(--text); background: var(--panel-3); }
.button-ghost[aria-pressed="true"] { color: var(--brand-2); background: var(--mint); }
.button-full { width: 100%; }
.icon-button { width: 38px; height: 38px; display: grid; place-items: center; border-radius: 999px; color: var(--muted); background: transparent; border: 1px solid transparent; }
.icon-button:hover { color: var(--text); background: var(--panel-3); }
.icon-button svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.text-button { padding: 5px 8px; color: var(--soft); background: transparent; font-size: 12px; font-weight: 600; border-radius: 8px; }
.text-button:hover { color: var(--brand-2); background: var(--mint); }

/* ---------- layout ---------- */
.studio-layout { flex: 1; min-height: 0; display: grid; grid-template-columns: 408px minmax(0, 1fr); grid-template-rows: minmax(0, 1fr); }
.editor-panel {
  min-width: 0; min-height: 0; padding: 28px 24px 32px;
  display: flex; flex-direction: column; gap: 16px;
  overflow-y: auto; overscroll-behavior: contain;
  scrollbar-width: thin; scrollbar-color: rgba(20, 22, 26, .2) transparent;
  border-right: 1px solid var(--line);
}
.editor-panel::-webkit-scrollbar { width: 8px; }
.editor-panel::-webkit-scrollbar-thumb { background: rgba(20, 22, 26, .14); border-radius: 99px; }
.editor-panel::-webkit-scrollbar-thumb:hover { background: rgba(20, 22, 26, .24); }

.panel-heading { padding: 0 4px 6px; }
.eyebrow { display: block; margin-bottom: 9px; color: var(--brand-2); font-size: 11px; font-weight: 700; letter-spacing: .14em; text-transform: uppercase; }
.panel-heading h1 { margin-bottom: 10px; font-family: var(--font-display); font-size: 32px; font-weight: 700; line-height: 1.08; letter-spacing: -.03em; }
.panel-heading p { margin: 0; color: var(--muted); font-size: 13.5px; line-height: 1.55; }

/* ---------- control cards ---------- */
.control-card {
  padding: 20px;
  border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--panel);
}
.card-head { display: flex; align-items: flex-start; gap: 12px; margin-bottom: 16px; }
.card-step {
  flex: none; width: 30px; height: 30px; display: grid; place-items: center;
  border-radius: 9px; background: var(--mint); color: var(--brand-2);
  font-size: 11px; font-weight: 800; letter-spacing: .04em;
}
.card-title { flex: 1; min-width: 0; }
.card-title h2 { margin: 0; font-family: var(--font-display); font-size: 16.5px; font-weight: 700; letter-spacing: -.01em; }
.card-title p { margin: 3px 0 0; color: var(--soft); font-size: 12px; }

/* upload */
.upload-zone {
  min-height: 92px; padding: 14px 16px;
  display: grid; grid-template-columns: 42px 1fr auto; align-items: center; gap: 13px;
  border: 1.5px dashed var(--line-strong); border-radius: 14px;
  background: var(--panel-2); cursor: pointer;
  transition: border-color .18s ease, background .18s ease, transform .18s ease;
}
.upload-zone:hover, .upload-zone.dragging { border-color: rgba(31, 174, 84, .55); background: rgba(231, 246, 236, .6); }
.upload-zone.dragging { transform: scale(.99); }
.upload-icon { width: 42px; height: 42px; display: grid; place-items: center; border-radius: 12px; color: var(--brand-2); background: var(--mint); }
.upload-icon svg { width: 19px; height: 19px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.upload-copy { min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.upload-copy strong { font-size: 13px; }
.upload-copy small { overflow: hidden; text-overflow: ellipsis; color: var(--soft); font-size: 11px; white-space: nowrap; }
.upload-thumbnail { width: 46px; height: 46px; border-radius: 11px; background: var(--panel-3) center / cover no-repeat; box-shadow: inset 0 0 0 1px var(--line); }
.upload-thumbnail:empty { display: none; }

/* presets */
.preset-grid { margin-top: 14px; display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.preset-card {
  position: relative; padding: 0; overflow: hidden; text-align: left;
  border: 1px solid var(--line); border-radius: 12px; background: var(--panel-2);
  cursor: pointer; transition: transform .18s ease, border-color .18s ease, box-shadow .18s ease;
}
.preset-card:hover { transform: translateY(-2px); border-color: rgba(20, 22, 26, .28); box-shadow: 0 8px 18px rgba(20, 22, 26, .08); }
.preset-thumb { display: block; aspect-ratio: 16 / 9.5; background: var(--thumb) center / cover no-repeat; }
.preset-name { display: block; padding: 7px 9px 8px; font-size: 10.5px; font-weight: 600; color: var(--muted); }
.preset-card.active { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(31, 174, 84, .16); }
.preset-card.active .preset-name { color: var(--brand-2); }
.preset-card.active::before {
  content: "✓"; position: absolute; right: 6px; top: 6px; z-index: 1;
  width: 18px; height: 18px; display: grid; place-items: center;
  border-radius: 99px; color: #ffffff; background: var(--brand);
  font-size: 10px; font-weight: 900; box-shadow: 0 2px 8px rgba(20, 22, 26, .25);
}

/* fields */
.field-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 11px; }
.field { display: flex; flex-direction: column; gap: 7px; }
.field-wide { grid-column: 1 / -1; }
.field > span, .color-field > span:first-child, .mode-label { color: var(--muted); font-size: 11px; font-weight: 600; }
.field input, .field select {
  width: 100%; height: 42px; padding: 0 13px;
  color: var(--text); background-color: var(--panel-2);
  border: 1px solid var(--line); border-radius: 11px; outline: none; font-size: 13px;
  transition: border-color .16s ease, box-shadow .16s ease, background .16s ease;
}
.field input:hover, .field select:hover { border-color: var(--line-strong); }
.field input:focus, .field select:focus { background-color: #ffffff; border-color: rgba(31, 174, 84, .55); box-shadow: 0 0 0 3px rgba(31, 174, 84, .1); }
.field select {
  appearance: none; cursor: pointer;
  background-image: linear-gradient(45deg, transparent 50%, #82878f 50%), linear-gradient(135deg, #82878f 50%, transparent 50%);
  background-position: calc(100% - 17px) 18px, calc(100% - 12px) 18px;
  background-size: 5px 5px, 5px 5px; background-repeat: no-repeat;
}

/* colors */
.color-row { margin-top: 13px; display: grid; grid-template-columns: repeat(3, 1fr); gap: 9px; }
.color-field { min-width: 0; display: flex; flex-direction: column; gap: 7px; }
.color-input-wrap {
  min-width: 0; height: 42px; padding: 0 10px;
  display: flex; align-items: center; gap: 8px;
  border: 1px solid var(--line); border-radius: 11px; background: var(--panel-2);
  transition: border-color .16s ease, box-shadow .16s ease;
}
.color-input-wrap:hover { border-color: var(--line-strong); }
.color-input-wrap:focus-within { background-color: #ffffff; border-color: rgba(31, 174, 84, .55); box-shadow: 0 0 0 3px rgba(31, 174, 84, .1); }
.color-input-wrap input { flex: none; width: 22px; height: 22px; padding: 0; overflow: hidden; border: 0; border-radius: 6px; background: none; cursor: pointer; }
.color-input-wrap input::-webkit-color-swatch-wrapper { padding: 0; }
.color-input-wrap input::-webkit-color-swatch { border: 0; border-radius: 6px; }
.color-input-wrap output { min-width: 0; overflow: hidden; text-overflow: ellipsis; color: var(--soft); font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 10px; }

/* segmented */
.mode-row { margin-top: 14px; display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.segmented-control {
  padding: 4px; display: grid; grid-template-columns: repeat(3, 1fr);
  border-radius: 999px; background: var(--panel-3);
}
.mode-row .segmented-control { width: 200px; }
.segmented-control button {
  height: 32px; padding: 0 12px; border: 0; border-radius: 999px;
  color: var(--muted); background: transparent; cursor: pointer;
  font-size: 12px; font-weight: 600;
  transition: color .16s ease, background .16s ease, box-shadow .16s ease;
}
.segmented-control button:hover { color: var(--text); }
.segmented-control button.active { color: var(--text); background: #ffffff; box-shadow: 0 2px 8px rgba(20, 22, 26, .1); }
.segmented-control.compact { width: 150px; margin: 0; grid-template-columns: repeat(2, 1fr); }

/* sliders */
.slider-list { display: grid; gap: 18px; }
.slider-field { display: grid; gap: 10px; }
.slider-field > span { display: flex; justify-content: space-between; align-items: baseline; gap: 15px; }
.slider-field b { color: var(--muted); font-size: 12px; font-weight: 600; }
.slider-field output { color: var(--soft); font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 11px; }
.slider-field input {
  width: 100%; height: 6px; margin: 0; appearance: none; border-radius: 99px;
  background: linear-gradient(90deg, var(--brand) var(--range-fill, 50%), #e3e6e1 var(--range-fill, 50%));
  outline: 0; cursor: pointer;
}
.slider-field input::-webkit-slider-thumb {
  width: 18px; height: 18px; appearance: none;
  border: 3px solid #ffffff; border-radius: 99px; background: var(--brand);
  box-shadow: 0 0 0 1px rgba(20, 22, 26, .12), 0 2px 10px rgba(31, 174, 84, .35);
  transition: transform .15s ease;
}
.slider-field input::-webkit-slider-thumb:hover { transform: scale(1.12); }
.position-field { margin-top: 18px; }

.editor-footer { padding: 2px 4px 0; }
.editor-footer p { margin: 11px 6px 0; color: var(--soft); font-size: 11px; line-height: 1.55; text-align: center; }
.studio-legal-links { margin-top: 10px; text-align: center; }
.studio-legal-links a { color: var(--muted); font-size: 11px; font-weight: 600; text-decoration: underline; text-underline-offset: 3px; }
.studio-legal-links a:hover { color: var(--brand-2); }
.editor-footer .studio-disclaimer { margin-top: 8px; color: var(--soft); font-size: 10.5px; }

/* ---------- preview panel ---------- */
.preview-panel {
  min-width: 0; min-height: 0; display: flex; flex-direction: column;
  background:
    linear-gradient(rgba(20, 22, 26, .045) 1px, transparent 1px),
    linear-gradient(90deg, rgba(20, 22, 26, .045) 1px, transparent 1px),
    #f3f3ee;
  background-size: 32px 32px;
}
.preview-toolbar {
  min-height: 62px; padding: 0 22px;
  display: flex; justify-content: space-between; align-items: center; gap: 14px;
  border-bottom: 1px solid var(--line);
  background: rgba(247, 247, 242, .85); backdrop-filter: blur(10px);
}
.preview-title { min-width: 0; display: flex; align-items: center; gap: 11px; }
.live-pill {
  flex: none; height: 27px; padding: 0 11px;
  display: inline-flex; align-items: center; gap: 7px;
  border-radius: 999px; color: var(--brand-2); background: var(--mint);
  border: 1px solid rgba(31, 174, 84, .22); font-size: 11.5px; font-weight: 700;
}
.live-pill i { width: 6px; height: 6px; border-radius: 99px; background: var(--brand); box-shadow: 0 0 8px rgba(31, 174, 84, .7); }
.preview-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); font-size: 13px; font-weight: 600; }
.preview-controls { display: flex; align-items: center; gap: 8px; }
.preview-controls .button { min-height: 38px; padding: 0 13px; }
.compare-toggle svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

.preview-stage {
  flex: 1; min-height: 0; padding: 28px 28px 18px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px;
}
.preview-fit { width: 100%; display: flex; align-items: flex-start; justify-content: center; container-type: inline-size;
  /* JS 就位前的初始高度估算（与 fitPreview 公式一致），避免首帧布局跳动 */
  height: calc(min(711px, 100vh - 215px) * min(1, 100cqw / 1280px)); }

/* ==========================================================================
   Workspace preview window — dark themed mock of the product being themed.
   Also embedded verbatim into the standalone export.
   ========================================================================== */
.workspace-window { --theme-bg: #081017; --theme-panel: rgba(8, 18, 25, .82); --theme-panel-alt: rgba(14, 28, 36, .72); --theme-accent: #8cff65; --theme-secondary: #54d7ff; --theme-highlight: #8c5cff; --theme-text: #effbf3; --theme-muted: #99aea4; --theme-line: rgba(140,255,101,.25); --theme-overlay-main: 56%; --theme-overlay-soft: 42%; --theme-blur: 18px; --theme-saturation: .92; --theme-radius: 24px; --theme-image: url('./assets/presets/skin-06.jpg'); --theme-position: right center;
  flex: none; width: 1280px; max-width: 1280px; height: min(711px, calc(100vh - 215px)); min-height: 460px;
  overflow: hidden; border: 1px solid rgba(20, 22, 26, .16); border-radius: 18px;
  background: #090c11;
  box-shadow: 0 36px 80px rgba(20, 22, 26, .22), 0 4px 18px rgba(20, 22, 26, .06);
  transform: scale(min(1, calc(100cqw / 1280px))); /* 首帧即按容器宽度缩放，JS 加载后再精确修正，消除放大闪动 */
  transform-origin: top center; will-change: transform; }
.window-bar { height: 40px; padding: 0 15px; display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; color: #7d8492; background: #11151c; border-bottom: 1px solid rgba(255,255,255,.06); font-size: 11px; }
.traffic-lights { display: flex; gap: 6px; }
.traffic-lights i { width: 10px; height: 10px; border-radius: 99px; background: #383d48; }
.window-actions { justify-self: end; display: flex; gap: 10px; }
.window-actions span { width: 12px; height: 1px; background: #454b58; }
.workspace-body { height: calc(100% - 40px); display: grid; grid-template-columns: 210px minmax(0,1fr); color: var(--theme-text); background: var(--theme-bg); }
.workspace-sidebar { min-width: 0; padding: 15px 12px 12px; display: flex; flex-direction: column; background: color-mix(in srgb, var(--theme-panel) 90%, transparent); border-right: 1px solid color-mix(in srgb, var(--theme-line) 50%, transparent); backdrop-filter: blur(var(--theme-blur)); }
.workspace-logo { height: 40px; display: grid; grid-template-columns: 29px 1fr auto; align-items: center; gap: 8px; padding: 0 6px 11px; }
.workspace-logo > span { width: 27px; height: 27px; display: grid; place-items: center; border: 1px solid color-mix(in srgb, var(--theme-accent) 58%, transparent); border-radius: 9px; color: var(--theme-accent); font-size: 8px; font-weight: 900; box-shadow: inset 0 0 14px color-mix(in srgb, var(--theme-accent) 9%, transparent); }
.workspace-logo strong { font-size: 12px; }
.workspace-logo button { border: 0; color: var(--theme-muted); background: transparent; }
.workspace-sidebar nav { display: grid; gap: 3px; }
.workspace-sidebar nav button { height: 33px; padding: 0 9px; display: flex; align-items: center; gap: 8px; border: 0; border-radius: 8px; color: var(--theme-muted); background: transparent; font-size: 10px; text-align: left; }
.workspace-sidebar nav button:hover, .workspace-sidebar nav button.active { color: var(--theme-text); background: color-mix(in srgb, var(--theme-accent) 10%, transparent); }
.workspace-sidebar nav button.active { box-shadow: inset 2px 0 var(--theme-accent); }
.workspace-sidebar nav kbd { margin-left: auto; color: color-mix(in srgb, var(--theme-muted) 65%, transparent); font-size: 7px; }
.nav-icon { width: 13px; color: var(--theme-accent); text-align: center; }
.sidebar-label { margin: 18px 8px 7px; color: color-mix(in srgb, var(--theme-muted) 60%, transparent); font-size: 8px; font-weight: 900; letter-spacing: .12em; text-transform: uppercase; }
.project-list { display: grid; gap: 3px; }
.project-list button { min-width: 0; height: 43px; padding: 0 8px; display: grid; grid-template-columns: 7px minmax(0,1fr); align-items: center; gap: 8px; border: 0; border-radius: 8px; color: var(--theme-text); background: transparent; text-align: left; }
.project-list button:hover { background: color-mix(in srgb, var(--theme-secondary) 7%, transparent); }
.project-list i { width: 5px; height: 5px; border-radius: 99px; background: var(--theme-secondary); box-shadow: 0 0 8px color-mix(in srgb, var(--theme-secondary) 70%, transparent); }
.project-list span { min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.project-list strong, .project-list small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.project-list strong { font-size: 9px; font-weight: 650; }
.project-list small { color: color-mix(in srgb, var(--theme-muted) 68%, transparent); font-size: 7px; }
.sidebar-user { margin-top: auto; height: 44px; padding: 0 6px; display: grid; grid-template-columns: 26px 1fr auto; align-items: center; gap: 7px; border-top: 1px solid color-mix(in srgb, var(--theme-line) 35%, transparent); }
.sidebar-user > span { width: 24px; height: 24px; display: grid; place-items: center; border-radius: 8px; color: #111; background: var(--theme-accent); font-size: 7px; font-weight: 900; }
.sidebar-user div { min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.sidebar-user strong { font-size: 8px; }
.sidebar-user small { color: var(--theme-muted); font-size: 6px; }
.sidebar-user button { border: 0; color: var(--theme-muted); background: transparent; }
.workspace-main { position: relative; min-width: 0; overflow: hidden; background:
  linear-gradient(90deg, color-mix(in srgb, var(--theme-bg) var(--theme-overlay-main), transparent), color-mix(in srgb, var(--theme-bg) var(--theme-overlay-soft), transparent)),
  radial-gradient(circle at 78% 18%, color-mix(in srgb, var(--theme-highlight) 18%, transparent), transparent 34%),
  var(--theme-image) var(--theme-position) / cover no-repeat; }
.workspace-main::after { content: ""; position: absolute; inset: 0; pointer-events: none; background: radial-gradient(circle at 30% 10%, color-mix(in srgb, var(--theme-secondary) 9%, transparent), transparent 26%); mix-blend-mode: screen; }
.workspace-main > * { position: relative; z-index: 1; }
.workspace-home[hidden], .workspace-task[hidden] { display: none !important; }
.workspace-home { height: 100%; padding: 26px 40px 24px; display: flex; flex-direction: column; gap: 13px; }
.home-welcome { flex: 1; min-height: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 9px; text-align: center; }
.home-welcome h2 { margin: 0; color: var(--theme-text); font-size: clamp(24px, 3.2vw, 38px); font-weight: 500; letter-spacing: -.02em; }
.home-welcome p { margin: 0; color: var(--theme-muted); font-size: 10.5px; }
.home-cards { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; }
.home-card { min-width: 0; min-height: 86px; padding: 13px 14px; display: flex; flex-direction: column; align-items: flex-start; gap: 12px; border: 1px solid color-mix(in srgb, var(--theme-line) 40%, transparent); border-radius: calc(var(--theme-radius) * .6); color: var(--theme-text); background: color-mix(in srgb, var(--theme-panel-alt) 78%, transparent); backdrop-filter: blur(var(--theme-blur)); }
.home-card-icon { width: 20px; height: 20px; color: var(--hci, var(--theme-accent)); }
.home-card-icon svg { width: 100%; height: 100%; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.home-card strong { font-size: 10.5px; font-weight: 500; line-height: 1.45; text-align: left; }
.home-project { display: flex; align-items: center; gap: 9px; padding: 12px 15px; border: 1px solid color-mix(in srgb, var(--theme-line) 45%, transparent); border-radius: calc(var(--theme-radius) * .55); color: var(--theme-text); background: color-mix(in srgb, var(--theme-panel) 80%, transparent); backdrop-filter: blur(var(--theme-blur)); font-size: 10.5px; font-weight: 500; text-align: left; cursor: pointer; }
.home-project svg { width: 15px; height: 15px; fill: none; stroke: var(--theme-muted); stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.home-composer { padding: 15px 16px 11px; }
.home-composer .composer-placeholder { font-size: 12px; }
.home-composer .composer-plus { font-size: 13px; }
.composer-actions-right { display: flex; align-items: center; gap: 7px; }
.composer-mic { display: inline-flex; width: 15px; height: 15px; }
.composer-mic svg { width: 100%; height: 100%; fill: none; stroke: var(--theme-muted); stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.home-send { width: 28px; height: 28px; display: inline-grid; place-items: center; border-radius: 50%; color: #0b1308; background: var(--theme-accent); font-size: 13px; font-weight: 900; }
.composer { padding: 11px 12px 9px; border: 1px solid color-mix(in srgb, var(--theme-line) 55%, transparent); border-radius: calc(var(--theme-radius) * .65); background: color-mix(in srgb, var(--theme-panel) 84%, transparent); box-shadow: 0 14px 35px rgba(0,0,0,.18); backdrop-filter: blur(var(--theme-blur)); }
.composer textarea { width: 100%; min-height: 36px; max-height: 80px; resize: none; border: 0; outline: 0; color: var(--theme-text); background: transparent; font-size: 10px; line-height: 1.45; }
.composer textarea::placeholder { color: color-mix(in srgb, var(--theme-muted) 68%, transparent); }
.composer-actions { display: flex; justify-content: space-between; align-items: center; }
.composer-actions > div { display: flex; gap: 4px; }
.composer-actions button { height: 24px; padding: 0 8px; border: 0; border-radius: 7px; color: var(--theme-muted); background: transparent; font-size: 8px; }
.composer-actions button:hover { color: var(--theme-text); background: color-mix(in srgb, var(--theme-accent) 8%, transparent); }
.composer-actions .send-button { width: 25px; padding: 0; border-radius: 8px; color: #0b1308; background: var(--theme-accent); font-size: 12px; font-weight: 900; }
.workspace-task { height: 100%; display: grid; grid-template-rows: 59px minmax(0,1fr) auto; }
.task-header { padding: 0 26px; display: flex; justify-content: space-between; align-items: center; border-bottom: 1px solid color-mix(in srgb, var(--theme-line) 35%, transparent); background: color-mix(in srgb, var(--theme-panel) 72%, transparent); backdrop-filter: blur(var(--theme-blur)); }
.task-header h2 { margin: 3px 0 0; font-size: 12px; }
.task-status { display: flex; align-items: center; gap: 5px; color: var(--theme-muted); font-size: 7px; text-transform: uppercase; letter-spacing: .1em; }
.task-status i { width: 4px; height: 4px; border-radius: 99px; background: var(--theme-accent); box-shadow: 0 0 7px var(--theme-accent); }
.task-header > button { height: 26px; padding: 0 11px; border: 1px solid color-mix(in srgb, var(--theme-line) 55%, transparent); border-radius: 8px; color: var(--theme-text); background: color-mix(in srgb, var(--theme-panel-alt) 70%, transparent); font-size: 8px; }
.task-scroll { min-height: 0; padding: 26px min(7vw, 72px); overflow: auto; scrollbar-color: color-mix(in srgb, var(--theme-accent) 35%, transparent) transparent; }
.message { max-width: 690px; margin: 0 auto 25px; display: grid; grid-template-columns: 60px minmax(0,1fr); gap: 18px; }
.message > span { padding-top: 3px; color: var(--theme-muted); font-size: 7px; font-weight: 900; letter-spacing: .12em; }
.message p { margin: 0 0 11px; color: color-mix(in srgb, var(--theme-text) 90%, transparent); font-size: 10px; line-height: 1.7; }
.user-message p { padding: 13px 15px; border: 1px solid color-mix(in srgb, var(--theme-line) 35%, transparent); border-radius: 12px; background: color-mix(in srgb, var(--theme-panel-alt) 60%, transparent); backdrop-filter: blur(var(--theme-blur)); }
.code-card { margin: 12px 0; overflow: hidden; border: 1px solid color-mix(in srgb, var(--theme-line) 38%, transparent); border-radius: 10px; background: color-mix(in srgb, var(--theme-bg) 87%, transparent); }
.code-card header { height: 30px; padding: 0 12px; display: flex; justify-content: space-between; align-items: center; border-bottom: 1px solid color-mix(in srgb, var(--theme-line) 28%, transparent); color: var(--theme-muted); font-size: 8px; }
.code-card button { border: 0; color: var(--theme-muted); background: transparent; font-size: 8px; }
.code-card pre { margin: 0; padding: 13px; overflow: auto; color: color-mix(in srgb, var(--theme-secondary) 80%, white); font-size: 8px; line-height: 1.55; }
.message-note { color: var(--theme-muted) !important; font-size: 8px !important; }
.task-composer { margin: 0 min(7vw, 72px) 22px; }

.workspace-window.default-preview { --theme-bg:#f3f4f6; --theme-panel:#eaebee; --theme-panel-alt:#ffffff; --theme-accent:#111318; --theme-secondary:#626a78; --theme-highlight:#d7d9de; --theme-text:#191b20; --theme-muted:#777d87; --theme-line:rgba(0,0,0,.12); --theme-overlay-main:92%;--theme-overlay-soft:78%; --theme-blur:0px; --theme-saturation:0; --theme-radius:14px; --theme-image:linear-gradient(#f6f7f8,#f6f7f8); }
.workspace-window.default-preview .workspace-main::after { opacity: 0; }

/* ---------- modals ---------- */
.modal { width: min(650px, calc(100vw - 30px)); padding: 0; border: 1px solid var(--line); border-radius: 22px; color: var(--text); background: #ffffff; box-shadow: var(--shadow); overflow: hidden; }
.modal::backdrop, .fullscreen-dialog::backdrop { background: rgba(20, 22, 26, .45); backdrop-filter: blur(8px); }
.modal-card { padding: 26px; }
.modal-header { display: flex; justify-content: space-between; align-items: flex-start; gap: 20px; }
.modal-header h2 { margin-bottom: 7px; font-family: var(--font-display); font-size: 25px; font-weight: 700; letter-spacing: -.02em; }
.modal-header p { color: var(--muted); font-size: 12.5px; }
.modal-close { flex: none; font-size: 20px; }
.export-grid { margin-top: 22px; display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.export-option { position: relative; min-height: 112px; padding: 16px; display: grid; grid-template-columns: 38px 1fr; align-items: start; gap: 12px; border: 1px solid var(--line); border-radius: 14px; color: var(--text); background: var(--panel-2); text-align: left; cursor: pointer; transition: transform .18s ease, border-color .18s ease, background .18s ease; }
.export-option:hover { border-color: rgba(31, 174, 84, .45); background: #ffffff; transform: translateY(-2px); }
.export-icon { width: 36px; height: 36px; display: grid; place-items: center; border-radius: 11px; color: var(--brand-2); background: var(--mint); font-family: ui-monospace, monospace; font-size: 13px; font-weight: 900; }
.export-option > span:nth-child(2) { display: flex; flex-direction: column; gap: 5px; }
.export-option strong { font-size: 13px; }
.export-option small { color: var(--muted); font-size: 10.5px; line-height: 1.45; }
.export-option > i { position: absolute; right: 10px; top: 10px; padding: 3px 7px; border-radius: 99px; color: var(--brand-2); background: var(--mint); font-size: 8px; font-weight: 700; font-style: normal; }
.export-primary { grid-column: 1 / -1; min-height: 96px; color: #f5f7f2; background: var(--night); border-color: transparent; }
.export-primary:hover { background: #1d2219; border-color: transparent; }
.export-primary .export-icon { color: #8cff65; background: rgba(140, 255, 101, .14); }
.export-primary strong { color: #f5f7f2; }
.export-primary small { color: rgba(245, 247, 242, .58); }
.export-primary > i { color: #0b1308; background: #8cff65; }
.more-formats { margin-top: 10px; border: 1px solid var(--line); border-radius: 14px; background: var(--panel-2); }
.more-formats summary { padding: 13px 16px; display: flex; justify-content: space-between; align-items: center; list-style: none; cursor: pointer; font-size: 13px; font-weight: 600; border-radius: 14px; transition: background .16s ease; }
.more-formats summary::-webkit-details-marker { display: none; }
.more-formats summary:hover { background: var(--panel-3); }
.more-formats summary small { color: var(--soft); font-size: 11px; font-weight: 500; }
.more-formats[open] summary { border-bottom: 1px solid var(--line); border-radius: 14px 14px 0 0; }
.export-grid-compact { margin-top: 0; padding: 10px; grid-template-columns: 1fr; gap: 8px; }
.export-grid-compact .export-option { min-height: 0; padding: 11px 13px; }
.export-note { margin-top: 14px; padding: 13px; display: flex; gap: 10px; border-radius: 11px; color: var(--muted); background: var(--panel-3); font-size: 10.5px; }
.export-note p { margin: 0; line-height: 1.5; }
.library-list { max-height: 430px; margin-top: 20px; overflow: auto; display: grid; gap: 8px; }
.library-empty { padding: 45px 20px; border: 1.5px dashed var(--line-strong); border-radius: 14px; color: var(--muted); text-align: center; font-size: 12px; }
.library-item { min-height: 74px; padding: 11px; display: grid; grid-template-columns: 74px 1fr auto; align-items: center; gap: 12px; border: 1px solid var(--line); border-radius: 13px; background: var(--panel-2); }
.library-thumb { width: 74px; height: 52px; border-radius: 9px; background: var(--panel-3) center / cover no-repeat; }
.library-copy { min-width: 0; }
.library-copy strong, .library-copy small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.library-copy strong { margin-bottom: 5px; font-size: 13px; }
.library-copy small { color: var(--muted); font-size: 10px; }
.library-actions { display: flex; gap: 6px; }
.library-actions button { height: 30px; padding: 0 11px; border: 1px solid var(--line); border-radius: 999px; color: var(--muted); background: #ffffff; cursor: pointer; font-size: 10.5px; font-weight: 600; transition: color .16s ease, border-color .16s ease; }
.library-actions button:hover { color: var(--text); border-color: var(--line-strong); }
.library-actions button.delete:hover { color: var(--danger); border-color: rgba(216, 74, 82, .4); }

/* ---------- fullscreen preview ---------- */
.fullscreen-dialog { width: 100vw; max-width: none; height: 100vh; max-height: none; margin: 0; padding: 38px; border: 0; color: var(--text); background: #0c0e12; }
.fullscreen-dialog[open] { display: grid; place-items: center; }
.fullscreen-close { position: fixed; right: 18px; top: 16px; z-index: 4; width: 38px; height: 38px; border: 1px solid rgba(255,255,255,.16); border-radius: 999px; color: #f5f7f2; background: #1a1f28; cursor: pointer; font-size: 20px; }
#fullscreenMount { width: min(1500px, 100%); }
#fullscreenMount .workspace-window { width: 100%; max-width: none; height: min(880px, calc(100vh - 76px)); transform: none !important; }

/* ---------- toast ---------- */
.toast { position: fixed; left: var(--toast-center-x, 50%); top: 96px; bottom: auto; z-index: 100; min-width: 220px; max-width: calc(100vw - 32px); padding: 12px 18px; opacity: 0; pointer-events: none; transform: translate(-50%, -10px); border-radius: 999px; color: #f5f7f2; background: var(--night); box-shadow: 0 12px 35px rgba(20, 22, 26, .3); font-size: 12px; font-weight: 600; text-align: center; transition: opacity .2s ease, transform .2s ease, left .18s ease; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
@media (max-width: 720px) { .toast { top: 74px; } }
.toast.error { background: #3a1d1f; color: #ffb7bc; }
.toast.has-action { pointer-events: auto; display: inline-flex; align-items: center; gap: 12px; }
.toast-action { flex: none; padding: 5px 13px; border: 0; border-radius: 999px; color: #0b1308; background: #8cff65; cursor: pointer; font-size: 11.5px; font-weight: 700; transition: background .15s ease, transform .15s ease; }
.toast-action:hover { background: #a5ff85; transform: translateY(-1px); }

/* ---------- responsive ---------- */
@media (max-width: 1240px) {
  .studio-layout { grid-template-columns: 360px minmax(0,1fr); }
  .editor-panel { padding-inline: 18px; }
  .preview-stage { padding-inline: 18px; }
}

@media (max-width: 980px) {
  .app-shell { height: auto; overflow: visible; }
  .studio-layout { display: block; }
  .editor-panel { overflow: visible; border-right: 0; border-bottom: 1px solid var(--line); }
  .preview-panel { min-height: 0; }
  .preview-stage { justify-content: flex-start; }
}

@media (max-width: 640px) {
  .topbar { height: 58px; padding: 0 14px; }
  .brand-word small, .desktop-only { display: none; }
  .save-state { display: none; }
  .topbar-actions { gap: 4px; }
  .editor-panel { padding: 22px 14px 26px; }
  .panel-heading h1 { font-size: 27px; }
  .preset-grid { grid-template-columns: repeat(3, 1fr); }
  .preview-toolbar { padding: 10px 12px; flex-wrap: wrap; }
  .preview-stage { padding: 18px 10px 14px; }
  .export-grid { grid-template-columns: 1fr; }
  .modal-card { padding: 20px; }
  .library-item { grid-template-columns: 58px minmax(0,1fr); }
  .library-thumb { width: 58px; height: 45px; }
  .library-actions { grid-column: 1 / -1; justify-content: flex-end; }
  .fullscreen-dialog { padding: 52px 12px 12px; overflow: hidden; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; }
}

/* ---------- Codex install flow ---------- */
.color-field > span:first-child { display: flex; flex-direction: column; gap: 2px; }
.color-field > span:first-child small { color: var(--soft); font-size: 8.5px; font-weight: 500; line-height: 1.25; }
.color-row-secondary { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.install-modal { position: relative; width: min(760px, calc(100vw - 30px)); }
.install-card { max-height: min(860px, calc(100vh - 30px)); overflow: auto; }
.install-modal .modal-header { padding-right: 54px; }
.install-close-form { position: absolute; top: 18px; right: 18px; z-index: 8; margin: 0; }
.install-modal .modal-close { color: var(--text); background: var(--panel-3); border-color: transparent; box-shadow: 0 2px 10px rgba(20, 22, 26, .08); }
.install-modal .modal-close:hover { background: #fff; box-shadow: 0 4px 14px rgba(20, 22, 26, .12); }
.install-platforms { margin-top: 20px; padding: 4px; display: grid; grid-template-columns: 1fr 1fr; gap: 4px; border-radius: 14px; background: var(--panel-3); }
.install-platforms button { min-height: 62px; padding: 10px 14px; display: flex; flex-direction: column; align-items: flex-start; justify-content: center; gap: 3px; border: 0; border-radius: 11px; color: var(--muted); background: transparent; cursor: pointer; text-align: left; transition: background .16s ease, color .16s ease, box-shadow .16s ease; }
.install-platforms button strong { font-size: 13px; }
.install-platforms button small { color: var(--soft); font-size: 10px; }
.install-platforms button.active { color: var(--text); background: #fff; box-shadow: 0 2px 9px rgba(20,22,26,.09); }
.install-panel { margin-top: 16px; padding: 18px; border: 1px solid var(--line); border-radius: 16px; background: var(--panel-2); }
.install-summary { display: grid; grid-template-columns: 30px minmax(0,1fr); gap: 12px; align-items: start; }
.install-summary-spaced { margin-top: 18px; padding-top: 18px; border-top: 1px solid var(--line); }
.install-step { width: 28px; height: 28px; display: grid; place-items: center; border-radius: 9px; color: var(--brand-2); background: var(--mint); font-size: 11px; font-weight: 800; }
.install-summary strong { display: block; margin: 2px 0 5px; font-size: 13px; }
.install-summary p { margin: 0; color: var(--muted); font-size: 11px; line-height: 1.55; }
.theme-value-grid { margin-top: 14px; display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.theme-value { min-width: 0; min-height: 66px; padding: 10px; display: flex; flex-direction: column; justify-content: center; gap: 5px; border: 1px solid var(--line); border-radius: 11px; color: var(--text); background: #fff; text-align: left; }
button.theme-value { cursor: pointer; transition: border-color .16s ease, transform .16s ease; }
button.theme-value:hover { border-color: rgba(31,174,84,.45); transform: translateY(-1px); }
.theme-value span { color: var(--soft); font-size: 9px; }
.theme-value strong { overflow: hidden; text-overflow: ellipsis; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 11px; white-space: nowrap; }
.install-primary { margin-top: 12px; }
.install-steps { margin: 7px 0 0; padding-left: 18px; color: var(--muted); font-size: 11px; line-height: 1.65; }
.install-steps b, .install-steps code { color: var(--text); }
.install-limit { margin: 16px 0 0; padding: 11px 12px; border-radius: 10px; color: var(--muted); background: #fff; font-size: 10.5px; line-height: 1.5; }
.install-limit b { color: var(--text); }
.install-command-box { margin-top: 12px; overflow: hidden; border: 1px solid var(--line); border-radius: 12px; background: #10151b; }
.install-command-head { min-height: 38px; padding: 0 12px; display: flex; align-items: center; justify-content: space-between; gap: 10px; border-bottom: 1px solid rgba(255,255,255,.1); color: rgba(255,255,255,.72); }
.install-command-head strong { font-size: 10.5px; }
.install-command-head button { height: 25px; padding: 0 10px; border: 1px solid rgba(255,255,255,.15); border-radius: 999px; color: #fff; background: rgba(255,255,255,.06); cursor: pointer; font-size: 9px; }
.install-command-box pre { max-height: 155px; margin: 0; padding: 13px; overflow: auto; color: #d9f8df; font-size: 10px; line-height: 1.55; white-space: pre-wrap; word-break: break-word; }
.windows-command { margin-top: 10px; }
.windows-command > summary { cursor: pointer; color: var(--muted); font-size: 11px; font-weight: 600; }
.windows-command[open] > summary { margin-bottom: 4px; }

@media (max-width: 640px) {
  .install-close-form { top: 12px; right: 12px; }
  .install-modal .modal-header { padding-right: 48px; }
  .install-celebration { padding-right: 54px; }
  .color-row, .color-row-secondary { grid-template-columns: 1fr; }
  .theme-value-grid { grid-template-columns: 1fr 1fr; }
  .install-platforms button { min-height: 58px; padding: 9px 10px; }
  .install-panel { padding: 14px; }
}


/* ---------- Simplified editor modes ---------- */
.editor-mode-switch { margin-top: 18px; padding: 4px; display: grid; grid-template-columns: 1fr 1fr; gap: 4px; border-radius: 14px; background: var(--panel-3); }
.editor-mode-switch button { min-height: 54px; padding: 9px 12px; display: flex; flex-direction: column; align-items: flex-start; justify-content: center; gap: 2px; border: 0; border-radius: 11px; color: var(--muted); background: transparent; cursor: pointer; text-align: left; }
.editor-mode-switch button strong { font-size: 12px; }
.editor-mode-switch button small { color: var(--soft); font-size: 9px; }
.editor-mode-switch button.active { color: var(--text); background: #fff; box-shadow: 0 2px 9px rgba(20,22,26,.09); }
.editor-panel[data-editor-mode="quick"] .advanced-only { display: none !important; }
.artwork-settings, .advanced-palette { margin-top: 18px; padding-top: 18px; border-top: 1px solid var(--line); }
.subsection-head { margin-bottom: 12px; display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.subsection-head > div { display: flex; flex-direction: column; gap: 3px; }
.subsection-head strong { font-size: 12px; }
.subsection-head small { color: var(--soft); font-size: 10px; }
.view-all-presets { display: none; width: 100%; min-height: 38px; margin-top: 10px; border: 1px solid var(--line); border-radius: 10px; color: var(--muted); background: var(--panel-2); cursor: pointer; font-size: 11px; font-weight: 650; }
.quick-color-row { margin-top: 13px; display: grid; grid-template-columns: minmax(0, .85fr) minmax(0, 1.15fr); gap: 12px; align-items: end; }
.brightness-field { min-width: 0; padding-bottom: 3px; }
.color-row-backgrounds { grid-template-columns: repeat(2, minmax(0, 1fr)); }

/* ---------- Theme health ---------- */
.readability-card { background: linear-gradient(145deg, #fff, #f8faf7); }
.readability-head { align-items: center; }
.health-score { flex: none; width: 48px; height: 48px; display: grid; place-items: center; border-radius: 14px; color: #176b37; background: #dff7e7; font-family: var(--font-display); font-size: 18px; font-weight: 800; }
.health-score[data-level="warning"] { color: #8a5a00; background: #fff2cb; }
.health-score[data-level="poor"] { color: #9b2c31; background: #ffe0e1; }
.readability-list { margin: 0 0 14px; padding: 0; display: grid; gap: 8px; list-style: none; }
.readability-list li { min-height: 44px; padding: 8px 10px; display: grid; grid-template-columns: 24px minmax(0,1fr); gap: 9px; align-items: center; border: 1px solid var(--line); border-radius: 10px; background: rgba(255,255,255,.72); }
.readability-icon { width: 22px; height: 22px; display: grid; place-items: center; border-radius: 7px; font-size: 10px; font-weight: 900; }
.readability-list li.pass .readability-icon { color: #176b37; background: #dff7e7; }
.readability-list li.warning .readability-icon { color: #9b2c31; background: #ffe0e1; }
.readability-list li > span:last-child { min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.readability-list strong { font-size: 11px; }
.readability-list small { overflow: hidden; text-overflow: ellipsis; color: var(--soft); font-size: 9px; white-space: nowrap; }
#autoFixReadabilityButton:disabled { display: none; }
.readability-list.is-empty { display: none; }
.readability-list.is-empty + #autoFixReadabilityButton { margin-top: 0; }

/* ---------- Static preview composer ---------- */
.composer-static { min-height: 72px; display: flex; flex-direction: column; justify-content: space-between; }
.composer-placeholder { color: color-mix(in srgb, var(--theme-muted) 68%, transparent); font-size: 10px; line-height: 1.45; }
.composer-static .composer-actions > div { display: flex; gap: 5px; }
.composer-static .composer-actions > div span { height: 24px; padding: 0 8px; display: inline-flex; align-items: center; border-radius: 7px; color: var(--theme-muted); font-size: 8px; }
.preview-only-badge { height: 24px; padding: 0 9px; display: inline-flex; align-items: center; border-radius: 999px; color: var(--theme-muted); background: color-mix(in srgb, var(--theme-accent) 8%, transparent); font-size: 7.5px; font-weight: 700; }

/* ---------- Mobile studio navigation ---------- */
.mobile-view-switch, .mobile-bottom-actions, .card-collapse-button { display: none; }

@media (max-width: 980px) {
  .app-shell { padding-bottom: 72px; }
  .topbar { position: sticky; top: 0; z-index: 35; }
  .mobile-view-switch { position: sticky; top: 58px; z-index: 30; padding: 6px; display: grid; grid-template-columns: 1fr 1fr; gap: 4px; border-bottom: 1px solid var(--line); background: rgba(247,247,242,.94); backdrop-filter: blur(12px); }
  .mobile-view-switch button { height: 38px; border: 0; border-radius: 10px; color: var(--muted); background: transparent; font-size: 12px; font-weight: 700; }
  .mobile-view-switch button.active { color: var(--text); background: #fff; box-shadow: 0 2px 8px rgba(20,22,26,.09); }
  .studio-layout .preview-panel { display: none; }
  .studio-layout.mobile-view-preview .editor-panel { display: none; }
  .studio-layout.mobile-view-preview .preview-panel { display: flex; min-height: calc(100vh - 116px); }
  .mobile-bottom-actions { position: fixed; left: 0; right: 0; bottom: 0; z-index: 45; height: 68px; padding: 10px 14px calc(10px + env(safe-area-inset-bottom)); display: grid; grid-template-columns: .85fr 1.15fr; gap: 9px; border-top: 1px solid var(--line); background: rgba(247,247,242,.94); backdrop-filter: blur(14px); }
  .mobile-bottom-actions .button { width: 100%; min-height: 44px; }
  #exportButton, #openLibraryButton, #resetButton { display: none; }
}

@media (max-width: 640px) {
  .editor-mode-switch button { padding: 8px 9px; }
  .editor-mode-switch button small { display: none; }
  .quick-color-row { grid-template-columns: 1fr; }
  .preset-grid:not(.expanded) .preset-card:nth-child(n+7) { display: none; }
  .view-all-presets { display: block; }
  .mobile-collapsible .card-collapse-button { flex: none; width: 30px; height: 30px; display: grid; place-items: center; border: 1px solid var(--line); border-radius: 9px; color: var(--muted); background: var(--panel-2); cursor: pointer; transition: transform .16s ease; }
  .mobile-collapsible:not(.collapsed-mobile) .card-collapse-button { transform: rotate(180deg); }
  .mobile-collapsible.collapsed-mobile > :not(.card-head) { display: none; }
  .readability-list li { grid-template-columns: 22px minmax(0,1fr); }
  .readability-list small { white-space: normal; }
  .preview-toolbar { position: sticky; top: 104px; z-index: 2; }
  .preview-stage { min-height: calc(100vh - 190px); }
}

/* ---- Undo / Redo history buttons ---- */
.history-buttons { display: flex; align-items: center; gap: 2px; padding: 2px; border: 1px solid var(--line, rgba(20, 22, 26, .1)); border-radius: 999px; }
.history-button { width: 32px; height: 32px; }
.history-button:disabled { opacity: .35; cursor: default; }
.history-button:disabled:hover { color: var(--muted); background: transparent; }
@media (max-width: 720px) { .history-buttons { display: none; } }

/* ---- Brightness slider with moon/sun cues ---- */
.brightness-slider-row { display: flex; align-items: center; gap: 10px; }
.brightness-slider-row input[type="range"] { flex: 1; }
.brightness-icon { font-style: normal; font-size: 15px; line-height: 1; filter: grayscale(.15); }

/* ---- Onboarding tour ---- */
.tour-overlay { position: fixed; inset: 0; z-index: 400; pointer-events: auto; }
.tour-spotlight {
  position: fixed; border-radius: 14px; pointer-events: none;
  box-shadow: 0 0 0 9999px rgba(14, 17, 21, .55), 0 0 0 3px var(--brand, #8cff65), 0 0 28px rgba(140, 255, 101, .45);
  transition: top .35s ease, left .35s ease, width .35s ease, height .35s ease;
}
.tour-overlay .tour-spotlight, .tour-overlay .tour-bubble { opacity: 0; transition: opacity .25s ease, top .35s ease, left .35s ease, width .35s ease, height .35s ease; }
.tour-overlay.placed .tour-spotlight, .tour-overlay.placed .tour-bubble { opacity: 1; }
.tour-bubble {
  position: fixed; width: 300px; padding: 16px 18px 14px; border-radius: 16px;
  background: #ffffff; color: #16181d; box-shadow: 0 18px 50px rgba(10, 14, 20, .35);
  transition: top .35s ease, left .35s ease; animation: tour-pop .3s ease;
}
@keyframes tour-pop { from { opacity: 0; transform: translateY(8px) scale(.96); } }
.tour-progress { display: inline-block; margin-bottom: 6px; padding: 2px 9px; border-radius: 999px; background: var(--brand, #8cff65); color: #0b1308; font-size: 10.5px; font-weight: 800; letter-spacing: .04em; }
.tour-title { display: block; font-size: 14.5px; font-weight: 800; }
.tour-text { margin: 6px 0 12px; font-size: 12.5px; line-height: 1.6; color: #4c5561; }
.tour-actions { display: flex; align-items: center; gap: 8px; }
.tour-spacer { flex: 1; }
.tour-actions button { padding: 6px 13px; border-radius: 999px; border: 0; font-size: 12px; font-weight: 700; cursor: pointer; transition: background .15s ease, transform .15s ease; }
.tour-actions button:active { transform: translateY(1px); }
.tour-skip { background: transparent; color: #8a93a0; }
.tour-skip:hover { color: #16181d; }
.tour-prev { background: #eef1f4; color: #16181d; }
.tour-prev:disabled { opacity: .4; cursor: default; }
.tour-next { background: #16181d; color: #fff; }
.tour-next:hover { background: #2a2f38; }
@media (max-width: 720px) {
  .tour-bubble { left: 12px !important; right: 12px; width: auto; }
}

/* ---- Install celebration ---- */
.install-card { position: relative; overflow: hidden auto; }

/* Slim, quiet scrollbar for the install dialog */
.install-card { scrollbar-width: thin; scrollbar-color: rgba(20, 22, 26, .22) transparent; }
.install-card::-webkit-scrollbar { width: 8px; }
.install-card::-webkit-scrollbar-track { background: transparent; }
.install-card::-webkit-scrollbar-thumb { background: rgba(20, 22, 26, .16); border-radius: 99px; border: 2px solid #ffffff; }
.install-card::-webkit-scrollbar-thumb:hover { background: rgba(20, 22, 26, .32); }

/* Breathing room between the two copy actions */

/* ---- Advanced mode switch feedback ---- */
/* Newly revealed advanced controls animate in, and the switch itself pulses
   so the tab change is impossible to miss. */
.editor-panel.mode-reveal .advanced-only { animation: advanced-in .45s cubic-bezier(.22, .61, .36, 1) both; }
.editor-panel.mode-reveal .control-card .advanced-only { animation-delay: .08s; }
@keyframes advanced-in { from { opacity: 0; transform: translateY(16px); } }
.editor-panel.mode-reveal .editor-mode-switch { animation: switch-pulse .9s ease; }
@keyframes switch-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(140, 255, 101, 0); }
  35% { box-shadow: 0 0 0 5px rgba(140, 255, 101, .55); }
}
.install-celebration {
  display: flex; align-items: center; gap: 12px; margin-bottom: 16px; padding: 12px 64px 12px 16px;
  border-radius: 14px; background: linear-gradient(120deg, rgba(140, 255, 101, .18), rgba(84, 215, 255, .16));
  border: 1px solid rgba(140, 255, 101, .35); animation: celebration-in .45s cubic-bezier(.2, .9, .3, 1.2);
}
.install-celebration.settled { animation: none; }
@keyframes celebration-in { from { opacity: 0; transform: translateY(-10px) scale(.94); } }
.celebration-emoji { font-size: 26px; animation: celebration-bounce .8s ease .1s; }
@keyframes celebration-bounce { 0% { transform: scale(0) rotate(-25deg); } 60% { transform: scale(1.35) rotate(8deg); } 100% { transform: scale(1); } }
.install-celebration strong { display: block; font-size: 14px; }
.install-celebration small { color: var(--muted, #5c6672); font-size: 11.5px; }
.confetti-layer { position: absolute; inset: 0; pointer-events: none; z-index: 5; }
.confetti-layer i {
  position: absolute; top: 52px; width: 7px; height: 11px; border-radius: 2px;
  background: var(--confetti-color); opacity: 0;
  animation: confetti-fall 1.5s cubic-bezier(.2, .7, .4, 1) var(--confetti-delay) forwards;
}
@keyframes confetti-fall {
  0% { opacity: 1; transform: translate(0, 0) rotate(0deg); }
  100% { opacity: 0; transform: translate(var(--confetti-x), 320px) rotate(var(--confetti-rotate)); }
}

/* ---- Rendering containment: isolate expensive subtrees ---- */
/* The live preview re-paints on every theme edit; containment keeps style
   recalculation and paint inside the preview instead of the whole page. */
.workspace-window { contain: layout paint; }
.editor-panel { contain: layout style; }

/* ---- Theme pack actions in the library modal ---- */
.library-pack-actions { display: flex; gap: 10px; margin-top: 16px; padding-top: 16px; border-top: 1px solid var(--line); }
.library-pack-actions .button { flex: 1; }
.library-pack-actions svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
