/* SPDX-License-Identifier: MIT */

[hidden] { display: none !important; }

:root {
  --max-width: 1100px;

  /* Dark theme defaults */
  --bg0: #0b0c10;
  --bg1: #0f1220;

  --surface: rgba(255, 255, 255, 0.06);
  --surface2: rgba(255, 255, 255, 0.04);
  --border: rgba(255, 255, 255, 0.12);

  --text: rgba(255, 255, 255, 0.92);
  --muted: rgba(255, 255, 255, 0.68);

  --shadow: 0 16px 50px rgba(0, 0, 0, 0.45);
  --radius: 16px;

  --accent: rgba(120, 90, 255, 0.92);
  --accent-soft: rgba(120, 90, 255, 0.18);
  --accent2: rgba(0, 200, 160, 0.18);

  /* Badges (ink stamp vibe) */
  --ok-border: rgba(40, 220, 140, 0.35);
  --ok-bg: rgba(40, 220, 140, 0.12);
  --warn-border: rgba(255, 170, 0, 0.40);
  --warn-bg: rgba(255, 170, 0, 0.16);
}

/* Light theme (crisp, not washed out) */
html[data-theme="light"] {
  --bg0: #f4f6fb;
  --bg1: #e9edf5;

  --surface: #ffffff;
  --surface2: #f3f5fa;
  --border: rgba(15, 20, 35, 0.18);

  --text: #0f1724;          /* darker */
  --muted: #475569;         /* slate-600 range */

  --shadow: 0 14px 36px rgba(15, 20, 35, 0.10);

  --accent: #4f46e5;
  --accent-soft: rgba(79, 70, 229, 0.14);
  --accent2: rgba(0, 160, 130, 0.12);

  --ok-border: rgba(10, 140, 80, 0.30);
  --ok-bg: rgba(10, 140, 80, 0.10);
  --warn-border: rgba(170, 110, 0, 0.34);
  --warn-bg: rgba(170, 110, 0, 0.12);
}

/* Warm / parchment theme */
html[data-theme="warm"] {
  --bg0: #f2ede2;
  --bg1: #e8e0d2;

  --surface: #fffdf8;
  --surface2: #f4ecdf;
  --border: rgba(80, 60, 35, 0.22);

  --text: #2b2115;          /* darker ink */
  --muted: #6b563e;         /* warm slate */

  --shadow: 0 12px 30px rgba(80, 60, 35, 0.12);

  --accent: #8b5e3c;
  --accent-soft: rgba(139, 94, 60, 0.14);
  --accent2: rgba(110, 80, 40, 0.08);

  --ok-border: rgba(50, 110, 70, 0.28);
  --ok-bg: rgba(50, 110, 70, 0.10);
  --warn-border: rgba(140, 90, 25, 0.36);
  --warn-bg: rgba(140, 90, 25, 0.14);
}

* { box-sizing: border-box; }

html, body {
  overscroll-behavior: none;
}

body {
  margin: 0;
  padding: 0;
  color: var(--text);
  font-family: system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  min-height: 100vh;
  voerflow-x: hidden;

  background:
radial-gradient(1200px 600px at 20% 10%, color-mix(in srgb, var(--accent) 18%, transparent), transparent 60%),    radial-gradient(1000px 600px at 85% 25%, var(--accent2), transparent 58%),
    linear-gradient(180deg, var(--bg1), var(--bg0));
}

.container {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 24px;
}

.page { padding: 0 0 64px 0; }

/* Header */
.topbar { padding: 28px 0 18px 0; }

.header-inner {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.brand { max-width: 760px; }

.brand h1 {
  margin: 0;
  font-size: 28px;
  font-weight: 760;
  letter-spacing: -0.01em;
}

.subtitle {
  margin: 8px 0 0 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.35;
}

.header-actions {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}

/* Cards */
.card {
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: var(--radius);
  padding: 22px;
  margin: 18px 0;
  box-shadow: var(--shadow);
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 14px;
}

.card h2 {
  margin: 0;
  font-size: 18px;
  font-weight: 760;
  letter-spacing: 0.01em;
}

.card h3 {
  margin: 10px 0 8px 0;
  font-size: 14px;
  font-weight: 720;
}

.muted {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.35;
}

code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.95em;
  padding: 0 0.25em;
  border-radius: 6px;
  background: color-mix(in srgb, var(--surface2) 70%, transparent);
  border: 1px solid var(--border);
}

/* Buttons */
.btn-ghost {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
  padding: 7px 12px;
  font-size: 13px;
  border-radius: 10px;
  cursor: pointer;
}

.btn-ghost:hover { background: color-mix(in srgb, var(--surface2) 55%, transparent); }

.btn-primary {
  background: var(--accent);
  border: 1px solid var(--accent);
  color: #fff;
  padding: 8px 14px;
  font-size: 13px;
  border-radius: 12px;
  cursor: pointer;
}

.btn-primary:hover { filter: brightness(1.06); }

.action-row {
  display: flex;
  gap: 10px;
  margin-top: 12px;
  align-items: center;
}

/* Form elements */
label {
  display: block;
  margin: 10px 0;
  font-size: 13px;
  color: var(--muted);
}

label.inline {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 10px;
  color: var(--text);
}

input[type="number"],
input[type="text"],
select {
  width: 100%;
  margin-top: 6px;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: color-mix(in srgb, var(--surface2) 85%, transparent);
  color: var(--text);
  outline: none;
}

input[type="number"]:focus,
input[type="text"]:focus,
select:focus {
  border-color: color-mix(in srgb, var(--accent) 55%, var(--border));
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 18%, transparent);
}

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

/* Layout grids */
.mode-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
  margin-top: 6px;
}

.advanced-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 12px;
  margin-top: 10px;
}

/* Derived KV */
.kv {
  display: grid;
  grid-template-columns: 180px 1fr;
  gap: 8px 12px;
  margin-top: 12px;
}

.kv .k {
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.kv .v {
  color: var(--text);
  font-size: 13px;
}

/* details */
.details {
  margin-top: 14px;
  border: 1px solid var(--border);
  background: color-mix(in srgb, var(--surface2) 60%, transparent);
  border-radius: 14px;
  padding: 10px 12px;
}

.details > summary {
  cursor: pointer;
  user-select: none;
  color: var(--text);
  font-weight: 650;
  font-size: 13px;
}

.details-body { padding-top: 10px; }

/* Generation notes */
.generation-notes {
  border: 1px solid var(--border);
  background: color-mix(in srgb, var(--surface2) 65%, transparent);
  border-radius: 14px;
  padding: 14px;
}

.note-title {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 750;
  color: var(--text);
  margin-top: 6px;
}

.generation-list { margin: 8px 0 0 18px; padding: 0; }
.generation-list li { margin: 6px 0; }

/* Results (generated by app.js) */
.result {
  border: 1px solid var(--border);
  background: color-mix(in srgb, var(--surface2) 65%, transparent);
  border-radius: 14px;
  padding: 14px;
  margin: 12px 0;
}

.result-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.result-title {
  font-weight: 760;
  font-size: 15px;
  margin-bottom: 2px;
}

.badge {
  font-size: 12px;
  padding: 6px 10px;
  border-radius: 999px;
  border: 1px solid var(--ok-border);
  background: var(--ok-bg);
  white-space: nowrap;
}

.badge-warn {
  border-color: var(--warn-border);
  background: var(--warn-bg);
}

/* Modal */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  align-items: center;
  justify-content: center;
  padding: 24px;
  z-index: 50;
  display: none;
}

.modal-overlay:not([hidden]) { display: flex; }

.modal {
  width: min(760px, 100%);
  max-height: min(80vh, 900px);
  overflow: auto;
  border-radius: 16px;
  border: 1px solid var(--border);
  background: var(--surface);
  box-shadow: var(--shadow);
  padding: 14px;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.modal-header h3 { margin: 0; }

.modal a {
  color: var(--accent);
  text-decoration: underline;
}

.modal a:hover {
  text-decoration: none;
}

.notice-pre {
  white-space: pre-wrap;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12px;
  line-height: 1.4;
  padding: 12px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: color-mix(in srgb, var(--surface2) 70%, transparent);
}

/* Responsive */
@media (max-width: 1100px) {
  .advanced-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

@media (max-width: 860px) {
  .header-inner { flex-direction: column; align-items: flex-start; }
  .mode-grid { grid-template-columns: 1fr; }
  .kv { grid-template-columns: 1fr; }
  .advanced-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }

  label { font-size: 12.5px; }
  input[type="number"], input[type="text"], select { padding: 9px 11px; }
}

@media (max-width: 520px) {
  .container { padding: 0 16px; }
  .brand h1 { font-size: 24px; }
  .card { padding: 18px; }
  .advanced-grid { grid-template-columns: 1fr; }
  label { font-size: 12px; }
}

.modal .version {
  font-size: 0.85rem;
  color: var(--muted);
  margin-top: 0.25rem;
}