:root {
  color-scheme: dark;
  --ink: #12212B;
  --paper: #F1F6F7;
  --teal: #1BA6A8;
  --gold: #F6C85F;
  --red: #D85A4F;
  --ink-soft: rgba(18, 33, 43, 0.72);
  --ink-faint: rgba(18, 33, 43, 0.16);
  --paper-soft: rgba(241, 246, 247, 0.74);
  --paper-faint: rgba(241, 246, 247, 0.12);
  --shadow: 0 24px 64px rgba(3, 12, 18, 0.36);
  font-family: "Microsoft YaHei UI", "PingFang SC", "Noto Sans CJK SC", system-ui, sans-serif;
  font-synthesis: none;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  min-width: 280px;
  background: var(--ink);
  scroll-behavior: smooth;
}

body {
  min-width: 280px;
  min-height: 100vh;
  margin: 0;
  background: var(--ink);
  color: var(--paper);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

button,
input {
  font: inherit;
}

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

button,
a {
  touch-action: manipulation;
}

code {
  font-family: ui-monospace, "Cascadia Mono", "SFMono-Regular", Consolas, monospace;
}

[hidden] {
  display: none !important;
}

.sr-only {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

.skip-link {
  position: fixed;
  z-index: 100;
  top: 12px;
  left: 12px;
  padding: 10px 14px;
  border-radius: 8px;
  background: var(--gold);
  color: var(--ink);
  font-weight: 800;
  text-decoration: none;
  transform: translateY(-160%);
}

.skip-link:focus {
  transform: translateY(0);
}

:focus-visible {
  outline: 3px solid var(--gold);
  outline-offset: 3px;
}

.page-shell {
  width: min(100%, 760px);
  margin: 0 auto;
  padding: 24px 16px 32px;
}

.masthead {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 20px;
  margin: 4px 4px 24px;
}

.brand-lockup {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.brand-mark {
  position: relative;
  display: grid;
  flex: 0 0 46px;
  width: 46px;
  height: 46px;
  place-items: center;
  border: 2px solid var(--teal);
  border-radius: 50%;
}

.brand-mark::after {
  content: "";
  position: absolute;
  right: -4px;
  bottom: 4px;
  width: 10px;
  height: 10px;
  border: 3px solid var(--ink);
  border-radius: 50%;
  background: var(--gold);
}

.brand-mark__arrow {
  position: relative;
  width: 3px;
  height: 19px;
  border-radius: 2px;
  background: var(--paper);
}

.brand-mark__arrow::before,
.brand-mark__arrow::after {
  content: "";
  position: absolute;
  bottom: 0;
  width: 3px;
  height: 11px;
  border-radius: 2px;
  background: var(--paper);
  transform-origin: bottom;
}

.brand-mark__arrow::before {
  left: -1px;
  transform: rotate(45deg);
}

.brand-mark__arrow::after {
  right: -1px;
  transform: rotate(-45deg);
}

.masthead__kicker,
.eyebrow {
  margin: 0 0 5px;
  color: var(--teal);
  font-size: 0.68rem;
  font-weight: 900;
  letter-spacing: 0.18em;
  line-height: 1.25;
}

.masthead h1 {
  margin: 0;
  font-family: "Arial Narrow", "Microsoft YaHei UI", "PingFang SC", sans-serif;
  font-size: clamp(1.55rem, 7vw, 2.15rem);
  font-stretch: condensed;
  font-weight: 900;
  letter-spacing: -0.06em;
  line-height: 1;
}

.device-ticket {
  flex: 0 0 auto;
  margin: 0;
  color: var(--paper-soft);
  font-size: 0.68rem;
  letter-spacing: 0.08em;
  text-align: right;
  text-transform: uppercase;
}

.device-ticket code {
  display: block;
  margin-top: 4px;
  color: var(--gold);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.12em;
}

.ticket {
  position: relative;
  overflow: hidden;
  border: 1px solid rgba(241, 246, 247, 0.45);
  border-radius: 22px;
  background: var(--paper);
  box-shadow: var(--shadow);
  color: var(--ink);
  animation: ticket-arrival 300ms ease-out both;
}

.ticket__header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  padding: 24px 20px 21px;
}

.ticket__heading {
  min-width: 0;
}

.ticket__header h2 {
  margin: 0;
  font-family: "Arial Narrow", "Microsoft YaHei UI", "PingFang SC", sans-serif;
  font-size: clamp(1.7rem, 8vw, 2.65rem);
  font-stretch: condensed;
  font-weight: 900;
  letter-spacing: -0.065em;
  line-height: 1.05;
}

.ticket__header p:last-child {
  max-width: 38rem;
  margin: 9px 0 0;
  color: var(--ink-soft);
  font-size: 0.9rem;
  line-height: 1.65;
}

.status-badge {
  display: inline-flex;
  flex: 0 0 auto;
  align-items: center;
  gap: 7px;
  min-height: 30px;
  padding: 6px 10px;
  border: 1px solid var(--ink-faint);
  border-radius: 999px;
  background: transparent;
  color: var(--ink);
  font-size: 0.72rem;
  font-weight: 900;
  white-space: nowrap;
}

.status-badge__dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--gold);
}

.ticket[data-state="unlocked"] .status-badge {
  border-color: var(--teal);
  background: var(--teal);
}

.ticket[data-state="unlocked"] .status-badge__dot {
  background: var(--ink);
}

.ticket[data-state="error"] .status-badge,
.ticket[data-state="configuration"] .status-badge {
  border-color: var(--red);
  background: var(--red);
  color: var(--paper);
}

.ticket[data-state="error"] .status-badge__dot,
.ticket[data-state="configuration"] .status-badge__dot {
  background: var(--paper);
}

.tear-line {
  position: relative;
  height: 1px;
  margin: 0;
  border-top: 2px dashed rgba(18, 33, 43, 0.24);
}

.tear-line::before,
.tear-line::after {
  content: "";
  position: absolute;
  top: -15px;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--ink);
}

.tear-line::before {
  left: -14px;
}

.tear-line::after {
  right: -14px;
}

.progress-stub {
  margin: 20px;
  padding: 18px;
  border: 2px solid var(--ink);
  border-radius: 16px;
  background: var(--gold);
}

.progress-stub__header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}

.eyebrow--dark {
  color: var(--ink-soft);
}

.progress-stub h3,
.action-panel h3 {
  margin: 0;
  font-size: 1rem;
  font-weight: 900;
  letter-spacing: -0.025em;
}

.progress-total {
  margin: 0;
  font-family: ui-monospace, "Cascadia Mono", Consolas, monospace;
  font-size: 1.45rem;
  font-weight: 900;
  letter-spacing: -0.06em;
}

.hole-track {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(18px, 1fr));
  gap: 9px;
  min-height: 52px;
  padding: 14px;
  border: 1px dashed rgba(18, 33, 43, 0.6);
  border-radius: 12px;
  background: rgba(241, 246, 247, 0.38);
}

.ticket-hole {
  position: relative;
  display: block;
  width: 20px;
  height: 20px;
  margin: auto;
  border: 2px solid rgba(18, 33, 43, 0.42);
  border-radius: 50%;
  background: var(--paper);
}

.ticket-hole.is-complete {
  border-color: var(--ink);
  background: var(--ink);
  box-shadow: inset 0 0 0 4px var(--teal);
}

.ticket-hole.is-next {
  border-color: var(--red);
  box-shadow: 0 0 0 3px rgba(216, 90, 79, 0.22);
}

.ticket-hole.is-placeholder {
  border-color: rgba(18, 33, 43, 0.2);
  background: rgba(241, 246, 247, 0.55);
  animation: hole-wait 1.2s ease-in-out infinite alternate;
}

.ticket-hole.is-placeholder:nth-child(2n) {
  animation-delay: 180ms;
}

.hole-track.is-empty {
  display: flex;
  align-items: center;
  justify-content: center;
}

.hole-empty {
  color: var(--ink-soft);
  font-size: 0.78rem;
  font-weight: 800;
}

.progress-caption {
  margin: 11px 0 0;
  color: var(--ink-soft);
  font-size: 0.76rem;
  line-height: 1.5;
}

.metric-strip {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  margin: 0 20px;
  border-top: 1px solid var(--ink-faint);
  border-bottom: 1px solid var(--ink-faint);
}

.metric-strip > div {
  min-width: 0;
  padding: 16px 10px;
  text-align: center;
}

.metric-strip > div + div {
  border-left: 1px solid var(--ink-faint);
}

.metric-strip dt {
  color: var(--ink-soft);
  font-size: 0.72rem;
  line-height: 1.4;
}

.metric-strip dd {
  margin: 4px 0 0;
  font-family: ui-monospace, "Cascadia Mono", Consolas, monospace;
  font-size: 1.3rem;
  font-weight: 900;
}

.status-message {
  display: flex;
  align-items: flex-start;
  gap: 11px;
  margin: 20px;
  padding: 14px;
  border-left: 4px solid var(--gold);
  background: rgba(246, 200, 95, 0.17);
}

.status-message__mark {
  flex: 0 0 10px;
  width: 10px;
  height: 10px;
  margin-top: 6px;
  border: 2px solid var(--ink);
  border-radius: 50%;
}

.status-message p {
  margin: 0;
  font-size: 0.86rem;
  line-height: 1.65;
  overflow-wrap: anywhere;
}

.ticket[data-state="unlocked"] .status-message {
  border-left-color: var(--teal);
  background: rgba(27, 166, 168, 0.12);
}

.ticket[data-state="unlocked"] .status-message__mark {
  border-color: var(--teal);
  background: var(--teal);
}

.ticket[data-state="error"] .status-message,
.ticket[data-state="configuration"] .status-message {
  border-left-color: var(--red);
  background: rgba(216, 90, 79, 0.1);
}

.ticket[data-state="error"] .status-message__mark,
.ticket[data-state="configuration"] .status-message__mark {
  border-color: var(--red);
  background: var(--red);
}

.action-grid {
  display: grid;
  gap: 1px;
  margin-top: 20px;
  border-top: 1px solid var(--ink-faint);
  background: var(--ink-faint);
}

.action-panel {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  min-width: 0;
  padding: 20px;
  background: var(--paper);
}

.action-panel__copy {
  min-width: 0;
}

.link-value {
  display: block;
  max-width: 100%;
  margin-top: 9px;
  overflow: hidden;
  color: var(--ink-soft);
  font-size: 0.72rem;
  line-height: 1.45;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.button {
  display: inline-flex;
  flex: 0 0 auto;
  min-height: 44px;
  align-items: center;
  justify-content: center;
  padding: 10px 15px;
  border: 2px solid transparent;
  border-radius: 10px;
  cursor: pointer;
  font-size: 0.82rem;
  font-weight: 900;
  line-height: 1.2;
  text-align: center;
  text-decoration: none;
  transition: transform 140ms ease, box-shadow 140ms ease, opacity 140ms ease;
}

.button:not(:disabled):not(.is-disabled):hover {
  transform: translateY(-2px);
}

.button:not(:disabled):not(.is-disabled):active {
  transform: translateY(0);
}

.button--primary {
  border-color: var(--teal);
  background: var(--teal);
  color: var(--ink);
  box-shadow: 0 5px 0 rgba(18, 33, 43, 0.18);
}

.button--secondary {
  border-color: var(--ink);
  background: transparent;
  color: var(--ink);
}

.button--dark {
  border-color: var(--ink);
  background: var(--ink);
  color: var(--paper);
}

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

.ticket__footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 20px 20px;
}

.ticket__footer p {
  margin: 0;
  color: var(--ink-soft);
  font-size: 0.74rem;
  line-height: 1.55;
}

.settings {
  margin-top: 16px;
  border: 1px solid var(--paper-faint);
  border-radius: 16px;
  background: rgba(241, 246, 247, 0.05);
}

.settings summary {
  display: flex;
  min-height: 64px;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 17px;
  border-radius: 15px;
  cursor: pointer;
  list-style: none;
}

.settings summary::-webkit-details-marker {
  display: none;
}

.settings__title,
.settings__summary {
  display: block;
}

.settings__title {
  color: var(--paper);
  font-size: 0.9rem;
  font-weight: 900;
}

.settings__summary {
  margin-top: 3px;
  color: var(--paper-soft);
  font-size: 0.7rem;
}

.settings__chevron {
  width: 10px;
  height: 10px;
  border-right: 2px solid var(--gold);
  border-bottom: 2px solid var(--gold);
  transform: rotate(45deg);
  transition: transform 160ms ease;
}

.settings[open] .settings__chevron {
  transform: rotate(225deg);
}

.settings__form {
  display: grid;
  gap: 16px;
  padding: 4px 17px 18px;
}

.settings__help {
  margin: 0 0 2px;
  color: var(--paper-soft);
  font-size: 0.75rem;
  line-height: 1.65;
}

.settings__help code,
.field label code {
  color: var(--gold);
}

.field {
  display: grid;
  gap: 7px;
}

.field label {
  color: var(--paper);
  font-size: 0.78rem;
  font-weight: 800;
}

.field input {
  width: 100%;
  min-height: 46px;
  padding: 10px 12px;
  border: 1px solid rgba(241, 246, 247, 0.28);
  border-radius: 9px;
  background: rgba(241, 246, 247, 0.08);
  color: var(--paper);
  outline: none;
}

.field input::placeholder {
  color: rgba(241, 246, 247, 0.42);
}

.field input:focus {
  border-color: var(--gold);
  box-shadow: 0 0 0 3px rgba(246, 200, 95, 0.18);
}

.field input[readonly] {
  color: var(--paper-soft);
  cursor: default;
}

.field small {
  color: var(--paper-soft);
  font-size: 0.68rem;
  line-height: 1.5;
}

.settings__actions {
  display: flex;
  align-items: center;
  gap: 14px;
}

#settings-feedback {
  margin: 0;
  color: var(--paper-soft);
  font-size: 0.72rem;
  line-height: 1.5;
}

.page-footer {
  padding: 20px 8px 0;
  color: rgba(241, 246, 247, 0.48);
  font-size: 0.68rem;
  line-height: 1.65;
  text-align: center;
}

.page-footer p {
  margin: 0;
}

@keyframes ticket-arrival {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes hole-wait {
  from {
    opacity: 0.35;
  }
  to {
    opacity: 0.82;
  }
}

@media (min-width: 680px) {
  .page-shell {
    padding-top: 42px;
    padding-bottom: 48px;
  }

  .masthead {
    margin-bottom: 30px;
  }

  .ticket__header {
    padding: 30px 30px 27px;
  }

  .progress-stub {
    margin: 28px 30px;
    padding: 22px;
  }

  .metric-strip,
  .status-message {
    margin-right: 30px;
    margin-left: 30px;
  }

  .action-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .action-panel {
    display: grid;
    align-content: space-between;
    min-height: 170px;
    padding: 24px 30px;
  }

  .action-panel + .action-panel {
    border-left: 1px dashed rgba(18, 33, 43, 0.24);
  }

  .action-panel .button {
    justify-self: start;
  }

  .ticket__footer {
    padding: 22px 30px 26px;
  }

  .settings summary {
    padding-right: 22px;
    padding-left: 22px;
  }

  .settings__form {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    padding: 5px 22px 22px;
  }

  .settings__help,
  .settings__actions {
    grid-column: 1 / -1;
  }
}

@media (max-width: 430px) {
  .page-shell {
    padding-right: 11px;
    padding-left: 11px;
  }

  .masthead {
    margin-right: 5px;
    margin-left: 5px;
  }

  .brand-mark {
    flex-basis: 40px;
    width: 40px;
    height: 40px;
  }

  .ticket__header {
    display: grid;
  }

  .status-badge {
    justify-self: start;
  }

  .action-panel {
    align-items: stretch;
    flex-direction: column;
  }

  .action-panel .button {
    width: 100%;
  }

  .ticket__footer {
    align-items: stretch;
    flex-direction: column;
  }

  .ticket__footer .button {
    width: 100%;
  }

  .settings__actions {
    align-items: stretch;
    flex-direction: column;
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
