/* Mobile first. Colors are tokens so light and dark share every rule. */

:root {
    --bg: #f6f7f9;
    --surface: #ffffff;
    --text: #1d2330;
    --muted: #5d6678;
    --border: #dde1e8;
    --accent: #2f5bd3;
    --accent-text: #ffffff;
    --notice-bg: #e6f4ea;
    --notice-text: #1e5b32;
    --error-bg: #fdecea;
    --error-text: #8a1c14;
    --radius: 10px;
    --space: 1rem;
    color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg: #12151b;
        --surface: #1b1f27;
        --text: #e6e9ef;
        --muted: #9aa3b5;
        --border: #2c323d;
        --accent: #7c9cff;
        --accent-text: #0d1118;
        --notice-bg: #183823;
        --notice-text: #b9e6c6;
        --error-bg: #42201d;
        --error-text: #ffc9c2;
    }
}

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

html { -webkit-text-size-adjust: 100%; }

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

a { color: var(--accent); }
h1 { font-size: 1.5rem; margin: 0 0 .25rem; }
h2 { font-size: 1.1rem; margin: 1.5rem 0 .5rem; }
h2.inline { display: inline; margin: 0; }
section { margin-top: 1.5rem; }
code, .mono { font-family: ui-monospace, "Cascadia Code", Consolas, monospace; }

.muted { color: var(--muted); font-size: .9rem; }
.empty { padding: 2rem 0; color: var(--muted); }
.count { color: var(--muted); font-weight: normal; font-size: 1rem; }

/* Layout */

.topbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: .5rem 1rem;
    padding: .75rem var(--space);
    background: var(--surface);
    border-bottom: 1px solid var(--border);
}

.brand { font-weight: 700; color: var(--text); text-decoration: none; }

.nav {
    order: 3;
    display: flex;
    gap: .25rem;
    width: 100%;
    overflow-x: auto;
}

.nav a {
    padding: .35rem .6rem;
    border-radius: var(--radius);
    color: var(--muted);
    text-decoration: none;
    white-space: nowrap;
}

.nav a.active { background: var(--bg); color: var(--text); font-weight: 600; }
.capture { margin-left: auto; }
.logout { margin: 0; }

.page { max-width: 60rem; margin: 0 auto; padding: var(--space); }
.page.narrow { max-width: 28rem; padding-top: 15vh; }

@media (min-width: 48rem) {
    .nav { order: 0; width: auto; }
}

/* Controls */

input, select, textarea, button, .button {
    font: inherit;
    color: inherit;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    padding: .5rem .75rem;
    min-height: 2.5rem;
}

textarea { width: 100%; resize: vertical; }
input:not([type=checkbox]) { min-width: 0; }

button, .button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    text-decoration: none;
    white-space: nowrap;
}

button:hover, .button:hover { border-color: var(--accent); }

/* The display rules above would otherwise show elements app.js keeps hidden. */
[hidden] { display: none !important; }

.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }

button.link {
    border: 0;
    background: none;
    color: var(--muted);
    padding: 0;
    min-height: auto;
    font-size: .9rem;
}

.stack { display: flex; flex-direction: column; gap: .75rem; }
.stack label { display: flex; flex-direction: column; gap: .25rem; font-size: .9rem; color: var(--muted); }
.stack label > input, .stack label > select, .stack label > textarea { color: var(--text); font-size: 1rem; }
.stack > button { align-self: flex-start; }
.field-row { display: flex; flex-wrap: wrap; gap: .75rem; }
.field-row > * { flex: 1 1 10rem; }
.field-row > button { flex: 0 0 auto; }
.grow { flex-grow: 3; }

.filters { display: flex; flex-wrap: wrap; gap: .5rem; margin: 1rem 0; }
.filters input[type=search] { flex: 1 1 12rem; }
.check { display: inline-flex; align-items: center; gap: .35rem; font-size: .9rem; color: var(--muted); }

.title-row { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .5rem; }
.actions-row { display: flex; flex-wrap: wrap; gap: .5rem; align-items: flex-start; }
.actions-row form { display: flex; gap: .5rem; margin: 0; }

.panel { margin: 1rem 0; padding: .75rem 1rem; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }
.panel > summary { cursor: pointer; font-weight: 600; }
.panel > form { margin-top: .75rem; }

/* Messages */

.flash { padding: .75rem 1rem; border-radius: var(--radius); margin: 0 0 1rem; }
.flash.notice { background: var(--notice-bg); color: var(--notice-text); }
.flash.error { background: var(--error-bg); color: var(--error-text); }

/* Lists */

.cards, .rows, .events { list-style: none; margin: 0; padding: 0; }

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: var(--space);
    margin-bottom: .75rem;
}

.card-title, .row-title { font-weight: 600; color: var(--text); text-decoration: none; }
.card-title { font-size: 1.1rem; }
.card-title:hover, .row-title:hover { color: var(--accent); }

.card-meta { display: flex; flex-wrap: wrap; align-items: center; gap: .25rem .75rem; color: var(--muted); font-size: .9rem; margin-top: .25rem; }
.card-meta a { color: inherit; }
.card-meta.lead { margin: .5rem 0 1rem; }
.card-text { margin: .5rem 0 0; }

.card-actions { display: flex; flex-wrap: wrap; gap: .5rem; margin-top: .75rem; align-items: flex-start; }
.card-actions form { margin: 0; }
.card-actions button, .card-actions .button, .card-actions summary { min-width: 6.5rem; }

.row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: .75rem;
    padding: .75rem 0;
    border-bottom: 1px solid var(--border);
}

.row-badges { display: flex; flex-wrap: wrap; gap: .35rem; justify-content: flex-end; align-items: center; }
.row-badges form { margin: 0; }
.row-badges a { text-decoration: none; }

.pager { text-align: center; margin: 1.5rem 0; }

/* Discard menu: two taps, no script */

.discard { position: relative; }
.discard > summary { list-style: none; }
.discard > summary::-webkit-details-marker { display: none; }
.discard[open] > summary { border-color: var(--accent); }

.discard-reasons {
    display: flex;
    flex-direction: column;
    gap: .35rem;
    margin-top: .5rem;
    min-width: 15rem;
}

.discard-reasons form { margin: 0; }
.discard-reasons button { width: 100%; justify-content: flex-start; }
.discard-reasons .inline { display: flex; gap: .35rem; }
.discard-reasons .inline input { flex: 1; }
.discard-reasons .inline button { width: auto; }

/* Badges */

.badge {
    display: inline-block;
    padding: .1rem .5rem;
    border-radius: 999px;
    font-size: .8rem;
    font-weight: 600;
    background: var(--bg);
    border: 1px solid var(--border);
    color: var(--muted);
    white-space: nowrap;
}

.fit-5, .fit-4 { color: #1e7a3c; border-color: currentColor; }
.fit-3 { color: #8a6d00; border-color: currentColor; }
.fit-2, .fit-1 { color: #a3341f; border-color: currentColor; }
.unrated { font-style: italic; }

.status-saved, .status-preparing, .rating-target { color: var(--accent); border-color: currentColor; }
.status-applied, .status-interviewing, .status-offer, .status-accepted { color: #1e7a3c; border-color: currentColor; }
.status-rejected, .status-withdrawn, .status-discarded, .rating-excluded { color: #a3341f; border-color: currentColor; }
.status-noresponse, .rating-watch { color: #8a6d00; border-color: currentColor; }
.ad-closed, .deadline-passed { color: #a3341f; border-color: currentColor; }
.deadline-soon { color: #8a6d00; border-color: currentColor; background: #fff4cc; }

@media (prefers-color-scheme: dark) {
    .fit-5, .fit-4, .status-applied, .status-interviewing, .status-offer, .status-accepted { color: #7fd69b; }
    .fit-3, .status-noresponse, .rating-watch { color: #e3c25b; }
    .fit-2, .fit-1, .status-rejected, .status-withdrawn, .status-discarded, .rating-excluded { color: #ff9a87; }
    .ad-closed, .deadline-passed { color: #ff9a87; }
    .deadline-soon { color: #e3c25b; background: #3a3214; }
}

/* Content */

.events li { padding: .6rem 0; border-bottom: 1px solid var(--border); }
.event-head { display: flex; flex-wrap: wrap; justify-content: space-between; gap: .25rem 1rem; }
.event-text { margin: .25rem 0 0; white-space: pre-wrap; }

.snapshot {
    white-space: pre-wrap;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: var(--space);
    margin-top: .5rem;
    font-size: .95rem;
}

.markdown {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 0 var(--space);
}

.facts { display: grid; grid-template-columns: max-content 1fr; gap: .25rem 1rem; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; }

ul.plain { list-style: none; padding: 0; margin: 0 0 0.75rem; }
ul.plain li { overflow-wrap: anywhere; }
