:root {
  --bg-primary: #0a0a0f;
  --bg-secondary: #14141f;
  --bg-tertiary: #1e1e2e;
  --text-primary: #ffffff;
  --text-secondary: #a0a0b0;
  --text-muted: #606070;
  --accent: #00d4ff;
  --accent-secondary: #00ff88;
  --danger: #ff4466;
  --focus-ring: #00d4ff;
  --focus-glow: rgba(0, 212, 255, 0.4);
  --radius-md: 12px;
}
* { margin: 0; padding: 0; box-sizing: border-box; }
html, body {
  width: 600px; height: 600px; overflow: hidden;
  background: #000;
  color: var(--text-primary);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}
#app { width: 100%; height: 100%; position: relative; }
.screen { width: 100%; height: 100%; position: absolute; top: 0; left: 0; display: flex; flex-direction: column; }
.screen.hidden { display: none; }
.focusable { transition: all 0.15s ease; border: 2px solid transparent; cursor: pointer; outline: none; }
.focusable:focus { border-color: var(--focus-ring); box-shadow: 0 0 20px var(--focus-glow); }
.hidden { display: none !important; }

/* Top bar */
.topbar {
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 16px 20px 12px;
}
.title { font-size: 26px; font-weight: 700; letter-spacing: 0.3px; }
.hint { font-size: 13px; color: var(--text-muted); }

/* Home swatch */
.swatch {
  flex: 0 0 auto;
  margin: 4px 20px 0;
  height: 234px;
  border-radius: var(--radius-md);
  background: #000;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  transition: background-color 0.25s ease, box-shadow 0.15s ease, border-color 0.15s ease;
  text-shadow: 0 1px 6px rgba(0, 0, 0, 0.35);
}
.swatch-hex {
  font-size: 46px;
  font-weight: 700;
  font-family: ui-monospace, 'SF Mono', Menlo, monospace;
  letter-spacing: 2px;
}
.swatch-tap { font-size: 14px; opacity: 0.8; }

/* Readouts */
.readouts {
  flex: 0 0 auto;
  display: flex;
  gap: 12px;
  padding: 14px 20px 8px;
}
.readout {
  flex: 1;
  background: var(--bg-secondary);
  border-radius: var(--radius-md);
  padding: 10px 14px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.rk { font-size: 12px; color: var(--text-muted); letter-spacing: 1px; }
.rv {
  font-size: 18px;
  font-weight: 600;
  font-family: ui-monospace, 'SF Mono', Menlo, monospace;
  color: var(--text-secondary);
}

/* Action buttons */
.actions {
  flex: 1 1 auto;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  padding: 12px 20px 20px;
  align-content: end;
}
.actions-single { grid-template-columns: 1fr; }
.actions-pair { grid-template-columns: 1fr 1fr; }
.btn {
  min-height: 88px;
  background: var(--bg-tertiary);
  color: var(--text-primary);
  border-radius: var(--radius-md);
  font-size: 20px;
  font-weight: 600;
  font-family: inherit;
  display: flex;
  align-items: center;
  justify-content: center;
}
.btn:active { transform: scale(0.98); }
#clearBtn { color: var(--danger); }

/* Palette grid */
.palette-grid {
  flex: 1 1 auto;
  display: grid;
  grid-template-columns: 1fr 1fr;
  grid-auto-rows: 1fr;
  gap: 12px;
  padding: 8px 20px 8px;
  overflow: hidden;
}
.pal-item {
  border-radius: var(--radius-md);
  background: #000;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: flex-end;
  gap: 2px;
  padding: 12px 14px;
  min-height: 88px;
  text-shadow: 0 1px 5px rgba(0, 0, 0, 0.4);
}
.pal-label { font-size: 14px; font-weight: 600; opacity: 0.92; }
.pal-hex {
  font-size: 18px;
  font-weight: 700;
  font-family: ui-monospace, 'SF Mono', Menlo, monospace;
  letter-spacing: 0.5px;
}

/* Saved list */
.saved-list {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 8px 20px;
  overflow-y: auto;
}
.saved-row {
  display: flex;
  align-items: center;
  gap: 12px;
}
.saved-apply {
  flex: 1 1 auto;
  display: flex;
  align-items: center;
  gap: 14px;
  min-height: 64px;
  background: var(--bg-secondary);
  border-radius: var(--radius-md);
  padding: 8px 14px;
}
.saved-chip {
  flex: 0 0 auto;
  width: 48px;
  height: 48px;
  border-radius: 10px;
  background: #000;
}
.saved-hex {
  font-size: 22px;
  font-weight: 600;
  font-family: ui-monospace, 'SF Mono', Menlo, monospace;
  letter-spacing: 1px;
}
.saved-del {
  flex: 0 0 auto;
  width: 64px;
  min-height: 64px;
  background: var(--bg-tertiary);
  color: var(--danger);
  border-radius: var(--radius-md);
  font-size: 24px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
}
.empty {
  flex: 1 1 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  font-size: 18px;
}

/* Toast */
.toast {
  position: absolute;
  left: 50%;
  bottom: 28px;
  transform: translateX(-50%);
  background: var(--bg-tertiary);
  color: var(--text-primary);
  border: 1px solid var(--accent);
  border-radius: var(--radius-md);
  padding: 12px 22px;
  font-size: 17px;
  font-weight: 600;
  box-shadow: 0 0 24px var(--focus-glow);
  z-index: 10;
}
