@font-face {
  font-family: "Inter Tight";
  src: url("/fonts/of-inter-tight-800.woff2") format("woff2");
  font-weight: 800;
  font-style: normal;
  font-display: swap;
}
@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 {
  --field: #151513;
  --lime: #faff69;
  --grey: #414141;
  --panel: #1c1c19;
  --panel-hi: #242420;

  --ink: #f4f4ef;
  --ink-dim: #a8a8a0;
  --ink-faint: #8c8c85;

  --rule: #2b2b27;
  --rule-hi: #3a3a35;

  --warn-bg: #3a2f10;
  --warn-fg: #f2c94c;
  --info-bg: #17282b;
  --info-fg: #8fd3d8;
  --error-bg: #3b1a1a;
  --error-fg: #f08a80;

  --sans: "Inter", ui-sans-serif, system-ui, sans-serif;
  --tight: "Inter Tight", "Inter", 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(--field);
  color: var(--ink);
  font-family: var(--sans);
  -webkit-text-size-adjust: 100%;
  text-rendering: optimizeLegibility;
}

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

/* the copy fallback's textarea: selectable, invisible, off-canvas */
.offclip {
  position: fixed;
  top: 0;
  left: -9999px;
  width: 1px;
  height: 1px;
  opacity: 0;
  border: 0;
  padding: 0;
}

/* ---------- shell ---------- */

.ledger {
  height: 100vh;
  height: 100dvh;
  max-width: 1240px;
  margin: 0 auto;
  padding: clamp(16px, 2.6vw, 34px) clamp(14px, 3.4vw, 44px) 0;
  display: grid;
  grid-template-rows: auto auto auto minmax(0, 1fr) auto;
  overflow: hidden;
}

/* ---------- masthead ---------- */

.masthead {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 4px 18px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--rule);
}

.mark {
  font-family: var(--tight);
  font-weight: 800;
  font-size: 11.5px;
  letter-spacing: 0.17em;
  text-transform: uppercase;
  color: var(--lime);
}

.title {
  margin: 0;
  font-family: var(--tight);
  font-weight: 800;
  font-size: 11.5px;
  letter-spacing: 0.17em;
  text-transform: uppercase;
  color: var(--ink);
}

.claim {
  margin-left: auto;
  font-size: 12px;
  color: var(--ink-faint);
  letter-spacing: 0.02em;
}

/* ---------- toolbar ---------- */

.toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--rule);
}

.keyrow {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.klabel {
  font-family: var(--tight);
  font-weight: 800;
  font-size: 9.5px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--ink-faint);
  white-space: nowrap;
}

.kinput {
  width: clamp(140px, 22vw, 240px);
  min-width: 0;
  padding: 7px 10px;
  background: var(--panel);
  border: 1px solid var(--rule-hi);
  border-radius: 2px;
  color: var(--ink);
  font-family: var(--mono);
  font-size: 12.5px;
  line-height: 1.4;
}

.kinput::placeholder { color: var(--ink-faint); }

.kinput:focus-visible {
  outline: none;
  border-color: var(--lime);
}

.tsep {
  width: 1px;
  height: 22px;
  background: var(--rule-hi);
}

.tbtn {
  appearance: none;
  padding: 6px 12px;
  background: transparent;
  border: 1px solid var(--rule-hi);
  border-radius: 2px;
  color: var(--ink-dim);
  font-family: var(--mono);
  font-size: 11.5px;
  line-height: 1.5;
  letter-spacing: 0.01em;
  cursor: pointer;
  white-space: nowrap;
  transition: color 120ms linear, border-color 120ms linear, background-color 120ms linear;
}

.tbtn:hover,
.tbtn:focus-visible {
  color: var(--ink);
  border-color: var(--ink-faint);
  outline: none;
}

.tbtn.attach {
  color: var(--lime);
  border-color: var(--grey);
}

.tbtn.attach:hover,
.tbtn.attach:focus-visible {
  border-color: var(--lime);
}

.tbtn.drq[aria-pressed="true"] {
  background: var(--lime);
  border-color: var(--lime);
  color: var(--field);
  font-weight: 700;
}

.tbtn.copy.done {
  color: var(--lime);
  border-color: var(--lime);
}

.count {
  margin-left: auto;
  font-family: var(--mono);
  font-size: 11.5px;
  color: var(--ink-faint);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

/* ---------- drq note ---------- */

.drqnote {
  margin: 0;
  padding: 10px 0 12px;
  border-bottom: 1px solid var(--rule);
  font-size: 11.5px;
  line-height: 1.55;
  color: var(--ink-faint);
}

.drqnote code {
  font-family: var(--mono);
  font-size: 0.95em;
  color: var(--ink-dim);
}

/* ---------- sheet ---------- */

.sheet {
  min-height: 0;
  overflow: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--grey) transparent;
  overscroll-behavior: contain;
}

.sheet::-webkit-scrollbar { width: 9px; height: 9px; }
.sheet::-webkit-scrollbar-thumb { background: #2c2c28; border-radius: 5px; }
.sheet::-webkit-scrollbar-track { background: transparent; }

.grid {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
  font-family: var(--mono);
  font-size: 12.5px;
  line-height: 1.62;
}

.c-time { width: 15.5ch; }
.c-level { width: 8.5ch; }
.c-text { width: auto; }

.grid thead th {
  position: sticky;
  top: 0;
  z-index: 2;
  padding: 8px 14px 8px 0;
  background: var(--field);
  border-bottom: 1px solid var(--rule-hi);
  text-align: left;
  font-family: var(--tight);
  font-weight: 800;
  font-size: 9px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--ink-faint);
  white-space: nowrap;
}

.grid thead th:first-child { padding-left: 14px; }
.grid thead th:last-child { padding-right: 14px; }

.grid tbody td {
  padding: 6px 14px 6px 0;
  border-bottom: 1px solid var(--rule);
  vertical-align: top;
}

.grid tbody td:first-child { padding-left: 14px; }
.grid tbody td:last-child { padding-right: 14px; }

.grid tbody tr:last-child td { border-bottom: 1px solid var(--rule-hi); }

.td-time {
  color: var(--ink-faint);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.td-level { white-space: nowrap; }

.td-text {
  color: var(--ink-dim);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.empty .td-text { color: var(--ink-faint); }

/* level chips */

.chip {
  display: inline-block;
  padding: 1px 6px;
  border-radius: 2px;
  font-family: var(--mono);
  font-size: 9.5px;
  font-weight: 700;
  line-height: 1.5;
  letter-spacing: 0.09em;
  text-transform: uppercase;
}

.chip-info  { background: var(--info-bg);  color: var(--info-fg); }
.chip-warn  { background: var(--warn-bg);  color: var(--warn-fg); }
.chip-error { background: var(--error-bg); color: var(--error-fg); }
.chip-idle  { background: var(--panel);    color: var(--ink-faint); }
.chip-other { background: var(--panel-hi); color: var(--ink-dim); }

.row-warn  .td-time { color: var(--ink-dim); }
.row-error .td-text { color: var(--ink); }

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

.statusbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 12px;
  padding: 10px 0 12px;
  border-top: 1px solid var(--rule);
  font-family: var(--mono);
  font-size: 11.5px;
  color: var(--ink-faint);
}

.state {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  white-space: nowrap;
}

.led {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--ink-faint);
  flex: none;
}

.state[data-state="connecting"] .led { background: var(--warn-fg); }
.state[data-state="open"] .led {
  background: var(--lime);
  box-shadow: 0 0 0 3px rgba(250, 255, 105, 0.14);
}
.state[data-state="closed"] .led { background: var(--error-fg); }

.stext { color: var(--ink-dim); }
.state[data-state="open"] .stext { color: var(--lime); }

.sdiv { color: var(--rule-hi); }

.cadence,
.endpoint {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.endpoint { color: var(--ink-faint); }

.site {
  margin-left: auto;
  color: var(--ink-faint);
  text-decoration: none;
  border-bottom: 1px solid transparent;
  transition: color 120ms linear, border-color 120ms linear;
}

.site:hover,
.site:focus-visible {
  color: var(--ink);
  border-bottom-color: var(--lime);
  outline: none;
}

/* ---------- narrow ---------- */

@media (max-width: 720px) {
  .ledger { padding: 12px 12px 0; }
  .claim { display: none; }
  .count { margin-left: 0; }
  .kinput { width: 100%; }
  .keyrow { flex: 1 1 220px; }
  .tsep { display: none; }
  .c-time { width: 10.5ch; }
  .c-level { width: 7.5ch; }
  .grid { font-size: 11px; }
  .grid thead th,
  .grid tbody td { padding-left: 8px; padding-right: 6px; }
  .grid thead th:first-child,
  .grid tbody td:first-child { padding-left: 0; }
  .td-time { font-size: 10.5px; letter-spacing: -0.03em; }
  .td-text { white-space: pre-wrap; }
}

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