/* ============================================================================
   Apple + ChatGPT Design System
   Bright Theme: Light Gray (#F5F5F7) Canvas + Elevated White (#FFFFFF) Cards
   Dark Theme:   Pure Black (#000000) Canvas + Obsidian (#111113) Cards
   Zero Neon Colors • High-Contrast Editorial Readability
   ============================================================================ */

:root {
  /* Bright Theme (Apple Light Gray #F5F5F7 + White Elevated Surfaces) */
  --canvas-bg: #f5f5f7;
  --surface-card: #ffffff;
  --surface-subtle: #efeff4;
  --surface-pill: #e8e8ed;
  --surface-pill-active: #ffffff;
  --nav-bg: rgba(245, 245, 247, 0.82);

  --text-primary: #1d1d1f;
  --text-secondary: #424245;
  --text-muted: #6e6e73;

  --border-hairline: rgba(0, 0, 0, 0.08);
  --border-strong: rgba(0, 0, 0, 0.16);

  --accent-fill: #1d1d1f;
  --accent-text: #ffffff;
  --bar-primary: #1d1d1f;
  --bar-secondary: #c7c7cc;
  --bar-track: #e5e5ea;

  --card-shadow: 0 2px 14px rgba(0, 0, 0, 0.035), 0 1px 2px rgba(0, 0, 0, 0.02);
  --pill-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);

  --code-bg: #141416;
  --code-header: #1c1c1e;
  --code-text: #f5f5f7;
  --code-border: rgba(255, 255, 255, 0.1);
}

html.dark {
  /* Dark Theme (Pure Black #000000 Canvas + Apple Pro Dark #111113 Cards) */
  --canvas-bg: #000000;
  --surface-card: #111113;
  --surface-subtle: #18181b;
  --surface-pill: #1c1c1e;
  --surface-pill-active: #2c2c2e;
  --nav-bg: rgba(0, 0, 0, 0.82);

  --text-primary: #f5f5f7;
  --text-secondary: #d1d1d6;
  --text-muted: #86868b;

  --border-hairline: rgba(255, 255, 255, 0.1);
  --border-strong: rgba(255, 255, 255, 0.22);

  --accent-fill: #f5f5f7;
  --accent-text: #000000;
  --bar-primary: #f5f5f7;
  --bar-secondary: #48484a;
  --bar-track: #242426;

  --card-shadow: 0 4px 24px rgba(0, 0, 0, 0.5);
  --pill-shadow: 0 1px 4px rgba(0, 0, 0, 0.4);

  --code-bg: #08080a;
  --code-header: #141416;
  --code-text: #e5e5ea;
  --code-border: rgba(255, 255, 255, 0.1);
}

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

html {
  scroll-behavior: smooth;
}

body {
  background-color: var(--canvas-bg);
  color: var(--text-primary);
  font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Text', 'SF Pro Display', 'Inter', 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  transition: background-color 0.2s ease, color 0.2s ease;
}

/* Typography Helpers */
.font-display {
  font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'Inter', sans-serif;
  letter-spacing: -0.028em;
}

.font-mono-num {
  font-family: 'SF Mono', 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-variant-numeric: tabular-nums;
}

.text-primary-ink {
  color: var(--text-primary);
}

.text-secondary-ink {
  color: var(--text-secondary);
}

.text-muted-ink {
  color: var(--text-muted);
}

/* Frosted Glass Apple Header */
.apple-glass-nav {
  background-color: var(--nav-bg);
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  border-bottom: 1px solid var(--border-hairline);
}

/* Bento Card Surface */
.bento-card {
  background-color: var(--surface-card);
  border: 1px solid var(--border-hairline);
  border-radius: 20px;
  box-shadow: var(--card-shadow);
  transition: border-color 0.18s ease, transform 0.18s ease, background-color 0.2s ease;
}

.bento-card-interactive:hover {
  border-color: var(--border-strong);
}

.bento-subtle {
  background-color: var(--surface-subtle);
  border: 1px solid var(--border-hairline);
  border-radius: 16px;
}

/* Apple Segmented Control (UISegmentedControl style) */
.segmented-control {
  display: inline-flex;
  background-color: var(--surface-pill);
  padding: 4px;
  border-radius: 12px;
  border: 1px solid var(--border-hairline);
  gap: 4px;
}

.segmented-item {
  padding: 7px 15px;
  border-radius: 9px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  background: transparent;
  border: none;
  cursor: pointer;
  transition: all 0.16s ease;
  white-space: nowrap;
}

.segmented-item:hover {
  color: var(--text-primary);
}

.segmented-item.active {
  background-color: var(--surface-pill-active);
  color: var(--text-primary);
  font-weight: 600;
  box-shadow: var(--pill-shadow);
}

/* Primary Action Button (ChatGPT / Apple Pill Button) */
.btn-primary-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  background-color: var(--accent-fill);
  color: var(--accent-text);
  padding: 9px 18px;
  border-radius: 9999px;
  font-size: 13px;
  font-weight: 600;
  text-decoration: none;
  transition: opacity 0.15s ease;
}

.btn-primary-pill:hover {
  opacity: 0.86;
}

.btn-secondary-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  background-color: var(--surface-subtle);
  color: var(--text-primary);
  border: 1px solid var(--border-hairline);
  padding: 9px 18px;
  border-radius: 9999px;
  font-size: 13px;
  font-weight: 500;
  text-decoration: none;
  transition: border-color 0.15s ease;
}

.btn-secondary-pill:hover {
  border-color: var(--border-strong);
}

/* Apple Silicon Style Capsule Progress Bars */
.apple-bar-track {
  width: 100%;
  height: 12px;
  background-color: var(--bar-track);
  border-radius: 9999px;
  overflow: hidden;
}

.apple-bar-fill-primary {
  height: 100%;
  background-color: var(--bar-primary);
  border-radius: 9999px;
  transition: width 0.4s cubic-bezier(0.22, 1, 0.36, 1);
}

.apple-bar-fill-secondary {
  height: 100%;
  background-color: var(--bar-secondary);
  border-radius: 9999px;
  transition: width 0.4s cubic-bezier(0.22, 1, 0.36, 1);
}

/* ChatGPT / macOS Code Terminal Window */
.code-window {
  background-color: var(--code-bg);
  border: 1px solid var(--code-border);
  border-radius: 16px;
  overflow: hidden;
}

.code-window-header {
  background-color: var(--code-header);
  border-bottom: 1px solid var(--code-border);
  padding: 10px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.window-dots {
  display: flex;
  align-items: center;
  gap: 7px;
}

.window-dot {
  width: 10px;
  height: 10px;
  border-radius: 9999px;
  background-color: #3a3a3c;
}

.code-window-body {
  padding: 20px 22px;
  color: var(--code-text);
  font-family: 'SF Mono', 'JetBrains Mono', ui-monospace, monospace;
  font-size: 13px;
  line-height: 1.65;
  overflow-x: auto;
  white-space: pre;
}

/* Clean Range Slider */
input[type="range"].apple-slider {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 6px;
  background: var(--bar-track);
  border-radius: 9999px;
  outline: none;
}

input[type="range"].apple-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--accent-fill);
  border: 2px solid var(--surface-card);
  box-shadow: 0 1px 5px rgba(0, 0, 0, 0.3);
  cursor: pointer;
}

/* Table Styling */
.apple-table th {
  color: var(--text-muted);
  font-weight: 600;
  font-size: 12px;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  border-bottom: 1px solid var(--border-hairline);
  background-color: var(--surface-subtle);
}

.apple-table td {
  border-bottom: 1px solid var(--border-hairline);
  color: var(--text-primary);
  font-size: 14px;
}

.apple-table tr:last-child td {
  border-bottom: none;
}

.katex-display {
  margin: 0.9em 0;
  overflow-x: auto;
  overflow-y: hidden;
}
