/* ── Appearance side panel (TASK-025, theme.js) ─────────────────────────────
 * A sheet on the right (full width on phones) with the theme mode, accent
 * presets, the person's own HEX colour and the neutral tone. Only tokens from
 * style.css are used, so the panel itself follows the chosen theme.
 */
.theme-panel-scrim { display: none; }
body.theme-panel-open .theme-panel-scrim {
  display: block; position: fixed; inset: 0; z-index: 940;
  background: rgba(10, 14, 22, 0.45);
}
body.theme-panel-open { overflow: hidden; }

.theme-panel {
  position: fixed; top: 0; right: 0; bottom: 0; z-index: 950;
  width: min(420px, 100vw);
  display: flex; flex-direction: column;
  background: var(--bg2); color: var(--text);
  border-left: 1px solid var(--border);
  box-shadow: var(--shadow-lg);
  animation: theme-panel-in 0.18s ease-out;
}
.theme-panel[hidden] { display: none; }
@keyframes theme-panel-in { from { transform: translateX(24px); opacity: 0; } to { transform: none; opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .theme-panel { animation: none; } }

.theme-panel-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 16px 12px 20px; border-bottom: 1px solid var(--border);
  padding-top: max(16px, env(safe-area-inset-top));
}
.theme-panel-head h2 { display: flex; align-items: center; gap: 10px; font-size: 18px; font-weight: 700; }
.theme-panel-head h2 .icon { width: 20px; height: 20px; color: var(--accent); }
.theme-panel-body {
  flex: 1; overflow-y: auto; padding: 8px 20px 24px;
  padding-bottom: max(24px, env(safe-area-inset-bottom));
}

.theme-section { padding: 16px 0; border-bottom: 1px solid var(--border); }
.theme-section h3 { font-size: 15px; font-weight: 650; margin-bottom: 2px; }
.theme-hint { font-size: 13px; color: var(--text-muted); margin-bottom: 12px; line-height: 1.45; }

.theme-options { display: grid; gap: 8px; }
.theme-modes { grid-template-columns: repeat(3, 1fr); }
.theme-accents { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); }
.theme-neutrals { grid-template-columns: repeat(3, 1fr); }

.theme-option {
  position: relative;
  display: flex; align-items: center; gap: 8px;
  min-height: 44px; padding: 8px 10px;
  background: var(--bg3); color: var(--text);
  border: 1.5px solid transparent; border-radius: var(--radius-md);
  font: inherit; font-size: 13.5px; font-weight: 500; text-align: left; cursor: pointer;
}
.theme-option:hover { background: var(--surface-hover); }
.theme-option:focus-visible { outline: none; box-shadow: var(--focus-ring); }
.theme-option .icon { width: 18px; height: 18px; flex: none; color: var(--text-sub); }
.theme-option-label { flex: 1; min-width: 0; }
.theme-option-check { visibility: hidden; font-weight: 700; color: var(--accent); }
.theme-option.active { border-color: var(--accent); background: var(--accent-soft); }
.theme-option.active .icon { color: var(--accent); }
.theme-option.active .theme-option-check { visibility: visible; }
.theme-modes .theme-option, .theme-neutrals .theme-option { flex-direction: column; justify-content: center; text-align: center; gap: 4px; padding: 10px 6px; }
.theme-modes .theme-option-check, .theme-neutrals .theme-option-check { position: absolute; top: 4px; right: 8px; }

/* Two halves: the colour in the light and in the dark theme. */
.theme-swatch {
  display: inline-flex; width: 22px; height: 22px; flex: none;
  border-radius: 50%; overflow: hidden; box-shadow: 0 0 0 1px var(--border-strong);
}
.theme-swatch-half { flex: 1; }

.theme-custom {
  display: flex; align-items: center; gap: 8px; max-width: 220px;
  padding: 6px 10px; border: 1.5px solid var(--border-strong); border-radius: var(--radius-md);
  background: var(--bg2); cursor: text;
}
.theme-custom.active { border-color: var(--accent); }
.theme-custom:focus-within { box-shadow: var(--focus-ring); }
.theme-custom-preview { width: 22px; height: 22px; border-radius: 6px; flex: none; box-shadow: 0 0 0 1px var(--border-strong); }
.theme-custom-preview.empty { background: repeating-linear-gradient(45deg, var(--bg3), var(--bg3) 3px, var(--bg4) 3px, var(--bg4) 6px) !important; }
.theme-custom-hash { color: var(--text-sub); font-weight: 600; }
.theme-custom input {
  flex: 1; min-width: 0; border: 0; background: transparent; color: var(--text);
  font: inherit; font-size: 15px; letter-spacing: 0.04em; text-transform: uppercase; padding: 4px 0;
}
.theme-custom input:focus { outline: none; box-shadow: none; border: 0; }
.theme-note {
  margin-top: 10px; padding: 8px 10px; border-radius: var(--radius-sm);
  background: var(--warn-bg); color: var(--text); font-size: 13px; line-height: 1.45;
}

.theme-panel-foot { display: flex; align-items: center; gap: 12px; padding: 14px 0 6px; flex-wrap: wrap; }
.theme-to-display { margin: 12px 0 8px; display: inline-flex; align-items: center; gap: 8px; }
.theme-open-panel { margin-top: 10px; display: inline-flex; align-items: center; gap: 6px; }

@media (max-width: 420px) {
  .theme-panel { border-left: 0; }
}
