/* LidGEN studio UI — precision tooling, warm industrial palette. */
:root {
  --bg: #0b0d0f; --bg-grid: rgba(255,255,255,.018);
  --panel: #111417; --panel-2: #171b1f; --panel-3: #1d2227;
  --fg: #f4f1eb; --fg-dim: #9ba1a6; --fg-faint: #626a70;
  --accent: #ff6b35; --accent-bright: #ff8152; --accent-soft: rgba(255,107,53,.12);
  --border: #272d32; --border-bright: #373e44;
  --good: #63d49c; --warn: #f4bc62; --fail: #f07272;
  --font-sans: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --font-display: "Arial Narrow", Inter, ui-sans-serif, sans-serif;
  --font-mono: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  --shadow: 0 24px 70px rgba(0,0,0,.38);
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--bg); color: var(--fg); font: 14px/1.55 var(--font-sans); overflow: hidden; -webkit-font-smoothing: antialiased; }
button, textarea { font: inherit; }
button { -webkit-tap-highlight-color: transparent; }
button:focus-visible, textarea:focus-visible, a:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
#app { display: grid; grid-template-columns: 272px 1fr; height: 100vh; }

/* Sidebar */
#sidebar { position: relative; display: flex; flex-direction: column; min-width: 0; overflow: hidden; background: #0e1113; border-right: 1px solid var(--border); }
#sidebar::after { content: ""; position: absolute; inset: 0; pointer-events: none; opacity: .45; background-image: linear-gradient(var(--bg-grid) 1px, transparent 1px), linear-gradient(90deg, var(--bg-grid) 1px, transparent 1px); background-size: 28px 28px; mask-image: linear-gradient(to bottom, #000, transparent 44%); }
.rail-header, #session-list, .rail-footer, .rail-label { position: relative; z-index: 1; }
.rail-header { display: flex; align-items: center; justify-content: space-between; min-height: 76px; padding: 16px 16px 14px 18px; }
.brand { display: flex; align-items: center; gap: 11px; color: inherit; text-decoration: none; }
.brand-mark { display: grid; place-items: center; width: 38px; height: 38px; color: var(--accent); border: 1px solid rgba(255,107,53,.28); border-radius: 11px; background: linear-gradient(145deg, rgba(255,107,53,.14), rgba(255,107,53,.035)); box-shadow: inset 0 1px rgba(255,255,255,.06), 0 8px 24px rgba(255,107,53,.08); }
.brand-mark svg { width: 26px; fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linejoin: round; }
.brand > span:last-child { display: flex; flex-direction: column; line-height: 1.05; }
.brand strong { font-size: 16px; letter-spacing: .06em; }
.brand small { margin-top: 5px; color: var(--fg-faint); font: 9px/1 var(--font-mono); letter-spacing: .16em; text-transform: uppercase; }
#btn-new, #btn-menu { display: grid; place-items: center; width: 36px; height: 36px; padding: 0; color: var(--fg-dim); background: var(--panel-2); border: 1px solid var(--border); border-radius: 10px; cursor: pointer; transition: .18s ease; }
#btn-new svg, #btn-menu svg { width: 18px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; }
#btn-new:hover, #btn-menu:hover { color: #fff; border-color: var(--accent); background: var(--accent); transform: translateY(-1px); }
.rail-label { padding: 14px 18px 8px; color: var(--fg-faint); font: 10px/1 var(--font-mono); letter-spacing: .13em; text-transform: uppercase; border-top: 1px solid rgba(255,255,255,.035); }
#session-list { flex: 1; overflow-y: auto; padding: 7px 10px 14px; }
.session-item { position: relative; display: flex; flex-direction: column; gap: 5px; margin: 2px 0; padding: 11px 12px 11px 14px; color: var(--fg-dim); border: 1px solid transparent; border-radius: 9px; cursor: pointer; transition: .15s ease; }
.session-item::before { content: ""; position: absolute; left: 4px; top: 13px; bottom: 13px; width: 2px; border-radius: 2px; background: transparent; }
.session-item:hover { color: var(--fg); background: rgba(255,255,255,.035); }
.session-item.active { color: var(--fg); background: var(--accent-soft); border-color: rgba(255,107,53,.14); }
.session-item.active::before { background: var(--accent); }
.session-item .brief { display: -webkit-box; overflow: hidden; font-size: 12.5px; line-height: 1.45; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.session-item .turns-count { color: var(--fg-faint); font: 9.5px/1.3 var(--font-mono); text-transform: uppercase; letter-spacing: .03em; }
.rail-footer { display: flex; align-items: center; gap: 10px; margin: 10px; padding: 12px; color: var(--fg-dim); background: rgba(255,255,255,.025); border: 1px solid var(--border); border-radius: 10px; }
.rail-footer div { display: flex; min-width: 0; flex-direction: column; line-height: 1.2; }
.rail-footer strong { font-size: 10.5px; font-weight: 600; }
.rail-footer small { margin-top: 4px; color: var(--fg-faint); font: 9px/1 var(--font-mono); }
.engine-dot { width: 7px; height: 7px; flex: 0 0 auto; border-radius: 50%; background: var(--good); box-shadow: 0 0 0 4px rgba(99,212,156,.1), 0 0 14px rgba(99,212,156,.45); }

/* Workspace */
#chat-area { position: relative; display: flex; min-width: 0; flex-direction: column; overflow: hidden; background: var(--bg); }
#chat-area::before { content: ""; position: absolute; inset: 0; pointer-events: none; background: radial-gradient(circle at 50% -15%, rgba(255,107,53,.065), transparent 34%), linear-gradient(var(--bg-grid) 1px, transparent 1px), linear-gradient(90deg, var(--bg-grid) 1px, transparent 1px); background-size: auto, 36px 36px, 36px 36px; mask-image: linear-gradient(to bottom, #000 0, rgba(0,0,0,.35) 55%, transparent 92%); }
#chat-header, #messages, #composer { position: relative; z-index: 1; }
#chat-header { display: flex; align-items: center; gap: 14px; min-height: 76px; padding: 12px 26px; background: rgba(11,13,15,.76); border-bottom: 1px solid rgba(255,255,255,.055); backdrop-filter: blur(18px); }
#btn-menu { display: none; }
.header-copy { display: flex; min-width: 0; flex: 1; flex-direction: column; }
.header-eyebrow { color: var(--accent); font: 9px/1 var(--font-mono); letter-spacing: .15em; text-transform: uppercase; }
#chat-header h2 { overflow: hidden; margin: 5px 0 0; font-size: 14px; font-weight: 550; line-height: 1.25; text-overflow: ellipsis; white-space: nowrap; }
#chat-meta { color: var(--fg-faint); font: 9.5px/1 var(--font-mono); }
.secure-chip { display: flex; align-items: center; gap: 5px; padding: 6px 9px; color: var(--good); font: 9px/1 var(--font-mono); letter-spacing: .06em; text-transform: uppercase; background: rgba(99,212,156,.06); border: 1px solid rgba(99,212,156,.16); border-radius: 99px; }
.secure-chip svg { width: 12px; fill: none; stroke: currentColor; stroke-width: 1.2; }
#messages { flex: 1; overflow-y: auto; padding: 30px clamp(20px,4vw,64px); scroll-behavior: smooth; }

/* Welcome */
#welcome { max-width: 980px; margin: clamp(44px,8vh,96px) auto 40px; text-align: center; animation: reveal .55s ease both; }
@keyframes reveal { from { opacity: 0; transform: translateY(10px); } }
.welcome-kicker { display: inline-flex; align-items: center; gap: 8px; color: var(--fg-dim); font: 10px/1 var(--font-mono); letter-spacing: .1em; text-transform: uppercase; }
.welcome-kicker span { width: 17px; height: 1px; background: var(--accent); box-shadow: 0 0 8px var(--accent); }
#welcome h2 { margin: 22px 0 17px; font-family: var(--font-display); font-size: clamp(38px,5.1vw,68px); font-weight: 650; line-height: .98; letter-spacing: -.045em; }
#welcome h2 span { color: var(--fg-dim); font-weight: 420; }
#welcome > p { max-width: 690px; margin: 0 auto; color: var(--fg-dim); font-size: 13px; line-height: 1.7; }
.workflow { display: flex; align-items: center; justify-content: center; max-width: 680px; margin: 34px auto 38px; }
.workflow > div { display: flex; align-items: center; gap: 10px; text-align: left; }
.workflow b { color: var(--accent); font: 10px/1 var(--font-mono); }
.workflow span { display: flex; flex-direction: column; }
.workflow strong { font-size: 11px; font-weight: 600; letter-spacing: .03em; }
.workflow small { margin-top: 3px; color: var(--fg-faint); font-size: 9.5px; }
.workflow i { width: clamp(34px,6vw,78px); height: 1px; margin: 0 14px; background: linear-gradient(90deg, var(--border-bright), var(--accent), var(--border-bright)); opacity: .5; }
.examples { max-width: 900px; margin: 0 auto; }
.examples-label { margin-bottom: 11px; color: var(--fg-faint); font: 9px/1 var(--font-mono); letter-spacing: .14em; text-align: left; text-transform: uppercase; }
.example-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.example { display: grid; grid-template-columns: 34px 1fr auto; align-items: center; gap: 10px; min-width: 0; padding: 13px; color: var(--fg); text-align: left; background: linear-gradient(145deg, rgba(255,255,255,.04), rgba(255,255,255,.018)); border: 1px solid var(--border); border-radius: 11px; cursor: pointer; transition: .18s ease; }
.example:hover { border-color: rgba(255,107,53,.5); background: var(--accent-soft); transform: translateY(-2px); box-shadow: 0 12px 35px rgba(0,0,0,.2); }
.example-icon { display: grid; place-items: center; width: 34px; height: 34px; color: var(--accent); font-size: 16px; background: rgba(255,107,53,.08); border: 1px solid rgba(255,107,53,.15); border-radius: 8px; }
.example > span:nth-child(2) { display: flex; min-width: 0; flex-direction: column; }
.example strong { font-size: 11.5px; font-weight: 600; }
.example small { overflow: hidden; margin-top: 3px; color: var(--fg-faint); font-size: 9.5px; text-overflow: ellipsis; white-space: nowrap; }
.example-arrow { color: var(--fg-faint); transition: .18s; }
.example:hover .example-arrow { color: var(--accent); transform: translateX(2px); }

/* Conversation */
.msg { max-width: 940px; margin: 0 auto 30px; animation: reveal .28s ease both; }
.msg.user { display: flex; justify-content: flex-end; }
.msg.user .bubble { max-width: 78%; padding: 12px 16px; white-space: pre-wrap; color: #f8f8f8; background: linear-gradient(145deg, #2b3035, #22272b); border: 1px solid #363d42; border-radius: 14px 14px 4px 14px; box-shadow: 0 9px 30px rgba(0,0,0,.12); }
.msg.assistant .bubble { color: var(--fg); }
.msg .role { display: flex; align-items: center; gap: 8px; margin-bottom: 9px; color: var(--fg-faint); font: 9px/1 var(--font-mono); letter-spacing: .12em; text-transform: uppercase; }
.role-avatar { display: grid; place-items: center; width: 27px; height: 27px; flex: 0 0 auto; color: var(--accent); border: 1px solid rgba(255,107,53,.24); border-radius: 8px; background: linear-gradient(145deg, rgba(255,107,53,.14), rgba(255,107,53,.035)); }
.role-avatar svg { width: 19px; height: 19px; fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linejoin: round; }

/* Shared cards */
.thinking { overflow: hidden; margin: 10px 0; background: rgba(17,20,23,.72); border: 1px solid var(--border); border-radius: 10px; }
.thinking-header { display: flex; align-items: center; gap: 10px; min-height: 43px; padding: 10px 13px; color: var(--fg-dim); font-size: 11px; cursor: pointer; user-select: none; transition: .15s; }
.thinking-header:hover { color: var(--fg); background: rgba(255,255,255,.022); }
.thinking-header .chev { color: var(--accent); font: 9px/1 var(--font-mono); transition: transform .18s; }
.thinking.open .thinking-header .chev { transform: rotate(90deg); }
.thinking-header .label { flex: 1; }
.thinking-header .badge, .status-pill { padding: 4px 7px; color: var(--fg-faint); font: 8.5px/1 var(--font-mono); background: var(--panel-3); border: 1px solid var(--border); border-radius: 99px; }
.thinking-body { max-height: 0; overflow: hidden; color: var(--fg-dim); transition: max-height .22s ease; }
.thinking.open .thinking-body { max-height: 6000px; padding: 13px 15px; border-top: 1px solid var(--border); }
.thinking-log { margin: 0; padding: 0; list-style: none; color: var(--fg-dim); font: 10px/1.5 var(--font-mono); }
.thinking-log li { display: flex; align-items: flex-start; gap: 10px; padding: 5px 0; }
.thinking-log li .step-badge { min-width: 74px; padding: 2px 5px; color: var(--fg-faint); text-align: center; white-space: nowrap; background: var(--panel-3); border-radius: 4px; }
.thinking-log li .step-badge.done { color: var(--good); background: rgba(99,212,156,.09); }
.thinking-log li .step-badge.error { color: var(--fail); background: rgba(240,114,114,.09); }
.status-pill.streaming { color: var(--accent); border-color: rgba(255,107,53,.2); background: var(--accent-soft); }
.status-pill.streaming::before { content: "● "; animation: pulse 1.2s infinite; }
@keyframes pulse { 50% { opacity: .3; } }
pre.json { overflow-x: auto; max-height: 400px; margin: 9px 0; padding: 13px; color: #cbd1d5; font: 10.5px/1.6 var(--font-mono); background: #090b0d; border: 1px solid var(--border); border-radius: 8px; }
.advice-card .label { color: var(--fg-faint); font: 8.5px/1 var(--font-mono); letter-spacing: .11em; text-transform: uppercase; }
.advice-card, .clarification-card, .build-failed-card { margin: 12px 0; padding: 14px 16px; background: var(--panel-2); border: 1px solid var(--border); border-left: 2px solid var(--accent); border-radius: 8px; }
.advice-card .label { margin-bottom: 7px; color: var(--accent); }
.clarification-card { border-left-color: var(--warn); background: rgba(244,188,98,.055); }
.build-failed-card { border-left-color: var(--fail); background: rgba(240,114,114,.05); }
.clarification-header { display: flex; align-items: center; gap: 8px; }
.clarification-icon, .clarification-title { color: var(--warn); }
.clarification-title { font-weight: 600; }
.clarification-msg { white-space: pre-wrap; }
.clarification-hint, .build-failed-detail { color: var(--fg-dim); font-size: 11px; }
.build-failed-detail summary { color: var(--fail); cursor: pointer; }
.build-failed-detail pre { overflow-x: auto; padding: 10px; white-space: pre-wrap; color: #e5aaaa; background: #110b0b; border-radius: 6px; }

.render-box { margin: 12px 0; padding: 10px; text-align: center; background: linear-gradient(145deg, #171b1e, #101315); border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--shadow); }
.render-box img { display: block; max-width: 100%; max-height: 520px; margin: 0 auto; background: #eef0ed; border-radius: 8px; }
.render-box .actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 7px; margin-top: 10px; }
.render-box a.btn-download, .render-box .btn-action { display: inline-block; padding: 7px 12px; color: var(--fg); font-size: 10px; text-decoration: none; background: var(--panel-3); border: 1px solid var(--border-bright); border-radius: 7px; cursor: pointer; }
.render-box a.btn-download:hover, .render-box .btn-action:hover { border-color: var(--accent); background: var(--accent-soft); }
.parts-list { margin-top: 11px; text-align: left; }
.parts-list-status { padding: 7px 2px; color: var(--fg-faint); font-size: 10px; }
.parts-list-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; color: var(--fg-faint); font: 8.5px/1 var(--font-mono); letter-spacing: .08em; text-transform: uppercase; }
.btn-zipall { padding: 6px 10px; color: #fff; font: 9px/1 var(--font-sans); text-decoration: none; text-transform: none; letter-spacing: 0; background: var(--accent); border-radius: 6px; }
.parts-list-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(165px,1fr)); gap: 7px; }
.part-card { display: flex; align-items: center; gap: 8px; min-width: 0; padding: 8px 9px; color: var(--fg); font-size: 10px; text-decoration: none; background: var(--panel-2); border: 1px solid var(--border); border-radius: 7px; transition: .15s; }
.part-card:hover { border-color: var(--accent); transform: translateY(-1px); }
.part-swatch, .viewer-swatch { width: 12px; height: 12px; flex: 0 0 auto; border: 1px solid rgba(255,255,255,.12); border-radius: 3px; }
.part-name { flex: 1; overflow: hidden; font: 9.5px/1 var(--font-mono); text-overflow: ellipsis; white-space: nowrap; }
.part-size, .part-dl { color: var(--fg-faint); font: 8.5px/1 var(--font-mono); }
.part-card:hover .part-dl { color: var(--accent); }
.findings-list { margin: 7px 0; padding: 0; list-style: none; }
.findings-list li { display: flex; align-items: flex-start; gap: 10px; padding: 8px 5px; border-bottom: 1px solid var(--border); }
.findings-list li:last-child { border: 0; }
.findings-list .status { padding: 3px 6px; font: 8px/1 var(--font-mono); border-radius: 4px; }
.findings-list .status.ok { color: var(--good); background: rgba(99,212,156,.1); } .findings-list .status.warn { color: var(--warn); background: rgba(244,188,98,.1); } .findings-list .status.fail { color: var(--fail); background: rgba(240,114,114,.1); }
.findings-list .check-name { color: var(--fg-dim); font: 9.5px/1.4 var(--font-mono); }
.findings-list .check-msg { margin-top: 3px; color: var(--fg); font-size: 10.5px; }
.viewer3d-host { position: relative; overflow: hidden; background: #0c0f11; border-radius: 8px; }
.viewer3d-host canvas { display: block; width: 100%; height: 500px; cursor: grab; }
.viewer3d-host canvas:active { cursor: grabbing; }
.viewer3d-legend { display: flex; flex-wrap: wrap; gap: 11px; padding: 9px 12px; color: var(--fg-dim); font-size: 10px; background: var(--panel); border-top: 1px solid var(--border); }
.viewer-leg { display: flex; align-items: center; gap: 6px; cursor: pointer; }
.viewer-leg input { margin: 0; accent-color: var(--accent); }

/* Composer */
#composer { width: 100%; max-width: 1040px; margin: 0 auto; padding: 10px 28px 22px; }
.composer-shell { padding: 5px 6px 6px 15px; background: rgba(23,27,31,.95); border: 1px solid var(--border-bright); border-radius: 14px; box-shadow: 0 18px 60px rgba(0,0,0,.35), inset 0 1px rgba(255,255,255,.025); transition: .18s; backdrop-filter: blur(14px); }
.composer-shell:focus-within { border-color: rgba(255,107,53,.58); box-shadow: 0 18px 60px rgba(0,0,0,.4), 0 0 0 3px rgba(255,107,53,.06); }
#input { display: block; width: 100%; min-height: 43px; max-height: 200px; padding: 9px 7px 3px 0; resize: none; color: var(--fg); font-size: 13px; background: transparent; border: 0; outline: 0; }
#input::placeholder { color: #737a80; }
.composer-bar { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.composer-bar > span { color: var(--fg-faint); font: 8.5px/1 var(--font-mono); }
kbd { padding: 2px 4px; font: inherit; background: var(--panel-3); border: 1px solid var(--border-bright); border-radius: 3px; }
#btn-send { display: flex; align-items: center; gap: 7px; height: 35px; padding: 0 13px; color: #fff; font-size: 10.5px; font-weight: 650; background: var(--accent); border: 0; border-radius: 9px; cursor: pointer; transition: .18s; }
#btn-send svg { width: 14px; fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linejoin: round; }
#btn-send:hover:not(:disabled) { background: var(--accent-bright); transform: translateY(-1px); box-shadow: 0 7px 22px rgba(255,107,53,.2); }
#btn-send:disabled { color: var(--fg-faint); background: var(--panel-3); cursor: not-allowed; }

::-webkit-scrollbar { width: 7px; height: 7px; } ::-webkit-scrollbar-track { background: transparent; } ::-webkit-scrollbar-thumb { background: #30363b; border-radius: 10px; } ::-webkit-scrollbar-thumb:hover { background: #434b51; }
#sidebar-backdrop { display: none; position: fixed; inset: 0; z-index: 90; background: rgba(0,0,0,.72); backdrop-filter: blur(3px); }
#sidebar-backdrop.active { display: block; }

@media (max-width: 900px) {
  .example-grid { grid-template-columns: 1fr; max-width: 580px; margin: 0 auto; }
  .examples-label { max-width: 580px; margin-right: auto; margin-left: auto; }
  #welcome { margin-top: 40px; }
}
@media (max-width: 768px) {
  html, body { width: 100%; max-width: 100%; overflow: hidden; }
  #app { grid-template-columns: 1fr; }
  #sidebar { position: fixed; inset: 0 auto 0 0; z-index: 100; width: 280px; max-width: 86vw; box-shadow: 15px 0 50px rgba(0,0,0,.45); transform: translateX(-100%); transition: transform .24s ease; }
  #sidebar.open { transform: translateX(0); }
  #btn-menu { display: grid; flex: 0 0 auto; }
  #chat-header { min-height: 64px; padding: 9px 13px; }
  #chat-meta, .secure-chip { display: none; }
  .header-eyebrow { font-size: 8px; }
  #chat-area, #messages, #composer, #welcome, .examples, .example-grid, .composer-shell { width: 100%; max-width: 100%; min-width: 0; }
  #messages { padding: 20px 12px; overflow-x: hidden; }
  #welcome { margin: 28px auto; }
  #welcome h2 { margin-top: 17px; font-size: clamp(32px,10.5vw,48px); overflow-wrap: anywhere; }
  #welcome > p { font-size: 12px; }
  .welcome-kicker { max-width: 100%; white-space: normal; }
  .desktop-only { display: none; }
  .workflow { width: 100%; min-width: 0; margin: 27px auto 30px; }
  .workflow > div { min-width: 0; }
  .workflow i { width: 20px; margin: 0 7px; }
  .workflow small { display: none; }
  .example-grid { gap: 7px; }
  .example { padding: 10px; }
  .msg { margin-bottom: 22px; }
  .msg.user .bubble { max-width: 90%; font-size: 13px; }
  .viewer3d-host canvas { height: 320px; }
  #composer { padding: 8px 10px 12px; }
  .composer-shell { padding-left: 12px; }
  #input { min-height: 41px; font-size: 16px; }
  .composer-bar > span { display: none; }
  .composer-bar { justify-content: flex-end; }
}
@media (max-width: 420px) {
  .welcome-kicker { font-size: 8px; letter-spacing: .06em; }
  #welcome h2 { font-size: 35px; }
  .workflow { justify-content: space-between; }
  .workflow i { flex: 1; }
  .workflow strong { font-size: 9.5px; }
  .example-icon { width: 31px; height: 31px; }
  .parts-list-grid { grid-template-columns: 1fr; }
  #btn-send span { display: none; }
  #btn-send { padding: 0 11px; }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; transition-duration: .01ms !important; } }
