:root {
  --st-bg: #f5f6fa;
  --st-surface: #ffffff;
  --st-muted-surface: #eef0f6;
  --st-line: #dfe3ec;
  --st-line-strong: #c8cedb;
  --st-ink: #161a26;
  --st-ink-soft: #3d4458;
  --st-muted: #687089;
  --st-accent: #4f46e5;
  --st-accent-soft: #eceafe;
  --st-danger: #c2410c;
  --st-ok: #15803d;
  --st-warn: #b45309;
  --st-radius: 12px;
  --st-shadow: 0 1px 2px rgba(20, 24, 40, .06), 0 8px 24px rgba(20, 24, 40, .06);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --st-bg: #0f1117;
    --st-surface: #171a23;
    --st-muted-surface: #1f2330;
    --st-line: #2a2f3d;
    --st-line-strong: #39404f;
    --st-ink: #eef0f6;
    --st-ink-soft: #c5cad8;
    --st-muted: #8d94a8;
    --st-accent: #8b84ff;
    --st-accent-soft: #26244a;
    --st-danger: #fb923c;
    --st-ok: #4ade80;
    --st-warn: #fbbf24;
    --st-shadow: 0 1px 2px rgba(0, 0, 0, .3);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--st-bg); color: var(--st-ink); font: 14px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif; -webkit-font-smoothing: antialiased; }
svg { width: 18px; height: 18px; flex: 0 0 auto; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--st-accent); }
code { padding: 1px 5px; border-radius: 5px; background: var(--st-muted-surface); font-size: .9em; }

.st-top { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 16px; height: 56px; padding: 0 16px; border-bottom: 1px solid var(--st-line); background: var(--st-surface); }
.st-logo { display: flex; align-items: center; gap: 9px; color: var(--st-ink); text-decoration: none; white-space: nowrap; }
.st-logo svg { width: 28px; height: 28px; }
.st-logo svg rect { fill: var(--st-accent); stroke: none; }
.st-logo svg path { stroke: #fff; stroke-width: 5; }
.st-logo span { font-size: 15px; color: var(--st-muted); }
.st-logo strong { color: var(--st-ink); }
.st-project { display: flex; align-items: baseline; gap: 10px; min-width: 0; padding-left: 16px; border-left: 1px solid var(--st-line); }
.st-project:empty { display: none; }
.st-project strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.st-project span { color: var(--st-muted); font-size: 12px; white-space: nowrap; }
.st-project span[data-state="saving"] { color: var(--st-warn); }
.st-project span[data-state="error"], .st-project span[data-state="conflict"] { color: var(--st-danger); }
.st-project span[data-state="offline"] { color: var(--st-warn); }
.st-actions { display: flex; gap: 8px; margin-left: auto; }

.st-button { display: inline-flex; align-items: center; justify-content: center; gap: 7px; min-height: 36px; padding: 0 14px; border: 1px solid var(--st-line-strong); border-radius: 9px; background: var(--st-surface); font-weight: 600; text-decoration: none; cursor: pointer; white-space: nowrap; }
.st-button:hover { border-color: var(--st-accent); }
.st-button:disabled { opacity: .5; cursor: not-allowed; }
.st-button.primary { border-color: var(--st-accent); background: var(--st-accent); color: #fff; }
.st-button.ghost { border-color: transparent; background: transparent; }
.st-button.ghost:hover { background: var(--st-muted-surface); }
.st-button.small { min-height: 30px; padding: 0 10px; font-size: 13px; }
.st-button.small svg { width: 15px; height: 15px; }
.st-button.danger { color: var(--st-danger); }
.st-icon-button { display: inline-grid; place-items: center; width: 32px; height: 32px; border: 0; border-radius: 8px; background: transparent; color: var(--st-muted); cursor: pointer; }
.st-icon-button:hover { background: var(--st-muted-surface); color: var(--st-ink); }
.st-link { padding: 0; border: 0; background: none; color: var(--st-accent); font-weight: 600; cursor: pointer; }

/* Home */
.st-body.home { overflow: auto; height: calc(100vh - 56px); }
.st-home { width: min(980px, 100%); margin: 0 auto; padding: 40px 20px 80px; }
.st-hero { padding: 36px; border-radius: 20px; background: linear-gradient(135deg, #1e1b4b, #4f46e5 60%, #7c3aed); color: #fff; box-shadow: var(--st-shadow); }
.st-hero h1 { margin: 0 0 10px; font-size: clamp(28px, 5vw, 44px); line-height: 1.05; letter-spacing: -.03em; }
.st-hero h1 span { color: #c7d2fe; }
.st-hero p { max-width: 640px; margin: 0 0 24px; color: #e0e7ff; font-size: 16px; }
.st-new { display: flex; flex-wrap: wrap; gap: 8px; }
.st-new input { flex: 1 1 320px; min-height: 44px; padding: 0 14px; border: 0; border-radius: 10px; color: #111; }
.st-new select { min-height: 44px; padding: 0 10px; border: 0; border-radius: 10px; color: #111; }
.st-new .st-button { min-height: 44px; border-color: #fff; background: #fff; color: #312e81; }
.st-home-links { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
.st-home-links .st-button { color: #fff; }
.st-home-links .st-button:hover { background: rgba(255,255,255,.12); }
.st-h2 { margin: 36px 0 12px; font-size: 18px; }
.st-projects { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 10px; }
.st-project-card { display: flex; align-items: center; gap: 6px; padding: 4px 6px 4px 4px; border: 1px solid var(--st-line); border-radius: var(--st-radius); background: var(--st-surface); text-align: left; }
button.st-project-card { padding: 12px 14px; cursor: pointer; flex-direction: column; align-items: flex-start; }
.st-project-card > button:first-child { flex: 1; min-width: 0; padding: 10px; border: 0; background: none; text-align: left; cursor: pointer; }
.st-project-card strong { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.st-project-card small { color: var(--st-muted); }
.st-project-card:hover { border-color: var(--st-accent); }
.st-note { display: flex; gap: 8px; align-items: flex-start; margin-top: 18px; color: var(--st-muted); }

/* Workspace */
.st-body.workspace { display: grid; grid-template-columns: 232px minmax(0, 1fr); height: calc(100vh - 56px); }
.st-body.workspace.with-preview { grid-template-columns: 232px minmax(0, 1fr) minmax(360px, 34%); }
.st-nav { display: flex; flex-direction: column; gap: 2px; padding: 12px 10px; overflow-y: auto; border-right: 1px solid var(--st-line); background: var(--st-surface); }
.st-nav button { position: relative; display: flex; align-items: center; gap: 10px; min-height: 36px; padding: 0 10px; border: 0; border-radius: 8px; background: none; color: var(--st-ink-soft); text-align: left; cursor: pointer; }
.st-nav button:hover { background: var(--st-muted-surface); }
.st-nav button.active { background: var(--st-accent-soft); color: var(--st-accent); font-weight: 650; }
.st-nav button.off span { opacity: .55; }
.st-nav button small { margin-left: auto; color: var(--st-muted); font-size: 11px; }
.st-badge { margin-left: auto; min-width: 20px; padding: 1px 6px; border-radius: 999px; background: var(--st-danger); color: #fff; font-size: 11px; text-align: center; }
.st-main { overflow-y: auto; padding: 24px clamp(16px, 3vw, 36px) 80px; }
.st-section-head { margin-bottom: 18px; }
.st-section-head h1 { margin: 0; font-size: 26px; letter-spacing: -.02em; }
.st-section-head p { margin: 4px 0 0; color: var(--st-muted); }
.st-card { margin-bottom: 16px; padding: 18px; border: 1px solid var(--st-line); border-radius: var(--st-radius); background: var(--st-surface); box-shadow: var(--st-shadow); }
.st-card.flat { box-shadow: none; }
.st-card > header { margin-bottom: 14px; }
.st-card > header h2 { margin: 0; font-size: 16px; }
.st-card > header p { margin: 3px 0 0; color: var(--st-muted); font-size: 13px; }
.st-grid.two { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 16px; }
.st-grid.two .st-card { margin-bottom: 0; }
.st-grid.two + .st-card { margin-top: 16px; }

.st-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; }
.st-field { display: flex; flex-direction: column; gap: 5px; min-width: 0; margin-bottom: 12px; }
.st-field > span { color: var(--st-ink-soft); font-size: 12.5px; font-weight: 600; }
.st-field small { color: var(--st-muted); font-size: 12px; }
.st-field input:not([type=checkbox]):not([type=color]), .st-field select, .st-field textarea, .st-search, .st-inline select {
  width: 100%; min-height: 36px; padding: 7px 10px; border: 1px solid var(--st-line-strong); border-radius: 8px; background: var(--st-surface);
}
.st-field textarea { resize: vertical; line-height: 1.5; }
.st-field input:focus, .st-field select:focus, .st-field textarea:focus, .st-search:focus { outline: 2px solid var(--st-accent); outline-offset: -1px; border-color: transparent; }
.st-color { display: flex; gap: 6px; }
.st-color input[type=color] { width: 44px; height: 36px; padding: 2px; border: 1px solid var(--st-line-strong); border-radius: 8px; background: var(--st-surface); }
.st-color input[type=text] { font-family: ui-monospace, monospace; }
.st-switch { display: flex; align-items: flex-start; gap: 10px; margin: 4px 0 12px; cursor: pointer; }
.st-switch input { position: absolute; opacity: 0; }
.st-switch-track { position: relative; flex: 0 0 auto; width: 38px; height: 22px; margin-top: 1px; border-radius: 999px; background: var(--st-line-strong); transition: background .15s; }
.st-switch-track::after { content: ""; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%; background: #fff; transition: transform .15s; }
.st-switch input:checked + .st-switch-track { background: var(--st-accent); }
.st-switch input:checked + .st-switch-track::after { transform: translateX(16px); }
.st-switch input:focus-visible + .st-switch-track { outline: 2px solid var(--st-accent); outline-offset: 2px; }
.st-switch-copy strong { display: block; font-weight: 600; }
.st-switch-copy small { display: block; color: var(--st-muted); }
.st-modules { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 6px 20px; }

.st-asset-row { display: flex; gap: 12px; align-items: center; }
.st-asset-row img, .st-asset-empty { width: 64px; height: 64px; flex: 0 0 auto; border: 1px solid var(--st-line); border-radius: 10px; object-fit: contain; background: repeating-conic-gradient(var(--st-muted-surface) 0 25%, transparent 0 50%) 50% / 12px 12px; }
.st-asset-empty { display: grid; place-items: center; color: var(--st-muted); }
.st-asset-row strong { display: block; font-size: 13px; word-break: break-all; }
.st-asset-actions { display: flex; gap: 6px; margin-top: 6px; }
.st-warn { color: var(--st-warn) !important; }

.st-list { display: flex; flex-direction: column; gap: 8px; margin: 8px 0 14px; }
.st-list-head { display: flex; align-items: baseline; gap: 8px; }
.st-list-head h3 { margin: 6px 0 0; font-size: 13px; text-transform: uppercase; letter-spacing: .04em; color: var(--st-muted); }
.st-list-head span { color: var(--st-muted); font-size: 12px; }
.st-list > .st-button { align-self: flex-start; }
.st-item { border: 1px solid var(--st-line); border-radius: 10px; background: var(--st-surface); }
.st-item[open] { border-color: var(--st-line-strong); }
.st-item > summary { display: flex; align-items: center; gap: 8px; min-height: 42px; padding: 4px 6px 4px 12px; list-style: none; cursor: pointer; }
.st-item > summary::-webkit-details-marker { display: none; }
.st-item > summary::before { content: ""; width: 7px; height: 7px; border-right: 2px solid var(--st-muted); border-bottom: 2px solid var(--st-muted); transform: rotate(-45deg); transition: transform .15s; flex: 0 0 auto; }
.st-item[open] > summary::before { transform: rotate(45deg); }
.st-item-title { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.st-item-title small { margin-left: 6px; color: var(--st-muted); }
.st-item-title em { color: var(--st-muted); }
.st-item-tools { display: flex; gap: 2px; opacity: .6; }
.st-item > summary:hover .st-item-tools { opacity: 1; }
.st-item-tools button { display: grid; place-items: center; width: 28px; height: 28px; border: 0; border-radius: 7px; background: none; color: var(--st-muted); cursor: pointer; }
.st-item-tools button:hover:not(:disabled) { background: var(--st-muted-surface); color: var(--st-ink); }
.st-item-tools button:disabled { opacity: .3; cursor: default; }
.st-item-tools button:nth-child(1) svg { transform: rotate(90deg); }
.st-item-tools button:nth-child(2) svg { transform: rotate(90deg); }
.st-item-body { padding: 4px 14px 6px; border-top: 1px solid var(--st-line); }
.st-list.compact .st-item > summary { min-height: 36px; }
.st-item .st-item { background: var(--st-bg); }
.st-empty { margin: 4px 0; color: var(--st-muted); }
.st-code { display: inline-grid; place-items: center; min-width: 24px; height: 22px; margin-right: 4px; padding: 0 5px; border-radius: 6px; background: var(--st-ink); color: var(--st-surface); font-size: 12px; }

.st-toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 4px 0 14px; }
.st-inline { display: flex; align-items: center; gap: 6px; color: var(--st-muted); font-size: 13px; }
.st-inline select { width: auto; min-height: 30px; padding: 2px 8px; }
.st-callout { display: flex; align-items: center; gap: 8px; margin: 0 0 14px; padding: 10px 12px; border-radius: 10px; background: var(--st-accent-soft); color: var(--st-ink-soft); }
.st-callout.warn { background: color-mix(in srgb, var(--st-warn) 14%, transparent); }
.st-hint { margin: 6px 0 0; color: var(--st-muted); font-size: 12.5px; }
.st-ok { display: flex; align-items: center; gap: 8px; margin: 0; color: var(--st-ok); font-weight: 600; }

.st-steps { margin: 0; padding: 0; list-style: none; }
.st-steps button { display: flex; align-items: center; gap: 10px; width: 100%; min-height: 38px; padding: 0 8px; border: 0; border-radius: 8px; background: none; text-align: left; cursor: pointer; }
.st-steps button:hover { background: var(--st-muted-surface); }
.st-steps li.done svg { color: var(--st-ok); }
.st-steps li.done span { color: var(--st-muted); text-decoration: line-through; }
.st-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.st-stats > * { display: flex; flex-direction: column; align-items: flex-start; padding: 10px 12px; border: 1px solid var(--st-line); border-radius: 10px; background: var(--st-bg); text-align: left; cursor: pointer; }
.st-stats.small > * { cursor: default; }
.st-stats strong { font-size: 22px; }
.st-stats span { color: var(--st-muted); font-size: 12px; }
.st-issues { margin: 0; padding: 0; list-style: none; }
.st-issues li { display: grid; grid-template-columns: 70px minmax(0, 1fr) auto; gap: 10px; align-items: center; padding: 8px 0; border-top: 1px solid var(--st-line); }
.st-issues li:first-child { border-top: 0; }
.st-issues li span { justify-self: start; padding: 1px 7px; border-radius: 6px; font-size: 11px; font-weight: 700; text-transform: uppercase; }
.st-issues li.error span { background: color-mix(in srgb, var(--st-danger) 16%, transparent); color: var(--st-danger); }
.st-issues li.warning span { background: color-mix(in srgb, var(--st-warn) 16%, transparent); color: var(--st-warn); }
.st-issues li.info span { background: var(--st-accent-soft); color: var(--st-accent); }
.st-issues p { margin: 0; }

.st-presets { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 14px; }
.st-presets button { display: inline-flex; align-items: center; gap: 3px; padding: 6px 10px 6px 6px; border: 1px solid var(--st-line); border-radius: 999px; background: var(--st-surface); font-size: 12.5px; cursor: pointer; }
.st-presets button:hover { border-color: var(--st-accent); }
.st-presets span { width: 14px; height: 14px; border-radius: 50%; }
.st-presets span:last-of-type { margin-right: 5px; }
.st-swatches { display: grid; grid-template-columns: repeat(16, 1fr); height: 28px; margin: 4px 0 12px; overflow: hidden; border-radius: 8px; border: 1px solid var(--st-line); }
.st-contrast { margin: 0; padding: 0; list-style: none; }
.st-contrast li { display: flex; align-items: center; gap: 8px; padding: 4px 0; }
.st-contrast li span { flex: 1; }
.st-contrast li.ok svg { color: var(--st-ok); }
.st-contrast li.bad { color: var(--st-danger); }

.st-master { display: grid; grid-template-columns: minmax(220px, 300px) minmax(0, 1fr); gap: 16px; align-items: start; }
.st-master-list { position: sticky; top: 0; display: flex; flex-direction: column; gap: 8px; max-height: calc(100vh - 140px); }
.st-master-items { overflow-y: auto; display: flex; flex-direction: column; gap: 4px; }
.st-master-items button { padding: 8px 10px; border: 1px solid transparent; border-radius: 8px; background: none; text-align: left; cursor: pointer; }
.st-master-items button:hover { background: var(--st-muted-surface); }
.st-master-items button.active { border-color: var(--st-accent); background: var(--st-accent-soft); }
.st-master-items small { display: block; color: var(--st-muted); font-size: 11.5px; }
.st-master-items strong { display: -webkit-box; overflow: hidden; font-size: 13px; font-weight: 600; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.st-detail-head { display: flex; justify-content: space-between; gap: 12px; align-items: flex-start; }
.st-detail-head h2 { margin: 0 0 12px; font-size: 17px; }

.st-table-wrap { overflow-x: auto; }
.st-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.st-table th { padding: 6px; border-bottom: 1px solid var(--st-line); color: var(--st-muted); font-size: 11.5px; text-align: left; text-transform: uppercase; }
.st-table td { padding: 3px; vertical-align: top; }
.st-table .st-field { margin: 0; }
.st-table td:first-child { width: 76px; }
.st-table td:nth-child(2) { width: 170px; }
.st-result { padding: 10px 0; border-top: 1px solid var(--st-line); }
.st-result strong { display: block; }
.st-bars { display: flex; align-items: flex-end; gap: 4px; height: 50px; margin-top: 6px; }
.st-bars i { width: 26px; height: max(2px, var(--h)); border-radius: 4px 4px 0 0; background: var(--st-accent); }

/* Preview */
.st-preview { display: flex; flex-direction: column; min-width: 0; border-left: 1px solid var(--st-line); background: var(--st-muted-surface); }
.st-preview-bar { display: flex; align-items: center; justify-content: space-between; padding: 8px 12px; }
.st-seg { display: inline-flex; padding: 2px; border-radius: 9px; background: var(--st-surface); border: 1px solid var(--st-line); }
.st-seg button { padding: 4px 10px; border: 0; border-radius: 7px; background: none; color: var(--st-muted); font-size: 12px; text-transform: capitalize; cursor: pointer; }
.st-seg button.active { background: var(--st-accent-soft); color: var(--st-accent); font-weight: 600; }
.st-device { flex: 1; display: flex; justify-content: center; min-height: 0; padding: 4px 12px 16px; }
.st-device iframe { width: 100%; height: 100%; border: 0; background: #fff; box-shadow: var(--st-shadow); }
.st-device.phone iframe { max-width: 390px; max-height: 844px; border: 8px solid #111; border-radius: 34px; }
.st-device.tablet iframe { max-width: 768px; border: 8px solid #111; border-radius: 22px; }
.st-device.desktop iframe { border-radius: 8px; }

.st-toast { position: fixed; z-index: 100; left: 50%; bottom: 24px; padding: 10px 16px; border-radius: 10px; background: #111827; color: #fff; font-weight: 600; opacity: 0; transform: translate(-50%, 20px); transition: opacity .2s, transform .2s; pointer-events: none; }
.st-toast.show { opacity: 1; transform: translate(-50%, 0); }
.st-dialog { width: min(480px, calc(100% - 32px)); padding: 22px; border: 1px solid var(--st-line); border-radius: 16px; background: var(--st-surface); color: var(--st-ink); box-shadow: 0 30px 80px rgba(0,0,0,.3); }
.st-dialog::backdrop { background: rgba(10, 12, 20, .45); }
.st-dialog h2 { margin: 0 0 8px; }
.st-form { margin-top: 12px; }

@media (max-width: 1100px) {
  .st-body.workspace.with-preview { grid-template-columns: 200px minmax(0, 1fr); }
  .st-body.workspace.with-preview .st-preview { position: fixed; inset: 56px 0 0 auto; width: min(420px, 100%); z-index: 15; box-shadow: -10px 0 40px rgba(0,0,0,.2); }
}
@media (max-width: 760px) {
  .st-body.workspace, .st-body.workspace.with-preview { grid-template-columns: 1fr; grid-template-rows: auto minmax(0, 1fr); }
  .st-nav { flex-direction: row; overflow-x: auto; border-right: 0; border-bottom: 1px solid var(--st-line); padding: 6px; }
  .st-nav button { flex: 0 0 auto; }
  .st-nav button small, .st-nav button svg { display: none; }
  .st-actions .st-button { padding: 0 9px; }
  .st-actions .st-button:not(.primary) { font-size: 0; gap: 0; }
  .st-actions .st-button svg { width: 18px; height: 18px; }
  .st-logo span, .st-project span { display: none; }
  .st-master { grid-template-columns: 1fr; }
  .st-master-list { position: static; max-height: 260px; }
}
