:root {
  --bg: #111315;
  --surface: #f6f3ed;
  --panel: #ffffff;
  --ink: #17191c;
  --muted: #68707a;
  --line: #d8d2c8;
  --red: #df3d32;
  --amber: #f1a208;
  --green: #1f9d66;
  --blue: #2457d6;
  --shadow: 0 20px 60px rgba(0, 0, 0, 0.22);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(120deg, rgba(31, 157, 102, 0.18), transparent 34%),
    linear-gradient(300deg, rgba(223, 61, 50, 0.16), transparent 38%),
    var(--bg);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input,
select {
  font: inherit;
}

.shell {
  width: min(1180px, calc(100vw - 32px));
  margin: 0 auto;
  padding: 28px 0;
  display: grid;
  grid-template-columns: 0.9fr 1.1fr;
  gap: 18px;
}

.control-panel,
.workspace {
  background: var(--surface);
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.control-panel {
  padding: 24px;
  min-height: calc(100vh - 56px);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.status-row,
.debug-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.eyebrow,
.label,
.hint,
.timestamp {
  margin: 0;
  color: var(--muted);
}

.eyebrow,
.label {
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1 {
  margin: 4px 0 0;
  font-size: clamp(2.2rem, 6vw, 4.7rem);
  line-height: 0.95;
  letter-spacing: 0;
}

.connection-state {
  min-width: 104px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  text-align: center;
  font-size: 0.9rem;
}

.connection-state.live {
  border-color: rgba(31, 157, 102, 0.42);
  color: var(--green);
  background: rgba(31, 157, 102, 0.08);
}

.stage {
  display: grid;
  grid-template-columns: minmax(160px, 260px) 1fr;
  align-items: end;
  gap: 24px;
}

.traffic-light {
  width: min(100%, 260px);
  aspect-ratio: 0.44;
  padding: 22px;
  border-radius: 42px;
  background: #20252a;
  box-shadow: inset 0 0 0 8px #2f363d, 0 28px 52px rgba(0, 0, 0, 0.28);
  display: grid;
  grid-template-rows: repeat(3, 1fr);
  gap: 18px;
}

.lamp {
  width: 100%;
  aspect-ratio: 1;
  border-radius: 50%;
  background: #3c444b;
  box-shadow: inset 0 10px 18px rgba(255, 255, 255, 0.04), inset 0 -18px 28px rgba(0, 0, 0, 0.38);
  opacity: 0.42;
  transition: transform 180ms ease, opacity 180ms ease, box-shadow 180ms ease, background 180ms ease;
}

.lamp.active {
  opacity: 1;
  transform: scale(1.025);
}

.lamp.red.active {
  background: var(--red);
  box-shadow: 0 0 34px rgba(223, 61, 50, 0.64), inset 0 10px 18px rgba(255, 255, 255, 0.25);
}

.lamp.amber.active {
  background: var(--amber);
  box-shadow: 0 0 34px rgba(241, 162, 8, 0.64), inset 0 10px 18px rgba(255, 255, 255, 0.28);
}

.lamp.green.active {
  background: var(--green);
  box-shadow: 0 0 34px rgba(31, 157, 102, 0.64), inset 0 10px 18px rgba(255, 255, 255, 0.25);
}

.state-card {
  border-top: 1px solid var(--line);
  padding-top: 16px;
}

.current-color {
  display: inline-block;
  margin: 0;
  min-width: var(--color-label-width, 5.2ch);
  font-size: clamp(2.5rem, 7vw, 6rem);
  line-height: 0.95;
  font-weight: 800;
}

.workspace {
  min-height: calc(100vh - 56px);
  display: flex;
  flex-direction: column;
}

.tabs {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px;
  border-bottom: 1px solid var(--line);
}

.tab {
  appearance: none;
  border: 1px solid transparent;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  padding: 9px 12px;
  text-decoration: none;
  cursor: pointer;
}

.tab.active {
  background: var(--ink);
  color: #fff;
}

.link-tab {
  margin-left: auto;
  border-color: var(--line);
}

.panel {
  display: none;
  padding: 18px;
}

.panel.active {
  display: block;
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr 0.7fr;
  gap: 12px;
}

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 0.88rem;
  font-weight: 700;
}

input,
select {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
  padding: 8px 10px;
}

.button-row {
  display: flex;
  gap: 10px;
  margin: 14px 0;
}

button {
  min-height: 42px;
  border-radius: 6px;
  border: 1px solid var(--line);
  padding: 9px 13px;
  cursor: pointer;
}

.primary {
  background: var(--blue);
  color: #fff;
  border-color: var(--blue);
}

.secondary {
  background: #fff;
  color: var(--ink);
}

.response-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

pre {
  min-height: 210px;
  max-height: 430px;
  overflow: auto;
  margin: 8px 0 0;
  padding: 12px;
  border-radius: 6px;
  background: #17191c;
  color: #f8f7f3;
  font-size: 0.82rem;
  line-height: 1.45;
  white-space: pre-wrap;
}

.hint {
  font-size: 0.88rem;
}

.logs {
  display: grid;
  gap: 10px;
  margin-top: 14px;
}

.log-entry {
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  padding: 12px;
}

.log-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}

.method,
.status {
  border-radius: 999px;
  padding: 4px 8px;
  font-size: 0.75rem;
  font-weight: 800;
}

.method {
  background: #e8eefc;
  color: var(--blue);
}

.status.ok {
  background: rgba(31, 157, 102, 0.12);
  color: var(--green);
}

.status.error {
  background: rgba(223, 61, 50, 0.12);
  color: var(--red);
}

.log-entry summary {
  cursor: pointer;
  color: var(--muted);
}

.log-entry pre {
  min-height: 120px;
}

@media (max-width: 900px) {
  .shell,
  .stage,
  .form-grid,
  .response-grid {
    grid-template-columns: 1fr;
  }

  .control-panel,
  .workspace {
    min-height: auto;
  }

  .traffic-light {
    max-width: 190px;
  }
}
