:root {
  color-scheme: dark;
  --paper: #e7e8e2;
  --ink: #111310;
  --surface: #171a17;
  --surface-raised: #202420;
  --line: #3b413b;
  --muted: #9da49c;
  --green: #8ed081;
  --amber: #e6b85c;
  --red: #ee766d;
  --blue: #77a8c8;
  --mono: "IBM Plex Mono", "Cascadia Mono", "Noto Sans Mono CJK SC", monospace;
  --sans: "IBM Plex Sans", "Noto Sans SC", "Microsoft YaHei", sans-serif;
}

* {
  box-sizing: border-box;
  letter-spacing: 0;
}

html {
  min-height: 100%;
  background: var(--ink);
}

body {
  min-height: 100vh;
  margin: 0;
  display: grid;
  grid-template-rows: 64px 1fr 44px;
  color: var(--paper);
  background-color: var(--ink);
  background-image:
    linear-gradient(rgba(231, 232, 226, 0.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(231, 232, 226, 0.035) 1px, transparent 1px);
  background-size: 36px 36px;
  font-family: var(--sans);
  transition: background-color 220ms ease, color 220ms ease;
}

body[data-provider="claude"] {
  color-scheme: light;
  --paper: #2d241d;
  --ink: #f1eadf;
  --surface: #f8f3eb;
  --surface-raised: #fffaf2;
  --line: #d8cbbb;
  --muted: #776a5e;
  --green: #c96f38;
  --amber: #c96f38;
  --red: #a64b3c;
  --blue: #9b6945;
  background-color: var(--ink);
  background-image:
    radial-gradient(circle at 15% 10%, rgba(201, 111, 56, 0.12), transparent 28%),
    radial-gradient(circle at 85% 75%, rgba(155, 105, 69, 0.10), transparent 32%),
    linear-gradient(rgba(45, 36, 29, 0.045) 1px, transparent 1px),
    linear-gradient(90deg, rgba(45, 36, 29, 0.045) 1px, transparent 1px);
  background-size: auto, auto, 36px 36px, 36px 36px;
}

body[data-provider="claude"] .topbar,
body[data-provider="claude"] footer {
  border-color: var(--line);
}

body[data-provider="claude"] .brand-mark {
  border-color: var(--paper);
  border-radius: 50%;
  font-family: Georgia, serif;
  font-size: 16px;
}

body[data-provider="claude"] .signal {
  background: var(--green);
  box-shadow: 0 0 0 4px rgba(201, 111, 56, 0.14);
}

button,
input {
  font: inherit;
}

button,
a {
  -webkit-tap-highlight-color: transparent;
}

button:focus-visible,
a:focus-visible,
input:focus-visible {
  outline: 2px solid var(--amber);
  outline-offset: 3px;
}

.topbar,
footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-inline: clamp(20px, 4vw, 64px);
  border-color: var(--line);
  font-family: var(--mono);
  font-size: 12px;
}

.topbar {
  border-bottom: 1px solid var(--line);
}

footer {
  border-top: 1px solid var(--line);
  color: var(--muted);
}

.brand,
.connection {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-mark {
  display: grid;
  width: 28px;
  height: 28px;
  place-items: center;
  border: 1px solid var(--paper);
  font-weight: 700;
}

.signal {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--amber);
  box-shadow: 0 0 0 4px rgba(230, 184, 92, 0.1);
}

.signal.online {
  background: var(--green);
  box-shadow: 0 0 0 4px rgba(142, 208, 129, 0.1);
}

.mode-label {
  padding: 4px 7px;
  color: var(--amber);
  border: 1px solid rgba(230, 184, 92, 0.55);
  border-radius: 3px;
  font-size: 10px;
  font-weight: 650;
}

main {
  display: grid;
  place-items: center;
  width: 100%;
  padding: clamp(28px, 6vw, 72px) clamp(20px, 4vw, 64px);
}

.unlock-view,
.console-view {
  width: min(100%, 980px);
  animation: reveal 320ms ease-out both;
}

.unlock-view {
  max-width: 620px;
}

.provider-view {
  width: min(100%, 880px);
  padding-block: clamp(10px, 3vw, 34px);
  animation: reveal 320ms ease-out both;
}

.provider-view h1 {
  max-width: 650px;
  margin-bottom: 12px;
}

.provider-intro {
  max-width: 560px;
  margin: 0 0 36px;
  color: var(--muted);
  font-size: 15px;
  line-height: 1.7;
}

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

.provider-card {
  position: relative;
  display: grid;
  grid-template-columns: 58px 1fr auto;
  align-items: center;
  gap: 18px;
  min-height: 170px;
  padding: 24px;
  overflow: hidden;
  color: var(--paper);
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  text-align: left;
  box-shadow: 0 22px 60px rgba(0, 0, 0, 0.18);
  transition: transform 180ms ease, border-color 180ms ease, box-shadow 180ms ease, background-color 180ms ease;
}

.provider-card::after {
  position: absolute;
  inset: auto -20px -62px auto;
  width: 150px;
  height: 150px;
  border: 1px solid currentColor;
  border-radius: 50%;
  opacity: 0.16;
  content: "";
}

.provider-card:hover {
  transform: translateY(-4px);
  border-color: var(--green);
  box-shadow: 0 28px 72px rgba(0, 0, 0, 0.25);
}

.provider-card:active:not(:disabled) {
  transform: translateY(-1px);
}

.provider-card-codex {
  --card-accent: #8ed081;
  color: var(--paper);
  background: linear-gradient(140deg, #171a17, #202820);
}

.provider-card-claude {
  --card-accent: #c96f38;
  color: #2d241d;
  background: linear-gradient(140deg, #fffaf2, #eee2d3);
}

.provider-card-codex:hover { border-color: var(--card-accent); }
.provider-card-claude:hover { border-color: var(--card-accent); }

.provider-card-mark {
  display: grid;
  width: 58px;
  height: 58px;
  place-items: center;
  color: var(--card-accent);
  border: 1px solid currentColor;
  border-radius: 4px;
  font-family: var(--mono);
  font-size: 22px;
  font-weight: 700;
}

.provider-card-claude .provider-card-mark {
  border-radius: 50%;
  font-family: Georgia, serif;
  font-size: 24px;
}

.provider-card-copy {
  display: grid;
  gap: 8px;
}

.provider-card-copy strong {
  font-size: 22px;
  font-weight: 620;
}

.provider-card-copy small {
  color: var(--muted);
  font-family: var(--mono);
  font-size: 11px;
}

.provider-card-arrow {
  align-self: start;
  color: var(--card-accent);
  font-family: var(--mono);
  font-size: 20px;
}

.provider-lock-button {
  margin-top: 30px;
}

.section-index,
label,
.timer-label,
.phase-badge,
.capacity-label,
.result-panel span {
  color: var(--muted);
  font-family: var(--mono);
  font-size: 11px;
  text-transform: uppercase;
}

h1 {
  margin: 12px 0 36px;
  font-family: var(--sans);
  font-size: clamp(30px, 5vw, 52px);
  font-weight: 600;
  line-height: 1.08;
}

.unlock-form label {
  display: block;
  margin-bottom: 10px;
}

.input-row {
  display: grid;
  grid-template-columns: 1fr 108px;
  min-height: 52px;
}

input {
  min-width: 0;
  border: 1px solid var(--line);
  border-right: 0;
  border-radius: 4px 0 0 4px;
  padding: 0 16px;
  color: var(--paper);
  background: var(--surface);
  font-family: var(--mono);
}

button {
  min-height: 44px;
  border: 1px solid transparent;
  border-radius: 4px;
  cursor: pointer;
  transition: background-color 140ms ease, color 140ms ease, border-color 140ms ease, transform 140ms ease;
}

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

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

.input-row button,
.primary-button {
  color: var(--ink);
  background: var(--green);
  font-weight: 650;
}

.input-row button {
  min-height: 52px;
  border-radius: 0 4px 4px 0;
}

.input-row button:hover,
.primary-button:hover {
  background: #a8dfa0;
}

.form-error {
  min-height: 22px;
  margin: 12px 0 0;
  color: var(--red);
  font-size: 13px;
}

.console-heading {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 24px;
}

.console-heading h1 {
  margin-bottom: 30px;
}

.quiet-button,
.danger-button {
  padding: 0 16px;
  color: var(--muted);
  border-color: var(--line);
  background: transparent;
}

.quiet-button:hover {
  color: var(--paper);
  border-color: var(--muted);
}

.workbench {
  display: grid;
  grid-template-columns: 168px minmax(0, 1fr);
  border: 1px solid var(--line);
  border-radius: 6px;
  overflow: hidden;
  background: var(--surface);
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.28);
}

body[data-provider="claude"] .workbench {
  background: var(--surface);
  box-shadow: 0 24px 80px rgba(95, 66, 42, 0.16);
}

body[data-provider="claude"] .timeline {
  background: #f0e7dc;
}

body[data-provider="claude"] .timeline li {
  color: #a08f7e;
}

body[data-provider="claude"] .timeline li.active {
  color: var(--paper);
}

body[data-provider="claude"] .timeline li.complete {
  color: var(--green);
}

.timeline {
  border-right: 1px solid var(--line);
  padding: 24px 20px;
  background: #141714;
}

.timeline ol {
  display: grid;
  gap: 28px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.timeline li {
  display: grid;
  grid-template-columns: 28px 1fr;
  align-items: center;
  color: #6f766f;
  font-size: 13px;
}

.timeline li span {
  font-family: var(--mono);
  font-size: 10px;
}

.timeline li strong {
  font-weight: 500;
}

.timeline li.active {
  color: var(--paper);
}

.timeline li.complete {
  color: var(--green);
}

.task-surface {
  min-width: 0;
  display: flex;
  min-height: 450px;
  flex-direction: column;
  padding: clamp(24px, 5vw, 48px);
}

.task-meta,
.task-footer,
.device-step,
.step-copy,
.code-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.phase-badge {
  padding: 5px 8px;
  color: var(--green);
  border: 1px solid rgba(142, 208, 129, 0.38);
  border-radius: 3px;
}

.timer-block {
  display: grid;
  gap: 3px;
  margin: 52px 0 42px;
}

.timer-block strong {
  font-family: var(--mono);
  font-size: 46px;
  font-weight: 500;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

.primary-actions {
  display: flex;
}

.primary-button {
  width: 160px;
  min-height: 48px;
}

.device-panel {
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.device-step {
  padding: 18px 0;
}

.device-step + .device-step {
  border-top: 1px solid var(--line);
}

.step-copy {
  align-items: flex-start;
  justify-content: flex-start;
  gap: 14px;
}

.step-number {
  display: inline-grid;
  flex: 0 0 34px;
  width: 34px;
  height: 34px;
  place-items: center;
  color: var(--blue);
  border: 1px solid var(--blue);
  font-family: var(--mono);
  font-size: 11px;
}

.step-copy strong {
  display: block;
  color: var(--paper);
  font-size: 15px;
}

.step-copy p {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.6;
}

.device-link-button {
  display: inline-flex;
  min-height: 44px;
  margin: 16px 0 0 48px;
  padding: 0 18px;
  align-items: center;
  justify-content: center;
  color: var(--blue);
  border: 1px solid var(--blue);
  text-decoration: none;
  font-family: var(--mono);
  font-size: 12px;
}

.device-link-button:hover {
  color: var(--ink);
  background: var(--blue);
}

.claude-panel {
  display: grid;
  gap: 0;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.claude-panel .device-step {
  align-items: flex-start;
  flex-direction: column;
  padding: 22px 0;
}

.claude-panel .device-step + .device-step {
  border-top: 1px solid var(--line);
}

.claude-panel .step-number {
  color: var(--amber);
  border-color: var(--amber);
}

.claude-panel .device-link-button {
  margin-left: 48px;
  color: var(--amber);
  border-color: var(--amber);
}

.claude-panel .device-link-button:hover {
  color: var(--ink);
  background: var(--amber);
}

.callback-step textarea {
  display: block;
  width: calc(100% - 48px);
  min-height: 84px;
  margin: 18px 0 0 48px;
  resize: vertical;
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 13px 14px;
  color: var(--paper);
  background: var(--surface-raised);
  font-family: var(--mono);
  font-size: 12px;
  line-height: 1.55;
}

.callback-submit {
  width: auto;
  min-width: 168px;
  margin: 14px 0 0 48px;
  padding-inline: 18px;
}

.callback-submit:not(:disabled) {
  background: var(--amber);
}

.callback-submit:not(:disabled):hover {
  background: #df8a50;
}

.callback-step .form-error {
  margin-left: 48px;
}

.is-disabled {
  pointer-events: none;
  opacity: 0.42;
}

.code-row {
  min-height: 72px;
  margin: 14px 0 0 48px;
  padding: 0 12px 0 16px;
  border: 1px solid var(--line);
  background: var(--surface-raised);
}

.code-row code {
  overflow-wrap: anywhere;
  color: var(--paper);
  font-family: var(--mono);
  font-size: 28px;
}

.icon-button {
  width: 44px;
  min-width: 44px;
  padding: 0;
  color: var(--paper);
  border-color: var(--line);
  background: var(--surface-raised);
  font-family: var(--mono);
  font-size: 19px;
}

.icon-button:hover {
  border-color: var(--paper);
}

.result-panel {
  display: grid;
  gap: 8px;
  padding: 22px 0;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.result-panel strong {
  overflow-wrap: anywhere;
  font-size: 20px;
  font-weight: 550;
}

.result-panel p {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
}

.task-footer {
  min-height: 46px;
  margin-top: auto;
  padding-top: 24px;
  color: var(--muted);
  font-size: 13px;
}

.danger-button {
  color: var(--red);
  border-color: rgba(238, 118, 109, 0.45);
}

.danger-button:hover {
  color: var(--ink);
  background: var(--red);
}

.is-hidden {
  display: none !important;
}

@keyframes reveal {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

@media (max-width: 720px) {
  body {
    grid-template-rows: 58px 1fr 40px;
  }

  .brand {
    gap: 8px;
    font-size: 10px;
  }

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

  .provider-card {
    min-height: 132px;
  }

  .brand-mark {
    width: 24px;
    height: 24px;
  }

  .connection {
    font-size: 10px;
  }

  main {
    place-items: start center;
  }

  h1 {
    margin-bottom: 26px;
  }

  .console-heading {
    align-items: center;
  }

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

  .timeline {
    border-right: 0;
    border-bottom: 1px solid var(--line);
    padding: 16px;
    overflow-x: auto;
  }

  .timeline ol {
    grid-template-columns: repeat(4, minmax(74px, 1fr));
    gap: 12px;
  }

  .timeline li {
    grid-template-columns: 20px 1fr;
  }

  .task-surface {
    min-height: 410px;
  }

  .timer-block {
    margin: 36px 0 30px;
  }

  .timer-block strong {
    font-size: 40px;
  }

  .device-step {
    align-items: flex-start;
    flex-direction: column;
    padding: 14px 0;
  }

  .code-row code {
    font-size: 23px;
  }

  .callback-step textarea,
  .callback-submit,
  .callback-step .form-error {
    width: calc(100% - 48px);
    margin-left: 48px;
  }
}

@media (max-width: 430px) {
  .topbar,
  footer {
    padding-inline: 14px;
  }

  main {
    padding-inline: 14px;
  }

  .brand > span:last-child {
    max-width: 150px;
    line-height: 1.2;
  }

  .input-row {
    grid-template-columns: 1fr 86px;
  }

  .task-surface {
    padding: 20px 16px;
  }

  .provider-card {
    grid-template-columns: 48px 1fr auto;
    gap: 12px;
    padding: 18px;
  }

  .provider-card-mark {
    width: 48px;
    height: 48px;
  }

  .callback-step textarea,
  .callback-submit,
  .callback-step .form-error {
    width: 100%;
    margin-left: 0;
  }
}
