@font-face {
  font-family: "Share Tech Mono";
  src: url("/fonts/ShareTechMono-Regular.ttf") format("truetype");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "Orbitron";
  src: url("/fonts/Orbitron-Regular.ttf") format("truetype");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

:root {
  color-scheme: dark;
  --bg: #05070a;
  --cyan: #5ce1ff;
  --amber: #e6a23c;
  --danger: #ff4d3a;
  --text: #d7e6ea;
  --muted: #7f97a1;
  --panel: rgba(8, 14, 18, 0.82);
  --hair: rgba(92, 225, 255, 0.28);
  --metal: #080e12;
}

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

html {
  height: 100%;
  overflow-x: hidden;
}

body {
  margin: 0;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.45 "Share Tech Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  overflow-x: hidden;
  max-width: 100%;
  display: flex;
  flex-direction: column;
  padding-left: env(safe-area-inset-left);
  padding-right: env(safe-area-inset-right);
}

[hidden] {
  display: none !important;
}

#reactor-canvas {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 0;
  pointer-events: none;
  display: block;
}

#HUD,
#gate,
#console {
  position: relative;
  z-index: 1;
}

#HUD {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 14px;
  min-height: 36px;
  padding: calc(4px + env(safe-area-inset-top)) 12px 4px;
  background: var(--panel);
  border-bottom: 1px solid var(--hair);
}

.brand,
.boot-mark {
  margin: 0;
  font-family: "Orbitron", "Avenir Next Condensed", "Segoe UI", sans-serif;
  font-weight: 400;
  letter-spacing: 0.18em;
  font-size: 13px;
  color: var(--text);
}

.readouts {
  display: flex;
  flex-wrap: wrap;
  gap: 2px 12px;
  min-width: 0;
}

.readouts p,
#session-body,
#pc-confirm-out,
#reg-hint {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
}

h2 {
  margin: 0 0 8px;
  font-size: 12px;
  font-weight: 400;
  letter-spacing: 0.14em;
  color: var(--muted);
}

.tone-ok { color: var(--cyan); }
.tone-warn { color: var(--amber); }
.tone-na { color: var(--muted); }

button,
.linkish,
input,
textarea,
.job-row {
  font-family: "Share Tech Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

button,
.linkish {
  min-height: 44px;
  padding: 8px 12px;
  background: var(--metal);
  color: var(--cyan);
  border: 1px solid rgba(92, 225, 255, 0.55);
  border-radius: 2px;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 14px;
}

button:active,
.linkish:active {
  border-color: var(--amber);
  color: var(--amber);
}

button:disabled {
  color: var(--muted);
  border-color: rgba(127, 151, 161, 0.45);
  cursor: default;
}

button.reject,
button.stop {
  color: var(--amber);
  border-color: rgba(230, 162, 60, 0.75);
  background: var(--metal);
}

button.confirm {
  color: var(--cyan);
  border-color: rgba(92, 225, 255, 0.7);
}

input,
textarea {
  width: 100%;
  min-height: 44px;
  padding: 8px 10px;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--hair);
  border-radius: 2px;
  font-size: 16px;
}

textarea#box {
  font-size: 16px;
  min-height: 44px;
  resize: vertical;
}

:focus-visible {
  outline: 2px solid #e6a23c;
  outline-offset: 2px;
}

label {
  color: var(--muted);
  font-size: 12px;
}

.bezel {
  border: 1px solid var(--hair);
  border-radius: 2px;
  background-color: var(--panel);
  background-image:
    linear-gradient(#5ce1ff, #5ce1ff),
    linear-gradient(#5ce1ff, #5ce1ff),
    linear-gradient(#5ce1ff, #5ce1ff),
    linear-gradient(#5ce1ff, #5ce1ff),
    linear-gradient(#5ce1ff, #5ce1ff),
    linear-gradient(#5ce1ff, #5ce1ff),
    linear-gradient(#5ce1ff, #5ce1ff),
    linear-gradient(#5ce1ff, #5ce1ff);
  background-size:
    11px 1px, 1px 11px,
    11px 1px, 1px 11px,
    11px 1px, 1px 11px,
    11px 1px, 1px 11px;
  background-position:
    left 0 top 0, left 0 top 0,
    right 0 top 0, right 0 top 0,
    left 0 bottom 0, left 0 bottom 0,
    right 0 bottom 0, right 0 bottom 0;
  background-repeat: no-repeat;
}

.panel {
  padding: 10px 12px;
  min-width: 0;
}

body:has(#console[hidden]) {
  height: 100dvh;
  overflow: hidden;
}

#gate {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}

#gate .stage {
  flex: 1 1 auto;
  min-height: 34dvh;
}

.dock {
  width: min(420px, 100%);
  margin: 0 auto;
  padding: 0 12px calc(12px + env(safe-area-inset-bottom));
}

.gate-plate .reactor-word {
  margin-bottom: 8px;
}

.auth {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.auth + .auth {
  margin-top: 8px;
}

#phone-code {
  margin: 0;
  min-height: 44px;
  display: flex;
  align-items: center;
  color: var(--amber);
  letter-spacing: 0.16em;
  font-size: 18px;
}

.reactor {
  background: transparent;
  text-align: center;
}

.reactor-word {
  margin: 0;
  color: var(--cyan);
  letter-spacing: 0.16em;
  font-size: 12px;
}

.reactor[data-state="job"] .reactor-word { color: var(--amber); }
.reactor[data-state="error"] .reactor-word { color: var(--danger); }
.reactor[data-state="offline"] .reactor-word { color: var(--muted); }

#console {
  flex: 1 1 auto;
  min-width: 0;
  max-width: 100%;
}

.workspace {
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: 100%;
  max-width: 100%;
  padding: 8px 8px calc(12px + env(safe-area-inset-bottom));
}

#panel-core {
  display: flex;
  flex-direction: column;
  min-width: 0;
  background: transparent;
}

.core-open {
  min-height: 22dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
  padding: 8px 8px 4px;
  background: transparent;
}

.chat-plate {
  padding: 10px 12px 12px;
}

.composer {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 8px;
}

#log {
  max-height: 32dvh;
  overflow: auto;
}

.line {
  display: grid;
  grid-template-columns: 72px minmax(0, 1fr);
  gap: 8px;
  margin: 0 0 6px;
  overflow-wrap: anywhere;
}

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

.line.you,
.line.you .who { color: var(--amber); }
.line.jarvis,
.line.jarvis .who { color: var(--cyan); }
.line.err,
.line.err .who { color: var(--danger); }

.last-reply { margin-top: 8px; }
.last-reply-kicker {
  margin: 0;
  color: var(--muted);
  font-size: 11px;
  letter-spacing: 0.14em;
}
.last-reply-body { margin: 4px 0 0; }
.last-reply.is-idle .last-reply-body { color: var(--muted); }
.last-reply.is-wait .last-reply-body { color: var(--amber); }
.last-reply.is-jarvis .last-reply-body { color: var(--cyan); }
.last-reply.is-err .last-reply-body { color: var(--danger); }

.chat-empty {
  margin: 8px 0 0;
  color: var(--amber);
}

#panel-side {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 0;
  background: transparent;
}

#panel-screen { min-width: 0; }

#job-list,
#memory-list,
#action-list,
#mail-list {
  max-height: 32dvh;
  overflow: auto;
}

#job-log {
  margin: 8px 0 0;
  max-height: 18dvh;
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-word;
  color: var(--muted);
  font: inherit;
}

.job-row {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  padding: 4px 8px;
  margin: 0 0 6px;
  border: 1px solid var(--hair);
  border-radius: 2px;
  background: transparent;
  color: var(--text);
}

.job-row.is-selected {
  border-color: #e6a23c;
  background: transparent;
}

.job-id {
  min-width: 0;
  overflow-wrap: anywhere;
  flex: 1 1 auto;
}

.job-stato { color: var(--muted); }

.job-row.is-running .job-stato { color: var(--cyan); }

.job-row button.stop {
  flex: 0 0 auto;
  min-width: 72px;
}

.na { margin: 0; color: var(--muted); }

.card,
.mail-item {
  padding: 8px 0;
  border-top: 1px solid var(--hair);
}

.card p,
.mail-item p { margin: 0 0 4px; }

.key,
.obj { color: var(--cyan); }

.card-actions {
  display: flex;
  gap: 8px;
  margin-top: 6px;
}

.card-actions button { flex: 1 1 0; }

.screen-shot {
  display: block;
  max-width: 100%;
  width: 100%;
  height: auto;
  max-height: 32dvh;
  object-fit: contain;
}

.linkish { width: 100%; margin-top: 8px; }

#session-body { margin-bottom: 8px; }

#boot {
  position: fixed;
  inset: 0;
  z-index: 8;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  background: transparent;
  pointer-events: none;
  padding: 12px;
  padding-bottom: calc(12px + env(safe-area-inset-bottom));
}

.boot-inner {
  pointer-events: auto;
  width: min(420px, 100%);
  padding: 12px;
}

.boot-lines {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin: 8px 0;
}

.boot-lines p { margin: 0; min-height: 1.2em; }
.boot-lines p.on { color: var(--cyan); }

#skip {
  width: 100%;
  min-height: 44px;
}

@media (max-width: 799px) {
  #gate .stage {
    flex: 1 1 auto;
    min-height: 0;
  }

  #gate .dock {
    position: sticky;
    bottom: 0;
    width: 100%;
  }

  #gate button,
  #gate input,
  #gate .linkish {
    width: 100%;
  }

  #send { width: 100%; }
}

@media (min-width: 800px) {
  .composer {
    flex-direction: row;
    align-items: stretch;
  }

  textarea#box { flex: 1 1 auto; }
  #send { min-width: 104px; }
}

@media (min-width: 1100px) {
  #console {
    height: calc(100dvh - 48px - env(safe-area-inset-top));
    min-height: 0;
  }

  #console .workspace {
    height: 100%;
    min-height: 0;
    display: grid;
    grid-template-columns: minmax(200px, 240px) minmax(0, 1fr) minmax(220px, 300px);
    grid-template-rows: minmax(0, 1fr);
    gap: 10px;
    align-items: stretch;
    padding: 10px;
  }

  #panel-jobs {
    grid-column: 1;
    grid-row: 1;
    align-self: start;
    width: 100%;
    max-height: 100%;
    overflow: auto;
  }

  #panel-core {
    grid-column: 2;
    grid-row: 1;
    min-height: 0;
    height: 100%;
  }

  .core-open {
    flex: 1 1 auto;
    min-height: 28dvh;
  }

  .chat-plate { margin-top: auto; }

  #panel-side {
    grid-column: 3;
    grid-row: 1;
    align-self: stretch;
    min-height: 0;
    max-height: 100%;
    overflow: auto;
    background: transparent;
  }

  #job-list { max-height: none; }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation: none !important;
    transition: none !important;
  }
}
