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

:root {
  --ink:       #0D0B09;
  --ink-2:     #1A1612;
  --ink-3:     #252017;
  --ink-4:     #342C20;
  --line:      rgba(201,168,76,0.12);
  --line-md:   rgba(201,168,76,0.22);
  --line-hi:   rgba(201,168,76,0.45);
  --gold:      #C9A84C;
  --gold-lt:   #E8C97A;
  --sand:      #F0DEB8;
  --cream:     #FAF3E4;
  --teal:      #0ABFA3;
  --teal-dim:  #076E5F;
  --red:       #E05252;
  --amber:     #E09A2B;
  --green:     #3DBD7D;
  --blue:      #4A9EE8;
  --muted:     rgba(240,222,184,0.45);
  --font:      'DM Sans', sans-serif;
  --mono:      'DM Mono', monospace;
  --serif:     'Cormorant Garamond', serif;
  --sidebar-w: 220px;
  --topbar-h:  56px;
}

/* Light theme */
[data-theme="light"] {
  --ink:       #FAFAFA;
  --ink-2:     #F5F5F5;
  --ink-3:     #EEEEEE;
  --ink-4:     #E0E0E0;
  --line:      rgba(0,0,0,0.08);
  --line-md:   rgba(0,0,0,0.12);
  --line-hi:   rgba(0,0,0,0.2);
  --gold:      #B8860B;
  --gold-lt:   #DAA520;
  --sand:      #424242;
  --cream:     #FDF5E6;
  --teal:      #00897B;
  --teal-dim:  #00695C;
  --red:       #D32F2F;
  --amber:     #F57C00;
  --green:     #388E3C;
  --blue:      #1976D2;
  --muted:     rgba(66,66,66,0.6);
}

html, body { height: 100%; overflow: hidden; }

body {
  font-family: var(--font);
  font-size: 13px;
  background: var(--ink);
  color: var(--sand);
  display: flex;
  flex-direction: column;
  transition: background 0.3s ease, color 0.3s ease;
}

/* ── TOPBAR ── */
#topbar {
  height: var(--topbar-h);
  background: var(--ink-2);
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  padding: 0 20px;
  gap: 16px;
  flex-shrink: 0;
  z-index: 100;
  transition: background 0.3s ease, border-color 0.3s ease;
}

.topbar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-right: auto;
}

.brand-icon {
  width: 32px; height: 32px;
  background: linear-gradient(135deg, var(--ink-4), var(--gold));
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  font-size: 16px;
  flex-shrink: 0;
  border: 1px solid var(--line-md);
}

.brand-name {
  font-family: var(--serif);
  font-size: 18px;
  color: var(--gold-lt);
  letter-spacing: 0.5px;
  line-height: 1;
}

.brand-sub {
  font-size: 10px;
  color: var(--muted);
  letter-spacing: 2px;
  text-transform: uppercase;
  font-weight: 400;
  margin-top: 2px;
}

.topbar-pill {
  display: flex; align-items: center; gap: 6px;
  background: var(--ink-3);
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 5px 12px;
  font-size: 11px;
  color: var(--muted);
  font-family: var(--mono);
}

.status-dot {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--red);
  transition: background 0.3s;
}

.status-dot.connected { background: var(--green); box-shadow: 0 0 6px var(--green); }
.status-dot.connecting { background: var(--amber); animation: blink 0.8s infinite; }

@keyframes blink { 0%,100%{opacity:1} 50%{opacity:0.3} }

.topbar-btns { display: flex; gap: 8px; }

/* Theme toggle button */
.theme-toggle {
  background: var(--ink-3);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px;
  cursor: pointer;
  color: var(--sand);
  font-size: 16px;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
}
.theme-toggle:hover {
  background: rgba(201,168,76,0.1);
  border-color: var(--gold);
  color: var(--gold-lt);
}

/* Mobile menu button */
.mobile-menu-btn {
  display: none;
  background: none;
  border: none;
  color: var(--sand);
  font-size: 20px;
  cursor: pointer;
  padding: 4px;
}

/* ── MAIN LAYOUT ── */
#layout {
  display: flex;
  flex: 1;
  overflow: hidden;
}

/* ── SIDEBAR ── */
#sidebar {
  width: var(--sidebar-w);
  background: var(--ink-2);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  overflow-y: auto;
  padding: 12px 0;
  transition: transform 0.3s ease, background 0.3s ease, border-color 0.3s ease;
}

.nav-section-label {
  font-size: 9px;
  letter-spacing: 2.5px;
  text-transform: uppercase;
  color: var(--muted);
  padding: 10px 16px 4px;
  font-weight: 500;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 16px;
  cursor: pointer;
  border-radius: 0;
  transition: background 0.15s;
  color: rgba(240,222,184,0.55);
  font-size: 12.5px;
  font-weight: 400;
  position: relative;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
}

.nav-item i { font-size: 15px; flex-shrink: 0; }

.nav-item:hover { background: rgba(201,168,76,0.06); color: var(--sand); }

.nav-item.active {
  background: rgba(201,168,76,0.1);
  color: var(--gold-lt);
  font-weight: 500;
}

.nav-item.active::before {
  content: '';
  position: absolute;
  left: 0; top: 20%; bottom: 20%;
  width: 2px;
  background: var(--teal);
  border-radius: 0 2px 2px 0;
}

.nav-divider {
  height: 1px;
  background: var(--line);
  margin: 8px 16px;
}

/* MQTT panel in sidebar */
#mqtt-panel {
  margin-top: auto;
  padding: 12px;
  border-top: 1px solid var(--line);
}

.mqtt-broker {
  font-size: 10px;
  font-family: var(--mono);
  color: var(--teal);
  background: rgba(10,191,163,0.07);
  border: 1px solid rgba(10,191,163,0.15);
  border-radius: 6px;
  padding: 4px 8px;
  word-break: break-all;
  margin-bottom: 8px;
  line-height: 1.5;
}

#conn-log {
  font-family: var(--mono);
  font-size: 9.5px;
  color: var(--muted);
  max-height: 70px;
  overflow-y: auto;
  line-height: 1.6;
}

/* ── CONTENT AREA ── */
#content {
  flex: 1;
  overflow-y: auto;
  background: var(--ink);
  display: flex;
  flex-direction: column;
}

.panel { display: none; flex: 1; }
.panel.active { display: flex; flex-direction: column; }

/* Panel Header */
.panel-header {
  padding: 20px 24px 0;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: flex-end;
  gap: 24px;
  flex-shrink: 0;
}

.panel-title {
  font-family: var(--serif);
  font-size: 22px;
  color: var(--gold-lt);
  letter-spacing: 0.3px;
  padding-bottom: 14px;
  border-bottom: 2px solid var(--teal);
  margin-bottom: -1px;
}

.panel-meta {
  font-size: 11px;
  color: var(--muted);
  padding-bottom: 16px;
}

/* Panel Body */
.panel-body {
  padding: 20px 24px;
  flex: 1;
  overflow-y: auto;
}

/* ── GRID LAYOUTS ── */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 12px; }
.grid-auto { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; }

/* ── CARDS ── */
.card {
  background: var(--ink-2);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 16px;
  transition: border-color 0.2s, background 0.3s ease;
}

.card:hover { border-color: var(--line-md); }

.card-title {
  font-size: 9px;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 500;
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.card-title i { font-size: 12px; color: var(--gold); }

/* ── STAT CARDS ── */
.stat-card {
  background: var(--ink-2);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 14px 16px;
  transition: background 0.3s ease, border-color 0.3s ease;
}

.stat-label {
  font-size: 10px;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 4px;
}

.stat-value {
  font-family: var(--mono);
  font-size: 20px;
  color: var(--sand);
  font-weight: 500;
}

.stat-value.accent { color: var(--teal); }
.stat-value.gold { color: var(--gold-lt); }

/* ── BUTTONS ── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: 1px solid var(--line-md);
  border-radius: 8px;
  padding: 8px 14px;
  font-family: var(--font);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
  background: transparent;
  color: var(--sand);
  white-space: nowrap;
}

.btn:hover { background: rgba(201,168,76,0.08); border-color: var(--gold); color: var(--gold-lt); }
.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.35; cursor: not-allowed; pointer-events: none; }

.btn-sm { padding: 6px 10px; font-size: 11px; }
.btn-full { width: 100%; }
.btn-icon { padding: 8px; gap: 0; }

.btn-primary {
  background: linear-gradient(135deg, rgba(74,158,232,0.2), rgba(74,158,232,0.08));
  border-color: rgba(74,158,232,0.4);
  color: #93C5FD;
}
.btn-primary:hover { background: rgba(74,158,232,0.2); border-color: var(--blue); color: #DBEAFE; }

.btn-success {
  background: linear-gradient(135deg, rgba(61,189,125,0.18), rgba(61,189,125,0.06));
  border-color: rgba(61,189,125,0.4);
  color: #86EFAC;
}
.btn-success:hover { background: rgba(61,189,125,0.22); border-color: var(--green); color: #D1FAE5; }

.btn-danger {
  background: linear-gradient(135deg, rgba(224,82,82,0.18), rgba(224,82,82,0.06));
  border-color: rgba(224,82,82,0.35);
  color: #FCA5A5;
}
.btn-danger:hover { background: rgba(224,82,82,0.22); border-color: var(--red); color: #FEE2E2; }

.btn-warning {
  background: linear-gradient(135deg, rgba(224,154,43,0.18), rgba(224,154,43,0.06));
  border-color: rgba(224,154,43,0.35);
  color: #FCD34D;
}

.btn-gold {
  background: linear-gradient(135deg, rgba(201,168,76,0.25), rgba(201,168,76,0.1));
  border-color: rgba(201,168,76,0.5);
  color: var(--gold-lt);
}
.btn-gold:hover { background: rgba(201,168,76,0.3); border-color: var(--gold-lt); color: var(--cream); }

.btn-teal {
  background: linear-gradient(135deg, rgba(10,191,163,0.2), rgba(10,191,163,0.06));
  border-color: rgba(10,191,163,0.4);
  color: #5EEAD4;
}
.btn-teal:hover { background: rgba(10,191,163,0.25); border-color: var(--teal); color: #CCFBF1; }

/* ── FORM ELEMENTS ── */
.field { margin-bottom: 12px; }

.field-label {
  display: block;
  font-size: 10px;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 5px;
  font-weight: 500;
}

.input {
  width: 100%;
  background: var(--ink-3);
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 7px 10px;
  color: var(--sand);
  font-family: var(--font);
  font-size: 13px;
  transition: border-color 0.15s, background 0.3s ease;
  outline: none;
}

.input:focus { border-color: var(--gold); box-shadow: 0 0 0 2px rgba(201,168,76,0.12); }
.input::placeholder { color: rgba(240,222,184,0.25); }

.range-row { display: flex; align-items: center; gap: 10px; }

input[type=range] {
  flex: 1;
  -webkit-appearance: none;
  appearance: none;
  height: 3px;
  background: rgba(201,168,76,0.18);
  border-radius: 99px;
  outline: none;
  cursor: pointer;
}

input[type=range]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 14px; height: 14px;
  border-radius: 50%;
  background: var(--gold);
  cursor: pointer;
  transition: transform 0.15s;
  box-shadow: 0 0 0 3px rgba(201,168,76,0.15);
}

input[type=range]::-webkit-slider-thumb:hover { transform: scale(1.25); }

.range-val {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--gold-lt);
  min-width: 30px;
  text-align: right;
}

.toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 0;
  border-bottom: 1px solid var(--line);
}

.toggle-row:last-child { border-bottom: none; }
.toggle-label { font-size: 12px; color: var(--sand); }
.toggle-sub { font-size: 10px; color: var(--muted); margin-top: 1px; }

/* Toggle switch */
.switch { position: relative; display: inline-block; width: 36px; height: 20px; }
.switch input { display: none; }
.slider-sw {
  position: absolute; inset: 0;
  background: var(--ink-4);
  border: 1px solid var(--line-md);
  border-radius: 20px;
  cursor: pointer;
  transition: background 0.2s;
}
.slider-sw::before {
  content: '';
  position: absolute;
  width: 14px; height: 14px;
  left: 2px; top: 2px;
  border-radius: 50%;
  background: var(--muted);
  transition: transform 0.2s, background 0.2s;
}
.switch input:checked + .slider-sw { background: rgba(10,191,163,0.25); border-color: var(--teal); }
.switch input:checked + .slider-sw::before { transform: translateX(16px); background: var(--teal); }

/* ── BADGE ── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 10px;
  font-family: var(--mono);
  padding: 3px 8px;
  border-radius: 20px;
  font-weight: 400;
}

.badge-success { background: rgba(61,189,125,0.12); color: #86EFAC; border: 1px solid rgba(61,189,125,0.25); }
.badge-danger  { background: rgba(224,82,82,0.12);  color: #FCA5A5; border: 1px solid rgba(224,82,82,0.25); }
.badge-warning { background: rgba(224,154,43,0.12); color: #FCD34D; border: 1px solid rgba(224,154,43,0.25); }
.badge-teal    { background: rgba(10,191,163,0.10); color: #5EEAD4; border: 1px solid rgba(10,191,163,0.22); }
.badge-gold    { background: rgba(201,168,76,0.12); color: var(--gold-lt); border: 1px solid rgba(201,168,76,0.25); }
.badge-blue    { background: rgba(74,158,232,0.12); color: #93C5FD; border: 1px solid rgba(74,158,232,0.25); }

/* ── PROGRESS ── */
.progress-track {
  height: 4px;
  background: rgba(201,168,76,0.1);
  border-radius: 99px;
  overflow: visible;
  position: relative;
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--gold), var(--teal));
  border-radius: 99px;
  transition: width 0.4s ease;
  position: relative;
}

.progress-fill::after {
  content: '';
  position: absolute;
  right: -4px; top: 50%;
  transform: translateY(-50%);
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--teal);
  box-shadow: 0 0 8px var(--teal);
}

.progress-labels {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 6px;
}

.progress-text { font-size: 10px; color: var(--muted); font-family: var(--mono); }
.progress-pct { font-size: 12px; color: var(--teal); font-family: var(--mono); font-weight: 500; }

/* ── JOG PAD ── */
.jog-grid {
  display: grid;
  grid-template-columns: repeat(3, 52px);
  grid-template-rows: repeat(3, 52px);
  gap: 4px;
  justify-content: center;
}

.jog-btn {
  width: 52px; height: 52px;
  border: 1px solid var(--line-md);
  border-radius: 8px;
  background: var(--ink-3);
  color: var(--sand);
  font-size: 14px;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: all 0.15s;
  font-family: var(--mono);
  font-weight: 500;
}

.jog-btn:hover { background: rgba(201,168,76,0.1); border-color: var(--gold); color: var(--gold-lt); transform: scale(1.05); }
.jog-btn:active { transform: scale(0.95); }
.jog-btn:disabled { opacity: 0.25; pointer-events: none; }
.jog-center {
  background: rgba(10,191,163,0.08);
  border-color: rgba(10,191,163,0.25);
  color: var(--teal);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.5px;
}

/* ── GCODE VIEWER ── */
.gcode-box {
  background: var(--ink);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  max-height: 200px;
  overflow-y: auto;
  font-family: var(--mono);
  font-size: 10.5px;
  color: rgba(240,222,184,0.6);
  line-height: 1.8;
}

.gcode-box::-webkit-scrollbar { width: 3px; }
.gcode-box::-webkit-scrollbar-thumb { background: rgba(201,168,76,0.2); border-radius: 99px; }

/* ── CANVAS SECTION ── */
#gcode-canvas {
  width: 100%;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: #07050302;
  display: block;
}

/* ── COMPLETION BANNER ── */
.done-banner {
  background: linear-gradient(135deg, rgba(10,191,163,0.12), rgba(61,189,125,0.08));
  border: 1px solid rgba(10,191,163,0.3);
  border-radius: 14px;
  padding: 28px;
  text-align: center;
  animation: popIn 0.4s cubic-bezier(0.16,1,0.3,1);
}

@keyframes popIn {
  from { opacity:0; transform: scale(0.94) translateY(8px); }
  to   { opacity:1; transform: scale(1) translateY(0); }
}

/* ── SETTINGS LOCK ── */
.settings-section {
  background: var(--ink-2);
  border: 1px solid var(--line);
  border-radius: 12px;
  margin-bottom: 12px;
  overflow: hidden;
}

.settings-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
}

.settings-title {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: var(--gold);
  display: flex; align-items: center; gap: 8px;
}

.settings-title i { font-size: 13px; }

.settings-body { padding: 16px; }

.locked .settings-body { opacity: 0.4; pointer-events: none; }

/* ── DIVIDER ── */
.divider { height: 1px; background: var(--line); margin: 14px 0; }

/* ── IMAGE PREVIEW ── */
.img-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.img-wrap {
  position: relative;
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid var(--line);
  background: var(--ink-3);
}

.img-wrap img { width: 100%; display: block; }
.img-label {
  position: absolute;
  bottom: 0; left: 0; right: 0;
  padding: 6px 10px;
  background: rgba(13,11,9,0.85);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: var(--muted);
  backdrop-filter: blur(4px);
}

/* ── TOPIC BADGES ── */
.topic-list { display: flex; flex-direction: column; gap: 5px; }
.topic-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 8px;
  background: rgba(10,191,163,0.05);
  border: 1px solid rgba(10,191,163,0.12);
  border-radius: 6px;
}
.topic-dot { width: 4px; height: 4px; border-radius: 50%; background: var(--teal); }
.topic-text { font-family: var(--mono); font-size: 10px; color: var(--teal); }

/* ── SCROLLBAR ── */
::-webkit-scrollbar { width: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(201,168,76,0.2); border-radius: 99px; }

/* ── RESPONSIVE DESIGN ── */
@media (max-width: 768px) {
  :root {
    --sidebar-w: 0px;
  }
  
  #sidebar {
    position: fixed;
    top: var(--topbar-h);
    left: 0;
    bottom: 0;
    width: 260px;
    z-index: 200;
    transform: translateX(-100%);
    box-shadow: 4px 0 20px rgba(0,0,0,0.3);
  }
  
  #sidebar.open {
    transform: translateX(0);
  }
  
  .mobile-menu-btn {
    display: flex;
  }
  
  #topbar {
    padding: 0 12px;
  }
  
  .topbar-brand {
    margin-right: 8px;
  }
  
  .brand-name {
    font-size: 16px;
  }
  
  .topbar-pill {
    display: none;
  }
  
  .topbar-btns .btn {
    padding: 6px 10px;
    font-size: 11px;
  }
  
  .grid-2 {
    grid-template-columns: 1fr;
  }
  
  .grid-3 {
    grid-template-columns: 1fr;
  }
  
  .panel-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
    padding: 16px;
  }
  
  .panel-body {
    padding: 16px;
  }
  
  .jog-grid {
    grid-template-columns: repeat(3, 48px);
    grid-template-rows: repeat(3, 48px);
  }
  
  .jog-btn {
    width: 48px;
    height: 48px;
    font-size: 13px;
  }
  
  .pos-display {
    gap: 6px;
  }
  
  .pos-axis {
    padding: 8px 10px;
  }
  
  .pos-axis-val {
    font-size: 16px;
  }
  
  .pattern-grid {
    grid-template-columns: 1fr 1fr;
  }
  
  .file-drop {
    padding: 20px;
  }
  
  .file-drop-icon {
    font-size: 24px;
  }
  
  .action-btn {
    padding: 12px;
    font-size: 12px;
  }
  
  .settings-section {
    margin-bottom: 10px;
  }
  
  .settings-body {
    padding: 12px;
  }
  
  /* Overlay when sidebar is open */
  .sidebar-overlay {
    display: none;
    position: fixed;
    top: var(--topbar-h);
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.5);
    z-index: 150;
  }
  
  .sidebar-overlay.active {
    display: block;
  }
}

@media (max-width: 480px) {
  .brand-name {
    font-size: 14px;
  }
  
  .brand-sub {
    font-size: 9px;
  }
  
  .topbar-btns {
    gap: 4px;
  }
  
  .topbar-btns .btn {
    padding: 5px 8px;
    font-size: 10px;
  }
  
  .btn {
    padding: 6px 10px;
    font-size: 11px;
  }
  
  .stat-value {
    font-size: 16px;
  }
  
  .panel-title {
    font-size: 18px;
  }
  
  .panel-meta {
    font-size: 10px;
  }
  
  .jog-grid {
    grid-template-columns: repeat(3, 44px);
    grid-template-rows: repeat(3, 44px);
  }
  
  .jog-btn {
    width: 44px;
    height: 44px;
    font-size: 12px;
  }
  
  .pattern-grid {
    grid-template-columns: 1fr;
  }
}

/* ── ALERT ── */
.alert {
  border-radius: 8px;
  padding: 10px 14px;
  font-size: 12px;
  display: flex;
  align-items: flex-start;
  gap: 8px;
  margin-bottom: 12px;
}
.alert i { font-size: 14px; flex-shrink: 0; margin-top: 1px; }
.alert-info { background: rgba(74,158,232,0.08); border: 1px solid rgba(74,158,232,0.2); color: #BFDBFE; }
.alert-warn { background: rgba(224,154,43,0.08); border: 1px solid rgba(224,154,43,0.2); color: #FDE68A; }

/* ── MISC ── */
.flex  { display: flex; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-8 { gap: 8px; }
.gap-12 { gap: 12px; }
.gap-16 { gap: 16px; }
.mb-8  { margin-bottom: 8px; }
.mb-12 { margin-bottom: 12px; }
.mb-16 { margin-bottom: 16px; }
.mt-16 { margin-top: 16px; }
.mt-8  { margin-top: 8px; }
.w-full{ width: 100%; }
.hidden { display: none !important; }
.text-muted { color: var(--muted); }
.text-teal  { color: var(--teal); }
.text-gold  { color: var(--gold-lt); }
.text-small { font-size: 11px; }
.mono { font-family: var(--mono); }

/* ── FILE INPUT ── */
.file-drop {
  border: 1.5px dashed rgba(201,168,76,0.25);
  border-radius: 12px;
  padding: 28px;
  text-align: center;
  background: rgba(201,168,76,0.02);
  cursor: pointer;
  transition: all 0.2s;
}
.file-drop:hover { border-color: var(--gold); background: rgba(201,168,76,0.05); }
.file-drop input { display: none; }
.file-drop-icon { font-size: 28px; color: rgba(201,168,76,0.4); margin-bottom: 8px; }
.file-drop-text { font-size: 12px; color: var(--muted); }
.file-drop-sub   { font-size: 10px; color: rgba(240,222,184,0.3); margin-top: 4px; }

/* ── BIG ACTION BUTTON ── */
.action-btn {
  width: 100%;
  padding: 14px;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.5px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  cursor: pointer;
  border: none;
  transition: all 0.2s;
  font-family: var(--font);
}

.action-btn-upload {
  background: linear-gradient(135deg, rgba(74,158,232,0.25), rgba(74,158,232,0.1));
  border: 1px solid rgba(74,158,232,0.4);
  color: #93C5FD;
}
.action-btn-upload:hover { background: rgba(74,158,232,0.28); box-shadow: 0 0 20px rgba(74,158,232,0.2); }

.action-btn-start {
  background: linear-gradient(135deg, rgba(61,189,125,0.22), rgba(10,191,163,0.1));
  border: 1px solid rgba(61,189,125,0.45);
  color: #6EE7B7;
}
.action-btn-start:hover { background: rgba(61,189,125,0.28); box-shadow: 0 0 20px rgba(61,189,125,0.2); }

.action-btn-disabled {
  background: var(--ink-3);
  border: 1px solid var(--line);
  color: var(--muted);
  cursor: not-allowed;
}

/* ── POSITION DISPLAY ── */
.pos-display {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 8px;
}

.pos-axis {
  background: var(--ink-3);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  text-align: center;
}

.pos-axis-label {
  font-size: 10px;
  letter-spacing: 2px;
  color: var(--muted);
  font-weight: 600;
}

.pos-axis-val {
  font-family: var(--mono);
  font-size: 18px;
  font-weight: 500;
  margin-top: 2px;
}

.pos-axis-val.x { color: #F87171; }
.pos-axis-val.y { color: #34D399; }
.pos-axis-val.z { color: #60A5FA; }

/* ── TEST PATTERN GRID ── */
.pattern-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}

.pattern-btn {
  background: var(--ink-3);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px 8px;
  cursor: pointer;
  text-align: center;
  color: var(--muted);
  font-size: 11px;
  transition: all 0.15s;
  font-family: var(--font);
}

.pattern-btn i { display: block; font-size: 18px; margin-bottom: 4px; color: var(--gold); }
.pattern-btn:hover { background: rgba(201,168,76,0.08); border-color: var(--gold); color: var(--sand); }

/* ── CANVAS LEGEND ── */
.canvas-legend {
  display: flex;
  align-items: center;
  gap: 16px;
  font-size: 10px;
  color: var(--muted);
}

.legend-item { display: flex; align-items: center; gap: 5px; }
.legend-line { width: 20px; height: 2px; border-radius: 1px; }
.legend-draw { background: #1565C0; }
.legend-travel { background: transparent; border-top: 1.5px dashed rgba(180,180,180,0.5); }