:root {
  color-scheme: light;
  --bg: #eef2f6;
  --surface: #ffffff;
  --surface-soft: #f6f8fb;
  --surface-muted: #edf2f7;
  --line: #d7e0ea;
  --line-strong: #aebdcb;
  --text: #111827;
  --text-soft: #334155;
  --muted: #64748b;
  --sidebar: #111827;
  --sidebar-soft: #1f2937;
  --sidebar-line: rgba(255, 255, 255, 0.12);
  --primary: #0f766e;
  --primary-hover: #0b625d;
  --primary-soft: #e6fffb;
  --accent: #2563eb;
  --success: #067647;
  --success-bg: #ecfdf3;
  --danger: #b42318;
  --danger-bg: #fff1f0;
  --warning: #b54708;
  --warning-bg: #fffaeb;
  --focus: rgba(15, 118, 110, 0.26);
  --shadow: 0 16px 36px rgba(15, 23, 42, 0.10);
  --shadow-soft: 0 8px 22px rgba(15, 23, 42, 0.08);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  background: var(--bg);
}

body {
  margin: 0;
  min-width: 320px;
  min-height: 100dvh;
  background:
    linear-gradient(90deg, rgba(17, 24, 39, 0.04) 1px, transparent 1px),
    linear-gradient(180deg, rgba(17, 24, 39, 0.04) 1px, transparent 1px),
    linear-gradient(180deg, #f8fafc 0, var(--bg) 280px);
  background-size: 32px 32px, 32px 32px, auto;
  color: var(--text);
  font-size: 16px;
  line-height: 1.55;
}

button,
input,
textarea {
  font: inherit;
}

button {
  touch-action: manipulation;
}

a {
  color: inherit;
}

.page-shell {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: 22px 0 36px;
}

.page-header {
  min-height: 76px;
  margin-bottom: 16px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 18px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 18px;
  background: rgba(255, 255, 255, 0.88);
  box-shadow: var(--shadow-soft);
}

.hero-copy {
  min-width: 0;
  display: grid;
  gap: 3px;
}

.eyebrow {
  margin: 0;
  color: var(--primary);
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.hero-copy h1 {
  margin: 0;
  font-size: clamp(24px, 3vw, 34px);
  line-height: 1.12;
  font-weight: 900;
  letter-spacing: 0;
}

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

.mode-switch {
  min-height: 46px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 12px;
  display: inline-flex;
  gap: 4px;
  background: var(--surface-muted);
}

.mode-tab {
  min-width: 128px;
  min-height: 38px;
  border: 0;
  border-radius: 9px;
  padding: 8px 14px;
  cursor: pointer;
  color: var(--muted);
  background: transparent;
  font-weight: 850;
  transition: color 0.16s ease, background 0.16s ease, transform 0.16s ease;
}

.mode-tab:hover {
  color: var(--text);
  background: rgba(255, 255, 255, 0.72);
}

.mode-tab.active {
  color: #ffffff;
  background: var(--sidebar);
}

.mode-tab:active,
.btn:active,
.guide-link:active {
  transform: translateY(1px);
}

.mode-tab:focus-visible,
.btn:focus-visible,
.guide-link:focus-visible,
input:focus-visible,
textarea:focus-visible,
.switch input:focus-visible + .switch-track {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}

.panel[hidden],
.flow-step[hidden] {
  display: none;
}

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

.guide-card,
.flow-card,
.batch-card {
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: var(--shadow);
}

.guide-card {
  padding: 18px;
  background: var(--sidebar);
  color: #ffffff;
}

.guide-card h2,
.batch-head h2,
.flow-heading h2 {
  margin: 0;
  font-weight: 900;
  letter-spacing: 0;
}

.guide-card h2 {
  font-size: 22px;
}

.guide-card > p {
  margin: 6px 0 14px;
  color: #a7b1c2;
  font-size: 13px;
}

.guide-list {
  margin: 0;
  padding: 0;
  display: grid;
  gap: 10px;
  list-style: none;
}

.guide-item {
  display: grid;
  grid-template-columns: 38px minmax(0, 1fr);
  gap: 12px;
  padding: 12px;
  border: 1px solid var(--sidebar-line);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.04);
}

.guide-number {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #dbeafe;
  background: var(--sidebar-soft);
  font-size: 12px;
  font-weight: 900;
  font-variant-numeric: tabular-nums;
}

.guide-item.active {
  border-color: rgba(45, 212, 191, 0.55);
  background: rgba(15, 118, 110, 0.22);
}

.guide-item.active .guide-number {
  color: #ffffff;
  background: var(--primary);
}

.guide-item h3 {
  margin: 0;
  color: #ffffff;
  font-size: 14px;
  line-height: 1.3;
  font-weight: 900;
}

.guide-item p {
  margin: 4px 0 0;
  color: #b7c3d4;
  font-size: 12px;
}

.guide-link {
  width: fit-content;
  min-height: 44px;
  margin-top: 8px;
  border: 1px solid rgba(94, 234, 212, 0.68);
  border-radius: 9px;
  padding: 9px 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #ffffff;
  background: var(--primary);
  box-shadow: 0 10px 22px rgba(15, 118, 110, 0.28);
  text-decoration: none;
  font-size: 12px;
  font-weight: 850;
  transition: background 0.16s ease, border-color 0.16s ease, box-shadow 0.16s ease, transform 0.16s ease;
}

.guide-link:hover {
  border-color: rgba(153, 246, 228, 0.92);
  background: var(--primary-hover);
  box-shadow: 0 14px 28px rgba(15, 118, 110, 0.36);
}

.flow-card,
.batch-card {
  background: rgba(255, 255, 255, 0.94);
}

.flow-card {
  padding: 18px;
}

.flow-progress {
  margin: 0 0 14px;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  list-style: none;
}

.progress-item {
  min-height: 46px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 12px;
  display: grid;
  grid-template-columns: 7px minmax(0, 1fr);
  gap: 9px;
  align-items: center;
  color: var(--muted);
  background: var(--surface-soft);
  font-size: 12px;
  font-weight: 850;
}

.progress-bar {
  width: 7px;
  height: 100%;
  min-height: 24px;
  border-radius: 999px;
  overflow: hidden;
  background: #dbe4ef;
}

.progress-bar::after {
  content: "";
  display: block;
  width: 100%;
  height: 0;
  border-radius: inherit;
  background: var(--primary);
  transition: height 0.18s ease;
}

.progress-item.active,
.progress-item.done {
  border-color: rgba(15, 118, 110, 0.28);
  color: var(--primary);
  background: var(--primary-soft);
}

.progress-item.active .progress-bar::after,
.progress-item.done .progress-bar::after {
  height: 100%;
}

.flow-step,
.form-stack {
  display: grid;
  gap: 12px;
}

.flow-step {
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: #ffffff;
}

.action-step {
  min-height: 0;
  padding: 24px 26px;
  grid-template-columns: 1fr;
  align-items: start;
  gap: 22px;
  border-color: rgba(15, 118, 110, 0.18);
  background: linear-gradient(135deg, #ffffff 0%, #f2fffc 100%);
}

.action-copy {
  min-width: 0;
  display: grid;
  gap: 12px;
}

.step-kicker {
  width: fit-content;
  min-height: 28px;
  padding: 4px 10px;
  border: 1px solid rgba(15, 118, 110, 0.18);
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  color: var(--primary);
  background: var(--primary-soft);
  font-size: 12px;
  font-weight: 900;
}

.action-step .flow-heading {
  gap: 6px;
}

.action-step .flow-heading h2 {
  font-size: clamp(22px, 2.4vw, 28px);
}

.action-step .flow-heading p {
  max-width: 720px;
  line-height: 1.65;
}

.action-controls {
  min-width: 0;
  display: grid;
  justify-items: start;
  gap: 12px;
}

.action-nav {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-start;
  gap: 10px;
}

.btn.featured-link {
  min-width: 176px;
  min-height: 48px;
  box-shadow: 0 12px 24px rgba(15, 118, 110, 0.22);
}

.flow-heading {
  display: grid;
  gap: 4px;
}

.flow-heading h2 {
  color: var(--text);
  font-size: clamp(22px, 3vw, 30px);
  line-height: 1.16;
}

.flow-heading p,
.batch-head p {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
}

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

.field-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

label {
  color: var(--text-soft);
  font-size: 14px;
  font-weight: 850;
}

.required {
  color: var(--danger);
}

.hint {
  color: var(--muted);
  font-size: 12px;
}

input[type="text"],
textarea {
  width: 100%;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  background: #ffffff;
  color: var(--text);
  outline: none;
  transition: border-color 0.16s ease, box-shadow 0.16s ease;
}

input[type="text"] {
  min-height: 46px;
  padding: 10px 13px;
}

textarea {
  min-height: 128px;
  padding: 11px 13px;
  resize: vertical;
  tab-size: 2;
}

textarea.session-input {
  min-height: 164px;
  font-family: "Cascadia Mono", "Consolas", monospace;
  font-size: 13px;
  line-height: 1.5;
}

input[type="text"]:hover,
textarea:hover {
  border-color: #8fa1b7;
}

input[type="text"]:focus,
textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 4px var(--focus);
}

textarea[aria-invalid="true"],
input[aria-invalid="true"] {
  border-color: var(--danger);
}

textarea[aria-invalid="true"]:focus,
input[aria-invalid="true"]:focus {
  border-color: var(--danger);
  box-shadow: 0 0 0 4px rgba(180, 35, 24, 0.16);
}

.actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}

.btn {
  min-height: 42px;
  border: 1px solid transparent;
  border-radius: 10px;
  padding: 9px 15px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: #ffffff;
  background: var(--primary);
  text-decoration: none;
  font-weight: 850;
  transition: background 0.16s ease, border-color 0.16s ease, opacity 0.16s ease, transform 0.16s ease;
}

.btn:hover:not(:disabled) {
  background: var(--primary-hover);
}

.btn:disabled {
  cursor: not-allowed;
  opacity: 0.48;
}

.btn.secondary {
  border-color: var(--line-strong);
  background: #ffffff;
  color: var(--text-soft);
}

.btn.secondary:hover:not(:disabled) {
  border-color: #8fa1b7;
  background: var(--surface-soft);
}

.link-button {
  width: fit-content;
}

.switch-row {
  min-height: 56px;
  padding: 11px 13px;
  border: 1px solid var(--line);
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  background: var(--surface-soft);
}

.switch-row p {
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.switch {
  position: relative;
  flex: 0 0 auto;
  width: 50px;
  height: 30px;
  cursor: pointer;
}

.switch input {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

.switch-track {
  position: absolute;
  inset: 0;
  border-radius: 999px;
  background: #c8d3e1;
  pointer-events: none;
  transition: background 0.16s ease;
}

.switch-track::after {
  content: "";
  position: absolute;
  top: 4px;
  left: 4px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #ffffff;
  box-shadow: 0 2px 7px rgba(15, 23, 42, 0.22);
  transition: transform 0.16s ease;
}

.switch input:checked + .switch-track {
  background: var(--primary);
}

.switch input:checked + .switch-track::after {
  transform: translateX(20px);
}

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

.summary-item {
  min-width: 0;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 11px;
  display: grid;
  gap: 4px;
  background: var(--surface-soft);
}

.summary-item span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 850;
}

.summary-item strong {
  color: var(--text);
  word-break: break-word;
}

.status-line {
  min-height: 22px;
  color: var(--muted);
  font-size: 13px;
}

.message {
  display: none;
  border-radius: 11px;
  border: 1px solid var(--line);
  padding: 10px 12px;
  font-size: 13px;
  font-weight: 750;
}

.message.visible {
  display: block;
}

.message.success {
  border-color: #abefc6;
  background: var(--success-bg);
  color: var(--success);
}

.message.error {
  border-color: #fecdca;
  background: var(--danger-bg);
  color: var(--danger);
}

.message.warning {
  border-color: #fedf89;
  background: var(--warning-bg);
  color: var(--warning);
}

.details {
  display: none;
  border: 1px solid var(--line);
  border-radius: 11px;
  overflow: hidden;
  background: #ffffff;
}

.details.visible {
  display: block;
}

.detail-row {
  display: grid;
  grid-template-columns: 112px minmax(0, 1fr);
  border-top: 1px solid var(--line);
}

.detail-row:first-child {
  border-top: 0;
}

.detail-key,
.detail-value {
  padding: 9px 12px;
  min-width: 0;
  word-break: break-word;
}

.detail-key {
  background: var(--surface-soft);
  color: var(--muted);
  font-size: 12px;
  font-weight: 850;
}

.batch-card {
  margin: 0 auto;
  padding: 24px;
  background: var(--surface);
}

.batch-head {
  margin-bottom: 16px;
  display: grid;
  gap: 4px;
}

.batch-head h2 {
  color: var(--text);
  font-size: clamp(24px, 3vw, 32px);
}

.table-wrap {
  width: 100%;
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: #ffffff;
}

table {
  width: 100%;
  min-width: 860px;
  border-collapse: collapse;
}

th,
td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
  word-break: break-word;
}

th {
  background: var(--surface-soft);
  color: var(--text-soft);
  font-size: 12px;
  font-weight: 900;
  white-space: nowrap;
}

td {
  color: var(--text);
  font-size: 13px;
}

tr:last-child td {
  border-bottom: 0;
}

.empty-cell {
  height: 96px;
  color: var(--muted);
  text-align: center;
  vertical-align: middle;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 900;
  white-space: nowrap;
}

.badge.ok {
  background: var(--success-bg);
  color: var(--success);
}

.badge.fail {
  background: var(--danger-bg);
  color: var(--danger);
}

.badge.wait {
  background: var(--warning-bg);
  color: var(--warning);
}

.mono {
  font-family: "Cascadia Mono", "Consolas", monospace;
  font-size: 13px;
}

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

@media (max-width: 920px) {
  .page-header {
    grid-template-columns: 1fr;
    align-items: start;
  }

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

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

  .action-nav {
    justify-content: flex-start;
  }

  .action-nav .btn {
    flex: 1 1 160px;
  }
}

@media (max-width: 640px) {
  .page-shell {
    width: min(100% - 18px, 1180px);
    padding-top: 14px;
  }

  .page-header,
  .guide-card,
  .flow-card,
  .batch-card {
    padding: 14px;
    border-radius: 15px;
  }

  .mode-switch {
    width: 100%;
  }

  .mode-tab {
    flex: 1 1 0;
    min-width: 0;
    padding-inline: 8px;
  }

  .guide-list,
  .flow-progress,
  .summary-grid {
    grid-template-columns: 1fr;
  }

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

  .action-step {
    padding: 16px;
    gap: 16px;
  }

  .action-controls {
    display: grid;
    grid-template-columns: 1fr;
  }

  .action-nav {
    width: 100%;
    display: grid;
    grid-template-columns: 1fr;
  }

  .btn,
  .guide-link,
  .link-button {
    width: 100%;
  }

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

  .detail-value {
    border-top: 1px solid var(--line);
  }
}
