:root {
  --bg: #ffffff;
  --surface: #f4f6f9;
  --text: #1b1f24;
  --muted: #4a5360;
  --border: #b6bec9;
  --brand: #1d4f91;
  --brand-dark: #133a6c;
  --link: #1d4f91;
  --focus: #ffbf47;
  --ok: #0b6b3a;
  --ok-bg: #e5f4ec;
  --warn: #8a4b00;
  --warn-bg: #fff3dc;
  --bad: #a4161a;
  --bad-bg: #fde8e8;
  --info-bg: #e8f0fb;
  --radius: 10px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #121519;
    --surface: #1c2128;
    --text: #eef1f5;
    --muted: #b3bcc8;
    --border: #47515e;
    --brand: #8ab4f8;
    --brand-dark: #b5cff9;
    --link: #9cc0fa;
    --ok: #7fd8a5;
    --ok-bg: #12301f;
    --warn: #ffcf7a;
    --warn-bg: #3a2a0c;
    --bad: #ff9a9a;
    --bad-bg: #3d1517;
    --info-bg: #17263b;
    color-scheme: dark;
  }
}

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

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  line-height: 1.55;
}

.wrap { max-width: 62rem; margin: 0 auto; padding: 0 16px; }

a { color: var(--link); text-underline-offset: 0.15em; }
a:hover { text-decoration-thickness: 2px; }

:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; box-shadow: 0 0 0 5px var(--text); }
[tabindex="-1"]:focus { outline: none; box-shadow: none; }

h1 { font-size: 1.75rem; line-height: 1.25; margin: 1.25rem 0 0.75rem; }
h2 { font-size: 1.3rem; line-height: 1.3; margin: 1.75rem 0 0.6rem; }
h3 { font-size: 1.08rem; margin: 0.25rem 0 0.4rem; }
p, ul { margin: 0 0 0.8rem; }
.lead { font-size: 1.1rem; color: var(--muted); max-width: 42rem; }
.small, .hint { font-size: 0.9rem; color: var(--muted); }
.hint { display: block; margin: 0 0 0.35rem; font-weight: normal; }

.skip-link { position: absolute; left: -9999px; top: 0; background: var(--focus); color: #000; padding: 0.6rem 1rem; z-index: 10; }
.skip-link:focus { left: 0; }
.visually-hidden { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* header and nav */
.site-header { background: var(--brand-dark); color: #fff; padding: 0.6rem 0 0.4rem; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .site-header { background: #0b1e38; } }
.site-name { color: #fff; font-weight: 700; font-size: 1.2rem; text-decoration: none; display: inline-block; padding: 0.2rem 0; }
.site-tag { font-weight: 400; opacity: 0.85; font-size: 0.95rem; }
#nav { display: flex; flex-wrap: wrap; align-items: center; gap: 0.4rem 1rem; }
#nav ul { list-style: none; margin: 0.3rem 0 0; padding: 0; display: flex; flex-wrap: wrap; gap: 0.15rem 0.2rem; }
#nav a { color: #fff; text-decoration: none; display: inline-block; padding: 0.45rem 0.6rem; border-radius: 6px; font-size: 0.95rem; min-height: 44px; line-height: 1.6; }
#nav a:hover { background: rgba(255, 255, 255, 0.14); }
#nav a[aria-current="page"] { background: #fff; color: #133a6c; font-weight: 600; }
#nav select { margin: 0.3rem 0 0; width: auto; }

main { padding-bottom: 2.5rem; min-height: 60vh; }
.breadcrumb { margin: 1rem 0 0; font-size: 0.95rem; }

/* forms */
label { display: block; font-weight: 600; margin-bottom: 0.25rem; }
.field { margin-bottom: 1.1rem; }
input, select, textarea {
  font: inherit; color: var(--text); background: var(--bg);
  border: 2px solid var(--border); border-radius: 6px; padding: 0.55rem 0.65rem;
  width: 100%; max-width: 30rem; min-height: 44px;
}
textarea { max-width: 100%; }
.letter-form #letter-body { font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; font-size: 0.92rem; line-height: 1.5; }
input:focus, select:focus, textarea:focus { border-color: var(--text); }
input[type="date"] { max-width: 14rem; }
.input-short { max-width: 9rem; }
input[type="radio"] { width: 1.3rem; height: 1.3rem; min-height: 0; margin: 0 0.5rem 0 0; vertical-align: -0.2rem; }
input[type="file"] { border-style: dashed; }
fieldset { border: 0; padding: 0; margin: 0 0 1.1rem; }
legend { font-weight: 600; margin-bottom: 0.4rem; }
.radio { font-weight: 400; padding: 0.35rem 0; }
.check { font-weight: 400; display: flex; align-items: center; gap: 0.5rem; min-height: 44px; margin: 0.25rem 0 0; cursor: pointer; }
input[type="checkbox"] { width: 1.3rem; height: 1.3rem; min-height: 0; margin: 0; flex: none; }
.not-yet { margin: 0.4rem 0 0.6rem; }

.button {
  display: inline-block; font: inherit; font-weight: 600; text-decoration: none; cursor: pointer;
  background: var(--brand); color: #fff; border: 2px solid var(--brand); border-radius: 8px;
  padding: 0.55rem 1rem; min-height: 44px; line-height: 1.4;
}
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .button { color: #0b1e38; } }
.button:hover { filter: brightness(1.1); }
.button-secondary { background: transparent; color: var(--link); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .button-secondary { color: var(--link); } }
.button-danger { background: var(--bad); border-color: var(--bad); }
.link-button { background: none; border: 0; padding: 0.4rem 0; color: var(--link); text-decoration: underline; font: inherit; cursor: pointer; min-height: 44px; }
.actions { display: flex; flex-wrap: wrap; gap: 0.6rem; align-items: center; margin-top: 0.6rem; }
.actions:empty { display: none; }

/* blocks */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem 1.1rem; margin: 0 0 1rem; }
.card > h2:first-child, .card > h3:first-child { margin-top: 0; }
.callout { border-left: 6px solid var(--brand); background: var(--info-bg); padding: 0.75rem 1rem; border-radius: 0 var(--radius) var(--radius) 0; margin: 0 0 1rem; }
.callout > :last-child { margin-bottom: 0; }
.callout-warn { border-color: var(--warn); background: var(--warn-bg); }
.callout-ok { border-color: var(--ok); background: var(--ok-bg); }
.callout-where { font-size: 1.05rem; }
.danger { border-color: var(--bad); }

.ticks { padding-left: 0; list-style: none; }
.ticks li { padding-left: 1.7rem; position: relative; margin-bottom: 0.35rem; }
.ticks li::before { content: "✓"; position: absolute; left: 0; color: var(--ok); font-weight: 700; }

.choice-list, .journey-list, .deadlines, .log-list, .contacts, .letter-list, .quick, .children { list-style: none; padding: 0; margin: 0 0 1rem; }
.choice { display: block; padding: 0.85rem 1rem; border: 2px solid var(--border); border-radius: var(--radius); margin-bottom: 0.6rem; text-decoration: none; background: var(--bg); }
.choice:hover { border-color: var(--link); }
.choice span { display: block; color: var(--muted); font-size: 0.92rem; }
.journey-list { display: grid; gap: 0.75rem; grid-template-columns: repeat(auto-fit, minmax(15rem, 1fr)); }
.journey-card { margin: 0; }
.journey-card p { margin: 0; color: var(--muted); }
.quick { display: flex; flex-wrap: wrap; gap: 0.6rem; }
.letter-list li { padding: 0.6rem 0; border-bottom: 1px solid var(--border); }
.children li { padding: 0.4rem 0; }

.journey-grid { display: grid; gap: 1.25rem; }
@media (min-width: 56rem) { .journey-grid { grid-template-columns: minmax(18rem, 2fr) 3fr; align-items: start; } .journey-grid > section > h2:first-child { margin-top: 0; } }

/* guided steps */
.before { margin: 1rem 0; }
.before > summary { color: var(--text); }
.before-title { font-size: 1.1rem; }
.before h3 { margin-top: 1rem; }
.words { margin: 0 0 0.6rem; }
.words dt { font-weight: 700; margin-top: 0.6rem; }
.words dd { margin: 0.1rem 0 0; color: var(--text); }

.steps { list-style: none; padding: 0; margin: 1rem 0 1.5rem; counter-reset: none; }
.step { position: relative; border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem 1.1rem 0.6rem; margin: 0 0 1rem; background: var(--bg); }
.step-current { border: 3px solid var(--brand); box-shadow: 0 2px 0 var(--border); }
.step-later { background: var(--surface); color: var(--muted); }
.step-later .step-num { background: var(--border); color: var(--text); }
.step-done { background: var(--surface); }
.step-done > details > summary { list-style: none; display: block; min-height: 0; padding: 0; }
.step-done > details > summary::-webkit-details-marker { display: none; }
.step-done > details > summary .step-heading::after { content: "Show"; font-size: 0.85rem; font-weight: 600; color: var(--link); text-decoration: underline; margin-left: 0.5rem; }
.step-done > details[open] > summary .step-heading::after { content: "Hide"; }
.step-title { display: flex; gap: 0.75rem; align-items: flex-start; margin: 0 0 0.4rem; font-size: 1.2rem; }
.step-num {
  flex: none; width: 2.1rem; height: 2.1rem; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center;
  background: var(--brand); color: #fff; font-size: 1rem; font-weight: 700;
}
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .step-num { color: #0b1e38; } }
.step-done .step-num { background: var(--ok); }
.step-heading { padding-top: 0.15rem; }
.step-state { display: inline-block; margin-left: 0.4rem; font-size: 0.8rem; font-weight: 700; padding: 0.1rem 0.55rem; border-radius: 999px; vertical-align: 0.15em; border: 2px solid currentColor; }
.step-state-current { color: var(--brand); background: var(--info-bg); }
.step-state-done { color: var(--ok); background: var(--ok-bg); }
.step-state-later { color: var(--muted); }
.step-outcomes { list-style: none; padding: 0; margin: 0.2rem 0 0.4rem 2.85rem; font-size: 0.93rem; }
.step-meta { display: flex; flex-wrap: wrap; gap: 0.2rem 1.2rem; font-size: 0.92rem; color: var(--muted); margin-bottom: 0.6rem; }
.step-meta strong { color: var(--text); }
.tips { background: var(--surface); border-radius: 8px; padding: 0.6rem 0.9rem; margin: 0 0 0.9rem; }
.step-done .tips, .step-later .tips { background: var(--bg); }
.tips h4, .deadlines-h { margin: 0 0 0.3rem; font-size: 1rem; }
.tips ul { margin: 0; padding-left: 1.2rem; }
.questions { border-top: 1px solid var(--border); padding-top: 0.9rem; margin-top: 0.4rem; }
.deadlines-h { margin-top: 0.4rem; }
.help { margin: 0 0 0.45rem; }
.help > summary { font-weight: 600; font-size: 0.93rem; padding: 0.2rem 0; min-height: 44px; display: list-item; }
.help[open] { background: var(--info-bg); border-radius: 8px; padding: 0.3rem 0.8rem 0.4rem; }
.help p { margin-bottom: 0.45rem; font-size: 0.95rem; }
.next { border-left: 4px solid var(--brand); padding: 0.3rem 0 0.3rem 0.75rem; margin: 0.8rem 0 0.6rem; }

/* Day / Month / Year date boxes */
.date-field legend { font-weight: 600; margin-bottom: 0.3rem; }
.date-input { display: flex; flex-wrap: wrap; gap: 0.75rem; align-items: flex-end; }
.date-part label { font-weight: 400; font-size: 0.95rem; margin-bottom: 0.15rem; }
.date-part input { text-align: left; }
.input-2 { width: 3.6rem; }
.input-4 { width: 5.4rem; }
.date-error { flex-basis: 100%; margin: 0; color: var(--bad); font-weight: 600; }
.date-error:empty { display: none; }
[aria-invalid="true"] { border-color: var(--bad); }

/* about / professionals */
.changes { list-style: none; padding: 0; }
.changes li { margin-bottom: 0.4rem; }
.pro-url { font-size: 1.5rem; color: var(--brand); margin: 0.2rem 0 0.8rem; }
@media print {
  .professionals { font-size: 10pt; line-height: 1.4; }
  .professionals h1 { font-size: 17pt; margin: 0 0 0.3rem; }
  .professionals h2 { font-size: 12pt; margin: 0.7rem 0 0.25rem; }
  .professionals .lead { font-size: 10.5pt; color: #000; }
  .professionals ul { margin-bottom: 0.4rem; }
  .professionals .pro-url { font-size: 16pt; color: #000; }
}

/* pop-up */
.dialog {
  border: 0; border-radius: var(--radius); padding: 1.2rem 1.3rem 1rem; max-width: min(32rem, calc(100vw - 32px));
  background: var(--bg); color: var(--text); box-shadow: 0 10px 40px rgba(0, 0, 0, 0.35); border-top: 6px solid var(--warn);
}
.dialog::backdrop { background: rgba(0, 0, 0, 0.55); }
.dialog h2 { margin-top: 0; }
.attach-reminder ul { margin: 0.2rem 0 0.6rem; }

/* letters */
.letter-form .step-title { align-items: center; margin-bottom: 0.6rem; }
.letter-preview {
  white-space: pre-wrap; overflow-wrap: anywhere; background: var(--bg); border: 1px solid var(--border); border-radius: 8px;
  padding: 1rem 1.1rem; font-family: Georgia, "Times New Roman", serif; font-size: 1rem; line-height: 1.55; max-height: 34rem; overflow-y: auto;
  margin-bottom: 0.6rem;
}
mark.missing { background: #ffd23f; color: #000; padding: 0 0.15em; border-radius: 3px; font-family: system-ui, sans-serif; font-weight: 700; outline: 2px dashed #8a4b00; }
.is-missing { border-color: var(--warn); border-style: dashed; }
.optional { font-weight: 400; color: var(--muted); font-size: 0.9rem; }
.profile-box { border: 1px solid var(--border); border-radius: 8px; padding: 0.4rem 0.9rem; margin: 0 0 1rem; background: var(--bg); }
.profile-box > summary { font-weight: 700; }

/* deadlines */
.deadline { border: 1px solid var(--border); border-left: 6px solid var(--border); border-radius: var(--radius); padding: 0.85rem 1rem; margin-bottom: 0.8rem; background: var(--bg); }
.deadline-overdue, .deadline-late { border-left-color: var(--bad); }
.deadline-today, .deadline-soon { border-left-color: var(--warn); }
.deadline-done { border-left-color: var(--ok); }
.deadline-upcoming { border-left-color: var(--brand); }
.deadline-head { display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: center; justify-content: space-between; }
.deadline-title { margin: 0.4rem 0 0.3rem; }
.owner { font-size: 0.85rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; font-weight: 600; }
.due { margin-bottom: 0.5rem; }
.due-label { color: var(--muted); }

.badge { display: inline-block; font-size: 0.85rem; font-weight: 700; padding: 0.15rem 0.55rem; border-radius: 999px; border: 2px solid currentColor; }
.badge-done { color: var(--ok); background: var(--ok-bg); }
.badge-late, .badge-overdue { color: var(--bad); background: var(--bad-bg); }
.badge-today, .badge-soon { color: var(--warn); background: var(--warn-bg); }
.badge-upcoming, .badge-needs { color: var(--brand); background: var(--info-bg); }
.badge-passed { color: var(--muted); background: var(--surface); }

details { margin: 0.5rem 0; }
summary { cursor: pointer; color: var(--link); font-weight: 600; padding: 0.35rem 0; min-height: 44px; display: list-item; }
details[open] > summary { margin-bottom: 0.4rem; }
blockquote { margin: 0.4rem 0 0.6rem; padding: 0.4rem 0.8rem; border-left: 4px solid var(--border); color: var(--muted); font-style: italic; }
.law-source { font-weight: 600; margin: 0; font-size: 0.92rem; }
.claim { border-top: 1px dashed var(--border); padding-top: 0.3rem; }
.claim-note { color: var(--warn); font-weight: 600; }

.log-entry { margin-bottom: 0.75rem; }
.log-meta { margin-bottom: 0.3rem; }
.log-summary, .pre { white-space: pre-wrap; }

.toc ul { margin: 0; padding-left: 1.2rem; }
.right { border-bottom: 1px solid var(--border); padding-bottom: 0.6rem; }
.right .summary { font-weight: 600; }
.cites { font-size: 0.9rem; color: var(--muted); }

.contact { margin-bottom: 0.75rem; }
.contact p { margin-bottom: 0.35rem; }
.contact a { overflow-wrap: anywhere; }

table { border-collapse: collapse; width: 100%; margin: 0.5rem 0 1rem; font-size: 0.92rem; }
th, td { text-align: left; vertical-align: top; border: 1px solid var(--border); padding: 0.35rem 0.5rem; }
th { background: var(--surface); }
.table-wrap { overflow-x: auto; }

.site-footer { border-top: 1px solid var(--border); background: var(--surface); padding: 1rem 0 1.5rem; font-size: 0.92rem; }
.site-footer ul { list-style: none; padding: 0; display: flex; flex-wrap: wrap; gap: 0.3rem 1.2rem; margin: 0; }
.site-footer a { display: inline-block; padding: 0.4rem 0; }

.print-only { display: none; }

@media print {
  html { font-size: 11pt; }
  body { background: #fff; color: #000; }
  .site-header, .site-footer, .no-print, .skip-link, .breadcrumb, .actions, .callout-warn[role="alert"] { display: none !important; }
  a { color: #000; text-decoration: none; }
  .wrap { max-width: none; padding: 0; }
  th, td { border-color: #888; }
  th { background: #eee; }
  body.printing-letter main > *:not(.letter-print) { display: none !important; }
  body.printing-letter .letter-print { display: block !important; white-space: pre-wrap; font-family: Georgia, serif; font-size: 11.5pt; line-height: 1.5; }
}

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