:root {
    --bg: #0d1117;
    --bg-card: #161b22;
    --bg-input: #1c2129;
    --border: #30363d;
    --text: #c9d1d9;
    --text-dim: #8b949e;
    --amber: #d4a017;
    --amber-dim: #b8860b;
    --red: #c44;
    --link: #d4a017;
    --link-hover: #f0c040;
    --bar: #d4a017;
    --bar-alt: #b8860b;
    --highlight: #2d1f00;
}

*, *::before, *::after { box-sizing: border-box; }

html {
    background: var(--bg);
    color: var(--text);
    font-family: "Cascadia Mono", "Fira Mono", "Consolas", "Liberation Mono", monospace;
    font-size: 14px;
    line-height: 1.55;
}

body {
    max-width: 960px;
    margin: 0 auto;
    padding: 0 16px 60px 16px;
}

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

/* --- NAV --- */
.nav {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 12px;
    padding: 12px 0;
    border-bottom: 1px solid var(--border);
    margin-bottom: 24px;
}
.nav-title {
    font-weight: bold;
    font-size: 1.1rem;
    color: var(--red);
    white-space: nowrap;
}
.nav-links { display: flex; gap: 14px; align-items: center; }
.nav-search {
    margin-left: auto;
    display: flex;
    gap: 6px;
}
.nav-search input[type="text"] {
    background: var(--bg-input);
    border: 1px solid var(--border);
    color: var(--text);
    padding: 5px 10px;
    font-family: inherit;
    font-size: 0.9rem;
    border-radius: 3px;
    width: 200px;
}
.nav-search button {
    background: var(--amber-dim);
    border: none;
    color: #000;
    padding: 5px 12px;
    font-family: inherit;
    font-size: 0.9rem;
    cursor: pointer;
    border-radius: 3px;
}
.nav-search button:hover { background: var(--amber); }

/* --- HEADINGS --- */
h1 { color: var(--red); font-size: 1.5rem; margin: 0 0 8px; }
h2 { color: var(--amber); font-size: 1.2rem; margin: 28px 0 12px; border-bottom: 1px solid var(--border); padding-bottom: 6px; }
h3 { color: var(--amber); font-size: 1rem; margin: 20px 0 8px; }

.subtitle { color: var(--text-dim); margin: 0 0 24px; font-size: 0.95rem; }

/* --- YEAR/MONTH GRID --- */
.grid-table { border-collapse: collapse; width: 100%; margin: 16px 0; }
.grid-table th {
    text-align: center;
    color: var(--amber);
    padding: 4px 2px;
    font-size: 0.8rem;
    font-weight: normal;
}
.grid-table td {
    text-align: center;
    padding: 0;
}
.grid-year {
    color: var(--amber);
    font-weight: bold;
    padding-right: 8px !important;
    text-align: right !important;
    white-space: nowrap;
    font-size: 0.95rem;
}
.grid-cell {
    display: block;
    padding: 6px 2px;
    font-size: 0.78rem;
    border: 1px solid var(--border);
    margin: 1px;
    border-radius: 2px;
    min-height: 34px;
    line-height: 1.3;
}
.grid-cell.has-msgs { cursor: pointer; }
.grid-cell.has-msgs:hover { border-color: var(--amber); }
.grid-cell.empty { color: var(--text-dim); opacity: 0.35; }

/* --- MESSAGE LIST / TOC --- */
.toc { list-style: none; padding: 0; margin: 0; }
.toc li {
    padding: 4px 0;
    border-bottom: 1px solid var(--border);
    font-size: 0.9rem;
}
.toc-subj { color: var(--link); }
.toc-meta { color: var(--text-dim); font-size: 0.82rem; }

/* --- MESSAGE --- */
.msg {
    border: 1px solid var(--border);
    border-radius: 4px;
    margin: 20px 0;
    background: var(--bg-card);
}
.msg-header {
    padding: 10px 14px;
    border-bottom: 1px solid var(--border);
    font-size: 0.88rem;
    line-height: 1.6;
}
.msg-label { color: var(--amber-dim); }
.msg-subject { color: var(--amber); font-weight: bold; font-size: 1rem; }
.msg-body {
    padding: 12px 14px;
    white-space: pre-wrap;
    word-wrap: break-word;
    overflow-wrap: break-word;
    font-size: 0.88rem;
    line-height: 1.5;
    color: var(--text);
    max-height: none;
}

/* --- STATS BARS --- */
.bar-row {
    display: flex;
    align-items: center;
    margin: 3px 0;
    font-size: 0.85rem;
}
.bar-label {
    min-width: 100px;
    text-align: right;
    padding-right: 10px;
    color: var(--text-dim);
    flex-shrink: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.bar-label-wide { min-width: 260px; }
.bar-fill {
    height: 18px;
    background: var(--bar);
    border-radius: 2px;
    min-width: 2px;
    transition: width 0.3s;
}
.bar-count {
    margin-left: 8px;
    color: var(--text-dim);
    font-size: 0.8rem;
    white-space: nowrap;
}

/* --- SEARCH RESULTS --- */
#search-area { margin: 20px 0; }
#search-box {
    width: 100%;
    background: var(--bg-input);
    border: 1px solid var(--border);
    color: var(--text);
    padding: 10px 14px;
    font-family: inherit;
    font-size: 1rem;
    border-radius: 4px;
    margin-bottom: 12px;
}
#search-box:focus { outline: none; border-color: var(--amber); }
#search-results { list-style: none; padding: 0; }
#search-results li {
    padding: 6px 0;
    border-bottom: 1px solid var(--border);
}
#search-results .sr-subj { color: var(--link); font-size: 0.95rem; }
#search-results .sr-meta { color: var(--text-dim); font-size: 0.82rem; }
#search-status { color: var(--text-dim); font-size: 0.9rem; margin: 8px 0; }
#show-more-btn {
    background: var(--amber-dim);
    color: #000;
    border: none;
    padding: 6px 18px;
    font-family: inherit;
    cursor: pointer;
    border-radius: 3px;
    margin: 12px 0;
}
#show-more-btn:hover { background: var(--amber); }

/* --- PREV/NEXT --- */
.pn { display: flex; justify-content: space-between; margin: 16px 0; font-size: 0.9rem; }
.pn a { color: var(--link); }

/* --- RESPONSIVE --- */
@media (max-width: 700px) {
    .nav { font-size: 0.85rem; }
    .nav-search input[type="text"] { width: 130px; }
    .grid-cell { font-size: 0.7rem; padding: 4px 1px; min-height: 28px; }
    .bar-label { min-width: 70px; font-size: 0.78rem; }
    .bar-label-wide { min-width: 150px; }
    .msg-body { font-size: 0.82rem; }
}
