/* PONSCHIVE — terminal shell
   Pons brand tokens, terminal execution: square corners, hairline rules,
   monospace throughout. Lime = money and liveness only. */

:root {
  --lime: #d4fc50;
  --lime-hover: #e2ff66;
  --lime-soft: #1c2610;
  --on-lime: #111;

  --page: #0d0d0d;
  --card: #161616;
  --elevated: #1c1c1c;
  --panel: #1f1f1f;

  --text: #f2f2f2;
  --muted: rgba(242, 242, 242, .58);
  --subtle: rgba(242, 242, 242, .4);
  --divider: rgba(242, 242, 242, .08);
  --rule: rgba(242, 242, 242, .16);

  --success: #30d158;
  --danger: #ff453a;
  --warn: #f5a623;

  --mono: ui-monospace, "SF Mono", "Cascadia Mono", "Segoe UI Mono", Menlo, Consolas, monospace;
  --fs: 13px;
  --lh: 1.5;
  --rail-w: 380px;
  --sb-h: 36px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--page);
  color: var(--text);
  font: var(--fs)/var(--lh) var(--mono);
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
  overflow-x: hidden;
}

body {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  height: 100vh;
  height: 100dvh;
  width: 100%;
  max-width: 100vw;
}

/* one subtle CRT touch: faint scanlines, never over text contrast */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 300;
  background: repeating-linear-gradient(0deg, rgba(0, 0, 0, .18) 0 1px, transparent 1px 3px);
  opacity: .22;
}

a { color: inherit; }
code, kbd, pre { font-family: inherit; }
button { font: inherit; color: inherit; }
input { font: inherit; color: inherit; }
[hidden] { display: none !important; }

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

:focus-visible { outline: 1px solid var(--text); outline-offset: -1px; }
.dim { color: var(--muted); }
.num { font-variant-numeric: tabular-nums; }

/* ---------- boot ---------- */
#boot {
  position: fixed; inset: 0; z-index: 400;
  background: var(--page);
  padding: 28px 24px;
  color: var(--muted);
  transition: opacity .18s ease-out;
}
#boot.fade { opacity: 0; pointer-events: none; }
.boot-inner { max-width: 72ch; }
.boot-line { white-space: pre; overflow: hidden; text-overflow: ellipsis; }
.boot-line .ok { color: var(--success); }
.boot-line .val { color: var(--text); }
.boot-hint { margin-top: 18px; color: var(--subtle); font-size: 11px; }

/* ---------- status bar ---------- */
#statusbar {
  height: var(--sb-h);
  display: flex; align-items: center; gap: 10px;
  padding: 0 12px;
  border-bottom: 1px solid var(--divider);
  background: var(--card);
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  min-width: 0;
}
.wordmark {
  color: var(--text);
  text-decoration: none;
  font-weight: 700;
  letter-spacing: .14em;
}
.wordmark:hover { color: var(--lime-hover); }
.sb-sep { color: var(--subtle); }
.sb-spacer { flex: 1; }
.sb-item { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.sb-clock { font-variant-numeric: tabular-nums; color: var(--text); }
.sb-conn { display: inline-flex; align-items: center; }
.dot {
  width: 7px; height: 7px; display: inline-block;
  background: var(--lime);
  box-shadow: 0 0 0 2px var(--lime-soft);
  animation: pulse 2.4s ease-in-out infinite;
}
.dot.off { background: var(--danger); box-shadow: none; animation: none; }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: .45; } }

.icon-btn {
  background: transparent; border: 1px solid var(--divider);
  width: 26px; height: 26px; line-height: 1; padding: 0;
  cursor: pointer; color: var(--muted);
}
.icon-btn:hover { color: var(--text); border-color: var(--rule); }
#rail-toggle { display: none; }

/* ---------- content grid ---------- */
#content {
  display: grid;
  grid-template-columns: var(--rail-w) minmax(0, 1fr);
  min-height: 0;
  min-width: 0;
  position: relative;
}

/* ---------- rail ---------- */
#rail {
  display: flex; flex-direction: column;
  min-height: 0;
  border-right: 1px solid var(--divider);
  background: var(--page);
}
.rail-tools { border-bottom: 1px solid var(--divider); }
.filter-wrap {
  display: flex; align-items: center; gap: 6px;
  padding: 6px 10px 6px 12px;
  border-bottom: 1px solid var(--divider);
}
.filter-prefix { color: var(--subtle); }
#filter {
  flex: 1; min-width: 0;
  background: transparent; border: 0; padding: 4px 0;
  outline: none;
}
#filter::placeholder { color: var(--subtle); }
#filter::-webkit-search-cancel-button { -webkit-appearance: none; }
.filter-wrap:focus-within { background: var(--card); }
.filter-count { color: var(--subtle); font-size: 11px; font-variant-numeric: tabular-nums; }

.quick {
  display: flex; align-items: baseline; gap: 8px;
  padding: 5px 10px 5px 12px;
  font-size: 11px;
  border-bottom: 1px solid var(--divider);
  min-width: 0;
}
.quick-label { color: var(--subtle); flex: none; width: 6ch; }
.quick-row { display: flex; flex-wrap: wrap; gap: 4px; min-width: 0; }
.qf {
  background: transparent; border: 1px solid var(--divider);
  color: var(--muted); padding: 0 6px; cursor: pointer;
  font-size: 11px; line-height: 18px;
}
.qf:hover { color: var(--text); border-color: var(--rule); }
.qf[aria-pressed="true"] { background: var(--elevated); color: var(--text); border-color: var(--rule); }

.list-head {
  display: grid;
  grid-template-columns: 4.5ch minmax(0, 1fr) auto 5.5ch;
  column-gap: 8px;
  padding: 4px 10px 4px 14px;
  font-size: 10px; letter-spacing: .08em; text-transform: uppercase;
  color: var(--subtle);
}

#list {
  flex: 1; min-height: 0;
  overflow-y: auto; overflow-x: hidden;
  overscroll-behavior: contain;
  outline: none;
}
#list:focus-visible { box-shadow: inset 0 0 0 1px var(--rule); }

.row {
  display: grid;
  grid-template-columns: 4.5ch minmax(0, 1fr) auto 5.5ch;
  column-gap: 8px;
  padding: 5px 10px 5px 12px;
  border-left: 2px solid transparent;
  border-bottom: 1px solid var(--divider);
  cursor: pointer;
  color: var(--muted);
  min-width: 0;
}
.row:hover { background: var(--card); color: var(--text); }
.row[aria-selected="true"] {
  background: var(--elevated);
  border-left-color: var(--lime);
  color: var(--text);
}
.row.open .title .tt { color: var(--lime); }
.row .seq { color: var(--subtle); font-variant-numeric: tabular-nums; }
.row[aria-selected="true"] .seq { color: var(--muted); }
.row .title { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row .title .tt { font-weight: 700; }
.row .tone { justify-self: end; }
.row .date { color: var(--subtle); font-variant-numeric: tabular-nums; font-size: 11px; text-align: right; }
.row .sum {
  grid-column: 1 / -1;
  font-size: 11px; color: var(--subtle);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  min-width: 0;
}
.row:hover .sum, .row[aria-selected="true"] .sum { color: var(--muted); }
.list-empty { padding: 18px 14px; color: var(--subtle); }

.rail-foot {
  border-top: 1px solid var(--divider);
  padding: 4px 12px;
  font-size: 10.5px; color: var(--subtle);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

/* tone chips — primary chip. no lime; greys + the existing accents. */
.chip.tone { text-align: center; }
.chip.t-comic     { color: var(--warn); border-color: rgba(245, 166, 35, .5); }
.chip.t-absurd    { color: var(--text); border-style: dashed; font-style: italic; }
.chip.t-warm      { color: var(--success); border-color: rgba(48, 209, 88, .45); }
.chip.t-serious   { color: var(--text); border-color: rgba(242, 242, 242, .55); font-weight: 700; }
.chip.t-technical { color: var(--muted); border-style: dotted; border-color: rgba(242, 242, 242, .4); }
.chip.t-bleak     { color: var(--subtle); border-color: var(--divider); background: var(--page); }
.chip.t-heated    { color: var(--danger); border-color: rgba(255, 69, 58, .55); }
.chip.t-none      { color: var(--subtle); }
.qf-tone[aria-pressed="true"].t-comic { color: var(--warn); }
.qf-tone[aria-pressed="true"].t-warm { color: var(--success); }
.qf-tone[aria-pressed="true"].t-heated { color: var(--danger); }
.qf-tone[aria-pressed="true"].t-absurd { font-style: italic; }
.qf-tone[aria-pressed="true"].t-technical { border-style: dotted; }

/* chips — the one place a small radius is allowed */
.chip {
  display: inline-block;
  font-size: 10px; line-height: 16px; letter-spacing: .06em;
  padding: 0 5px;
  border: 1px solid var(--rule);
  border-radius: 3px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis;
  max-width: 100%;
  vertical-align: middle;
}

/* ---------- main pane ---------- */
#main {
  min-width: 0; min-height: 0;
  overflow-y: auto; overflow-x: hidden;
  overscroll-behavior: contain;
  outline: none;
}
.pane { padding: 18px 22px 36px; max-width: 1040px; min-width: 0; }
.pane-empty { padding: 24px 0; }
.pane-error { color: var(--danger); padding: 24px 0; white-space: pre-wrap; }
.pane-loading { color: var(--subtle); padding: 24px 0; }

.log-head { border-bottom: 1px solid var(--rule); padding-bottom: 14px; margin-bottom: 8px; }
.log-path { color: var(--subtle); font-size: 11px; margin-bottom: 6px; overflow-wrap: anywhere; }
.log-title { font-size: 17px; font-weight: 700; margin: 0 0 4px; line-height: 1.3; overflow-wrap: anywhere; }
.log-summary { color: var(--muted); margin: 0 0 12px; overflow-wrap: anywhere; }

.meta-line { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 0; margin-bottom: 12px; font-size: 12px; }
.meta-line .ml-item { color: var(--muted); padding: 0 12px; border-left: 1px solid var(--divider); }
.meta-line .chip + .ml-item { border-left: 0; padding-left: 12px; }
.log.short .log-head { padding-bottom: 10px; }
.log.short .stream { padding: 10px 0 14px; }

.people { display: flex; flex-wrap: wrap; gap: 6px 14px; margin-bottom: 8px; font-size: 12px; }
.people .p { display: inline-flex; gap: 6px; align-items: baseline; min-width: 0; }
.people .handle { font-weight: 700; }
.people .role { color: var(--subtle); }
.tags { display: flex; flex-wrap: wrap; gap: 4px 10px; font-size: 11px; color: var(--subtle); }
.tags .tag::before { content: "#"; opacity: .6; }
.tags .tag { cursor: pointer; background: transparent; border: 0; padding: 0; color: var(--subtle); }
.tags .tag:hover { color: var(--text); }

/* message stream */
.stream { padding: 6px 0; }
.line {
  display: grid;
  grid-template-columns: 8ch 12ch minmax(0, 1fr);
  column-gap: 12px;
  padding: 3px 0;
  min-width: 0;
}
.line .t { color: var(--subtle); font-variant-numeric: tabular-nums; white-space: nowrap; }
.line .h { font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.line .x { min-width: 0; overflow-wrap: anywhere; white-space: pre-wrap; }

.line.k-sys .x { color: var(--subtle); }
.line.k-sys .h { visibility: hidden; }

.line.k-tool .x {
  color: var(--muted);
  border-left: 1px solid var(--rule);
  padding-left: 10px;
  white-space: pre-wrap;
}
.line.k-tool .x::before { content: "› "; color: var(--subtle); }

.line.k-data { padding: 5px 0; }
.line.k-data .x {
  background: var(--card);
  border: 1px solid var(--divider);
  padding: 7px 10px;
}
.line.k-data .x .payload { color: var(--text); }
.line.k-data pre {
  margin: 8px 0 0;
  padding: 8px 0 2px;
  border-top: 1px solid var(--divider);
  color: var(--muted);
  font-size: 12px;
  overflow-x: auto;
  white-space: pre;
  max-width: 100%;
  tab-size: 4;
}

.log-foot {
  border-top: 1px solid var(--rule);
  margin-top: 10px; padding-top: 10px;
  display: flex; flex-wrap: wrap; gap: 6px 22px;
  font-size: 12px;
}
.log-foot .f { display: inline-flex; gap: 8px; min-width: 0; }
.log-foot .fk { color: var(--subtle); }
.log-foot .fv { overflow-wrap: anywhere; }
.log-nav { display: flex; gap: 14px; margin-top: 16px; font-size: 12px; }
.log-nav button { background: none; border: 0; padding: 0; color: var(--muted); cursor: pointer; text-decoration: underline dotted; text-underline-offset: 3px; }
.log-nav button:hover { color: var(--text); }

/* ---------- command line ---------- */
#cmdline {
  border-top: 1px solid var(--divider);
  background: var(--card);
  min-width: 0;
}
#cmd-out {
  max-height: 36vh;
  overflow-y: auto; overflow-x: hidden;
  padding: 6px 12px 2px;
  font-size: 12px;
  color: var(--muted);
  border-bottom: 1px solid var(--divider);
}
#cmd-out:empty { display: none; }
#cmd-out .o { white-space: pre-wrap; overflow-wrap: anywhere; }
#cmd-out .o.echo { color: var(--subtle); }
#cmd-out .o.echo::before { content: "ponschive:~$ "; }
#cmd-out .o.err { color: var(--danger); }
#cmd-out .o.ok { color: var(--text); }
#cmd-out .o.head { color: var(--subtle); }
#cmd-out .o a { color: var(--text); }
.cmd-row { display: flex; align-items: center; gap: 8px; padding: 7px 12px; min-width: 0; }
.prompt { color: var(--muted); white-space: nowrap; flex: none; }
.prompt-user { color: var(--text); }
.cmd-field { flex: 1; display: flex; align-items: center; min-width: 0; position: relative; }
#cmd {
  flex: 1; min-width: 0;
  background: transparent; border: 0; padding: 0; outline: none;
  caret-color: var(--lime);
}
.cursor {
  width: 8px; height: 15px; margin-left: 1px; flex: none;
  background: var(--lime);
  animation: blink 1.1s steps(1) infinite;
  display: none;
}
.cmd-field.empty:not(:focus-within) .cursor { display: block; }
.cmd-field.empty:not(:focus-within) #cmd { flex: 0 0 0; }
@keyframes blink { 50% { opacity: 0; } }
.cmd-hint { color: var(--subtle); font-size: 11px; white-space: nowrap; flex: none; }

/* ---------- help overlay ---------- */
.overlay {
  position: fixed; inset: 0; z-index: 350;
  background: rgba(13, 13, 13, .82);
  display: flex; align-items: center; justify-content: center;
  padding: 24px;
}
.overlay-panel {
  background: var(--panel);
  border: 1px solid var(--rule);
  width: min(760px, 100%);
  max-height: 100%;
  display: flex; flex-direction: column;
}
.overlay-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 8px 12px; border-bottom: 1px solid var(--divider);
  font-weight: 700;
}
.overlay-body {
  overflow: auto; padding: 12px 16px 18px;
  display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.25fr); gap: 20px;
}
.overlay-body h3 { font-size: 10px; letter-spacing: .1em; text-transform: uppercase; color: var(--subtle); margin: 0 0 8px; }
.keys { display: grid; grid-template-columns: minmax(0, 44%) minmax(0, 1fr); gap: 3px 14px; margin: 0; font-size: 12px; }
.keys dt { color: var(--text); overflow-wrap: anywhere; }
.keys dd { margin: 0; color: var(--muted); }
kbd { border: 1px solid var(--rule); padding: 0 4px; font-size: 11px; line-height: 16px; display: inline-block; }

.noscript { padding: 20px; color: var(--danger); }

/* ---------- responsive ---------- */
@media (min-width: 1440px) { :root { --rail-w: 420px; } }
@media (max-width: 1100px) { :root { --rail-w: 300px; } }

@media (max-width: 768px) {
  #rail-toggle { display: inline-block; }
  .sb-node { display: none; }
  #content { grid-template-columns: minmax(0, 1fr); }
  #rail {
    position: fixed;
    top: var(--sb-h); bottom: 0; left: 0;
    width: min(86vw, 360px);
    z-index: 250;
    transform: translateX(-102%);
    transition: transform .18s ease-out;
    box-shadow: none;
  }
  #rail.open { transform: none; box-shadow: 8px 0 24px rgba(0, 0, 0, .5); }
  #rail-backdrop { position: fixed; inset: var(--sb-h) 0 0 0; background: rgba(0, 0, 0, .5); z-index: 240; }
  .pane { padding: 14px 14px 30px; }
  .line { grid-template-columns: 8.5ch minmax(0, 1fr); column-gap: 8px; }
  .line .h { grid-column: 2; font-size: 11px; }
  .line .x { grid-column: 2; }
  .line.k-sys .h { display: none; }
  .cmd-hint { display: none; }
  .overlay-body { grid-template-columns: 1fr; }
  .overlay { padding: 10px; }
}

@media (max-width: 420px) {
  :root { --fs: 12px; }
  .row { grid-template-columns: 4ch minmax(0, 1fr) auto 5.5ch; column-gap: 6px; }
  .list-head { grid-template-columns: 4ch minmax(0, 1fr) auto 5.5ch; column-gap: 6px; }
  #statusbar { gap: 8px; padding: 0 8px; }
  .sb-sep { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  .dot { animation: none; }
  .cursor { animation: none; }
  #rail { transition: none; }
  #boot { transition: none; }
  * { scroll-behavior: auto !important; }
}

/* ---------- landing pane ---------- */
.landing-head { border-bottom: 1px solid var(--rule); padding-bottom: 12px; margin-bottom: 14px; }
.landing-head .log-title { letter-spacing: .12em; text-transform: uppercase; }
.landing-grid {
  display: grid;
  grid-template-columns: minmax(150px, 180px) minmax(220px, 1fr) minmax(240px, 1.4fr);
  gap: 1px;
  background: var(--divider);
  border: 1px solid var(--divider);
  margin-bottom: 14px;
}
.lblock { background: var(--card); padding: 10px 12px 12px; min-width: 0; }
.lh { font-size: 10px; letter-spacing: .1em; text-transform: uppercase; color: var(--subtle); margin: 0 0 8px; font-weight: 400; }
.ldl { display: grid; grid-template-columns: 1fr auto; gap: 3px 12px; margin: 0; font-size: 12px; }
.ldl dt { color: var(--muted); }
.ldl dd { margin: 0; text-align: right; color: var(--text); }
.tone-rows, .chan-rows { display: flex; flex-direction: column; gap: 3px; }
.tone-row, .chan-row {
  display: grid; align-items: center; gap: 10px;
  background: transparent; border: 0; padding: 2px 4px; margin: 0 -4px;
  cursor: pointer; text-align: left; color: var(--muted); font-size: 12px; min-width: 0;
}
.tone-row:hover, .chan-row:hover { background: var(--elevated); color: var(--text); }
.tone-row { grid-template-columns: auto minmax(0, 1fr) 3.5ch; }
.tone-row .chip { min-width: 9.5ch; }
.tbar { height: 3px; background: rgba(242, 242, 242, .08); display: block; min-width: 0; }
.tbar > i { display: block; height: 100%; background: rgba(242, 242, 242, .45); }
.tone-row .tn { text-align: right; color: var(--text); }
.chan-row { grid-template-columns: minmax(14ch, auto) 3.5ch minmax(0, 1fr); }
.chan-row .cl { color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chan-row .cn { text-align: right; }
.chan-row .cd { color: var(--subtle); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.landing-hint { color: var(--subtle); font-size: 12px; margin: 0; }
.landing-hint code { color: var(--text); }

@media (max-width: 1100px) {
  .landing-grid { grid-template-columns: minmax(150px, 180px) minmax(0, 1fr); }
  .landing-grid .lblock:nth-child(3) { grid-column: 1 / -1; }
}
@media (max-width: 560px) {
  .landing-grid { grid-template-columns: minmax(0, 1fr); }
  .landing-grid .lblock:nth-child(3) { grid-column: auto; }
  .chan-row { grid-template-columns: minmax(0, 1fr) 3.5ch; }
  .chan-row .cd { display: none; }
}
