/* ══════════════════════════════════════════════════════════════════════
   Apple macOS Sonoma / Sequoia Inspired Monotone Design System
   Sleek frosted glass, minimal typography, subtle borders, crisp feedback
   ══════════════════════════════════════════════════════════════════════ */

:root {
  --bg-desktop: #fbfbfd;
  --panel-bg: rgba(255, 255, 255, 0.72);
  --panel-card: rgba(255, 255, 255, 0.82);
  --border-subtle: rgba(0, 0, 0, 0.08);
  --border-strong: rgba(0, 0, 0, 0.16);
  --text-primary: #1d1d1f;
  --text-secondary: #86868b;
  --text-tertiary: #a1a1a6;
  --accent-black: #000000;
  --system-gray: #f5f5f7;
  --system-gray-hover: #e8e8ed;
  
  --radius-window: 20px;
  --radius-card: 14px;
  --radius-pill: 999px;
  --radius-btn: 10px;

  --shadow-window: 0 20px 48px rgba(0, 0, 0, 0.08), 0 1px 3px rgba(0, 0, 0, 0.04);
  --shadow-card: 0 4px 16px rgba(0, 0, 0, 0.03), 0 1px 2px rgba(0, 0, 0, 0.04);
  --shadow-btn: 0 1px 2px rgba(0, 0, 0, 0.06);

  --font: -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'Inter', system-ui, sans-serif;
  --font-mono: 'SF Mono', 'JetBrains Mono', Menlo, monospace;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-font-smoothing: antialiased;
}

body {
  font-family: var(--font);
  background: var(--bg-desktop);
  color: var(--text-primary);
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  overflow-x: hidden;
}

/* Background Subtle Ambient Glow */
.ambient-glow {
  position: fixed;
  top: -10vw;
  left: 20vw;
  width: 60vw;
  height: 40vw;
  background: radial-gradient(circle, rgba(0,0,0,0.025) 0%, transparent 70%);
  pointer-events: none;
  z-index: 0;
}

/* Main macOS Window Frame */
.window-container {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 1180px;
  background: var(--panel-bg);
  backdrop-filter: blur(28px) saturate(180%);
  -webkit-backdrop-filter: blur(28px) saturate(180%);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-window);
  box-shadow: var(--shadow-window);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

/* Window Titlebar (macOS style traffic lights) */
.window-titlebar {
  height: 52px;
  padding: 0 20px;
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  user-select: none;
}

.traffic-lights {
  display: flex;
  gap: 8px;
}
.traffic-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  border: 1px solid rgba(0,0,0,0.06);
}
.traffic-dot.close { background: #ff5f56; }
.traffic-dot.minimize { background: #ffbd2e; }
.traffic-dot.maximize { background: #27c93f; }

.titlebar-center {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
}
.titlebar-center strong {
  color: var(--text-primary);
  font-weight: 600;
}

.badge-engine {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  background: var(--system-gray);
  border-radius: var(--radius-pill);
  font-size: 11px;
  font-weight: 500;
  font-family: var(--font-mono);
  color: var(--text-primary);
  border: 1px solid var(--border-subtle);
}
.badge-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #34c759;
  box-shadow: 0 0 6px rgba(52, 199, 89, 0.6);
}
.badge-dot.loading {
  background: #ff9500;
  animation: pulse 1s infinite alternate;
}
@keyframes pulse { from { opacity: 0.4; } to { opacity: 1; } }

/* Window Body Grid */
.window-content {
  display: grid;
  grid-template-columns: 320px 1fr;
  min-height: 640px;
}

/* Left Sidebar Controls */
.sidebar {
  border-right: 1px solid var(--border-subtle);
  background: rgba(245, 245, 247, 0.45);
  padding: 24px 20px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.control-card {
  background: var(--panel-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-card);
  padding: 16px;
  box-shadow: var(--shadow-card);
}

.card-heading {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 12px;
}

.select-wrapper {
  margin-bottom: 12px;
}
.select-wrapper:last-child {
  margin-bottom: 0;
}
.select-label {
  display: block;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.macos-select {
  width: 100%;
  padding: 9px 12px;
  background: #ffffff;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-btn);
  font-family: var(--font);
  font-size: 13px;
  color: var(--text-primary);
  outline: none;
  cursor: pointer;
  box-shadow: var(--shadow-btn);
  transition: all 0.2s ease;
}
.macos-select:focus {
  border-color: var(--accent-black);
}

/* Loader / Download Bar */
.loader-box {
  margin-top: 10px;
  padding: 10px 12px;
  background: #ffffff;
  border-radius: var(--radius-btn);
  border: 1px solid var(--border-subtle);
}
.loader-header {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  font-family: var(--font-mono);
  color: var(--text-secondary);
  margin-bottom: 6px;
}
.progress-track {
  width: 100%;
  height: 5px;
  background: var(--system-gray);
  border-radius: var(--radius-pill);
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  width: 0%;
  background: var(--accent-black);
  border-radius: var(--radius-pill);
  transition: width 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

/* Sliders */
.slider-container {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.slider-top {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  color: var(--text-secondary);
}
.slider-top span.val {
  font-family: var(--font-mono);
  color: var(--text-primary);
  font-weight: 600;
}
input[type="range"].macos-slider {
  -webkit-appearance: none;
  width: 100%;
  height: 4px;
  background: var(--border-subtle);
  border-radius: var(--radius-pill);
  outline: none;
}
input[type="range"].macos-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #ffffff;
  border: 1px solid rgba(0,0,0,0.15);
  box-shadow: 0 2px 5px rgba(0,0,0,0.12);
  cursor: pointer;
  transition: transform 0.1s ease;
}
input[type="range"].macos-slider::-webkit-slider-thumb:active {
  transform: scale(1.15);
}

.checkbox-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--text-primary);
  margin-top: 10px;
  cursor: pointer;
}

/* Metric HUD Cards */
.metrics-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.metric-tile {
  background: #ffffff;
  padding: 10px 12px;
  border-radius: var(--radius-btn);
  border: 1px solid var(--border-subtle);
}
.metric-name {
  font-size: 10px;
  font-weight: 500;
  text-transform: uppercase;
  color: var(--text-secondary);
}
.metric-num {
  font-size: 18px;
  font-weight: 600;
  font-family: var(--font-mono);
  color: var(--text-primary);
  margin-top: 2px;
}

/* Right Viewport Area */
.main-viewport {
  padding: 24px 28px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* Segmented Control Tabs (Apple Style) */
.segmented-control {
  align-self: center;
  display: inline-flex;
  background: var(--system-gray);
  padding: 3px;
  border-radius: var(--radius-btn);
  border: 1px solid var(--border-subtle);
}
.segment-btn {
  padding: 6px 20px;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary);
  background: transparent;
  border: none;
  border-radius: 7px;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}
.segment-btn.active {
  background: #ffffff;
  color: var(--text-primary);
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}

/* Canvas Viewport */
.canvas-wrapper {
  flex: 1;
  position: relative;
  background: #ffffff;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-card);
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 480px;
  box-shadow: var(--shadow-card);
}
canvas {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  display: block;
}

/* Idle & Empty Overlay */
.viewport-empty-state {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  background: #ffffff;
  color: var(--text-secondary);
  z-index: 10;
}
.viewport-empty-state p {
  font-size: 13px;
  font-weight: 400;
}

/* Buttons */
.apple-btn {
  padding: 9px 18px;
  font-size: 13px;
  font-weight: 500;
  border-radius: var(--radius-btn);
  border: 1px solid var(--border-subtle);
  background: #ffffff;
  color: var(--text-primary);
  cursor: pointer;
  box-shadow: var(--shadow-btn);
  transition: all 0.15s ease;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.apple-btn:hover {
  background: var(--system-gray);
}
.apple-btn.primary {
  background: var(--accent-black);
  color: #ffffff;
  border-color: var(--accent-black);
}
.apple-btn.primary:hover {
  background: #2a2a2e;
}
.apple-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.bottom-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

/* Toast */
.toast-notice {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  background: rgba(0, 0, 0, 0.85);
  color: #ffffff;
  backdrop-filter: blur(12px);
  padding: 8px 18px;
  border-radius: var(--radius-pill);
  font-size: 12px;
  opacity: 0;
  transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  pointer-events: none;
  z-index: 999;
}
.toast-notice.show {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
}

@media (max-width: 860px) {
  .window-content {
    grid-template-columns: 1fr;
  }
  .sidebar {
    border-right: none;
    border-bottom: 1px solid var(--border-subtle);
  }
}
