/* Dark theme — readable typography */
:root {
  color-scheme: dark;
  --bg: #0e1117;
  --bg-soft: #1a2332;
  --sidebar: #161b22;
  --text: #e7ecf3;
  --muted: #9aa8bc;
  --accent: #5b9cff;
  --primary: #3d8bfd;
  --primary-hover: #2f6fd4;
  --border: #2a3548;
  --success-bg: #1a3d2e;
  --success-text: #7ddea8;
  --info-bg: #1a2d3d;
  --info-text: #8ec8f0;
  --warn-bg: #3d321a;
  --warn-text: #f0d070;
  --code-bg: #1c2b3a;
  --font: "DM Sans", "Segoe UI", system-ui, sans-serif;
  --text-base: 1.125rem;
  --text-sm: 1rem;
  --text-xs: 0.9375rem;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  line-height: 1.6;
  font-size: var(--text-base);
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

.site-header {
  padding: 1.25rem 1.75rem 1rem;
  border-bottom: 1px solid var(--border);
  background: var(--bg-soft);
}

.site-header h1 { margin: 0; font-size: 2rem; font-weight: 600; }
.site-header h1 a { color: inherit; text-decoration: none; }
.tagline { margin: 0.5rem 0 0; color: var(--muted); font-size: 1.1rem; max-width: none; }

.layout {
  display: flex;
  min-height: calc(100vh - 6rem);
}

.sidebar {
  width: 24rem;
  min-width: 18rem;
  max-width: 42rem;
  padding: 1.25rem 1.35rem;
  border-right: 1px solid var(--border);
  background: var(--sidebar);
  overflow-y: auto;
  resize: horizontal;
  overflow: auto;
}

.main {
  flex: 1 1 auto;
  padding: 1.25rem 2rem 2.5rem;
  max-width: 100%;
  overflow-x: auto;
}

h2 { font-size: 1.5rem; font-weight: 600; margin: 1.25rem 0 0.65rem; }
h3 { font-size: 1.25rem; font-weight: 600; }

.divider, hr.divider {
  border: none;
  border-top: 1px solid var(--border);
  margin: 1.25rem 0;
}

.section-label { font-weight: 600; margin: 0.65rem 0; font-size: 1.05rem; }

.checkbox-row {
  display: flex;
  gap: 0.65rem;
  align-items: flex-start;
  margin: 0.5rem 0;
  font-size: var(--text-sm);
  cursor: pointer;
}

.checkbox-row input { width: 1.1rem; height: 1.1rem; margin-top: 0.2rem; }

fieldset { border: none; margin: 0; padding: 0; }
legend { font-weight: 600; margin-bottom: 0.5rem; font-size: 1.05rem; }

.btn {
  display: inline-block;
  padding: 0.6rem 1.15rem;
  border-radius: 0.5rem;
  border: 1px solid var(--border);
  cursor: pointer;
  font-weight: 600;
  font-size: var(--text-sm);
  text-align: center;
  background: var(--bg-soft);
  color: var(--text);
}

.btn-block { display: block; width: 100%; }
.export-actions { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.btn-primary { background: var(--primary); color: #fff; border-color: var(--primary); }
.btn-primary:hover { background: var(--primary-hover); color: #fff; }
.btn-secondary { background: var(--bg-soft); }
.btn-danger { background: #b91c1c; color: #fff; border-color: #991b1b; }
.btn-danger:hover { background: #991b1b; color: #fff; }
.btn-sm { padding: 0.3rem 0.7rem; font-size: var(--text-xs); font-weight: 500; }
.btn-ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn-ghost:hover { background: var(--bg-soft); color: var(--text); border-color: var(--border); }

.alert {
  padding: 0.9rem 1.1rem;
  border-radius: 0.5rem;
  margin: 0.65rem 0;
  font-size: var(--text-sm);
  border: 1px solid transparent;
}

.alert.compact { padding: 0.65rem 0.9rem; }
.alert-success { background: var(--success-bg); color: var(--success-text); border-color: #2d5a42; }
.alert-info { background: var(--info-bg); color: var(--info-text); border-color: #2a4a5e; }
.alert-warning { background: var(--warn-bg); color: var(--warn-text); border-color: #5a4a2a; }

.alert-list { list-style: none; padding: 0; margin: 0; }

.hidden { display: none !important; }

.hint, .caption { color: var(--muted); font-size: var(--text-xs); }
.sidebar-foot { font-size: var(--text-xs); }

code {
  background: var(--code-bg);
  padding: 0.15rem 0.35rem;
  border-radius: 0.25rem;
  font-size: 0.95em;
}

.log-tail {
  max-height: 240px;
  overflow: auto;
  font-size: var(--text-xs);
  background: var(--code-bg);
  color: #d8dee9;
  padding: 0.65rem;
  border-radius: 0.35rem;
  white-space: pre-wrap;
  margin: 0.5rem 0;
  border: 1px solid var(--border);
}

.code-peek {
  margin: 0.65rem 0 1.15rem;
  border: 1px solid var(--border);
  border-radius: 0.35rem;
  background: var(--bg-soft);
}

.code-peek summary {
  cursor: pointer;
  padding: 0.65rem 0.9rem;
  font-size: var(--text-sm);
}

.code-peek pre {
  margin: 0;
  padding: 0.9rem;
  overflow: auto;
  font-size: var(--text-xs);
  border-top: 1px solid var(--border);
  background: var(--code-bg);
  color: #d8dee9;
}

.peek-extra { padding: 0 0.9rem 0.9rem; font-size: var(--text-xs); color: var(--muted); }
.peek-extra pre { margin-top: 0.5rem; padding: 0.5rem; background: var(--code-bg); border-radius: 0.25rem; }

.peek-tier-label { margin: 0.6rem 0 0.3rem; font-size: 0.85rem; color: var(--muted); }
.peek-tiers { display: flex; flex-wrap: wrap; gap: 1.25rem; margin-top: 0.25rem; }
.peek-tier-group { flex: 1; min-width: 18rem; }
.peek-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
  margin: 0.3rem 0 0.5rem;
}
.peek-tag {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 0.25rem;
  padding: 0.1rem 0.45rem;
  font-size: 0.78rem;
  font-family: monospace;
  color: var(--accent);
  white-space: nowrap;
}
.peek-prompt {
  margin: 0.25rem 0 0;
  padding: 0.75rem;
  background: var(--code-bg);
  border-radius: 0.35rem;
  white-space: pre-wrap;
  line-height: 1.55;
}

.progress-wrap {
  height: 8px;
  background: var(--border);
  border-radius: 4px;
  overflow: hidden;
  margin: 0.9rem 0;
}

.progress-bar {
  height: 100%;
  background: var(--primary);
  transition: width 0.25s ease;
}

.metrics {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 1rem;
  margin: 1.25rem 0;
}

.metric {
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: 0.5rem;
  padding: 1rem 1.15rem;
}

.metric-label { display: block; font-size: var(--text-xs); color: var(--muted); }
.metric-value { display: block; font-size: 1.75rem; font-weight: 600; margin-top: 0.25rem; }

.tabs { margin-top: 1.25rem; }

.tab-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  border-bottom: 2px solid var(--border);
  margin-bottom: 1.15rem;
}

.tab {
  background: transparent;
  border: none;
  padding: 0.65rem 1rem;
  cursor: pointer;
  font-size: var(--text-sm);
  color: var(--muted);
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
}

.tab.active { color: var(--accent); border-bottom-color: var(--accent); font-weight: 600; }

.tab-panel { display: none; }
.tab-panel.active { display: block; }

.table-wrap {
  overflow: auto;
  max-height: 65vh;
  border: 1px solid var(--border);
  border-radius: 0.35rem;
  background: var(--bg-soft);
}

.table-wrap.compact { max-height: none; }

table { width: 100%; border-collapse: collapse; font-size: var(--text-sm); }
th, td {
  border-bottom: 1px solid var(--border);
  padding: 0.55rem 0.7rem;
  text-align: left;
  vertical-align: top;
}

th {
  background: var(--sidebar);
  font-weight: 600;
  position: sticky;
  top: 0;
  font-size: var(--text-xs);
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--muted);
}

/* Compact course table */
.course-table { font-size: 0.85rem; }
.course-table th, .course-table td { padding: 0.3rem 0.5rem; }
td.terms, td.reason {
  max-width: 14rem;
  font-size: 0.8rem;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  line-clamp: 2;
}

.chart { min-height: 400px; margin: 1.25rem 0; }

#chart-clusters.chart {
  width: 100%;
  max-width: min(56rem, 100%);
  min-height: 420px;
}

.how-it-works {
  margin-top: 1.25rem;
  border: 1px solid var(--border);
  border-radius: 0.5rem;
  padding: 0.75rem 1.15rem;
  background: var(--bg-soft);
}

.how-it-works summary { cursor: pointer; font-weight: 600; font-size: 1.1rem; }

.run-controls { margin-top: 0.75rem; }

.notice { font-size: var(--text-sm); margin: 0.5rem 0; }
.notice.warn { color: var(--warn-text); }

@media (max-width: 900px) {
  .layout { grid-template-columns: 1fr; }
  .main { padding: 1rem; }
  body { font-size: 1.0625rem; }
}
