:root {
  color-scheme: light dark;
  --fg: #1a1a1a;
  --bg: #fafafa;
  --surface: #ffffff;
  --surface-hover: #f5f5f5;
  --selected: #fff3f3;
  --accent: #8b0000;
  --accent-fg: #ffffff;
  --muted: #666666;
  --border: #e2e2e2;
  --code-bg: #f0f0f0;
  --shadow: 0 8px 24px rgba(0, 0, 0, .12);
}

@media (prefers-color-scheme: dark) {
  :root {
    --fg: #e6e6e6;
    --bg: #161618;
    --surface: #1f1f23;
    --surface-hover: #27272c;
    --selected: #3a1d1d;
    --accent: #ff6b6b;
    --accent-fg: #1a1a1a;
    --muted: #9a9a9a;
    --border: #333338;
    --code-bg: #26262b;
    --shadow: 0 8px 24px rgba(0, 0, 0, .6);
  }
}

html[data-theme="light"] {
  --fg: #1a1a1a;
  --bg: #fafafa;
  --surface: #ffffff;
  --surface-hover: #f5f5f5;
  --selected: #fff3f3;
  --accent: #8b0000;
  --accent-fg: #ffffff;
  --muted: #666666;
  --border: #e2e2e2;
  --code-bg: #f0f0f0;
  --shadow: 0 8px 24px rgba(0, 0, 0, .12);
}

html[data-theme="dark"] {
  --fg: #e6e6e6;
  --bg: #161618;
  --surface: #1f1f23;
  --surface-hover: #27272c;
  --selected: #3a1d1d;
  --accent: #ff6b6b;
  --accent-fg: #1a1a1a;
  --muted: #9a9a9a;
  --border: #333338;
  --code-bg: #26262b;
  --shadow: 0 8px 24px rgba(0, 0, 0, .6);
}
* { box-sizing: border-box; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  margin: 0;
  color: var(--fg);
  background: var(--bg);
  line-height: 1.45;
}
body > header {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.75rem 1.25rem;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
}
body > header .brand {
  font-weight: 700;
  font-size: 1.15rem;
  color: var(--accent);
  text-decoration: none;
}
body > header .search { flex: 1; display: flex; gap: .5rem; position: relative; }
body > header .search-box { flex: 1; position: relative; }
body > header input[type=search] {
  width: 100%;
  padding: .5rem .75rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 1rem;
}
.live-dropdown {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  max-height: 60vh;
  overflow-y: auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: var(--shadow);
  z-index: 20;
}
.live-dropdown[hidden] { display: none; }
.live-dropdown ul { list-style: none; margin: 0; padding: .25rem 0; }
.live-dropdown li {
  padding: .5rem .75rem;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
}
.live-dropdown li:last-child { border-bottom: 0; }
.live-dropdown li.sel { background: var(--selected); }
.live-dropdown li a { text-decoration: none; color: var(--fg); display: block; }
.live-dropdown strong { color: var(--accent); }
.live-dropdown .ver { color: var(--muted); margin-left: .35rem; font-family: ui-monospace, monospace; font-size: .9rem; }
.live-dropdown .origin { color: var(--muted); margin-left: .75rem; font-family: ui-monospace, monospace; font-size: .85rem; }
.live-dropdown .comment { margin: .1rem 0 0; color: var(--muted); font-size: .9rem; }
.live-dropdown .empty { padding: .75rem; color: var(--muted); font-style: italic; margin: 0; }
body > header button {
  padding: .5rem 1rem;
  background: var(--accent);
  color: var(--accent-fg);
  border: 0;
  border-radius: 6px;
  cursor: pointer;
}
.theme-toggle {
  background: transparent !important;
  color: var(--fg) !important;
  border: 1px solid var(--border) !important;
  font-size: 1.1rem;
  line-height: 1;
  padding: .4rem .6rem !important;
  cursor: pointer;
}
.theme-toggle:hover { border-color: var(--accent) !important; color: var(--accent) !important; }
main { max-width: 1400px; margin: 1.5rem auto; padding: 0 1.25rem; }
footer {
  max-width: 1400px;
  margin: 2rem auto 1rem;
  padding: 0 1.25rem;
  color: var(--muted);
  font-size: .9rem;
  display: flex;
  justify-content: space-between;
}
.hero h1 { font-size: 2rem; margin-bottom: .25rem; }
.hero p { color: var(--muted); }
.hits { list-style: none; padding: 0; }
.hits li {
  padding: .75rem 0;
  border-bottom: 1px solid var(--border);
}
.hits a { text-decoration: none; color: var(--fg); }
.hits strong { font-size: 1.05rem; color: var(--accent); }
.hits .ver { color: var(--muted); margin-left: .35rem; font-family: ui-monospace, monospace; }
.hits .origin { color: var(--muted); margin-left: .75rem; font-family: ui-monospace, monospace; font-size: .9rem; }
.hits .comment { margin: .15rem 0 0; color: var(--muted); }
.hits .when { font-family: ui-monospace, monospace; font-size: .85rem; }
.recent { margin-top: 2rem; }
.recent h2 { font-size: 1.1rem; color: var(--muted); margin-bottom: .5rem; }
.empty { color: var(--muted); font-style: italic; }
.meta-line { color: var(--muted); font-size: .9rem; }
.pagination {
  display: flex;
  gap: 1rem;
  align-items: center;
  justify-content: center;
  margin: 1.5rem 0;
}
.pagination .page {
  padding: .4rem .9rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  text-decoration: none;
  color: var(--fg);
  background: var(--surface);
}
.pagination .page:hover { border-color: var(--accent); color: var(--accent); }
.pagination .page-info { color: var(--muted); font-family: ui-monospace, monospace; }
.port > header {
  margin-bottom: 1.5rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--border);
}
.port > header h1 {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: .5rem;
  margin: 0 0 .35rem;
  line-height: 1.2;
}
.port > header h1 small {
  color: var(--muted);
  font-weight: 400;
  font-size: 1rem;
  font-family: ui-monospace, monospace;
}
.port > header .origin {
  margin: 0 0 .35rem;
  font-family: ui-monospace, monospace;
  color: var(--muted);
  font-size: .9rem;
}
.port > header .comment {
  margin: 0;
  font-size: 1.05rem;
}
.meta dl {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: .25rem 1rem;
  margin: 1rem 0;
}
.meta dt { color: var(--muted); }
.descr pre {
  white-space: pre-wrap;
  background: var(--code-bg);
  padding: .75rem;
  border-radius: 6px;
  font-family: ui-monospace, monospace;
  font-size: .9rem;
}
.deps ul { list-style: none; padding: 0; }
.deps li {
  padding: .35rem 0;
  border-bottom: 1px solid var(--border);
  display: flex;
  gap: .75rem;
  align-items: baseline;
}
.deps .kind {
  font-size: .8rem;
  color: #fff;
  background: var(--muted);
  padding: .05rem .4rem;
  border-radius: 3px;
  min-width: 3.5rem;
  text-align: center;
}

.history-note { color: var(--muted); font-size: .9rem; margin: 0 0 .75rem; }
.commits-table {
  width: 100%;
  border-collapse: collapse;
  font-size: .9rem;
}
.commits-table thead th {
  text-align: left;
  color: var(--muted);
  font-weight: 600;
  border-bottom: 2px solid var(--border);
  padding: .5rem .75rem;
}
.commits-table tbody td {
  border-bottom: 1px solid var(--border);
  padding: .6rem .75rem;
  vertical-align: top;
}
.commits-table tbody tr:hover { background: var(--surface-hover); }
.col-commit {
  white-space: nowrap;
  width: 1%;
  font-family: ui-monospace, monospace;
  font-size: .8rem;
  line-height: 1.5;
}
.col-commit .pv {
  font-weight: 600;
  color: var(--fg);
  font-size: .95rem;
}
.col-commit time { display: block; color: var(--muted); }
.col-commit .hash {
  display: inline-block;
  color: var(--accent);
  text-decoration: none;
  margin-top: .15rem;
}
.col-commit .hash:hover { text-decoration: underline; }
.col-commit .files {
  display: block;
  color: var(--muted);
  font-size: .75rem;
  text-decoration: none;
  margin-top: .15rem;
}
.col-commit .files:hover { color: var(--accent); text-decoration: underline; }
.col-author {
  white-space: nowrap;
  width: 1%;
  color: var(--fg);
}
.col-msg .subject { font-weight: 500; }
.col-msg .body {
  white-space: pre-wrap;
  margin: .35rem 0 0;
  padding: .5rem .65rem;
  background: var(--code-bg);
  border-radius: 4px;
  font-family: ui-monospace, monospace;
  font-size: .8rem;
  color: var(--fg);
}
