/* ---------- Colors (all text pairs meet WCAG AA contrast or better) ---------- */
:root {
  --bg: #ffffff;
  --surface: #f4f6fb;
  --border: #d5dbe8;
  --text: #141a2b;
  --muted: #47506a;
  --navy: #14213d;
  --accent: #1f3f99;
  --accent-hover: #142c70;
  --accent-soft: #e6ebf7;
  --on-accent: #ffffff;
  --danger: #a3141e;
  --danger-soft: #fbeaeb;
  --success: #17643a;
  --success-soft: #e7f4ec;
  --focus: #1f3f99;
  --radius: 10px;
  --max: 46rem;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0d1424;
    --surface: #151f36;
    --border: #2b3a5c;
    --text: #e8ecf5;
    --muted: #aab4cc;
    --navy: #e8ecf5;
    --accent: #8fb0ff;
    --accent-hover: #b6ccff;
    --accent-soft: #1c2b4f;
    --on-accent: #0d1424;
    --danger: #ff9aa0;
    --danger-soft: #3a1418;
    --success: #8fe0b0;
    --success-soft: #12301f;
    --focus: #b6ccff;
  }
}

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

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 1.0625rem;
  line-height: 1.65;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

main { flex: 1; }

.wrap {
  width: 100%;
  max-width: var(--max);
  margin: 0 auto;
  padding: 0 1rem;
}

h1, h2, h3, h4 { color: var(--navy); line-height: 1.25; margin: 1.6em 0 .5em; }
h1 { font-size: clamp(1.9rem, 5vw, 2.5rem); margin-top: 2.5rem; letter-spacing: -0.01em; }
h2 { font-size: 1.45rem; }
h3 { font-size: 1.15rem; }

a { color: var(--accent); text-underline-offset: 0.18em; }
a:hover { color: var(--accent-hover); }

:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 3px;
  border-radius: 4px;
}

img { max-width: 100%; height: auto; border-radius: var(--radius); }

code {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 5px;
  padding: .1em .35em;
  font-size: .92em;
}
pre { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem; overflow-x: auto; }
pre code { border: 0; padding: 0; background: none; }

.visually-hidden {
  position: absolute !important;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0);
  white-space: nowrap; border: 0;
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; scroll-behavior: auto !important; }
}

/* ---------- Skip link ---------- */
.skip-link {
  position: absolute;
  left: 1rem; top: -4rem;
  background: var(--accent);
  color: var(--on-accent);
  padding: .6rem 1rem;
  border-radius: var(--radius);
  font-weight: 600;
  z-index: 10;
}
.skip-link:focus { top: 1rem; color: var(--on-accent); }

/* ---------- Header & footer ---------- */
#site-header { border-bottom: 1px solid var(--border); }
.header-inner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: .5rem 1.5rem;
  padding-top: 1rem;
  padding-bottom: 1rem;
}
.brand {
  font-weight: 700;
  font-size: 1.15rem;
  color: var(--navy);
  text-decoration: none;
}
.nav-list { list-style: none; display: flex; gap: .25rem; margin: 0; padding: 0; flex-wrap: wrap; }
.nav-list a {
  display: inline-block;
  padding: .4rem .75rem;
  border-radius: 999px;
  color: var(--text);
  text-decoration: none;
  font-weight: 500;
}
.nav-list a:hover { background: var(--surface); color: var(--text); }
.nav-list a[aria-current="page"] { background: var(--accent-soft); color: var(--accent); font-weight: 650; }

.demo-banner {
  margin: 0 auto .75rem;
  font-size: .9rem;
  color: var(--muted);
}

#site-footer { border-top: 1px solid var(--border); margin-top: 4rem; color: var(--muted); font-size: .95rem; }
.footer-inner { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: .5rem 1rem; padding-top: 1.25rem; padding-bottom: 1.25rem; }
.footer-inner p { margin: 0; }

/* ---------- Home ---------- */
.lead { font-size: 1.2rem; color: var(--muted); max-width: 36rem; margin-top: 0; }
.actions { display: flex; flex-wrap: wrap; gap: .75rem; margin: 1.5rem 0 1rem; }

/* ---------- Buttons ---------- */
.button, button {
  font: inherit;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .4rem;
  min-height: 2.75rem;
  padding: .55rem 1.15rem;
  border-radius: var(--radius);
  border: 2px solid var(--accent);
  background: var(--accent);
  color: var(--on-accent);
  cursor: pointer;
  text-decoration: none;
}
.button:hover, button:hover { background: var(--accent-hover); border-color: var(--accent-hover); color: var(--on-accent); }
.button.secondary, button.secondary { background: transparent; color: var(--accent); }
.button.secondary:hover, button.secondary:hover { background: var(--accent-soft); color: var(--accent-hover); }
button.danger { background: transparent; border-color: var(--danger); color: var(--danger); }
button.danger:hover { background: var(--danger-soft); color: var(--danger); }
button.small { min-height: 2.25rem; padding: .3rem .8rem; font-size: .95rem; }

/* ---------- Cards ---------- */
.card-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 1rem; }
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.1rem 1.25rem;
}
.card article > :last-child { margin-bottom: 0; }
.card-title { margin: 0 0 .15rem; font-size: 1.2rem; }
.card-title a { color: var(--navy); text-decoration: none; }
.card-title a:hover { color: var(--accent); text-decoration: underline; }
.meta { color: var(--muted); font-size: .92rem; margin: 0 0 .4rem; }

/* ---------- Socials ---------- */
.social-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 1rem; grid-template-columns: repeat(auto-fill, minmax(16rem, 1fr)); }
.social-card {
  display: flex; gap: 1rem; align-items: flex-start;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.1rem 1.25rem;
  position: relative;
}
.social-card:hover { border-color: var(--accent); }
.social-card:focus-within { outline: 3px solid var(--focus); outline-offset: 3px; }
.social-card a:focus-visible { outline: none; }
.social-initial {
  flex: none;
  width: 2.75rem; height: 2.75rem;
  border-radius: 50%;
  background: var(--accent);
  color: var(--on-accent);
  display: grid; place-items: center;
  font-weight: 700; font-size: 1.2rem;
}
.social-card h2 { margin: 0; font-size: 1.15rem; }
.social-card h2 a { color: var(--navy); text-decoration: none; }
/* The link covers the whole card so it is easy to tap. */
.social-card h2 a::after { content: ""; position: absolute; inset: 0; border-radius: var(--radius); }
.social-handle { display: block; font-weight: 500; color: var(--accent); font-size: .98rem; }
.social-card p { margin: .35rem 0 0; color: var(--muted); font-size: .95rem; }

/* ---------- Tutorial page ---------- */
.post-header { border-bottom: 1px solid var(--border); padding-bottom: 1rem; margin-bottom: 1.5rem; }
.post-header h1 { margin-bottom: .35rem; }
.video-link { margin: .75rem 0 0; }
.post-body { overflow-wrap: anywhere; }
.post-body li { margin: .3rem 0; }
.back-link { display: inline-block; margin-top: 2.5rem; }

/* ---------- Forms ---------- */
.field { margin: 0 0 1.35rem; }
label, .label { display: block; font-weight: 600; margin-bottom: .3rem; }
.hint { display: block; color: var(--muted); font-size: .93rem; margin: -.1rem 0 .4rem; }
input[type="text"], input[type="email"], input[type="password"], input[type="url"], input[type="search"], textarea {
  font: inherit;
  width: 100%;
  padding: .6rem .75rem;
  color: var(--text);
  background: var(--bg);
  border: 2px solid var(--border);
  border-radius: var(--radius);
}
input:hover, textarea:hover { border-color: var(--muted); }
input:focus-visible, textarea:focus-visible { border-color: var(--focus); outline-offset: 1px; }
textarea { min-height: 8rem; resize: vertical; }
textarea.body-input { min-height: 18rem; font-family: ui-monospace, "Cascadia Code", Consolas, monospace; font-size: .98rem; }
[aria-invalid="true"] { border-color: var(--danger) !important; }
.field-error { color: var(--danger); font-weight: 600; margin: .35rem 0 0; }
.field-error::before { content: "Error: "; }

.check { display: flex; gap: .6rem; align-items: flex-start; font-weight: 600; }
.check input { width: 1.25rem; height: 1.25rem; margin-top: .2rem; accent-color: var(--accent); }

.password-row { display: flex; gap: .5rem; }
.password-row input { flex: 1; min-width: 0; }

.form-actions { display: flex; flex-wrap: wrap; gap: .75rem; margin-top: 1.5rem; }

.error-summary {
  border: 2px solid var(--danger);
  background: var(--danger-soft);
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
  margin: 1rem 0 1.5rem;
}
.error-summary h2 { margin: 0 0 .5rem; font-size: 1.15rem; color: var(--danger); }
.error-summary ul { margin: 0; padding-left: 1.2rem; }
.error-summary a { color: var(--danger); font-weight: 600; }

.notice {
  border-radius: var(--radius);
  padding: .8rem 1rem;
  margin: 1rem 0;
}
/* Kept in the page (not display:none) so screen readers still announce new messages. */
.notice:empty { padding: 0; margin: 0; border: 0; }
.notice.success { background: var(--success-soft); color: var(--success); border: 2px solid var(--success); font-weight: 600; }
.notice.info { background: var(--accent-soft); color: var(--text); border: 1px solid var(--border); }

details.help { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: .6rem 1rem; margin: 0 0 .75rem; }
details.help summary { cursor: pointer; font-weight: 600; color: var(--accent); }
details.help table { border-collapse: collapse; width: 100%; margin: .75rem 0 .25rem; font-size: .95rem; }
details.help th, details.help td { text-align: left; padding: .35rem .5rem; border-bottom: 1px solid var(--border); vertical-align: top; }

/* ---------- Dashboard ---------- */
.dash-top { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: .5rem 1rem; }
.dash-top p { margin: 0; color: var(--muted); }
.preview {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 0 1.25rem 1rem;
  margin-top: 1.5rem;
}
.manage-list { list-style: none; margin: 0; padding: 0; }
.manage-list li {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between;
  gap: .5rem 1rem;
  padding: .85rem 0;
  border-bottom: 1px solid var(--border);
}
.manage-list .item-title { font-weight: 600; }
.status-tag { font-size: .85rem; font-weight: 600; padding: .1rem .55rem; border-radius: 999px; margin-left: .4rem; white-space: nowrap; }
.status-tag.live { background: var(--success-soft); color: var(--success); }
.status-tag.draft { background: var(--surface); color: var(--muted); border: 1px solid var(--border); }
.item-actions { display: flex; gap: .5rem; }

.empty { color: var(--muted); }
