:root {
  color-scheme: dark;
  --black: #080a09;
  --panel: #0d100f;
  --panel-2: #121614;
  --line: #3b413e;
  --line-bright: #747d78;
  --text: #e8e8df;
  --muted: #858c87;
  --dim: #565d59;
  --amber: #f5a900;
  --amber-pale: #ffd36a;
  --green: #70e09a;
  --red: #ff715f;
  --mono: "Berkeley Mono", "IBM Plex Mono", "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
}

* { box-sizing: border-box; }

html {
  min-width: 320px;
  min-height: 100%;
  background: var(--black);
}

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  padding: clamp(12px, 3vw, 36px);
  color: var(--text);
  background:
    radial-gradient(circle at 50% -10%, rgba(245, 169, 0, 0.055), transparent 34%),
    var(--black);
  font-family: var(--mono);
  font-size: 13px;
}

button, input, select, textarea { font: inherit; }
button { color: inherit; }
[hidden] { display: none !important; }

button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
a:focus-visible {
  outline: 2px solid var(--amber-pale);
  outline-offset: 3px;
}

::selection { color: var(--black); background: var(--amber-pale); }

.terminal {
  width: min(1100px, 100%);
  min-height: calc(100vh - clamp(24px, 6vw, 72px));
  margin: 0 auto;
  display: grid;
  grid-template-rows: 47px minmax(610px, 1fr) 35px;
  overflow: hidden;
  border: 1px solid var(--line-bright);
  background: var(--panel);
  box-shadow: 0 22px 90px rgba(0, 0, 0, 0.42);
}

.terminal-bar {
  min-width: 0;
  padding: 0 14px 0 10px;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  border-bottom: 1px solid var(--line-bright);
  background: #171b19;
  font-size: 10px;
  letter-spacing: 0.09em;
}

.brand {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text);
  font-weight: 700;
  text-decoration: none;
}

.brand img {
  width: 30px;
  height: 30px;
  object-fit: contain;
  image-rendering: pixelated;
}

.terminal-status,
.terminal-version { margin: 0; }
.terminal-status { color: var(--muted); }
.online-ticker {
  min-width: 156px;
  padding: 6px 10px;
  border: 1px solid var(--line);
  background: #0c0f0d;
  text-align: center;
}
.online-ticker strong { color: var(--amber-pale); font-weight: 700; }
.terminal-status span {
  width: 6px;
  height: 6px;
  margin-right: 7px;
  display: inline-block;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 9px rgba(112, 224, 154, 0.65);
}
.terminal-version { justify-self: end; color: var(--dim); }

.app-view { min-height: 610px; }

.entry-view {
  position: relative;
  display: grid;
  place-items: center;
  padding: clamp(24px, 5vw, 62px);
  overflow: hidden;
  background:
    linear-gradient(rgba(255,255,255,.018) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,.018) 1px, transparent 1px),
    var(--panel);
  background-size: 32px 32px;
}

.backdrop-copy {
  position: absolute;
  inset: 34px 40px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  color: #242a27;
  pointer-events: none;
  user-select: none;
}

.backdrop-copy p,
.backdrop-copy span { margin: 0; font-size: 9px; letter-spacing: .16em; }
.backdrop-copy span { align-self: end; }
.backdrop-copy strong {
  font-size: clamp(58px, 9.5vw, 112px);
  line-height: .88;
  letter-spacing: -.09em;
}

.wizard,
.ended-dialog {
  width: min(610px, 100%);
  position: relative;
  z-index: 1;
  border: 1px solid var(--line-bright);
  background: #101311;
  box-shadow: 12px 12px 0 #030404, 13px 13px 0 var(--line);
}

.wizard-bar {
  height: 35px;
  padding: 0 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--line-bright);
  background: #1b201d;
  color: var(--muted);
  font-size: 9px;
  letter-spacing: .11em;
}

#wizard-dots { color: var(--amber); letter-spacing: .24em; }

.wizard-step {
  min-height: 425px;
  padding: clamp(32px, 6vw, 58px);
  display: flex;
  flex-direction: column;
}

.prompt {
  margin: 0 0 16px;
  color: var(--amber);
  font-size: 10px;
  letter-spacing: .14em;
}

.welcome-lockup {
  display: grid;
  grid-template-columns: 112px minmax(0, 1fr);
  align-items: center;
  gap: 25px;
}

.welcome-lockup .prompt { margin-bottom: 11px; }

.welcome-mark {
  width: 112px;
  height: 112px;
  object-fit: contain;
  image-rendering: pixelated;
  filter: drop-shadow(0 0 18px rgba(245, 169, 0, .12));
}

.wizard h1,
.search-terminal h1,
.connection-panel h1,
.ended-content h1 {
  margin: 0;
  color: var(--text);
  font-size: clamp(28px, 5vw, 48px);
  font-weight: 500;
  line-height: 1.06;
  letter-spacing: -.055em;
}

.wizard-copy {
  max-width: 470px;
  margin: 24px 0 44px;
  color: #b4bab6;
  font-size: 14px;
  line-height: 1.75;
}

.field {
  margin: 37px 0 9px;
  display: block;
  color: var(--muted);
  font-size: 9px;
  letter-spacing: .14em;
}

.wizard input,
.wizard select {
  width: 100%;
  height: 56px;
  padding: 0 15px;
  appearance: none;
  border: 1px solid var(--line-bright);
  border-radius: 0;
  background: #080a09;
  color: var(--text);
  font-size: 15px;
}

.wizard select {
  padding-right: 48px;
  background-image:
    linear-gradient(45deg, transparent 50%, var(--amber) 50%),
    linear-gradient(135deg, var(--amber) 50%, transparent 50%);
  background-position: calc(100% - 20px) 25px, calc(100% - 14px) 25px;
  background-size: 6px 6px;
  background-repeat: no-repeat;
}

.wizard input::placeholder { color: var(--dim); }
.wizard input:hover, .wizard select:hover { border-color: var(--amber); }

.location-fields {
  display: grid;
  grid-template-columns: .9fr 1.1fr;
  gap: 14px;
}

.location-note {
  margin: 14px 0 0;
  color: var(--muted);
  font-size: 10px;
  line-height: 1.5;
}

.input-hint {
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 9px;
  line-height: 1.5;
}

.step-error {
  min-height: 17px;
  margin: 10px 0 0;
  color: var(--red);
  font-size: 10px;
}

.command-button,
.back-button {
  border-radius: 0;
  cursor: pointer;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .09em;
}

.command-button {
  min-height: 47px;
  padding: 0 15px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 25px;
  border: 1px solid var(--amber);
  background: var(--amber);
  color: #151006;
}

.command-button:hover { background: var(--amber-pale); border-color: var(--amber-pale); }
.wizard-step > .command-button { width: min(220px, 100%); margin-top: auto; }

.back-button {
  padding: 6px 0;
  border: 0;
  background: transparent;
  color: var(--muted);
}
.back-button:hover { color: var(--text); }

.wizard-actions {
  margin-top: auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
}

.wizard-actions .command-button { min-width: 170px; }

.matching-view,
.ended-view {
  padding: clamp(24px, 6vw, 70px);
  display: grid;
  place-items: center;
  background:
    repeating-linear-gradient(0deg, transparent, transparent 3px, rgba(255,255,255,.012) 3px, rgba(255,255,255,.012) 4px),
    #090b0a;
}

.search-terminal { width: min(640px, 100%); }
.search-terminal > p:first-child { margin: 0 0 24px; color: var(--amber); font-size: 10px; letter-spacing: .12em; }
.search-terminal h1 { margin-bottom: 38px; }
.cursor { color: var(--amber); animation: blink .8s steps(1) infinite; }
@keyframes blink { 50% { opacity: 0; } }

.search-terminal dl { margin: 0; border: 1px solid var(--line); }
.search-terminal dl div {
  min-height: 48px;
  padding: 0 14px;
  display: grid;
  grid-template-columns: 110px 1fr;
  align-items: center;
  border-bottom: 1px solid var(--line);
}
.search-terminal dl div:last-child { border-bottom: 0; }
.search-terminal dt { color: var(--dim); font-size: 9px; letter-spacing: .12em; }
.search-terminal dd { margin: 0; color: var(--amber-pale); }

.scanner { height: 5px; margin: 22px 0; overflow: hidden; background: #171c19; }
.scanner span { width: 23%; height: 100%; display: block; background: var(--amber); animation: scan 1.5s ease-in-out infinite alternate; }
@keyframes scan { from { transform: translateX(-100%); } to { transform: translateX(440%); } }
.search-note { color: var(--muted); font-size: 10px; }
.search-terminal .back-button { margin-top: 16px; }

.chat-view {
  display: grid;
  grid-template-columns: 245px minmax(0, 1fr);
  background: #090b0a;
}

.connection-panel {
  min-width: 0;
  padding: 24px 20px 18px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 30px;
  border-right: 1px solid var(--line-bright);
  background: #101311;
}

.panel-label { margin: 0 0 10px; color: var(--dim); font-size: 9px; letter-spacing: .12em; }
.connection-state { color: var(--green); font-size: 9px; letter-spacing: .12em; }
.connection-state i {
  width: 6px;
  height: 6px;
  margin-right: 6px;
  display: inline-block;
  border-radius: 50%;
  background: var(--green);
}
.connection-panel h1 {
  margin: 17px 0 7px;
  overflow-wrap: anywhere;
  font-size: 31px;
}
.connection-panel h1 + p { margin: 0; color: #b1b7b3; line-height: 1.45; }
#partner-location { margin: 8px 0 0; color: var(--amber); font-size: 10px; line-height: 1.5; }

.session-data { margin: 0; border-top: 1px solid var(--line); }
.session-data div { padding: 9px 0; display: flex; justify-content: space-between; gap: 10px; border-bottom: 1px solid var(--line); }
.session-data dt { color: var(--dim); font-size: 8px; }
.session-data dd { margin: 0; color: var(--muted); font-size: 8px; }
.side-actions { display: grid; gap: 15px; }
.side-actions .back-button { justify-self: start; color: #b37b72; font-size: 8px; }

.chat-console { min-width: 0; display: grid; grid-template-rows: 39px minmax(410px, 1fr) auto; }
.channel-bar {
  padding: 0 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--line);
  background: #151917;
  color: var(--muted);
  font-size: 9px;
  letter-spacing: .1em;
}
.channel-bar p { margin: 0; color: var(--amber); }

.transcript {
  min-height: 410px;
  max-height: calc(100vh - 238px);
  padding: 21px 18px;
  overflow-y: auto;
  scroll-behavior: smooth;
  scrollbar-color: var(--line-bright) var(--black);
}

.message {
  display: grid;
  grid-template-columns: 54px minmax(70px, auto) 1fr;
  align-items: start;
  gap: 9px;
  margin: 0 0 9px;
  font-size: 12px;
  line-height: 1.55;
}
.message-meta { display: contents; }
.message-meta time { grid-column: 1; grid-row: 1; color: var(--dim); }
.message-meta span { grid-column: 2; grid-row: 1; max-width: 140px; overflow: hidden; color: var(--amber); text-overflow: ellipsis; white-space: nowrap; }
.message-meta span::before { content: "<"; }
.message-meta span::after { content: ">"; }
.message.you .message-meta span { color: var(--green); }
.message-body { grid-column: 3; grid-row: 1; margin: 0; color: #d5d8d5; white-space: pre-wrap; overflow-wrap: anywhere; }
.system-message { margin: 4px 0 13px 63px; color: var(--muted); font-size: 10px; line-height: 1.6; }
.system-message::before { content: "*** "; color: var(--amber); }

.composer {
  padding: 12px 14px 10px;
  display: grid;
  grid-template-columns: 17px 1fr auto;
  align-items: start;
  gap: 8px;
  border-top: 1px solid var(--line-bright);
  background: #101311;
}
.composer > label { padding-top: 12px; color: var(--amber); font-weight: 700; }
.composer textarea {
  width: 100%;
  min-height: 43px;
  max-height: 135px;
  padding: 11px 0;
  resize: none;
  border: 0;
  border-bottom: 1px solid var(--line);
  border-radius: 0;
  background: transparent;
  color: var(--text);
  line-height: 1.45;
}
.composer textarea::placeholder { color: var(--dim); }
.composer button {
  min-height: 43px;
  padding: 0 12px;
  border: 1px solid var(--line-bright);
  border-radius: 0;
  background: #181d1a;
  color: var(--amber);
  cursor: pointer;
  font-size: 9px;
  letter-spacing: .08em;
}
.composer button:hover { border-color: var(--amber); }
.composer > p {
  grid-column: 2 / -1;
  margin: 0;
  display: flex;
  justify-content: space-between;
  color: var(--dim);
  font-size: 8px;
}

.ended-content { padding: clamp(34px, 6vw, 58px); }
.ended-content > p:not(.prompt) { margin: 20px 0 0; color: #aeb3b0; line-height: 1.7; }
.ended-actions { margin-top: 38px; display: flex; align-items: center; justify-content: space-between; gap: 24px; }

.terminal-footer {
  min-width: 0;
  padding: 0 13px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  border-top: 1px solid var(--line-bright);
  background: #171b19;
  color: var(--dim);
  font-size: 8px;
  letter-spacing: .09em;
}
.terminal-footer span:first-child { color: var(--amber); }

@media (max-width: 720px) {
  body { padding: 0; }
  .terminal { min-height: 100vh; border: 0; grid-template-rows: 47px minmax(calc(100vh - 82px), 1fr) 35px; }
  .terminal-version { display: none; }
  .terminal-bar { grid-template-columns: 1fr auto; }
  .entry-view { padding: 24px 15px 34px; }
  .backdrop-copy { display: none; }
  .wizard, .ended-dialog { box-shadow: 6px 6px 0 #030404; }
  .wizard-step { min-height: 440px; padding: 34px 24px; }
  .location-fields { grid-template-columns: 1fr; gap: 0; }
  .location-fields .field { margin-top: 20px; }
  .chat-view { grid-template-columns: 1fr; grid-template-rows: auto minmax(0, 1fr); }
  .connection-panel {
    padding: 13px 14px;
    display: grid;
    grid-template-columns: 1fr auto;
    align-items: center;
    border-right: 0;
    border-bottom: 1px solid var(--line-bright);
  }
  .panel-label, .session-data { display: none; }
  .connection-state { display: block; margin-bottom: 5px; }
  .connection-panel h1 { margin: 0 0 3px; font-size: 20px; }
  .connection-panel h1 + p { font-size: 9px; }
  #partner-location { margin-top: 3px; font-size: 8px; }
  .side-actions { display: flex; align-items: center; flex-direction: row-reverse; }
  .side-actions .command-button { min-height: 38px; }
  .chat-console { grid-template-rows: 33px minmax(320px, 1fr) auto; }
  .transcript { min-height: 320px; max-height: none; padding: 16px 12px; }
  .message { grid-template-columns: 43px minmax(55px, auto) 1fr; gap: 6px; font-size: 11px; }
  .message-meta span { max-width: 90px; }
  .system-message { margin-left: 49px; }
  .composer { padding: 10px; }
  .composer > p span:last-child { display: none; }
  .ended-view { padding: 22px 15px; }
}

@media (max-width: 430px) {
  .welcome-lockup { grid-template-columns: 76px minmax(0, 1fr); gap: 15px; }
  .welcome-mark { width: 76px; height: 76px; }
  .welcome-lockup h1 { font-size: clamp(25px, 8vw, 34px); }
  .terminal-version { font-size: 8px; }
  .wizard-actions { align-items: stretch; flex-direction: column-reverse; }
  .wizard-actions .command-button { width: 100%; }
  .wizard-actions .back-button { align-self: flex-start; }
  .ended-actions { align-items: stretch; flex-direction: column; }
  .ended-actions .back-button { align-self: center; }
  .side-actions .back-button { display: none; }
  .terminal-footer span:last-child { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    scroll-behavior: auto !important;
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
  }
}
