:root {
  --bg: #f6f5f1;
  --surface: #ffffff;
  --soft: #eef3f0;
  --ink: #1d2623;
  --muted: #5d6965;
  --line: #dfe3df;
  --brand: #2f6f5e;
  --brand-ink: #ffffff;
  --ok: #2f6f5e;
  --ok-bg: #e5f0eb;
  --flag: #9a5a0b;
  --flag-bg: #fbefd9;
  --lab: rgba(47, 111, 94, 0.12);
  --personal: #6a4fb3;
  --guide: #b45309;
  --context: rgba(93, 105, 101, 0.10);
  --radius: 12px;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.05), 0 2px 8px rgba(0, 0, 0, 0.04);
  font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color: var(--ink);
  background: var(--bg);
  line-height: 1.5;
}

* { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; display: flex; flex-direction: column; }
a { color: var(--brand); }
h1, h2, h3 { line-height: 1.2; margin: 0 0 0.5rem; }
h1 { font-size: 1.75rem; }
h2 { font-size: 1.2rem; }
h3 { font-size: 1rem; }
p { margin: 0.4rem 0; }

.skip { position: absolute; left: -999px; }
.skip:focus { left: 1rem; top: 1rem; background: var(--surface); padding: 0.5rem; z-index: 10; }

.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap;
  padding: 0.75rem 1.5rem; background: var(--surface); border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 5;
}
.brand { display: flex; align-items: center; gap: 0.5rem; font-weight: 700; color: var(--brand); text-decoration: none; }
.nav { display: flex; align-items: center; gap: 0.25rem; flex-wrap: wrap; }
.nav a { padding: 0.4rem 0.7rem; border-radius: 8px; color: var(--ink); text-decoration: none; font-size: 0.95rem; }
.nav a:hover { background: var(--soft); }
.nav a.active { background: var(--soft); color: var(--brand); font-weight: 600; }

.banner { background: var(--flag-bg); color: var(--flag); text-align: center; padding: 0.5rem 1rem; font-size: 0.9rem; }

main { flex: 1; width: 100%; max-width: 1080px; margin: 0 auto; padding: 1.5rem; outline: none; }
.footer { text-align: center; color: var(--muted); font-size: 0.85rem; padding: 1.5rem; border-top: 1px solid var(--line); }

.hero { max-width: 720px; margin: 2rem 0 1.5rem; }
.hero h1 { font-size: 2.2rem; }
.lede { font-size: 1.08rem; color: var(--muted); max-width: 70ch; }
.page-head { margin-bottom: 1rem; }
.section-title { margin: 1.5rem 0 0.75rem; }
.muted { color: var(--muted); }
.small { font-size: 0.88rem; }
.error { color: #a12b2b; }
.notice { background: var(--flag-bg); color: var(--flag); padding: 0.5rem 0.75rem; border-radius: 8px; display: inline-block; }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.25rem; box-shadow: var(--shadow); margin-bottom: 1rem; }
.card.soft { background: var(--soft); box-shadow: none; }
.two-col { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 1rem; }
.three { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 1rem; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 1rem; }
.row { display: flex; gap: 0.75rem; flex-wrap: wrap; align-items: flex-end; }
.row > label { flex: 1 1 180px; }
.row-between { display: flex; justify-content: space-between; align-items: baseline; gap: 1rem; flex-wrap: wrap; }
.stack { display: flex; flex-direction: column; gap: 0.75rem; }
.empty { text-align: center; padding: 3rem 1rem; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.4rem;
  border: 1px solid var(--line); background: var(--surface); color: var(--ink);
  padding: 0.6rem 1rem; border-radius: 10px; font: inherit; font-weight: 600; cursor: pointer; text-decoration: none;
}
.btn:hover { border-color: var(--brand); }
.btn.primary { background: var(--brand); color: var(--brand-ink); border-color: var(--brand); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.small { padding: 0.35rem 0.7rem; font-size: 0.88rem; }
.btn.ghost { background: transparent; }
.btn:disabled { opacity: 0.6; cursor: progress; }
button.link { background: none; border: none; color: var(--brand); text-decoration: underline; cursor: pointer; font: inherit; padding: 0 0.25rem; }
:focus-visible { outline: 3px solid #86b9a9; outline-offset: 2px; }

label { display: flex; flex-direction: column; gap: 0.3rem; font-weight: 600; font-size: 0.92rem; }
input, select, textarea {
  font: inherit; font-weight: 400; padding: 0.55rem 0.7rem; border: 1px solid var(--line); border-radius: 8px; background: #fff; color: var(--ink);
}
textarea { resize: vertical; }

.areas { list-style: none; padding: 0; margin: 0.5rem 0 0; display: flex; flex-wrap: wrap; gap: 0.6rem; }
.area { display: flex; flex-direction: column; padding: 0.7rem 1rem; border-radius: 10px; background: var(--flag-bg); color: var(--flag); text-decoration: none; min-width: 160px; }
.area-name { font-weight: 700; }
.area-count { font-size: 0.88rem; }

.marker-card { display: block; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem; color: var(--ink); text-decoration: none; box-shadow: var(--shadow); }
.marker-card:hover { border-color: var(--brand); }
.mc-top { display: flex; justify-content: space-between; gap: 0.5rem; }
.mc-name { font-weight: 700; }
.mc-system { font-size: 0.8rem; color: var(--muted); text-align: right; }
.mc-value { font-size: 1.6rem; font-weight: 700; margin-top: 0.3rem; }
.unit { font-size: 0.9rem; font-weight: 500; color: var(--muted); }
.spark { width: 100%; height: 32px; margin: 0.4rem 0; }
.spark polyline { fill: none; stroke: var(--brand); stroke-width: 1.6; }
.spark circle { fill: var(--brand); }
.spark circle.out { fill: var(--flag); }

.badges { display: flex; flex-wrap: wrap; gap: 0.35rem; }
.badge { font-size: 0.78rem; padding: 0.15rem 0.5rem; border-radius: 999px; white-space: nowrap; }
.badge.ok { background: var(--ok-bg); color: var(--ok); }
.badge.flag { background: var(--flag-bg); color: var(--flag); }
.badge-k { font-weight: 700; }

.range-card .big { font-size: 1.25rem; font-weight: 700; }

.chart { width: 100%; height: auto; display: block; }
.chart text { font-size: 11px; fill: var(--muted); font-family: inherit; }
.c-grid { stroke: var(--line); stroke-width: 1; }
.c-axis { stroke: #b9c0bc; stroke-width: 1; }
.c-lab { fill: var(--lab); }
.c-personal { fill: rgba(106, 79, 179, 0.06); stroke: var(--personal); stroke-dasharray: 5 4; stroke-width: 1.2; }
.c-guide { stroke: var(--guide); stroke-dasharray: 6 4; stroke-width: 1.5; }
.c-context { fill: var(--context); }
.chart .c-context-label { font-size: 10px; }
.c-line { fill: none; stroke: var(--brand); stroke-width: 2; }
.c-dot { fill: var(--surface); stroke: var(--brand); stroke-width: 2; }
.c-dot-out { stroke: var(--flag); fill: var(--flag-bg); }
.chart .c-label { font-size: 11px; font-weight: 600; }
.chart .c-label-lab { fill: var(--brand); }
.chart .c-label-personal { fill: var(--personal); }
.chart .c-label-guide { fill: var(--guide); }

.table { width: 100%; border-collapse: collapse; font-size: 0.92rem; }
.table th, .table td { text-align: left; padding: 0.5rem; border-bottom: 1px solid var(--line); }
.table th { color: var(--muted); font-weight: 600; }

.tension-kind { text-transform: uppercase; letter-spacing: 0.06em; font-size: 0.75rem; font-weight: 700; color: var(--flag); margin-bottom: 0.5rem; }
.facts { display: grid; grid-template-columns: 1fr auto 1fr; gap: 0.75rem; align-items: stretch; margin-bottom: 0.75rem; }
.fact { background: var(--soft); border-radius: 10px; padding: 0.75rem; }
.fact p { margin: 0.25rem 0; }
.fact-k { font-size: 0.75rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); }
.vs { align-self: center; font-weight: 700; color: var(--flag); }
.question { border-left: 3px solid var(--brand); padding: 0.25rem 0 0.25rem 0.75rem; margin: 0.75rem 0; }
.inline-form { margin-top: 0.75rem; }
.closed-item { padding: 0.6rem 0; border-top: 1px solid var(--line); }
details summary { cursor: pointer; font-weight: 600; }

.tabs { display: flex; gap: 0.25rem; flex-wrap: wrap; margin-bottom: 0.75rem; }
.tabs a { padding: 0.45rem 0.8rem; border-radius: 8px; text-decoration: none; color: var(--ink); border: 1px solid var(--line); background: var(--surface); font-size: 0.92rem; }
.tabs a.active { background: var(--brand); color: #fff; border-color: var(--brand); }
.tag { font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.05em; font-weight: 700; color: var(--brand); }

.chips { list-style: none; padding: 0; display: flex; flex-wrap: wrap; gap: 0.5rem; }
.chip { background: var(--soft); border-radius: 999px; padding: 0.3rem 0.75rem; font-weight: 600; }
.timeline { list-style: none; padding: 0; margin: 0; }
.timeline li { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 0.8rem 1rem; margin-bottom: 0.6rem; }
.tl-date { font-size: 0.85rem; color: var(--muted); margin-right: 0.6rem; }
.tl-kind { font-size: 0.72rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em; color: var(--brand); margin-right: 0.6rem; }

.toast { position: fixed; bottom: 1.5rem; left: 50%; transform: translateX(-50%); background: var(--ink); color: #fff; padding: 0.7rem 1.1rem; border-radius: 10px; box-shadow: var(--shadow); z-index: 20; }

@media (max-width: 640px) {
  main { padding: 1rem; }
  .facts { grid-template-columns: 1fr; }
  .vs { text-align: center; }
  .hero h1 { font-size: 1.7rem; }
}
