/* ============================================
   ChromaDaily — Style Sheet
   Mobile-first, dark mode default
   ============================================ */

:root {
  /* Surface colors (OKLCH-derived neutrals) */
  --bg: #12121a;
  --surface: #1a1a2e;
  --surface-2: #222238;
  --surface-3: #2a2a42;
  --border: #3a3a52;
  --border-light: #4a4a66;

  /* Text */
  --text: #e8e8f0;
  --text-dim: #9898b0;
  --text-muted: #6a6a82;

  /* Accents */
  --accent: #7c6ef0;
  --accent-dim: #5a50b0;
  --success: #4ecf8a;
  --warning: #f5a623;
  --error: #e84057;

  /* Sizing */
  --swatch-size: min(120px, 28vw);
  --radius: 10px;
  --radius-sm: 6px;
}

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

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100dvh;
  overflow-x: hidden;
  -webkit-tap-highlight-color: transparent;
}

#app {
  max-width: 480px;
  margin: 0 auto;
  padding: 0 16px 32px;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

/* ============ HEADER ============ */

#header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 0 10px;
  border-bottom: 1px solid var(--border);
}

.logo {
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.logo-accent {
  color: var(--accent);
}

.header-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.streak {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--warning);
}

.day-badge {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text-dim);
  background: var(--surface-2);
  padding: 3px 8px;
  border-radius: var(--radius-sm);
}

/* ============ MODE NAV ============ */

.mode-nav {
  display: flex;
  gap: 4px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}

.mode-tab {
  flex: 1;
  padding: 8px 0;
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-family: inherit;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  border-radius: var(--radius-sm);
  transition: all 0.2s;
}

.mode-tab.active {
  background: var(--surface-2);
  color: var(--text);
}

.mode-tab:hover:not(.active) {
  color: var(--text-dim);
}

/* ============ ROUND TABS ============ */

.round-tabs {
  display: flex;
  gap: 4px;
  padding: 12px 0 8px;
}

.round-tab {
  flex: 1;
  padding: 8px 0;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-muted);
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.8rem;
  font-weight: 500;
  cursor: pointer;
  border-radius: var(--radius-sm);
  transition: all 0.2s;
  position: relative;
}

.round-tab.active {
  background: var(--surface-2);
  color: var(--text);
  border-color: var(--accent);
}

.round-tab.completed {
  background: var(--surface-3);
  color: var(--success);
  border-color: var(--success);
  opacity: 0.85;
}

.round-tab.completed::after {
  content: '\2713';
  position: absolute;
  top: -6px;
  right: -2px;
  font-size: 0.65rem;
  background: var(--success);
  color: var(--bg);
  width: 14px;
  height: 14px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
}

.round-tab.locked {
  opacity: 0.4;
  cursor: default;
}

/* ============ BLIND INDICATOR ============ */

.blind-indicator {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 0;
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--warning);
  transition: all 0.3s;
}

.blind-indicator.revealed {
  color: var(--text-muted);
}

.blind-indicator.revealed svg {
  opacity: 0.5;
}

/* ============ COLOR SWATCHES ============ */

.color-area {
  padding: 16px 0;
  display: flex;
  justify-content: center;
}

.swatch-pair {
  display: flex;
  gap: 16px;
  align-items: center;
}

.swatch {
  text-align: center;
}

.swatch-color {
  width: var(--swatch-size);
  height: var(--swatch-size);
  border-radius: var(--radius);
  border: 2px solid var(--border-light);
  transition: background-color 0.1s;
}

.target-swatch .swatch-color {
  border-color: var(--text-dim);
}

.swatch-label {
  font-size: 0.7rem;
  font-weight: 500;
  color: var(--text-muted);
  margin-top: 6px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

/* ============ SLIDERS ============ */

.slider-group {
  padding: 8px 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

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

.slider-label {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.85rem;
  font-weight: 600;
  width: 24px;
  text-align: center;
  color: var(--text-dim);
  flex-shrink: 0;
}

.slider-track-wrap {
  flex: 1;
  position: relative;
}

.slider {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 32px;
  background: transparent;
  cursor: pointer;
  outline: none;
}

.slider::-webkit-slider-runnable-track {
  height: 8px;
  border-radius: 4px;
  background: var(--surface-3);
}

.slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--text);
  border: 2px solid var(--bg);
  margin-top: -8px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.4);
}

.slider::-moz-range-track {
  height: 8px;
  border-radius: 4px;
  background: var(--surface-3);
  border: none;
}

.slider::-moz-range-thumb {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--text);
  border: 2px solid var(--bg);
  box-shadow: 0 1px 4px rgba(0,0,0,0.4);
}

.slider-value {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.8rem;
  font-weight: 500;
  width: 48px;
  text-align: right;
  color: var(--text-dim);
  flex-shrink: 0;
}

/* ============ CONTROLS ============ */

.controls {
  display: flex;
  gap: 10px;
  padding: 12px 0;
}

.btn {
  padding: 12px 20px;
  border: none;
  border-radius: var(--radius);
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.btn-submit {
  flex: 1;
  background: var(--accent);
  color: white;
}

.btn-submit:hover {
  filter: brightness(1.1);
}

.btn-submit:active {
  transform: scale(0.98);
}

.btn-reveal {
  background: var(--surface-2);
  color: var(--text-dim);
  border: 1px solid var(--border);
}

.btn-reveal:hover {
  border-color: var(--border-light);
  color: var(--text);
}

.btn-reveal.active {
  background: var(--surface-3);
  color: var(--warning);
  border-color: var(--warning);
}

/* ============ FACTOID SCREEN ============ */

.factoid-card {
  margin-top: 20vh;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px 24px;
  text-align: center;
}

.factoid-header {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--accent);
  margin-bottom: 16px;
}

.factoid-text {
  font-size: 1rem;
  line-height: 1.6;
  color: var(--text);
  margin-bottom: 24px;
}

/* ============ REVEAL SCREEN ============ */

.reveal-title {
  font-size: 1.1rem;
  font-weight: 700;
  padding: 16px 0 12px;
  text-align: center;
}

.score-summary {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 16px;
}

.score-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 6px 0;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.85rem;
}

.score-row .score-model {
  color: var(--text-dim);
  font-weight: 500;
}

.score-row .score-value {
  font-weight: 600;
  color: var(--text);
}

.score-row.total {
  border-top: 1px solid var(--border);
  margin-top: 6px;
  padding-top: 10px;
  font-size: 0.95rem;
}

.score-row.total .score-value {
  color: var(--accent);
}

.blind-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: var(--warning);
  color: var(--bg);
  font-size: 0.7rem;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 10px;
  margin-left: 8px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* Decomposition */

.decomposition {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 16px;
}

.decomp-title {
  font-size: 0.85rem;
  font-weight: 600;
  margin-bottom: 12px;
  color: var(--text);
}

.decomp-hint {
  font-weight: 400;
  color: var(--text-muted);
  font-size: 0.75rem;
}

.decomp-round {
  margin-bottom: 14px;
}

.decomp-round:last-child {
  margin-bottom: 0;
}

.decomp-round-label {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.decomp-swatches {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}

.decomp-mini-swatch {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-light);
  transition: background-color 0.3s;
}

.decomp-arrow {
  color: var(--text-muted);
  font-size: 0.8rem;
}

.decomp-lch-row {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.decomp-lch-btn {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.72rem;
  padding: 4px 10px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text-dim);
  cursor: pointer;
  transition: all 0.15s;
}

.decomp-lch-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.decomp-lch-btn:active {
  background: var(--accent);
  color: white;
}

/* Target values */

.target-values {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 16px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.tv-item {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.72rem;
  padding: 4px 10px;
  background: var(--surface-2);
  border-radius: var(--radius-sm);
  color: var(--text-dim);
}

.tv-label {
  color: var(--text-muted);
  margin-right: 4px;
}

/* Share */

.share-area {
  display: flex;
  align-items: center;
  gap: 12px;
}

.share-confirm {
  font-size: 0.85rem;
  color: var(--success);
  font-weight: 500;
}

/* ============ COMPLEMENT SCREEN ============ */

.complement-header {
  text-align: center;
  padding: 16px 0 8px;
}

.complement-header h2 {
  font-size: 1rem;
  font-weight: 700;
  margin-bottom: 6px;
}

.complement-desc {
  font-size: 0.85rem;
  color: var(--text-dim);
  line-height: 1.5;
}

.complement-model-select {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 8px 0 4px;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.model-buttons {
  display: flex;
  gap: 4px;
}

.model-btn {
  padding: 6px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-muted);
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.8rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
}

.model-btn.active {
  background: var(--surface-2);
  color: var(--text);
  border-color: var(--accent);
}

/* ============ SANDBOX ============ */

.sandbox-preview {
  display: flex;
  justify-content: center;
  padding: 16px 0 8px;
}

.sandbox-swatch .swatch-color {
  width: min(160px, 40vw);
  height: min(160px, 40vw);
}

.sandbox-models {
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 8px 0;
}

.sandbox-model-group {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 14px;
}

.sandbox-model-label {
  font-size: 0.85rem;
  font-weight: 600;
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.sandbox-model-type {
  font-size: 0.65rem;
  font-weight: 500;
  color: var(--text-muted);
  background: var(--surface-2);
  padding: 2px 6px;
  border-radius: 4px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.sandbox-hex {
  text-align: center;
  font-family: 'JetBrains Mono', monospace;
  font-size: 1rem;
  font-weight: 500;
  color: var(--text-dim);
  padding: 8px 0;
}

/* ============ TUTORIAL ============ */

#tutorial-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.85);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 20px;
}

.tutorial-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 32px 24px;
  max-width: 380px;
  text-align: center;
}

.tutorial-card h2 {
  font-size: 1.2rem;
  margin-bottom: 16px;
}

.tutorial-card p {
  font-size: 0.9rem;
  line-height: 1.6;
  color: var(--text-dim);
  margin-bottom: 14px;
}

.tutorial-card em {
  color: var(--success);
  font-style: normal;
  font-weight: 600;
}

.tutorial-card strong {
  color: var(--text);
}

.tutorial-card .btn {
  margin-top: 8px;
  width: 100%;
}

/* ============ UTILITY ============ */

.screen {
  flex: 1;
}

/* ============ RESPONSIVE ============ */

@media (min-width: 481px) {
  #app {
    padding: 0 24px 40px;
  }

  :root {
    --swatch-size: 140px;
  }

  .sandbox-models {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
  }
}
