* { margin: 0; padding: 0; box-sizing: border-box; }
:root { --transition: 0.3s ease; }

[data-theme="dark"] {
  --bg: #1a1917;
  --surface: #23221f;
  --border: #33312c;
  --text: #e8e4dc;
  --muted: #8a857b;
  --accent: #9b6fd4;
  --hover: #2a2926;
  --scroll-thumb: #3d3a34;
}
[data-theme="light"] {
  --bg: #f4f1eb;
  --surface: #ece8e0;
  --border: #d4cfc6;
  --text: #1a1a1a;
  --muted: #7a756d;
  --accent: #7c4dba;
  --hover: #e4e0d7;
  --scroll-thumb: #c4bfb6;
}

html {
  scrollbar-width: thin;
  scrollbar-color: var(--scroll-thumb) transparent;
}
html::-webkit-scrollbar { width: 6px; height: 6px; }
html::-webkit-scrollbar-track { background: transparent; }
html::-webkit-scrollbar-thumb { background: var(--scroll-thumb); border-radius: 4px; }
html::-webkit-scrollbar-thumb:hover { background: var(--muted); }

body {
  font-family: 'DM Mono', monospace;
  background: var(--bg);
  color: var(--text);
  font-size: 13px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  height: 100vh;
  overflow: hidden;
  transition: background var(--transition), color var(--transition);
}

a { color: var(--text); text-decoration: none; transition: color 0.2s; }
a:hover { color: var(--accent); }

.page {
  height: 100vh;
  display: grid;
  grid-template-rows: auto 1fr auto;
  max-width: 1120px;
  margin: 0 auto;
  padding: 0 32px;
  overflow: hidden;
}

/* ── NAV ── */
nav {
  padding: 20px 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--border);
  transition: border-color var(--transition);
  gap: 16px;
  flex-shrink: 0;
}

.logo { font-weight: 500; font-size: 14px; letter-spacing: -0.3px; }
.logo span { color: var(--accent); }

.nav-left { display: flex; align-items: center; gap: 10px; flex: 1; min-width: 0; }
.nav-right { display: flex; align-items: center; gap: 14px; flex-shrink: 0; }

.nav-back {
  font-size: 11px;
  color: var(--muted);
  transition: color 0.2s;
  background: none; border: none;
  font-family: 'DM Mono', monospace;
  padding: 0; cursor: pointer;
  text-decoration: none;
}
.nav-back:hover { color: var(--accent); }

.nav-sep { color: var(--border); font-size: 11px; user-select: none; }

.theme-toggle {
  width: 28px; height: 28px;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--muted);
  font-size: 14px;
  border-radius: 50%;
  cursor: pointer;
  transition: all var(--transition);
  display: flex; align-items: center; justify-content: center;
  line-height: 1; font-family: inherit;
}
.theme-toggle:hover { color: var(--text); border-color: var(--muted); }

/* ── FOOTER ── */
footer {
  padding: 14px 0;
  font-size: 11px;
  color: var(--muted);
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  transition: border-color var(--transition);
  flex-shrink: 0;
}
.clock { font-variant-numeric: tabular-nums; }

/* ── UTILITIES ── */
.section-label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 1.4px;
  color: var(--muted);
  margin-bottom: 10px;
}

.scroll-thin {
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--scroll-thumb) transparent;
}
.scroll-thin::-webkit-scrollbar { width: 4px; }
.scroll-thin::-webkit-scrollbar-track { background: transparent; }
.scroll-thin::-webkit-scrollbar-thumb { background: var(--scroll-thumb); border-radius: 4px; }
.scroll-thin::-webkit-scrollbar-thumb:hover { background: var(--muted); }

/* ── GENERATOR LAYOUT ── */
.main {
  display: grid; grid-template-columns: 272px 1fr;
  min-height: 0; overflow: hidden;
}

.controls {
  border-right: 1px solid var(--border);
  padding: 20px 20px 20px 0;
  display: flex; flex-direction: column; gap: 0;
  overflow-y: auto; overflow-x: hidden;
  scrollbar-width: thin; scrollbar-color: var(--scroll-thumb) transparent;
}
.controls::-webkit-scrollbar { width: 3px; }
.controls::-webkit-scrollbar-thumb { background: var(--scroll-thumb); border-radius: 4px; }

.ctrl-div { height: 1px; background: var(--border); margin: 16px 0; flex-shrink: 0; }

.search-row { display: flex; gap: 6px; margin-bottom: 8px; }

.ctrl-input {
  flex: 1; background: var(--surface); border: 1px solid var(--border);
  color: var(--text); font-family: 'DM Mono', monospace; font-size: 11px;
  padding: 6px 10px; border-radius: 4px; transition: border-color 0.2s; outline: none;
}
.ctrl-input::placeholder { color: var(--muted); opacity: 0.65; }
.ctrl-input:focus { border-color: var(--accent); }

.ctrl-btn {
  background: var(--surface); border: 1px solid var(--border);
  color: var(--muted); font-family: 'DM Mono', monospace;
  font-size: 11px; padding: 6px 11px; border-radius: 4px;
  cursor: pointer; white-space: nowrap;
  transition: color 0.2s, border-color 0.2s, background 0.2s;
}
.ctrl-btn:hover:not(:disabled) { color: var(--text); border-color: var(--muted); }
.ctrl-btn:disabled { opacity: 0.38; cursor: not-allowed; }
.ctrl-btn-full { width: 100%; text-align: center; }
.ctrl-btn-accent { border-color: var(--accent); color: var(--accent); }
.ctrl-btn-accent:hover:not(:disabled) { background: var(--accent); color: var(--bg); border-color: var(--accent); }

.named-preset-btn {
  flex: 1; display: flex; flex-direction: column; align-items: flex-start; gap: 3px;
  background: var(--surface); border: 1px solid var(--border);
  color: var(--muted); font-family: 'DM Mono', monospace;
  font-size: 10px; padding: 7px 10px; border-radius: 4px;
  cursor: pointer; transition: all 0.15s; text-align: left;
}
.named-preset-btn:hover { color: var(--text); border-color: var(--muted); }
.named-preset-name { letter-spacing: 0.3px; color: var(--text); }
.named-preset-meta { font-size: 9px; color: var(--muted); opacity: 0.6; }

.seg-row { display: flex; gap: 4px; }
.seg-btn {
  flex: 1; background: var(--surface); border: 1px solid var(--border);
  color: var(--muted); font-family: 'DM Mono', monospace;
  font-size: 10px; padding: 5px 4px; border-radius: 4px;
  cursor: pointer; text-align: center; letter-spacing: 0.5px; transition: all 0.15s;
}
.seg-btn:hover { color: var(--text); }
.seg-btn.active { border-color: var(--accent); color: var(--accent); }

.res-inputs { display: flex; align-items: center; gap: 6px; margin-bottom: 8px; }
.res-inputs span { font-size: 11px; color: var(--muted); }

.num-input {
  width: 62px; background: var(--surface); border: 1px solid var(--border);
  color: var(--text); font-family: 'DM Mono', monospace;
  font-size: 11px; padding: 5px 8px; border-radius: 4px;
  text-align: center; outline: none; transition: border-color 0.2s;
}
.num-input:focus { border-color: var(--accent); }

.preset-row { display: flex; gap: 4px; flex-wrap: wrap; }
.preset-btn {
  background: var(--surface); border: 1px solid var(--border);
  color: var(--muted); font-family: 'DM Mono', monospace;
  font-size: 10px; padding: 3px 9px; border-radius: 4px;
  cursor: pointer; letter-spacing: 0.3px; transition: all 0.15s;
}
.preset-btn:hover { color: var(--text); border-color: var(--muted); }
.preset-btn.active { border-color: var(--accent); color: var(--accent); }

.dl-row { display: flex; gap: 6px; align-items: stretch; }
.dl-btn {
  flex: 1; background: var(--accent); border: none;
  color: #fff; font-family: 'DM Mono', monospace;
  font-size: 12px; padding: 9px; border-radius: 4px;
  cursor: pointer; letter-spacing: 0.5px; transition: opacity 0.2s;
}
.dl-btn:hover:not(:disabled) { opacity: 0.85; }
.dl-btn:disabled { opacity: 0.32; cursor: not-allowed; }

.preview-meta {
  font-size: 10px; color: var(--muted); opacity: 0.45;
  text-align: center; flex-shrink: 0; letter-spacing: 0.3px;
  font-variant-numeric: tabular-nums;
}

.credits {
  font-size: 9px; color: var(--muted); opacity: 0.32;
  text-align: center; flex-shrink: 0; letter-spacing: 0.4px;
}

/* ── BUTTONS (index page) ── */
.btn {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--muted);
  font-family: 'DM Mono', monospace;
  font-size: 11px;
  padding: 6px 12px;
  border-radius: 4px;
  cursor: pointer;
  transition: color 0.2s, border-color 0.2s, background 0.2s;
  white-space: nowrap;
  line-height: 1.4;
}
.btn:hover:not(:disabled) { color: var(--text); border-color: var(--muted); }
.btn:disabled { opacity: 0.38; cursor: not-allowed; }
.btn-accent { border-color: var(--accent); color: var(--accent); }
.btn-accent:hover:not(:disabled) { background: var(--accent); color: var(--bg); border-color: var(--accent); }
.btn-primary {
  background: var(--accent); border-color: var(--accent); color: #fff;
  font-size: 12px; padding: 9px 16px; letter-spacing: 0.3px;
}
.btn-primary:hover:not(:disabled) { opacity: 0.86; color: #fff; background: var(--accent); border-color: var(--accent); }
.btn-primary:disabled { opacity: 0.32; }

/* ── INPUTS (index page) ── */
.input {
  background: var(--surface); border: 1px solid var(--border);
  color: var(--text); font-family: 'DM Mono', monospace;
  font-size: 11px; padding: 6px 10px; border-radius: 4px;
  transition: border-color 0.2s; outline: none;
}
.input::placeholder { color: var(--muted); opacity: 0.65; }
.input:focus { border-color: var(--accent); }
select.input {
  cursor: pointer; -webkit-appearance: none; appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%238a857b'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 10px center; padding-right: 28px;
}

@media (max-width: 768px) {
  body { overflow: auto; height: auto; }
  .page { height: auto; min-height: 100vh; padding: 0 16px; overflow: visible; }
  .main { grid-template-columns: 1fr; }
  .controls { border-right: none; border-bottom: 1px solid var(--border); padding: 16px 0; }
}
