/* Sharerare Shell. See DESIGN.md. Sharerare's graphite and link lights:
   the only colour on the page (outside the terminal) is link state. */

@font-face {
  font-family: "Inter Variable";
  font-style: normal; font-weight: 100 900; font-display: swap;
  src: url(/fonts/inter-latin-ext.woff2) format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: "Inter Variable";
  font-style: normal; font-weight: 100 900; font-display: swap;
  src: url(/fonts/inter-latin.woff2) format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

:root {
  color-scheme: dark;
  --bg: #08090a;
  --raise: #0e0f11;
  --raise-2: #15161a;
  --hover: rgba(255, 255, 255, .04);
  --press: rgba(255, 255, 255, .07);
  --line: rgba(255, 255, 255, .07);
  --line-2: rgba(255, 255, 255, .12);
  --ink: #f3f4f5;
  --ink-2: #c5c8ce;
  --ink-3: #8c9199;
  --ink-4: #686c75;
  --led: #46e08f;
  --led-halo: rgba(70, 224, 143, .14);
  --led-glow: rgba(70, 224, 143, .6);
  --amber: #f0b648;
  --red: #f0646a;
  --font: "Inter Variable", Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --mono: ui-monospace, "SF Mono", "JetBrains Mono", Menlo, Consolas, "DejaVu Sans Mono", monospace;
  --ease-out: cubic-bezier(.22, 1, .36, 1);
  --spring: var(--ease-out);
  --t-micro: 120ms;
  --t-std: 220ms;
  --t-large: 380ms;
  --r-sm: 6px;
  --r: 10px;
  --rail: 280px;
}
@supports (transition-timing-function: linear(0, 1)) {
  :root {
    /* stiffness 520, damping 34: crisp, ~3% overshoot, settles in 360ms */
    --spring: linear(0, 0.037, 0.128, 0.246, 0.375, 0.502, 0.618, 0.719, 0.804, 0.872, 0.925, 0.965, 0.993, 1.011, 1.022, 1.028, 1.03, 1.029, 1.026, 1.023, 1.019, 1.015, 1.012, 1.009, 1.006, 1.004, 1.002, 1.001, 1);
  }
}

* { box-sizing: border-box; }
html, body { height: 100%; }
html { -webkit-text-size-adjust: 100%; background: var(--bg); }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink-2);
  font: 13px/1.5 var(--font);
  letter-spacing: -.006em;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}
.mono { font-family: var(--mono); font-variant-numeric: tabular-nums; letter-spacing: 0; }
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; -webkit-tap-highlight-color: transparent; }
button:focus-visible, a:focus-visible, summary:focus-visible, input:focus-visible + .track { outline: 1.5px solid var(--ink); outline-offset: 2px; border-radius: var(--r-sm); }
a { color: var(--ink-3); text-decoration: none; }
a:hover { color: var(--ink); }
[hidden] { display: none !important; }

.app {
  display: grid;
  grid-template-columns: var(--rail) 1fr;
  height: 100dvh;
}

/* ---------- rail ---------- */
.rail {
  display: flex;
  flex-direction: column;
  min-height: 0;
  border-right: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(255, 255, 255, .018), transparent 240px), var(--bg);
  padding: max(14px, env(safe-area-inset-top)) 10px max(10px, env(safe-area-inset-bottom)) max(10px, env(safe-area-inset-left));
}
.brand {
  position: relative;
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 2px 6px 14px;
}
.mark { position: relative; display: inline-flex; align-items: center; width: 34px; height: 14px; }
.mark .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--ink); }
.mark .wire { width: 8px; height: 1.6px; background: var(--ink); }
.mark .prompt { font: 600 11px/1 var(--mono); font-style: normal; color: var(--led); margin-left: 2px; text-shadow: 0 0 8px var(--led-glow); }
.word { color: var(--ink); font-weight: 590; letter-spacing: -.01em; }
.word b { font-weight: 590; color: var(--ink-3); }
.keychip {
  margin-left: auto;
  padding: 3px 7px;
  border-radius: 999px;
  border: 1px solid var(--line);
  color: var(--ink-4);
  font-size: 11px;
  transition: color var(--t-micro), border-color var(--t-micro);
}
.keychip:hover { color: var(--ink-2); border-color: var(--line-2); }

.new {
  display: flex;
  align-items: center;
  gap: 8px;
  height: 34px;
  padding: 0 12px;
  margin: 0 0 10px;
  border-radius: 7px;
  border: 1px solid var(--line-2);
  color: var(--ink);
  font-weight: 510;
  transition: background var(--t-micro), transform var(--t-micro) var(--spring);
}
.new span { color: var(--ink-3); font-size: 15px; line-height: 1; }
.new:hover { background: var(--hover); }
.new:active { transform: scale(.97); background: var(--press); }

.ports { list-style: none; margin: 0; padding: 0; overflow-y: auto; min-height: 0; }
.foot { margin-top: auto; }
.port {
  position: relative;
  display: grid;
  grid-template-columns: 14px 1fr auto;
  grid-template-rows: auto auto;
  column-gap: 10px;
  align-items: center;
  padding: 8px 10px;
  border-radius: 8px;
  cursor: pointer;
  outline: none;
  transition: background var(--t-micro);
  animation: arrive 420ms var(--spring) both;
}
.port + .port { margin-top: 2px; }
.port:hover { background: var(--hover); }
.port[aria-selected="true"] { background: var(--raise-2); }
.port:focus-visible { box-shadow: inset 2px 0 0 var(--ink); background: var(--hover); }
.port .led { grid-row: 1 / span 2; }
.port .name { color: var(--ink); font-weight: 510; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.port .who { grid-column: 2; font-size: 11.5px; color: var(--ink-4); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.port .link { grid-column: 3; grid-row: 1 / span 2; font-size: 11px; color: var(--ink-4); text-align: right; white-space: nowrap; }
.port[data-state="ready"] .link { color: var(--ink-3); }
.port[data-state="denied"] .link, .port[data-state="wrong-agent"] .link { color: var(--red); }
.port.pending .name { color: var(--ink-3); font-weight: 400; }
@keyframes arrive { from { opacity: 0; transform: scale(.84); filter: blur(5px); } }

/* Link lights: the only colour. */
.led {
  position: relative;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  justify-self: center;
  background: transparent;
  box-shadow: inset 0 0 0 1.5px var(--ink-4);
  flex: none;
}
.led[data-state="ready"] { background: var(--led); box-shadow: 0 0 0 3px var(--led-halo), 0 0 10px var(--led-glow); }
.led[data-state="linking"], .led[data-state="lost"], .led[data-state="signaling"] { background: var(--amber); box-shadow: none; animation: blink 1.1s ease-in-out infinite; }
.led[data-state="denied"], .led[data-state="wrong-agent"] { background: var(--red); box-shadow: none; }
.led[data-state="waiting"], .led[data-state="off"] { background: transparent; }
.led.ring::after {
  content: "";
  position: absolute;
  inset: -1px;
  border-radius: 50%;
  border: 1.5px solid var(--led);
  animation: ring 700ms var(--ease-out) forwards;
}
@keyframes blink { 50% { opacity: .35; } }
@keyframes ring { to { transform: scale(3.4); opacity: 0; } }

.tell {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 6px 10px;
  color: var(--ink-3);
}
.tell svg { width: 16px; height: 16px; flex: none; fill: none; stroke: var(--ink-4); stroke-width: 1.4; stroke-linecap: round; stroke-linejoin: round; }
.tell svg circle { fill: var(--ink-4); stroke: none; }
.tell.center { position: absolute; inset: 0; justify-content: center; margin: 0; }

.foot { display: flex; gap: 6px; padding: 10px 8px 0; font-size: 11px; color: var(--ink-4); flex-wrap: wrap; }

/* ---------- stage ---------- */
.stage { position: relative; min-width: 0; min-height: 0; }

.term { position: absolute; inset: 0; display: flex; flex-direction: column; animation: fade 150ms ease-out; }
@keyframes fade { from { opacity: 0; } }
.bar {
  position: relative;
  display: flex;
  align-items: center;
  gap: 6px;
  height: 42px;
  padding: 0 10px 0 6px;
  border-bottom: 1px solid var(--line);
  flex: none;
}
.back { display: none; width: 34px; height: 34px; border-radius: 7px; place-items: center; }
.back svg { width: 16px; height: 16px; fill: none; stroke: var(--ink-2); stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.tabs { display: flex; gap: 2px; min-width: 0; overflow-x: auto; scrollbar-width: none; }
.tab {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 28px;
  padding: 0 6px 0 10px;
  border-radius: 6px;
  color: var(--ink-3);
  white-space: nowrap;
  transition: background var(--t-micro), color var(--t-micro);
}
.tab:hover { background: var(--hover); color: var(--ink-2); }
.tab[aria-selected="true"] { background: var(--raise-2); color: var(--ink); }
.tab .x { width: 18px; height: 18px; display: grid; place-items: center; border-radius: 4px; color: var(--ink-4); font-size: 13px; line-height: 1; }
.tab .x:hover { background: var(--press); color: var(--ink); }
.tab.gone { color: var(--ink-4); text-decoration: line-through; }
.tab-add { width: 28px; height: 28px; border-radius: 6px; color: var(--ink-3); font-size: 16px; flex: none; }
.tab-add:hover { background: var(--hover); color: var(--ink); }
.spacer { flex: 1; }
.facts { position: relative; display: flex; align-items: center; gap: 10px; color: var(--ink-4); font-size: 11.5px; min-width: 0; }
.rxtx { display: inline-flex; gap: 3px; }
.rxtx i { width: 5px; height: 5px; border-radius: 50%; background: rgba(255, 255, 255, .1); transition: background 60ms; }
.rxtx i.on { background: var(--led); box-shadow: 0 0 6px var(--led-glow); }
.route { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.code { color: var(--ink-3); padding: 2px 6px; border-radius: 5px; border: 1px solid var(--line); font-size: 11px; }
.code:hover { color: var(--ink); border-color: var(--line-2); }
.end {
  height: 28px;
  padding: 0 11px;
  border-radius: 6px;
  border: 1px solid var(--line-2);
  color: var(--ink-2);
  transition: border-color var(--t-micro), color var(--t-micro), transform var(--t-micro) var(--spring);
}
.end:hover { border-color: rgba(240, 100, 106, .5); color: var(--red); }
.end:active { transform: scale(.97); }
.confirm {
  position: absolute;
  right: 8px;
  top: 6px;
  display: flex;
  align-items: center;
  gap: 8px;
  height: 30px;
  padding: 0 4px 0 12px;
  border-radius: 8px;
  background: var(--raise-2);
  border: 1px solid var(--line-2);
  box-shadow: 0 10px 30px rgba(0, 0, 0, .5);
  color: var(--ink);
  z-index: 5;
  animation: pop 220ms var(--spring);
}
@keyframes pop { from { opacity: 0; transform: translateY(-4px) scale(.98); } }
.danger { height: 24px; padding: 0 10px; border-radius: 5px; background: var(--red); color: #1a0a0b; font-weight: 590; }
.quiet { display: inline-flex; align-items: center; height: 28px; padding: 0 11px; border-radius: 6px; border: 1px solid var(--line-2); color: var(--ink-2); }
.quiet:hover { background: var(--hover); color: var(--ink); }

.screens { position: relative; flex: 1; min-height: 0; }
.screen { position: absolute; inset: 0; padding: 8px 0 4px 10px; }
.screen .xterm { height: 100%; letter-spacing: 0; font-variant-numeric: normal; font-feature-settings: normal; -webkit-font-smoothing: auto; }
.code, .keychip { white-space: nowrap; flex: none; }
.screen .xterm-viewport { background: var(--bg) !important; scrollbar-width: thin; scrollbar-color: rgba(255,255,255,.12) transparent; }

.strip {
  position: absolute;
  left: 50%;
  bottom: 18px;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 12px;
  border-radius: 8px;
  background: var(--raise-2);
  border: 1px solid var(--line-2);
  box-shadow: 0 10px 30px rgba(0, 0, 0, .5);
  color: var(--ink);
  z-index: 4;
  animation: pop 220ms var(--spring);
}
.term:has(.keys:not([hidden])) .strip { bottom: 62px; }

.keys { display: none; gap: 4px; padding: 6px 8px max(6px, env(safe-area-inset-bottom)); border-top: 1px solid var(--line); overflow-x: auto; flex: none; scrollbar-width: none; }
.keys button { flex: none; min-width: 40px; height: 34px; padding: 0 8px; border-radius: 6px; background: var(--raise-2); color: var(--ink-2); font: 12px var(--mono); }
.keys button:active { background: var(--press); }
.keys button[aria-pressed="true"] { background: var(--ink); color: var(--bg); }

/* ---------- panels ---------- */
.panel { position: absolute; inset: 0; display: grid; grid-template-columns: minmax(0, 1fr); place-items: center; padding: 24px; overflow-y: auto; background: var(--bg); animation: fade 150ms ease-out; z-index: 6; }
.card { width: min(620px, 100%); }
.card h1 { margin: 0 0 14px; font-size: 18px; font-weight: 590; color: var(--ink); letter-spacing: -.015em; }
.lead { margin: -6px 0 14px; color: var(--ink-3); }
.cmd {
  position: relative;
  display: flex;
  align-items: center;
  gap: 8px;
  height: 46px;
  padding: 0 6px 0 14px;
  border-radius: var(--r);
  background: var(--raise);
  border: 1px solid var(--line-2);
}
.cmd code {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  white-space: nowrap;
  color: var(--ink);
  font-size: 12.5px;
  -webkit-mask-image: linear-gradient(90deg, #000 85%, transparent);
  mask-image: linear-gradient(90deg, #000 85%, transparent);
  user-select: all;
}
.cmd code .flag { color: var(--led); }
.copy { flex: none; height: 32px; padding: 0 14px; border-radius: 7px; background: var(--ink); color: var(--bg); font-weight: 510; transition: transform var(--t-micro) var(--spring); min-width: 76px; }
.copy:active { transform: scale(.97); }
.row { display: flex; align-items: center; gap: 12px; margin: 14px 2px 0; flex-wrap: wrap; }
.note { color: var(--ink-4); font-size: 12px; }
.switch { display: inline-flex; align-items: center; gap: 9px; color: var(--ink-2); cursor: pointer; }
.switch input { position: absolute; opacity: 0; pointer-events: none; }
.track { position: relative; width: 28px; height: 16px; border-radius: 999px; background: var(--raise-2); box-shadow: inset 0 0 0 1px var(--line-2); transition: background var(--t-std); }
.knob { position: absolute; top: 2px; left: 2px; width: 12px; height: 12px; border-radius: 50%; background: var(--ink-3); transition: transform var(--t-std) var(--spring), background var(--t-std); }
.switch input:checked + .track { background: rgba(70, 224, 143, .25); }
.switch input:checked + .track .knob { transform: translateX(12px); background: var(--led); }
.waiting { display: flex; align-items: center; gap: 10px; margin: 22px 2px 0; color: var(--ink); }
.waiting[data-state="denied"] { color: var(--red); }
.more { margin: 20px 2px 0; color: var(--ink-3); }
.more summary { cursor: pointer; color: var(--ink-4); list-style: none; width: max-content; }
.more summary::before { content: "ⓘ "; }
.more summary:hover { color: var(--ink-2); }
.more p { margin: 8px 0 0; max-width: 60ch; }
.actions { display: flex; gap: 8px; margin-top: 24px; }

/* ---------- tips and toast ---------- */
.tip {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  width: max-content;
  max-width: min(300px, calc(100vw - 24px));
  padding: 9px 11px;
  border-radius: 8px;
  background: var(--raise-2);
  border: 1px solid var(--line-2);
  box-shadow: 0 10px 30px rgba(0, 0, 0, .5);
  color: var(--ink-2);
  font-size: 12px;
  line-height: 1.45;
  opacity: 0;
  transform: translateY(-4px);
  pointer-events: none;
  transition: opacity 110ms, transform 110ms;
  z-index: 10;
}
.brand .tip { left: 6px; right: auto; }
:is(.keychip, .code):is(:hover, :focus-visible) + .tip, .tip.open { opacity: 1; transform: none; transition-duration: 140ms; transition-delay: 140ms; }

.toast {
  position: fixed;
  left: 50%;
  bottom: max(20px, env(safe-area-inset-bottom));
  transform: translate(-50%, 12px);
  padding: 8px 14px;
  border-radius: 8px;
  background: var(--raise-2);
  border: 1px solid var(--line-2);
  color: var(--ink);
  opacity: 0;
  pointer-events: none;
  transition: opacity 150ms, transform 150ms;
  z-index: 20;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); transition: opacity 220ms, transform 340ms var(--spring); }

/* ---------- phones ---------- */
@media (max-width: 760px) {
  .app { grid-template-columns: 1fr; }
  .rail { border-right: 0; }
  .app[data-view="term"] .rail, .app[data-view="list"] .stage { display: none; }
  .app[data-view="list"]:has(.panel:not([hidden])) .stage { display: block; position: fixed; inset: 0; }
  .back { display: grid; }
  .keys { display: flex; }
  .route { max-width: 30vw; }
  .rxtx { display: none; }
  .tab { max-width: 34vw; }
  .tab span:first-child { overflow: hidden; text-overflow: ellipsis; }
  .facts .code { display: none; }
  .port { padding: 11px 10px; }
  .screen { padding-left: 4px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 1ms !important; animation-iteration-count: 1 !important; transition-duration: 1ms !important; }
  .led[data-state="linking"], .led[data-state="lost"], .led[data-state="signaling"] { opacity: .6; }
}
