:root {
  --bg: #060a0a;
  --bg-elevated: rgba(8, 20, 20, 0.86);
  --panel: rgba(10, 24, 24, 0.92);
  --panel-border: rgba(78, 255, 161, 0.2);
  --text: #defee8;
  --muted: #8ab8a0;
  --accent: #59ff9b;
  --accent-strong: #afffcf;
  --danger: #ff6e88;
  --warning: #ffd36e;
  --shadow: 0 20px 60px rgba(0, 0, 0, 0.45);
  --radius: 22px;
  --radius-sm: 14px;
  --font-display: "Orbitron", "Eurostile", "Bank Gothic", sans-serif;
  --font-body: "IBM Plex Sans", "Segoe UI", sans-serif;
  color-scheme: dark;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font-body);
  color: var(--text);
  background:
    radial-gradient(circle at top, rgba(89, 255, 155, 0.12), transparent 28%),
    linear-gradient(180deg, #0a1111 0%, #050707 100%);
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background: linear-gradient(rgba(89, 255, 155, 0.03) 1px, transparent 1px);
  background-size: 100% 5px;
  opacity: 0.25;
}

.grid {
  position: fixed;
  inset: auto 0 0;
  height: 40vh;
  background:
    linear-gradient(rgba(89, 255, 155, 0.18) 1px, transparent 1px),
    linear-gradient(90deg, rgba(89, 255, 155, 0.18) 1px, transparent 1px);
  background-size: 44px 44px;
  transform: perspective(420px) rotateX(72deg);
  transform-origin: bottom;
  opacity: 0.2;
}

.app-shell {
  position: relative;
  width: min(1120px, calc(100% - 32px));
  margin: 0 auto;
  padding: 32px 0 40px;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  backdrop-filter: blur(12px);
}

.hero {
  padding: 28px;
  margin-bottom: 20px;
}

.hero-row,
.columns,
.section-head,
.chat-form,
.row-actions {
  display: flex;
  gap: 16px;
}

.hero-row,
.section-head,
.chat-head {
  justify-content: space-between;
  align-items: flex-start;
}

.columns {
  margin-bottom: 20px;
}

.columns > * {
  flex: 1;
  min-width: 0;
}

.stack {
  padding: 24px;
}

.eyebrow,
.status-label,
.field span,
button,
.badge {
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-size: 0.72rem;
}

.eyebrow,
.status-label,
.field span,
.lede,
.section-head p,
.notice {
  color: var(--muted);
}

h1,
h2 {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 800;
  letter-spacing: 0.08em;
}

h1 {
  font-size: clamp(2.2rem, 4vw, 4rem);
}

h2 {
  font-size: 1.1rem;
  margin-bottom: 6px;
}

.lede,
.section-head p {
  margin: 8px 0 0;
  line-height: 1.5;
}

.status-card,
.fingerprint-card,
.notice,
.message {
  border-radius: var(--radius-sm);
}

.status-card,
.fingerprint-card {
  min-width: min(100%, 280px);
  padding: 16px;
  background: var(--bg-elevated);
  border: 1px solid rgba(89, 255, 155, 0.16);
}

.status-card strong,
.status-card code,
.fingerprint-card code {
  display: block;
  margin-top: 6px;
  word-break: break-word;
}

.fingerprint-card code,
textarea,
input,
#stateText {
  font-family: "IBM Plex Mono", "SFMono-Regular", monospace;
}

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

.grow {
  flex: 1;
}

textarea,
input {
  width: 100%;
  border: 1px solid rgba(89, 255, 155, 0.18);
  border-radius: 16px;
  background: rgba(4, 12, 12, 0.9);
  color: var(--text);
  padding: 14px 16px;
  resize: vertical;
}

textarea {
  min-height: 180px;
}

textarea:focus,
input:focus,
button:focus-visible {
  outline: 2px solid rgba(175, 255, 207, 0.4);
  outline-offset: 2px;
}

button {
  appearance: none;
  border: none;
  border-radius: 999px;
  padding: 13px 18px;
  font-family: var(--font-display);
  color: #04100a;
  background: linear-gradient(135deg, var(--accent) 0%, #caff8f 100%);
  cursor: pointer;
  transition: transform 140ms ease, box-shadow 140ms ease, opacity 140ms ease;
  box-shadow: 0 10px 24px rgba(89, 255, 155, 0.18);
}

button:hover:not(:disabled) {
  transform: translateY(-1px);
}

button:disabled {
  opacity: 0.42;
  cursor: not-allowed;
  box-shadow: none;
}

.ghost-button {
  color: var(--accent-strong);
  background: transparent;
  border: 1px solid rgba(89, 255, 155, 0.28);
  box-shadow: none;
}

.notice {
  padding: 14px 16px;
  border: 1px solid rgba(89, 255, 155, 0.14);
  background: rgba(7, 17, 17, 0.82);
  line-height: 1.45;
}

.notice.error {
  color: #ffd7e0;
  border-color: rgba(255, 110, 136, 0.34);
  background: rgba(48, 8, 18, 0.78);
}

.hidden {
  display: none;
}

.chat-panel {
  padding: 24px;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  border-radius: 999px;
  border: 1px solid rgba(89, 255, 155, 0.16);
  background: rgba(7, 17, 17, 0.82);
}

.badge.pending {
  color: var(--warning);
}

.badge.secure {
  color: var(--accent-strong);
}

.badge.failed {
  color: #ffd7e0;
}

.message-log {
  height: min(48vh, 420px);
  overflow: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 4px 2px;
  margin-bottom: 16px;
}

.message {
  max-width: min(100%, 720px);
  padding: 14px 16px;
  border: 1px solid rgba(89, 255, 155, 0.14);
  background: rgba(7, 17, 17, 0.82);
}

.message.self {
  align-self: flex-end;
  background: rgba(20, 55, 31, 0.65);
}

.message.remote {
  align-self: flex-start;
}

.message strong {
  display: block;
  margin-bottom: 6px;
  font-size: 0.76rem;
  color: var(--accent-strong);
}

.message p {
  margin: 0;
  line-height: 1.45;
  white-space: pre-wrap;
  word-break: break-word;
}

@media (max-width: 820px) {
  .app-shell {
    width: min(100% - 20px, 1120px);
    padding: 18px 0 28px;
  }

  .hero,
  .stack,
  .chat-panel {
    padding: 18px;
  }

  .hero-row,
  .columns,
  .section-head,
  .chat-form,
  .row-actions {
    flex-direction: column;
  }

  button,
  .ghost-button {
    width: 100%;
  }

  .message-log {
    height: 42vh;
  }
}
