:root {
  color-scheme: dark;
  --bg: #0d1110;
  --surface: rgba(18, 27, 25, 0.94);
  --surface-2: rgba(29, 43, 39, 0.92);
  --surface-3: #edf8f4;
  --text: #edf8f4;
  --text-dark: #101615;
  --muted: #9fb7b0;
  --line: rgba(141, 255, 223, 0.2);
  --accent: #2ad8b5;
  --accent-strong: #92ffe1;
  --warning: #ffbd5a;
  --danger: #ff6b6b;
  --shadow: 0 20px 60px rgba(0, 0, 0, 0.42);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(rgba(42, 216, 181, 0.07) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 189, 90, 0.05) 1px, transparent 1px),
    linear-gradient(135deg, #0d1110 0%, #14201d 52%, #0f1416 100%),
    var(--bg);
  background-size: 42px 42px, 42px 42px, auto;
  color: var(--text);
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  border: 0;
  cursor: pointer;
}

button:disabled {
  cursor: wait;
  opacity: 0.68;
}

.button:disabled {
  cursor: not-allowed;
  filter: grayscale(0.35);
}

.shell {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 18px clamp(18px, 4vw, 56px);
  border-bottom: 1px solid var(--line);
  background: rgba(13, 17, 16, 0.82);
  backdrop-filter: blur(16px);
  position: sticky;
  top: 0;
  z-index: 10;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  font-weight: 760;
  color: var(--text);
  text-decoration: none;
}

.brand-mark {
  width: 34px;
  height: 34px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  color: var(--text-dark);
  background: var(--warning);
  box-shadow: 0 0 24px rgba(255, 189, 90, 0.28);
}

.brand-copy {
  display: grid;
  gap: 1px;
}

.brand-copy strong {
  font-size: 17px;
}

.brand-copy small {
  color: var(--muted);
  font-size: 12px;
  font-weight: 620;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.nav-wrap,
.language-wrap {
  position: relative;
}

.nav-toggle,
.language-toggle {
  width: 42px;
  height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(18, 27, 25, 0.92);
}

.nav-toggle {
  display: grid;
  align-content: center;
  gap: 5px;
  padding: 0 10px;
}

.language-toggle {
  width: auto;
  padding: 0 12px;
  color: var(--text);
  font-size: 13px;
  font-weight: 760;
  text-transform: uppercase;
}

.nav-toggle:hover,
.language-toggle:hover {
  background: rgba(42, 216, 181, 0.12);
}

.nav-toggle span {
  display: block;
  height: 2px;
  border-radius: 2px;
  background: var(--accent-strong);
  transition:
    transform 160ms ease,
    opacity 160ms ease;
}

.nav-toggle[aria-expanded="true"] span:nth-child(1) {
  transform: translateY(7px) rotate(45deg);
}

.nav-toggle[aria-expanded="true"] span:nth-child(2) {
  opacity: 0;
}

.nav-toggle[aria-expanded="true"] span:nth-child(3) {
  transform: translateY(-7px) rotate(-45deg);
}

.nav,
.language-menu {
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  min-width: 168px;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 10px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(12, 18, 17, 0.98);
  box-shadow: var(--shadow);
}

.nav a {
  border-bottom: 1px solid var(--line);
  color: var(--text);
  padding: 10px 8px;
  text-decoration: none;
  font-size: 13px;
  font-weight: 760;
  text-transform: uppercase;
  transition:
    color 160ms ease,
    border-color 160ms ease;
}

.nav a:last-child {
  border-bottom: 0;
}

.nav a:hover {
  color: var(--accent-strong);
  border-color: var(--accent);
}

.language-menu {
  min-width: 148px;
  display: grid;
  gap: 2px;
  padding: 8px;
}

.language-menu-title {
  margin: 2px 4px 6px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.language-option {
  width: 100%;
  border: 0;
  border-radius: 4px;
  padding: 9px 10px;
  color: var(--text);
  background: transparent;
  text-align: left;
}

.language-option:hover {
  background: rgba(42, 216, 181, 0.12);
}

.language-option-active {
  color: var(--accent-strong);
  background: rgba(42, 216, 181, 0.12);
  font-weight: 760;
}

.nav.menu-collapsed,
.language-menu.menu-collapsed {
  display: none;
}

.main {
  flex: 1;
  width: min(1120px, calc(100% - 32px));
  margin: 0 auto;
  padding: 34px 0 52px;
}

.hero {
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(320px, 0.95fr);
  align-items: center;
  gap: 34px;
  min-height: calc(100vh - 134px);
}

.eyebrow {
  color: var(--warning);
  font-weight: 700;
  margin: 0 0 12px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

h1 {
  margin: 0;
  font-size: clamp(40px, 7vw, 78px);
  line-height: 0.96;
  letter-spacing: 0;
  text-shadow: 0 0 34px rgba(42, 216, 181, 0.16);
}

h2 {
  font-size: 28px;
  margin: 0 0 14px;
  letter-spacing: 0;
}

p {
  color: var(--muted);
  line-height: 1.65;
}

.lead {
  font-size: 18px;
  max-width: 650px;
}

.mission-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 22px;
}

.mission-stats span,
.signal-footer span {
  border: 1px solid rgba(255, 189, 90, 0.3);
  border-radius: 8px;
  padding: 7px 9px;
  color: var(--warning);
  background: rgba(255, 189, 90, 0.08);
  font-size: 12px;
  font-weight: 760;
  text-transform: uppercase;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 26px;
}

.button,
.button-secondary,
.button-danger {
  border-radius: 8px;
  padding: 12px 16px;
  min-height: 46px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  text-decoration: none;
  font-weight: 720;
}

.button {
  color: var(--text-dark);
  background: var(--warning);
  box-shadow: 0 0 26px rgba(255, 189, 90, 0.22);
}

.button:hover {
  background: #ffd17d;
}

.button-secondary {
  color: var(--text);
  background: rgba(18, 27, 25, 0.82);
  border: 1px solid var(--line);
}

.button-danger {
  color: white;
  background: var(--danger);
}

.flow {
  background:
    linear-gradient(rgba(42, 216, 181, 0.08) 1px, transparent 1px),
    linear-gradient(90deg, rgba(42, 216, 181, 0.08) 1px, transparent 1px),
    rgba(18, 27, 25, 0.9);
  background-size: 22px 22px, 22px 22px, auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 22px;
}

.signal-board {
  display: grid;
  gap: 16px;
}

.signal-header {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 760;
  letter-spacing: 0.08em;
}

.signal-header strong {
  color: var(--accent-strong);
}

.flow-row {
  display: grid;
  grid-template-columns: 1fr auto 1fr auto 1fr;
  align-items: center;
  gap: 12px;
}

.flow-node {
  min-height: 118px;
  border: 1px solid var(--line);
  background: rgba(13, 17, 16, 0.78);
  border-radius: 8px;
  display: grid;
  place-items: center;
  text-align: center;
  padding: 14px;
  font-weight: 760;
}

.flow-node-translate {
  border-color: rgba(255, 189, 90, 0.4);
}

.flow-node small {
  display: block;
  margin-top: 6px;
  color: var(--muted);
  font-weight: 520;
}

.arrow {
  font-size: 26px;
  color: var(--accent-strong);
}

.signal-footer {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 22px;
}

.narrow-panel {
  width: min(620px, 100%);
  margin: 0 auto;
}

.waiting-indicator {
  display: flex;
  justify-content: center;
  gap: 8px;
  margin: 26px 0 6px;
}

.waiting-indicator i {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--accent);
  animation: typing-pulse 1.1s ease-in-out infinite;
}

.waiting-indicator i:nth-child(2) {
  animation-delay: 0.16s;
}

.waiting-indicator i:nth-child(3) {
  animation-delay: 0.32s;
}

.grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.field {
  display: grid;
  gap: 7px;
}

.field label {
  font-weight: 700;
  color: var(--text);
}

.field input,
.field select,
.field textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 11px 12px;
  background: rgba(9, 14, 13, 0.9);
  color: var(--text);
}

.setup-hint {
  margin: 14px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.confidence-control {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 68px;
  align-items: center;
  gap: 12px;
}

.confidence-value {
  min-height: 44px;
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-2);
  padding: 9px 8px;
}

.confidence-value strong {
  color: var(--accent-strong);
  font-size: 19px;
}

.confidence-value span {
  color: var(--muted);
  font-size: 12px;
}

.chat-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 280px;
  gap: 18px;
}

.chat-window {
  min-height: 60vh;
  display: flex;
  flex-direction: column;
}

.chat-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

.chat-heading h2 {
  margin: 0;
}

.role-badge {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  padding: 5px 9px;
  border: 1px solid rgba(42, 216, 181, 0.36);
  border-radius: 8px;
  background: rgba(42, 216, 181, 0.1);
  color: var(--accent-strong);
  font-size: 12px;
  font-weight: 760;
}

.briefing-backdrop,
.role-confirmation-backdrop {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: grid;
  place-items: center;
  padding: 18px;
  background:
    linear-gradient(rgba(42, 216, 181, 0.06) 1px, transparent 1px),
    linear-gradient(90deg, rgba(42, 216, 181, 0.06) 1px, transparent 1px),
    rgba(5, 8, 8, 0.78);
  background-size: 32px 32px, 32px 32px, auto;
  backdrop-filter: blur(10px);
}

.role-confirmation-backdrop[hidden] {
  display: none;
}

.briefing-modal,
.role-confirmation-modal {
  width: min(640px, 100%);
  max-height: min(740px, calc(100vh - 36px));
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
  padding: 24px;
}

.briefing-modal {
  border-color: rgba(255, 189, 90, 0.34);
}

.briefing-modal h2,
.role-confirmation-modal h2 {
  margin-top: 0;
}

.briefing-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-top: 18px;
}

.briefing-grid article {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: rgba(9, 14, 13, 0.54);
}

.briefing-grid strong {
  color: var(--accent-strong);
}

.briefing-grid p,
.briefing-grid ul {
  margin: 8px 0 0;
  color: var(--muted);
  line-height: 1.55;
}

.briefing-grid ul {
  display: grid;
  gap: 7px;
  padding-left: 18px;
}

.briefing-consent {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 18px;
  color: var(--text);
  font-weight: 700;
}

.briefing-consent input {
  width: 18px;
  height: 18px;
  accent-color: var(--warning);
}

.role-instructions {
  display: grid;
  gap: 10px;
  margin: 18px 0 0;
  padding-left: 20px;
  color: var(--muted);
  line-height: 1.55;
}

.chat-language-bar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  align-items: center;
  gap: 14px;
  margin: 0 0 16px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(9, 14, 13, 0.58);
}

.chat-language {
  display: grid;
  gap: 3px;
}

.chat-language:last-child {
  text-align: right;
}

.chat-language span,
.chat-language-bridge small {
  color: var(--muted);
  font-size: 12px;
}

.chat-language strong {
  font-size: 14px;
}

.chat-language-bridge {
  display: grid;
  justify-items: center;
  gap: 2px;
  color: var(--accent-strong);
}

.chat-language-bridge span {
  font-size: 20px;
  line-height: 1;
}

.translation-notice {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  margin: 0 0 14px;
  padding: 10px 12px;
  border-left: 3px solid var(--accent);
  background: rgba(42, 216, 181, 0.08);
  color: var(--muted);
  font-size: 13px;
  line-height: 1.55;
}

.translation-notice-icon {
  width: 17px;
  height: 17px;
  flex: 0 0 17px;
  display: grid;
  place-items: center;
  border: 1px solid var(--accent);
  border-radius: 50%;
  color: var(--accent-strong);
  font-size: 11px;
  font-weight: 800;
  line-height: 1;
}

.messages {
  flex: 1;
  min-height: 420px;
  overflow: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 4px;
}

.message {
  max-width: 78%;
  border-radius: 8px;
  padding: 12px 14px;
  line-height: 1.55;
  border: 1px solid var(--line);
  background: rgba(237, 248, 244, 0.94);
  color: var(--text-dark);
}

.message.judge {
  align-self: flex-end;
  background: var(--accent);
  color: var(--text-dark);
  border-color: transparent;
}

.message.witness {
  align-self: flex-start;
  background: rgba(237, 248, 244, 0.94);
}

.witness-view .message.judge {
  align-self: flex-start;
  border-color: var(--line);
  background: rgba(237, 248, 244, 0.94);
  color: var(--text-dark);
}

.witness-view .message.witness {
  align-self: flex-end;
  border-color: transparent;
  background: var(--accent);
  color: var(--text-dark);
}

.message.pending {
  opacity: 0.7;
}

.message.failed {
  border-color: rgba(168, 61, 61, 0.55);
}

.message.judge.failed {
  background: var(--danger);
  color: var(--text-dark);
}

.typing-dots {
  display: inline-flex;
  gap: 3px;
  margin-left: 7px;
  vertical-align: middle;
}

.typing-dots i {
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: currentColor;
  animation: typing-pulse 1.1s ease-in-out infinite;
}

.typing-dots i:nth-child(2) {
  animation-delay: 0.16s;
}

.typing-dots i:nth-child(3) {
  animation-delay: 0.32s;
}

@keyframes typing-pulse {
  0%,
  60%,
  100% {
    opacity: 0.35;
    transform: translateY(0);
  }

  30% {
    opacity: 1;
    transform: translateY(-2px);
  }
}

.message-meta {
  display: block;
  font-size: 12px;
  margin-bottom: 4px;
  opacity: 0.76;
}

.composer {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  margin-top: 16px;
}

.composer textarea {
  width: 100%;
  min-height: 58px;
  max-height: 150px;
  resize: vertical;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 11px 12px;
  background: rgba(9, 14, 13, 0.9);
  color: var(--text);
  line-height: 1.5;
}

.composer .button {
  align-self: stretch;
}

.composer-hint {
  grid-column: 1 / -1;
  color: var(--muted);
  font-size: 12px;
}

.composer button:disabled,
.composer textarea:disabled {
  cursor: wait;
  opacity: 0.68;
}

.status-list {
  display: grid;
  gap: 10px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.status-list li {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
}

.countdown-value {
  color: var(--accent-strong);
  font-variant-numeric: tabular-nums;
}

.countdown-warning {
  color: var(--danger);
}

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

.hidden-note {
  border-left: 4px solid var(--danger);
  padding-left: 12px;
  color: var(--muted);
}

.internal-log {
  max-height: 560px;
  overflow: auto;
  display: grid;
  gap: 10px;
}

.code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 13px;
  background: #10201d;
  color: #e9fff8;
  padding: 14px;
  border-radius: 8px;
  overflow: auto;
}

@media (max-width: 820px) {
  .hero,
  .chat-layout,
  .grid {
    grid-template-columns: 1fr;
  }

  .flow-row {
    grid-template-columns: 1fr;
  }

  .arrow {
    transform: rotate(90deg);
    justify-self: center;
  }

  .topbar {
    align-items: center;
    flex-direction: row;
  }

  .message {
    max-width: 92%;
  }

  .brand-copy small {
    display: none;
  }

  .chat-language-bar {
    gap: 8px;
    padding: 10px;
  }

  .briefing-grid {
    grid-template-columns: 1fr;
  }

  .mission-stats,
  .signal-footer {
    align-items: stretch;
    flex-direction: column;
  }

  .chat-heading {
    align-items: flex-start;
    flex-direction: column;
  }

  .chat-language-bridge small {
    display: none;
  }
}
