/* SayCut — editor UI */
:root {
  --bg: #09090b;
  --surface: #111113;
  --surface-2: #17171a;
  --surface-3: #1f1f23;
  --border: #25252a;
  --border-strong: #33333a;
  --text: #fafafa;
  --text-2: #a1a1aa;
  --text-3: #6b6b74;
  --accent: #0866ff;
  --accent-hover: #2b7bff;
  --accent-soft: rgba(8, 102, 255, 0.14);
  --danger: #f05252;
  --success: #22c55e;
  --spark: #a78bfa;
  --sam: #60a5fa;
  --image: #f472b6;
  --voice: #34d399;
  --render: #a1a1aa;
  --radius-sm: 8px;
  --radius: 12px;
  --radius-lg: 16px;
  --nav-h: 56px;
  --shadow: 0 1px 0 rgba(255, 255, 255, 0.03) inset, 0 12px 32px rgba(0, 0, 0, 0.35);
  --font: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --mono: ui-monospace, "SF Mono", "JetBrains Mono", Menlo, monospace;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font: 14px/1.5 var(--font);
  -webkit-font-smoothing: antialiased;
  font-feature-settings: "cv11", "ss01";
}
button, input, textarea { font: inherit; color: inherit; }
a { color: inherit; }
code { font-family: var(--mono); }
[hidden] { display: none !important; }
svg.i { width: 16px; height: 16px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.muted { color: var(--text-3); font-size: 12px; }

/* ------------------------------------------------------------ buttons */
.btn {
  display: inline-flex; align-items: center; gap: 7px; height: 36px; padding: 0 14px;
  border-radius: var(--radius-sm); border: 1px solid transparent; background: none;
  font-weight: 500; font-size: 13px; cursor: pointer; text-decoration: none; white-space: nowrap;
  transition: background .15s, border-color .15s, color .15s, opacity .15s;
}
.btn-sm { height: 32px; padding: 0 12px; }
.btn-xs { height: 26px; padding: 0 8px; font-size: 12px; gap: 5px; }
.btn-xs svg.i { width: 14px; height: 14px; }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); }
.btn-secondary { background: var(--surface-3); border-color: var(--border-strong); }
.btn-secondary:hover { background: #26262b; }
.btn-ghost { color: var(--text-2); }
.btn-ghost:hover { color: var(--text); background: var(--surface-3); }
.btn:disabled, .btn.is-disabled { opacity: .4; pointer-events: none; }

.icon-btn {
  width: 32px; height: 32px; display: inline-grid; place-items: center; flex: none;
  border-radius: var(--radius-sm); border: 0; background: transparent; color: var(--text-2); cursor: pointer;
  transition: background .15s, color .15s, transform .1s;
}
.icon-btn:hover { background: var(--surface-3); color: var(--text); }
.icon-btn:active { transform: scale(.95); }
.icon-btn-primary { background: var(--accent); color: #fff; }
.icon-btn-primary:hover { background: var(--accent-hover); color: #fff; }
.icon-btn:disabled { opacity: .35; pointer-events: none; }

kbd {
  font: 500 10.5px/1 var(--mono); color: var(--text-2); background: var(--surface-3);
  border: 1px solid var(--border-strong); border-bottom-width: 2px; border-radius: 4px; padding: 2px 5px;
}

/* ------------------------------------------------------------ nav */
.nav {
  height: var(--nav-h); display: flex; align-items: center; justify-content: space-between;
  padding: 0 20px; border-bottom: 1px solid var(--border); background: rgba(9, 9, 11, .85);
  backdrop-filter: blur(12px); position: sticky; top: 0; z-index: 20;
}
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; }
.brand-mark { width: 28px; height: 28px; border-radius: 8px; background: var(--accent); display: grid; place-items: center; color: #fff; }
.brand-mark svg.i { width: 16px; height: 16px; stroke-width: 2.2; }
.brand-name { font-weight: 650; font-size: 15px; letter-spacing: -0.01em; }
.brand-sep { width: 1px; height: 16px; background: var(--border-strong); }
.brand-tag { color: var(--text-3); font-size: 13px; }
.nav-right { display: flex; align-items: center; gap: 16px; }
.model-list { list-style: none; display: flex; gap: 14px; margin: 0; padding: 0; color: var(--text-3); font-size: 12px; }
.model-list li { display: flex; align-items: center; gap: 6px; }
.dot { width: 6px; height: 6px; border-radius: 50%; display: inline-block; }
.dot.spark { background: var(--spark); } .dot.sam { background: var(--sam); } .dot.image { background: var(--image); } .dot.voice { background: var(--voice); } .dot.render { background: var(--render); }
@media (max-width: 860px) { .model-list, .brand-sep, .brand-tag { display: none; } }

/* ------------------------------------------------------------ landing */
.landing { max-width: 1040px; margin: 0 auto; padding: 72px 24px 64px; }
.hero { text-align: center; max-width: 720px; margin: 0 auto; }
.eyebrow {
  display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 500; color: var(--text-2);
  padding: 5px 11px; border-radius: 999px; border: 1px solid var(--border-strong); background: var(--surface);
}
.eyebrow svg.i { width: 13px; height: 13px; color: var(--spark); }
.hero h1 { font-size: clamp(34px, 5vw, 52px); line-height: 1.05; letter-spacing: -0.035em; font-weight: 700; margin: 20px 0 14px; }
.lede { color: var(--text-2); font-size: 16px; line-height: 1.6; margin: 0 auto 32px; max-width: 600px; }

.dropzone {
  display: block; border: 1px dashed var(--border-strong); border-radius: var(--radius-lg); background: var(--surface);
  padding: 28px; cursor: pointer; transition: border-color .2s, background .2s; text-align: left;
}
.dropzone:hover, .dropzone.drag { border-color: var(--accent); background: #0d1220; }
.dz-idle { display: flex; align-items: center; gap: 16px; justify-content: center; }
.dz-icon { width: 44px; height: 44px; border-radius: 12px; background: var(--accent-soft); color: var(--accent); display: grid; place-items: center; }
.dz-icon svg.i { width: 20px; height: 20px; }
.dz-text { display: flex; flex-direction: column; gap: 2px; }
.dz-text strong { font-weight: 600; font-size: 15px; }
.dz-text u { color: var(--accent); text-decoration: none; }
.dz-text span { color: var(--text-3); font-size: 13px; }
.dz-progress-head { display: flex; justify-content: space-between; font-size: 13px; color: var(--text-2); margin-bottom: 10px; }
.progress { height: 4px; background: var(--surface-3); border-radius: 4px; overflow: hidden; }
.progress > div { height: 100%; width: 0; background: var(--accent); transition: width .2s; }
.warning { display: inline-flex; gap: 8px; align-items: center; color: #fbbf24; font-size: 13px; margin-top: 16px; }

.features { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-top: 56px; }
@media (max-width: 900px) { .features { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 560px) { .features { grid-template-columns: 1fr; } }
.feature { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; display: flex; flex-direction: column; gap: 6px; }
.feature-icon { width: 32px; height: 32px; border-radius: 8px; background: var(--surface-3); display: grid; place-items: center; color: var(--text); margin-bottom: 6px; }
.feature h3 { margin: 0; font-size: 14px; font-weight: 600; }
.feature p { margin: 0; color: var(--text-2); font-size: 13px; flex: 1; }
.feature code { font-size: 11.5px; color: var(--text-3); margin-top: 6px; }

.how { display: grid; grid-template-columns: repeat(4, 1fr); gap: 20px; margin-top: 40px; padding-top: 32px; border-top: 1px solid var(--border); }
@media (max-width: 900px) { .how { grid-template-columns: repeat(2, 1fr); } }
.how-step { display: flex; gap: 12px; }
.how-step strong { display: block; font-size: 13px; font-weight: 600; }
.how-step span:not(.step-n) { color: var(--text-3); font-size: 12.5px; }
.step-n { width: 22px; height: 22px; border-radius: 50%; border: 1px solid var(--border-strong); display: grid; place-items: center; font-size: 11px; color: var(--text-2); flex: none; }

/* ------------------------------------------------------------ workspace */
.workspace { display: grid; grid-template-columns: minmax(0, 1fr) 400px; height: calc(100vh - var(--nav-h)); }
@media (max-width: 980px) { .workspace { grid-template-columns: 1fr; height: auto; } }
.canvas { display: flex; flex-direction: column; min-width: 0; min-height: 0; border-right: 1px solid var(--border); }

.toolbar { height: 52px; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 0 16px; border-bottom: 1px solid var(--border); }
.project-meta { display: flex; align-items: center; gap: 8px; min-width: 0; color: var(--text-2); }
.meta-name { color: var(--text); font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 260px; }
.meta-specs { color: var(--text-3); font-size: 12px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.toolbar-actions { display: flex; align-items: center; gap: 8px; }
@media (max-width: 640px) { .meta-specs { display: none; } }

.segmented { display: inline-flex; padding: 3px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 9px; }
.segmented button { border: 0; background: none; color: var(--text-2); font-size: 12.5px; font-weight: 500; padding: 4px 12px; border-radius: 6px; cursor: pointer; }
.segmented button[aria-selected="true"] { background: var(--surface-3); color: var(--text); box-shadow: 0 1px 2px rgba(0, 0, 0, .4); }
.segmented button:disabled { opacity: .4; cursor: default; }

.stage {
  position: relative; flex: 1; min-height: 360px; overflow: hidden; display: grid; place-items: center; padding: 24px;
  background: radial-gradient(ellipse at center, #121216 0%, var(--bg) 70%);
}
.backdrop { position: absolute; inset: -40px; background: center / cover no-repeat; filter: blur(60px) saturate(1.2); opacity: .22; transition: background-image .3s; }
.frame { position: relative; border-radius: 10px; overflow: hidden; background: #000; box-shadow: 0 0 0 1px rgba(255, 255, 255, .06), 0 24px 60px rgba(0, 0, 0, .55); transition: opacity .25s; }
.frame video { display: block; width: 100%; height: 100%; object-fit: contain; background: #000; }
.frame.is-busy video { opacity: .55; }
.frame-progress { position: absolute; left: 0; right: 0; top: 0; height: 3px; background: rgba(255, 255, 255, .08); z-index: 2; }
.frame-progress > div { height: 100%; width: 0; background: var(--accent); transition: width .3s; }
.frame-progress.indeterminate > div { width: 30% !important; animation: slide 1.2s ease-in-out infinite; }
@keyframes slide { from { transform: translateX(-100%); } to { transform: translateX(340%); } }

.status {
  position: absolute; left: 50%; bottom: 20px; transform: translateX(-50%); z-index: 3;
  display: flex; align-items: center; gap: 10px; max-width: calc(100% - 40px);
  padding: 8px 14px 8px 12px; border-radius: 999px; background: rgba(17, 17, 19, .92); border: 1px solid var(--border-strong);
  box-shadow: var(--shadow); font-size: 12.5px; backdrop-filter: blur(8px);
}
.status-model { font-weight: 600; font-size: 11px; letter-spacing: .02em; display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.status-text { color: var(--text-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.spinner { width: 14px; height: 14px; border-radius: 50%; border: 2px solid rgba(255, 255, 255, .15); border-top-color: var(--text); animation: spin .8s linear infinite; flex: none; }
@keyframes spin { to { transform: rotate(360deg); } }

.layers { border-top: 1px solid var(--border); padding: 10px 16px 14px; background: var(--surface); }
.layers-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.layers-title { display: inline-flex; align-items: center; gap: 7px; font-size: 12px; font-weight: 600; color: var(--text-2); text-transform: uppercase; letter-spacing: .06em; }
.count { font-variant-numeric: tabular-nums; color: var(--text-3); font-weight: 500; }
.layer-list { list-style: none; margin: 0; padding: 0; display: flex; gap: 8px; overflow-x: auto; min-height: 36px; scrollbar-width: thin; }
.layer {
  display: inline-flex; align-items: center; gap: 8px; height: 34px; padding: 0 6px 0 10px; flex: none;
  background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-sm); font-size: 12.5px; max-width: 320px;
  animation: pop .25s ease-out;
}
@keyframes pop { from { transform: scale(.96); opacity: 0; } }
.layer-icon { width: 20px; height: 20px; border-radius: 5px; display: grid; place-items: center; background: var(--surface-3); color: var(--text-2); }
.layer-icon svg.i { width: 13px; height: 13px; }
.layer-label { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.layer .icon-btn { width: 24px; height: 24px; opacity: 0; }
.layer:hover .icon-btn, .layer .icon-btn:focus-visible { opacity: 1; }
.layer .icon-btn svg.i { width: 13px; height: 13px; }
.layer-empty { color: var(--text-3); font-size: 12.5px; display: flex; align-items: center; height: 34px; }

/* ------------------------------------------------------------ inspector */
.inspector { display: flex; flex-direction: column; min-height: 0; background: var(--surface); }
@media (max-width: 980px) { .inspector { min-height: 70vh; border-top: 1px solid var(--border); } }
.panel-head { height: 52px; display: flex; align-items: center; justify-content: space-between; padding: 0 16px; border-bottom: 1px solid var(--border); flex: none; }
.panel-title { display: inline-flex; align-items: center; gap: 8px; font-weight: 600; font-size: 13px; }
.panel-title svg.i { color: var(--spark); }

.insight { margin: 14px 16px 4px; padding: 14px; border-radius: var(--radius); background: var(--surface-2); border: 1px solid var(--border); flex: none; }
.insight-label { display: block; font-size: 11px; color: var(--text-3); text-transform: uppercase; letter-spacing: .06em; font-weight: 600; margin-bottom: 6px; }
.insight strong { display: block; font-size: 15px; font-weight: 600; letter-spacing: -0.01em; }
.insight p { margin: 4px 0 0; color: var(--text-2); font-size: 13px; }
.skeleton { color: transparent !important; background: linear-gradient(90deg, var(--surface-3) 0%, #2a2a30 50%, var(--surface-3) 100%); background-size: 200% 100%; animation: shimmer 1.4s infinite; border-radius: 6px; }
.insight strong.skeleton { width: 60%; height: 20px; }
.insight p.skeleton { height: 34px; margin-top: 8px; }
@keyframes shimmer { to { background-position: -200% 0; } }

.chat { flex: 1; min-height: 120px; overflow-y: auto; padding: 12px 16px; display: flex; flex-direction: column; gap: 14px; scrollbar-width: thin; }
.msg { display: flex; gap: 10px; max-width: 100%; animation: pop .2s ease-out; }
.msg-avatar { width: 24px; height: 24px; border-radius: 7px; background: var(--accent); color: #fff; display: grid; place-items: center; flex: none; margin-top: 1px; }
.msg-avatar svg.i { width: 13px; height: 13px; stroke-width: 2.2; }
.msg-body { min-width: 0; flex: 1; }
.msg-text { font-size: 13.5px; line-height: 1.55; white-space: pre-wrap; overflow-wrap: anywhere; }
.msg.user { justify-content: flex-end; }
.msg.user .msg-text { background: var(--surface-3); border: 1px solid var(--border-strong); padding: 8px 12px; border-radius: 12px 12px 4px 12px; max-width: 85%; }
.msg.error .msg-text { color: #fca5a5; }
.trace { list-style: none; margin: 8px 0 0; padding: 8px 10px; display: flex; flex-direction: column; gap: 6px; border-radius: var(--radius-sm); background: var(--surface-2); border: 1px solid var(--border); }
.trace li { display: grid; grid-template-columns: 92px 1fr; gap: 8px; font-size: 12px; color: var(--text-2); align-items: baseline; }
.trace li.live { color: var(--text); }
.trace li.live .trace-text::after { content: ""; display: inline-block; width: 4px; height: 4px; margin-left: 6px; border-radius: 50%; background: currentColor; animation: blink 1s infinite; vertical-align: middle; }
@keyframes blink { 50% { opacity: .1; } }
.tag { display: inline-flex; align-items: center; gap: 6px; font-size: 10.5px; font-weight: 600; letter-spacing: .02em; color: var(--text-2); white-space: nowrap; }
.trace-text { overflow-wrap: anywhere; }

.suggest-wrap { padding: 4px 16px 10px; flex: none; }
.suggest-label { display: block; font-size: 11px; color: var(--text-3); text-transform: uppercase; letter-spacing: .06em; font-weight: 600; margin-bottom: 8px; }
.suggestions { display: flex; flex-wrap: wrap; gap: 6px; }
.suggestions button {
  border: 1px solid var(--border-strong); background: var(--surface-2); color: var(--text-2); border-radius: 999px;
  padding: 5px 11px; font-size: 12.5px; cursor: pointer; transition: border-color .15s, color .15s, background .15s;
}
.suggestions button:hover { border-color: var(--accent); color: var(--text); background: var(--accent-soft); }
.suggestions button:disabled { opacity: .4; pointer-events: none; }

.composer { margin: 0 16px 16px; border: 1px solid var(--border-strong); border-radius: var(--radius); background: var(--surface-2); transition: border-color .15s, box-shadow .15s; position: relative; flex: none; }
.composer:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.composer textarea { display: block; width: 100%; border: 0; outline: 0; resize: none; background: transparent; padding: 12px 14px 4px; font-size: 14px; line-height: 1.45; max-height: 140px; }
.composer textarea::placeholder { color: var(--text-3); }
.composer-row { display: flex; align-items: center; gap: 8px; padding: 6px 8px 8px; }
.composer-hint { flex: 1; color: var(--text-3); font-size: 11.5px; display: flex; align-items: center; gap: 4px; }
@media (max-width: 420px) { .composer-hint { visibility: hidden; } }
#mic.recording { background: var(--danger); color: #fff; }
.rec { position: absolute; inset: 0; z-index: 2; border-radius: inherit; background: var(--surface-2); display: flex; align-items: center; gap: 10px; padding: 0 16px; font-size: 13px; font-weight: 500; }
.rec-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--danger); animation: blink 1s infinite; }
.rec-time { font-variant-numeric: tabular-nums; color: var(--text-2); }
.rec.is-starting .rec-dot { background: var(--text-3); }
.rec.is-starting .wave i { background: var(--text-3); animation-duration: 1.6s; }
.rec.is-starting .rec-time { visibility: hidden; }
.rec-hint { margin-left: auto; color: var(--text-3); font-size: 12px; font-weight: 400; }
.wave { display: inline-flex; gap: 3px; align-items: center; height: 16px; }
.wave i { width: 3px; height: 100%; background: var(--danger); border-radius: 2px; animation: wave 0.9s ease-in-out infinite; }
.wave i:nth-child(2) { animation-delay: .1s; } .wave i:nth-child(3) { animation-delay: .2s; } .wave i:nth-child(4) { animation-delay: .3s; } .wave i:nth-child(5) { animation-delay: .4s; }
@keyframes wave { 0%, 100% { transform: scaleY(.3); } 50% { transform: scaleY(1); } }

/* ------------------------------------------------------------ dialog + toasts */
.dialog { border: 1px solid var(--border-strong); border-radius: var(--radius-lg); background: var(--surface); color: var(--text); padding: 0; width: min(420px, 92vw); box-shadow: 0 30px 80px rgba(0, 0, 0, .6); }
.dialog::backdrop { background: rgba(0, 0, 0, .65); backdrop-filter: blur(4px); }
.dialog-head, .dialog-foot { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 14px; }
.dialog-head { border-bottom: 1px solid var(--border); }
.dialog-foot { border-top: 1px solid var(--border); }
.dialog img { display: block; width: 100%; max-height: 70vh; object-fit: contain; background: #000; }

.toasts { position: fixed; right: 20px; bottom: 20px; z-index: 50; display: flex; flex-direction: column; gap: 8px; }
.toast { display: flex; gap: 10px; align-items: flex-start; max-width: 380px; padding: 12px 14px; border-radius: var(--radius); background: var(--surface-2); border: 1px solid var(--border-strong); box-shadow: var(--shadow); font-size: 13px; animation: pop .2s ease-out; }
.toast.error svg.i { color: var(--danger); } .toast.success svg.i { color: var(--success); }

@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }

/* ------------------------------------------------------------ small screens */
@media (max-width: 980px) {
  .workspace { grid-template-columns: minmax(0, 1fr); }
  .canvas { border-right: 0; }
  .stage { min-height: 0; padding: 16px 16px 64px; }
  .inspector { min-height: 0; }
  .chat { min-height: 160px; max-height: 50vh; }
}
@media (max-width: 640px) {
  .nav { padding: 0 14px; }
  .toolbar { padding: 0 12px; gap: 8px; }
  .toolbar-actions { gap: 6px; }
  .toolbar-actions .btn span { display: none; }
  .toolbar-actions .btn { padding: 0 9px; }
  .meta-name { max-width: 110px; }
  .landing { padding: 40px 18px 48px; }
  .dz-idle { flex-direction: column; text-align: center; }
  .layers { padding: 10px 12px 12px; }
  .insight, .composer { margin-left: 12px; margin-right: 12px; }
  .chat, .suggest-wrap { padding-left: 12px; padding-right: 12px; }
}
