@font-face {
  font-family: "Inter";
  src: url("/fonts/of-inter-400.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Inter";
  src: url("/fonts/of-inter-700.woff2") format("woff2");
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "JetBrains Mono";
  src: url("/fonts/of-jetbrains-mono-400.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "JetBrains Mono";
  src: url("/fonts/of-jetbrains-mono-700.woff2") format("woff2");
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}

:root {
  --paper: #fbfbf7;
  --card: #ffffff;
  --ink: #16160f;
  --ink-soft: #4a4a40;
  --ink-faint: #6b6b60;
  --line: #d6d6cc;
  --line-soft: #e8e8e0;
  --lime: #faff69;
  --warn: #7a5200;
  --alert: #a3231b;
  --ok: #1d5c2a;
  --ui: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: "JetBrains Mono", ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}

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

html { height: 100%; }

body {
  margin: 0;
  min-height: 100%;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--ui);
  font-size: 17px;
  line-height: 1.6;
  -webkit-text-size-adjust: 100%;
}

:focus-visible {
  outline: 3px solid var(--ink);
  outline-offset: 2px;
}

.page {
  max-width: 800px;
  margin: 0 auto;
  padding: 28px 20px 48px;
}

/* ---- head ---- */

.kicker {
  margin: 0 0 6px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-faint);
}

h1 {
  margin: 0 0 10px;
  font-size: clamp(28px, 7vw, 40px);
  line-height: 1.1;
  letter-spacing: -0.015em;
  font-weight: 700;
}

.lede {
  margin: 0;
  max-width: 46ch;
  font-size: 18px;
  color: var(--ink-soft);
}

/* ---- status ---- */

.status {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  margin: 24px 0 0;
  padding: 16px 18px;
  background: var(--card);
  border: 2px solid var(--line);
  border-radius: 8px;
  font-size: 17px;
  line-height: 1.45;
}

.status .dot {
  flex: none;
  width: 14px;
  height: 14px;
  margin-top: 6px;
  border-radius: 50%;
  border: 2px solid var(--ink-faint);
  background: transparent;
}

.status[data-state="connecting"] .dot {
  border-color: var(--warn);
  background: var(--warn);
}
.status[data-state="open"] .dot {
  border-color: var(--ok);
  background: var(--ok);
}
.status[data-state="closed"] .dot,
.status[data-state="error"] .dot {
  border-color: var(--alert);
  background: var(--alert);
}

.status[data-state="open"] { border-color: var(--ok); }
.status[data-state="closed"],
.status[data-state="error"] { border-color: var(--alert); }

.status-text { flex: 1 1 auto; min-width: 0; }
.status-text strong { text-transform: capitalize; }

/* ---- steps ---- */

.step {
  margin-top: 32px;
  padding-top: 24px;
  border-top: 2px solid var(--line-soft);
}

.step h2 {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 0 0 12px;
  font-size: 21px;
  line-height: 1.25;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.num {
  flex: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--lime);
  color: var(--ink);
  font-family: var(--mono);
  font-size: 15px;
  font-weight: 700;
}

.label {
  display: block;
  margin-bottom: 8px;
  font-size: 16px;
  font-weight: 700;
}

/* ---- key form ---- */

.keyrow {
  display: flex;
  gap: 12px;
}

.input {
  flex: 1 1 auto;
  min-width: 0;
  height: 52px;
  padding: 0 16px;
  background: var(--card);
  color: var(--ink);
  border: 2px solid var(--ink);
  border-radius: 8px;
  font-family: var(--mono);
  font-size: 16px;
}

.input::placeholder {
  color: var(--ink-faint);
  opacity: 1;
}

.input:focus-visible {
  outline: 3px solid var(--ink);
  outline-offset: 2px;
  background: #fdfdf3;
}

.btn {
  flex: none;
  min-height: 52px;
  padding: 0 24px;
  border-radius: 8px;
  border: 2px solid var(--ink);
  background: var(--card);
  color: var(--ink);
  font-family: var(--ui);
  font-size: 17px;
  font-weight: 700;
  line-height: 1.2;
  cursor: pointer;
  transition: background-color 100ms linear, color 100ms linear;
}

.btn:hover { background: var(--lime); }

.btn:active { background: var(--ink); color: var(--paper); }

.btn-primary {
  background: var(--ink);
  color: var(--paper);
}
.btn-primary:hover {
  background: #000000;
  color: var(--lime);
}

.btn-quiet {
  min-height: 44px;
  padding: 0 16px;
  font-size: 15px;
  border-width: 2px;
}

.hint-note { margin-top: 4px; }

.hint {
  margin: 10px 0 0;
  font-size: 15px;
  line-height: 1.55;
  color: var(--ink-soft);
}

.hint code,
.drqstate code {
  padding: 2px 6px;
  background: var(--lime);
  color: var(--ink);
  border-radius: 4px;
  font-family: var(--mono);
  font-size: 0.94em;
  font-weight: 700;
}

.demoline {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 16px;
  margin-top: 12px;
}

.demoline .hint {
  margin: 0;
  font-size: 16px;
  font-weight: 700;
  color: var(--ink);
}

/* ---- DRQ ---- */

.checkrow {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-top: 14px;
  padding: 12px 16px;
  min-height: 60px;
  background: var(--card);
  border: 2px solid var(--ink);
  border-radius: 8px;
  cursor: pointer;
}

.checkrow:hover { background: #fdfdf3; }

.check {
  flex: none;
  width: 26px;
  height: 26px;
  margin: 0;
  accent-color: var(--ink);
  cursor: pointer;
}

.checklabel {
  display: block;
  flex: 1 1 auto;
  font-size: 17px;
  font-weight: 700;
  line-height: 1.35;
  cursor: pointer;
  user-select: none;
}

.drqstate {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 12px;
  margin: 14px 0 0;
  font-size: 15px;
  line-height: 1.5;
  color: var(--ink-soft);
}

.badge {
  display: inline-block;
  padding: 3px 9px;
  border-radius: 5px;
  border: 2px solid var(--ink);
  background: var(--card);
  color: var(--ink);
  font-family: var(--mono);
  font-size: 14px;
  font-weight: 700;
}

.badge[data-on="true"] {
  background: var(--lime);
}

/* ---- log ---- */

.step-log { padding-bottom: 8px; }

.loghead {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 4px 16px;
}

.loghead h2 { margin-bottom: 12px; }

.count {
  font-family: var(--mono);
  font-size: 14px;
  color: var(--ink-faint);
  white-space: nowrap;
}

.logtools {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 14px;
  margin: 4px 0 14px;
}

.copystate {
  font-size: 15px;
  font-weight: 700;
  color: var(--ok);
}

.copystate[data-fail="true"] { color: var(--alert); }

.logwrap {
  border: 2px solid var(--ink);
  border-radius: 8px;
  background: var(--card);
  overflow: hidden;
}

.empty {
  margin: 0;
  padding: 20px 18px;
  font-size: 16px;
  line-height: 1.5;
  color: var(--ink-soft);
}

.empty[hidden] { display: none; }

.log {
  max-height: 46vh;
  min-height: 120px;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: thin;
  scrollbar-color: var(--line) transparent;
}

.log:focus-visible {
  outline: 3px solid var(--ink);
  outline-offset: -3px;
}

.line {
  display: grid;
  grid-template-columns: auto auto minmax(0, 1fr);
  align-items: baseline;
  gap: 0 12px;
  padding: 9px 16px;
  border-bottom: 1px solid var(--line-soft);
  font-family: var(--mono);
  font-size: 14px;
  line-height: 1.55;
}

.line:last-child { border-bottom: 0; }
.line:first-child { padding-top: 14px; }

.lts {
  color: var(--ink-faint);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.llevel {
  padding: 0 7px;
  border-radius: 4px;
  border: 1px solid var(--line);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  white-space: nowrap;
}

.llevel[data-level="warn"] {
  color: var(--warn);
  border-color: var(--warn);
  background: #fdf6e6;
}

.llevel[data-level="error"] {
  color: var(--alert);
  border-color: var(--alert);
  background: #fdeeec;
}

.ltext {
  min-width: 0;
  color: var(--ink);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.line[data-level="error"] .ltext { color: var(--alert); font-weight: 700; }

.copyarea {
  position: fixed;
  top: 0;
  left: 0;
  width: 1px;
  height: 1px;
  padding: 0;
  border: 0;
  opacity: 0;
  pointer-events: none;
}

/* ---- foot ---- */
.foot {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px 20px;
  margin-top: 40px;
  padding-top: 18px;
  border-top: 2px solid var(--line-soft);
  font-size: 14px;
  color: var(--ink-faint);
}

.site {
  color: var(--ink);
  font-weight: 700;
  text-decoration: none;
  border-bottom: 2px solid var(--lime);
  padding-bottom: 1px;
}

.site:hover { background: var(--lime); }
.site:focus-visible { outline: 3px solid var(--ink); outline-offset: 2px; }

/* ---- narrow: 320px and up ---- */

@media (max-width: 560px) {
  .page { padding: 22px 14px 40px; }
  .lede { font-size: 17px; }

  .keyrow { flex-direction: column; }
  .keyrow .btn { width: 100%; }

  .input { height: 54px; font-size: 16px; }

  .btn-quiet {
    display: block;
    width: 100%;
  }

  .demoline .btn-quiet { margin-top: 4px; }

  .line {
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 4px 10px;
    padding: 10px 12px;
  }

  .ltext {
    grid-column: 1 / -1;
    font-size: 13.5px;
  }

  .lts { font-size: 12.5px; }

  .loghead { gap: 2px 12px; }
  .logtools .btn { width: 100%; }
  .copystate { width: 100%; }

  .log { max-height: 56vh; }
}

@media (min-width: 561px) and (max-width: 720px) {
  .line { gap: 0 10px; }
  .ltext { font-size: 13.5px; }
}

@media (prefers-reduced-motion: reduce) {
  .btn { transition: none; }
}
