/* ═══════════════════════════════════════════════════════════════════════
   fairGround Theme & Icon Studio — Unified Instrument Shell Styles
   Uses fairGround paper-instrument tokens (pine + amber on warm paper,
   crisp 1px/1.5px borders over shadows, tabular numerals).
   ═══════════════════════════════════════════════════════════════════════ */

:root,
[data-studio-theme="light"] {
  color-scheme: light;
  --st-bg: oklch(0.975 0.004 140);
  --st-surface: #ffffff;
  --st-surface-2: oklch(0.955 0.005 140);
  --st-surface-3: oklch(0.93 0.006 145);
  --st-text: oklch(0.26 0.02 160);
  --st-muted: oklch(0.49 0.02 155);
  --st-faint: oklch(0.64 0.015 152);
  --st-border: oklch(0.87 0.01 150);
  --st-border-strong: oklch(0.77 0.014 152);
  --st-pine: #235340;
  --st-sage: #6E9E89;
  --st-amber: #B8791E;
  --st-gold: #E2A94E;
  --st-accent: #235340;
  --st-on-accent: #ffffff;
  --st-danger: #b3403f;
  --st-danger-soft: #fbeaea;
  --st-warn: #8a570c;
  --st-warn-soft: #fdf4e3;
  --st-ok: #1f6445;
  --st-ok-soft: #e6f4ed;
  --st-font-ui: "Segoe UI", system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
  --st-font-mono: ui-monospace, "Cascadia Mono", Consolas, Menlo, monospace;
}

[data-studio-theme="dark"] {
  color-scheme: dark;
  --st-bg: oklch(0.18 0.01 160);
  --st-surface: oklch(0.23 0.012 160);
  --st-surface-2: oklch(0.275 0.013 158);
  --st-surface-3: oklch(0.32 0.014 157);
  --st-text: oklch(0.93 0.005 150);
  --st-muted: oklch(0.71 0.015 155);
  --st-faint: oklch(0.55 0.015 155);
  --st-border: oklch(0.34 0.012 155);
  --st-border-strong: oklch(0.45 0.014 155);
  --st-pine: #4E8E75;
  --st-sage: #8FC2AC;
  --st-amber: #D99634;
  --st-gold: #F2C06E;
  --st-accent: #5FA388;
  --st-on-accent: #0f1f19;
  --st-danger: #f08886;
  --st-danger-soft: rgba(179, 64, 63, 0.2);
  --st-warn: #f2c06e;
  --st-warn-soft: rgba(217, 150, 52, 0.18);
  --st-ok: #8FC2AC;
  --st-ok-soft: rgba(78, 142, 117, 0.2);
}

*, *::before, *::after {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html, body {
  margin: 0;
  height: 100%;
  background: var(--st-bg);
  color: var(--st-text);
  font-family: var(--st-font-ui);
  font-size: 14px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}

.studio-shell {
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
}

/* ── Top Navigation Bar ─────────────────────────────────────────────── */
.studio-topbar {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 16px;
  background: var(--st-surface);
  border-bottom: 1.5px solid var(--st-border);
  flex-wrap: wrap;
  z-index: 50;
}

.studio-brand {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  text-decoration: none;
  color: var(--st-text);
  margin-right: 4px;
}

.studio-brand-title {
  font-size: 15px;
  font-weight: 700;
  letter-spacing: -0.02em;
  display: inline-flex;
  align-items: baseline;
  gap: 6px;
}

.studio-brand-title .w1 {
  color: var(--st-sage);
  font-weight: 500;
}

.studio-brand-sub {
  font-family: var(--st-font-mono);
  font-size: 11px;
  font-weight: 500;
  color: var(--st-muted);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.studio-tabs {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 3px;
  background: var(--st-surface-2);
  border: 1px solid var(--st-border);
  border-radius: 8px;
}

.studio-tab {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--st-muted);
  font-family: var(--st-font-ui);
  font-size: 13px;
  font-weight: 600;
  padding: 6px 12px;
  border-radius: 6px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: background 120ms ease, color 120ms ease;
  white-space: nowrap;
}

.studio-tab:hover {
  color: var(--st-text);
  background: var(--st-surface);
}

.studio-tab[aria-selected="true"] {
  background: var(--st-accent);
  color: var(--st-on-accent);
}

.studio-topbar-spacer {
  flex: 1 1 auto;
}

.studio-override-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--st-warn-soft);
  border: 1px solid var(--st-amber);
  font-size: 12px;
  font-weight: 600;
  color: var(--st-text);
}

.studio-override-pill[hidden] {
  display: none !important;
}

/* ── Buttons & Controls ─────────────────────────────────────────────── */
.st-btn {
  appearance: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: 6px;
  border: 1px solid var(--st-border-strong);
  background: var(--st-surface);
  color: var(--st-text);
  font-family: var(--st-font-ui);
  font-size: 13px;
  font-weight: 600;
  line-height: 1.25;
  cursor: pointer;
  text-decoration: none;
  transition: background 120ms ease, border-color 120ms ease;
}

.st-btn:hover:not(:disabled) {
  background: var(--st-surface-2);
}

.st-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.st-btn-primary {
  background: var(--st-accent);
  border-color: var(--st-accent);
  color: var(--st-on-accent);
}

.st-btn-primary:hover:not(:disabled) {
  filter: brightness(1.07);
  background: var(--st-accent);
}

.st-btn-amber {
  background: var(--st-amber);
  border-color: var(--st-amber);
  color: #ffffff;
}

.st-btn-amber:hover:not(:disabled) {
  filter: brightness(1.07);
  background: var(--st-amber);
}

.st-btn-sm {
  padding: 4px 9px;
  font-size: 12px;
}

.st-btn-ghost {
  border-color: transparent;
  background: transparent;
  color: var(--st-muted);
}

.st-btn-ghost:hover:not(:disabled) {
  background: var(--st-surface-2);
  color: var(--st-text);
}

:focus-visible {
  outline: 2px solid var(--st-amber);
  outline-offset: 2px;
}

/* ── Workspace Panels ───────────────────────────────────────────────── */
.studio-main {
  flex: 1 1 auto;
  min-height: 0;
  position: relative;
  display: flex;
  flex-direction: column;
}

.studio-panel {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.studio-panel[hidden] {
  display: none !important;
}

.studio-iframe {
  flex: 1 1 auto;
  width: 100%;
  height: 100%;
  border: 0;
  background: var(--st-bg);
}

.studio-subbar {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 6px 16px;
  background: var(--st-surface-2);
  border-bottom: 1px solid var(--st-border);
  font-size: 12px;
  color: var(--st-muted);
  flex-wrap: wrap;
}

/* ── Palette Generator Workspace ────────────────────────────────────── */
.palette-scroll {
  flex: 1 1 auto;
  overflow-y: auto;
  padding: 24px;
}

.palette-container {
  max-width: 1240px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.palette-hero {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.palette-hero h1 {
  margin: 0 0 4px;
  font-size: 22px;
  letter-spacing: -0.02em;
}

.palette-hero p {
  margin: 0;
  color: var(--st-muted);
  max-width: 700px;
}

.palette-grid {
  display: grid;
  grid-template-columns: minmax(320px, 430px) minmax(0, 1fr);
  gap: 20px;
  align-items: start;
}

@media (max-width: 960px) {
  .palette-grid {
    grid-template-columns: minmax(0, 1fr);
  }
}

.st-card {
  background: var(--st-surface);
  border: 1.5px solid var(--st-border);
  border-radius: 10px;
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.st-card h2 {
  margin: 0;
  font-size: 15px;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.st-sub {
  margin: 0;
  font-size: 12.5px;
  color: var(--st-muted);
}

/* Segmented Control */
.st-seg {
  display: inline-flex;
  background: var(--st-surface-2);
  border: 1px solid var(--st-border);
  border-radius: 8px;
  padding: 3px;
  gap: 3px;
  align-self: flex-start;
}

.st-seg button {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--st-muted);
  padding: 6px 12px;
  border-radius: 6px;
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
}

.st-seg button[aria-pressed="true"] {
  background: var(--st-surface);
  color: var(--st-text);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08);
}

/* Upload Dropzone */
.logo-dropzone {
  border: 1.5px dashed var(--st-border-strong);
  border-radius: 10px;
  background: var(--st-surface-2);
  padding: 18px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  transition: border-color 120ms ease, background 120ms ease;
}

.logo-dropzone:hover,
.logo-dropzone.dragover {
  border-color: var(--st-accent);
  background: var(--st-surface-3);
}

.logo-preview-frame {
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--st-surface-2);
  border: 1px solid var(--st-border);
  border-radius: 8px;
  padding: 12px;
  min-height: 96px;
}

.logo-preview-frame img {
  max-height: 96px;
  max-width: 260px;
  object-fit: contain;
}

.preset-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.preset-chip {
  appearance: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 9px;
  border-radius: 999px;
  border: 1px solid var(--st-border);
  background: var(--st-surface-2);
  color: var(--st-text);
  font-size: 11.5px;
  font-weight: 600;
  cursor: pointer;
}

.preset-chip:hover {
  border-color: var(--st-border-strong);
  background: var(--st-surface-3);
}

.cand-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.cand-btn {
  appearance: none;
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 5px 9px 5px 6px;
  border-radius: 8px;
  border: 1.5px solid var(--st-border);
  background: var(--st-surface);
  color: var(--st-text);
  font-family: var(--st-font-mono);
  font-size: 11.5px;
  cursor: pointer;
}

.cand-btn[aria-pressed="true"] {
  border-color: var(--st-text);
  background: var(--st-surface-2);
  font-weight: 700;
}

.cand-rank {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  border-radius: 999px;
  background: var(--st-text);
  color: var(--st-surface);
  font-size: 10px;
  font-weight: 700;
}

.st-swatch {
  display: inline-block;
  width: 22px;
  height: 22px;
  border-radius: 5px;
  border: 1px solid rgba(128, 128, 128, 0.35);
  flex-shrink: 0;
}

/* Accessible SpectrumColorPicker */
.spectrum-picker {
  display: grid;
  gap: 8px;
  width: 100%;
  max-width: 260px;
  padding: 10px;
  background: var(--st-surface-2);
  border: 1px solid var(--st-border);
  border-radius: 8px;
}

.spectrum-area {
  position: relative;
  height: 132px;
  border-radius: 6px;
  border: 1px solid var(--st-border-strong);
  touch-action: none;
  cursor: crosshair;
  user-select: none;
}

.spectrum-thumb {
  position: absolute;
  width: 14px;
  height: 14px;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  border: 2px solid #ffffff;
  box-shadow: 0 0 0 1.5px #111111;
  pointer-events: none;
}

.spectrum-hue {
  width: 100%;
  height: 10px;
  border-radius: 5px;
  appearance: none;
  background: linear-gradient(to right, #f00, #ff0, #0f0, #0ff, #00f, #f0f, #f00);
  cursor: pointer;
}

.spectrum-hex-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.spectrum-hex-input {
  font-family: var(--st-font-mono);
  font-size: 12.5px;
  width: 9.5ch;
  padding: 4px 8px;
  border: 1px solid var(--st-border-strong);
  border-radius: 5px;
  background: var(--st-surface);
  color: var(--st-text);
  font-variant-numeric: tabular-nums;
}

/* Dual Specimen Cards */
.specimen-pair {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 14px;
}

.specimen-card {
  border-radius: 10px;
  padding: 16px;
  border: 1.5px solid;
  display: flex;
  flex-direction: column;
  gap: 12px;
  font-variant-numeric: tabular-nums;
}

.specimen-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.contrast-pill {
  font-family: var(--st-font-mono);
  font-size: 11px;
  padding: 2px 7px;
  border-radius: 999px;
  border: 1px solid currentColor;
  opacity: 0.85;
}

.cat-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.cat-pill {
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 999px;
  border: 1px solid;
}

.series-bars {
  display: flex;
  align-items: flex-end;
  gap: 4px;
  height: 52px;
  padding-top: 4px;
}

.series-bars span {
  flex: 1;
  border-radius: 3px 3px 0 0;
}

/* Check issues banner */
.issue-list {
  margin: 0;
  padding: 10px 14px 10px 30px;
  border-radius: 8px;
  font-size: 12.5px;
  display: grid;
  gap: 4px;
}

.issue-list.has-err {
  background: var(--st-danger-soft);
  border: 1px solid var(--st-danger);
}

.issue-list.warn-only {
  background: var(--st-warn-soft);
  border: 1px solid var(--st-amber);
}

.issue-ok {
  padding: 8px 12px;
  border-radius: 8px;
  background: var(--st-ok-soft);
  border: 1px solid var(--st-ok);
  color: var(--st-text);
  font-size: 12.5px;
  font-weight: 600;
}

/* All 27 tokens grid */
.token-groups {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.token-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(235px, 1fr));
  gap: 8px;
  margin-top: 8px;
}

.token-cell {
  border: 1px solid var(--st-border);
  border-radius: 8px;
  padding: 8px 10px;
  background: var(--st-surface-2);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.token-cell-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.token-name {
  font-family: var(--st-font-mono);
  font-size: 11.5px;
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.token-badge {
  font-family: var(--st-font-mono);
  font-size: 10.5px;
  padding: 1px 6px;
  border-radius: 999px;
  border: 1px solid var(--st-border-strong);
  color: var(--st-muted);
}

.token-badge.locked {
  border-color: var(--st-amber);
  background: var(--st-warn-soft);
  color: var(--st-text);
  font-weight: 700;
}

.code-preview {
  margin: 0;
  padding: 12px;
  border-radius: 8px;
  background: var(--st-surface-2);
  border: 1px solid var(--st-border);
  font-family: var(--st-font-mono);
  font-size: 11.5px;
  line-height: 1.5;
  max-height: 200px;
  overflow: auto;
}

/* ── Package Assets Browser ─────────────────────────────────────────── */
.assets-scroll {
  flex: 1 1 auto;
  overflow-y: auto;
  padding: 24px;
}

.assets-container {
  max-width: 1240px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.asset-brand-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
  gap: 16px;
}

.asset-stage {
  border-radius: 8px;
  padding: 16px;
  border: 1px solid var(--st-border);
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 92px;
}

.asset-stage.light {
  background: #F6F7F5;
  color: #1E2B25;
}

.asset-stage.dark {
  background: #101614;
  color: #EAF0EC;
}

.asset-links {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}
