:root {
  --bg: #070a0f;
  --panel: #101722;
  --panel-2: #0b111a;
  --line: #223246;
  --text: #eef7fb;
  --muted: #94a4b3;
  --cyan: #2cf3ff;
  --green: #68f59d;
  --amber: #ffd166;
  --red: #ff5c8a;
  --shadow: 0 18px 60px rgba(0, 0, 0, 0.35);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--text);
  background:
    radial-gradient(circle at 12% 10%, rgba(44, 243, 255, 0.16), transparent 26rem),
    radial-gradient(circle at 88% 18%, rgba(104, 245, 157, 0.1), transparent 24rem),
    linear-gradient(180deg, #070a0f 0%, #0a0f16 100%);
}

body::before {
  position: fixed;
  inset: 0;
  z-index: -1;
  content: "";
  background-image:
    linear-gradient(rgba(44, 243, 255, 0.055) 1px, transparent 1px),
    linear-gradient(90deg, rgba(44, 243, 255, 0.045) 1px, transparent 1px);
  background-size: 36px 36px;
  opacity: 0.5;
}

a {
  color: var(--cyan);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

button,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

button:disabled {
  cursor: wait;
  opacity: 0.64;
}

.app {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: 28px 0 40px;
}

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

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

.brand-mark {
  display: grid;
  width: 52px;
  height: 52px;
  place-items: center;
  border: 1px solid rgba(44, 243, 255, 0.55);
  border-radius: 8px;
  color: #061018;
  background: linear-gradient(135deg, var(--cyan), var(--green));
  box-shadow: 0 0 28px rgba(44, 243, 255, 0.24);
  font-size: 24px;
  font-weight: 950;
}

.module-switch {
  display: inline-flex;
  gap: 6px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 5px;
  background: rgba(7, 10, 15, 0.72);
}

.switch-btn {
  min-height: 36px;
  border: 1px solid transparent;
  border-radius: 999px;
  padding: 0 16px;
  color: var(--muted);
  background: transparent;
  font-weight: 850;
}

.switch-btn.active {
  color: #061018;
  border-color: rgba(44, 243, 255, 0.58);
  background: linear-gradient(135deg, var(--cyan), var(--green));
  box-shadow: 0 0 22px rgba(44, 243, 255, 0.18);
}

.eyebrow {
  margin: 0 0 5px;
  color: var(--cyan);
  font-size: 11px;
  font-weight: 850;
  letter-spacing: 0;
}

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

h1 {
  font-size: clamp(28px, 4vw, 44px);
  line-height: 1;
}

h2 {
  font-size: 18px;
}

.module-view {
  display: grid;
  gap: 16px;
}

.module-view[hidden] {
  display: none !important;
}

.guide {
  border: 1px solid rgba(44, 243, 255, 0.16);
  border-radius: 8px;
  padding: 17px 18px;
  background:
    linear-gradient(135deg, rgba(44, 243, 255, 0.07), transparent 45%),
    linear-gradient(180deg, rgba(16, 23, 34, 0.96), rgba(11, 17, 26, 0.98));
  box-shadow: var(--shadow);
}

.guide p {
  margin: 0 0 8px;
  color: var(--muted);
}

.guide ol,
.guide ul {
  margin: 10px 0 0;
  padding-left: 22px;
  color: #cfdbe6;
}

.guide li + li {
  margin-top: 7px;
}

.guide code {
  border: 1px solid rgba(148, 164, 179, 0.16);
  border-radius: 6px;
  padding: 1px 5px;
  color: #e8fbff;
  background: rgba(255, 255, 255, 0.04);
}

.guide-copy {
  max-width: 980px;
}

.flow,
.module-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(360px, 0.92fr);
  gap: 16px;
  align-items: start;
}

.token-grid textarea {
  min-height: 240px;
}

.token-grid .status-panel {
  grid-row: auto;
}

.panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: linear-gradient(180deg, rgba(16, 23, 34, 0.96), rgba(11, 17, 26, 0.98));
  box-shadow: var(--shadow);
}

.step-panel,
.status-panel {
  padding: 18px;
}

.wide-panel {
  padding: 18px;
}

.status-panel {
  grid-row: span 2;
}

.panel-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

.head-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 10px;
}

.head-actions .button {
  flex: 0 0 auto;
}

.badge {
  display: inline-flex;
  min-height: 32px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0 12px;
  color: var(--muted);
  background: rgba(7, 10, 15, 0.72);
  font-size: 13px;
  white-space: nowrap;
}

.field {
  display: grid;
  gap: 8px;
  margin-bottom: 14px;
}

.field span {
  color: #cfdae3;
  font-size: 13px;
  font-weight: 800;
}

.segmented {
  display: inline-flex;
  gap: 6px;
  margin-bottom: 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 4px;
  background: rgba(255, 255, 255, 0.03);
}

.seg-btn {
  min-height: 32px;
  border: 1px solid transparent;
  border-radius: 999px;
  padding: 0 12px;
  color: var(--muted);
  background: transparent;
  font-weight: 850;
}

.seg-btn.active {
  color: var(--text);
  border-color: rgba(44, 243, 255, 0.45);
  background: rgba(44, 243, 255, 0.09);
}

textarea {
  width: 100%;
  min-height: 118px;
  resize: vertical;
  border: 1px solid #25364b;
  border-radius: 8px;
  outline: none;
  padding: 13px;
  color: var(--text);
  background: #080d14;
  line-height: 1.55;
  transition: border-color 0.14s ease, box-shadow 0.14s ease;
}

textarea:focus {
  border-color: rgba(44, 243, 255, 0.75);
  box-shadow: 0 0 0 3px rgba(44, 243, 255, 0.12);
}

.hint,
.notice,
.gate {
  border: 1px solid rgba(148, 164, 179, 0.16);
  border-radius: 8px;
  padding: 11px 12px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.035);
  font-size: 13px;
}

.hint.ok,
.notice.ok {
  border-color: rgba(104, 245, 157, 0.3);
  color: #bfffd3;
}

.notice.warn,
.hint.warn {
  border-color: rgba(255, 209, 102, 0.3);
  color: #ffe2a1;
}

.notice.error {
  border-color: rgba(255, 92, 138, 0.42);
  color: #ffb6cd;
}

.toolbar,
.mini-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 14px;
}

.button {
  display: inline-flex;
  min-height: 42px;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  padding: 0 15px;
  font-weight: 850;
  letter-spacing: 0;
}

.button.primary {
  flex: 1;
  min-width: 150px;
  border: 1px solid rgba(44, 243, 255, 0.7);
  color: #061018;
  background: linear-gradient(135deg, var(--cyan), var(--green));
}

.button.secondary,
.button.ghost {
  border: 1px solid #2a3b51;
  color: #dff7fb;
  background: #111b27;
}

.button.ghost {
  color: var(--muted);
}

.button:hover {
  border-color: rgba(44, 243, 255, 0.62);
}

.button.small {
  min-height: 34px;
  padding: 0 11px;
  font-size: 12px;
}

.button.danger {
  color: #ffb6cd;
}

.token-panel.is-locked {
  opacity: 0.8;
}

.token-form[hidden],
.gate[hidden] {
  display: none;
}

.toggle {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 750;
}

.toggle input {
  width: 18px;
  height: 18px;
  accent-color: var(--cyan);
}

.stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  margin: 12px 0;
}

.summary {
  display: none;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  margin: 12px 0;
}

.metric {
  border: 1px solid rgba(148, 164, 179, 0.12);
  border-radius: 8px;
  padding: 10px;
  background: rgba(255, 255, 255, 0.03);
}

.metric span {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

.metric strong {
  display: block;
  margin-top: 4px;
  font-size: 24px;
}

.metric.ok strong {
  color: var(--green);
}

.metric.warn strong {
  color: var(--amber);
}

.metric.bad strong {
  color: var(--red);
}

.stats div {
  border: 1px solid rgba(148, 164, 179, 0.12);
  border-radius: 8px;
  padding: 10px;
  background: rgba(255, 255, 255, 0.03);
}

.stats span {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

.stats strong {
  display: block;
  margin-top: 4px;
  font-size: 24px;
}

.current-status {
  margin-top: 12px;
}

.empty,
.status-card,
.task-card {
  border: 1px solid rgba(148, 164, 179, 0.14);
  border-radius: 8px;
  background: var(--panel-2);
}

.empty {
  padding: 28px 14px;
  color: var(--muted);
  text-align: center;
}

.status-card,
.task-card {
  padding: 12px;
}

.status-card {
  background:
    linear-gradient(135deg, rgba(44, 243, 255, 0.08), transparent 52%),
    var(--panel-2);
}

.status-card-top,
.task-main {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}

code {
  color: #e8fbff;
  word-break: break-all;
  font-family: "Cascadia Mono", "SFMono-Regular", Consolas, monospace;
}

.status {
  border: 1px solid rgba(148, 164, 179, 0.18);
  border-radius: 999px;
  padding: 5px 9px;
  font-size: 12px;
  font-weight: 850;
  white-space: nowrap;
}

.status.success {
  border-color: rgba(104, 245, 157, 0.42);
  color: #bfffd3;
  background: rgba(104, 245, 157, 0.08);
}

.status.running {
  border-color: rgba(255, 209, 102, 0.42);
  color: #ffe2a1;
  background: rgba(255, 209, 102, 0.08);
}

.status.ready {
  border-color: rgba(44, 243, 255, 0.42);
  color: #c5fbff;
  background: rgba(44, 243, 255, 0.08);
}

.status.failed {
  border-color: rgba(255, 92, 138, 0.42);
  color: #ffb6cd;
  background: rgba(255, 92, 138, 0.08);
}

.progress-line {
  position: relative;
  overflow: hidden;
  border: 1px solid rgba(44, 243, 255, 0.2);
  border-radius: 8px;
  padding: 12px;
  background:
    radial-gradient(circle at 18% 20%, rgba(44, 243, 255, 0.14), transparent 28%),
    rgba(255, 255, 255, 0.035);
  box-shadow: inset 0 0 24px rgba(44, 243, 255, 0.05);
}

.progress-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.progress-head b {
  color: var(--text);
}

.progress-percent {
  color: #eaffff;
  font-size: 28px;
  line-height: 1;
  text-shadow: 0 0 18px rgba(44, 243, 255, 0.45);
}

.liquid-track {
  position: relative;
  height: 30px;
  overflow: hidden;
  border-radius: 999px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.08), transparent 48%),
    #142031;
  box-shadow:
    inset 0 0 0 1px rgba(255, 255, 255, 0.06),
    inset 0 0 22px rgba(0, 0, 0, 0.45),
    0 0 28px rgba(44, 243, 255, 0.1);
}

.liquid-track::before {
  position: absolute;
  inset: 4px;
  z-index: 2;
  border-radius: inherit;
  content: "";
  pointer-events: none;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.24), transparent 42%);
  opacity: 0.45;
}

.liquid-fill {
  position: relative;
  display: block;
  height: 100%;
  width: var(--progress);
  border-radius: inherit;
  overflow: hidden;
  background:
    radial-gradient(circle at 18% 50%, rgba(255, 255, 255, 0.8) 0 2px, transparent 3px),
    linear-gradient(90deg, #16d6ff, #41f7d7 42%, #80ff9b);
  box-shadow:
    0 0 20px rgba(44, 243, 255, 0.5),
    inset 0 0 18px rgba(255, 255, 255, 0.2);
  transition: width 0.32s ease;
}

.liquid-fill::before,
.liquid-fill::after {
  position: absolute;
  inset: -20px -16px auto -16px;
  height: 52px;
  content: "";
  opacity: 0.55;
  background:
    radial-gradient(ellipse at 18% 58%, rgba(255, 255, 255, 0.55) 0 12%, transparent 13%),
    radial-gradient(ellipse at 46% 46%, rgba(255, 255, 255, 0.38) 0 10%, transparent 11%),
    radial-gradient(ellipse at 76% 58%, rgba(255, 255, 255, 0.48) 0 13%, transparent 14%);
  background-size: 72px 30px;
  animation: liquidWave 2.8s linear infinite;
}

.liquid-fill::after {
  top: -15px;
  opacity: 0.32;
  animation-duration: 4.2s;
  animation-direction: reverse;
}

.liquid-shine {
  position: absolute;
  inset: 0;
  z-index: 1;
  background: linear-gradient(110deg, transparent 0 20%, rgba(255, 255, 255, 0.55) 42%, transparent 62% 100%);
  transform: translateX(-115%);
  animation: liquidShine 2.4s ease-in-out infinite;
}

.liquid-bubble {
  position: absolute;
  z-index: 2;
  bottom: 5px;
  width: 5px;
  height: 5px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.74);
  box-shadow: 0 0 10px rgba(255, 255, 255, 0.38);
  animation: bubbleRise 2.7s ease-in-out infinite;
}

.bubble-one {
  left: 22%;
}

.bubble-two {
  left: 54%;
  width: 4px;
  height: 4px;
  animation-delay: 0.8s;
}

.bubble-three {
  left: 78%;
  width: 6px;
  height: 6px;
  animation-delay: 1.4s;
}

@keyframes liquidWave {
  from {
    transform: translateX(0);
  }
  to {
    transform: translateX(72px);
  }
}

@keyframes liquidShine {
  0% {
    transform: translateX(-115%);
  }
  48%,
  100% {
    transform: translateX(115%);
  }
}

@keyframes bubbleRise {
  0% {
    transform: translateY(8px) scale(0.7);
    opacity: 0;
  }
  25%,
  70% {
    opacity: 0.9;
  }
  100% {
    transform: translateY(-16px) scale(1.15);
    opacity: 0;
  }
}

@media (prefers-reduced-motion: reduce) {
  .liquid-fill::before,
  .liquid-fill::after,
  .liquid-shine,
  .liquid-bubble {
    animation: none;
  }
}

.status-meta {
  display: grid;
  grid-template-columns: 1.3fr 0.7fr;
  gap: 8px;
  margin-top: 10px;
}

.status-meta div {
  border: 1px solid rgba(148, 164, 179, 0.1);
  border-radius: 8px;
  padding: 9px;
  background: rgba(255, 255, 255, 0.025);
}

.status-meta span {
  display: block;
  color: var(--muted);
  font-size: 11px;
}

.status-meta strong {
  display: block;
  margin-top: 4px;
  color: #d8e5ec;
  font-size: 12px;
  font-weight: 700;
}

.task-list {
  display: grid;
  gap: 10px;
}

.task-card p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

.history-list,
.channels-list {
  display: grid;
  gap: 12px;
  margin-top: 12px;
}

.history-card,
.channel-card {
  border: 1px solid rgba(148, 164, 179, 0.14);
  border-radius: 8px;
  background:
    linear-gradient(135deg, rgba(44, 243, 255, 0.055), transparent 44%),
    var(--panel-2);
}

.history-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 220px;
  gap: 12px;
  padding: 12px;
}

.history-card-head {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.compact-progress {
  display: grid;
  grid-template-columns: auto auto;
  gap: 8px 12px;
  align-content: start;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.compact-progress strong {
  justify-self: end;
  color: var(--text);
  font-size: 18px;
}

.mini-track {
  grid-column: 1 / -1;
  height: 10px;
  overflow: hidden;
  border-radius: 999px;
  background: #142031;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.06);
}

.mini-track i {
  display: block;
  width: var(--progress);
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #16d6ff, #41f7d7 42%, #80ff9b);
}

.history-meta {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.history-meta div,
.channel-grid div {
  border: 1px solid rgba(148, 164, 179, 0.1);
  border-radius: 8px;
  padding: 9px;
  background: rgba(255, 255, 255, 0.025);
}

.history-meta span,
.channel-grid span {
  display: block;
  color: var(--muted);
  font-size: 11px;
}

.history-meta strong,
.channel-grid strong {
  display: block;
  margin-top: 4px;
  color: #d8e5ec;
  overflow-wrap: anywhere;
  font-size: 12px;
}

.history-actions {
  display: flex;
  align-items: end;
  justify-content: flex-end;
  gap: 8px;
}

.channel-card {
  display: grid;
  grid-template-columns: 56px minmax(0, 1fr);
  gap: 12px;
  padding: 14px;
}

.channel-rank {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  border: 1px solid rgba(44, 243, 255, 0.28);
  border-radius: 8px;
  color: var(--cyan);
  background: rgba(44, 243, 255, 0.06);
  font-weight: 950;
}

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

.channel-title strong {
  min-width: 0;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 18px;
}

.channel-sub {
  margin-top: 5px;
  color: var(--muted);
  font-size: 12px;
}

.channel-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin-top: 12px;
}

.results {
  padding-top: 12px;
}

.list {
  display: grid;
  gap: 10px;
}

.card {
  overflow: hidden;
  border: 1px solid rgba(148, 164, 179, 0.14);
  border-radius: 8px;
  background: var(--panel-2);
}

.card-main {
  display: grid;
  grid-template-columns: 86px minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  padding: 12px;
}

.pill {
  display: inline-flex;
  min-height: 30px;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(148, 164, 179, 0.18);
  border-radius: 999px;
  padding: 0 10px;
  font-size: 12px;
  font-weight: 900;
  white-space: nowrap;
}

.pill.ok {
  color: #bfffd3;
  border-color: rgba(104, 245, 157, 0.42);
  background: rgba(104, 245, 157, 0.08);
}

.pill.warn {
  color: #ffe2a1;
  border-color: rgba(255, 209, 102, 0.42);
  background: rgba(255, 209, 102, 0.08);
}

.pill.bad {
  color: #ffb6cd;
  border-color: rgba(255, 92, 138, 0.42);
  background: rgba(255, 92, 138, 0.08);
}

.main-line {
  overflow: hidden;
  color: var(--text);
  font-weight: 900;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sub-line {
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
  word-break: break-all;
}

.card-tools {
  display: flex;
  gap: 8px;
}

.detail {
  display: none;
  border-top: 1px solid rgba(148, 164, 179, 0.12);
  padding: 12px;
}

.detail.open {
  display: block;
}

.kv {
  display: grid;
  grid-template-columns: 120px minmax(0, 1fr);
  gap: 7px 12px;
}

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

.v {
  color: #d8e5ec;
  overflow-wrap: anywhere;
  font-size: 12px;
}

.toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 10;
  max-width: min(420px, calc(100vw - 40px));
  transform: translateY(14px);
  border: 1px solid rgba(44, 243, 255, 0.35);
  border-radius: 8px;
  padding: 11px 13px;
  color: var(--text);
  background: #0b111a;
  box-shadow: var(--shadow);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.16s ease, transform 0.16s ease;
}

.toast.show {
  transform: translateY(0);
  opacity: 1;
}

@media (max-width: 980px) {
  .flow,
  .module-grid {
    grid-template-columns: 1fr;
  }

  .status-panel {
    grid-row: auto;
  }
}

@media (max-width: 680px) {
  .app {
    width: min(100% - 22px, 1180px);
    padding-top: 18px;
  }

  .hero,
  .module-switch,
  .panel-head,
  .status-card-top,
  .task-main,
  .card-main {
    align-items: stretch;
    flex-direction: column;
  }

  .step-panel,
  .status-panel,
  .wide-panel {
    padding: 14px;
  }

  .stats,
  .summary,
  .status-meta,
  .history-card,
  .history-meta,
  .channel-card,
  .channel-grid {
    grid-template-columns: 1fr;
  }

  .history-card-head,
  .channel-title,
  .head-actions {
    align-items: stretch;
    flex-direction: column;
  }

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

  .toolbar .button {
    width: 100%;
  }
}
