/* ---- Reset ---- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

/* ---- Tokens ---- */
:root {
    --bg:           #111111;
    --surface:      #1a1a1a;
    --surface-2:    #222222;
    --border:       #2a2a2a;
    --text:         #e8e8e8;
    --text-muted:   #777777;
    --text-faint:   #3d3d3d;
    --accent:       #5b8af0;
    --accent-hover: #7aa3f5;
    --danger:       #e05555;
    --success:      #4caf7d;

    --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    --font-mono: 'SF Mono', 'Fira Code', Consolas, 'Liberation Mono', monospace;

    --radius-sm: 4px;
    --radius:    6px;
    --radius-lg: 10px;

    --s1: 4px;
    --s2: 8px;
    --s3: 12px;
    --s4: 16px;
    --s5: 20px;
    --s6: 24px;
}

/* ---- Base ---- */
html { font-size: 16px; }

body {
    background:  var(--bg);
    color:       var(--text);
    font-family: var(--font);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    display: flex;
    flex-direction: column;
    min-height: 100dvh;
}

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

/* ---- Header ---- */
header {
    display: flex;
    align-items: center;
    gap: var(--s4);
    padding: var(--s3) var(--s4);
    border-bottom: 1px solid var(--border);
    background: var(--surface);
    flex-shrink: 0;
}

.site-name { color: var(--text); font-weight: 700; font-size: 15px; letter-spacing: -0.01em; }
.site-name:hover { text-decoration: none; color: var(--text); }

header nav { display: flex; align-items: center; gap: var(--s4); margin-left: auto; }
header nav a { color: var(--text-muted); font-size: 13px; }
header nav a:hover { color: var(--text); text-decoration: none; }
header nav form { display: contents; }
header nav button {
    background: none; border: none; color: var(--text-muted);
    cursor: pointer; font-size: 13px; font-family: var(--font); padding: 0;
}
header nav button:hover { color: var(--text); }
.nav-user { color: var(--text-faint); font-size: 13px; }

/* ---- Main ---- */
main { flex: 1; padding: var(--s4); overflow-y: auto; }
main.no-pad { padding: 0; overflow: hidden; }

/* ---- Flash messages ---- */
.messages { list-style: none; padding: var(--s2) var(--s4) 0; }
.messages li {
    background: var(--surface);
    border-left: 3px solid var(--accent);
    border-radius: 0 var(--radius) var(--radius) 0;
    padding: var(--s2) var(--s3);
    margin-bottom: var(--s2);
    font-size: 14px;
}
.messages li.error   { border-left-color: var(--danger); }
.messages li.success { border-left-color: var(--success); }

/* ---- Form validation errors (Django's default form.as_p() errorlist) ---- */
.errorlist {
    list-style: none;
    padding: 0;
    margin-bottom: var(--s2);
}
.errorlist li {
    background: var(--surface);
    border-left: 3px solid var(--danger);
    border-radius: 0 var(--radius) var(--radius) 0;
    padding: var(--s2) var(--s3);
    margin-bottom: var(--s2);
    font-size: 14px;
    color: var(--danger);
}

/* ---- SSR typography ---- */
h1 { font-size: 1.4rem; font-weight: 700; margin-bottom: var(--s4); }
h2 { font-size: 1.15rem; font-weight: 600; margin-bottom: var(--s3); }
p  { margin-bottom: var(--s3); }

/* ---- SSR forms ---- */
label { display: block; font-size: 13px; color: var(--text-muted); margin-bottom: var(--s1); }
input[type=text], input[type=email], input[type=password], input[type=search], textarea, select {
    display: block;
    width: 100%;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text);
    font-family: var(--font);
    font-size: 14px;
    padding: var(--s2) var(--s3);
    outline: none;
    transition: border-color 0.15s;
}
input:focus, textarea:focus, select:focus { border-color: var(--accent); }
input::placeholder, textarea::placeholder { color: var(--text-faint); }
textarea { resize: vertical; line-height: 1.6; }

button[type=submit], .btn-ssr {
    display: inline-flex;
    align-items: center;
    padding: var(--s2) var(--s4);
    background: var(--accent);
    border: none;
    border-radius: var(--radius);
    color: #fff;
    cursor: pointer;
    font-family: var(--font);
    font-size: 14px;
    font-weight: 500;
    transition: background 0.15s;
}
button[type=submit]:hover { background: var(--accent-hover); }

/* ---- Note body prose (shared SSR + app) ---- */
.note-body { line-height: 1.75; font-size: 15px; }
.note-body h1, .note-body h2, .note-body h3 { margin: var(--s5) 0 var(--s3); font-weight: 600; }
.note-body h1 { font-size: 1.35em; }
.note-body h2 { font-size: 1.15em; }
.note-body h3 { font-size: 1em; }
.note-body p  { margin-bottom: var(--s4); }
.note-body ul, .note-body ol { margin: 0 0 var(--s4) var(--s5); }
.note-body li { margin-bottom: var(--s1); }
.note-body code { font-family: var(--font-mono); font-size: .875em; background: var(--surface-2); padding: 2px 5px; border-radius: var(--radius-sm); }
.note-body pre  { position: relative; background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius); padding: var(--s4); overflow-x: auto; margin-bottom: var(--s4); }

.copy-btn {
    position: absolute;
    top: var(--s2);
    right: var(--s2);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    cursor: pointer;
    font-family: var(--font-mono);
    font-size: 11px;
    line-height: 1;
    opacity: 0;
    padding: 3px var(--s2);
    transition: opacity 0.15s, color 0.15s;
}
.copy-btn:hover { color: var(--text); }
pre:hover .copy-btn { opacity: 1; }
@media (hover: none) { .copy-btn { opacity: 1; } }
.note-body pre code { background: none; padding: 0; }
.note-body blockquote { border-left: 3px solid var(--border); padding-left: var(--s4); color: var(--text-muted); margin-bottom: var(--s4); }
.note-body a   { color: var(--accent); }
.note-body strong { font-weight: 600; }
.note-body em  { font-style: italic; }
.note-body table { border-collapse: collapse; width: 100%; margin-bottom: var(--s4); }
.note-body th, .note-body td { border: 1px solid var(--border); padding: var(--s2) var(--s3); text-align: left; }
.note-body th  { background: var(--surface-2); font-weight: 600; }
.note-body hr  { border: none; border-top: 1px solid var(--border); margin: var(--s5) 0; }

/* ---- Utility ---- */
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); border: 0; }
