/* Green-bar ledger paper, set in IBM Plex: the sheet reads like a line-printer listing you can type into.
   The one loud thing is the thread: each row's brands sit on a line like stations, and a lit lamp means the site answers. */

@font-face { font-family: 'Plex Sans'; src: url('/fonts/plex-sans.woff2') format('woff2'); font-weight: 100 700; font-display: swap; }
@font-face { font-family: 'Plex Mono'; src: url('/fonts/plex-mono-400.woff2') format('woff2'); font-weight: 400; font-display: swap; }
@font-face { font-family: 'Plex Mono'; src: url('/fonts/plex-mono-500.woff2') format('woff2'); font-weight: 500; font-display: swap; }

:root {
  color-scheme: light;
  --paper: #fbfcf8;
  --bar: #e7f1e5;
  --rule: #c5d7c6;
  --rule-strong: #8fb399;
  --ink: #14241b;
  --ink-2: #51665a;
  --ink-3: #8b9d91;
  --ledger: #1d5c3f;
  --ledger-deep: #154630;
  --pen: #1b3fd1;
  --up: #12a150;
  --down: #c2412d;
  --thread: #6a9c7f;
  --gutter: 44px;
  --col: 236px;
  --row-h: 56px;
  --sans: 'Plex Sans', system-ui, sans-serif;
  --mono: 'Plex Mono', ui-monospace, monospace;
}

*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body { background: var(--paper); color: var(--ink); font: 14px/1.35 var(--sans); -webkit-font-smoothing: antialiased; }
#app { height: 100%; }
button, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--pen); outline-offset: 2px; }

/* ---- wordmark: two stations on a thread */
.wordmark { display: flex; align-items: center; gap: 14px; margin: 0; font-weight: 600; font-size: 44px; line-height: 1; letter-spacing: -0.025em; color: var(--ledger); }
.wordmark-glyph { position: relative; flex: none; width: 1em; height: 0.3em; background: linear-gradient(currentColor, currentColor) center / 100% 0.07em no-repeat; }
.wordmark-glyph::before, .wordmark-glyph::after { content: ''; position: absolute; top: 0; width: 0.3em; height: 0.3em; border-radius: 50%; }
.wordmark-glyph::before { left: 0; background: var(--paper); border: 0.07em solid currentColor; }
.wordmark-glyph::after { right: 0; background: var(--up); box-shadow: 0 0 0 0.07em var(--paper); }
.wordmark-small { font-size: 17px; gap: 9px; letter-spacing: -0.01em; color: #fff; }
.wordmark-small .wordmark-glyph { width: 26px; height: 9px; background-size: 100% 2px; }
.wordmark-small .wordmark-glyph::before, .wordmark-small .wordmark-glyph::after { width: 9px; height: 9px; }
.wordmark-small .wordmark-glyph::before { background: var(--ledger); border-width: 2px; }
.wordmark-small .wordmark-glyph::after { background: #56e08f; box-shadow: none; }

/* ---- sign-in: a blank page of the same paper */
.gate { min-height: 100dvh; display: grid; place-content: center; padding: 24px;
  background: repeating-linear-gradient(var(--paper) 0 var(--row-h), var(--bar) var(--row-h) calc(var(--row-h) * 2)); }
.gate-form { width: min(360px, calc(100vw - 48px)); display: grid; gap: 12px; }
.gate-lede { margin: 4px 0 20px; font-size: 16px; line-height: 1.45; color: var(--ink-2); }
.gate-btn { height: 48px; border: 0; border-radius: 3px; background: var(--ledger); color: #fff; font-weight: 600; font-size: 15px; transition: background 0.15s; }
.gate-btn:hover { background: var(--ledger-deep); }
.gate-btn:disabled { opacity: 0.6; cursor: progress; }
.gate-msg { min-height: 40px; margin: 4px 0 0; color: var(--down); }
.gate-msg a { color: var(--pen); }

/* ---- frame */
.sheet { display: grid; grid-template-columns: minmax(0, 1fr); grid-template-rows: auto auto minmax(0, 1fr) auto; height: 100dvh; }
.topbar { display: flex; align-items: center; gap: 16px; height: 48px; padding: 0 16px; background: var(--ledger); color: #fff; }
.find { flex: 0 1 320px; min-width: 0; height: 30px; margin-left: 12px; padding: 0 10px; border: 1px solid rgb(255 255 255 / 0.28); border-radius: 3px;
  background: rgb(255 255 255 / 0.1); color: #fff; }
.find::placeholder { color: rgb(255 255 255 / 0.66); }
.find:focus-visible { outline-color: #fff; outline-offset: 0; background: rgb(255 255 255 / 0.18); }
.wallet { margin-left: auto; font: 400 12px var(--mono); color: rgb(255 255 255 / 0.8); }
.signout { height: 30px; padding: 0 12px; border: 1px solid rgb(255 255 255 / 0.4); border-radius: 3px; background: transparent; color: #fff; }
.signout:hover { background: rgb(255 255 255 / 0.14); }
.signout:focus-visible { outline-color: #fff; }

.fx { display: flex; align-items: stretch; height: 36px; border-bottom: 1px solid var(--rule); }
.fx-ref { flex: none; width: 72px; display: grid; place-items: center; border-right: 1px solid var(--rule); font: 500 12px var(--mono); color: var(--ink-2); }
.fx-text { flex: 1; min-width: 0; align-self: center; padding: 0 12px; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; color: var(--ink-2); }
.fx-text.is-error { color: var(--down); }
.fx-details { display: none; flex: none; margin: 4px 8px; padding: 0 10px; border: 1px solid var(--rule-strong); border-radius: 3px; background: var(--paper); color: var(--ledger); }

.work { display: grid; grid-template-columns: minmax(0, 1fr) 340px; min-height: 0; }

/* ---- grid */
.grid { overflow: auto; min-height: 0; outline: none; overscroll-behavior: contain; }
.row { display: grid; grid-template-columns: var(--gutter) repeat(var(--cols), var(--col)) minmax(24px, 1fr);
  min-width: max-content; height: var(--row-h); background: var(--paper); }
.row:nth-child(odd):not(.row-head) { background: var(--bar); }
.row > * { border-right: 1px solid var(--rule); border-bottom: 1px solid var(--rule); min-width: 0; }
.row > .fill { border-right: 0; }

.row-head { position: sticky; top: 0; z-index: 3; height: 34px; }
.row-head > * { border-bottom: 2px solid var(--ledger); }
.colhead { display: flex; align-items: center; gap: 10px; padding: 0 14px; font-weight: 500; font-size: 12.5px; color: var(--ledger); }
.colhead-letter { font: 400 11px var(--mono); color: var(--ink-3); }
.gutter { position: sticky; left: 0; z-index: 2; display: grid; place-items: center; background: inherit; font: 400 11px var(--mono); color: var(--ink-3); }
.row-new .gutter { color: transparent; }

.cell { position: relative; display: flex; align-items: center; padding-left: 14px; cursor: cell; scroll-margin: 40px 8px 8px 52px; }
.cell.is-inert { cursor: default; }
.cell.is-selected { z-index: 1; outline: 2px solid var(--pen); outline-offset: -2px; background: color-mix(in srgb, var(--pen) 6%, transparent); }
.cell.is-selected::after { content: ''; position: absolute; right: -3px; bottom: -3px; width: 7px; height: 7px; background: var(--pen); box-shadow: 0 0 0 1px var(--paper); }

.stn { flex: none; width: 10px; height: 10px; margin-right: 10px; border-radius: 50%; }
.stn.is-up { background: var(--up); color: var(--up); box-shadow: 0 0 0 3px color-mix(in srgb, var(--up) 22%, transparent); }
.stn.is-fwd { background: var(--paper); border: 2px solid var(--up); color: var(--up); }
.stn.is-down { background: var(--paper); border: 2px solid var(--down); color: var(--down); }
.stn.is-wait { background: var(--paper); border: 2px solid var(--ink-3); color: var(--ink-3); }
.stn.is-none { width: 6px; height: 6px; margin: 0 12px 0 2px; background: var(--ink-3); color: var(--ink-3); }

.lbl { display: flex; flex-direction: column; flex: 0 1 auto; min-width: 0; }
.name, .dom { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.name { color: var(--ink-2); }
.is-current .name { color: var(--ink); font-weight: 600; }
.dom { font: 400 12px/1.4 var(--mono); color: var(--ink-2); text-decoration: none; }
.dom:hover { color: var(--pen); text-decoration: underline; }

/* the thread: out of this cell to its right edge, and from the next cell's left edge into its station */
.track { flex: 1 1 16px; min-width: 16px; height: 2px; margin-left: 10px; background: var(--thread); transform-origin: left center; }
.cell.has-prev::before { content: ''; position: absolute; left: -1px; top: 50%; width: 15px; height: 2px; margin-top: -1px; background: var(--thread); transform-origin: left center; }

.plus { font-size: 18px; line-height: 1; color: var(--ink-3); opacity: 0.5; }
.row:hover .plus, .is-selected .plus { opacity: 1; color: var(--ledger); }
.edit { flex: 1; min-width: 0; margin-right: 12px; padding: 0; border: 0; outline: 0; background: transparent; font-weight: 600; }
.edit::placeholder { font-weight: 400; color: var(--ink-3); }
.row-none { grid-template-columns: var(--gutter) 1fr; }
.none { display: flex; align-items: center; padding: 0 14px; color: var(--ink-2); }

/* ---- inspector */
.inspector { display: flex; flex-direction: column; gap: 12px; min-height: 0; overflow: auto; padding: 18px 20px 24px; border-left: 1px solid var(--rule-strong); background: var(--paper); }
.ins-close { display: none; align-self: flex-end; padding: 4px 10px; border: 1px solid var(--rule-strong); border-radius: 3px; background: var(--paper); color: var(--ledger); }
.ins-name { width: 100%; padding: 2px 0; border: 0; border-bottom: 1px solid transparent; background: transparent; font-weight: 600; font-size: 22px; letter-spacing: -0.01em; }
.ins-name:hover { border-bottom-color: var(--rule-strong); }
.ins-name:focus { outline: 0; border-bottom-color: var(--pen); }
.ins-role { margin: -8px 0 0; color: var(--ink-2); }
.ins-status { display: flex; align-items: center; margin: 4px 0 0; font-size: 13px; }
.ins-open { align-self: flex-start; margin-top: -6px; font: 400 13px var(--mono); color: var(--pen); }
.field { display: grid; gap: 4px; }
.field-label { font-weight: 500; font-size: 12.5px; color: var(--ink-2); }
.field input, .field textarea { width: 100%; padding: 7px 10px; border: 1px solid var(--rule); border-radius: 3px; background: #fff; }
.field input { height: 36px; }
.field textarea { min-height: 120px; resize: vertical; line-height: 1.45; }
.field .is-mono { font: 400 13px var(--mono); }
.field input:focus, .field textarea:focus { outline: 2px solid var(--pen); outline-offset: -1px; border-color: transparent; }
.ins-note { min-height: 18px; margin: 0; font-size: 12.5px; color: var(--ledger); }
.ins-note.is-error { color: var(--down); }
.ins-actions { display: flex; gap: 16px; margin-top: auto; padding-top: 8px; }
.danger { padding: 0; border: 0; background: none; color: var(--down); text-decoration: underline; text-underline-offset: 3px; }
.ins-empty { margin: 4px 0; color: var(--ink-2); line-height: 1.5; }

/* ---- status bar and dialog */
.status { display: flex; align-items: center; gap: 28px; height: 30px; padding: 0 16px; overflow: hidden; white-space: nowrap;
  border-top: 1px solid var(--rule-strong); background: var(--bar); font-size: 12.5px; color: var(--ink-2); }
.status-up::before { content: ''; display: inline-block; width: 8px; height: 8px; margin-right: 8px; border-radius: 50%; background: var(--up); }

.confirm { width: min(380px, calc(100vw - 32px)); padding: 22px; border: 1px solid var(--rule-strong); border-radius: 4px; background: var(--paper); color: var(--ink); }
.confirm::backdrop { background: rgb(20 36 27 / 0.4); }
.confirm h2 { margin: 0 0 8px; font-size: 18px; }
.confirm p { margin: 0 0 20px; color: var(--ink-2); line-height: 1.5; }
.confirm-actions { display: flex; justify-content: flex-end; gap: 10px; }
.quiet, .danger-solid { height: 36px; padding: 0 14px; border-radius: 3px; font-weight: 500; }
.quiet { border: 1px solid var(--rule-strong); background: var(--paper); }
.danger-solid { border: 0; background: var(--down); color: #fff; }

/* ---- motion: the threads draw once on load; a lamp rings once when a site changes state */
@media (prefers-reduced-motion: no-preference) {
  .is-intro .cell { --at: calc(var(--c, 0) * 180ms + var(--r, 0) * 28ms); }
  .is-intro .cell .stn { animation: lamp 0.3s cubic-bezier(0.2, 1.4, 0.4, 1) var(--at) backwards; }
  .is-intro .cell .lbl { animation: ink 0.3s ease-out calc(var(--at) + 50ms) backwards; }
  .is-intro .cell .track { animation: draw 0.14s linear calc(var(--at) + 40ms) backwards; }
  .is-intro .cell.has-prev::before { animation: draw 0.04s linear calc(var(--at) - 40ms) backwards; }
  .stn.just-flipped { animation: ring 1.2s ease-out; }
  .inspector { transition: transform 0.25s cubic-bezier(0.2, 0.8, 0.2, 1); }
}
@keyframes lamp { from { transform: scale(0); } }
@keyframes ink { from { opacity: 0; } }
@keyframes draw { from { transform: scaleX(0); } }
@keyframes ring { from { box-shadow: 0 0 0 0 currentColor; } to { box-shadow: 0 0 0 14px transparent; } }

/* A finger aims at the cell, and browsers snap a near miss onto the nearest link: the site link then lives in the details only. */
@media (max-width: 860px), (hover: none) {
  .dom { pointer-events: none; }
}

/* ---- phone: two columns in view, details slide up from the bottom */
@media (max-width: 860px) {
  :root { --gutter: 32px; --col: 172px; }
  .topbar { gap: 10px; padding: 0 12px; }
  .find { flex: 1 1 0; margin-left: 4px; }
  .wallet { display: none; }
  .fx-ref { width: 52px; }
  .fx-details { display: block; }
  .work { grid-template-columns: minmax(0, 1fr); }
  .inspector { position: fixed; inset: auto 0 0 0; z-index: 10; max-height: 80dvh; padding-bottom: max(24px, env(safe-area-inset-bottom));
    border-left: 0; border-top: 2px solid var(--ledger); box-shadow: 0 -18px 48px rgb(20 36 27 / 0.22); transform: translateY(105%); }
  .inspector.is-open { transform: none; }
  .ins-close { display: block; }
  .ins-actions { margin-top: 4px; }
  .status { gap: 16px; padding: 0 12px; }
  .status-when { display: none; }
  .field input, .field textarea, .edit, .find { font-size: 16px; }   /* below 16px iOS zooms the page on focus */
}
