/* LocalVoices — civic, readable, restrained. */

:root {
  --bg: #f7f7f5;
  --surface: #ffffff;
  --surface-sunken: #f1f1ee;
  --border: #dedcd6;
  --border-strong: #c3c0b8;
  --text: #1c1b19;
  --text-muted: #5f5c55;
  --text-faint: #86827a;
  --accent: #1f5f8b;
  --accent-hover: #17496b;
  --accent-soft: #e6eff5;
  --success: #2f6b46;
  --success-soft: #e4f0e9;
  --warning: #8a5a12;
  --warning-soft: #f7eddb;
  --danger: #9b2c2c;
  --danger-soft: #f7e5e5;
  --radius: 8px;
  --radius-sm: 5px;
  --shadow: 0 1px 2px rgba(28, 27, 25, 0.06), 0 2px 8px rgba(28, 27, 25, 0.04);
  --measure: 68ch;
  --font-sans: "Helvetica Neue", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-serif: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #17181a;
    --surface: #1f2123;
    --surface-sunken: #26282b;
    --border: #343739;
    --border-strong: #4a4d50;
    --text: #ececea;
    --text-muted: #a8a7a3;
    --text-faint: #85847f;
    --accent: #6fb2dc;
    --accent-hover: #8cc4e8;
    --accent-soft: #1d3444;
    --success: #7cc79b;
    --success-soft: #1e3227;
    --warning: #ddb271;
    --warning-soft: #352a19;
    --danger: #e08585;
    --danger-soft: #3a2222;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 2px 8px rgba(0, 0, 0, 0.2);
  }
}

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4 { font-family: var(--font-serif); line-height: 1.25; margin: 0 0 0.5em; font-weight: 600; }
h1 { font-size: 2rem; letter-spacing: -0.01em; }
h2 { font-size: 1.45rem; }
h3 { font-size: 1.15rem; }
h4 { font-size: 1rem; }
p { margin: 0 0 1em; }
a { color: var(--accent); text-decoration-thickness: 1px; text-underline-offset: 2px; }
a:hover { color: var(--accent-hover); }
hr { border: 0; border-top: 1px solid var(--border); margin: 2rem 0; }
small { font-size: 0.85rem; }

/* ---- Layout ---- */
.wrap { max-width: 1060px; margin: 0 auto; padding: 0 20px; }
.wrap-narrow { max-width: 720px; margin: 0 auto; padding: 0 20px; }
main { padding: 2rem 0 4rem; }
.stack > * + * { margin-top: 1rem; }
.stack-lg > * + * { margin-top: 2rem; }
.row { display: flex; gap: 0.75rem; align-items: center; flex-wrap: wrap; }
.row-between { display: flex; gap: 1rem; align-items: center; justify-content: space-between; flex-wrap: wrap; }
.grid { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
.grid-2 { display: grid; gap: 1.5rem; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); }
.split { display: grid; gap: 2.5rem; grid-template-columns: minmax(0, 1fr) 280px; align-items: start; }
@media (max-width: 860px) { .split { grid-template-columns: 1fr; gap: 1.5rem; } }

/* ---- Header ---- */
.site-header { background: var(--surface); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 20; }
.site-header .wrap { display: flex; align-items: center; justify-content: space-between; gap: 1rem; min-height: 62px; flex-wrap: wrap; }
.brand { font-family: var(--font-serif); font-size: 1.3rem; font-weight: 600; color: var(--text); text-decoration: none; letter-spacing: -0.01em; }
.brand span { color: var(--accent); }
.site-nav { display: flex; gap: 1.25rem; align-items: center; flex-wrap: wrap; }
.site-nav a { color: var(--text-muted); text-decoration: none; font-size: 0.925rem; }
.site-nav a:hover, .site-nav a.is-active { color: var(--text); text-decoration: underline; }

/* ---- Cards ---- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  box-shadow: var(--shadow);
}
.card-link { display: block; color: inherit; text-decoration: none; transition: border-color 0.15s, transform 0.15s; }
.card-link:hover { border-color: var(--border-strong); color: inherit; transform: translateY(-1px); }
.card h3 { margin-bottom: 0.25rem; }
.card-muted { background: var(--surface-sunken); box-shadow: none; }

/* ---- Meta and badges ---- */
.meta { color: var(--text-muted); font-size: 0.875rem; }
.meta-dot::before { content: "·"; margin: 0 0.45em; color: var(--text-faint); }
.badge {
  display: inline-block; padding: 0.15em 0.6em; border-radius: 99px;
  font-size: 0.75rem; font-weight: 600; letter-spacing: 0.02em;
  background: var(--surface-sunken); color: var(--text-muted); border: 1px solid var(--border);
}
.badge-accent { background: var(--accent-soft); color: var(--accent); border-color: transparent; }
.badge-open { background: var(--success-soft); color: var(--success); border-color: transparent; }
.badge-closed { background: var(--surface-sunken); color: var(--text-faint); }
.badge-draft { background: var(--warning-soft); color: var(--warning); border-color: transparent; }

/* ---- Buttons ---- */
.btn {
  display: inline-flex; align-items: center; gap: 0.4rem; justify-content: center;
  padding: 0.55rem 1rem; border-radius: var(--radius-sm); border: 1px solid transparent;
  background: var(--accent); color: #fff; font: inherit; font-size: 0.925rem; font-weight: 500;
  cursor: pointer; text-decoration: none; transition: background 0.15s;
}
.btn:hover { background: var(--accent-hover); color: #fff; }
.btn-secondary { background: var(--surface); color: var(--text); border-color: var(--border-strong); }
.btn-secondary:hover { background: var(--surface-sunken); color: var(--text); }
.btn-danger { background: transparent; color: var(--danger); border-color: var(--border); }
.btn-danger:hover { background: var(--danger-soft); color: var(--danger); }
.btn-sm { padding: 0.3rem 0.65rem; font-size: 0.825rem; }
.btn-block { width: 100%; }
/* .site-nav a is more specific than .btn, so buttons in the nav need this. */
.site-nav a.btn, .site-nav a.btn:hover { color: #fff; }
.site-nav a.btn-secondary, .site-nav a.btn-secondary:hover { color: var(--text); }
@media (prefers-color-scheme: dark) {
  .btn, .btn:hover, .site-nav a.btn, .site-nav a.btn:hover { color: #10171c; }
  .btn-secondary, .btn-secondary:hover,
  .site-nav a.btn-secondary, .site-nav a.btn-secondary:hover { color: var(--text); }
  .btn-danger, .btn-danger:hover { color: var(--danger); }
}

/* ---- Forms ---- */
form .field { margin-bottom: 1.1rem; }
label { display: block; font-weight: 500; font-size: 0.9rem; margin-bottom: 0.3rem; }
.input, input[type="text"], input[type="email"], input[type="url"], input[type="password"],
input[type="date"], input[type="datetime-local"], input[type="number"], select, textarea {
  width: 100%; padding: 0.55rem 0.7rem; font: inherit; font-size: 0.95rem;
  color: var(--text); background: var(--surface);
  border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
}
.input:focus, input:focus, select:focus, textarea:focus {
  outline: 2px solid var(--accent); outline-offset: -1px; border-color: var(--accent);
}
textarea { resize: vertical; min-height: 5rem; }
.checkbox-field { display: flex; gap: 0.5rem; align-items: flex-start; }
.checkbox-field input { width: auto; margin-top: 0.35rem; }
.checkbox-field label { margin: 0; font-weight: 400; }
.helptext { display: block; color: var(--text-muted); font-size: 0.825rem; margin-top: 0.25rem; }
.errorlist { list-style: none; margin: 0.35rem 0 0; padding: 0; color: var(--danger); font-size: 0.85rem; }
.form-error { background: var(--danger-soft); border: 1px solid var(--danger); color: var(--danger); padding: 0.75rem 1rem; border-radius: var(--radius-sm); }

/* ---- Messages ---- */
.messages { list-style: none; margin: 0 0 1.5rem; padding: 0; }
.messages li {
  padding: 0.7rem 1rem; border-radius: var(--radius-sm); margin-bottom: 0.5rem;
  border: 1px solid var(--border); background: var(--surface); font-size: 0.925rem;
}
.messages .success { background: var(--success-soft); border-color: transparent; color: var(--success); }
.messages .error { background: var(--danger-soft); border-color: transparent; color: var(--danger); }
.messages .warning { background: var(--warning-soft); border-color: transparent; color: var(--warning); }
.messages .info { background: var(--accent-soft); border-color: transparent; color: var(--accent); }

/* ---- Prose (sanitized rich text) ---- */
.prose { max-width: var(--measure); }
.prose > *:first-child { margin-top: 0; }
.prose > *:last-child { margin-bottom: 0; }
.prose h2, .prose h3, .prose h4 { margin-top: 1.5em; }
.prose ul, .prose ol { padding-left: 1.3em; margin: 0 0 1em; }
.prose li + li { margin-top: 0.25em; }
.prose blockquote {
  margin: 1em 0; padding: 0.25em 0 0.25em 1em;
  border-left: 3px solid var(--border-strong); color: var(--text-muted);
}
.prose code { background: var(--surface-sunken); padding: 0.1em 0.35em; border-radius: 3px; font-size: 0.9em; }
.prose pre { background: var(--surface-sunken); padding: 0.9em; border-radius: var(--radius-sm); overflow-x: auto; }

/* ---- Page header ---- */
.page-head { border-bottom: 1px solid var(--border); padding-bottom: 1.25rem; margin-bottom: 2rem; }
.page-head h1 { margin-bottom: 0.35rem; }
.breadcrumb { font-size: 0.85rem; color: var(--text-muted); margin-bottom: 0.6rem; }
.breadcrumb a { color: var(--text-muted); }
.breadcrumb span { margin: 0 0.4em; color: var(--text-faint); }

/* ---- Candidate ---- */
.candidate-head { display: flex; gap: 1.5rem; align-items: flex-start; flex-wrap: wrap; }
.avatar {
  width: 112px; height: 112px; border-radius: var(--radius); object-fit: cover;
  background: var(--surface-sunken); border: 1px solid var(--border); flex-shrink: 0;
}
.avatar-sm { width: 52px; height: 52px; border-radius: var(--radius-sm); }
.avatar-placeholder {
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-serif); font-size: 2rem; color: var(--text-faint);
}
.avatar-placeholder.avatar-sm { font-size: 1.1rem; }

/* ---- Lists ---- */
.list-plain { list-style: none; margin: 0; padding: 0; }
.list-divided { list-style: none; margin: 0; padding: 0; }
.list-divided > li { padding: 1rem 0; border-bottom: 1px solid var(--border); }
.list-divided > li:last-child { border-bottom: 0; }
.list-divided > li:first-child { padding-top: 0; }

/* ---- Resume ---- */
.resume-entry { padding-left: 1rem; border-left: 2px solid var(--border); }
.resume-entry h4 { margin-bottom: 0.1rem; }
.resume-relevance {
  margin-top: 0.75rem; padding: 0.75rem 0.9rem;
  background: var(--accent-soft); border-radius: var(--radius-sm); font-size: 0.925rem;
}
.resume-relevance strong { display: block; font-size: 0.775rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--accent); margin-bottom: 0.2rem; }

/* ---- Discussion ---- */
.post { padding: 1rem 0; border-bottom: 1px solid var(--border); }
.post:last-child { border-bottom: 0; }
.post-head { display: flex; gap: 0.6rem; align-items: baseline; flex-wrap: wrap; margin-bottom: 0.35rem; }
.post-author { font-weight: 600; font-size: 0.95rem; }
.post-body { white-space: pre-wrap; margin: 0; }
.post-replies { margin: 0.75rem 0 0 1.25rem; padding-left: 1rem; border-left: 2px solid var(--border); }
.post-actions { margin-top: 0.4rem; display: flex; gap: 0.75rem; }
.post-actions button, .post-actions a {
  background: none; border: 0; padding: 0; font: inherit; font-size: 0.825rem;
  color: var(--text-muted); cursor: pointer; text-decoration: underline;
}
.post-actions button:hover, .post-actions a:hover { color: var(--text); }

/* ---- Polls ---- */
.poll-option { margin-bottom: 0.6rem; }
.poll-choice { display: flex; gap: 0.6rem; align-items: center; padding: 0.55rem 0.7rem; border: 1px solid var(--border); border-radius: var(--radius-sm); cursor: pointer; }
.poll-choice:hover { border-color: var(--border-strong); background: var(--surface-sunken); }
.poll-choice input { width: auto; margin: 0; }
.poll-choice.is-mine { border-color: var(--accent); background: var(--accent-soft); }
.result-row { margin-bottom: 0.85rem; }
.result-label { display: flex; justify-content: space-between; gap: 1rem; font-size: 0.9rem; margin-bottom: 0.25rem; }
.result-label .result-count { color: var(--text-muted); white-space: nowrap; }
.result-bar { height: 9px; background: var(--surface-sunken); border-radius: 99px; overflow: hidden; }
.result-bar span { display: block; height: 100%; background: var(--accent); border-radius: 99px; transition: width 0.4s ease; }
.result-row.is-mine .result-bar span { background: var(--success); }
.result-row.is-mine .result-label { font-weight: 600; }

/* ---- Dashboard ---- */
.dash { display: grid; grid-template-columns: 216px minmax(0, 1fr); gap: 2.5rem; align-items: start; }
@media (max-width: 800px) { .dash { grid-template-columns: 1fr; gap: 1.5rem; } }
.dash-nav { position: sticky; top: 80px; }
.dash-nav ul { list-style: none; margin: 0; padding: 0; }
.dash-nav li { margin-bottom: 2px; }
.dash-nav a {
  display: block; padding: 0.5rem 0.75rem; border-radius: var(--radius-sm);
  color: var(--text-muted); text-decoration: none; font-size: 0.925rem;
}
.dash-nav a:hover { background: var(--surface-sunken); color: var(--text); }
.dash-nav a.is-active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.dash-nav .nav-heading {
  font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.08em;
  color: var(--text-faint); padding: 1rem 0.75rem 0.35rem; font-weight: 600;
}
.stat-grid { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem; }
.stat-value { font-family: var(--font-serif); font-size: 1.9rem; line-height: 1.1; }
.stat-label { color: var(--text-muted); font-size: 0.85rem; margin-top: 0.15rem; }

/* ---- Rich text editor ---- */
.richtext-wrap { border: 1px solid var(--border-strong); border-radius: var(--radius-sm); background: var(--surface); }
.richtext-wrap:focus-within { outline: 2px solid var(--accent); outline-offset: -1px; }
.richtext-toolbar {
  display: flex; gap: 2px; flex-wrap: wrap; padding: 0.35rem;
  border-bottom: 1px solid var(--border); background: var(--surface-sunken);
  border-radius: var(--radius-sm) var(--radius-sm) 0 0;
}
.richtext-toolbar button {
  min-width: 30px; height: 28px; padding: 0 0.45rem; font: inherit; font-size: 0.85rem;
  background: transparent; border: 1px solid transparent; border-radius: 4px;
  color: var(--text-muted); cursor: pointer;
}
.richtext-toolbar button:hover { background: var(--surface); border-color: var(--border); color: var(--text); }
.richtext-toolbar .sep { width: 1px; background: var(--border); margin: 3px 4px; }
.richtext-editor {
  min-height: 11rem; max-height: 32rem; overflow-y: auto; padding: 0.7rem 0.8rem;
  font-size: 0.95rem; line-height: 1.65;
}
.richtext-editor:focus { outline: none; }
.richtext-editor > *:first-child { margin-top: 0; }
.richtext-editor[data-empty="true"]::before {
  content: attr(data-placeholder); color: var(--text-faint); pointer-events: none;
}
.richtext-hint { font-size: 0.8rem; color: var(--text-faint); padding: 0.3rem 0.8rem 0.5rem; }

/* ---- Footer ---- */
.site-footer {
  border-top: 1px solid var(--border); background: var(--surface);
  padding: 1.75rem 0; color: var(--text-muted); font-size: 0.875rem;
}

/* ---- Utilities ---- */
.empty { color: var(--text-muted); font-style: italic; }
.text-muted { color: var(--text-muted); }
.text-center { text-align: center; }
.mt-0 { margin-top: 0; } .mb-0 { margin-bottom: 0; }
.mt-2 { margin-top: 2rem; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }
.notice { background: var(--accent-soft); border-radius: var(--radius-sm); padding: 0.85rem 1rem; font-size: 0.925rem; }
.notice-warn { background: var(--warning-soft); color: var(--warning); }
.credential { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; background: var(--surface-sunken); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 0.6rem 0.8rem; word-break: break-all; font-size: 0.9rem; }
