:root {
  --ink: #1b2421;
  --ink-soft: #3e4944;
  --paper: #efece4;
  --card: #f7f6f2;
  --white: #fffcf8;
  --line: #d7d1c5;
  --accent: #1f4d3a;
  --accent-ink: #f6f3ea;
  --danger: #8c2f2f;
  --danger-bg: #f8e8e4;
  --ok: #1d6b45;
  --ok-bg: #e5f2ea;
  --warn: #7a5412;
  --warn-bg: #f8efd8;
  --focus: #1f4d3a;
  color-scheme: light;
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

html, body { margin: 0; padding: 0; }

body {
  background: var(--paper);
  color: var(--ink);
  font-family: "Segoe UI", "Helvetica Neue", Arial, sans-serif;
  font-size: 16.5px;
  line-height: 1.45;
}

img, textarea, input, select { max-width: 100%; }

.wrap {
  width: min(1120px, calc(100% - 32px));
  margin: 0 auto;
}

.skip {
  position: absolute;
  left: 12px;
  top: -48px;
  background: white;
  color: var(--ink);
  padding: 8px 12px;
  z-index: 5;
}

.skip:focus, .skip:focus-within { top: 12px; }

.topbar { background: var(--accent); color: var(--accent-ink); }

.top {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: flex-end;
  padding: 22px 0 18px;
}

.eyebrow {
  margin: 0 0 4px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-size: 0.74rem;
}

h1 {
  margin: 0;
  font-family: Georgia, "Iowan Old Style", Palatino, "Palatino Linotype", serif;
  font-size: 2rem;
  font-weight: 600;
  letter-spacing: -0.02em;
  line-height: 1.15;
}

h1 .badge {
  font-family: "Segoe UI", "Helvetica Neue", Arial, sans-serif;
  font-size: 0.68rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  border: 1px solid rgba(246, 243, 234, 0.55);
  border-radius: 999px;
  padding: 3px 8px;
  vertical-align: middle;
  margin-left: 8px;
}

.top-note {
  margin: 0;
  max-width: 280px;
  text-align: right;
  font-size: 0.92rem;
}

.offline {
  background: #f4e2c4;
  color: #2a2116;
  border-bottom: 1px solid #e0c48a;
  padding: 12px 0;
}

.offline strong {
  display: block;
  font-size: 1.08rem;
}

.offline span { display: block; margin-top: 2px; }

main { padding-bottom: 28px; }

h2, h3, h4 { line-height: 1.25; }

h2 { font-size: 1.35rem; margin: 0 0 8px; }

h3 { font-size: 1.05rem; margin: 0 0 6px; }

.lede { margin-top: 0; max-width: 68ch; }

.views {
  margin: 16px 0;
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}

#diagnostics-dialog { max-height: calc(100vh - 32px); overflow: auto; }

.diag-list, .diag-errors { margin: 8px 0 12px; padding-left: 1.1rem; }

.diag-errors { max-height: 220px; overflow: auto; }

.diag-stack {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.82rem;
  background: #f3f0e8;
  padding: 8px;
  border-radius: 6px;
}

.tablist { display: flex; flex-wrap: wrap; gap: 8px; }

.tablist button[aria-selected="true"] {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-ink);
}

h2[tabindex="-1"]:focus { outline: none; }

button, input, select, textarea { font: inherit; color: inherit; }

button {
  min-height: 44px;
  padding: 0.55rem 0.9rem;
  border-radius: 6px;
  border: 1px solid #c9c3b6;
  background: var(--white);
  cursor: pointer;
}

button.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-ink);
}

button:disabled, button.primary:disabled {
  background: #e4e0d6;
  color: #6a645b;
  border-color: #d5d0c6;
  cursor: not-allowed;
}

button:focus-visible,
a:focus-visible,
input:focus-visible,
textarea:focus-visible,
select:focus-visible,
summary:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}

.cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 12px;
}

.card, .panel, .compare article, .review, .device {
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.card {
  border-top: 4px solid var(--mark, var(--accent));
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}

.card h3 { font-size: 1.3rem; }

.card p { margin: 0; }

.handle, .domain, .mono {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.92rem;
}

.card .status, .card .meta { color: var(--ink-soft); font-size: 0.92rem; }

.card button { margin-top: 10px; }

.device, .panel { padding: 14px 16px; margin-top: 16px; }

.confirm-box {
  margin-top: 10px;
  padding: 10px;
  background: var(--warn-bg);
  border-radius: 6px;
}

.confirm-box p { margin: 0 0 8px; }

.confirm-box button + button { margin-left: 8px; }

.mark-note, .hint, footer, .muted { color: var(--ink-soft); }

.mark-note, .hint { margin: 8px 0 0; font-size: 0.92rem; overflow-wrap: anywhere; }

.ward-switch {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 8px;
  margin: 8px 0 14px;
}

.ward-switch button {
  text-align: left;
  border-top: 4px solid var(--mark, var(--accent));
  background: var(--card);
  min-width: 0;
}

.ward-switch button[aria-pressed="true"] {
  background: white;
  box-shadow: inset 0 0 0 2px var(--accent);
}

.ward-switch button[aria-pressed="true"] .num { color: var(--accent); }

.ward-switch .num { display: block; font-weight: 700; }

.ward-switch .mini {
  display: block;
  overflow-wrap: anywhere;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.75rem;
  color: var(--ink-soft);
}

.desk {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(280px, 0.8fr);
  gap: 16px;
  align-items: start;
}

.dest {
  border: 1px solid var(--line);
  border-top: 4px solid var(--mark, var(--accent));
  background: var(--card);
  border-radius: 8px;
  padding: 12px 14px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px 16px;
}

.dest .kicker, .kicker {
  margin: 0;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-size: 0.72rem;
  color: var(--ink-soft);
  grid-column: 1 / -1;
}

.dest .dest-ward { margin: 0; font-size: 1.45rem; font-weight: 700; }

.dest p { margin: 0; }

.pair {
  margin: 10px 0 0;
  padding: 10px 12px;
  border-radius: 6px;
}

.pair.ok { background: var(--ok-bg); }

.pair.bad { background: var(--danger-bg); }

.composer fieldset {
  border: 1px solid var(--line);
  border-radius: 8px;
  margin: 14px 0;
  padding: 10px 12px 12px;
}

.composer legend { font-weight: 700; padding: 0 4px; }

.checks { display: flex; flex-wrap: wrap; gap: 8px 16px; }

.checks label { display: flex; align-items: center; gap: 8px; min-height: 44px; font-weight: 600; }

.field { display: flex; flex-direction: column; gap: 6px; margin: 14px 0; }

.field > label, .check-label { font-weight: 700; }

textarea, input[type="text"], select, input[type="file"] {
  width: 100%;
  border: 1px solid #c9c3b6;
  background: white;
  border-radius: 6px;
  padding: 10px 12px;
}

textarea { min-height: 10rem; resize: vertical; line-height: 1.45; }

.meter {
  height: 6px;
  background: #e4e0d6;
  border-radius: 99px;
  overflow: hidden;
}

.meter span { display: block; height: 100%; width: 0; background: var(--ok); }

.meter.over span { background: var(--danger); }

.meter.reference span { background: #8aa399; }

.count-over { color: var(--danger); font-weight: 700; }

.count-ok { color: var(--ok); font-weight: 700; }

.form-note { min-height: 1.2em; margin: 8px 0; }

.review {
  padding: 14px;
  position: sticky;
  top: 12px;
}

.review button { width: 100%; margin-top: 8px; }

#check-list {
  list-style: none;
  padding: 0;
  margin: 8px 0 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

#check-list li { padding: 8px 10px; border-radius: 6px; }

#check-list .block { background: var(--danger-bg); }

#check-list .pass { background: var(--ok-bg); }

#check-list .note { background: var(--warn-bg); }

#check-list a { color: inherit; }

.simulate-note {
  background: var(--warn-bg);
  border: 1px dashed #c4a15a;
  padding: 8px 10px;
  border-radius: 6px;
  margin: 12px 0 0;
}

.compare-wrap { margin-top: 18px; }

.compare {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.compare article { padding: 12px; min-width: 0; }

.compare img {
  width: 100%;
  height: auto;
  background: #e7e2d8;
  border-radius: 4px;
}

.copy {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  font-family: inherit;
  margin: 0 0 8px;
  background: #f3f0e8;
  padding: 10px;
  border-radius: 6px;
}

.channel-label {
  margin: 8px 0 4px;
  font-size: 0.78rem;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--ink-soft);
}

.activity-list { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 8px; }

.activity-list li {
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
}

.activity-list time { display: block; color: var(--ink-soft); font-size: 0.85rem; }

.empty {
  background: var(--white);
  border: 1px dashed var(--line);
  border-radius: 8px;
  padding: 14px;
}

#self-check {
  background: var(--danger-bg);
  border: 1px solid var(--danger);
  padding: 10px 12px;
  border-radius: 8px;
}

footer { margin: 22px 0 8px; font-size: 0.92rem; }

dialog {
  width: min(680px, calc(100vw - 24px));
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
  background: var(--card);
}

dialog img { width: 100%; height: auto; max-height: 75vh; object-fit: contain; }

dialog::backdrop { background: rgba(20, 24, 22, 0.72); }

.dialog-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }

.action-note {
  background: var(--ok-bg);
  border: 1px solid #b7d7c4;
  border-radius: 8px;
  padding: 10px 12px;
  margin: 0 0 12px;
}

.session-note {
  background: var(--warn-bg);
  border-radius: 8px;
  padding: 10px 12px;
}

@media (max-width: 900px) {
  .desk { grid-template-columns: 1fr; }
  .review { position: static; }
}

@media (max-width: 720px) {
  .compare { grid-template-columns: 1fr; }
  .ward-switch { grid-template-columns: 1fr 1fr; }
  .ward-switch button:last-child { grid-column: 1 / -1; }
  .top { flex-direction: column; align-items: flex-start; }
  .top-note { text-align: left; max-width: none; }
  h1 { font-size: 1.65rem; }
  .dest { grid-template-columns: 1fr; }
}

@media (max-width: 420px) {
  .wrap { width: min(1120px, calc(100% - 20px)); }
  .dialog-actions { flex-direction: column; }
  .dialog-actions button { width: 100%; }
}

.auth, .panel {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 18px;
  margin: 18px 0;
}
.auth label, .field label, .composer label { display: block; font-weight: 650; margin: 12px 0 4px; }
.composer input[type="text"], .composer textarea, .composer select { width: 100%; display: block; }
.auth input, .field input, .field textarea, .field select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 10px;
  font: inherit;
  background: var(--white);
}
.row-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
button, .primary {
  font: inherit;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--white);
  padding: 8px 12px;
  cursor: pointer;
}
button.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.tablist { display: flex; flex-wrap: wrap; gap: 8px; }
.tablist button[aria-selected="true"] { background: var(--accent); color: var(--accent-ink); }
.ward-switch { display: flex; flex-wrap: wrap; gap: 8px; margin: 8px 0 12px; }
.meter { height: 8px; background: #e4dfd4; border-radius: 99px; overflow: hidden; }
.meter span { display: block; height: 100%; background: var(--accent); }
.check-list { padding-left: 1.1rem; }
.card-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px; }
.mini { background: var(--white); border: 1px solid var(--line); border-radius: 12px; padding: 12px; }
@media (max-width: 800px) {
  .desk { display: block; }
  .top { flex-direction: column; align-items: flex-start; }
}

.with-help {
  position: relative;
  display: inline-block;
  max-width: 100%;
  vertical-align: top;
  margin: 8px 8px 0 0;
  padding-top: 18px;
}

.with-help.is-block {
  display: block;
  width: 100%;
  margin-right: 0;
}

.with-help.skip {
  width: auto;
  max-width: max-content;
}

.with-help > label.check-label { padding-right: 8px; }

button.help-dot,
.ward-switch button.help-dot,
.tablist button.help-dot,
.card button.help-dot,
.row-actions button.help-dot,
dialog button.help-dot {
  position: absolute;
  z-index: 4;
  top: -26px;
  right: 0;
  width: 44px;
  max-width: 100%;
  height: 44px;
  min-height: 44px;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  color: transparent;
  line-height: 0;
  text-align: left;
  cursor: help;
}

button.help-dot:hover,
button.help-dot:focus,
.ward-switch button.help-dot:hover,
.tablist button.help-dot:hover {
  background: transparent;
  border: 0;
  color: transparent;
}

button.help-dot:focus-visible {
  outline: none;
}

button.help-dot:focus-visible .help-glyph {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}

.help-glyph {
  position: absolute;
  right: 0;
  bottom: 0;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #c1121f;
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  line-height: 16px;
  text-align: center;
  pointer-events: none;
}

.help-tip {
  position: absolute;
  z-index: 6;
  top: 20px;
  left: 0;
  right: auto;
  width: max-content;
  max-width: min(280px, calc(100vw - 28px));
  padding: 8px 10px;
  border: 1px solid #c1121f;
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  font-size: 0.95rem;
  font-weight: 400;
  line-height: 1.35;
  text-align: left;
  white-space: normal;
  overflow-wrap: anywhere;
  box-shadow: 0 8px 22px rgba(27, 36, 33, 0.16);
}

.help-tip.align-end { left: auto; right: 0; }

.help-tip.open-up { top: auto; bottom: calc(100% - 8px); }

.update-banner {
  margin: 12px 0;
  padding: 0.75rem 0.9rem;
  background: var(--warn-bg);
  color: var(--warn);
  border: 1px solid #e0c48a;
  border-radius: 8px;
  font-weight: 700;
}

label.check {
  display: flex;
  gap: 8px;
  align-items: flex-start;
  font-weight: 600;
  margin: 0.7rem 0;
}
