/* ── Fonts ─────────────────────────────────────────────────────────────── */
@import url('https://fonts.googleapis.com/css2?family=JetBrains+Mono:ital,wght@0,400;0,600;0,700;1,400&display=swap');

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

:root {
  --bg:          #1b2220;
  --bg-card:     #24302b;
  --bg-code:     #17201d;
  --bg-code-hd:  #1f2a26;
  --border:      #365046;
  --border-bright: #4d9078;
  --accent:      #5fad56;
  --accent2:     #b4436c;
  --accent3:     #f2c14e;
  --text:        #f3f6f2;
  --text-dim:    #b5c7be;
  --text-muted:  #7f988d;
  --ln-color:    #7f988d;
  --font-mono:   'JetBrains Mono', 'Cascadia Code', 'Fira Code', monospace;
  --font-sans:   system-ui, -apple-system, sans-serif;
  --radius:      6px;
  --radius-lg:   10px;
}

html { font-size: 16px; scroll-behavior: smooth; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  line-height: 1.6;
  min-height: 100vh;
}

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

/* ── Site Header ───────────────────────────────────────────────────────── */
.site-header {
  border-bottom: 1px solid var(--border);
  padding: 0 2rem;
  background: rgba(27, 34, 32, 0.95);
  backdrop-filter: blur(8px);
  position: sticky;
  top: 0;
  z-index: 100;
}
.site-header-inner {
  max-width: 1100px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 52px;
}
.site-logo {
  font-family: var(--font-mono);
  font-size: 1rem;
  font-weight: 700;
  color: var(--accent);
  letter-spacing: -0.02em;
}
.site-logo span { color: var(--text-dim); font-weight: 400; }
.site-nav a {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--text-dim);
  padding: 0.25rem 0.75rem;
  border-radius: var(--radius);
  transition: color 0.15s, background 0.15s;
}
.site-nav a:hover { color: var(--text); background: var(--bg-card); text-decoration: none; }

/* ── Page Wrapper ──────────────────────────────────────────────────────── */
.page-wrap {
  max-width: 1100px;
  margin: 0 auto;
  padding: 3rem 2rem 5rem;
}

/* ── Hero ──────────────────────────────────────────────────────────────── */
.hero {
  padding: 4rem 0 3rem;
  text-align: center;
}
.hero-eyebrow {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--accent);
  letter-spacing: 0.15em;
  text-transform: uppercase;
  margin-bottom: 1rem;
}
.hero h1 {
  font-family: var(--font-mono);
  font-size: clamp(1.8rem, 4vw, 3rem);
  font-weight: 700;
  color: var(--text);
  line-height: 1.15;
  margin-bottom: 1rem;
}
.hero h1 .hl { color: var(--accent); }
.hero-sub {
  color: var(--text-dim);
  font-size: 1.05rem;
  max-width: 560px;
  margin: 0 auto 2.5rem;
}

/* ── Scheme Cards ──────────────────────────────────────────────────────── */
.schemes-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 1.25rem;
}
.scheme-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  transition: border-color 0.2s, transform 0.15s;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}
.scheme-card:hover {
  border-color: var(--accent);
  transform: translateY(-2px);
  text-decoration: none;
}
.card-meta {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.card-tag {
  font-family: var(--font-mono);
  font-size: 0.65rem;
  padding: 0.2rem 0.55rem;
  border-radius: 3px;
  background: rgba(95, 173, 86, 0.14);
  color: var(--accent);
  border: 1px solid rgba(95, 173, 86, 0.28);
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.card-date {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  color: var(--text-muted);
}
.scheme-card h2 {
  font-family: var(--font-mono);
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--text);
  line-height: 1.3;
}
.scheme-card p {
  font-size: 0.875rem;
  color: var(--text-dim);
  line-height: 1.55;
  flex: 1;
}
.card-arrow {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--accent);
  margin-top: 0.25rem;
}

/* ── Scheme Page Layout ────────────────────────────────────────────────── */
.scheme-header {
  margin-bottom: 2.5rem;
  padding-bottom: 1.5rem;
  border-bottom: 1px solid var(--border);
}
.scheme-breadcrumb {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-bottom: 1rem;
}
.scheme-breadcrumb a { color: var(--text-dim); }
.scheme-breadcrumb a:hover { color: var(--accent); text-decoration: none; }
.scheme-breadcrumb .sep { margin: 0 0.4rem; }
.scheme-title {
  font-family: var(--font-mono);
  font-size: clamp(1.4rem, 3vw, 2.2rem);
  font-weight: 700;
  color: var(--text);
  margin-bottom: 0.5rem;
}
.scheme-meta {
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
}
.scheme-date {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--text-muted);
}
.scheme-updated {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--text-dim);
}
.scheme-tag {
  font-family: var(--font-mono);
  font-size: 0.65rem;
  padding: 0.2rem 0.6rem;
  border-radius: 3px;
  background: rgba(95, 173, 86, 0.12);
  color: var(--accent);
  border: 1px solid rgba(95, 173, 86, 0.26);
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

/* ── Config Form ───────────────────────────────────────────────────────── */
.config-panel {
  background: var(--bg-card);
  border: 1px solid var(--border-bright);
  border-radius: var(--radius-lg);
  padding: 1.5rem 1.75rem;
  margin-bottom: 2.5rem;
}
.config-panel-header {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin-bottom: 1.25rem;
}
.config-panel-icon {
  width: 18px;
  height: 18px;
  color: var(--accent);
  flex-shrink: 0;
}
.config-panel-title {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.config-panel-hint {
  font-size: 0.78rem;
  color: var(--text-dim);
  margin-bottom: 1.25rem;
  line-height: 1.5;
}
.config-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 1rem;
}
.config-field {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}
.config-field label {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--text-dim);
  letter-spacing: 0.04em;
}
.config-field label .var-name {
  color: var(--accent2);
}
.required-tag {
  font-size: 0.62rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #f78154;
  margin-left: 0.45rem;
}
.input-wrap {
  display: flex;
  align-items: center;
  background: var(--bg-code);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  transition: border-color 0.15s;
}
.input-wrap:focus-within {
  border-color: var(--accent);
}
.input-prefix {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--text-muted);
  padding: 0.45rem 0.6rem;
  background: rgba(255,255,255,0.03);
  border-right: 1px solid var(--border);
  white-space: nowrap;
  user-select: none;
}
.input-suffix {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--text-muted);
  padding: 0.45rem 0.6rem;
  background: rgba(255,255,255,0.03);
  border-left: 1px solid var(--border);
  white-space: nowrap;
  user-select: none;
}
.config-field input {
  font-family: var(--font-mono);
  font-size: 0.82rem;
  color: var(--text);
  background: transparent;
  border: none;
  outline: none;
  padding: 0.45rem 0.6rem;
  width: 100%;
  min-width: 0;
}
.config-field input::placeholder { color: var(--text-muted); }

.input-wrap:has(.input-error) {
  border-color: #f78154;
}
.config-field input.input-error {
  color: #f78154;
}
.config-field input.input-error::placeholder {
  color: rgba(247, 129, 84, 0.55);
}

/* reset button */
.config-reset {
  margin-top: 1rem;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--text-dim);
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.35rem 0.9rem;
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s;
}
.config-reset:hover { border-color: var(--border-bright); color: var(--text); }

.scheme-intro {
  margin-bottom: 1.5rem;
}

/* live substitution highlight */
.sub-highlight {
  background: rgba(180, 67, 108, 0.36);
  color: #fff4f8;
  border-radius: 2px;
  padding: 0 1px;
  transition: background 0.25s, color 0.25s;
}

/* ── Pager Nav ─────────────────────────────────────────────────────────── */
.pager-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  background: var(--bg-card);
  border: 1px solid var(--border-bright);
  border-radius: var(--radius-lg);
  padding: 0.6rem 1rem;
  margin-top: 2rem;
  position: sticky;
  bottom: 1rem;
  z-index: 90;
}

.pager-btn {
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-dim);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  padding: 0;
  flex-shrink: 0;
  transition: color 0.15s, border-color 0.15s, background 0.15s;
}
.pager-btn svg { width: 14px; height: 14px; }
.pager-btn:hover:not(:disabled) {
  color: var(--accent);
  border-color: var(--accent);
  background: rgba(95, 173, 86, 0.1);
}
.pager-btn:disabled { opacity: 0.25; cursor: default; }

.pager-indicator {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.1rem;
  flex: 1;
  min-width: 0;
}
.pager-label {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: var(--text);
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}
.pager-count {
  font-family: var(--font-mono);
  font-size: 0.65rem;
  color: var(--text-muted);
  letter-spacing: 0.05em;
}

/* ── Prose Content ─────────────────────────────────────────────────────── */
.scheme-content { font-size: 0.95rem; }

.scheme-content h1,
.scheme-content h2,
.scheme-content h3 {
  font-family: var(--font-mono);
  color: var(--text);
  margin: 2.5rem 0 1rem;
  line-height: 1.3;
}
.scheme-content h1 { font-size: 1.5rem; border-bottom: 1px solid var(--border); padding-bottom: 0.5rem; }
.scheme-content h2 { font-size: 1.2rem; color: var(--accent); }
.scheme-content h3 { font-size: 1rem; color: var(--text-dim); }

.scheme-content p { margin: 0.75rem 0; color: var(--text-dim); line-height: 1.65; }
.scheme-content strong { color: var(--text); }
.scheme-content em { color: var(--accent2); font-style: italic; }

.scheme-content ul, .scheme-content ol {
  margin: 0.75rem 0 0.75rem 1.5rem;
  color: var(--text-dim);
}
.scheme-content li { margin: 0.3rem 0; }

.scheme-intro table,
.scheme-content table {
  width: 100%;
  border-collapse: collapse;
  margin: 1rem 0;
  border: 1px solid var(--border);
}

.scheme-intro th,
.scheme-intro td,
.scheme-content th,
.scheme-content td {
  padding: 0.5rem 0.85rem;
  border: 1px solid var(--border);
  text-align: left;
}

.scheme-intro th,
.scheme-content th {
  font-family: var(--font-mono);
  color: var(--text);
  background: rgba(255, 255, 255, 0.03);
}

/* inline code */
.scheme-content p code,
.scheme-content li code {
  font-family: var(--font-mono);
  font-size: 0.83em;
  background: var(--bg-code);
  color: var(--accent);
  border: 1px solid var(--border);
  border-radius: 3px;
  padding: 0.1em 0.4em;
}

/* ── Code Blocks ───────────────────────────────────────────────────────── */
.code-block-wrap {
  margin: 1.5rem 0;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  overflow-x: auto;
  background: var(--bg-code);
}

.code-block-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.5rem 1rem;
  background: var(--bg-code-hd);
  border-bottom: 1px solid var(--border);
  gap: 1rem;
}

.code-block-lang {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  color: var(--text-muted);
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.copy-btn {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  color: var(--text-dim);
  background: none;
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 0.25rem 0.65rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.35rem;
  transition: color 0.15s, border-color 0.15s, background 0.15s;
  flex-shrink: 0;
}
.copy-btn:hover {
  color: var(--accent);
  border-color: var(--accent);
  background: rgba(95, 173, 86, 0.1);
}
.copy-btn.copied {
  color: var(--accent3);
  border-color: var(--accent3);
  background: rgba(242, 193, 78, 0.14);
}
.copy-btn svg { width: 12px; height: 12px; }

/* The actual highlight container */
.code-block-wrap .highlight,
.scheme-content .highlight {
  margin: 0;
  background: transparent;
  overflow-x: auto;
}

.code-block-wrap pre,
.scheme-content pre {
  margin: 0;
  padding: 0;
  background: transparent;
  overflow-x: auto;
  white-space: pre;
  word-wrap: normal;
  font-size: 0.82rem;
  line-height: 1.6;
}

/* line number table layout from rouge */
.code-block-wrap .highlight table,
.scheme-content .highlight table {
  border-collapse: collapse;
  width: 100%;
}

.code-block-wrap .highlight td,
.scheme-content .highlight td {
  padding: 0;
  border: none;
}

/* line numbers column */
.highlight .gl,
.highlight .gutter,
.highlight pre.lineno {
  user-select: none;
  color: var(--ln-color);
  border-right: 1px solid var(--border);
  padding: 0.85rem 0.75rem 0.85rem 1rem;
  text-align: right;
  font-size: 0.75rem;
  min-width: 3rem;
  vertical-align: top;
  background: rgba(0,0,0,0.15);
}

/* code column */
.highlight .code,
.highlight pre:not(.lineno) {
  padding: 0.85rem 1.25rem;
  vertical-align: top;
}

/* Side gutter for line numbers */
.highlight.ln-has-gutter {
  display: flex;
  align-items: stretch;
}

.ln-gutter {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  padding: 0.85rem 0.75rem;
  min-width: 2.75rem;
  background: rgba(0,0,0,0.15);
  border-right: 1px solid var(--border);
  user-select: none;
  flex-shrink: 0;
}

.ln-gutter span {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--ln-color);
  line-height: 1.6;
  display: block;
}

.highlight.ln-has-gutter pre {
  padding: 0.85rem 1.25rem;
  flex: 1;
  min-width: 0;
}

/* scrollbar styling */
.code-block-wrap pre::-webkit-scrollbar { height: 5px; }
.code-block-wrap pre::-webkit-scrollbar-track { background: transparent; }
.code-block-wrap pre::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
.code-block-wrap pre::-webkit-scrollbar-thumb:hover { background: var(--border-bright); }

/* ── Rouge Token Colors (dark theme) ───────────────────────────────────── */
.highlight .c,  .highlight .c1, .highlight .cm { color: #5c6773; font-style: italic; }  /* comments */
.highlight .cp { color: #5c6773; }
.highlight .k,  .highlight .kd, .highlight .kn,
.highlight .kp, .highlight .kr, .highlight .kt { color: #cc99cd; font-weight: 600; }     /* keywords */
.highlight .nb { color: #79b8ff; }                                                         /* builtins */
.highlight .nf { color: #b3d9ff; }                                                         /* function names */
.highlight .na { color: #b3d9ff; }                                                         /* attr names */
.highlight .s,  .highlight .s1, .highlight .s2,
.highlight .sb, .highlight .sc, .highlight .sd,
.highlight .se, .highlight .sh, .highlight .si,
.highlight .sx { color: #9ecbff; }                                                         /* strings */
.highlight .sr { color: #dbedff; }                                                         /* regex */
.highlight .m,  .highlight .mf, .highlight .mi,
.highlight .mh, .highlight .mo { color: #f8c555; }                                        /* numbers */
.highlight .o,  .highlight .ow { color: #e1e4e8; }                                        /* operators */
.highlight .p  { color: #e1e4e8; }                                                         /* punctuation */
.highlight .nv, .highlight .vi { color: #ffab70; }                                        /* variables */
.highlight .no { color: #79b8ff; }                                                         /* constants */
.highlight .nc { color: #b3d9ff; }                                                         /* class names */
.highlight .nd { color: #79b8ff; }                                                         /* decorators */
.highlight .nt { color: #85e89d; }                                                         /* tags */
.highlight .gi { color: #1f6f43; background: #cdebd7; }                                     /* diff add */
.highlight .gd { color: #7f1d3a; background: #f6d1de; }                                     /* diff del */
.highlight .ge { font-style: italic; }
.highlight .gs { font-weight: 700; }
.highlight .err { color: #f97583; }

/* shell-specific */
.highlight .nv  { color: #ffab70; }  /* $VAR */

/* ── Footer ────────────────────────────────────────────────────────────── */
.site-footer {
  border-top: 1px solid var(--border);
  padding: 1.5rem 2rem;
  text-align: center;
}
.site-footer p {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--text-muted);
}

/* ── Responsive ────────────────────────────────────────────────────────── */
@media (max-width: 640px) {
  .page-wrap { padding: 2rem 1rem 4rem; }
  .config-grid { grid-template-columns: 1fr; }
  .site-header { padding: 0 1rem; }
}
