/* Studio page: dark, full-bleed 3D canvas with floating controls (mockup B). */
:root {
  --bg: #0e1114;
  --card: rgba(18, 21, 24, 0.84);
  --line: rgba(255, 255, 255, 0.12);
  --ink: #edeff1;
  --soft: #c3c8cd;
  --muted: #9aa1a8;
  --accent: #ff6a3d;
  --on-accent: #15181b;
  --font: "Noto Sans KR", system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
html, body { margin: 0; height: 100%; }
body { background: var(--bg); color: var(--ink); font: 14px/1.45 var(--font); overflow: hidden; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
button { font-family: inherit; }

#view { position: fixed; inset: 0; z-index: 0; width: 100%; height: 100%; display: block; }

/* Shared glass look */
.card, .pill, .dock, .chip { background: var(--card); border: 1px solid var(--line); backdrop-filter: blur(10px); }

/* Top bar */
.bar { position: fixed; z-index: 2; left: 24px; right: 24px; top: 20px; display: flex; align-items: center; justify-content: space-between; gap: 12px; pointer-events: none; }
.bar > * { pointer-events: auto; }
.pill { display: flex; align-items: center; gap: 18px; padding: 8px 18px; border-radius: 999px; }
.brand { display: flex; align-items: center; gap: 10px; }
.brand h1 { margin: 0; font-size: 15px; font-weight: 700; }
.link { color: var(--soft); font-size: 13px; text-decoration: none; }
.link:hover { color: var(--ink); text-decoration: underline; }
.btn-accent { display: flex; align-items: center; gap: 8px; padding: 11px 18px; border: 0; border-radius: 999px; background: var(--accent); color: var(--on-accent); font: 700 14px var(--font); cursor: pointer; box-shadow: 0 2px 12px rgba(0, 0, 0, 0.35); }
.btn-accent:hover { filter: brightness(1.08); }

/* Side column: parameters (right) and finishes (bottom-left) */
.side { display: contents; }
.card { position: fixed; z-index: 2; border-radius: 16px; color: var(--ink); }
.params { right: 24px; top: 84px; width: 300px; max-height: calc(100vh - 210px); overflow: auto; padding: 16px 18px 18px; }
.params h2, .finishes h2 { margin: 0; font-size: 12px; font-weight: 700; color: var(--muted); letter-spacing: 0.04em; }
.card-toggle { display: flex; justify-content: space-between; align-items: center; width: 100%; padding: 0; border: 0; background: transparent; color: inherit; font: inherit; letter-spacing: inherit; cursor: pointer; }
.card-toggle:hover { color: var(--ink); }
.card-toggle svg { transition: transform 0.15s; }
.card-toggle[aria-expanded="false"] svg { transform: rotate(-90deg); }
#params-body, #finishes-body { margin-top: 12px; }
#params-body[hidden], #finishes-body[hidden] { display: none; }
#controls { display: flex; flex-direction: column; gap: 12px; }
.param { display: block; }
.param-head { display: flex; justify-content: space-between; font-weight: 500; }
.param-name { font-weight: 500; }
.param-value { font-family: var(--mono); color: var(--muted); }
.param input[type="range"] { width: 100%; margin: 4px 0 0; accent-color: var(--accent); }
.param-bool { display: flex; align-items: center; justify-content: space-between; }
.param-bool input { width: 18px; height: 18px; margin: 0; accent-color: var(--accent); }

.seg { display: flex; padding: 3px; gap: 2px; margin-top: 6px; background: rgba(255, 255, 255, 0.08); border-radius: 10px; }
.seg-btn { flex: 1; border: 0; padding: 6px 0; border-radius: 8px; background: transparent; color: var(--soft); font: 500 13px var(--font); cursor: pointer; }
.seg-btn[aria-pressed="true"] { background: var(--ink); color: var(--on-accent); font-weight: 700; }

.finishes { left: 24px; bottom: 24px; width: 312px; padding: 14px 16px; }
#finishes-body { display: flex; flex-direction: column; gap: 12px; }
.finish-head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 8px; }
.finish-title { font-size: 12px; font-weight: 700; color: var(--muted); letter-spacing: 0.04em; }
.finish-name { font-size: 13px; font-weight: 500; }
.swatches { display: flex; gap: 8px; }
.swatch { width: 40px; height: 40px; padding: 0; overflow: hidden; border: 2px solid #121518; box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.22); border-radius: 10px; background: none; cursor: pointer; }
.swatch[aria-pressed="true"] { box-shadow: 0 0 0 2.5px var(--accent); }
.swatch:focus-visible { outline: 2px solid var(--accent); outline-offset: 4px; }
.swatch img { display: block; width: 100%; height: 100%; object-fit: cover; }

/* Bottom dock: type, presets, random */
.dock { position: fixed; z-index: 2; left: 50%; bottom: 24px; transform: translateX(-50%); width: max-content; max-width: calc(100vw - 48px); display: flex; align-items: center; gap: 14px; padding: 8px; border-radius: 999px; }
.dock .seg { margin: 0; border-radius: 999px; }
.dock .seg-btn { padding: 8px 18px; border-radius: 999px; font-size: 14px; white-space: nowrap; }
.dock-sep { width: 1px; height: 24px; background: var(--line); }
.chips { display: flex; gap: 6px; }
.chip-btn { padding: 8px 16px; border-radius: 999px; border: 1.5px solid rgba(255, 255, 255, 0.22); background: transparent; color: var(--ink); font: 500 13px var(--font); white-space: nowrap; cursor: pointer; }
.chip-btn[aria-pressed="true"] { border-color: var(--accent); background: rgba(255, 106, 61, 0.16); color: #ffb29a; font-weight: 700; }
.btn-ghost { white-space: nowrap; display: flex; align-items: center; gap: 8px; margin-right: 4px; padding: 8px 14px; border: 0; border-radius: 999px; background: rgba(255, 255, 255, 0.1); color: var(--ink); font: 700 13px var(--font); cursor: pointer; }
.btn-ghost:hover { background: rgba(255, 255, 255, 0.16); }

.chip { position: fixed; z-index: 2; right: 24px; bottom: 24px; margin: 0; padding: 8px 14px; border-radius: 999px; font-family: var(--mono); font-size: 13px; }
.notice { position: fixed; z-index: 3; left: 50%; top: 50%; transform: translate(-50%, -50%); max-width: 420px; margin: 0; padding: 18px 22px; border-radius: 16px; background: var(--card); border: 1px solid var(--line); text-align: center; }

/* Mid-width laptops: both cards share one scrolling column on the right; the status chip moves to the top. */
@media (max-width: 1359px) {
  .side { position: fixed; z-index: 2; right: 24px; top: 84px; width: 300px; max-height: calc(100vh - 172px); overflow: auto; display: flex; flex-direction: column; gap: 12px; }
  .params, .finishes { position: static; width: auto; max-height: none; overflow: visible; }
  .chip { right: auto; bottom: auto; left: 24px; top: 84px; }
}

/* Phones and narrow windows: 3D on top (sticky), everything else stacked below. */
@media (max-width: 820px) {
  body { overflow: auto; height: auto; min-height: 100%; }
  .bar { position: static; padding: 12px 16px; flex-wrap: wrap; }
  #view { position: sticky; top: 0; height: 46vh; min-height: 260px; }
  .dock { position: static; transform: none; width: auto; max-width: none; margin: 12px 12px 0; flex-direction: column; align-items: stretch; gap: 12px; border-radius: 16px; }
  .dock .seg { border-radius: 12px; }
  .dock .seg-btn { flex: 1; min-height: 44px; padding: 8px 4px; border-radius: 10px; font-size: 14px; }
  .dock-sep { display: none; }
  .chips { flex-wrap: wrap; }
  .chip-btn { flex: 1; min-height: 44px; }
  .btn-ghost { justify-content: center; min-height: 44px; margin: 0; }
  .chip { position: static; display: inline-block; margin: 12px 12px 0; }
  .side { position: static; width: auto; max-height: none; overflow: visible; padding: 12px; }
  .finishes { padding: 14px 16px; }
  .swatches { justify-content: space-between; }
  .swatch { width: 48px; height: 48px; }
  .param input[type="range"] { height: 28px; }
  .param-bool { min-height: 44px; }
  .param-bool input { width: 22px; height: 22px; }
  .seg-btn { min-height: 44px; }
}

/* Forced-colors (high contrast) mode drops background and border colors: mark the pressed state with a heavy outline and a check-like inset instead. */
@media (forced-colors: active) {
  .seg-btn[aria-pressed="true"], .chip-btn[aria-pressed="true"] { outline: 3px solid Highlight; outline-offset: -3px; font-weight: 700; }
  .swatch[aria-pressed="true"] { outline: 3px solid Highlight; outline-offset: 2px; }
  .chip-btn, .seg-btn, .btn-ghost, .btn-accent { border: 1px solid ButtonText; }
}

/* Rule editor panel: opens from the right, the 3D stays visible on the left. The parameter card hides while it is open. */
.bar-actions { display: flex; align-items: center; gap: 10px; }
.editor { right: 24px; top: 84px; bottom: 100px; width: 480px; max-width: calc(100vw - 48px); padding: 14px 16px; display: flex; flex-direction: column; gap: 10px; z-index: 3; }
.editor[hidden] { display: none; }
body.editor-open .params { display: none; }
.editor-head { display: flex; justify-content: space-between; align-items: baseline; }
.editor-head h2 { margin: 0; font-size: 12px; font-weight: 700; color: var(--muted); letter-spacing: 0.04em; }
.editor-status { font-size: 12px; font-weight: 700; color: var(--soft); }
.editor-status[data-state="적용됨"] { color: #8fe3a8; }
.editor-status[data-state="오류"] { color: #ff9a8a; }
#editor-text { flex: 1; min-height: 160px; width: 100%; resize: none; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; background: rgba(0, 0, 0, 0.35); color: var(--ink); font: 12px/1.5 var(--mono); tab-size: 2; white-space: pre; overflow: auto; }
#editor-text[aria-invalid="true"] { border-color: #ff9a8a; }
.editor-errors { margin: 0; padding: 0; list-style: none; max-height: 30%; overflow: auto; font: 12px/1.45 var(--mono); color: #ffb4a8; }
.editor-error { padding: 3px 0; border-bottom: 1px solid var(--line); overflow-wrap: anywhere; }
.editor-actions { display: flex; gap: 8px; }
.editor-actions .btn-ghost { margin: 0; flex: 1; justify-content: center; }
@media (max-width: 1359px) {
  /* the right column is a shared scrolling column here; the open editor takes its place */
  body.editor-open .side { display: none; }
}
@media (max-width: 820px) {
  .editor { position: static; width: auto; max-width: none; margin: 12px; height: 70vh; }
  body.editor-open .side { display: flex; }
}

/* The header button sits on the light sky, so it gets the dark glass look instead of the dock's translucent white. */
.bar-actions .btn-ghost { margin: 0; padding: 11px 16px; background: var(--card); border: 1px solid var(--line); backdrop-filter: blur(10px); }
.bar-actions .btn-ghost:hover { background: rgba(40, 44, 48, 0.92); }
.bar-actions .btn-ghost[aria-expanded="true"] { border-color: var(--accent); }
/* With the panel open (wide enough to sit beside the 3D), narrow the 3D view so the facade is not hidden behind it. */
@media (min-width: 821px) {
  body.editor-open #view { width: calc(100vw - 504px); }
}
