@font-face {
    font-family: 'JetBrains Mono';
    src: url('/static/fonts/JetBrainsMono-Regular.woff2') format('woff2');
    font-weight: 400;
    font-style: normal;
    font-display: swap;
}
@font-face {
    font-family: 'JetBrains Mono';
    src: url('/static/fonts/JetBrainsMono-Medium.woff2') format('woff2');
    font-weight: 500;
    font-style: normal;
    font-display: swap;
}
@font-face {
    font-family: 'JetBrains Mono';
    src: url('/static/fonts/JetBrainsMono-Bold.woff2') format('woff2');
    font-weight: 700;
    font-style: normal;
    font-display: swap;
}
@font-face {
    font-family: 'JetBrains Mono';
    src: url('/static/fonts/JetBrainsMono-Italic.woff2') format('woff2');
    font-weight: 400;
    font-style: italic;
    font-display: swap;
}

:root {
    --bg: #2d2a2e;
    --bg-raised: #363236;
    --bg-subtle: #403e41;
    --border: #4a474b;
    --text: #fcfcfa;
    --text-muted: #939293;
    --text-faint: #5b595c;
    --yellow: #ffd866;
    --pink: #ff6188;
    --green: #a9dc76;
    --cyan: #78dce8;
    --purple: #ab9df2;
    --orange: #fc9867;
    --font-mono: 'JetBrains Mono', ui-monospace, monospace;

    --status-done: var(--green);
    --status-active: var(--yellow);
    --status-backlog: var(--cyan);
    --status-inbox: var(--orange);
    --status-paused: var(--purple);
    --status-abandoned: var(--text-faint);
    --status-reference: var(--text-muted);
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    background: var(--bg);
    color: var(--text);
    font-family: var(--font-mono);
    font-size: 15px;
    line-height: 1.5;
}

a { color: var(--cyan); text-decoration: none; }
a:hover { color: var(--text); transition: color 0.15s; }

button, input, select, textarea {
    font-family: var(--font-mono);
    font-size: 14px;
    background: var(--bg-subtle);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: 3px;
    padding: 0.4em 0.6em;
}

button {
    cursor: pointer;
    transition: background-color 0.15s, border-color 0.15s;
}
button:hover { background: var(--bg-raised); border-color: var(--text-muted); }
button.primary { background: var(--yellow); color: var(--bg); border-color: var(--yellow); }
button.primary:hover { background: var(--text); }

.container {
    max-width: 1100px;
    margin: 0 auto;
    padding: 1.5rem;
}

header.topbar {
    display: flex;
    align-items: center;
    gap: 1.5rem;
    padding: 0.75rem 1.5rem;
    border-bottom: 1px solid var(--border);
    background: var(--bg-raised);
}

header.topbar .brand {
    font-weight: 700;
    color: var(--yellow);
}

header.topbar nav {
    display: flex;
    gap: 1rem;
    flex: 1;
}

header.topbar nav a {
    color: var(--text-muted);
    padding: 0.25rem 0;
    border-bottom: 2px solid transparent;
}

header.topbar nav a.active,
header.topbar nav a:hover {
    color: var(--text);
    border-bottom-color: var(--cyan);
}

#search-input {
    width: 220px;
}

.status-dot {
    display: inline-block;
    width: 0.6em;
    height: 0.6em;
    border-radius: 50%;
    margin-right: 0.4em;
}
.status-dot.done { background: var(--status-done); }
.status-dot.active { background: var(--status-active); }
.status-dot.backlog { background: var(--status-backlog); }
.status-dot.inbox { background: var(--status-inbox); }
.status-dot.paused { background: var(--status-paused); }
.status-dot.abandoned { background: var(--status-abandoned); }
.status-dot.reference { background: var(--status-reference); }

table.dense {
    width: 100%;
    border-collapse: collapse;
    font-size: 13.5px;
}
table.dense th {
    text-align: left;
    color: var(--text-muted);
    font-weight: 500;
    padding: 0.3rem 0.6rem;
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    background: var(--bg);
}
table.dense td {
    padding: 0.28rem 0.6rem;
    border-bottom: 1px solid var(--bg-subtle);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
table.dense tr[data-item-row] { cursor: pointer; }
table.dense tr[data-item-row]:hover,
table.dense tr[data-item-row].selected {
    background: var(--bg-subtle);
}
table.dense tr.selected { outline: 1px solid var(--cyan); outline-offset: -1px; }

.card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 1rem;
}
.card {
    background: var(--bg-raised);
    border: 1px solid var(--border);
    border-radius: 3px;
    padding: 0.6rem;
    transition: border-color 0.15s;
}
.card:hover { border-color: var(--cyan); }
.card .cover-placeholder {
    width: 100%;
    aspect-ratio: 2 / 3;
    background: var(--bg-subtle);
    border-radius: 3px;
    margin-bottom: 0.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-faint);
    font-size: 12px;
}
.card .card-title { font-weight: 500; }
.card .card-meta { color: var(--text-muted); font-size: 12px; }

.section-title {
    color: var(--text-muted);
    text-transform: uppercase;
    font-size: 12px;
    letter-spacing: 0.05em;
    margin: 1.5rem 0 0.5rem;
}

.warning {
    color: var(--orange);
    border: 1px solid var(--orange);
    padding: 0.5rem 0.75rem;
    border-radius: 3px;
    margin: 0.5rem 0;
}

.stale-row {
    border: 1px solid var(--purple);
    border-radius: 3px;
    padding: 0.5rem 0.75rem;
    margin-bottom: 0.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}
.stale-actions { display: flex; gap: 0.4rem; }
.stale-actions button { font-size: 12px; padding: 0.25em 0.5em; }

form.item-form {
    display: flex;
    flex-direction: column;
    gap: 0.85rem;
    max-width: 560px;
}
form.item-form label {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    font-size: 13px;
    color: var(--text-muted);
}
form.item-form .row {
    display: flex;
    gap: 0.85rem;
}
form.item-form .row > label { flex: 1; }

.pill {
    display: inline-block;
    background: var(--bg-subtle);
    border: 1px solid var(--border);
    border-radius: 3px;
    padding: 0.1em 0.5em;
    font-size: 12px;
    margin-right: 0.3em;
}

.timeline { list-style: none; padding: 0; margin: 0; }
.timeline li {
    border-left: 2px solid var(--border);
    padding: 0.3rem 0 0.3rem 0.75rem;
    margin-bottom: 0.4rem;
}
.timeline li .ts { color: var(--text-faint); font-size: 12px; }

.help-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 50;
}
.help-overlay .panel {
    background: var(--bg-raised);
    border: 1px solid var(--border);
    border-radius: 3px;
    padding: 1.5rem;
    min-width: 280px;
}
.help-overlay dl {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 0.3rem 1rem;
    margin: 0;
}
.help-overlay dt { color: var(--yellow); }
.help-overlay dd { margin: 0; color: var(--text-muted); }

.progress-bar {
    background: var(--bg-subtle);
    border-radius: 3px;
    height: 6px;
    overflow: hidden;
    width: 100px;
}
.progress-bar .fill { height: 100%; background: var(--green); }

@media (max-width: 700px) {
    header.topbar { flex-wrap: wrap; gap: 0.75rem; }
    #search-input { width: 100%; order: 3; }
    table.dense { font-size: 12px; }
    table.dense th:nth-child(4),
    table.dense td:nth-child(4),
    table.dense th:nth-child(5),
    table.dense td:nth-child(5) {
        display: none;
    }
}

@media (max-width: 380px) {
    .container { padding: 0.75rem; }
    header.topbar { padding: 0.5rem 0.75rem; }
}
