:root {
  --bg: #f4f0ea;
  --panel: #fff9f1;
  --ink: #1f2733;
  --ink-soft: #4f5d6f;
  --accent: #2f6f6d;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Space Grotesk", sans-serif;
  color: var(--ink);
  background:
    radial-gradient(circle at 20% 10%, #fffaf2 0%, transparent 45%),
    radial-gradient(circle at 90% 90%, #f3d9a7 0%, transparent 55%),
    linear-gradient(135deg, #efe7dc, #f6efe4 45%, #efe3d0);
}

.viz-shell {
  display: grid;
  grid-template-columns: minmax(330px, 420px) 1fr;
  gap: 1rem;
  padding: 1rem;
}

.panel {
  background: var(--panel);
  border: 2px solid #ccbca5;
  border-radius: 18px;
  box-shadow: 0 12px 28px rgba(47, 29, 3, 0.1);
}

.controls {
  padding: 1.1rem;
}

h1,
h2 {
  margin: 0;
  font-family: "Sora", sans-serif;
}

h1 {
  font-size: 1.45rem;
}

h2 {
  font-size: 1rem;
}

.subtitle {
  margin: 0.45rem 0 0.9rem;
  color: var(--ink-soft);
}

.section {
  margin-top: 0.95rem;
  padding-top: 0.85rem;
  border-top: 1px dashed #cfbfa8;
}

.left-controls-hidden {
  position: absolute;
  left: -99999px;
  top: auto;
  width: 1px;
  height: 1px;
  overflow: hidden;
  opacity: 0;
  pointer-events: none;
}

.field-grid {
  margin-top: 0.45rem;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.6rem;
}

.field-grid .wide {
  grid-column: 1 / -1;
}

.field-grid .layer-select {
  grid-column: 1 / -1;
}

label {
  display: grid;
  gap: 0.35rem;
  font-size: 0.84rem;
  color: var(--ink-soft);
}

input,
select,
button {
  font: inherit;
}

input,
select {
  border: 1px solid #b8aa95;
  border-radius: 10px;
  padding: 0.5rem 0.6rem;
  background: #fffdf8;
  color: var(--ink);
}

.button-row {
  margin-top: 0.65rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

button {
  border: 0;
  border-radius: 999px;
  padding: 0.5rem 0.95rem;
  font-weight: 600;
  cursor: pointer;
  background: var(--accent);
  color: #f7fffe;
}

.status {
  margin: 0.6rem 0 0;
  font-size: 0.9rem;
  color: var(--ink-soft);
}

.summary-list {
  margin: 0.4rem 0 0;
  padding-left: 1.1rem;
  display: grid;
  gap: 0.25rem;
  font-size: 0.88rem;
}

.viewport-panel {
  display: grid;
  grid-template-rows: auto 1fr;
  overflow: hidden;
}

.viewport-header {
  padding: 0.95rem 1rem 0.4rem;
}

.viewport-header p {
  margin: 0.2rem 0 0;
  color: var(--ink-soft);
}

.viewport-header.secondary {
  padding-top: 0.25rem;
}

.viewport3d {
  position: relative;
  margin: 0.75rem;
  border-radius: 14px;
  border: 2px solid #d8c8b0;
  background: linear-gradient(180deg, rgba(255, 251, 243, 0.95), rgba(242, 230, 210, 0.95));
  min-height: 76vh;
  overflow: hidden;
}

.viewport3d canvas {
  display: block;
  width: 100%;
  height: 100%;
}

.scale-overlay {
  position: absolute;
  left: 0.8rem;
  bottom: 0.8rem;
  background: rgba(255, 248, 235, 0.9);
  border: 1px solid #ccbca5;
  border-radius: 10px;
  padding: 0.35rem 0.45rem;
  pointer-events: none;
}

.scale-line {
  height: 0;
  width: 90px;
  border-top: 3px solid #304657;
  border-left: 1px solid #304657;
  border-right: 1px solid #304657;
  margin-bottom: 0.2rem;
}

.scale-label {
  font-size: 0.76rem;
  color: #2d3d4b;
  text-align: center;
}

.viewport-layer-controls {
  position: absolute;
  top: 0.7rem;
  right: 0.7rem;
  width: min(320px, calc(100% - 1.4rem));
  background: rgba(255, 249, 237, 0.92);
  border: 1px solid #ccbca5;
  border-radius: 12px;
  padding: 0.55rem 0.6rem;
  box-shadow: 0 8px 20px rgba(48, 29, 2, 0.16);
  z-index: 3;
}

.viewport-layer-controls h3 {
  margin: 0 0 0.45rem;
  font-family: "Sora", sans-serif;
  font-size: 0.82rem;
  color: #2d3d4b;
}

.viewport-layer-row {
  display: grid;
  grid-template-columns: minmax(112px, 1fr) minmax(92px, 1.2fr) 44px;
  align-items: center;
  gap: 0.42rem;
  padding: 0.18rem 0;
}

.viewport-layer-toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.34rem;
  margin: 0;
  font-size: 0.74rem;
  color: #30404e;
  white-space: nowrap;
}

.viewport-layer-toggle input[type="checkbox"] {
  margin: 0;
}

.viewport-layer-row input[type="range"] {
  width: 100%;
  margin: 0;
  accent-color: #3d7098;
}

.viewport-opacity-value {
  font-size: 0.7rem;
  color: #41505d;
  text-align: right;
}

.editor2d-wrap {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
  padding: 0 0.75rem 0.75rem;
}

.editor2d-card {
  border: 1px solid #d8c8b0;
  border-radius: 12px;
  padding: 0.35rem;
  background: rgba(255, 252, 246, 0.9);
}

.editor2d-card h3 {
  margin: 0.2rem 0 0.25rem;
  padding-left: 0.2rem;
  font-family: "Sora", sans-serif;
  font-size: 0.9rem;
  color: #4a596a;
}

#frontEditorCanvas,
#backEditorCanvas {
  display: block;
  width: 100%;
  height: min(34vh, 290px);
  border-radius: 10px;
  border: 1px solid #d8c8b0;
  background: linear-gradient(180deg, rgba(255, 248, 235, 0.95), rgba(245, 233, 214, 0.95));
}

.editor-cell {
  fill: #fae7c8;
  stroke: #6a5b45;
  stroke-width: 2;
}

.editor-pad-front {
  fill: #d8ebff;
}

.editor-pad-back {
  fill: #ffe4cb;
}

.editor-strip-front {
  stroke: #4f86c5;
  stroke-width: 4;
}

.editor-strip-back {
  stroke: #b78654;
  stroke-width: 4;
}

.editor-main-pos {
  fill: #ffdfdf;
  stroke: #cf2b2b;
  stroke-width: 2;
}

.editor-main-neg {
  fill: #dfebff;
  stroke: #2a57a8;
  stroke-width: 2;
}

.cell-group.dragging {
  opacity: 0.72;
}

.cell-group.dragging .cell-circle {
  stroke-dasharray: 4 3;
}

.editor-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin: 0.2rem 0 0.6rem;
}

.sheet-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0 0.75rem 0.55rem;
}

.sheet-btn {
  width: 2.25rem;
  height: 2.25rem;
  border-radius: 999px;
  border: 1px solid #c9b49c;
  font-size: 1rem;
  font-weight: 700;
  padding: 0;
}

.sheet-btn.confirm {
  background: linear-gradient(180deg, #f3f7ef, #d7e8d2);
  color: #2b6b33;
}

.sheet-btn.cancel {
  background: linear-gradient(180deg, #fff4f1, #f2d4d0);
  color: #a63d3d;
}

.sheet-actions .status {
  margin: 0;
}

.tool-btn {
  border: 1px solid #c9b49c;
  border-radius: 8px;
  background: #f5ead8;
  color: #3f4f62;
  font-family: "Sora", sans-serif;
  font-size: 0.82rem;
  font-weight: 600;
  padding: 0.38rem 0.62rem;
  cursor: pointer;
}

.tool-btn.active {
  background: #4f86c5;
  border-color: #3a6da8;
  color: #fff;
}

.editor-cell.sheet-draft-cell {
  fill: rgba(192, 192, 192, 0.78);
  stroke: #7d8087;
}

.editor-sheet-outline {
  fill: rgba(193, 195, 199, 0.22);
  stroke: rgba(122, 126, 134, 0.95);
  stroke-width: 2.5;
}

.editor-sheet-preview {
  fill: rgba(193, 195, 199, 0.24);
  stroke: rgba(122, 126, 134, 0.95);
  stroke-width: 2.5;
}

@media (max-width: 980px) {
  .viz-shell {
    grid-template-columns: 1fr;
  }

  .viewport3d {
    min-height: 60vh;
  }

  .editor2d-wrap {
    grid-template-columns: 1fr;
  }

  .viewport-layer-row {
    grid-template-columns: minmax(112px, 1fr) minmax(72px, 1fr) 40px;
  }
}
