:root {
  color-scheme: light;
  --wood-base: #b58354;
  --wood-dark: #84552d;
  --paper: rgba(252, 248, 240, 0.95);
  --paper-edge: rgba(94, 62, 34, 0.24);
  --ink: #2f2319;
  --ink-muted: #5b4736;
  --accent: #b86545;
  --accent-deep: #7a341c;
  --accent-soft: rgba(184, 101, 69, 0.15);
  --focus-ring: #b86545;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
}

body {
  background-color: var(--wood-base);
  background-image:
    radial-gradient(ellipse at 22% 14%, rgba(255, 243, 218, 0.42), transparent 54%),
    radial-gradient(ellipse at 86% 88%, rgba(36, 18, 6, 0.46), transparent 64%),
    repeating-linear-gradient(
      178deg,
      rgba(88, 52, 22, 0.068) 0px,
      rgba(88, 52, 22, 0.068) 2px,
      transparent 2px,
      transparent 11px,
      rgba(255, 232, 196, 0.05) 11px,
      rgba(255, 232, 196, 0.05) 14px,
      transparent 14px,
      transparent 26px
    ),
    repeating-linear-gradient(
      90deg,
      transparent 0px,
      transparent 168px,
      rgba(62, 35, 14, 0.13) 168px,
      rgba(62, 35, 14, 0.13) 170px
    ),
    linear-gradient(155deg, #c79665 0%, #a87649 52%, #865730 100%);
  background-attachment: fixed;
}

.workbench {
  max-width: 1420px;
  margin: 0 auto;
  padding: 8px 14px 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  background: linear-gradient(180deg, rgba(254, 250, 244, 0.97) 0%, rgba(246, 238, 225, 0.94) 100%);
  border: 1px solid var(--paper-edge);
  border-radius: 13px;
  padding: 7px 14px;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.8),
    0 8px 22px rgba(42, 24, 10, 0.2);
  backdrop-filter: blur(8px);
}

.brand-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 7px;
}

.brand h1 {
  margin: 0;
  font-size: 1.15rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: #2a1d13;
}

.brand-badge {
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 2px 7px;
  border-radius: 999px;
  background: rgba(184, 101, 69, 0.14);
  color: var(--accent-deep);
  border: 1px solid rgba(184, 101, 69, 0.28);
}

.social-pill {
  font-size: 0.66rem;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 999px;
  background: rgba(255, 252, 246, 0.9);
  color: var(--ink);
  border: 1px solid rgba(94, 62, 34, 0.24);
  text-decoration: none;
  white-space: nowrap;
  transition: border-color 0.12s ease, background 0.12s ease, color 0.12s ease;
}

.social-pill:hover {
  border-color: var(--accent);
  color: var(--accent-deep);
  background: #fdf4ea;
}

.coffee-pill {
  background: linear-gradient(180deg, #fff8dc 0%, #f8e5a8 100%);
  border-color: rgba(168, 120, 30, 0.42);
  color: #5c3d08;
}

.coffee-pill:hover {
  background: #f5dd8e;
  border-color: #a8781e;
  color: #3f2804;
}

.tagline {
  margin: 1px 0 0;
  font-size: 0.75rem;
  color: var(--ink-muted);
}

.actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.action-btn {
  appearance: none;
  border: 1px solid rgba(94, 62, 34, 0.24);
  background: linear-gradient(180deg, #fffefb 0%, #f7f0e4 100%);
  color: var(--ink);
  border-radius: 8px;
  padding: 5px 10px;
  font-size: 0.76rem;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.85), 0 1px 2px rgba(46, 26, 10, 0.08);
  transition: background 0.12s ease, border-color 0.12s ease, transform 0.08s ease, box-shadow 0.12s ease;
}

.action-btn:hover:not(:disabled) {
  background: #f5ebe0;
  border-color: rgba(94, 62, 34, 0.42);
}

.action-btn:active:not(:disabled) {
  transform: translateY(1px);
}

.action-btn:disabled {
  opacity: 0.42;
  cursor: not-allowed;
  box-shadow: none;
}

.action-btn[aria-pressed="true"] {
  background: #eadcc8;
  color: var(--ink-muted);
  box-shadow: inset 0 1px 3px rgba(48, 28, 12, 0.14);
}

.action-accent {
  background: linear-gradient(180deg, rgba(196, 111, 78, 0.18) 0%, rgba(184, 101, 69, 0.25) 100%);
  border-color: rgba(184, 101, 69, 0.5);
  color: var(--accent-deep);
}

.action-accent:hover:not(:disabled) {
  background: rgba(184, 101, 69, 0.28);
  border-color: var(--accent);
}

.action-reset:hover:not(:disabled) {
  border-color: var(--accent);
  color: var(--accent);
}

.studio {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 334px;
  gap: 12px;
  align-items: start;
}

.slab-stage {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 0 2px 4px;
}

.stage-row {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  gap: 0;
}

.stage-row.port-right .slab-viewport { order: 1; }
.stage-row.port-right .tube-bridge { order: 2; }
.stage-row.port-right .outworld-panel { order: 3; }

.stage-row:not(.port-right) .outworld-panel { order: 1; }
.stage-row:not(.port-right) .tube-bridge { order: 2; }
.stage-row:not(.port-right) .slab-viewport { order: 3; }

/* Zoom & Pan viewport wrapping the Ytong block */
.slab-viewport {
  position: relative;
  flex: 1 1 0;
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 6px 14px 16px 6px;
  border-radius: 14px;
  overflow: hidden;
  max-width: 100%;
}

.slab-panzoom {
  width: 100%;
  max-width: 100%;
  display: flex;
  justify-content: center;
  transform-origin: center center;
  will-change: transform;
}

.zoom-hud {
  position: absolute;
  top: 14px;
  right: 20px;
  display: inline-flex;
  align-items: center;
  gap: 3px;
  background: rgba(250, 245, 236, 0.92);
  border: 1px solid rgba(94, 62, 34, 0.22);
  border-radius: 8px;
  padding: 3px 5px;
  box-shadow: 0 3px 10px rgba(38, 21, 8, 0.22);
  z-index: 4;
}

.zoom-btn {
  appearance: none;
  border: none;
  background: transparent;
  color: var(--ink);
  font-size: 0.78rem;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 5px;
  cursor: pointer;
}

.zoom-btn:hover {
  background: #ede1cf;
}

.zoom-reset {
  font-size: 0.68rem;
  font-weight: 600;
  border-left: 1px solid rgba(94, 62, 34, 0.16);
  border-radius: 0 5px 5px 0;
}

.zoom-val {
  font-size: 0.7rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--ink-muted);
  min-width: 34px;
  text-align: center;
}

/* Connected Outworld Arena & Vinyl Tube */
.outworld-panel {
  display: flex;
  flex-direction: column;
  gap: 6px;
  background: var(--paper);
  border: 1px solid var(--paper-edge);
  border-radius: 11px;
  padding: 8px;
  box-shadow: 0 8px 22px rgba(38, 21, 8, 0.28);
  flex: 0 0 206px;
}

.outworld-panel[hidden] { display: none; }

.outworld-head {
  display: flex;
  flex-direction: column;
  font-size: 0.76rem;
  font-weight: 700;
}

.outworld-sub {
  font-size: 0.65rem;
  font-weight: 500;
  color: var(--ink-muted);
}

.outworld-box {
  width: 190px;
  height: 190px;
  border-radius: 7px;
  overflow: hidden;
  border: 2px solid rgba(110, 138, 152, 0.55);
  box-shadow: inset 0 2px 8px rgba(48, 28, 12, 0.22);
}

#outworld-canvas {
  display: block;
  width: 100%;
  height: 100%;
  cursor: crosshair;
}

.tube-bridge {
  width: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 28px;
}

.tube-bridge[hidden] { display: none; }

.vinyl-tube {
  width: 34px;
  height: 16px;
  margin: 0 -3px;
  border-radius: 4px;
  background: linear-gradient(180deg, rgba(180, 208, 220, 0.8), rgba(245, 252, 255, 0.85) 32%, rgba(140, 172, 188, 0.55) 65%, rgba(110, 138, 152, 0.85));
  border-top: 1px solid rgba(72, 92, 104, 0.7);
  border-bottom: 1px solid rgba(72, 92, 104, 0.7);
  box-shadow: 0 4px 10px rgba(38, 21, 8, 0.25);
  z-index: 2;
}

.ytong-slab {
  position: relative;
  width: min(720px, 100%, calc(100vh - 108px));
  max-height: calc(100vh - 108px);
  aspect-ratio: 1 / 1;
  border-radius: 7px;
  background: #d6d1c6;
  box-shadow:
    2px 2px 0 #d5d0c5,
    4px 4px 0 #cbc6ba,
    6px 6px 0 #c0bbb0,
    8px 8px 0 #b5afa3,
    10px 10px 0 #a8a296,
    12px 12px 0 #9b9589,
    14px 18px 28px rgba(38, 21, 8, 0.42),
    26px 34px 54px rgba(38, 21, 8, 0.28);
}

#ytong-canvas {
  display: block;
  width: 100%;
  height: 100%;
  border-radius: 6px;
  touch-action: none;
  user-select: none;
  cursor: none;
  border: 1px solid rgba(255, 255, 255, 0.45);
}

.test-banner {
  margin-top: 6px;
  padding: 5px 12px;
  border-radius: 8px;
  font-size: 0.78rem;
  font-weight: 600;
  background: #e6f4ea;
  color: #1c5c2e;
  border: 1px solid #9bd1a9;
}

.test-banner.fail {
  background: #fde8e8;
  color: #8f1d1d;
  border-color: #e69c9c;
}

/* Tabbed Artisan Tool Dock */
.tool-dock {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.dock-tabs {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 4px;
  background: rgba(46, 28, 14, 0.42);
  padding: 4px;
  border-radius: 11px;
  border: 1px solid rgba(255, 240, 218, 0.14);
  box-shadow: inset 0 1px 3px rgba(24, 12, 4, 0.32);
}

.dock-tab {
  appearance: none;
  border: none;
  background: transparent;
  color: #f8eedc;
  font-size: 0.72rem;
  font-weight: 700;
  padding: 6px 4px;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.12s ease, color 0.12s ease, box-shadow 0.12s ease;
}

.dock-tab:hover {
  background: rgba(255, 250, 240, 0.16);
}

.dock-tab[aria-selected="true"] {
  background: linear-gradient(180deg, #fffefb 0%, #f5ece0 100%);
  color: var(--ink);
  box-shadow: 0 2px 6px rgba(32, 18, 8, 0.25);
}

.panel-card {
  background: linear-gradient(180deg, rgba(253, 249, 242, 0.96) 0%, rgba(245, 237, 224, 0.94) 100%);
  border: 1px solid var(--paper-edge);
  border-radius: 13px;
  padding: 10px 11px;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.78),
    0 10px 24px rgba(42, 24, 10, 0.22);
  backdrop-filter: blur(8px);
}

.tab-panel[hidden] {
  display: none;
}

.section-label {
  margin: 0 0 6px;
  font-size: 0.67rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-muted);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.hint-inline {
  font-size: 0.62rem;
  font-weight: 600;
  letter-spacing: 0;
  text-transform: none;
  opacity: 0.85;
}

.panel-card .section-label:not(:first-child) {
  margin-top: 9px;
}

.tool-grid-4 {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 5px;
}

.tool-btn {
  position: relative;
  appearance: none;
  border: 1.5px solid rgba(94, 62, 34, 0.18);
  background: linear-gradient(180deg, #fffefb 0%, #f8f2e7 100%);
  color: var(--ink);
  border-radius: 9px;
  padding: 6px 3px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  font-size: 0.7rem;
  font-weight: 600;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.9), 0 1px 2px rgba(46, 26, 10, 0.06);
  transition: background 0.12s ease, border-color 0.12s ease, box-shadow 0.12s ease, transform 0.08s ease;
}

.tool-btn:hover {
  background: #f5ece0;
  border-color: rgba(94, 62, 34, 0.38);
}

.tool-btn:active {
  transform: translateY(1px);
}

.tool-btn[aria-pressed="true"] {
  background: linear-gradient(180deg, rgba(196, 111, 78, 0.16) 0%, rgba(184, 101, 69, 0.24) 100%);
  border-color: var(--accent);
  color: var(--accent-deep);
  box-shadow:
    inset 0 0 0 1px rgba(184, 101, 69, 0.22),
    0 2px 5px rgba(140, 62, 34, 0.14);
}

.tool-icon {
  font-size: 0.98rem;
  line-height: 1.05;
}

.kbd {
  position: absolute;
  top: 2px;
  right: 4px;
  font-size: 0.58rem;
  font-weight: 700;
  color: var(--ink-muted);
  opacity: 0.88;
}

.sketch-bar {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 5px;
  margin-top: 7px;
}

.sketch-bar-2 {
  grid-template-columns: repeat(2, 1fr);
}

.wall-row {
  display: flex;
  align-items: center;
  gap: 5px;
  margin-top: 7px;
}

.mini-lbl {
  font-size: 0.68rem;
  font-weight: 700;
  color: var(--ink-muted);
}

.mini-val {
  font-size: 0.68rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  min-width: 26px;
  text-align: center;
}

.mini-btn {
  appearance: none;
  border: 1px solid rgba(94, 62, 34, 0.22);
  background: linear-gradient(180deg, #fffefb 0%, #f7f0e4 100%);
  color: var(--ink);
  border-radius: 7px;
  padding: 4px 6px;
  font-size: 0.68rem;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 3px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.85);
  transition: background 0.12s ease, border-color 0.12s ease, transform 0.08s ease;
}

.mini-btn:hover:not(:disabled) {
  background: #f4ebe0;
  border-color: rgba(94, 62, 34, 0.42);
}

.mini-btn:active:not(:disabled) {
  transform: translateY(1px);
}

.mini-btn:disabled {
  opacity: 0.42;
  cursor: not-allowed;
}

.mini-btn[aria-pressed="true"] {
  background: rgba(78, 132, 172, 0.16);
  border-color: rgba(78, 132, 172, 0.62);
  color: #234c6a;
}

#btn-fill-paint[aria-pressed="true"] {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent-deep);
}

.stamp-bar {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 4px;
  margin-top: 4px;
}

.stamp-btn {
  appearance: none;
  border: 1px solid rgba(94, 62, 34, 0.2);
  background: linear-gradient(180deg, #fffefb 0%, #f7f0e4 100%);
  color: var(--ink-muted);
  border-radius: 7px;
  padding: 4px 3px;
  font-size: 0.67rem;
  font-weight: 600;
  cursor: pointer;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.85);
  transition: background 0.12s ease, border-color 0.12s ease, color 0.12s ease;
}

.stamp-btn:hover {
  background: #f4ebe0;
  color: var(--ink);
}

.stamp-btn[aria-pressed="true"] {
  background: linear-gradient(180deg, rgba(196, 111, 78, 0.16) 0%, rgba(184, 101, 69, 0.24) 100%);
  border-color: var(--accent);
  color: var(--accent-deep);
}

.controls-card {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.material-bar {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 3px;
  background: rgba(94, 62, 34, 0.08);
  padding: 3px;
  border-radius: 8px;
  border: 1px solid rgba(94, 62, 34, 0.14);
}

.mat-btn {
  appearance: none;
  border: 1px solid transparent;
  background: transparent;
  color: var(--ink-muted);
  border-radius: 6px;
  padding: 3px 4px;
  font-size: 0.65rem;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.12s ease, color 0.12s ease, border-color 0.12s ease;
}

.mat-btn:hover {
  background: rgba(255, 253, 248, 0.65);
  color: var(--ink);
}

.mat-btn[aria-pressed="true"] {
  background: #fffefb;
  color: var(--accent-deep);
  border-color: rgba(184, 101, 69, 0.45);
  box-shadow: 0 1px 3px rgba(46, 26, 10, 0.12);
}

.slider-grid-3 {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.slider-row {
  display: flex;
  flex-direction: column;
  gap: 2px;
  transition: opacity 0.15s ease;
}

.slider-row.dimmed { opacity: 0.42; }

.slider-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-size: 0.72rem;
  font-weight: 600;
}

.slider-val {
  font-variant-numeric: tabular-nums;
  color: var(--ink-muted);
  font-size: 0.68rem;
  font-weight: 700;
}

input[type="range"] {
  width: 100%;
  height: 5px;
  accent-color: var(--accent);
  cursor: pointer;
  margin: 2px 0;
}

.action-help {
  min-width: 28px;
  justify-content: center;
  font-weight: 800;
}

.quick-bar {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 5px;
}

.quick-bar .mini-btn {
  white-space: nowrap;
  padding: 4px 3px;
  font-size: 0.66rem;
}

.dim-pill {
  font-size: 0.65rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  color: var(--ink-muted);
  background: #ebe0ce;
  border: 1px solid rgba(94, 62, 34, 0.16);
  padding: 2px 7px;
  border-radius: 999px;
}

.palette-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 9px;
  margin-bottom: 6px;
}

.palette-head .section-label { margin: 0; }

.mode-group {
  display: flex;
  align-items: center;
  gap: 4px;
}

.mode-toggle {
  display: inline-flex;
  background: #eee5d6;
  border-radius: 7px;
  padding: 2px;
  border: 1px solid rgba(94, 62, 34, 0.14);
}

.mode-btn,
.wall-btn {
  appearance: none;
  border: none;
  background: transparent;
  color: var(--ink-muted);
  font-size: 0.66rem;
  font-weight: 600;
  padding: 2px 6px;
  border-radius: 5px;
  cursor: pointer;
}

.mode-btn[aria-pressed="true"],
.wall-btn[aria-pressed="true"] {
  background: #fffdf8;
  color: var(--ink);
  box-shadow: 0 1px 3px rgba(50, 30, 14, 0.15);
}

.swatch-grid {
  display: grid;
  grid-template-columns: repeat(9, 1fr);
  gap: 5px;
}

.swatch {
  position: relative;
  aspect-ratio: 1 / 1;
  border-radius: 50%;
  border: 2px solid rgba(64, 42, 24, 0.24);
  background: var(--c);
  cursor: pointer;
  padding: 0;
  transition: transform 0.1s ease, box-shadow 0.12s ease, border-color 0.12s ease;
}

.swatch:hover { transform: scale(1.1); }

.swatch[aria-pressed="true"] {
  border-color: var(--ink);
  box-shadow: 0 0 0 1.5px #fffdf8, 0 0 0 3px var(--accent);
  transform: scale(1.08);
}

.swatch-custom {
  display: flex;
  align-items: center;
  justify-content: center;
  background: conic-gradient(from 90deg, #d6c19e, #b86545, #6c7d55, #6d767e, #d6c19e);
  color: #fff;
  font-weight: 700;
  font-size: 0.85rem;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.45);
  overflow: hidden;
}

.swatch-custom input[type="color"] {
  position: absolute;
  inset: 0;
  opacity: 0;
  width: 100%;
  height: 100%;
  cursor: pointer;
}

.finish-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
}

.finish-head .section-label { margin: 0; }

.species-select {
  border: 1px solid rgba(94, 62, 34, 0.24);
  background: #fffdf8;
  color: var(--ink);
  border-radius: 7px;
  padding: 2px 6px;
  font-size: 0.68rem;
  font-weight: 600;
}

.finish-grid-4 {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 5px;
  margin-top: 7px;
}

.finish-btn {
  appearance: none;
  border: 1.5px solid rgba(94, 62, 34, 0.2);
  background: linear-gradient(180deg, #fffefb 0%, #f8f2e7 100%);
  color: var(--ink);
  font-size: 0.68rem;
  font-weight: 600;
  padding: 6px 3px;
  border-radius: 8px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.9), 0 1px 2px rgba(46, 26, 10, 0.06);
  transition: background 0.12s ease, border-color 0.12s ease, transform 0.08s ease;
}

.finish-btn:hover {
  background: #f5ece0;
  border-color: rgba(94, 62, 34, 0.38);
}

.finish-btn:active {
  transform: translateY(1px);
}

.finish-btn[aria-pressed="true"] {
  background: linear-gradient(180deg, rgba(196, 111, 78, 0.16) 0%, rgba(184, 101, 69, 0.24) 100%);
  border-color: var(--accent);
  color: var(--accent-deep);
}

/* Nest Statistics & Readiness Card */
.stats-card {
  margin-top: 9px;
  background: rgba(238, 228, 211, 0.85);
  border: 1px solid rgba(94, 62, 34, 0.18);
  border-radius: 10px;
  padding: 8px;
  box-shadow: inset 0 1px 2px rgba(54, 34, 18, 0.08);
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 5px;
}

.stat-box {
  background: #fffefb;
  border-radius: 7px;
  padding: 4px 5px;
  text-align: center;
  border: 1px solid rgba(94, 62, 34, 0.12);
  box-shadow: 0 1px 2px rgba(46, 26, 10, 0.05);
}

.stat-box small {
  display: block;
  font-size: 0.58rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--ink-muted);
}

.stat-box strong {
  font-size: 0.76rem;
  font-variant-numeric: tabular-nums;
}

.stat-readiness {
  margin: 6px 0 0;
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--ink);
  line-height: 1.3;
}

.status-row {
  display: flex;
  align-items: stretch;
  gap: 6px;
}

.craft-tip {
  flex: 1;
  margin: 0;
  padding: 7px 10px;
  font-size: 0.7rem;
  line-height: 1.32;
  color: #fdf6ea;
  background: rgba(44, 26, 12, 0.62);
  border-radius: 10px;
  border: 1px solid rgba(255, 240, 215, 0.18);
  box-shadow: 0 4px 12px rgba(32, 18, 8, 0.18);
}

.rh-pill {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  padding: 7px 10px;
  font-size: 0.72rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  border-radius: 10px;
  background: linear-gradient(180deg, rgba(42, 76, 100, 0.92) 0%, rgba(28, 54, 72, 0.92) 100%);
  color: #eef8ff;
  border: 1px solid rgba(165, 220, 250, 0.36);
  box-shadow: 0 4px 12px rgba(24, 38, 50, 0.22);
}

/* Native <dialog> */
.library-dialog {
  width: min(92vw, 560px);
  border: 1px solid var(--paper-edge);
  border-radius: 14px;
  background: #faf5ec;
  color: var(--ink);
  padding: 16px 18px;
  box-shadow: 0 18px 48px rgba(32, 18, 8, 0.45);
}

.library-dialog::backdrop {
  background: rgba(32, 18, 8, 0.48);
  backdrop-filter: blur(3px);
}

.dialog-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

.dialog-head h2 { margin: 0; font-size: 1.05rem; }

.dialog-section { margin-bottom: 12px; }

.dialog-section h3 {
  margin: 0 0 7px;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--ink-muted);
}

.preset-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 6px;
}

.preset-btn {
  appearance: none;
  border: 1px solid rgba(94, 62, 34, 0.22);
  background: #fffdf8;
  color: var(--ink);
  border-radius: 8px;
  padding: 6px 8px;
  font-size: 0.72rem;
  font-weight: 600;
  cursor: pointer;
}

.preset-btn[aria-pressed="true"] {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: #7c351d;
}

.blueprint-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 7px;
}

.bp-btn {
  appearance: none;
  text-align: left;
  border: 1px solid rgba(94, 62, 34, 0.22);
  background: #fffdf8;
  color: var(--ink);
  border-radius: 9px;
  padding: 7px 9px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.bp-btn:hover {
  border-color: var(--accent);
  background: #f6efe2;
}

.bp-btn strong { font-size: 0.78rem; }
.bp-btn span { font-size: 0.68rem; color: var(--ink-muted); }

.save-bar {
  display: flex;
  gap: 6px;
  margin-bottom: 7px;
}

.save-bar input {
  flex: 1;
  border: 1px solid rgba(94, 62, 34, 0.25);
  border-radius: 8px;
  padding: 6px 10px;
  font-size: 0.8rem;
  background: #fffdf8;
  color: var(--ink);
}

.gallery-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 130px;
  overflow-y: auto;
}

.gallery-empty {
  font-size: 0.75rem;
  color: var(--ink-muted);
  margin: 4px 0;
}

.gallery-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  background: #fffdf8;
  border: 1px solid rgba(94, 62, 34, 0.16);
  border-radius: 8px;
  padding: 6px 9px;
  font-size: 0.78rem;
}

.gallery-meta { display: flex; flex-direction: column; }
.gallery-meta small { font-size: 0.66rem; color: var(--ink-muted); }
.gallery-actions { display: flex; gap: 5px; }

.dialog-files {
  display: flex;
  gap: 8px;
  margin-bottom: 0;
}

.file-label { display: inline-flex; align-items: center; }

.studio-footer {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 6px;
  padding: 5px 12px;
  border-radius: 10px;
  font-size: 0.7rem;
  color: #fdf5e8;
  background: rgba(44, 26, 12, 0.56);
  border: 1px solid rgba(255, 240, 215, 0.16);
}

.studio-footer a {
  color: #ffd8ad;
  font-weight: 700;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.studio-footer a:hover {
  color: #ffffff;
}

.help-list {
  margin: 0;
  padding-left: 18px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 0.78rem;
  line-height: 1.4;
}

.shortcut-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 6px 12px;
  font-size: 0.74rem;
}

.help-dialog kbd {
  display: inline-block;
  padding: 1px 5px;
  border-radius: 4px;
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  font-size: 0.68rem;
  font-weight: 700;
  background: #fffdf8;
  border: 1px solid rgba(94, 62, 34, 0.28);
  box-shadow: 0 1px 0 rgba(94, 62, 34, 0.18);
}

.help-foot {
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding-top: 8px;
  border-top: 1px solid rgba(94, 62, 34, 0.16);
  font-size: 0.76rem;
}

.help-foot a {
  color: var(--accent-deep);
}

.help-foot small {
  color: var(--ink-muted);
  font-size: 0.7rem;
}

:focus-visible {
  outline: 2.5px solid var(--focus-ring);
  outline-offset: 2px;
}

@media (max-width: 980px) {
  .studio { grid-template-columns: minmax(0, 1fr); }
  .stage-row { flex-direction: column; gap: 10px; }
  .slab-viewport { flex: none; width: 100%; padding: 4px 4px 14px; }
  .tube-bridge { transform: rotate(90deg); height: 18px; }
  .ytong-slab { width: min(100%, 560px); max-height: none; }
  .tool-dock { min-width: 0; max-width: 560px; width: 100%; margin: 0 auto; }
}

@media (max-width: 540px) {
  .workbench { padding: 6px 8px 10px; gap: 6px; }
  .topbar { padding: 7px 10px; gap: 8px; }
  .tagline { font-size: 0.7rem; }
  .action-btn { padding: 5px 8px; font-size: 0.72rem; }
  .panel-card { padding: 8px 8px; }
  .hint-inline { display: none; }
  .sketch-bar .mini-btn { padding: 4px 2px; font-size: 0.63rem; }
  .wall-row { flex-wrap: wrap; }
  .slider-grid-3 { gap: 6px; }
  .preset-grid,
  .blueprint-grid,
  .shortcut-grid { grid-template-columns: 1fr; }
}

@media (max-width: 400px) {
  .quick-bar { grid-template-columns: repeat(2, 1fr); }
}

@media (pointer: coarse), (max-width: 980px) {
  .action-btn,
  .dock-tab,
  .mini-btn,
  .mat-btn,
  .stamp-btn,
  .zoom-btn {
    min-height: 40px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
  }
}
