:root {
  color-scheme: dark;
  --bg: #08090a;
  --panel: #0f1012;
  --line: rgba(245,245,245,.78);
  --soft-line: rgba(255,255,255,.18);
  --text: #f3f4f6;
  --muted: #a9b0bb;
  --accent: #16486a;
  --accent-light: #d9b76c;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  min-height: 100vh;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
}

.topbar {
  width: min(1500px, 100%);
  margin: 0 auto;
  padding: 1.1rem clamp(1rem, 2vw, 1.8rem) .5rem;
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 1rem;
}
.eyebrow, .label { color: var(--accent-light); text-transform: uppercase; letter-spacing: .14em; font-size: .7rem; font-weight: 700; }
h1 { margin: .2rem 0 0; font-size: clamp(1.6rem, 3vw, 3rem); line-height: .95; letter-spacing: -.045em; }
.status, .muted, .hint, .small { color: var(--muted); }
.small { font-size: .78rem; line-height: 1.35; }
.status { border: 1px solid var(--soft-line); border-radius: 999px; padding: .55rem .85rem; background: rgba(255,255,255,.04); }

.workspace {
  width: min(1500px, 100%);
  min-height: calc(100vh - 110px);
  margin: 0 auto;
  padding: clamp(.7rem, 1.8vw, 1.4rem);
  display: grid;
  grid-template-columns: 270px minmax(430px, 1fr) 360px;
  gap: 1rem;
}

.panel {
  position: relative;
  border: 3px solid var(--line);
  border-radius: 28px;
  background: #0b0c0e;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.08), 0 24px 80px rgba(0,0,0,.35);
}

.tools-panel { padding: 1rem; }
.tools-title {
  width: 100%;
  border: 2px solid var(--line);
  border-radius: 14px;
  background: var(--accent);
  text-align: center;
  padding: 1rem .8rem;
  font-size: 1.25rem;
  font-weight: 800;
  margin-bottom: 1rem;
}
.tool-section { margin: 1rem 0; }
.tool-grid { display: flex; flex-wrap: wrap; gap: .7rem; margin: 1rem 0; }
.tool-button, .upload span {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  border: 2px solid var(--line);
  border-radius: 10px;
  background: transparent;
  color: var(--text);
  font: inherit;
  font-weight: 750;
  padding: .55rem .75rem;
  cursor: pointer;
}
.tool-button.primary, .upload.primary span { width: 100%; }
.tool-button:hover, .upload span:hover { background: rgba(255,255,255,.08); }
.tool-button.ghost { color: var(--muted); }
.mode-tabs { display: grid; grid-template-columns: 1fr 1fr; gap: .5rem; margin-bottom: .8rem; }
.mode-tab { border: 1px solid var(--soft-line); border-radius: 999px; background: rgba(255,255,255,.04); color: var(--muted); min-height: 36px; font: inherit; font-weight: 800; cursor: pointer; }
.mode-tab.active { background: var(--accent); color: var(--text); border-color: var(--line); }
.tool-mode { display: none; }
.tool-mode.active { display: block; }
.surface-list { display: grid; gap: .55rem; margin-top: .6rem; }
.surface-select.active { background: rgba(217,183,108,.18); border-color: var(--accent-light); }
.admin-card { border: 1px solid var(--soft-line); border-radius: 14px; padding: .8rem; background: rgba(255,255,255,.04); }
.admin-card p { margin: .55rem 0 0; color: var(--muted); font-size: .82rem; line-height: 1.45; }
.surface-pill { border: 1px solid var(--soft-line); border-radius: 999px; padding: .55rem .75rem; color: var(--text); background: rgba(217,183,108,.10); font-weight: 750; }
.upload input, .tool-button input { display: none; }
.compact-controls { display: grid; gap: .55rem; border-top: 1px solid var(--soft-line); padding-top: 1rem; }
label { display: grid; gap: .25rem; color: var(--muted); font-size: .82rem; }
input[type="number"], input[type="range"] { width: 100%; }
input[type="number"] { border: 1px solid var(--soft-line); border-radius: 9px; padding: .55rem .6rem; color: var(--text); background: rgba(255,255,255,.05); }
.actions { display: grid; grid-template-columns: 1fr 1fr; gap: .5rem; }
.actions .ghost { grid-column: 1 / -1; }

.editor-panel { padding: 4.5rem 1.4rem 1rem; }
.preview3d-panel { padding: 4.5rem 1.4rem 1rem; }
.panel-tab {
  position: absolute;
  top: 1.1rem;
  left: 50%;
  transform: translateX(-50%);
  min-width: 210px;
  border: 2px solid var(--line);
  border-radius: 10px;
  text-align: center;
  padding: .55rem 1.2rem;
  font-size: 1.05rem;
  font-weight: 850;
  letter-spacing: .04em;
}
.floating-button {
  position: absolute;
  top: 4.1rem;
  right: 2rem;
  z-index: 3;
  border: 2px solid var(--line);
  border-radius: 13px;
  background: #111214;
  color: var(--text);
  padding: .75rem .9rem;
  font-weight: 800;
  cursor: pointer;
}
.stage-wrap {
  min-height: 540px;
  display: grid;
  place-items: center;
  padding: clamp(.8rem, 2.5vw, 2rem);
}
.konva-stage {
  width: min(860px, 100%);
  aspect-ratio: 1.55;
  background: #334253;
  overflow: hidden;
  box-shadow: inset 0 0 0 2px rgba(0,0,0,.45);
}
.hint { margin: .2rem 0 0; font-size: .85rem; text-align: center; }

.preview3d {
  min-height: 440px;
  display: grid;
  place-items: center;
  background: #334253;
  margin-top: 2rem;
  overflow: hidden;
  position: relative;
  perspective: 900px;
}
.three-preview { position: absolute; inset: 0; }
.three-preview canvas { display: block; width: 100% !important; height: 100% !important; cursor: grab; }
.three-preview canvas:active { cursor: grabbing; }
.three-help { position: absolute; left: 1rem; bottom: .85rem; z-index: 4; border: 1px solid rgba(255,255,255,.22); border-radius: 999px; padding: .4rem .65rem; color: rgba(255,255,255,.78); background: rgba(0,0,0,.34); font-size: .72rem; pointer-events: none; }
.preview-object {
  width: 78%;
  aspect-ratio: 1.45;
  position: relative;
  transform: rotateX(10deg) rotateY(-35deg) rotateZ(-6deg);
  transform-style: preserve-3d;
}
.preview-object::before {
  content: "";
  position: absolute;
  inset: 7% -8% -7% 8%;
  border-radius: 22px;
  background: #3f4348;
  transform: translateZ(-42px);
  box-shadow: 16px 18px 0 rgba(0,0,0,.18);
}
.preview-face {
  position: absolute;
  inset: 0;
  border-radius: 28px;
  background: #8c8b84;
  box-shadow: inset 0 0 0 2px rgba(255,255,255,.22), 0 24px 50px rgba(0,0,0,.35);
}
.preview-face::before {
  content: "";
  position: absolute;
  inset: 30% 18%;
  border-radius: 13px;
  background: #171819;
  box-shadow: inset 0 0 0 2px rgba(0,0,0,.35);
}
.preview-design {
  display: none !important;
  left: 8%;
  top: 14%;
  width: 84%;
  height: 70%;
  z-index: 2;
  display: grid;
  place-items: center;
  pointer-events: none;
  color: rgba(0,0,0,.7);
  font-size: .85rem;
  transform-origin: center;
  mix-blend-mode: multiply;
  filter: grayscale(1) contrast(1.4) brightness(.55);
  overflow: hidden;
}
.preview-design.empty { border: 1px dashed rgba(0,0,0,.35); border-radius: 9px; filter: none; mix-blend-mode: normal; }
.preview-design img { width: 100%; height: 100%; object-fit: contain; }
.preview-fullscreen { top: 5.4rem; right: 1.4rem; }
.production-data { margin-top: 1rem; }
pre { white-space: pre-wrap; overflow: auto; max-height: 180px; color: #dbe3ef; font-size: .7rem; line-height: 1.35; margin: .6rem 0 0; }

@media (max-width: 1180px) {
  .workspace { grid-template-columns: 230px 1fr; }
  .preview3d-panel { grid-column: 1 / -1; }
}
@media (max-width: 820px) {
  .topbar { align-items: start; flex-direction: column; }
  .workspace { grid-template-columns: 1fr; }
  .editor-panel, .preview3d-panel { padding-inline: .8rem; }
  .stage-wrap, .preview3d { min-height: 360px; }
  .floating-button { position: static; margin: .5rem 0 0 auto; display: flex; }
}
