:root {
  color-scheme: dark;
  --bg: #080908;
  --surface: #111311;
  --surface-2: #171a17;
  --surface-3: #1d211d;
  --edge: #2d332e;
  --edge-soft: #222722;
  --text: #f3f3ee;
  --muted: #8f978f;
  --green: #a9b88f;
  --green-strong: #c3d3a5;
  --forest: #263c2f;
  --forest-2: #1b2c23;
  --amber: #efb65b;
  --danger: #e4776c;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  font-family: "SF Pro Display", "PingFang SC", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--bg); color: var(--text); font-size: 14px;
}
button, input, select, textarea { font: inherit; }
button { color: inherit; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.error { color: var(--danger); min-height: 18px; margin: 4px 0 0; font-size: 12px; line-height: 1.5; }

.login-shell { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: radial-gradient(circle at 50% 25%, #172119 0, var(--bg) 42%); }
.login-card { width: min(420px, 100%); padding: 40px; border-radius: 24px; background: rgba(17,19,17,.94); border: 1px solid var(--edge); box-shadow: 0 30px 80px #0009; text-align: center; }
.brand-mark { width: 58px; height: 58px; border-radius: 50%; display: grid; place-items: center; margin: 0 auto 20px; border: 1px solid #71806d; color: var(--green-strong); font: 600 16px/1 ui-monospace; letter-spacing: .08em; background: #1b261e; }
.brand-mark.small { width: 38px; height: 38px; margin: 0; font-size: 11px; }
.eyebrow { margin: 0 0 5px; color: var(--green); font: 600 10px/1.2 ui-monospace; letter-spacing: .16em; }
h1, h2, h3, p { margin-top: 0; }
.login-card h1 { margin-bottom: 8px; font-size: 26px; }
.login-card .muted { margin-bottom: 30px; }

.app-shell { min-height: 100vh; }
.topbar { height: 72px; padding: 0 24px; border-bottom: 1px solid var(--edge-soft); display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; position: sticky; top: 0; z-index: 20; background: rgba(8,9,8,.9); backdrop-filter: blur(20px); }
.brand { display: flex; align-items: center; gap: 12px; }
.brand h1 { margin: 0; font-size: 15px; font-weight: 650; }
.tabs { display: flex; gap: 5px; padding: 4px; border-radius: 999px; background: var(--surface); border: 1px solid var(--edge-soft); }
.tab { padding: 8px 18px; border: 0; border-radius: 999px; background: transparent; color: var(--muted); cursor: pointer; }
.tab.active { background: var(--surface-3); color: var(--text); box-shadow: inset 0 0 0 1px var(--edge); }
.top-actions { justify-self: end; display: flex; align-items: center; gap: 12px; }
.status-dot { color: var(--muted); font-size: 12px; display: flex; align-items: center; gap: 7px; }
.status-dot i { width: 7px; height: 7px; border-radius: 50%; background: var(--amber); box-shadow: 0 0 12px #efb65b88; }
.status-dot.ready i { background: #75a884; box-shadow: 0 0 12px #75a88488; }

.button, .icon-button { border: 1px solid var(--edge); background: var(--surface-2); border-radius: 9px; min-height: 38px; padding: 0 14px; cursor: pointer; transition: .18s ease; }
.button:hover:not(:disabled), .icon-button:hover:not(:disabled) { border-color: #697268; transform: translateY(-1px); }
.button.primary { color: #0d130f; border-color: #a4b68d; background: var(--green-strong); font-weight: 650; }
.button.ghost { background: transparent; }
.button.ghost.active { color: var(--green-strong); border-color: #65765f; background: #172019; }
.button.danger { color: var(--danger); }
.button.wide { width: 100%; }
.button:disabled, .icon-button:disabled { opacity: .38; cursor: not-allowed; }
.icon-button { width: 38px; padding: 0; font-size: 19px; }

.studio-page { min-height: calc(100vh - 72px); display: grid; grid-template-columns: 300px minmax(440px, 1fr) 340px; }
.rail { padding: 24px 20px; background: var(--surface); }
.upload-rail { border-right: 1px solid var(--edge-soft); }
.detail-rail { min-width: 0; overflow: hidden; border-left: 1px solid var(--edge-soft); }
.section-title { display: flex; gap: 11px; align-items: flex-start; margin-bottom: 20px; }
.section-title .step { width: 24px; height: 24px; flex: 0 0 auto; display: grid; place-items: center; border-radius: 50%; background: var(--forest); color: var(--green-strong); font: 600 11px ui-monospace; }
.section-title h2 { font-size: 15px; margin: 1px 0 3px; }
.section-title p { margin: 0; color: var(--muted); font-size: 11px; line-height: 1.5; }

.dropzone { position: relative; min-height: 240px; border: 1px dashed #465046; border-radius: 14px; display: grid; place-items: center; overflow: hidden; background: #0c0e0c; cursor: pointer; transition: .2s ease; }
.dropzone:hover, .dropzone.dragover { border-color: var(--green); background: #111711; }
.dropzone input { position: absolute; opacity: 0; pointer-events: none; }
.drop-empty { text-align: center; color: var(--muted); display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 24px; }
.drop-empty strong { color: var(--text); font-size: 13px; }
.drop-empty span { font-size: 10px; }
.upload-icon { width: 42px; height: 42px; display: grid; place-items: center; border-radius: 50%; background: var(--forest-2); color: var(--green-strong); font-size: 22px; margin-bottom: 5px; }
.source-thumb { width: 100%; height: 240px; object-fit: contain; background: #080908; }
.remove-photo { position: absolute; right: 10px; top: 10px; width: 28px; height: 28px; border-radius: 50%; border: 1px solid #ffffff33; background: #080908cc; color: white; cursor: pointer; }

.field { display: flex; flex-direction: column; gap: 7px; color: var(--muted); font-size: 11px; margin-top: 14px; }
.field input, .field select, .field textarea, select { width: 100%; color: var(--text); background: var(--surface-2); border: 1px solid var(--edge); border-radius: 9px; padding: 10px 11px; outline: none; resize: vertical; }
.field input:focus, .field select:focus, .field textarea:focus { border-color: #71806d; box-shadow: 0 0 0 3px #71806d20; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.model-note { display: flex; gap: 9px; margin: 12px 0 16px; padding: 10px; border-radius: 9px; color: var(--muted); background: #141814; font-size: 10px; line-height: 1.5; }
.model-note span { color: var(--green-strong); }
.model-note p { min-width: 0; margin: 0; overflow-wrap: anywhere; }
.progress-card { display: flex; align-items: center; gap: 12px; margin-top: 13px; padding: 12px; border-radius: 10px; background: var(--forest-2); }
.progress-card strong { font-size: 12px; }
.progress-card p { margin: 3px 0 0; color: var(--muted); font-size: 10px; }
.spinner { width: 22px; height: 22px; border: 2px solid #61705e55; border-top-color: var(--green-strong); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.orientation-explainer { margin-top: 24px; padding-top: 18px; border-top: 1px solid var(--edge-soft); }
.orientation-explainer > strong { font-size: 11px; color: var(--muted); }
.orientation-explainer > div { display: grid; grid-template-columns: 30px 1fr; gap: 9px; margin-top: 12px; align-items: start; }
.orientation-explainer span { width: 28px; height: 22px; display: grid; place-items: center; border-radius: 6px; background: var(--surface-3); color: var(--green); font-size: 10px; }
.orientation-explainer p { margin: 2px 0 0; font-size: 10px; color: var(--muted); line-height: 1.45; }

.workspace { min-width: 0; padding: 24px; display: flex; flex-direction: column; background: radial-gradient(circle at 50% 45%, #151815 0, #0b0c0b 52%, #080908 100%); }
.workspace-head { display: flex; justify-content: space-between; align-items: flex-start; }
.canvas-actions { display: flex; gap: 7px; }
.empty-workspace { flex: 1; display: grid; place-content: center; justify-items: center; text-align: center; color: var(--muted); padding: 40px; }
.empty-workspace h3 { margin: 22px 0 8px; color: var(--text); font-size: 16px; }
.empty-workspace p { max-width: 380px; font-size: 12px; line-height: 1.7; }
.empty-orbit { width: 82px; height: 82px; border: 1px solid #455046; border-radius: 50%; display: grid; place-items: center; position: relative; color: var(--green-strong); }
.empty-orbit::before, .empty-orbit::after { content: ""; position: absolute; inset: 10px -8px; border: 1px solid #455046; border-radius: 50%; transform: rotate(35deg); }
.empty-orbit::after { transform: rotate(-35deg); }
.canvas-workspace { flex: 1; min-height: 0; display: flex; flex-direction: column; align-items: center; }
.aspect-tabs { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; margin-bottom: 14px; }
.aspect-tab { border: 1px solid var(--edge); background: var(--surface); color: var(--muted); border-radius: 8px; padding: 7px 11px; cursor: pointer; }
.aspect-tab.active { color: var(--green-strong); border-color: #6a7964; background: #192019; }
.aspect-tab small { margin-left: 5px; opacity: .7; }
.canvas-stage { flex: 1; min-height: 300px; width: 100%; position: relative; display: grid; place-items: center; }
#preview, #libraryPreview { max-width: 100%; max-height: calc(100vh - 260px); border-radius: 10px; border: 1px solid #3a403a; background: #161916; touch-action: none; box-shadow: 0 24px 70px #0009; }
.canvas-badge { position: absolute; left: 50%; top: 18px; transform: translateX(-50%); padding: 6px 10px; border-radius: 999px; background: #050605b8; color: var(--text); font-size: 10px; pointer-events: none; backdrop-filter: blur(8px); }
.legend { display: flex; justify-content: center; gap: 18px; margin-top: 13px; color: var(--muted); font-size: 10px; }
.legend span { display: flex; align-items: center; gap: 6px; }
.legend i { width: 20px; height: 0; border-top: 2px solid white; display: inline-block; }
.legend i.dash { border-top-style: dashed; }
.legend i.line { opacity: .55; }
.legend i.dot { width: 7px; height: 7px; border: 1px solid white; border-radius: 50%; }

.empty-details { min-height: 230px; display: grid; place-content: center; text-align: center; border: 1px dashed var(--edge); border-radius: 12px; color: var(--muted); }
.empty-details p { max-width: 220px; margin: 6px auto 0; font-size: 10px; line-height: 1.5; }
.detail-form .field { margin-top: 11px; }
.summary-card, .recommendation-card { margin-top: 13px; border: 1px solid var(--edge); background: var(--surface-2); border-radius: 10px; padding: 12px; }
.summary-card > div, .recommendation-card > div { display: flex; justify-content: space-between; align-items: center; }
.summary-card span, .recommendation-card span { color: var(--muted); font-size: 10px; }
.summary-card strong { color: var(--green-strong); font-size: 12px; }
.summary-card p, .recommendation-card p { margin: 7px 0 0; color: var(--muted); font-size: 10px; line-height: 1.45; overflow-wrap: anywhere; word-break: break-word; }
.recommendation-card { background: var(--forest-2); border-color: #34483b; }
.recommendation-card strong { font-size: 12px; }
.recommendation-card b { color: var(--amber); font-size: 18px; }
.manual-parameter-grid { display: grid !important; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 12px; align-items: end; }
.manual-parameter-grid label, .box-coordinate-grid label { display: flex; min-width: 0; flex-direction: column; gap: 5px; color: var(--muted); font-size: 9px; }
.manual-parameter-grid input, .box-coordinate-grid input { width: 100%; min-width: 0; color: var(--text); background: #111611; border: 1px solid var(--edge); border-radius: 7px; padding: 8px; outline: none; }
.manual-parameter-grid input:focus, .box-coordinate-grid input:focus { border-color: #71806d; box-shadow: 0 0 0 3px #71806d20; }
.manual-parameter-grid .button { min-height: 33px; padding-inline: 8px; font-size: 10px; }
.box-editor { margin-top: 13px; padding: 12px; border: 1px solid #4a594b; border-radius: 10px; background: #151a15; }
.box-editor .subhead { margin-bottom: 4px; }
.box-editor > p { margin: 0 0 10px; color: var(--muted); font-size: 9px; line-height: 1.5; }
.box-coordinate-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
.guide-editor { margin-top: 18px; }
.subhead { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.subhead h3 { font-size: 12px; margin: 0; }
.subhead span { font-size: 9px; color: var(--green); border: 1px solid #415347; padding: 2px 6px; border-radius: 999px; }
.guide-step { display: grid; grid-template-columns: 25px 1fr; gap: 8px; padding: 8px 0; border-bottom: 1px solid var(--edge-soft); }
.guide-step { border-radius: 8px; transition: background .16s ease, box-shadow .16s ease; }
.guide-step.active { background: #2b2418; box-shadow: inset 3px 0 #efb65b; }
.guide-step > span { width: 23px; height: 23px; display: grid; place-items: center; border-radius: 6px; background: var(--forest); color: var(--green-strong); font: 600 10px ui-monospace; }
.guide-step > div { min-width: 0; }
.guide-step input, .guide-step textarea { display: block; width: 100%; min-width: 0; border: 0; border-bottom: 1px solid transparent; background: transparent; color: var(--text); padding: 2px 0; font-size: 11px; line-height: 1.45; outline: none; }
.guide-step textarea { min-height: 34px; color: var(--muted); font-size: 10px; resize: none; overflow: hidden; overflow-wrap: anywhere; word-break: break-word; }
.guide-step input:focus, .guide-step textarea:focus { border-color: #60705f; }
.warnings-card { margin-top: 13px; padding: 10px 12px; border-radius: 9px; border: 1px solid #7c6034; background: #241d13; color: #e4bd7e; font-size: 10px; }
.warnings-card ul { padding-left: 16px; margin: 7px 0 0; line-height: 1.5; }
.validation-card { display: flex; gap: 10px; margin-top: 14px; padding: 10px; border-radius: 9px; background: var(--surface-2); border: 1px solid var(--edge); }
.validation-card.valid { border-color: #3e5948; background: #17221b; }
.validation-card.invalid { border-color: #744039; background: #251716; }
.validation-card > span { color: var(--green); }
.validation-card strong { font-size: 11px; }
.validation-card p { margin: 3px 0 0; color: var(--muted); font-size: 9px; line-height: 1.4; }
.detail-actions { display: grid; grid-template-columns: 1fr 1fr 1.35fr; gap: 8px; margin-top: 13px; }

.library-page { padding: 20px; display: grid; grid-template-columns: 280px 1fr; gap: 16px; align-items: start; }
.panel { background: var(--surface); border: 1px solid var(--edge-soft); border-radius: 14px; padding: 16px; }
.library-list { position: sticky; top: 92px; max-height: calc(100vh - 112px); overflow: auto; }
.library-head, .editor-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; }
.library-head h2, .editor-head h2 { font-size: 17px; margin: 0; }
#list .item { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 11px; border-radius: 9px; cursor: pointer; }
#list .item:hover, #list .item.active { background: var(--surface-2); }
#list .meta { margin-top: 4px; color: var(--muted); font-size: 9px; }
.badge { flex: 0 0 auto; padding: 3px 7px; border: 1px solid var(--edge); border-radius: 999px; color: var(--muted); font-size: 9px; }
.badge.published { color: var(--green-strong); border-color: #4c624f; }
.badge.draft { color: var(--amber); border-color: #69512c; }
.editor-grid { display: grid; grid-template-columns: minmax(420px, 1fr) 420px; gap: 18px; }
.form-col textarea { min-height: 430px; font: 11px/1.55 ui-monospace, SFMono-Regular, Menlo, monospace; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.legacy-preview { display: flex; flex-direction: column; gap: 10px; }
.preview-tools { display: flex; align-items: center; gap: 8px; font-size: 10px; }
.preview-tools select { width: auto; }
.library-empty { display: grid; place-content: center; min-height: 420px; text-align: center; color: var(--muted); }
.library-empty h3 { color: var(--text); margin-bottom: 7px; }

@media (max-width: 1180px) {
  .studio-page { grid-template-columns: 270px 1fr; }
  .detail-rail { grid-column: 1 / -1; border-left: 0; border-top: 1px solid var(--edge-soft); }
  .detail-form { display: grid; grid-template-columns: repeat(2, 1fr); gap: 0 14px; }
  .guide-editor, .warnings-card, .validation-card, .detail-actions { grid-column: 1 / -1; }
}
@media (max-width: 820px) {
  .topbar { grid-template-columns: 1fr auto; }
  .tabs { order: 3; grid-column: 1 / -1; margin: 8px auto; }
  .topbar { height: auto; padding-block: 10px; }
  .status-dot { display: none; }
  .studio-page { grid-template-columns: 1fr; }
  .upload-rail, .detail-rail { border: 0; border-bottom: 1px solid var(--edge-soft); }
  .workspace { min-height: 650px; }
  .library-page { grid-template-columns: 1fr; }
  .library-list { position: static; max-height: 280px; }
  .editor-grid { grid-template-columns: 1fr; }
}
