:root {
  --bg-body: #ffffff;
  --bg-surface: #f8f9fa;
  --bg-elevated: #ffffff;
  --bg-hover: #f1f3f5;
  --fg-primary: #212529;
  --fg-secondary: #495057;
  --fg-muted: #6c757d;
  --border: #dee2e6;
  --accent: #0d6efd;
  --accent-hover: #0a58ca;
  --link: #0d6efd;
  --header-bg: #ffffff;
  --footer-bg: #f8f9fa;
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
  --radius: 6px;
  --radius-lg: 10px;
}

:root[data-theme="dark"] {
  --bg-body: #0d1117;
  --bg-surface: #161b22;
  --bg-elevated: #161b22;
  --bg-hover: #1f262d;
  --fg-primary: #c9d1d9;
  --fg-secondary: #b1bac4;
  --fg-muted: #8b949e;
  --border: #30363d;
  --accent: #58a6ff;
  --accent-hover: #79b8ff;
  --link: #58a6ff;
  --header-bg: #0d1117;
  --footer-bg: #010409;
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.5);
}

:root[data-theme="vt100"] {
  --bg-body: #000000;
  --bg-surface: #000000;
  --bg-elevated: #000000;
  --bg-hover: #002200;
  --fg-primary: #33ff33;
  --fg-secondary: #33ff33;
  --fg-muted: #1f8b1f;
  --border: #1f8b1f;
  --accent: #33ff33;
  --accent-hover: #66ff66;
  --link: #33ff33;
  --header-bg: #000000;
  --footer-bg: #000000;
  --font-sans: "VT323", "Courier New", Consolas, monospace;
  --font-mono: "VT323", "Courier New", Consolas, monospace;
  --shadow-sm: none;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }

body {
  background: var(--bg-body);
  color: var(--fg-primary);
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.5;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  transition: background-color 0.15s ease, color 0.15s ease;
}

:root[data-theme="vt100"] body {
  font-size: 18px;
  letter-spacing: 0.5px;
  text-shadow: 0 0 1px rgba(51, 255, 51, 0.4);
}

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

/* Site header */
.site-header {
  background: var(--header-bg);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
  box-shadow: var(--shadow-sm);
}
.site-header-inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0.875rem 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}
.brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  color: var(--fg-primary);
}
.brand:hover { text-decoration: none; }
.brand-logo { width: 36px; height: 36px; color: var(--accent); }
.brand-text { display: flex; flex-direction: column; line-height: 1.2; }
.brand-primary {
  font-weight: 600;
  font-size: 1.05rem;
  color: var(--fg-primary);
}
.brand-secondary {
  font-size: 0.8rem;
  color: var(--fg-muted);
  letter-spacing: 0.02em;
}
:root[data-theme="vt100"] .brand-primary,
:root[data-theme="vt100"] .brand-secondary { color: var(--fg-primary); }

/* Theme switcher */
.theme-switcher {
  display: inline-flex;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 2px;
  background: var(--bg-surface);
}
.theme-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  padding: 0;
  background: transparent;
  border: 0;
  border-radius: calc(var(--radius) - 2px);
  color: var(--fg-muted);
  cursor: pointer;
  transition: background-color 0.15s ease, color 0.15s ease;
}
.theme-button:hover { background: var(--bg-hover); color: var(--fg-primary); }
.theme-button[aria-pressed="true"] { background: var(--accent); color: #ffffff; }
:root[data-theme="vt100"] .theme-button[aria-pressed="true"] { color: #000000; }
.theme-button svg { width: 18px; height: 18px; }

/* Content area */
.content { flex: 1; padding: 2rem 1.5rem; }
.container { max-width: 1200px; margin: 0 auto; }

.breadcrumb { margin-bottom: 1rem; font-size: 0.875rem; }
.breadcrumb ol {
  list-style: none; padding: 0; margin: 0;
  display: flex; flex-wrap: wrap; align-items: center;
}
.breadcrumb li { display: inline-flex; align-items: center; }
.breadcrumb li + li::before {
  content: "/"; color: var(--fg-muted); margin: 0 0.5rem;
}

.page-title {
  font-size: 1.5rem;
  font-weight: 600;
  margin: 0 0 1.5rem 0;
  color: var(--fg-primary);
  word-break: break-all;
}
.page-title #currentPath {
  font-family: var(--font-mono);
  font-weight: 500;
  color: var(--fg-secondary);
}
:root[data-theme="vt100"] .page-title { text-transform: uppercase; }

/* Listing table — styles the output produced by mod_autoindex */
.listing {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}
.listing table {
  width: 100%;
  border-collapse: collapse;
  font-family: var(--font-sans);
}
.listing th {
  text-align: left;
  padding: 0.75rem 1rem;
  font-weight: 600;
  font-size: 0.8rem;
  color: var(--fg-secondary);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border);
}
.listing th a { color: inherit; }
.listing th a:hover { color: var(--accent); text-decoration: none; }

/* Apache emits a separator row containing only <hr>; hide it. */
.listing tr:has(> th[colspan] hr),
.listing tr:has(> td[colspan] hr) { display: none; }

.listing td {
  padding: 0.6rem 1rem;
  border-bottom: 1px solid var(--border);
  font-family: var(--font-mono);
  font-size: 0.875rem;
  color: var(--fg-secondary);
  vertical-align: middle;
}
.listing tr:last-child td { border-bottom: 0; }
.listing tbody tr:hover, .listing tr:hover { background: var(--bg-hover); }
.listing td a { color: var(--link); font-weight: 500; font-family: var(--font-sans); }
.listing td[align="right"] {
  text-align: right;
  color: var(--fg-muted);
  white-space: nowrap;
}

/* Suppress any stray Apache signature that escapes ServerSignature Off */
body > address, body > hr { display: none; }

/* Footer */
.site-footer {
  background: var(--footer-bg);
  border-top: 1px solid var(--border);
  padding: 1.5rem;
  margin-top: auto;
}
.site-footer-inner {
  max-width: 1200px;
  margin: 0 auto;
  text-align: center;
  font-size: 0.85rem;
  color: var(--fg-muted);
}
.site-footer-inner p { margin: 0.25rem 0; }

@media (max-width: 600px) {
  .site-header-inner { flex-direction: column; align-items: flex-start; gap: 0.75rem; }
  .content { padding: 1.25rem 1rem; }
}
