/* yink — cryptographic instrument panel.
   Deep ink, warm bone text, amber accent. Everything mono, everything local. */

@font-face {
  font-family: "Martian Mono";
  src: url("/vendor/martian-mono.woff2") format("woff2");
  font-weight: 100 800;
  font-display: swap;
}

:root {
  --bg: #0b0e14;
  --panel: #10141d;
  --panel-2: #151a26;
  --line: #232a3a;
  --ink: #e8e3d5;
  --dim: #8b8fa3;
  --amber: #f0a63c;
  --amber-soft: rgba(240, 166, 60, 0.14);
  --green: #46d391;
  --teal: #4dd0e1;
  --red: #ff6b6b;
  --mono: "Martian Mono", ui-monospace, "Cascadia Code", Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--mono);
  font-size: 14px;
  line-height: 1.5;
  display: flex;
  flex-direction: column;
}

/* faint grain so the dark isn't flat */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  opacity: 0.05;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2'/%3E%3C/filter%3E%3Crect width='160' height='160' filter='url(%23n)' opacity='0.6'/%3E%3C/svg%3E");
}

header, main, #toast, #fatal { position: relative; z-index: 1; }

/* ---------- header ---------- */
header {
  display: flex;
  align-items: baseline;
  gap: 16px;
  padding: 18px 24px 10px;
  flex-wrap: wrap;
}

.brand {
  font-weight: 800;
  font-size: 22px;
  letter-spacing: -0.5px;
  color: var(--amber);
}

.brand .cursor { animation: blink 1.2s steps(1) infinite; }
@keyframes blink { 50% { opacity: 0; } }

.tagline { color: var(--dim); font-size: 12px; }

.chip {
  margin-left: auto;
  font-size: 11px;
  padding: 4px 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--dim);
  background: var(--panel);
  white-space: nowrap;
}
.chip.warn { color: var(--amber); border-color: var(--amber); }
.chip.ok { color: var(--green); border-color: var(--green); }

/* ---------- pairing screen ---------- */
.screen { flex: 1; display: flex; flex-direction: column; min-height: 0; }
.hidden { display: none !important; }

#pairing {
  max-width: 1060px;
  width: 100%;
  margin: 0 auto;
  padding: 20px 24px 32px;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 22px;
  align-items: stretch;
  align-content: start;
  flex: initial;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 22px;
  min-width: 0;
}

.panel h2 {
  margin: 0 0 16px;
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 3px;
  text-transform: uppercase;
  color: var(--dim);
}

.panel h2::before { content: "// "; color: var(--amber); }

.code-layout { display: flex; gap: 20px; }
.code-layout > div:first-child { flex: 1; min-width: 0; }

.words {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
  margin-bottom: 18px;
}

.word {
  border: 1px solid var(--line);
  border-left: 3px solid var(--amber);
  background: var(--panel-2);
  border-radius: 6px;
  padding: 9px 12px;
  font-size: 16px;
  font-weight: 600;
  letter-spacing: 0.5px;
  animation: rise 0.5s cubic-bezier(0.2, 0.9, 0.3, 1) both;
}

@keyframes rise {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: none; }
}

.word .idx {
  color: var(--amber);
  font-size: 10px;
  vertical-align: top;
  margin-right: 7px;
  font-weight: 400;
}

.qr-side { text-align: center; }

.qr-card {
  background: #fff;
  padding: 10px;
  border-radius: 8px;
  display: inline-block;
  line-height: 0;
}

.qr-card svg { width: 148px; height: 148px; }

.qr-note { color: var(--dim); font-size: 10.5px; margin: 10px 0 0; line-height: 1.6; }

.divider {
  display: flex;
  align-items: center;
  color: var(--dim);
  font-size: 11px;
  letter-spacing: 2px;
}

.divider span {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 6px 10px;
  background: var(--panel);
}

/* ---------- buttons + inputs ---------- */
.btn {
  font-family: var(--mono);
  font-size: 13px;
  color: var(--ink);
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 9px 16px;
  cursor: pointer;
  position: relative;
  transition: border-color 0.15s, background 0.15s, transform 0.05s;
}

.btn:hover:not(:disabled) { border-color: var(--amber); }
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled { opacity: 0.4; cursor: not-allowed; }

.btn.primary {
  background: var(--amber);
  border-color: var(--amber);
  color: #14100a;
  font-weight: 700;
}

.btn.primary:hover:not(:disabled) { filter: brightness(1.1); }
.btn.small { padding: 4px 10px; font-size: 12px; }

.btn .ico { color: var(--amber); }
.btn.primary .ico { color: inherit; }

/* pulsing rings while broadcasting / listening */
.btn .rings { display: none; }
.btn.live { border-color: var(--amber); background: var(--amber-soft); }
.btn.live .rings { display: inline-block; position: absolute; inset: 0; overflow: visible; pointer-events: none; }
.btn.live .rings i {
  position: absolute;
  inset: 0;
  border: 1px solid var(--amber);
  border-radius: 6px;
  animation: ring 1.8s ease-out infinite;
  opacity: 0;
}
.btn.live .rings i:nth-child(2) { animation-delay: 0.6s; }
.btn.live .rings i:nth-child(3) { animation-delay: 1.2s; }
@keyframes ring {
  0% { transform: scale(1); opacity: 0.7; }
  100% { transform: scale(1.25, 1.9); opacity: 0; }
}

.pair-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 14px; }

input[type="text"], textarea {
  font-family: var(--mono);
  color: var(--ink);
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 6px;
  outline: none;
}

input[type="text"] {
  width: 100%;
  padding: 12px 14px;
  font-size: 15px;
}

input[type="text"]:focus, textarea:focus { border-color: var(--amber); }

.hint { font-size: 11px; color: var(--dim); min-height: 18px; margin-top: 6px; }
.hint.ok { color: var(--green); }

.trust {
  grid-column: 1 / -1;
  text-align: center;
  color: var(--dim);
  font-size: 11px;
  letter-spacing: 0.4px;
  border-top: 1px dashed var(--line);
  padding-top: 16px;
}

/* ---------- session screen ---------- */
#session { padding: 0 24px 18px; max-width: 1200px; width: 100%; margin: 0 auto; }

.statusbar, .bottombar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 0;
}

.spacer { flex: 1; }

.dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; }
.dot.on { background: var(--green); box-shadow: 0 0 8px var(--green); }
.dot.off { background: var(--red); }

.badge {
  font-size: 10px;
  letter-spacing: 2px;
  text-transform: uppercase;
  padding: 4px 10px;
  border-radius: 4px;
  border: 1px solid;
}
.badge.relay { color: var(--amber); border-color: var(--amber); background: var(--amber-soft); }
.badge.p2p { color: var(--green); border-color: var(--green); background: rgba(70, 211, 145, 0.1); }
.badge.lan { color: var(--teal); border-color: var(--teal); background: rgba(77, 208, 225, 0.1); }
.badge.warn { color: var(--amber); border-color: var(--amber); }

.seal {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: 1px dashed var(--line);
  border-radius: 6px;
  padding: 3px 10px;
  cursor: help;
}
.fp-emoji { font-size: 16px; }
.fp-code { font-size: 11px; color: var(--dim); letter-spacing: 2px; }

/* ---------- shared terminal / shared local site ---------- */
.rs {
  margin: 0 16px 14px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 16px 18px;
}

.rs .spacer { flex: 1; }

.rs-head { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; }
.rs-head h3 {
  margin: 0;
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 3px;
  text-transform: uppercase;
  color: var(--dim);
}
.rs-head h3::before { content: "// "; color: var(--amber); }

.rs-note { margin: 0 0 12px; font-size: 12px; color: var(--dim); line-height: 1.6; }
.rs-actions { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }

.rs-cmdbox {
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 12px 14px;
  margin-bottom: 12px;
}
/* Wrap rather than scroll: the operator is being asked to run this, so the
   whole thing has to be readable without dragging a scrollbar. */
.rs-cmdbox code {
  display: block;
  font-family: var(--mono);
  font-size: 12px;
  line-height: 1.7;
  color: var(--ink);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.rs-code { font-size: 11px; color: var(--dim); letter-spacing: 1px; }
.rs-code b { color: var(--amber); font-weight: 500; letter-spacing: 0; }

.rs-warn {
  margin: 12px 0 0;
  padding-left: 12px;
  border-left: 2px solid var(--amber);
  font-size: 11px;
  color: var(--amber);
  line-height: 1.6;
}

.rs-opt {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 14px;
  font-size: 11px;
  color: var(--dim);
  cursor: pointer;
}

/* Sits between the role note and the command it changes, so it loses the
   standalone option's top gap. */
.rs-opt.tight { margin-top: 0; margin-bottom: 12px; }

.rs-port {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--ink);
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 5px 8px;
  width: 7em;
}
.rs-port:focus { outline: none; border-color: var(--amber); }

/* ---------- screen share / call view ---------- */
#media { min-height: 0; }
#mStage {
  position: relative;
  flex: 1;
  min-height: 0;
  margin: 0 16px;
  background: #05070b;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}
#mRemote {
  width: 100%;
  height: 100%;
  object-fit: contain;   /* letterbox: never crop someone's screen */
  background: #05070b;
}
.m-idle {
  position: absolute;
  color: var(--dim);
  font-size: 12px;
  text-align: center;
  padding: 0 24px;
  pointer-events: none;
}
.m-local {
  position: absolute;
  right: 12px;
  bottom: 12px;
  width: 22%;
  max-width: 260px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #05070b;
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.5);
}
#mStatus { padding: 6px 18px 12px; }
.btn.small.live { border-color: var(--amber); background: var(--amber-soft); color: var(--amber); }

/* ---------- helper terminal view ---------- */
#terminal { min-height: 0; }
#termWrap {
  flex: 1;
  min-height: 0;
  margin: 0 16px;
  padding: 10px;
  background: #05070b;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
}
#termWrap .xterm { height: 100%; }
.t-host { font-size: 11px; color: var(--dim); }
#tStatus { padding: 6px 18px 12px; }

.tabstrip { display: flex; align-items: center; gap: 8px; padding-bottom: 8px; overflow-x: auto; }
#tabs { display: flex; gap: 6px; }

.tab {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--dim);
  background: var(--panel);
  border: 1px solid var(--line);
  border-bottom: 2px solid transparent;
  border-radius: 6px 6px 0 0;
  padding: 6px 12px;
  cursor: pointer;
  white-space: nowrap;
}

.tab.active {
  color: var(--ink);
  border-bottom-color: var(--amber);
  background: var(--panel-2);
}

.tab .x { margin-left: 8px; color: var(--dim); }
.tab .x:hover { color: var(--red); }

#editor {
  flex: 1;
  width: 100%;
  min-height: 200px;
  resize: none;
  padding: 16px;
  font-size: 14.5px;
  line-height: 1.6;
  border-radius: 0 8px 8px 8px;
  background: var(--panel);
}

.autocopy { font-size: 11.5px; color: var(--dim); display: flex; gap: 6px; align-items: center; }
.autocopy input { accent-color: var(--amber); }

/* ---------- transfers ---------- */
#transfers { display: flex; flex-direction: column; gap: 6px; }

.transfer {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 12px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 8px 12px;
}

.t-dir { color: var(--amber); }
.transfer.in .t-dir { color: var(--green); }
.t-name { max-width: 40%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.t-size { color: var(--dim); }
.transfer progress { flex: 1; height: 6px; accent-color: var(--amber); }
.t-status { color: var(--dim); margin-left: auto; }

.t-save {
  margin-left: auto;
  color: #14100a;
  background: var(--green);
  border-radius: 4px;
  padding: 3px 12px;
  font-weight: 700;
  text-decoration: none;
}

/* ---------- overlays ---------- */
#dropOverlay {
  position: fixed;
  inset: 0;
  background: rgba(11, 14, 20, 0.85);
  border: 3px dashed var(--amber);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  color: var(--amber);
  z-index: 50;
}

#fatal {
  position: fixed;
  inset: 0;
  background: rgba(11, 14, 20, 0.92);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}

.fatal-box {
  background: var(--panel);
  border: 1px solid var(--red);
  border-radius: 10px;
  padding: 28px;
  max-width: 460px;
  margin: 20px;
}

.fatal-title { color: var(--red); font-weight: 700; margin-bottom: 10px; }
.fatal-box p { color: var(--dim); font-size: 13px; }

#toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translate(-50%, 80px);
  background: var(--panel-2);
  border: 1px solid var(--amber);
  color: var(--ink);
  border-radius: 8px;
  padding: 10px 18px;
  font-size: 13px;
  opacity: 0;
  transition: transform 0.25s, opacity 0.25s;
  z-index: 200;
  max-width: 90vw;
}

#toast.show { transform: translate(-50%, 0); opacity: 1; }

/* ---------- responsive ---------- */
@media (max-width: 860px) {
  #pairing { grid-template-columns: 1fr; }
  .divider { justify-content: center; }
  .code-layout { flex-direction: column; align-items: center; }
  .words { width: 100%; }
  header { padding: 14px 16px 8px; }
  #session { padding: 0 12px 12px; }
}

/* ---------- copy affordances ---------- */
.btn.ok { border-color: var(--green); color: var(--green); }
.btn.ghost { background: transparent; color: var(--dim); border-style: dashed; }
.btn.ghost:hover:not(:disabled) { color: var(--ink); border-color: var(--teal); }

/* ---------- agent session ----------
   Teal, not amber: an AI in the room is a different kind of presence from the
   human chrome around it, and the approval prompts have to read as prompts. */
.ai {
  border: 1px solid var(--teal);
  border-left: 3px solid var(--teal);
  background: linear-gradient(180deg, rgba(77, 208, 225, 0.07), transparent);
  margin: 0 0 10px;
  padding: 10px 12px;
}

.ai-head { display: flex; align-items: center; gap: 8px; font-size: 12px; }
.ai-mark { color: var(--teal); }
.ai-who { color: var(--ink); }
.ai-policy { color: var(--dim); font-size: 10.5px; }

.ai-reqs { display: flex; flex-direction: column; gap: 6px; }
.ai-reqs:not(:empty) { margin-top: 10px; }

.ai-req {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  background: var(--panel-2);
  animation: ai-in 160ms ease-out;
}
.ai-req.live { border-color: var(--teal); }
.ai-req-ico { color: var(--teal); font-size: 15px; }
.ai-req-body { display: flex; flex-direction: column; gap: 2px; flex: 1; min-width: 0; }
.ai-req-body b { font-weight: 600; font-size: 12px; }
.ai-req-note { color: var(--dim); font-size: 10.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ai-req-always { color: var(--dim); font-size: 10px; display: flex; align-items: center; gap: 4px; white-space: nowrap; }

.ai-log { margin-top: 8px; display: flex; flex-direction: column; gap: 2px; }
.ai-log-row { color: var(--dim); font-size: 10.5px; }
.ai-log-row::before { content: "· "; color: var(--teal); }

@keyframes ai-in { from { opacity: 0; transform: translateY(-3px); } to { opacity: 1; transform: none; } }

@media (max-width: 620px) {
  .ai-req { flex-wrap: wrap; }
  .ai-req-always { order: 3; }
}

/* A request with no stated reason should look like one. */
.ai-req-note.bare { opacity: 0.55; font-style: italic; }

/* Two seals, two jobs: the room seal is the one a person compares (stable for
   the session), the link seal fingerprints this handshake and churns whenever
   an agent reconnects. Weight them accordingly. */
.seal.link { opacity: 0.5; font-size: 11px; }
.seal.room .fp-label {
  color: var(--dim);
  font-size: 9.5px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin-right: 5px;
}

/* ---------- first contact ----------
   The one moment the continuity pin cannot protect: nothing is pinned yet, so
   a person has to vouch for the peer. Deliberately blocking. */
#fcPanel {
  position: fixed;
  inset: 0;
  background: rgba(11, 14, 20, 0.94);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 110;
  padding: 20px;
}

.fc-box {
  background: var(--panel);
  border: 1px solid var(--teal);
  border-left: 3px solid var(--teal);
  padding: 22px 24px;
  max-width: 540px;
}

.fc-title { color: var(--teal); font-size: 15px; margin-bottom: 12px; }
.fc-who { font-size: 13px; margin: 0 0 12px; }
.fc-note { color: var(--dim); font-size: 11px; line-height: 1.7; margin: 0 0 14px; }
.fc-note.dim { opacity: 0.7; margin: 14px 0 0; }

.fc-sealrow {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  background: var(--panel-2);
  margin-bottom: 16px;
}
.fc-seal-label { color: var(--dim); font-size: 10.5px; }
.fc-actions { display: flex; gap: 10px; }

/* ---------- "use it with an AI" ----------
   #pairing is a three-column grid (code | or | their code); this block is a
   footer to both, so it spans the lot. */
.ai-setup { grid-column: 1 / -1; margin-top: 4px; }
.ai-setup-note { color: var(--dim); font-size: 11px; line-height: 1.7; margin: 0 0 4px; }
.ai-setup-note.dim { opacity: 0.7; margin: 12px 0 0; }
.ai-setup .pair-actions a.btn { text-decoration: none; display: inline-flex; align-items: center; }
