:root {
  --bg: #0f172a;
  --panel-bg: #1e293b;
  --card-bg: #334155;
  --primary: #38bdf8;
  --primary-hover: #0284c7;
  --text: #f8fafc;
  --text-muted: #94a3b8;
  --border: #475569;
  --warning-bg: rgba(234, 179, 8, 0.12);
  --warning-border: #eab308;
  --warning-text: #fef08a;
  --success-bg: rgba(16, 185, 129, 0.12);
  --success-border: #10b981;
  --success-text: #6ee7b7;
}

* { 
  box-sizing: border-box; 
}

body { 
  font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif; 
  background: var(--bg); 
  color: var(--text); 
  margin: 0; 
  padding: 1.5rem 1rem; 
}

/* Master 3-Panel Dashboard Layout */
.dashboard-grid {
  display: grid;
  grid-template-columns: 300px 1fr 350px;
  gap: 1rem;
  max-width: 1520px;
  margin: 0 auto;
}

@media (max-width: 1100px) {
  .dashboard-grid {
    grid-template-columns: 300px 1fr;
  }
  .panel.controls {
    grid-column: span 2;
  }
}

@media (max-width: 768px) {
  .dashboard-grid {
    grid-template-columns: 1fr;
  }
  .panel.controls {
    grid-column: span 1;
  }
}

/* Panel Containers */
.panel { 
  background: var(--panel-bg); 
  border-radius: 10px; 
  overflow: hidden; 
  border: 1px solid var(--border); 
  display: flex;
  flex-direction: column;
}

.panel-header { 
  background: #0a0e1b; 
  color: var(--text-muted); 
  font-size: 0.8rem; 
  padding: 10px 14px; 
  font-weight: 700; 
  letter-spacing: 0.05em;
  text-transform: uppercase; 
  display: flex; 
  justify-content: space-between; 
  align-items: center;
  border-bottom: 1px solid var(--border);
  position: relative;
  z-index: 50;
}

.header-tools {
  display: flex;
  align-items: center;
  gap: 8px;
  position: relative;
  z-index: 60;
}

/* Crop Lock Button */
.btn-lock {
  background: #0f172a;
  border: 1px solid var(--border);
  color: var(--text);
  font-size: 0.76rem;
  font-weight: 600;
  padding: 5px 10px;
  border-radius: 14px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  transition: all 0.2s ease;
}

.btn-lock:hover {
  border-color: var(--primary);
  color: #fff;
}

.btn-lock.locked {
  background: rgba(16, 185, 129, 0.2);
  border-color: #10b981;
  color: #6ee7b7;
}

.status-badge { 
  color: var(--primary); 
  font-weight: 600;
  font-size: 0.75rem;
  background: rgba(56, 189, 248, 0.1);
  padding: 2px 8px;
  border-radius: 12px;
  border: 1px solid rgba(56, 189, 248, 0.2);
}

.card { 
  background: var(--card-bg); 
  margin: 0.75rem; 
  padding: 1rem; 
  border-radius: 8px; 
  border: 1px solid var(--border); 
}

.card-header { 
  font-size: 0.75rem; 
  text-transform: uppercase; 
  color: var(--text-muted); 
  margin-bottom: 10px; 
  font-weight: 700; 
  letter-spacing: 0.05em;
}

/* Panel 1: Upload, Camera & Shape/Hook Pickers */
.upload-card { 
  border: 2px dashed #64748b; 
  text-align: center; 
  cursor: pointer; 
  display: flex; 
  flex-direction: column; 
  align-items: center; 
  padding: 1.25rem 1rem; 
  transition: all 0.2s ease; 
}

.upload-card:hover { 
  background: rgba(56, 189, 248, 0.05); 
  border-color: var(--primary); 
}

.upload-card svg {
  margin-bottom: 0.5rem;
}

.upload-card p { 
  font-size: 0.85rem; 
  line-height: 1.4; 
  color: var(--text-muted); 
  margin: 0; 
}

.upload-card strong { 
  color: var(--text); 
  font-size: 0.92rem; 
}

.btn-camera {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: #0f172a;
  border: 1px solid #64748b;
  color: var(--text);
  margin: 0 0.75rem 0.5rem;
  padding: 10px;
  border-radius: 6px;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  touch-action: manipulation;
  transition: all 0.2s ease;
}

.btn-camera:hover {
  background: #1e293b;
  border-color: var(--primary);
  color: var(--primary);
}

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

.opt-btn {
  background: #0f172a;
  border: 1px solid var(--border);
  color: var(--text);
  padding: 10px 8px;
  border-radius: 6px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  touch-action: manipulation;
  transition: all 0.2s ease;
}

.opt-btn:hover:not(:disabled) {
  border-color: var(--primary);
  background: #152238;
}

.opt-btn.active {
  background: #1a2a41;
  border-color: var(--primary);
  box-shadow: 0 0 0 1px var(--primary);
}

.opt-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  border-color: var(--border);
}

.opt-btn strong {
  font-size: 0.85rem;
}

.opt-btn small {
  color: var(--text-muted);
  font-size: 0.72rem;
}

.opt-btn.active small {
  color: #7dd3fc;
}

/* Shape Preview Icons */
.shape-icon {
  width: 22px;
  height: 22px;
  border: 2px solid var(--text-muted);
  display: inline-block;
  margin-bottom: 2px;
  border-radius: 2px;
}

.icon-square {
  width: 20px;
  height: 20px;
}

.icon-portrait {
  width: 16px;
  height: 24px;
}

.icon-landscape {
  width: 24px;
  height: 16px;
}

.icon-circle {
  width: 22px;
  height: 22px;
  border-radius: 50%;
}

.opt-btn.active .shape-icon {
  border-color: var(--primary);
}

.hook-preview-icon {
  font-size: 0.85rem;
  letter-spacing: 2px;
  color: var(--text-muted);
}

.opt-btn.active .hook-preview-icon {
  color: var(--primary);
}

/* Panel 2: Preview & Crop Workspace */
.res-warning {
  margin: 0.75rem 0.75rem 0;
  padding: 8px 12px;
  background: var(--warning-bg);
  border: 1px solid var(--warning-border);
  color: var(--warning-text);
  border-radius: 6px;
  font-size: 0.78rem;
  display: flex;
  align-items: center;
  gap: 8px;
  line-height: 1.35;
}

.canvas-card { 
  min-height: 540px; 
  height: 100%;
  background: #070b14; 
  border: 1px solid #1e293b; 
  padding: 0; 
  margin: 0.75rem;
  border-radius: 8px;
  overflow: hidden;
  position: relative; 
  display: flex;
  align-items: center;
  justify-content: center;
}

.cropper-wrapper {
  width: 100%;
  height: 100%;
  position: relative;
  background: #000;
}

.cropper-wrapper img {
  max-width: 100%;
  display: block;
}

.cropper-view-box {
  outline: 2px solid var(--primary);
  outline-color: rgba(56, 189, 248, 0.85);
}

.is-circle .cropper-view-box,
.is-circle .cropper-face {
  border-radius: 50%;
}

/* 3.0mm Slim Border Overlay Guide */
.border-overlay-guide {
  position: absolute;
  pointer-events: none;
  border: 9px solid rgba(248, 250, 252, 0.45);
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.4), 0 0 0 1px rgba(255, 255, 255, 0.25);
  z-index: 10;
  display: none;
  transition: border-radius 0.2s ease;
}

.border-overlay-guide.is-circle {
  border-radius: 50%;
}

/* Integrated Outer Keychain/Hanging Tab */
.hook-guide {
  position: absolute;
  top: -34px;
  width: 24px;
  height: 28px;
  background: rgba(248, 250, 252, 0.95);
  border-radius: 12px 12px 2px 2px;
  border: 1px solid rgba(255, 255, 255, 0.6);
  border-bottom: none;
  display: none;
  transform: translateX(-50%);
  box-shadow: 0 -2px 6px rgba(0, 0, 0, 0.35);
  z-index: 12;
}

.hook-guide::after {
  content: '';
  position: absolute;
  top: 6px;
  left: 50%;
  transform: translateX(-50%);
  width: 10px;
  height: 10px;
  background: #070b14;
  border-radius: 50%;
  box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.8);
}

.hook-guide::before {
  content: '';
  position: absolute;
  bottom: -6px;
  left: -5px;
  width: 34px;
  height: 8px;
  background: rgba(248, 250, 252, 0.95);
  clip-path: polygon(15% 0, 85% 0, 100% 100%, 0% 100%);
}

.hook-guide.hook-center {
  left: 50%;
}

.hook-guide.hook-left {
  left: 20%;
}

.hook-guide.hook-right {
  left: 80%;
}

.border-overlay-guide.is-circle .hook-guide.hook-center {
  top: -34px;
  left: 50%;
}

/* Panel 3: Controls, Sliders & Tone Explainer */
.slider-group { 
  margin-bottom: 12px; 
}

.slider-label { 
  display: flex;
  justify-content: space-between;
  font-size: 0.82rem; 
  color: var(--text-muted); 
  margin-bottom: 6px; 
}

.slider-label span:last-child {
  color: var(--primary);
  font-weight: 600;
}

.slider-group input[type="range"] { 
  width: 100%; 
  accent-color: var(--primary);
  cursor: pointer;
}

.btn-secondary {
  width: 100%;
  background: #0f172a;
  border: 1px solid var(--border);
  color: var(--text-muted);
  padding: 8px;
  font-size: 0.8rem;
  border-radius: 5px;
  cursor: pointer;
  margin-top: 6px;
  margin-bottom: 12px;
  touch-action: manipulation;
  transition: all 0.2s;
}

.btn-secondary:hover {
  color: var(--text);
  border-color: #64748b;
}

.tone-explainer {
  background: #0f172a;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 10px 12px;
  font-size: 0.77rem;
  line-height: 1.45;
  color: var(--text-muted);
}

.tone-explainer strong {
  color: #38bdf8;
  display: block;
  margin-bottom: 4px;
  font-size: 0.8rem;
}

.tone-explainer p {
  margin: 0 0 6px;
}

.tone-explainer ul {
  margin: 0;
  padding-left: 1rem;
}

.tone-explainer li {
  margin-bottom: 4px;
}

.tone-explainer li strong {
  display: inline;
  color: var(--text);
}

.specs-card {
  padding: 0.85rem 1rem;
}

.specs-list {
  margin: 0;
  padding-left: 1.1rem;
  color: var(--text-muted);
  font-size: 0.78rem;
  line-height: 1.6;
}

.specs-list strong {
  color: var(--text);
}

.submit-card { 
  display: flex; 
  flex-direction: column; 
  gap: 8px; 
}

.submit-card input, 
.submit-card textarea { 
  background: #0f172a; 
  color: var(--text); 
  border: 1px solid var(--border); 
  border-radius: 6px; 
  padding: 9px 12px; 
  font-size: 0.88rem; 
  width: 100%;
  outline: none;
  transition: border-color 0.2s;
}

.submit-card input:focus, 
.submit-card textarea:focus {
  border-color: var(--primary);
}

.btn-submit { 
  background: var(--primary); 
  color: #000; 
  border: none; 
  padding: 12px; 
  border-radius: 6px; 
  font-weight: 700; 
  cursor: pointer; 
  touch-action: manipulation;
  transition: background 0.2s ease; 
  font-size: 0.92rem; 
}

.btn-submit:hover { 
  background: var(--primary-hover); 
}

.status-msg { 
  font-size: 0.82rem; 
  text-align: center; 
  margin: 4px 0 0; 
}

.export-success-box {
  background: var(--success-bg);
  border: 1px solid var(--success-border);
  color: var(--success-text);
  border-radius: 6px;
  padding: 10px 12px;
  font-size: 0.78rem;
  line-height: 1.45;
  margin-top: 6px;
}

.export-success-box strong {
  display: block;
  font-size: 0.84rem;
  margin-bottom: 2px;
}