/* The box's console (Plane C-46): Tavenor's "Signal" look, as app.tavenor.io. Served by the box's
   Caddy from root-owned files; no inline styles (the CSP forbids them). */

@font-face {
  font-family: 'Onest';
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url('fonts/onest-latin-wght-normal.woff2') format('woff2');
}

@font-face {
  font-family: 'DM Mono';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url('fonts/dm-mono-latin-400-normal.woff2') format('woff2');
}

@font-face {
  font-family: 'DM Mono';
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url('fonts/dm-mono-latin-500-normal.woff2') format('woff2');
}

:root {
  color-scheme: light;
  --ink: #101114;
  --ink-hover: #2a2c31;
  --red: #df2638;
  --red-tint: #fff0f2;
  --ok: #087b4c;
  --ok-pale: #ecfdf3;
  --warn: #7a4a00;
  --warn-pale: #fff8e6;
  --err: #b42318;
  --err-pale: #fef3f2;
  --bg: #ffffff;
  --bg-alt: #f5f6f8;
  --text: #101114;
  --text-muted: #64666e;
  --border: #dfe0e4;
  --dark-bg: #101114;
  --dark-surface: #1c1d21;
  --dark-raised: #2a2b30;
  --dark-text: #ffffff;
  --dark-muted: #c9c9c9;
  --dark-border: rgba(255, 255, 255, 0.16);
  --font: 'Onest', system-ui, -apple-system, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  --font-mono: 'DM Mono', ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
  /* Density B (Karol, W-60), App's names and values (app.css): compact text and controls; on phones
     40px tap targets and 16px text in text boxes. */
  --fs-xs: 0.75rem;
  --fs-sm: 0.8125rem;
  --fs-base: 0.875rem;
  --fs-md: 0.9375rem;
  --fs-lg: 1.0625rem;
  --fs-xl: 1.25rem;
  --lh-body: 1.45;
  --control-h: 2rem;
  --control-h-sm: 1.75rem;
  --control-pad-x: 0.75rem;
  --card-pad: 1rem;
  --mark: 1.75rem;
  --stack-gap: 0.75rem;
  --tap-min: 2.5rem;
  --radius: 0.75rem;
  --radius-btn: 0.5rem;
  --radius-sm: 0.375rem;
  --shadow: 0 1px 2px rgba(16, 17, 20, 0.05), 0 8px 24px rgba(16, 17, 20, 0.06);
}

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

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

body {
  font-family: var(--font);
  font-size: var(--fs-base);
  line-height: var(--lh-body);
  color: var(--text);
  background: var(--bg-alt);
  -webkit-text-size-adjust: 100%;
}

[hidden] {
  display: none !important;
}

/* Words for a computer or a phone (signin.js marks the page); a computer's until it does. */
.on-phone,
.is-phone .on-computer {
  display: none;
}

.is-phone .on-phone {
  display: revert;
}

a {
  color: var(--ink);
}

button {
  font: inherit;
  color: inherit;
  cursor: pointer;
}

:focus-visible {
  outline: 2px solid var(--ink);
  outline-offset: 2px;
}

.mono {
  font-family: var(--font-mono);
}

/* ---------- Buttons ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  min-height: var(--control-h);
  padding: 0 var(--control-pad-x);
  font-size: var(--fs-base);
  border: 1px solid var(--ink);
  border-radius: var(--radius-btn);
  background: var(--ink);
  color: #fff;
  font-weight: 600;
  text-decoration: none;
}

.btn:hover {
  background: var(--ink-hover);
}

.btn-quiet {
  background: #fff;
  color: var(--ink);
  border-color: var(--border);
}

.btn-quiet:hover {
  background: var(--bg-alt);
  border-color: var(--ink);
}

.btn-block {
  width: 100%;
}

.btn-link {
  border: 0;
  background: none;
  padding: 0;
  text-decoration: underline;
  text-underline-offset: 0.2em;
}

/* ---------- Sign-in pages: one card in the middle ---------- */

.page {
  min-height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 1.25rem 1rem 2rem;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  text-decoration: none;
  color: var(--ink);
}

.brand-mark {
  width: 1.5rem;
  height: 1.5rem;
  border-radius: 0.4rem;
  background: var(--ink);
  position: relative;
  flex: none;
}

.brand-mark::after {
  content: '';
  position: absolute;
  left: 0.38rem;
  right: 0.38rem;
  bottom: 0.38rem;
  height: 0.19rem;
  border-radius: 1px;
  background: var(--red);
}

.page .brand {
  margin: 0.25rem 0 1.25rem;
}

.card {
  width: 100%;
  max-width: 24rem;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: var(--card-pad);
}

.card h1 {
  font-size: var(--fs-lg);
  line-height: 1.25;
  letter-spacing: -0.03em;
  margin: 0 0 0.35rem;
}

.card p {
  margin: 0 0 0.75rem;
}

.card form + p,
.card .btn-block + p {
  margin-top: 0.75rem;
}

.muted {
  color: var(--text-muted);
}

.small {
  font-size: var(--fs-sm);
}

.box-name {
  font-family: var(--font-mono);
  font-size: var(--fs-sm);
  background: var(--bg-alt);
  border-radius: 0.3rem;
  padding: 0.05rem 0.35rem;
  overflow-wrap: anywhere;
}

.choices {
  display: grid;
  gap: var(--stack-gap);
  margin: 1rem 0 0.25rem;
}

.choice {
  display: grid;
  grid-template-columns: var(--mark) 1fr;
  gap: 0.1rem 0.75rem;
  align-items: center;
  width: 100%;
  text-align: left;
  padding: 0.65rem 0.85rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-btn);
  background: #fff;
}

.choice:hover {
  border-color: var(--ink);
}

.choice-icon {
  grid-row: span 2;
  width: var(--mark);
  height: var(--mark);
  border-radius: 50%;
  background: var(--bg-alt);
  display: grid;
  place-items: center;
}

.choice-icon svg {
  width: 1.1rem;
  height: 1.1rem;
  stroke: var(--ink);
  fill: none;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.choice-title {
  font-weight: 600;
}

.choice-note {
  font-size: var(--fs-sm);
  color: var(--text-muted);
  line-height: 1.4;
}

.tag {
  display: inline-block;
  margin-left: 0.4rem;
  font-size: 0.6875rem;
  font-weight: 600;
  padding: 0.05rem 0.4rem;
  border-radius: 0.375rem;
  background: var(--ok-pale);
  color: var(--ok);
  vertical-align: 0.1em;
}

.steps {
  list-style: none;
  padding: 0;
  margin: 0 0 1rem;
  display: flex;
  gap: 0.4rem;
}

.steps li {
  flex: 1;
  height: 0.25rem;
  border-radius: 1px;
  background: var(--border);
}

.steps li.done {
  background: var(--red);
}

.field {
  display: block;
  margin: 0.75rem 0;
}

.field span {
  display: block;
  font-weight: 600;
  margin-bottom: 0.25rem;
  font-size: var(--fs-sm);
}

.code-input {
  width: 100%;
  font-family: var(--font-mono);
  font-size: var(--fs-md);
  letter-spacing: 0.5em;
  text-align: center;
  height: var(--control-h);
  padding: 0 0 0 0.5em;
  border: 1px solid var(--border-strong, #8a8a8a);
  border-radius: var(--radius-btn);
  background: #fff;
}

.code-input:focus {
  outline: 2px solid var(--ink);
  outline-offset: 1px;
}

.qr {
  display: grid;
  place-items: center;
  margin: 1rem 0;
}

.qr img,
.qr svg {
  width: 11rem;
  height: 11rem;
  image-rendering: pixelated;
}

.secret {
  font-family: var(--font-mono);
  font-size: var(--fs-sm);
  word-spacing: 0.4em;
  text-align: center;
  background: var(--bg-alt);
  border-radius: var(--radius-sm);
  padding: 0.5rem;
  overflow-wrap: anywhere;
}

details.secret-box summary {
  cursor: pointer;
  font-size: var(--fs-sm);
  color: var(--text-muted);
  margin-bottom: 0.5rem;
}

.note {
  border-radius: var(--radius-sm);
  padding: 0.55rem 0.75rem;
  margin: 0 0 0.75rem;
  font-size: var(--fs-sm);
  line-height: 1.45;
}

.note-warn {
  background: var(--warn-pale);
  color: var(--warn);
}

.note-err {
  background: var(--err-pale);
  color: var(--err);
}

.note-ok {
  background: var(--ok-pale);
  color: var(--ok);
}

.foot {
  margin-top: 1rem;
  max-width: 24rem;
  text-align: center;
  font-size: var(--fs-xs);
  color: var(--text-muted);
}

.foot p {
  margin: 0.25rem 0;
}

/* ---------- The console: bar, tabs, terminal, key bar ---------- */

.console {
  height: 100%;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  background: var(--dark-bg);
  color: var(--dark-text);
}

.topbar {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.35rem 0.75rem;
  background: #fff;
  color: var(--ink);
  border-bottom: 1px solid var(--border);
  flex: none;
}

.topbar .brand {
  font-size: var(--fs-base);
  min-width: 0;
}

.topbar .brand-text {
  display: flex;
  flex-direction: column;
  line-height: 1.15;
  min-width: 0;
}

.topbar .brand-box {
  font-family: var(--font-mono);
  font-weight: 400;
  font-size: var(--fs-xs);
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.tabs {
  display: flex;
  gap: 0.25rem;
  margin-left: auto;
}

.tab {
  border: 0;
  background: none;
  padding: 0.3rem 0.6rem;
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-size: var(--fs-base);
  color: var(--text-muted);
  white-space: nowrap;
}

.tab:hover {
  color: var(--ink);
  background: var(--bg-alt);
}

.tab[aria-selected='true'] {
  color: var(--ink);
  box-shadow: inset 0 -2px 0 var(--red);
  border-radius: var(--radius-sm) var(--radius-sm) 0 0;
}

.tab .soon {
  display: inline;
  font-size: 0.625rem;
  font-weight: 600;
  margin-left: 0.3rem;
  padding: 0.05rem 0.35rem;
  border-radius: 0.3rem;
  background: var(--bg-alt);
  color: var(--text-muted);
  vertical-align: 0.1em;
}

.menu-wrap {
  position: relative;
}

.icon-btn {
  width: var(--control-h);
  height: var(--control-h);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: #fff;
  display: grid;
  place-items: center;
}

.icon-btn svg {
  width: 1rem;
  height: 1rem;
  stroke: var(--ink);
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
}

.menu {
  position: absolute;
  right: 0;
  top: calc(100% + 0.4rem);
  z-index: 20;
  min-width: 14rem;
  background: #fff;
  color: var(--ink);
  border: 1px solid var(--border);
  border-radius: var(--radius-btn);
  box-shadow: var(--shadow);
  padding: 0.35rem;
}

.menu button {
  display: block;
  width: 100%;
  text-align: left;
  border: 0;
  background: none;
  padding: 0.45rem 0.65rem;
  border-radius: var(--radius-sm);
}

.menu button:hover {
  background: var(--bg-alt);
}

.menu .menu-meta {
  padding: 0.4rem 0.65rem 0.5rem;
  font-size: var(--fs-xs);
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
  margin-bottom: 0.3rem;
  line-height: 1.4;
}

.banner {
  flex: none;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 1rem;
  padding: 0.45rem 0.75rem;
  background: var(--warn-pale);
  color: var(--warn);
  font-size: var(--fs-sm);
  line-height: 1.4;
}

.banner .btn {
  min-height: var(--control-h-sm);
  padding: 0 var(--control-pad-x);
  font-size: var(--fs-sm);
}

.term-view {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.sessionbar {
  flex: none;
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.3rem 0.75rem;
  background: var(--dark-surface);
  border-bottom: 1px solid var(--dark-border);
  font-size: var(--fs-sm);
}

.sessionbar label {
  color: var(--dark-muted);
}

.select {
  appearance: none;
  font: inherit;
  font-family: var(--font-mono);
  font-size: var(--fs-sm);
  color: var(--dark-text);
  background: var(--dark-raised)
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%23fff' stroke-width='1.8' fill='none'/%3E%3C/svg%3E")
    no-repeat right 0.7rem center;
  border: 1px solid var(--dark-border);
  border-radius: var(--radius-sm);
  padding: 0.25rem 1.8rem 0.25rem 0.5rem;
  max-width: 60vw;
}

.status-dot {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  color: var(--dark-muted);
  margin-left: auto;
  white-space: nowrap;
}

.status-dot::before {
  content: '';
  width: 0.5rem;
  height: 0.5rem;
  border-radius: 50%;
  background: #8a8a8a;
}

.status-dot[data-state='open']::before {
  background: #3ccf8e;
}

.status-dot[data-state='connecting']::before {
  background: #f5b546;
}

.term-wrap {
  position: relative;
  flex: 1;
  min-height: 0;
  padding: 0.35rem 0 0 0.5rem;
  background: var(--dark-bg);
}

#terminal {
  width: 100%;
  height: 100%;
}

.overlay {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  background: rgba(16, 17, 20, 0.86);
  text-align: center;
  padding: 1.5rem;
  z-index: 5;
}

.overlay h2 {
  margin: 0 0 0.35rem;
  font-size: 1.1rem;
}

.overlay p {
  margin: 0 0 1rem;
  color: var(--dark-muted);
}

.overlay .btn {
  background: #fff;
  color: var(--ink);
  border-color: #fff;
}

.offscreen {
  position: fixed;
  left: -9999px;
  top: 0;
  opacity: 0;
}

.copybar {
  flex: none;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.4rem 0.6rem;
  background: #fff;
  color: var(--ink);
  border-top: 1px solid var(--border);
  font-size: var(--fs-sm);
}

.copybar-text {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.copybar .btn {
  min-height: var(--control-h-sm);
  padding: 0 var(--control-pad-x);
  font-size: var(--fs-sm);
}

.copybar .icon-btn {
  width: var(--control-h-sm);
  height: var(--control-h-sm);
}

.keys {
  flex: none;
  display: flex;
  gap: 0.3rem;
  padding: 0.4rem 0.5rem calc(0.4rem + env(safe-area-inset-bottom));
  background: var(--dark-surface);
  border-top: 1px solid var(--dark-border);
  overflow-x: auto;
  scrollbar-width: none;
}

.keys::-webkit-scrollbar {
  display: none;
}

.key {
  flex: none;
  min-width: var(--tap-min);
  height: var(--tap-min);
  padding: 0 0.65rem;
  border: 1px solid var(--dark-border);
  border-radius: var(--radius-sm);
  background: var(--dark-raised);
  color: var(--dark-text);
  font-family: var(--font-mono);
  font-size: var(--fs-base);
  touch-action: manipulation;
  -webkit-user-select: none;
  user-select: none;
}

.key:active {
  background: #3a3b41;
}

.key[aria-pressed='true'] {
  background: #fff;
  color: var(--ink);
  border-color: #fff;
}

.key-sep {
  flex: none;
  width: 1px;
  margin: 0.3rem 0.15rem;
  background: var(--dark-border);
}

.panel {
  flex: 1;
  overflow: auto;
  background: var(--bg-alt);
  color: var(--text);
  display: flex;
  justify-content: center;
  padding: 1.5rem 1rem;
}

.panel .card {
  align-self: flex-start;
}

.panel ul {
  margin: 0 0 1rem;
  padding-left: 1.2rem;
}

/* Phones: the tabs shrink, the box's name goes. */
@media (max-width: 34rem) {
  .topbar {
    gap: 0.4rem;
    padding: 0.4rem 0.5rem;
  }

  .topbar .brand-text {
    display: none;
  }

  .tabs {
    margin-left: 0.25rem;
    flex: 1;
    justify-content: space-between;
  }

  .tab {
    padding: 0.3rem 0.35rem;
    font-size: var(--fs-sm);
  }

  .tab .soon {
    font-size: 0.5625rem;
    margin-left: 0.2rem;
    padding: 0 0.25rem;
  }

  .sessionbar label {
    display: none;
  }

  .sessionbar .select {
    flex: 1;
    min-width: 0;
    max-width: none;
  }

  /* Only the dot on phones; the words are its label for screen readers. */
  .status-dot {
    font-size: 0;
  }
}

@media (min-width: 34.01rem) {
  .keys {
    display: none;
  }
}

/* Touch screens of any size keep the key bar. */
@media (pointer: coarse) {
  .keys {
    display: flex;
  }
}

/* Phones and touch screens: 40px tap targets, and 16px in text boxes so iPhones don't zoom (App's rule). */
@media (max-width: 47.99em), (pointer: coarse) {
  .code-input {
    height: var(--tap-min);
    font-size: 1rem;
  }

  .btn,
  .choice,
  .tab,
  .menu button,
  .banner .btn {
    min-height: var(--tap-min);
  }

  .icon-btn {
    width: var(--tap-min);
    height: var(--tap-min);
  }

  .select {
    font-size: 1rem;
    min-height: var(--tap-min);
  }
}

/* xterm's hidden input: 16px, so a phone doesn't zoom when the terminal takes the keyboard. */
.xterm .xterm-helper-textarea {
  font-size: 16px !important;
}
