:root {
  color-scheme: dark;
  --bg: #101115;
  --panel: #1c1f25;
  --panel-2: #242933;
  --line: #363d4a;
  --text: #f4f6f8;
  --muted: #9aa4b2;
  --accent: #ff4b2f;
  --accent-2: #2fbf8f;
  --warn: #e1b84c;
  --radius: 8px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background:
    linear-gradient(135deg, rgba(255, 75, 47, 0.16), transparent 34%),
    linear-gradient(315deg, rgba(47, 191, 143, 0.13), transparent 38%),
    var(--bg);
  color: var(--text);
}

button,
input {
  font: inherit;
}

.shell {
  width: min(980px, calc(100vw - 32px));
  margin: 0 auto;
  padding: 32px 0;
}

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

.eyebrow {
  margin: 0 0 4px;
  color: var(--muted);
  font-size: 13px;
}

h1 {
  margin: 0;
  font-size: 34px;
  font-weight: 700;
  letter-spacing: 0;
}

.status {
  min-width: 118px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 8px 12px;
  text-align: center;
  color: var(--muted);
  background: rgba(28, 31, 37, 0.8);
}

.status[data-state="connected"] {
  border-color: rgba(47, 191, 143, 0.7);
  color: #c5f8e8;
}

.status[data-state="needs_input"] {
  border-color: rgba(225, 184, 76, 0.7);
  color: #ffe3a1;
}

.status[data-state="failed"],
.status[data-state="error"] {
  border-color: rgba(255, 75, 47, 0.8);
  color: #ffc8be;
}

.grid {
  display: grid;
  grid-template-columns: minmax(280px, 360px) 1fr;
  gap: 16px;
  align-items: start;
}

.panel {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(28, 31, 37, 0.92);
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.24);
}

.control-panel,
.challenge-panel {
  padding: 18px;
}

.challenge-panel {
  grid-column: 1;
}

.log-panel {
  grid-column: 2;
  grid-row: 1 / span 2;
  min-height: 470px;
  overflow: hidden;
}

.field {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-size: 14px;
}

input {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0 12px;
  color: var(--text);
  background: #11141a;
  outline: none;
}

input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(255, 75, 47, 0.18);
}

.actions {
  display: flex;
  gap: 10px;
  margin-top: 16px;
}

button {
  min-height: 42px;
  border: 1px solid transparent;
  border-radius: 6px;
  padding: 0 16px;
  cursor: pointer;
  color: var(--text);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.5;
}

.primary {
  background: var(--accent);
}

.secondary {
  border-color: var(--line);
  background: var(--panel-2);
}

.ghost {
  min-height: 32px;
  padding: 0 10px;
  border-color: var(--line);
  color: var(--muted);
  background: transparent;
}

.log-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 50px;
  border-bottom: 1px solid var(--line);
  padding: 0 14px;
  color: var(--muted);
}

pre {
  height: 420px;
  margin: 0;
  padding: 14px;
  overflow: auto;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  color: #d7dee8;
  background: #0c0f14;
  font: 13px/1.45 ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
}

.hidden {
  display: none;
}

.muted {
  opacity: 0.72;
}

dialog {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0;
  color: var(--text);
  background: var(--panel);
}

dialog::backdrop {
  background: rgba(0, 0, 0, 0.55);
}

.token-box {
  width: min(360px, calc(100vw - 32px));
  padding: 18px;
}

@media (max-width: 760px) {
  .shell {
    width: min(100vw - 20px, 980px);
    padding: 18px 0;
  }

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

  h1 {
    font-size: 28px;
  }

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

  .challenge-panel,
  .log-panel {
    grid-column: 1;
    grid-row: auto;
  }

  .actions {
    flex-direction: column;
  }

  pre {
    height: 360px;
  }
}
