@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: "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;
  --rule: #2b2b27;
  --ink: #f4f4ef;
  --row-h: 21px;
  --sans: "Inter", 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;
  height: 100%;
  background: var(--field);
  color: var(--ink);
  -webkit-text-size-adjust: 100%;
}

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

.book {
  height: 100vh;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* ---------- ribbon ---------- */

.ribbon {
  flex: none;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 22px;
  padding: 9px clamp(10px, 1.6vw, 20px);
  background: var(--panel);
  border-bottom: 1px solid var(--rule);
}

.brand {
  font-family: var(--tight);
  font-weight: 800;
  font-size: 11px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--lime);
  flex: none;
}

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

.klabel {
  font-family: var(--sans);
  font-size: 10.5px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink);
  opacity: 0.42;
}

.kinput {
  width: 15ch;
  padding: 3px 6px;
  border: 1px solid var(--rule);
  background: var(--field);
  color: var(--ink);
  font-family: var(--mono);
  font-size: 11.5px;
  line-height: 1.5;
  border-radius: 2px;
}
.kinput::placeholder { color: var(--ink); opacity: 0.24; }
.kinput:focus-visible {
  outline: none;
  border-color: var(--lime);
}

.kbtn,
.drq,
.copy {
  padding: 3px 10px;
  border: 1px solid var(--rule);
  background: var(--panel-hi);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 11px;
  letter-spacing: 0.06em;
  border-radius: 2px;
  cursor: pointer;
  transition: border-color 100ms linear, color 100ms linear, background 100ms linear;
}
.kbtn:hover,
.drq:hover,
.copy:hover { border-color: var(--grey); }
.kbtn:focus-visible,
.drq:focus-visible,
.copy:focus-visible {
  outline: 1px solid var(--lime);
  outline-offset: 1px;
}

.khint {
  font-family: var(--sans);
  font-size: 10.5px;
  color: var(--ink);
  opacity: 0.3;
  white-space: nowrap;
}

.tools {
  display: flex;
  align-items: center;
  gap: 8px;
}

.drq { min-width: 13ch; text-align: center; }
.drq[aria-pressed="true"] {
  background: var(--lime);
  border-color: var(--lime);
  color: #14140f;
  font-weight: 700;
}

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

.status {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 7px;
  font-family: var(--mono);
  font-size: 10.5px;
  color: var(--ink);
  opacity: 0.72;
  white-space: nowrap;
}

.led {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--grey);
  flex: none;
}
.status[data-state="connecting"] .led { background: #d8c24a; animation: pulse 1.1s ease-in-out infinite; }
.status[data-state="open"] .led { background: var(--lime); box-shadow: 0 0 6px rgba(250, 255, 105, 0.55); }
.status[data-state="closed"] .led { background: #c85a4a; }
.status[data-state="closed"] .stext { color: #e58e80; }

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.25; }
}

.sdiv { opacity: 0.3; }
.surl { opacity: 0.4; }

/* ---------- formula strip ---------- */

.formula {
  flex: none;
  display: flex;
  align-items: center;
  gap: 0;
  height: 27px;
  background: var(--panel-hi);
  border-bottom: 1px solid var(--rule);
  font-family: var(--mono);
  font-size: 11.5px;
}

.namebox {
  flex: none;
  width: 74px;
  padding: 0 8px;
  height: 100%;
  display: flex;
  align-items: center;
  border-right: 1px solid var(--rule);
  color: var(--lime);
  font-size: 11px;
  letter-spacing: 0.04em;
  background: var(--panel);
  overflow: hidden;
  white-space: nowrap;
}

.fx {
  flex: none;
  padding: 0 8px;
  height: 100%;
  display: flex;
  align-items: center;
  border-right: 1px solid var(--rule);
  color: var(--ink);
  opacity: 0.34;
  font-style: italic;
  font-size: 11px;
}

.strip {
  flex: 1 1 auto;
  min-width: 0;
  padding: 0 10px;
  height: 100%;
  display: flex;
  align-items: center;
  overflow-x: auto;
  overflow-y: hidden;
  white-space: pre;
  color: var(--ink);
  opacity: 0.88;
  scrollbar-width: none;
}
.strip::-webkit-scrollbar { height: 0; }
.strip.placeholder { opacity: 0.32; }

/* ---------- grid ---------- */

.gridwrap {
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
  position: relative;
  scrollbar-width: thin;
  scrollbar-color: #33332e transparent;
  overscroll-behavior: contain;
}
.gridwrap::-webkit-scrollbar { width: 11px; height: 11px; }
.gridwrap::-webkit-scrollbar-thumb { background: #33332e; border-radius: 0; }
.gridwrap::-webkit-scrollbar-track { background: var(--field); }

.grid {
  border-collapse: separate;
  border-spacing: 0;
  width: 100%;
  table-layout: fixed;
  font-family: var(--mono);
  font-size: 11.5px;
  line-height: 1;
}

.c-gutter { width: 42px; }
.c-time { width: 164px; }
.c-level { width: 68px; }
.c-text { width: auto; }

.grid thead th {
  position: sticky;
  top: 0;
  z-index: 3;
  height: 23px;
  padding: 0 7px;
  text-align: left;
  vertical-align: middle;
  background: var(--panel);
  border-bottom: 1px solid var(--rule);
  border-right: 1px solid var(--rule);
  font-family: var(--sans);
  font-size: 10px;
  font-weight: 400;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: #8f8f85;
  white-space: nowrap;
  overflow: hidden;
}

.grid thead th:last-child { border-right: 0; }

.grid thead th .letter {
  display: inline-block;
  min-width: 2.4ch;
  margin-right: 0.9ch;
  padding: 1px 3px;
  background: var(--panel-hi);
  color: var(--lime);
  font-family: var(--mono);
  font-size: 9.5px;
  line-height: 1.3;
  text-align: center;
  opacity: 0.95;
  letter-spacing: 0;
}

.grid thead th .colname {
  font-size: 9.5px;
  letter-spacing: 0.14em;
  opacity: 0.8;
}

.grid thead th.rn.head {
  position: sticky;
  left: 0;
  z-index: 5;
  padding: 0;
  background: var(--panel);
  border-right: 1px solid var(--rule);
}

.grid thead th.rn.head::before {
  content: "";
  display: block;
  width: 0;
  height: 0;
  margin: 0 auto;
  border-style: solid;
  border-width: 0 7px 7px 0;
  border-color: transparent var(--grey) transparent transparent;
}

.grid tbody tr {
  cursor: default;
}

.grid tbody td {
  height: var(--row-h);
  max-height: var(--row-h);
  padding: 0 7px;
  vertical-align: middle;
  border-bottom: 1px solid #1e1e1b;
  border-right: 1px solid #1e1e1b;
  background: var(--field);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-variant-numeric: tabular-nums;
}

.grid tbody td:last-child { border-right: 0; }

.grid tbody tr:nth-child(even) td { background: #181816; }

.rn {
  position: sticky;
  left: 0;
  z-index: 2;
  width: 42px;
  padding: 0 6px 0 0;
  text-align: right;
  color: var(--ink);
  opacity: 0.34;
  background: var(--panel) !important;
  border-right: 1px solid var(--rule) !important;
  font-size: 10px;
  user-select: none;
}

td.t-time { color: var(--ink); opacity: 0.62; }
td.t-level { text-transform: lowercase; }

.lv-info { color: #9dc9a4; }
.lv-warn { color: #e3c25b; }
.lv-error { color: #e0785f; }
.lv-debug { color: #8a8a80; }

td.t-text { color: var(--ink); opacity: 0.92; }

.grid tbody tr:hover td { background: #20201c; }
.grid tbody tr:hover td.rn { background: var(--panel) !important; }

.grid tbody tr.sel td {
  background: #2a2a1c;
  border-bottom-color: #3a3a26;
}
.grid tbody tr.sel td.t-text { color: var(--lime); opacity: 1; }
.grid tbody tr.sel td.rn {
  background: var(--lime) !important;
  color: #14140f;
  opacity: 1;
  font-weight: 700;
}
.grid tbody tr.sel td.t-time,
.grid tbody tr.sel td.t-level { opacity: 1; }

.gridwrap:focus-visible { outline: 1px solid var(--lime); outline-offset: -1px; }

.empty {
  margin: 0;
  padding: 20px 12px;
  font-family: var(--mono);
  font-size: 11.5px;
  color: var(--ink);
  opacity: 0.3;
}
.empty.hidden { display: none; }

.clip {
  position: fixed;
  top: 0;
  left: -9999px;
  width: 1px;
  height: 1px;
  opacity: 0;
}

/* ---------- foot ---------- */

.foot {
  flex: none;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  padding: 6px clamp(10px, 1.6vw, 20px);
  background: var(--panel);
  border-top: 1px solid var(--rule);
  font-family: var(--sans);
  font-size: 10.5px;
  line-height: 1.45;
}

.note {
  color: var(--ink);
  opacity: 0.34;
  max-width: 100ch;
}
.note code {
  font-family: var(--mono);
  font-size: 0.95em;
  color: var(--lime);
  opacity: 0.75;
}

.site {
  flex: none;
  color: var(--ink);
  opacity: 0.5;
  text-decoration: none;
  border-bottom: 1px solid var(--grey);
  padding-bottom: 1px;
}
.site:hover,
.site:focus-visible {
  opacity: 1;
  border-bottom-color: var(--lime);
  outline: none;
}

/* ---------- phone ---------- */

@media (max-width: 760px) {
  .ribbon { gap: 8px 14px; padding: 8px 10px; }
  .khint { display: none; }
  .status { width: 100%; margin-left: 0; }
  .c-time { width: 132px; }
  .c-level { width: 58px; }
  .c-gutter { width: 34px; }
  .grid { font-size: 9.5px; min-width: 560px; }
  .grid tbody td { padding: 0 5px; }
  .rn { width: 34px; }
  .formula { height: 25px; }
  .namebox { width: 58px; }
  .foot { padding: 6px 10px; }
  .note { font-size: 10px; }
  .site { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  .status[data-state="connecting"] .led { animation: none; }
  .kbtn, .drq, .copy { transition: none; }
}
