/* ==========================================================================
   EMPHN Workbench — workspace styles (the four tabs)
   Loaded after shell.css, which supplies the tokens.
   --------------------------------------------------------------------------
   Deliberately NOT a resizable chat panel bolted to the left of every page.
   Chat gets its own full surface with a proper reading measure; the other
   three get the whole canvas. Continuity comes from one persistent context
   bar, not a duplicated conversation column on every screen.
   ========================================================================== */

body.app {
  height: 100vh;
  overflow: hidden;
  display: grid;
  grid-template-rows: var(--navh) auto auto 1fr;
  background: var(--paper-warm);
}
body.app .nav { position: static; }

/* --- tab bar ------------------------------------------------------------ */
.tabs {
  display: flex;
  padding: 0 var(--gutter);
  background: var(--paper);
  border-bottom: 1px solid var(--n-200);
  overflow-x: auto;
  scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }
.tab {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  padding: 0.85rem 1.15rem;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--n-500);
  white-space: nowrap;
  transition: color var(--fast);
}
.tab:hover { color: var(--ink); }
.tab.is-on { color: var(--ink); }
/* A 2px rule, not a pill — reads as an instrument selector, not a web widget */
.tab.is-on::after {
  content: "";
  position: absolute;
  left: 1.15rem; right: 1.15rem; bottom: -1px;
  height: 2px;
  background: var(--accent);
  border-radius: 2px 2px 0 0;
}
.tab .tnum {
  font-family: var(--mono);
  font-size: 0.625rem;
  color: var(--n-400);
  letter-spacing: 0.04em;
}
.tab.is-on .tnum { color: var(--accent); }

/* --- context bar -------------------------------------------------------- */
/* One line, always present, identical on all four tabs. This is what makes
   four surfaces feel like one product. */
.ctx {
  display: flex;
  align-items: center;
  gap: 1.1rem;
  flex-wrap: wrap;
  padding: 0.6rem var(--gutter);
  background: var(--paper-warm);
  border-bottom: 1px solid var(--n-200);
  font-size: 0.75rem;
  color: var(--n-500);
}
.ctx b { color: var(--ink); font-weight: 600; font-variant-numeric: tabular-nums; }
.ctx-sep { width: 1px; height: 13px; background: var(--n-200); flex: none; }
.ctx-basis {
  margin-left: auto;
  font-family: var(--mono);
  font-size: 0.6875rem;
  color: var(--n-400);
}
@media (max-width: 720px) { .ctx-basis { margin-left: 0; } }

/* --- workspace ---------------------------------------------------------- */
.ws { overflow: hidden; position: relative; min-height: 0; }

/* ==========================================================================
   TAB 1 — CHAT
   A reading column, not a messaging app. Answers look like briefing notes
   because that is what a PHN analyst actually wants out of them.
   ========================================================================== */
.chat-wrap { height: 100%; display: grid; grid-template-rows: 1fr auto; min-height: 0; }
.chat-scroll { overflow-y: auto; padding: clamp(1.5rem, 4vh, 3rem) var(--gutter); }
.chat-col { max-width: 760px; margin: 0 auto; }

.chat-open { padding-top: clamp(0.5rem, 4vh, 2.5rem); }
.chat-open h1 {
  font-size: clamp(1.7rem, 3.2vw, 2.4rem);
  font-weight: 600;
  letter-spacing: -0.03em;
  line-height: 1.12;
  margin-bottom: 0.7rem;
}
.chat-open .lede { max-width: 54ch; margin-bottom: clamp(1.75rem, 4vh, 2.75rem); }

.ask-group { margin-bottom: 1.75rem; }
.ask-group h2 {
  font-size: 0.6875rem;
  font-weight: 500;
  letter-spacing: 0.145em;
  text-transform: uppercase;
  color: var(--n-400);
  margin-bottom: 0.7rem;
}
.ask-list {
  display: grid;
  gap: 1px;
  background: var(--n-200);
  border: 1px solid var(--n-200);
  border-radius: var(--r);
  overflow: hidden;
}
.ask {
  display: flex;
  align-items: center;
  gap: 0.875rem;
  padding: 0.8rem 1.05rem;
  background: var(--paper);
  text-align: left;
  width: 100%;
  font-size: 0.9375rem;
  color: var(--ink);
  transition: background var(--fast), padding-left var(--fast);
}
.ask:hover { background: var(--accent-pale); padding-left: 1.3rem; }
.ask .arw { margin-left: auto; color: var(--n-300); transition: color var(--fast), transform var(--fast); }
.ask:hover .arw { color: var(--accent); transform: translateX(3px); }

/* --- turns -------------------------------------------------------------- */
.turn { margin-bottom: clamp(1.75rem, 4vh, 2.5rem); }
.turn-q {
  font-size: 1.0625rem;
  font-weight: 600;
  letter-spacing: -0.018em;
  line-height: 1.4;
  padding-left: 0.9rem;
  border-left: 2px solid var(--accent);
  margin-bottom: 1rem;
}
.turn-a { font-size: 0.9688rem; line-height: 1.72; color: var(--n-700); }
.turn-a p { margin-bottom: 0.8rem; }
.turn-a strong { color: var(--ink); font-weight: 600; }
.turn-a .num { font-variant-numeric: tabular-nums; }

/* Inline citation — a quiet mono chip */
.cite {
  font-family: var(--mono);
  font-size: 0.6875rem;
  color: var(--n-500);
  background: var(--n-100);
  border: 1px solid var(--n-200);
  border-radius: var(--r-xs);
  padding: 0.05rem 0.3rem;
  white-space: nowrap;
}

/* A ranked table inside an answer — reading a ranking shouldn't need a chart */
.mini { width: 100%; border-collapse: collapse; margin: 1rem 0 1.25rem; font-size: 0.875rem; }
.mini th {
  text-align: left;
  font-size: 0.625rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--n-400);
  padding: 0 0.75rem 0.5rem 0;
  border-bottom: 1px solid var(--n-200);
  white-space: nowrap;
}
.mini td { padding: 0.5rem 0.75rem 0.5rem 0; border-bottom: 1px solid var(--n-100); color: var(--n-700); }
.mini td.is-num { text-align: right; font-variant-numeric: tabular-nums; color: var(--ink); font-weight: 500; }
.mini tr:hover td { background: var(--paper-warm); }
.mini .zone-dot {
  display: inline-block; width: 7px; height: 7px; border-radius: 2px;
  margin-right: 0.5rem; vertical-align: middle; background: var(--n-400);
}
.mini .zone-dot[data-zone="urban"] { background: var(--zone-urban); }
.mini .zone-dot[data-zone="green-wedge"] { background: var(--zone-green); }
.mini .zone-dot[data-zone="peri-urban"] { background: var(--zone-peri); }
.bar-cell { width: 34%; min-width: 90px; }
.bar-cell i { display: block; height: 4px; border-radius: 2px; background: var(--accent); opacity: 0.85; }

/* Answer footer actions */
.turn-acts { display: flex; gap: 0.5rem; flex-wrap: wrap; margin-top: 0.9rem; }
.act {
  font-size: 0.75rem;
  color: var(--n-500);
  border: 1px solid var(--n-200);
  border-radius: var(--r-pill);
  padding: 0.3rem 0.75rem;
  background: var(--paper);
  transition: all var(--fast);
}
.act:hover { color: var(--ink); border-color: var(--n-400); }

/* --- composer ----------------------------------------------------------- */
.composer-bar { border-top: 1px solid var(--n-200); background: var(--paper); padding: 0.875rem var(--gutter) 1rem; }
.composer-col { max-width: 760px; margin: 0 auto; }
.composer-field {
  display: flex;
  align-items: flex-end;
  gap: 0.6rem;
  border: 1px solid var(--n-300);
  border-radius: var(--r-lg);
  padding: 0.55rem 0.55rem 0.55rem 1rem;
  background: var(--paper);
  transition: border-color var(--fast), box-shadow var(--fast);
}
.composer-field:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-pale); }
.composer-field textarea {
  flex: 1; border: 0; outline: 0; resize: none; background: none;
  font-size: 0.9375rem; line-height: 1.5; max-height: 150px; padding: 0.3rem 0;
}
.send {
  flex: none; width: 34px; height: 34px; border-radius: 50%;
  background: var(--ink); color: #fff; display: grid; place-items: center;
  transition: background var(--fast), opacity var(--fast);
}
.send:disabled { opacity: 0.22; cursor: not-allowed; }
.send:not(:disabled):hover { background: var(--accent); }
.composer-hint { display: flex; gap: 0.85rem; flex-wrap: wrap; margin-top: 0.5rem; font-size: 0.6875rem; color: var(--n-400); }
kbd {
  font-family: var(--mono); font-size: 0.625rem;
  border: 1px solid var(--n-200); border-bottom-width: 2px;
  border-radius: var(--r-xs); padding: 0.05rem 0.3rem; background: var(--paper);
}

.thinking { display: flex; gap: 5px; align-items: center; padding: 0.3rem 0; }
.thinking i { width: 5px; height: 5px; border-radius: 50%; background: var(--n-400); animation: tp 1.3s var(--ease) infinite; }
.thinking i:nth-child(2) { animation-delay: 0.16s; }
.thinking i:nth-child(3) { animation-delay: 0.32s; }
@keyframes tp { 0%,60%,100% { opacity: 0.25; transform: translateY(0); } 30% { opacity: 1; transform: translateY(-3px); } }

/* ==========================================================================
   TAB 2 — DASHBOARDS
   Tiles read as instruments: hairline rules, tabular figures, no drop
   shadows, no rounded-card-with-shadow bootstrap look.
   ========================================================================== */
.board-scroll { height: 100%; overflow-y: auto; padding: clamp(1.25rem, 3vh, 2rem) var(--gutter) 4rem; }
.board {
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  gap: 1px;
  background: var(--n-200);
  border: 1px solid var(--n-200);
  border-radius: var(--r-lg);
  overflow: hidden;
  max-width: var(--maxw);
  margin: 0 auto;
}
.tile { background: var(--paper); padding: 1.35rem 1.5rem; display: grid; align-content: start; gap: 0.5rem; grid-column: span 4; }
.tile[data-w="6"] { grid-column: span 6; }
.tile[data-w="8"] { grid-column: span 8; }
.tile[data-w="12"] { grid-column: span 12; }
@media (max-width: 1080px) { .tile, .tile[data-w] { grid-column: span 6; } }
@media (max-width: 680px)  { .tile, .tile[data-w] { grid-column: span 12; } }

.tile-h { display: flex; align-items: baseline; gap: 0.6rem; }
.tile-t { font-size: 0.75rem; font-weight: 600; letter-spacing: 0.02em; color: var(--n-500); }
.tile-src { margin-left: auto; font-family: var(--mono); font-size: 0.625rem; color: var(--n-300); }
.tile-v { font-size: clamp(1.6rem, 2.4vw, 2.1rem); font-weight: 600; letter-spacing: -0.032em; font-variant-numeric: tabular-nums; line-height: 1.05; }
.tile-sub { font-size: 0.75rem; color: var(--n-500); }
.delta { font-size: 0.75rem; font-weight: 600; font-variant-numeric: tabular-nums; }
.delta.up { color: var(--pos); }
.delta.down { color: var(--neg); }

/* Ranked list inside a tile — the workhorse chart */
.rank { display: grid; gap: 0.45rem; margin-top: 0.35rem; }
.rank-row { display: grid; grid-template-columns: 1fr auto; gap: 0.6rem; align-items: center; font-size: 0.8125rem; }
.rank-lab { display: flex; align-items: center; gap: 0.45rem; color: var(--n-700); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rank-val { font-variant-numeric: tabular-nums; font-weight: 500; color: var(--ink); }
.rank-track { grid-column: 1 / -1; height: 4px; border-radius: 2px; background: var(--n-100); overflow: hidden; }
.rank-track i { display: block; height: 100%; border-radius: 2px; background: var(--accent); }
.rank-row.is-hi .rank-lab { color: var(--ink); font-weight: 600; }

/* ==========================================================================
   TAB 3 — MAPS
   ========================================================================== */
.map-wrap { height: 100%; position: relative; }
#map { position: absolute; inset: 0; background: var(--paper-sunk); }
.map-panel {
  position: absolute;
  top: 1rem; left: 1rem;
  z-index: 500;
  width: 272px;
  max-width: calc(100% - 2rem);
  background: rgba(255,255,255,0.96);
  backdrop-filter: blur(14px);
  border: 1px solid var(--n-200);
  border-radius: var(--r-lg);
  overflow: hidden;
}
.map-panel-h { padding: 0.85rem 1rem 0.6rem; border-bottom: 1px solid var(--n-100); }
.map-panel-b { padding: 0.75rem 1rem 0.9rem; display: grid; gap: 0.5rem; max-height: 46vh; overflow-y: auto; }
.metric-btn {
  display: flex; align-items: center; gap: 0.5rem; width: 100%;
  text-align: left; font-size: 0.8125rem; color: var(--n-700);
  padding: 0.4rem 0.5rem; border-radius: var(--r-sm);
  transition: background var(--fast), color var(--fast);
}
.metric-btn:hover { background: var(--n-100); color: var(--ink); }
.metric-btn.is-on { background: var(--accent-pale); color: var(--accent-deep); font-weight: 600; }
.legend {
  position: absolute; bottom: 1rem; left: 1rem; z-index: 500;
  background: rgba(255,255,255,0.96); backdrop-filter: blur(14px);
  border: 1px solid var(--n-200); border-radius: var(--r);
  padding: 0.7rem 0.85rem; font-size: 0.6875rem; color: var(--n-500);
}
.legend-ramp { height: 8px; width: 168px; border-radius: 2px; margin: 0.4rem 0 0.3rem; }
.legend-ends { display: flex; justify-content: space-between; font-variant-numeric: tabular-nums; }
.zone-key { display: grid; gap: 0.3rem; margin-top: 0.65rem; padding-top: 0.6rem; border-top: 1px solid var(--n-100); }

/* ==========================================================================
   TAB 4 — HNA
   Document-grade. A real reading measure and a chapter rail.
   ========================================================================== */
.hna-grid { height: 100%; display: grid; grid-template-columns: 250px 1fr; min-height: 0; }
@media (max-width: 900px) { .hna-grid { grid-template-columns: 1fr; } .hna-rail { display: none; } }
.hna-rail { border-right: 1px solid var(--n-200); background: var(--paper); overflow-y: auto; padding: 1.25rem 0.75rem; }
.rail-h { font-size: 0.6875rem; font-weight: 500; letter-spacing: 0.145em; text-transform: uppercase; color: var(--n-400); padding: 0 0.75rem; margin-bottom: 0.75rem; }
.rail-item {
  display: grid; grid-template-columns: auto 1fr; gap: 0.7rem; align-items: baseline;
  width: 100%; text-align: left; padding: 0.55rem 0.75rem;
  border-radius: var(--r-sm); transition: background var(--fast);
}
.rail-item:hover { background: var(--n-100); }
.rail-item.is-on { background: var(--accent-pale); }
.rail-n { font-family: var(--mono); font-size: 0.625rem; color: var(--n-400); }
.rail-item.is-on .rail-n { color: var(--accent); }
.rail-t { font-size: 0.8125rem; color: var(--n-700); line-height: 1.35; }
.rail-item.is-on .rail-t { color: var(--ink); font-weight: 600; }
.rail-prog { grid-column: 2; height: 3px; border-radius: 2px; background: var(--n-100); margin-top: 0.4rem; overflow: hidden; }
.rail-prog i { display: block; height: 100%; background: var(--accent); border-radius: 2px; }

.doc-scroll { overflow-y: auto; padding: clamp(1.75rem, 4vh, 3.25rem) var(--gutter) 5rem; }
.doc { max-width: 720px; margin: 0 auto; }
.doc-meta { display: flex; gap: 1rem; flex-wrap: wrap; align-items: center; font-size: 0.6875rem; color: var(--n-400); font-family: var(--mono); margin-bottom: 1.25rem; padding-bottom: 0.9rem; border-bottom: 1px solid var(--n-200); }
.doc h1 { font-size: clamp(1.8rem, 3.2vw, 2.4rem); font-weight: 600; letter-spacing: -0.03em; line-height: 1.1; margin-bottom: 1rem; }
.doc .deck { font-size: 1.0625rem; line-height: 1.65; color: var(--n-700); padding-bottom: 1.25rem; border-bottom: 1px solid var(--n-100); margin-bottom: 1.5rem; }
.doc h2 { font-size: 1.125rem; font-weight: 600; letter-spacing: -0.015em; margin: 2rem 0 0.65rem; }
.doc p { font-size: 0.9688rem; line-height: 1.75; color: var(--n-700); margin-bottom: 0.85rem; }
.doc strong { color: var(--ink); font-weight: 600; }
.sec { padding: 0.6rem 0.85rem; margin: 0 -0.85rem 0.5rem; border-radius: var(--r); transition: background var(--fast); }
.sec:hover { background: var(--paper-warm); }
.sec-acts { display: flex; gap: 0.4rem; flex-wrap: wrap; opacity: 0; transition: opacity var(--fast); }
.sec:hover .sec-acts, .sec:focus-within .sec-acts { opacity: 1; }
@media (hover: none) { .sec-acts { opacity: 1; } }

/* --- shared: empty state ------------------------------------------------ */
.empty { height: 100%; display: grid; place-items: center; padding: 2rem; text-align: center; }
.empty-in { max-width: 430px; display: grid; gap: 0.55rem; justify-items: center; }
.empty-mark {
  width: 44px; height: 44px; border-radius: 13px;
  background: var(--ink); color: var(--paper);
  display: grid; place-items: center;
  font-family: var(--mono); font-size: 0.8125rem; margin-bottom: 0.4rem;
}
.empty h2 { font-size: 1.125rem; font-weight: 600; letter-spacing: -0.018em; }
.empty p { font-size: 0.875rem; color: var(--n-500); line-height: 1.6; }
