/* AgentDeck 10" concept — shared screen styling.
   Dark ink ground + bright product-UI signals. Tokens from ../design/tokens.css. */

*, *::before, *::after { box-sizing: border-box; }

:root {
  --ink-0: #07140f;     /* deepest aquarium floor */
  --ink-1: #0b1d1a;     /* base */
  --ink-2: #102a27;     /* panel */
  --ink-3: #16413c;     /* raised surface */
  --line:  rgba(111,182,168,0.14);
  --line-2: rgba(111,182,168,0.26);
  --text:  #e7efe8;
  --dim:   #8fa6a2;
  --faint: #5d7470;
  --ok:    #52D988;
  --cyan:  #3ED6E8;
  --attn:  #FFA93D;
  --error: #FF6B6B;
}

html, body { margin: 0; height: 100%; }

.screen {
  position: relative;
  overflow: hidden;
  font-family: var(--font-sans);
  font-feature-settings: "ss01", "cv11";
  color: var(--text);
  background:
    radial-gradient(120% 90% at 18% 0%, #123430 0%, var(--ink-1) 46%, var(--ink-0) 100%);
  -webkit-font-smoothing: antialiased;
  user-select: none;
}
.mono { font-family: var(--font-mono); font-feature-settings: "zero", "ss01"; }

/* ───────── top bar ───────── */
.topbar {
  position: absolute; top: 0; left: 0; right: 0;
  display: flex; align-items: center; gap: 18px;
  padding: 0 22px;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(to bottom, rgba(7,20,15,0.7), rgba(7,20,15,0));
  z-index: 6;
}
.brand { display: flex; align-items: center; gap: 11px; }
.brand .mk {
  width: 32px; height: 32px; border-radius: 7px; flex: 0 0 auto;
  object-fit: contain; background: transparent; border: 0;
  filter: drop-shadow(0 2px 7px rgba(0,0,0,0.55));
}
.brand .nm { font-size: 16px; font-weight: 600; letter-spacing: -0.01em; }
.brand .nm b { color: var(--cyan); font-weight: 600; }
.topbar .seg {
  display: flex; align-items: center; gap: 7px;
  font-family: var(--font-mono); font-size: 11.5px; letter-spacing: 0.04em;
  color: var(--dim); text-transform: uppercase;
}
.topbar .spacer { flex: 1; }
.statline { display: flex; align-items: center; gap: 16px; }
.stat { display: flex; align-items: baseline; gap: 6px; }
.stat .n { font-family: var(--font-mono); font-weight: 600; font-variant-numeric: tabular-nums; }
.stat .l { font-size: 10.5px; letter-spacing: 0.14em; text-transform: uppercase; color: var(--faint); }
.clock { font-family: var(--font-mono); font-variant-numeric: tabular-nums; color: var(--text); font-weight: 600; }

/* mini rate gauge in topbar */
.gauge { display: flex; align-items: center; gap: 9px; }
.gauge .bar { width: 96px; height: 6px; border-radius: 999px; background: rgba(255,255,255,0.08); overflow: hidden; }
.gauge .bar i { display: block; height: 100%; border-radius: 999px; background: var(--cyan); }
.gauge .bar.warn i { background: var(--attn); }
.gauge .lab { font-size: 10.5px; letter-spacing: 0.12em; text-transform: uppercase; color: var(--faint); }
.gauge .pct { font-family: var(--font-mono); font-size: 12px; font-weight: 600; font-variant-numeric: tabular-nums; }

/* ───────── stage ───────── */
.stage { position: absolute; left: 0; right: 0; bottom: 0; display: flex; }

/* ───────── terrarium ───────── */
.terr {
  position: relative; overflow: hidden;
  background:
    radial-gradient(140% 80% at 50% -10%, rgba(62,214,232,0.10), transparent 60%),
    linear-gradient(to bottom, #0c2622 0%, #0a201c 55%, #07140f 100%);
}
.terr .surface {  /* waterline shimmer */
  position: absolute; left: 0; right: 0; top: 0; height: 34%;
  background: linear-gradient(to bottom, rgba(62,214,232,0.07), transparent);
  pointer-events: none;
}
.terr .floor {
  position: absolute; left: 0; right: 0; bottom: 0; height: 18%;
  background: linear-gradient(to top, rgba(7,20,15,0.85), transparent);
  pointer-events: none;
}
.terr .caption {
  position: absolute; left: 16px; top: 14px; z-index: 4;
  font-family: var(--font-mono); font-size: 11px; letter-spacing: 0.14em;
  text-transform: uppercase; color: var(--faint);
}
.terr .legend {
  position: absolute; left: 16px; bottom: 14px; z-index: 4;
  display: flex; gap: 14px; flex-wrap: wrap;
  font-family: var(--font-mono); font-size: 10.5px; letter-spacing: 0.06em; color: var(--dim);
}
.terr .legend span { display: inline-flex; align-items: center; gap: 6px; }
.terr .legend i { width: 8px; height: 8px; border-radius: 999px; }

.bubble { position: absolute; border-radius: 999px; background: rgba(140,210,200,0.16);
  border: 1px solid rgba(140,210,200,0.22); pointer-events: none; }

/* creature node (absolutely positioned, JS-driven transform) */
.cr {
  position: absolute; left: 0; top: 0;
  display: flex; flex-direction: column; align-items: center; gap: 5px;
  will-change: transform; cursor: pointer;
  transition: filter .2s ease;
}
.cr .body { position: relative; display: grid; place-items: center; }
.cr .glow {
  position: absolute; inset: -34%; border-radius: 999px; z-index: -1;
  opacity: 0.5; filter: blur(7px);
}
.cr .tag {
  font-family: var(--font-mono); font-size: 10px; letter-spacing: 0.04em;
  color: var(--dim); white-space: nowrap;
  padding: 1px 6px; border-radius: 999px; background: rgba(7,20,15,0.5);
  border: 1px solid var(--line); opacity: 0; transition: opacity .2s;
}
.cr.show-tag .tag, .terr.hover-any .cr.active .tag { opacity: 1; }
.cr .ask {
  position: absolute; top: -10px; right: -14px;
  width: 22px; height: 22px; border-radius: 50% 50% 50% 4px;
  background: var(--attn); color: #1a1205; font-weight: 700; font-size: 13px;
  display: grid; place-items: center; box-shadow: 0 2px 8px rgba(255,169,61,0.5);
}
.cr .bang {
  position: absolute; top: -9px; right: -12px;
  width: 20px; height: 20px; border-radius: 6px;
  background: var(--error); color: #2a0c0c; font-weight: 800; font-size: 13px;
  display: grid; place-items: center;
}
.cr.dim { filter: grayscale(0.5) brightness(0.7); opacity: 0.62; }
.terr.hover-any .cr:not(.active) { filter: grayscale(0.6) brightness(0.6); opacity: 0.4; }
.cr.active { filter: none !important; opacity: 1 !important; }
.cr.active .body::after {
  content: ''; position: absolute; inset: -30%; border-radius: 999px;
  border: 1.5px solid currentColor; opacity: 0.8;
}
@keyframes askPulse { 0%,100% { transform: scale(1); opacity: 1; } 50% { transform: scale(0.84); opacity: 0.6; } }
.cr .ask { animation: askPulse 1.1s ease-in-out infinite; }

/* ───────── work area / cells ───────── */
.work { position: relative; overflow: hidden; }
.grid { position: absolute; inset: 0; padding: 14px; display: flex; flex-wrap: wrap; gap: 10px; align-content: flex-start; }

.cell {
  position: relative; overflow: hidden;
  container-type: inline-size;
  border-radius: 14px;
  background: linear-gradient(to bottom, rgba(22,65,60,0.55), rgba(16,42,39,0.62));
  border: 1px solid var(--line);
  display: flex; flex-direction: column;
  cursor: pointer;
  transition: box-shadow .2s, border-color .2s, transform .2s;
  --accent: var(--cyan);
}
.cell::before { /* left accent rail */
  content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 3px;
  background: var(--accent); opacity: 0.9;
}
.cell.s-idle { background: rgba(16,42,39,0.4); }
.cell.s-idle::before { opacity: 0.35; }
.cell.s-awaiting { border-color: rgba(255,169,61,0.5);
  background: linear-gradient(to bottom, rgba(70,52,20,0.6), rgba(30,42,40,0.6)); }
.cell.s-error { border-color: rgba(255,107,107,0.45); }
.cell.active, .cell:hover { border-color: var(--line-2); box-shadow: 0 10px 30px -12px rgba(0,0,0,0.7); }
.cell.linked { border-color: var(--accent); box-shadow: 0 0 0 1.5px var(--accent); }

.cell .ch { display: flex; align-items: center; gap: 9px; padding: 11px 13px 0; }
.cell .ava { width: 22px; height: 22px; flex: 0 0 auto; display: grid; place-items: center; }
.cell .who { min-width: 0; flex: 1; }
.cell .who .nm { font-size: 13.5px; font-weight: 600; letter-spacing: -0.01em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cell .who .pj { font-family: var(--font-mono); font-size: 10.5px; color: var(--dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pill {
  flex: 0 0 auto; display: inline-flex; align-items: center; gap: 5px;
  font-family: var(--font-mono); font-size: 10px; letter-spacing: 0.08em; text-transform: uppercase;
  padding: 3px 8px; border-radius: 999px; color: var(--accent);
  background: color-mix(in srgb, var(--accent) 14%, transparent);
}
.pill i { width: 6px; height: 6px; border-radius: 999px; background: var(--accent); }
.cell.s-awaiting .pill i { animation: askPulse 1.1s ease-in-out infinite; }

.cell .cb { padding: 9px 13px 0; flex: 1; min-height: 0; display: flex; flex-direction: column; gap: 7px; }
.cell .tool {
  font-family: var(--font-mono); font-size: 11.5px; color: var(--text);
  background: rgba(7,20,15,0.5); border: 1px solid var(--line);
  border-radius: 7px; padding: 6px 9px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.cell .tool .dollar { color: var(--cyan); }
.cell .think { font-size: 12.5px; line-height: 1.45; color: var(--dim);
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.cell .think .cur { display: inline-block; width: 7px; height: 13px; background: var(--cyan);
  margin-left: 2px; vertical-align: -1px; animation: blink 1s steps(1) infinite; }
@keyframes blink { 50% { opacity: 0; } }

.cell .cf { display: flex; align-items: center; gap: 12px; padding: 9px 13px 11px; margin-top: auto;
  font-family: var(--font-mono); font-size: 10.5px; color: var(--faint); }
.cell .cf .k { color: var(--dim); }
.cell .cf .sp { flex: 1; }

/* tiny token gauge inside cell */
.tgauge { display: flex; align-items: center; gap: 6px; }
.tgauge .b { width: 44px; height: 4px; border-radius: 999px; background: rgba(255,255,255,0.1); overflow: hidden; }
.tgauge .b i { display: block; height: 100%; background: var(--cyan); }

/* awaiting prompt + yes/no */
.ask-box { padding: 9px 13px 12px; display: flex; flex-direction: column; gap: 9px; }
.ask-box .q { font-size: 13px; line-height: 1.4; color: var(--text); }
.ask-box .row { display: flex; gap: 8px; }
.btn {
  flex: 1; min-height: 40px; border-radius: 9px; border: 1px solid var(--line-2);
  font-family: var(--font-mono); font-size: 12px; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase;
  cursor: pointer; background: rgba(255,255,255,0.04); color: var(--text); transition: filter .15s, transform .1s;
}
.btn:active { transform: translateY(1px); }
.btn.yes { background: var(--attn); color: #1a1205; border-color: transparent; }
.btn.no  { background: transparent; color: var(--dim); }
.btn.danger { background: var(--error); color: #2a0c0c; border-color: transparent; }
.btn:hover { filter: brightness(1.06); }

/* size tiers — what each reveals */
.cell.t-sm .cb, .cell.t-sm .cf, .cell.t-md .think { display: none; }
.cell.t-sm .ch { padding: 0 12px; height: 100%; }
.cell.t-sm .who .pj { display: none; }
.cell.t-md .cb { padding-bottom: 4px; }
.cell.t-md .think { display: none; }
.cell.t-sm .pill { padding: 3px; background: transparent; }
.cell.t-sm .pill .pl { display: none; }
/* any narrow cell: drop the pill label to a dot so the name keeps its room */
@container (max-width: 234px) {
  .cell .pill { padding: 3px; background: transparent; }
  .cell .pill .pl { display: none; }
}
/* xs — avatar + status dot only */
.cell.t-xs { min-width: 0; }
.cell.t-xs::before { width: 2px; }
.cell.t-xs .xs-in { position: relative; height: 100%; display: grid; place-items: center; }
.cell.t-xs .xs-dot { position: absolute; top: 7px; right: 7px; width: 8px; height: 8px; border-radius: 999px; background: var(--accent); }
.cell.t-xs.s-awaiting .xs-dot { animation: askPulse 1.1s ease-in-out infinite; }

/* ───────── lanes (D2) ───────── */
.lane { display: flex; flex-direction: column; min-width: 0; background: rgba(10,32,28,0.4);
  border: 1px solid var(--line); border-radius: 14px; overflow: hidden; }
.lane > h4 { margin: 0; padding: 11px 14px; font-family: var(--font-mono); font-size: 11px; letter-spacing: 0.1em;
  text-transform: uppercase; color: var(--dim); border-bottom: 1px solid var(--line);
  display: flex; align-items: center; justify-content: space-between; }
.lane > h4 .ct { color: var(--faint); }
.lane .lbody { flex: 1; min-height: 0; overflow-y: auto; padding: 10px; display: flex; flex-direction: column; gap: 9px; }
.lane.hot { border-color: var(--line-2); box-shadow: 0 12px 36px -16px rgba(0,0,0,0.7); }

/* ───────── focus (D3) ───────── */
.focus-hero { position: relative; border-radius: 16px; overflow: hidden;
  background: linear-gradient(to bottom, rgba(22,65,60,0.6), rgba(12,38,34,0.7));
  border: 1px solid var(--line-2); display: flex; flex-direction: column; }
.rail { position: relative; overflow: hidden; }
.rail .rail-bg { position: absolute; inset: 0; }  /* terrarium behind */
.rail .rail-list { position: absolute; inset: 0; padding: 12px; display: flex; flex-direction: column; gap: 9px; z-index: 2; }
.minitile {
  display: flex; align-items: center; gap: 10px; padding: 9px 11px; border-radius: 11px;
  background: rgba(7,20,15,0.82); border: 1px solid var(--line); cursor: pointer;
  --accent: var(--cyan); transition: border-color .15s, background .15s;
}
.minitile::before { content: ''; width: 8px; height: 8px; border-radius: 999px; background: var(--accent); flex: 0 0 auto; }
.minitile.active, .minitile.linked { border-color: var(--accent); background: rgba(16,42,39,0.95); }
.minitile .mt-nm { flex: 1; min-width: 0; font-size: 12.5px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.minitile .mt-st { font-family: var(--font-mono); font-size: 10px; color: var(--accent); text-transform: uppercase; letter-spacing: 0.06em; }

/* ───────── control room (D4) ───────── */
.sidebar { border-left: 1px solid var(--line); background: rgba(8,24,20,0.5);
  display: flex; flex-direction: column; gap: 12px; padding: 14px; overflow: hidden; }
.panel { background: rgba(16,42,39,0.4); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; }
.panel h5 { margin: 0 0 9px; font-family: var(--font-mono); font-size: 10.5px; letter-spacing: 0.12em;
  text-transform: uppercase; color: var(--faint); }
.bigpct { font-family: var(--font-mono); font-size: 30px; font-weight: 600; font-variant-numeric: tabular-nums; }
.svc { display: flex; align-items: center; gap: 9px; padding: 5px 0; font-size: 13px; }
.svc i { width: 8px; height: 8px; border-radius: 999px; flex: 0 0 auto; }
.svc .d { margin-left: auto; font-family: var(--font-mono); font-size: 10.5px; color: var(--faint); white-space: nowrap; }
.porthole { position: relative; border-radius: 14px; overflow: hidden; border: 1px solid var(--line-2); }

/* ───────── detail overlay (shared) ───────── */
.detail-back { position: absolute; inset: 0; z-index: 20; background: rgba(5,14,11,0.66);
  backdrop-filter: blur(7px); display: flex; align-items: center; justify-content: center; padding: 40px;
  opacity: 0; pointer-events: none; transition: opacity .2s; }
.detail-back.open { opacity: 1; pointer-events: auto; }
.detail {
  width: min(620px, 100%); max-height: 100%; display: flex; flex-direction: column;
  border-radius: 16px; overflow: hidden; --accent: var(--cyan);
  background: linear-gradient(to bottom, #143b36, #0d2723);
  border: 1px solid var(--line-2); box-shadow: 0 40px 100px -30px #000;
  transform: scale(0.96); transition: transform .2s;
}
.detail-back.open .detail { transform: scale(1); }
.detail .dh { display: flex; align-items: center; gap: 12px; padding: 16px 18px; border-bottom: 1px solid var(--line); }
.detail .dh .ava { width: 30px; height: 30px; }
.detail .dh .nm { font-size: 17px; font-weight: 600; }
.detail .dh .pj { font-family: var(--font-mono); font-size: 11.5px; color: var(--dim); }
.detail .dh .x { margin-left: auto; width: 34px; height: 34px; border-radius: 8px; border: 1px solid var(--line);
  background: transparent; color: var(--dim); font-size: 18px; cursor: pointer; }
.detail .dbody { padding: 16px 18px; overflow-y: auto; display: flex; flex-direction: column; gap: 13px; }
.detail .dsec-l { font-family: var(--font-mono); font-size: 10px; letter-spacing: 0.14em; text-transform: uppercase; color: var(--faint); margin-bottom: 6px; }
.detail .log { font-family: var(--font-mono); font-size: 12px; line-height: 1.7; color: var(--dim);
  background: rgba(7,20,15,0.6); border: 1px solid var(--line); border-radius: 9px; padding: 11px 13px; max-height: 180px; overflow-y: auto; }
.detail .log .line { white-space: pre-wrap; }
.detail .log .line .t { color: var(--faint); margin-right: 8px; }
.detail .dfoot { padding: 14px 18px; border-top: 1px solid var(--line); display: flex; gap: 10px; }

/* scrollbars hidden (touch panel) */
.work *::-webkit-scrollbar, .detail *::-webkit-scrollbar, .lane *::-webkit-scrollbar { width: 0; height: 0; }
* { scrollbar-width: none; }

/* reduced motion / print safety */
@media (prefers-reduced-motion: reduce) {
  .cr, .bubble { animation: none !important; }
}
