:root {
  color-scheme: dark;
  --page: #101316;
  --panel: #181d22;
  --panel-2: #20262d;
  --text: #edf2f6;
  --muted: #9aa8b3;
  --line: #303944;
  --accent: #64d0b7;
  --accent-2: #e6c06a;
  --danger: #f0787d;
  --focus: #8ad8ff;
  --shadow: 0 24px 80px rgba(0, 0, 0, 0.34);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--page);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input,
select {
  font: inherit;
}

button {
  border: 1px solid var(--line);
  background: var(--panel-2);
  color: var(--text);
  min-height: 38px;
  border-radius: 7px;
  cursor: pointer;
}

button:hover {
  border-color: color-mix(in srgb, var(--accent), white 18%);
}

button:focus-visible,
input:focus-visible,
select:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

.app-shell {
  display: grid;
  grid-template-columns: minmax(300px, 360px) minmax(0, 1fr);
  min-height: 100vh;
}

.panel {
  background: var(--panel);
  border-right: 1px solid var(--line);
}

.controls {
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 22px;
  overflow: auto;
}

.brand-row,
.palette-header,
.topbar,
.actions,
.inline-row,
.toggle-row {
  display: flex;
  align-items: center;
}

.brand-row {
  justify-content: space-between;
  gap: 16px;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 1.28rem;
  line-height: 1.2;
  letter-spacing: 0;
}

h2 {
  font-size: 0.95rem;
  letter-spacing: 0;
}

p {
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.5;
  margin-top: 8px;
}

.icon-button {
  width: 42px;
  min-width: 42px;
  padding: 0;
  font-size: 1.35rem;
}

.control-group,
.sliders,
.palette,
.score-card,
.saved-themes {
  display: grid;
  gap: 12px;
}

label,
.group-label {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 650;
}

input[type="text"],
select {
  width: 100%;
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #11161a;
  color: var(--text);
  padding: 0 12px;
}

input[type="color"] {
  width: 46px;
  height: 40px;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 2px;
  background: #11161a;
}

.inline-row {
  gap: 10px;
}

.seed-actions {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  gap: 10px;
}

.seed-actions button {
  padding: 0 12px;
}

.subtle-primary {
  border-color: transparent;
  background: var(--accent);
  color: #07100e;
  font-weight: 750;
}

.preset-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.segmented {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
}

.segment {
  border: 0;
  border-right: 1px solid var(--line);
  border-radius: 0;
  background: #11161a;
}

.segment:last-child {
  border-right: 0;
}

.segment.active {
  background: var(--accent);
  color: #07100e;
}

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

.control-grid label:last-child {
  grid-column: 1 / -1;
}

.sliders label span {
  display: flex;
  justify-content: space-between;
  gap: 10px;
}

input[type="range"] {
  width: 100%;
  accent-color: var(--accent);
}

.toggle-row {
  justify-content: space-between;
  gap: 12px;
  color: var(--muted);
  font-size: 0.85rem;
  font-weight: 650;
}

input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: var(--accent);
}

.palette-header {
  justify-content: space-between;
}

.palette-header button {
  min-height: 32px;
  padding: 0 10px;
  font-size: 0.8rem;
}

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

.swatch {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr);
  gap: 9px;
  align-items: center;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #11161a;
}

.swatch-chip {
  width: 34px;
  height: 34px;
  border-radius: 7px;
  border: 1px solid rgba(255, 255, 255, 0.18);
}

.swatch-name,
.swatch-value {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.swatch-name {
  color: var(--text);
  font-size: 0.77rem;
  font-weight: 700;
}

.swatch-value {
  color: var(--muted);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.72rem;
}

.score-card {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #11161a;
}

.score-card > div:first-child {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
}

.score-label {
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 700;
}

#score {
  font-size: 1.5rem;
}

.diagnostics {
  display: grid;
  gap: 7px;
}

.diagnostic {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 28px;
  padding: 0 8px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--panel);
  color: var(--muted);
  font-size: 0.76rem;
}

.diagnostic strong {
  color: var(--text);
  font-weight: 750;
}

.diagnostic.warn {
  border-color: color-mix(in srgb, var(--accent-2), var(--line) 45%);
}

.saved-list {
  display: grid;
  gap: 8px;
}

.saved-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 34px;
  gap: 8px;
}

.saved-load {
  min-width: 0;
  min-height: 48px;
  display: grid;
  grid-template-columns: 28px minmax(0, 1fr);
  align-items: center;
  gap: 10px;
  padding: 6px 9px;
  text-align: left;
}

.saved-chip {
  width: 28px;
  height: 28px;
  border-radius: 7px;
  border: 1px solid rgba(255, 255, 255, 0.2);
}

.saved-load strong,
.saved-load small {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.saved-load strong {
  font-size: 0.8rem;
}

.saved-load small,
.empty-saved {
  color: var(--muted);
  font-size: 0.72rem;
}

.saved-delete {
  width: 34px;
  min-width: 34px;
  padding: 0;
}

.empty-saved {
  margin: 0;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #11161a;
}

.workspace {
  min-width: 0;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
}

.topbar {
  justify-content: space-between;
  gap: 18px;
  min-height: 72px;
  padding: 14px 24px;
  border-bottom: 1px solid var(--line);
  background: #12171b;
}

.window-dots {
  display: flex;
  gap: 8px;
}

.window-dots span {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--danger);
}

.window-dots span:nth-child(2) {
  background: var(--accent-2);
}

.window-dots span:nth-child(3) {
  background: var(--accent);
}

.theme-name {
  display: grid;
  gap: 5px;
  min-width: 220px;
  width: min(420px, 50vw);
}

.theme-name label {
  display: block;
  font-size: 0.72rem;
}

.actions {
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.actions button {
  padding: 0 14px;
  min-width: 86px;
}

.actions .primary {
  border-color: transparent;
  background: var(--accent);
  color: #07100e;
  font-weight: 750;
}

.preview-grid {
  min-height: 0;
  padding: 24px;
  display: grid;
  grid-template-columns: minmax(0, 1.55fr) minmax(310px, 0.75fr);
  gap: 20px;
}

.editor-shell {
  min-width: 0;
  min-height: 540px;
  display: grid;
  grid-template-columns: 50px 176px minmax(0, 1fr);
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  box-shadow: var(--shadow);
}

.activity-bar,
.sidebar,
.editor,
.tabs,
.statusbar {
  transition: background-color 160ms ease, color 160ms ease, border-color 160ms ease;
}

.activity-bar {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 12px 7px;
}

.activity-bar button {
  width: 36px;
  height: 36px;
  min-height: 36px;
  padding: 0;
  border-radius: 7px;
  background: transparent;
}

.sidebar {
  padding: 14px 10px;
  border-right: 1px solid;
}

.sidebar-title {
  font-size: 0.72rem;
  font-weight: 750;
  margin: 4px 8px 14px;
}

.file {
  min-height: 30px;
  display: flex;
  align-items: center;
  border-radius: 6px;
  padding: 0 8px;
  font-size: 0.84rem;
}

.file.muted {
  opacity: 0.65;
}

.editor {
  min-width: 0;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
}

.tabs {
  display: flex;
  min-width: 0;
  border-bottom: 1px solid;
}

.tab {
  min-width: 112px;
  max-width: 170px;
  min-height: 42px;
  display: flex;
  align-items: center;
  padding: 0 14px;
  border-right: 1px solid;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 0.84rem;
}

.code {
  margin: 0;
  min-width: 0;
  overflow: auto;
  padding: 18px 20px 18px 0;
  font: 14px/1.75 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

.line {
  display: grid;
  grid-template-columns: 46px minmax(0, 1fr);
  min-width: max-content;
}

.ln {
  user-select: none;
  text-align: right;
  padding-right: 16px;
}

.statusbar {
  min-height: 30px;
  display: flex;
  justify-content: flex-end;
  gap: 18px;
  align-items: center;
  padding: 0 12px;
  font-size: 0.76rem;
}

.token-panel {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  overflow: hidden;
  box-shadow: var(--shadow);
}

.tabs.compact {
  border-color: var(--line);
}

.tab-button {
  flex: 1;
  border: 0;
  border-right: 1px solid var(--line);
  border-radius: 0;
  background: #11161a;
}

.tab-button:last-child {
  border-right: 0;
}

.tab-button.active {
  background: var(--panel-2);
  color: var(--accent);
}

.tab-content {
  display: none;
  max-height: calc(100vh - 146px);
  overflow: auto;
  padding: 16px;
}

.tab-content.active {
  display: block;
}

.token-row {
  display: grid;
  grid-template-columns: 24px minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  min-height: 34px;
  border-bottom: 1px solid var(--line);
}

.token-row:last-child {
  border-bottom: 0;
}

.mini-chip {
  width: 18px;
  height: 18px;
  border-radius: 5px;
  border: 1px solid rgba(255, 255, 255, 0.18);
}

.token-key {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 0.8rem;
}

.token-value,
.json-output {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

.token-value {
  color: var(--muted);
  font-size: 0.76rem;
}

.json-output {
  margin: 0;
  white-space: pre;
  font-size: 0.76rem;
  line-height: 1.55;
  background: #0f1317;
}

.install-panel {
  display: grid;
  gap: 16px;
}

.install-panel h2 {
  font-size: 1rem;
}

.install-panel p {
  margin-top: 0;
}

.install-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.install-actions button,
.install-step button {
  padding: 0 12px;
}

.install-actions .primary {
  border-color: transparent;
  background: var(--accent);
  color: #07100e;
  font-weight: 750;
}

.install-step {
  display: grid;
  gap: 10px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #11161a;
}

.install-step strong {
  font-size: 0.85rem;
}

.install-step code {
  display: block;
  overflow-x: auto;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 7px;
  color: var(--text);
  background: var(--panel);
  font: 0.75rem/1.5 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

@media (max-width: 1100px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .panel {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .controls {
    max-height: none;
  }

  .preview-grid {
    grid-template-columns: 1fr;
  }

  .tab-content {
    max-height: 460px;
  }
}

@media (max-width: 720px) {
  .controls,
  .preview-grid,
  .topbar {
    padding: 16px;
  }

  .topbar {
    align-items: stretch;
    flex-wrap: wrap;
  }

  .window-dots {
    width: 100%;
  }

  .theme-name {
    width: 100%;
  }

  .actions {
    width: 100%;
  }

  .actions button {
    flex: 1;
  }

  .seed-actions {
    grid-template-columns: 1fr;
  }

  .preset-grid {
    grid-template-columns: 1fr;
  }

  .install-actions {
    grid-template-columns: 1fr;
  }

  .control-grid,
  .swatches {
    grid-template-columns: 1fr;
  }

  .editor-shell {
    grid-template-columns: 46px minmax(0, 1fr);
    min-height: 520px;
  }

  .sidebar {
    display: none;
  }

  .code {
    font-size: 12px;
  }
}
