/* Structure Generator v3: the tool's own styles, scoped to the tool. The dev
   preview and the live site's panel load this same file; page-wide rules for
   the preview pages are in page.css. */

/* Site tokens (public/css/app.css), set on the tool itself so the live page's
   own tokens are never changed. */
:where(.sg-page, .sg-app, .sg-mobile) {
  --indus-purple: #A855F7;
  --indus-purple-dark: #2E1065;
  --text-main: #E8E8EC;
  --text-soft: #8888A0;
  --bg-dark: #08080B;
  --bg-panel: rgba(255, 255, 255, 0.025);
  --border-soft: rgba(255, 255, 255, 0.06);
  --border-strong: rgba(168, 85, 247, 0.75);
  --status-success: #1bff6b;
  --status-error: #ff6b6b;
  --status-warning: #ffb86b;
  --radius-sm: 0.5rem;
  --radius-md: 0.75rem;
  --radius-lg: 1rem;
  --radius-full: 999px;
  --clash: 'Clash Grotesk', system-ui, -apple-system, sans-serif;
  --mono: 'JetBrains Mono', ui-monospace, monospace;
  --ease: cubic-bezier(.2, .8, .2, 1);
}

.sg-app, .sg-app *, .sg-app *::before, .sg-app *::after, .sg-mobile { box-sizing: border-box; }
.sg-app, .sg-mobile { background: var(--bg-dark); color: var(--text-main); font: 14px/1.45 var(--clash); }
.sg-app button { font: inherit; color: inherit; }
.sg-app[hidden], .sg-app [hidden], .sg-mobile[hidden] { display: none !important; }

.sg-app { display: grid; grid-template: "head head head" auto "left stage right" 1fr "foot foot foot" auto / var(--sg-side, 300px) 1fr var(--sg-side, 300px); }
/* Inside the live site's panel: fills the panel beside the site's sidebar. */
.sg-app.sg-embedded { height: 100%; --sg-side: 280px; }
.sg-header { grid-area: head; display: flex; align-items: center; justify-content: space-between; padding: 12px 18px; border-bottom: 1px solid var(--border-soft); }
.sg-brand { display: flex; align-items: center; gap: 10px; font-weight: 600; letter-spacing: 0.02em; }
.sg-badge { font: 11px var(--mono); color: var(--text-soft); border: 1px solid var(--border-soft); border-radius: var(--radius-full); padding: 2px 8px; }
.sg-header-note { color: var(--text-soft); font-size: 12px; }
.sg-panel { overflow-y: auto; padding: 16px; border-color: var(--border-soft); border-style: solid; border-width: 0; }
.sg-left { grid-area: left; border-right-width: 1px; }
/* Right panel: the cards scroll, the download stays pinned at the bottom. */
.sg-right { grid-area: right; border-left-width: 1px; display: flex; flex-direction: column; padding: 0; overflow: hidden; }
.sg-right-scroll { flex: 1; min-height: 0; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 12px; }
.sg-export { flex: none; padding: 12px 16px 14px; border-top: 1px solid var(--border-soft); background: var(--bg-dark); box-shadow: 0 -10px 20px -12px rgba(0, 0, 0, .8); }
.sg-export .sg-button { width: 100%; padding: 11px 14px; }
.sg-export .sg-notes { margin-top: 8px; font-size: 11.5px; }
.sg-footer { grid-area: foot; padding: 6px 18px; font-size: 10.5px; color: var(--text-soft); border-top: 1px solid var(--border-soft); letter-spacing: 0.02em; }

/* Controls */
.sg-controls { display: flex; flex-direction: column; gap: 18px; }
.sg-group-title { font-size: 11px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--text-soft); margin: 6px 0 -6px; }
.sg-field { display: flex; flex-direction: column; gap: 8px; position: relative; }
.sg-field-row { flex-direction: row; align-items: center; justify-content: space-between; gap: 12px; }
.sg-field-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.sg-label { font-weight: 600; font-size: 13px; }
.sg-value { font: 12px var(--mono); color: var(--indus-purple); }
.sg-field-note { font-size: 12px; color: var(--text-soft); min-height: 1em; }
.sg-field.is-changed .sg-label { text-shadow: 0 0 10px rgba(168, 85, 247, .9); transition: text-shadow 0s; }
.sg-field .sg-label { transition: text-shadow .9s var(--ease); }

.sg-slider { position: relative; height: 28px; cursor: pointer; touch-action: none; outline: none; }
.sg-slider-rail { position: absolute; inset: 0 9px; }
.sg-slider-track { position: absolute; left: 0; right: 0; top: 12px; height: 4px; border-radius: 4px; background: rgba(255, 255, 255, .09); overflow: hidden; }
.sg-slider-fill { height: 100%; background: linear-gradient(90deg, var(--indus-purple-dark), var(--indus-purple)); }
.sg-slider-ticks span { position: absolute; top: 19px; width: 1px; height: 4px; background: rgba(255, 255, 255, .18); transform: translateX(-.5px); }
.sg-slider-thumb { position: absolute; top: 5px; width: 18px; height: 18px; margin-left: -9px; border-radius: 50%; background: #fff; box-shadow: 0 0 0 3px rgba(168, 85, 247, .35), 0 2px 8px rgba(0, 0, 0, .6); transition: box-shadow .2s var(--ease), transform .15s var(--ease); }
.sg-slider:focus-visible .sg-slider-thumb, .sg-slider.is-dragging .sg-slider-thumb { box-shadow: 0 0 0 5px rgba(168, 85, 247, .55), 0 2px 10px rgba(0, 0, 0, .6); transform: scale(1.08); }
.sg-slider-bubble { position: absolute; bottom: 26px; left: 50%; transform: translate(-50%, 4px); padding: 2px 7px; border-radius: 6px; background: var(--indus-purple); color: #fff; font: 11px var(--mono); white-space: nowrap; opacity: 0; pointer-events: none; transition: opacity .15s, transform .15s var(--ease); }
.sg-slider.is-dragging .sg-slider-bubble, .sg-slider:focus-visible .sg-slider-bubble { opacity: 1; transform: translate(-50%, 0); }

.sg-segmented { display: flex; padding: 3px; gap: 3px; border-radius: var(--radius-sm); background: rgba(255, 255, 255, .04); border: 1px solid var(--border-soft); }
.sg-segment { flex: 1; border: 0; background: transparent; padding: 6px 4px; border-radius: 6px; cursor: pointer; color: var(--text-soft); font-size: 12.5px; transition: background .18s var(--ease), color .18s; }
.sg-segment[aria-checked="true"] { background: var(--indus-purple); color: #fff; box-shadow: 0 2px 10px rgba(168, 85, 247, .35); }
.sg-segment:focus-visible, .sg-switch:focus-visible, .sg-dropdown-button:focus-visible, .sg-button:focus-visible, .sg-chip:focus-visible, .sg-disclosure:focus-visible { outline: 2px solid var(--indus-purple); outline-offset: 2px; }

.sg-switch { flex: none; width: 44px; height: 24px; border-radius: var(--radius-full); border: 1px solid var(--border-soft); background: rgba(255, 255, 255, .08); position: relative; cursor: pointer; transition: background .2s var(--ease); }
.sg-switch-knob { position: absolute; top: 2px; left: 2px; width: 18px; height: 18px; border-radius: 50%; background: #fff; transition: transform .22s var(--ease); }
.sg-switch[aria-checked="true"] { background: var(--indus-purple); }
.sg-switch[aria-checked="true"] .sg-switch-knob { transform: translateX(20px); }

.sg-dropdown-button { width: 100%; display: flex; align-items: center; justify-content: space-between; padding: 9px 12px; border-radius: var(--radius-sm); border: 1px solid var(--border-soft); background: rgba(255, 255, 255, .04); cursor: pointer; text-align: left; }
.sg-dropdown-caret { width: 8px; height: 8px; border-right: 2px solid var(--text-soft); border-bottom: 2px solid var(--text-soft); transform: rotate(45deg) translateY(-2px); }
.sg-dropdown-list { position: absolute; z-index: 20; top: 100%; left: 0; right: 0; margin: 6px 0 0; padding: 4px; list-style: none; border-radius: var(--radius-sm); border: 1px solid var(--border-strong); background: #14121c; box-shadow: 0 12px 40px rgba(0, 0, 0, .6); outline: none; }
.sg-dropdown-option { padding: 8px 10px; border-radius: 6px; cursor: pointer; display: flex; flex-direction: column; }
.sg-dropdown-option.is-active, .sg-dropdown-option:hover { background: rgba(168, 85, 247, .18); }
.sg-dropdown-option[aria-selected="true"] .sg-option-label { color: var(--indus-purple); }
.sg-option-note { font-size: 11.5px; color: var(--text-soft); }

.sg-button { border: 0; border-radius: var(--radius-sm); padding: 9px 14px; background: var(--indus-purple); color: #fff; font-weight: 600; cursor: pointer; transition: filter .15s, transform .1s; }
.sg-button:hover { filter: brightness(1.1); }
.sg-button:active { transform: translateY(1px); }
.sg-button.sg-ghost { background: rgba(255, 255, 255, .06); color: var(--text-main); font-weight: 400; }
.sg-button[disabled] { opacity: .5; cursor: default; }
.sg-seed { display: flex; gap: 8px; align-items: center; }
.sg-seed-value { flex: 1; font: 13px var(--mono); padding: 8px 10px; border-radius: var(--radius-sm); border: 1px solid var(--border-soft); background: rgba(255, 255, 255, .03); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sg-dice { width: 38px; height: 36px; padding: 0; display: grid; place-items: center; }
.sg-dice svg { width: 20px; height: 20px; }
.sg-dice.is-rolling svg { animation: sg-roll .5s var(--ease); }
@keyframes sg-roll { from { transform: rotate(0) scale(1); } 50% { transform: rotate(200deg) scale(1.2); } to { transform: rotate(360deg) scale(1); } }
.sg-locks { display: flex; flex-direction: column; gap: 6px; }
.sg-locks-label { font-size: 11.5px; color: var(--text-soft); }
.sg-lock-row { display: flex; gap: 6px; }
.sg-lock { flex: 1; min-width: 0; display: inline-flex; align-items: center; justify-content: center; gap: 4px; border: 1px solid var(--border-soft); background: rgba(255, 255, 255, .03); border-radius: var(--radius-full); padding: 5px 6px; font-size: 12px; white-space: nowrap; cursor: pointer; color: var(--text-soft); transition: color .15s, border-color .15s, background .18s var(--ease), box-shadow .18s var(--ease); }
.sg-lock svg { width: 12px; height: 12px; flex: none; }
.sg-lock:hover { color: var(--text-main); border-color: var(--border-strong); }
.sg-lock[aria-pressed="true"] { background: var(--indus-purple); border-color: var(--indus-purple); color: #fff; box-shadow: 0 2px 10px rgba(168, 85, 247, .35); }
.sg-lock[disabled] { opacity: .38; cursor: not-allowed; border-color: var(--border-soft); color: var(--text-soft); }
.sg-lock:focus-visible { outline: 2px solid var(--indus-purple); outline-offset: 2px; }

/* Stage */
.sg-stage { grid-area: stage; display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.sg-viewport { position: relative; flex: 1; min-height: 0; background: radial-gradient(120% 90% at 50% 10%, #1d2235 0%, #11131c 55%, #08080b 100%); overflow: hidden; }
.sg-viewport canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.sg-plan { background: #0d0e14; cursor: grab; }
.sg-sweep { position: absolute; inset: 0; pointer-events: none; opacity: 0; background: linear-gradient(100deg, transparent 0%, rgba(168, 85, 247, 0) 35%, rgba(168, 85, 247, .22) 50%, rgba(168, 85, 247, 0) 65%, transparent 100%); background-size: 250% 100%; transition: opacity .25s; }
.sg-viewport.is-generating .sg-sweep { opacity: 1; animation: sg-sweep 1.1s linear infinite; }
@keyframes sg-sweep { from { background-position: 125% 0; } to { background-position: -125% 0; } }
.sg-status { position: absolute; left: 14px; bottom: 12px; font: 12px var(--mono); color: var(--text-soft); background: rgba(8, 8, 11, .6); padding: 4px 8px; border-radius: 6px; pointer-events: none; }
.sg-crosshair { position: absolute; left: 50%; top: 50%; width: 14px; height: 14px; margin: -7px 0 0 -7px; pointer-events: none; }
.sg-crosshair::before, .sg-crosshair::after { content: ""; position: absolute; background: rgba(255, 255, 255, .85); }
.sg-crosshair::before { left: 6px; top: 0; width: 2px; height: 14px; }
.sg-crosshair::after { top: 6px; left: 0; width: 14px; height: 2px; }
.sg-hud { position: absolute; left: 50%; top: calc(50% + 18px); transform: translateX(-50%); font-size: 12.5px; padding: 3px 10px; border-radius: 6px; background: rgba(8, 8, 11, .7); pointer-events: none; white-space: nowrap; }
.sg-walk-help { position: absolute; left: 50%; top: 14px; transform: translateX(-50%); font-size: 12px; color: var(--text-soft); background: rgba(8, 8, 11, .7); padding: 4px 10px; border-radius: 6px; pointer-events: none; }
.sg-plan-bar { position: absolute; top: 12px; left: 12px; display: flex; align-items: center; gap: 6px; padding: 6px; border-radius: var(--radius-sm); background: rgba(8, 8, 11, .75); border: 1px solid var(--border-soft); }
.sg-plan-step { width: 28px; height: 28px; border-radius: 6px; border: 1px solid var(--border-soft); background: rgba(255, 255, 255, .04); cursor: pointer; }
.sg-plan-step[disabled] { opacity: .35; cursor: default; }
.sg-plan-floor { min-width: 110px; text-align: center; font-weight: 600; font-size: 13px; }
.sg-viewbar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; padding: 10px 14px; border-top: 1px solid var(--border-soft); }
.sg-viewbar .sg-segmented { width: 270px; }
/* The in-game look (v0.3.0): a switch beside the views; while it is on, the time of day floats
   at the top left of the view (where the floorplan's floor stepper goes), the walk help below it. */
.sg-look { display: flex; align-items: center; }
.sg-look .sg-field-row { gap: 10px; }
.sg-look .sg-label { white-space: nowrap; font-weight: 500; color: var(--text-soft); }
.sg-look .sg-field-row:has(.sg-switch[aria-checked="true"]) .sg-label { color: var(--text-main); }
.sg-look.is-loading .sg-switch { opacity: .55; cursor: progress; }
.sg-time-bar { position: absolute; top: 12px; left: 12px; padding: 4px; border-radius: var(--radius-sm); background: rgba(8, 8, 11, .75); border: 1px solid var(--border-soft); }
.sg-time-bar .sg-segmented { width: 250px; background: transparent; border: 0; padding: 0; }
.sg-viewport.has-time-bar .sg-walk-help { top: 58px; }
/* The camera presets keep their chips on one line: on a narrow bar they move to a row of their own. */
.sg-presets { display: flex; gap: 6px; flex: 1 0 auto; }
.sg-chip { border: 1px solid var(--border-soft); background: rgba(255, 255, 255, .03); border-radius: var(--radius-full); padding: 4px 11px; font-size: 12.5px; cursor: pointer; color: var(--text-soft); transition: color .15s, border-color .15s; }
.sg-chip:hover { color: var(--text-main); border-color: var(--border-strong); }
.sg-chip[aria-pressed="false"] { opacity: .45; text-decoration: line-through; }

/* Right panel */
.sg-card { border: 1px solid var(--border-soft); background: var(--bg-panel); border-radius: var(--radius-md); padding: 12px 14px; }
.sg-card h2 { margin: 0 0 10px; font-size: 12px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--text-soft); font-weight: 600; }
.sg-stats { margin: 0; display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.sg-stats dt { font-size: 11px; color: var(--text-soft); }
.sg-stats dd { margin: 0; font: 13px var(--mono); }
.sg-notes { margin: 10px 0 0; font-size: 12px; color: var(--text-soft); }
.sg-checks { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; font-size: 12.5px; }
.sg-checks li { display: grid; grid-template-columns: 16px 1fr; gap: 6px; }
.sg-check-icon { font-weight: 700; }
.sg-checks .is-pass .sg-check-icon { color: var(--status-success); }
.sg-checks .is-fail .sg-check-icon { color: var(--status-error); }
.sg-checks .is-na { color: var(--text-soft); }
.sg-check-problems { grid-column: 2; font: 11px var(--mono); color: var(--status-warning); margin: 2px 0 0; padding-left: 14px; }
.sg-layers { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.sg-layer { min-width: 0; border: 1px solid rgba(168, 85, 247, .45); background: rgba(168, 85, 247, .14); border-radius: var(--radius-sm); padding: 7px 2px; font-size: 11.5px; text-align: center; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; cursor: pointer; color: var(--text-main); transition: background .18s var(--ease), border-color .18s, color .18s; }
.sg-layer:hover { border-color: var(--indus-purple); }
.sg-layer[aria-pressed="false"] { background: transparent; border-color: var(--border-soft); color: var(--text-soft); }
.sg-layer:focus-visible { outline: 2px solid var(--indus-purple); outline-offset: 2px; }
.sg-notes-first { margin: 0 0 10px; }
.sg-notes code { font: 11.5px var(--mono); color: var(--text-main); background: rgba(255, 255, 255, .06); padding: 0 4px; border-radius: 4px; }
.sg-verify { margin-top: 10px; font-size: 12.5px; display: flex; flex-direction: column; gap: 6px; }
.sg-verify .is-ok { color: var(--status-success); font-weight: 600; }
.sg-verify .is-bad { color: var(--status-error); font-weight: 600; }
.sg-verify ul { margin: 0; padding-left: 16px; font: 11px var(--mono); color: var(--status-warning); }
.sg-viewport.is-dropping::after { content: "Drop the saved .schem to compare it with this build"; position: absolute; inset: 12px; border: 2px dashed var(--indus-purple); border-radius: var(--radius-md); display: grid; place-items: center; background: rgba(46, 16, 101, .55); font-weight: 600; }
.sg-cutaway { margin-top: 12px; }
.sg-checklist { margin: 10px 0 0; padding-left: 18px; font-size: 12px; color: var(--text-soft); display: flex; flex-direction: column; gap: 4px; }
.sg-disclosure { margin-top: 10px; border: 0; background: none; padding: 0; color: var(--indus-purple); cursor: pointer; font-size: 12.5px; }
.sg-card h2 + .sg-checklist, .sg-card h2 + .sg-disclosure { margin-top: 0; }
.sg-disclosure::after { content: " ▸"; }
.sg-disclosure[aria-expanded="true"]::after { content: " ▾"; }
.sg-materials { width: 100%; margin-top: 8px; border-collapse: collapse; font-size: 12px; }
.sg-materials td { padding: 3px 0; border-bottom: 1px solid var(--border-soft); }
.sg-materials td:nth-child(n+2) { text-align: right; font-family: var(--mono); color: var(--text-soft); padding-left: 10px; white-space: nowrap; }

/* Phantom loading */
.sg-skeleton { position: relative; overflow: hidden; background: rgba(255, 255, 255, .05); border-radius: var(--radius-sm); }
.sg-skeleton::after { content: ""; position: absolute; inset: 0; transform: translateX(-100%); background: linear-gradient(90deg, transparent, rgba(168, 85, 247, .16), transparent); animation: sg-shimmer 1.4s infinite; }
.sg-skeleton-field { height: 52px; }
.sg-skeleton-line { height: 14px; list-style: none; }
@keyframes sg-shimmer { to { transform: translateX(100%); } }

.sg-mobile { position: fixed; inset: 0; display: grid; place-items: center; padding: 24px; text-align: center; }
.sg-mobile.sg-embedded { position: static; min-height: 60vh; border: 1px solid var(--border-soft); border-radius: var(--radius-md); }

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

/* Options that are not built yet (Phase 2 themes and classes). */
.sg-segment[aria-disabled='true'] { opacity: 0.38; cursor: not-allowed; }
