:root {
  --bg:           #0f172a;
  --surface:      #1e293b;
  --border:       #334155;
  --text:         #f1f5f9;
  --muted:        #94a3b8;
  --accent:       #818cf8;
  --accent-deep:  #6366f1;
  --accent-hover: #4f46e5;
  --red:          #fca5a5;
  --amber-bg:     #431407;
  --amber-text:   #fcd34d;
  --amber-border: #92400e;
  --green:        #4ade80;
  --glow:         0 0 0 3px rgba(129, 140, 248, 0.25);
}

/* ── Reset ────────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { scroll-behavior: smooth; }

/* ── Base body ────────────────────────────────────────────────────────────── */
body {
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  /* default padding for depsview */
  padding: 3rem 1.5rem;
}

/* ── Landing page (body.pg-landing) ──────────────────────────────────────── */
.pg-landing {
  font-size: 16px;
  padding: 0 1.5rem 4rem;
}

.container {
  max-width: 860px;
  margin: 0 auto;
}

.pg-landing .site-header {
  display: block;
  border-bottom: 1px solid var(--border);
  padding: 1.1rem 0;
  margin-bottom: 4rem;
}

.pg-landing .site-header .container {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.logo {
  font-family: ui-monospace, "SF Mono", Consolas, "Liberation Mono", Menlo, monospace;
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--accent);
  letter-spacing: 0.04em;
  text-decoration: none;
}

.header-links {
  display: flex;
  gap: 1.5rem;
}

.header-links a {
  font-family: ui-monospace, "SF Mono", Consolas, "Liberation Mono", Menlo, monospace;
  font-size: 0.75rem;
  color: var(--muted);
  text-decoration: none;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  transition: color 0.2s;
}

.header-links a:hover { color: var(--text); }

.hero { margin-bottom: 4rem; }

.hero h1 {
  font-size: clamp(2rem, 5vw, 3rem);
  font-weight: 700;
  margin: 0 0 0.5rem;
  background: linear-gradient(90deg, #c4b5fd 0%, #a855f7 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  line-height: 1.15;
}

.hero .tagline {
  color: var(--muted);
  font-size: 1rem;
  max-width: 540px;
}

.hero .tagline a { color: var(--accent); text-decoration: none; }
.hero .tagline a:hover { text-decoration: underline; }

.section-label {
  font-family: ui-monospace, "SF Mono", Consolas, "Liberation Mono", Menlo, monospace;
  font-size: 0.72rem;
  color: var(--accent);
  letter-spacing: 0.14em;
  text-transform: uppercase;
  margin-bottom: 1.5rem;
}

.project-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 1rem;
}

.project-card {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1.5rem 1.6rem;
  text-decoration: none;
  color: inherit;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.project-card:hover {
  border-color: var(--accent);
  box-shadow: var(--glow);
}

.project-header {
  display: flex;
  align-items: baseline;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.project-name {
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--text);
}

.project-tag {
  font-family: ui-monospace, "SF Mono", Consolas, "Liberation Mono", Menlo, monospace;
  font-size: 0.68rem;
  color: var(--accent);
  background: rgba(129, 140, 248, 0.1);
  border: 1px solid rgba(129, 140, 248, 0.25);
  border-radius: 4px;
  padding: 0.15em 0.5em;
  letter-spacing: 0.04em;
}

.project-desc {
  font-size: 0.88rem;
  color: var(--muted);
  line-height: 1.65;
  flex: 1;
}

.project-link {
  font-family: ui-monospace, "SF Mono", Consolas, "Liberation Mono", Menlo, monospace;
  font-size: 0.78rem;
  color: var(--accent-deep);
  letter-spacing: 0.04em;
  transition: color 0.2s;
}

.project-card:hover .project-link { color: var(--accent); }

.site-footer {
  margin-top: 5rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border);
}

.site-footer p {
  font-family: ui-monospace, "SF Mono", Consolas, "Liberation Mono", Menlo, monospace;
  font-size: 0.75rem;
  color: var(--muted);
}

.site-footer a { color: var(--accent); text-decoration: none; }
.site-footer a:hover { text-decoration: underline; }

@media (max-width: 480px) {
  .project-grid { grid-template-columns: 1fr; }
  .header-links { display: none; }
}

/* ── Depsview app ─────────────────────────────────────────────────────────── */

main { max-width: 980px; margin: 0 auto; }

/* Header */
.site-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 2rem;
}

.site-header h1 { margin: 0; width: fit-content; line-height: 1; }
.site-header a:last-child:not(:first-child) { margin-left: auto; }

.site-header > a { display: flex; align-items: center; text-decoration: none; color: inherit; }

.header-logo {
  display: block;
  width: 32px;
  height: 32px;
  opacity: 0.75;
  transition: opacity 0.2s;
}

.header-logo:hover { opacity: 1; }

.header-github {
  display: block;
  width: 24px;
  height: 24px;
  opacity: 0.5;
  filter: invert(1);
  transition: opacity 0.2s;
}

.header-github:hover { opacity: 0.9; }

/* Gradient headline */
h1 {
  font-size: 2rem;
  font-weight: 700;
  margin: 0 0 0.25rem;
  background: linear-gradient(90deg, #c4b5fd 0%, #a855f7 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.tagline     { color: var(--muted); margin: 0 0 0.35rem; font-size: 1rem; }
.tagline-sub { font-size: 0.82rem; color: var(--muted); margin: 0 0 2.5rem; opacity: 0.75; }

/* ── Form ─────────────────────────────────────────────────────────────────── */
.input-row {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  align-items: stretch;
}

#url-input,
#formula-input,
.token-row input {
  padding: 0.6rem 0.85rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 1rem;
  font-family: inherit;
  color: var(--text);
  background: var(--surface);
  transition: border-color 0.2s, box-shadow 0.2s;
}

#url-input,
#formula-input { flex: 1; min-width: 280px; }

#url-input::placeholder,
#formula-input::placeholder,
.token-row input::placeholder { color: var(--muted); }

#url-input:focus,
#formula-input:focus,
.token-row input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: var(--glow);
}

#submit-btn {
  padding: 0.6rem 1.5rem;
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-deep) 100%);
  box-shadow: 0 2px 12px rgba(99, 102, 241, 0.35);
  color: #fff;
  border: none;
  border-radius: 8px;
  font-size: 1rem;
  font-family: inherit;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  transition: box-shadow 0.2s, opacity 0.2s;
}

#submit-btn:hover:not(:disabled) {
  box-shadow: 0 4px 20px rgba(99, 102, 241, 0.55);
  opacity: 0.92;
}

#submit-btn:disabled { opacity: 0.4; cursor: not-allowed; box-shadow: none; }

.token-note {
  font-size: 0.82rem;
  color: #a5b4fc;
  margin: 1.25rem 0 0;
}

.storage-note {
  font-size: 0.78rem;
  color: var(--muted);
  margin: 0.25rem 0 0 1.4rem;
}

.token-row { margin-top: 0.75rem; }
.token-row input { flex: 1; min-width: 280px; font-size: 0.9rem; }

.option-row {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  margin-top: 0.85rem;
  font-size: 0.9rem;
  color: var(--muted);
}

.option-row input[type="checkbox"] { cursor: pointer; width: 1em; height: 1em; accent-color: var(--accent); }
.option-row label { cursor: pointer; }

.section-divider {
  border: none;
  border-top: 1px solid var(--border);
  margin: 1.25rem 0;
}

.note {
  font-size: 0.8rem;
  color: var(--muted);
  margin: 1.25rem 0 0;
  line-height: 1.6;
}

.note-warning {
  background: rgba(146, 64, 14, 0.2);
  border-left: 3px solid var(--amber-border);
  border-radius: 0 6px 6px 0;
  padding: 0.5rem 0.85rem;
  color: var(--amber-text);
  margin: 0 0 0.85rem;
}

.legend      { font-size: 0.8rem; color: var(--muted); margin: 0.5rem 0 0; }
.legend-swatch { font-style: normal; }

/* ── Error banner ─────────────────────────────────────────────────────────── */
#error {
  margin-top: 2rem;
  background: var(--amber-bg);
  border: 1px solid var(--amber-border);
  border-radius: 8px;
  padding: 0.85rem 1.1rem;
  color: var(--amber-text);
  font-size: 0.95rem;
}

/* ── Progress log ─────────────────────────────────────────────────────────── */
#progress {
  margin-top: 2rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.85rem 1.1rem;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
  font-size: 0.82rem;
  color: var(--muted);
  max-height: 200px;
  overflow-y: auto;
  white-space: pre-wrap;
  word-break: break-all;
}

/* ── Results ──────────────────────────────────────────────────────────────── */
#results { margin-top: 2rem; }

.summary {
  font-size: 0.88rem;
  color: var(--muted);
  margin: 0 0 0.25rem;
}

.source-files {
  font-size: 0.78rem;
  color: var(--muted);
  opacity: 0.65;
  margin: 0 0 0.85rem;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
}

thead tr { border-bottom: 2px solid var(--border); }

th {
  text-align: left;
  padding: 0.65rem 0.9rem;
  font-weight: 600;
  white-space: nowrap;
  color: var(--muted);
}

td { padding: 0.55rem 0.9rem; border-bottom: 1px solid var(--border); }

tbody tr:last-child td { border-bottom: none; }
tbody tr:hover td { background: #273548; }

.age-new   { color: var(--red);    font-weight: 500; }
.age-fresh { color: #fcd34d;       font-weight: 500; }

.row-error td { color: var(--muted); font-style: italic; }

table a       { color: var(--accent); text-decoration: none; }
table a:hover { text-decoration: underline; }

/* ── Sortable column headers ──────────────────────────────────────────────── */
th[data-col]       { cursor: pointer; user-select: none; }
th[data-col]:hover { color: var(--text); }
th.th-sort-desc::after { content: ' ▼'; font-size: 0.75em; opacity: 0.8; }
th.th-sort-asc::after  { content: ' ▲'; font-size: 0.75em; opacity: 0.8; }
