/* Dark theme in the Mantine idiom (the UI library Civitai is built on):
   charcoal-blue surfaces, a blue accent, soft borders, generous radii. */

:root {
    color-scheme: dark;

    --bg: #1a1b1e;
    --bg-deep: #141517;
    --surface: #25262b;
    --surface-2: #2c2e33;
    --surface-3: #373a40;
    --border: #373a40;
    --border-soft: #2c2e33;

    --text: #f1f3f5;
    --text-dim: #c1c2c5;
    --muted: #909296;
    --faint: #5c5f66;

    --accent: #228be6;
    --accent-hover: #1c7ed6;
    --accent-dim: #1971c2;
    --accent-fade: rgba(34, 139, 230, 0.14);
    --accent-edge: rgba(34, 139, 230, 0.35);

    --danger: #fa5252;
    --danger-fade: rgba(250, 82, 82, 0.12);
    --ok: #40c057;
    --ok-fade: rgba(64, 192, 87, 0.12);
    --warn: #fab005;
    --warn-fade: rgba(250, 176, 5, 0.12);

    --radius: 8px;
    --radius-lg: 12px;
    --mono: ui-monospace, "Cascadia Code", "JetBrains Mono", Consolas, monospace;
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.5), 0 8px 24px rgba(0, 0, 0, 0.22);
}

* { box-sizing: border-box; }

html { background: var(--bg); }

body {
    margin: 0;
    background: var(--bg);
    color: var(--text-dim);
    font: 15px/1.6 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
          "Helvetica Neue", Arial, sans-serif;
    -webkit-font-smoothing: antialiased;
}

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

h1, h2, h3 { color: var(--text); font-weight: 650; letter-spacing: -0.015em; }

.wrap { max-width: 960px; margin: 0 auto; padding: 0 16px 72px; }

/* ---------- header ---------- */
header.site {
    background: var(--bg-deep);
    border-bottom: 1px solid var(--border-soft);
    margin-bottom: 28px;
    position: sticky;
    top: 0;
    z-index: 20;
}
header.site .wrap {
    display: flex; align-items: center; gap: 20px;
    padding-top: 12px; padding-bottom: 12px;
}
.brand {
    font-weight: 750; font-size: 1.05rem; color: var(--text);
    letter-spacing: -0.02em;
}
.brand:hover { color: var(--text); text-decoration: none; }
header.site nav { display: flex; gap: 6px; margin-left: auto; align-items: center; }
header.site nav a {
    color: var(--muted); font-size: 0.9rem; font-weight: 500;
    padding: 6px 12px; border-radius: 999px;
}
header.site nav a:hover {
    color: var(--text); background: var(--surface-2); text-decoration: none;
}
header.site nav a.active { color: var(--accent); background: var(--accent-fade); }

/* ---------- buttons ---------- */
.btn {
    display: inline-block; padding: 8px 16px; border-radius: var(--radius);
    border: 1px solid var(--surface-3); background: var(--surface-2);
    color: var(--text); font: inherit; font-size: 0.9rem; font-weight: 500;
    cursor: pointer; transition: background 120ms ease, border-color 120ms ease;
}
.btn:hover {
    background: var(--surface-3); border-color: var(--faint);
    color: var(--text); text-decoration: none;
}
.btn-primary {
    background: var(--accent); border-color: var(--accent); color: #fff;
}
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); color: #fff; }
.btn-danger { color: var(--danger); border-color: transparent; background: var(--danger-fade); }
.btn-danger:hover { background: rgba(250, 82, 82, 0.2); border-color: var(--danger); color: var(--danger); }
.btn-sm { padding: 5px 11px; font-size: 0.83rem; }
.btn-link {
    background: none; border: none; color: var(--muted);
    padding: 0; cursor: pointer; font: inherit; font-size: 0.85rem;
}
.btn-link:hover { color: var(--accent); text-decoration: underline; }

/* ---------- forms ---------- */
label { display: block; font-size: 0.85rem; color: var(--text-dim); font-weight: 500; margin-bottom: 6px; }
input[type=text], input[type=password], input[type=datetime-local],
input[type=date], select, textarea {
    width: 100%; padding: 10px 12px; font: inherit; font-size: 0.92rem;
    background: var(--bg-deep); color: var(--text);
    border: 1px solid var(--surface-3); border-radius: var(--radius);
    transition: border-color 120ms ease, box-shadow 120ms ease;
}
input::placeholder, textarea::placeholder { color: var(--faint); }
input:focus, textarea:focus, select:focus {
    outline: none; border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-fade);
}
textarea { min-height: 190px; resize: vertical; font-family: inherit; line-height: 1.65; }
.field { margin-bottom: 18px; }
.field-row { display: flex; gap: 14px; flex-wrap: wrap; }
.field-row > .field { flex: 1 1 220px; }
.check { display: flex; align-items: flex-start; gap: 10px; margin-bottom: 14px; }
.check input { margin-top: 4px; accent-color: var(--accent); width: 16px; height: 16px; }
.check label { margin: 0; color: var(--text); font-size: 0.92rem; }
.check .hint { display: block; color: var(--muted); font-size: 0.84rem; font-weight: 400; margin-top: 2px; }

/* ---------- cards ---------- */
.card {
    background: var(--surface); border: 1px solid var(--border-soft);
    border-radius: var(--radius-lg); padding: 22px; margin-bottom: 16px;
}
.card-tight { padding: 14px 18px; }

/* ---------- flash messages ---------- */
.flash {
    padding: 11px 16px; border-radius: var(--radius); margin-bottom: 12px;
    font-size: 0.9rem; border: 1px solid var(--border-soft);
    background: var(--surface); color: var(--text-dim);
    border-left: 3px solid var(--faint);
}
.flash-error   { background: var(--danger-fade); border-color: transparent; border-left-color: var(--danger); color: #ffc9c9; }
.flash-success { background: var(--ok-fade);     border-color: transparent; border-left-color: var(--ok);     color: #b2f2bb; }
.flash-warning { background: var(--warn-fade);   border-color: transparent; border-left-color: var(--warn);   color: #ffe066; }
.flash-info    { background: var(--accent-fade); border-color: transparent; border-left-color: var(--accent); color: #a5d8ff; }

/* ---------- thread list ---------- */
.thread-row {
    display: block; color: inherit;
    background: var(--surface); border: 1px solid var(--border-soft);
    border-radius: var(--radius-lg); padding: 16px 20px; margin-bottom: 10px;
    transition: background 120ms ease, border-color 120ms ease;
}
.thread-row:hover {
    background: var(--surface-2); border-color: var(--accent-edge);
    text-decoration: none;
}
.thread-row h2 { margin: 0 0 6px; font-size: 1.02rem; color: var(--text); }
.thread-row .preview { color: var(--muted); font-size: 0.89rem; margin: 0 0 9px; }
.meta { color: var(--muted); font-size: 0.83rem; }
.tag {
    display: inline-block; font-size: 0.7rem; font-weight: 600;
    text-transform: uppercase; letter-spacing: 0.04em;
    padding: 3px 9px; border-radius: 999px;
    background: var(--accent-fade); color: #74c0fc;
    margin-right: 7px; vertical-align: 2px;
}

/* ---------- posts ---------- */
.post {
    background: var(--surface); border: 1px solid var(--border-soft);
    border-radius: var(--radius-lg); margin-bottom: 14px; overflow: hidden;
}
.post:target { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-fade); }
.post-head {
    display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap;
    padding: 12px 20px; background: var(--bg-deep);
    border-bottom: 1px solid var(--border-soft); font-size: 0.85rem;
}
.post-head .who { font-weight: 650; font-size: 0.93rem; color: var(--text); }
.post-head .spacer { margin-left: auto; }
.post-head a.meta:hover { color: var(--accent); }
.post-body { padding: 6px 20px 16px; overflow-wrap: break-word; color: var(--text-dim); }
.post-body h1, .post-body h2, .post-body h3 { font-size: 1.1rem; margin: 1.1em 0 0.5em; }
.post-body pre {
    background: var(--bg-deep); padding: 13px 15px; border-radius: var(--radius);
    border: 1px solid var(--border-soft);
    overflow-x: auto; font-family: var(--mono); font-size: 0.86rem;
}
.post-body code {
    font-family: var(--mono); font-size: 0.88em;
    background: var(--surface-3); padding: 1px 5px; border-radius: 4px;
}
.post-body pre code { background: none; padding: 0; font-size: inherit; }
.post-body blockquote {
    margin: 0 0 1em; padding: 2px 0 2px 15px;
    border-left: 3px solid var(--accent-dim); color: var(--muted);
}
.post-body img { max-width: 100%; height: auto; border-radius: var(--radius); }
.post-body table { border-collapse: collapse; width: 100%; font-size: 0.9rem; }
.post-body th, .post-body td { border: 1px solid var(--border); padding: 7px 11px; }
.post-body th { background: var(--surface-2); color: var(--text); }
.post-body a { text-decoration: underline; text-underline-offset: 2px; }

/* ---------- calendar ---------- */
.cal-head { display: flex; align-items: center; gap: 10px; margin-bottom: 18px; flex-wrap: wrap; }
.cal-head h1 { margin: 0; font-size: 1.35rem; }
.cal-grid {
    display: grid; grid-template-columns: repeat(7, 1fr);
    gap: 1px; background: var(--border-soft);
    border: 1px solid var(--border-soft);
    border-radius: var(--radius-lg); overflow: hidden;
}
.cal-dow {
    background: var(--bg-deep); padding: 8px;
    font-size: 0.72rem; font-weight: 600; text-transform: uppercase;
    letter-spacing: 0.06em; color: var(--muted); text-align: center;
}
.cal-day { background: var(--surface); min-height: 100px; padding: 7px 8px; }
.cal-day.outside { background: var(--bg); }
.cal-day.outside .daynum { color: var(--faint); }
.cal-day.today { background: var(--accent-fade); }
.cal-day.today .daynum {
    background: var(--accent); color: #fff; font-weight: 600;
    border-radius: 999px; min-width: 22px; height: 22px;
    display: inline-flex; align-items: center; justify-content: center;
}
.daynum { font-size: 0.79rem; color: var(--muted); display: inline-block; margin-bottom: 5px; }
.cal-day a.add {
    float: right; color: var(--muted); font-size: 1rem;
    opacity: 0; line-height: 1; padding: 0 3px; border-radius: 4px;
}
.cal-day:hover a.add { opacity: 1; }
.cal-day a.add:hover { color: var(--accent); background: var(--surface-3); text-decoration: none; }
.chip {
    display: block; font-size: 0.75rem; padding: 3px 7px; border-radius: 5px;
    background: var(--surface-3); color: var(--text-dim);
    margin-bottom: 3px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.chip:hover { background: var(--accent); color: #fff; text-decoration: none; }
.chip.exclusive {
    background: var(--accent-fade); color: #74c0fc;
    border-left: 3px solid var(--accent);
}
.chip.exclusive:hover { background: var(--accent); color: #fff; }

.upcoming li { margin-bottom: 11px; }
.upcoming .when { color: var(--muted); font-size: 0.83rem; display: block; margin-top: 1px; }

/* ---------- misc ---------- */
h1 { font-size: 1.35rem; }
.page-head { display: flex; align-items: center; gap: 12px; margin-bottom: 20px; flex-wrap: wrap; }
.page-head h1 { margin: 0; }
.page-head .spacer { margin-left: auto; }
.empty { color: var(--muted); text-align: center; padding: 56px 0; }
.hint { color: var(--muted); font-size: 0.84rem; }
.rev {
    border-left: 3px solid var(--surface-3); padding-left: 16px; margin-bottom: 22px;
}
.rev pre {
    white-space: pre-wrap; background: var(--bg-deep); color: var(--text-dim);
    padding: 13px; border-radius: var(--radius); border: 1px solid var(--border-soft);
    font-family: var(--mono); font-size: 0.85rem;
}
.pagination { display: flex; gap: 10px; justify-content: center; margin-top: 24px; }
.inline-form { display: inline; }

::selection { background: var(--accent-dim); color: #fff; }

/* Scrollbars, so they don't glare white against the dark page. */
* { scrollbar-color: var(--surface-3) var(--bg); }
::-webkit-scrollbar { width: 11px; height: 11px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--surface-3); border-radius: 6px; border: 2px solid var(--bg); }
::-webkit-scrollbar-thumb:hover { background: var(--faint); }

@media (max-width: 640px) {
    .cal-day { min-height: 70px; padding: 5px; }
    .chip { font-size: 0.68rem; padding: 2px 5px; }
    header.site .wrap { flex-wrap: wrap; gap: 10px; }
    header.site nav { gap: 2px; }
    header.site nav a { padding: 6px 9px; font-size: 0.85rem; }
    .card { padding: 16px; }
    .post-head, .post-body { padding-left: 14px; padding-right: 14px; }
}
