:root {
  color-scheme: light;
  --bg: #f5f7f9;
  --panel: #ffffff;
  --ink: #16202a;
  --muted: #64717f;
  --line: #d9e0e7;
  --accent: #4b5563;
  --accent-strong: #1f2937;
  --danger: #b42318;
  --ok: #067647;
  --shadow: 0 10px 28px rgba(22, 32, 42, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font: 14px/1.45 system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input,
select {
  font: inherit;
}

button {
  border: 1px solid var(--line);
  border-radius: 2px;
  background: #fff;
  color: var(--ink);
  cursor: pointer;
  min-height: 38px;
  padding: 0 14px;
}

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

button.primary {
  border-color: #2f3843;
  background: #374151;
  color: #fff;
  font-weight: 650;
}

button.primary:hover:not(:disabled) {
  background: var(--accent-strong);
}

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

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

.eyebrow {
  margin: 0 0 2px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 750;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2 {
  margin: 0;
  letter-spacing: 0;
}

h1 {
  font-size: clamp(24px, 3vw, 34px);
  line-height: 1.05;
}

h2 {
  font-size: 17px;
}

.status-pill {
  min-width: 110px;
  border: 1px solid var(--line);
  border-radius: 2px;
  background: var(--panel);
  padding: 8px 12px;
  text-align: center;
  font-weight: 700;
  box-shadow: var(--shadow);
}

.status-pill.connected,
.status-pill.completed {
  color: var(--ok);
}

.status-pill.failed {
  color: var(--danger);
}

.layout {
  display: grid;
  grid-template-columns: minmax(300px, 0.78fr) minmax(420px, 1.22fr);
  gap: 16px;
  align-items: stretch;
}

.panel {
  border: 1px solid var(--line);
  border-radius: 2px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border-bottom: 1px solid var(--line);
  padding: 14px 16px;
}

.form-panel,
.run-panel {
  padding-bottom: 16px;
}

.run-panel {
  margin-top: 16px;
}

label {
  display: grid;
  gap: 6px;
  margin: 14px 16px 0;
  color: var(--muted);
  font-weight: 650;
}

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

input:focus,
select:focus {
  border-color: var(--accent);
  outline: 2px solid rgba(75, 85, 99, 0.14);
}

.form-panel > button.primary {
  width: calc(100% - 32px);
  margin: 16px 16px 0;
}

.run-actions {
  display: flex;
  gap: 8px;
}

.run-select-row {
  padding: 14px 16px 0;
}

.run-select-row label {
  margin: 0;
}

.result-strip {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1px;
  margin: 16px 0 0;
  background: var(--line);
  border-bottom: 1px solid var(--line);
  border-top: 1px solid var(--line);
}

.result-strip div {
  min-width: 0;
  background: #fff;
  padding: 14px 16px;
}

.result-strip span {
  display: block;
  margin-bottom: 5px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 750;
  text-transform: uppercase;
}

.result-strip strong {
  display: block;
  margin: 0;
  min-height: 21px;
  overflow-wrap: anywhere;
  font-weight: 700;
}

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

.timer-grid div {
  border: 1px solid var(--line);
  border-radius: 2px;
  padding: 12px;
}

.timer-grid span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 750;
  text-transform: uppercase;
}

.timer-grid strong {
  display: block;
  margin-top: 4px;
  font-size: 24px;
  letter-spacing: 0;
}

.otp-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: end;
  padding: 0 16px;
}

.otp-row label {
  margin: 0;
}

.hidden {
  display: none;
}

.output-panel {
  margin-top: 16px;
}

.screenshot-panel {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.screenshot-stage {
  position: relative;
  display: grid;
  place-items: center;
  flex: 1;
  width: 100%;
  min-height: 0;
  overflow: hidden;
  background: #101820;
}

.screenshot-nav {
  margin-top: auto;
}

.screenshot-stage img {
  display: none;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.screenshot-stage img.visible {
  display: block;
}

.empty-shot {
  color: #bac6d1;
  font-weight: 700;
}

.empty-shot.hidden {
  display: none;
}

.screenshot-nav {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  border-top: 1px solid var(--line);
  padding: 10px 12px;
}

.screenshot-nav button {
  width: 42px;
  min-height: 34px;
  padding: 0;
  font-size: 20px;
  font-weight: 800;
}

.screenshot-meta {
  min-width: 0;
}

.screenshot-nav strong,
.screenshot-nav span {
  display: block;
  overflow-wrap: anywhere;
}

.screenshot-nav span {
  color: var(--muted);
  font-size: 12px;
  margin-top: 2px;
}

.screenshot-buttons {
  display: flex;
  gap: 6px;
}

.output-panel pre,
.event-log {
  margin: 0;
  min-height: 160px;
  max-height: 320px;
  overflow: auto;
  padding: 14px 16px;
  background: #101820;
  color: #e7edf3;
  font: 12px/1.5 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

.event-log {
  display: grid;
  align-content: start;
  gap: 8px;
}

.event-row {
  display: grid;
  grid-template-columns: 96px 160px minmax(0, 1fr);
  gap: 10px;
  border-bottom: 1px solid rgba(231, 237, 243, 0.14);
  padding-bottom: 8px;
}

.event-row:last-child {
  border-bottom: 0;
  padding-bottom: 0;
}

.event-row code {
  color: #a7f3d0;
  overflow-wrap: anywhere;
}

.event-row span {
  color: #bac6d1;
}

@media (max-width: 820px) {
  .shell {
    width: min(100vw - 20px, 720px);
    padding-top: 16px;
  }

  .topbar,
  .layout,
  .otp-row {
    grid-template-columns: 1fr;
  }

  .topbar {
    display: grid;
  }

  .timer-grid,
  .result-strip {
    grid-template-columns: 1fr;
  }

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