:root {
  color-scheme: dark;
  --page-bg: #080d13;
  --page-glow: rgba(46, 125, 218, 0.14);
  --card-bg: #111820;
  --card-top: #141c25;
  --field-bg: #0b121a;
  --field-hover: #0e1721;
  --surface-soft: #161f29;
  --surface-raised: #1a2531;
  --text: #edf3fb;
  --text-strong: #ffffff;
  --muted: #91a1b4;
  --subtle: #697a8d;
  --border: #2a3644;
  --border-strong: #3a4b5e;
  --primary: #4da3ff;
  --primary-hover: #70b5ff;
  --primary-contrast: #06101d;
  --primary-soft: rgba(77, 163, 255, 0.12);
  --success: #36d17e;
  --success-soft: rgba(54, 209, 126, 0.11);
  --warning: #f2b84b;
  --warning-soft: rgba(242, 184, 75, 0.12);
  --danger: #ff6675;
  --danger-hover: #ff8591;
  --danger-soft: rgba(255, 102, 117, 0.12);
  --shadow: 0 24px 70px rgba(0, 0, 0, 0.34);
  --focus-ring: rgba(77, 163, 255, 0.28);
  --radius-lg: 18px;
  --radius-md: 11px;
  --radius-sm: 8px;
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei UI", "PingFang SC", sans-serif;
}

:root[data-theme="light"] {
  color-scheme: light;
  --page-bg: #eef2f6;
  --page-glow: rgba(44, 127, 218, 0.12);
  --card-bg: #ffffff;
  --card-top: #fbfcfe;
  --field-bg: #f6f8fb;
  --field-hover: #f0f4f8;
  --surface-soft: #f4f7fa;
  --surface-raised: #edf2f7;
  --text: #1c2836;
  --text-strong: #101923;
  --muted: #5e6f82;
  --subtle: #8290a0;
  --border: #d8e0e8;
  --border-strong: #c2ceda;
  --primary: #1677d2;
  --primary-hover: #0d68be;
  --primary-contrast: #ffffff;
  --primary-soft: rgba(22, 119, 210, 0.09);
  --success: #13884a;
  --success-soft: rgba(19, 136, 74, 0.09);
  --warning: #a66800;
  --warning-soft: rgba(166, 104, 0, 0.09);
  --danger: #d83b4e;
  --danger-hover: #bd2c3e;
  --danger-soft: rgba(216, 59, 78, 0.09);
  --shadow: 0 22px 60px rgba(31, 48, 68, 0.12);
  --focus-ring: rgba(22, 119, 210, 0.18);
}

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

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

body {
  min-height: 100vh;
  margin: 0;
  color: var(--text);
  background:
    radial-gradient(circle at 50% -16%, var(--page-glow), transparent 38rem),
    var(--page-bg);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

button,
textarea {
  font: inherit;
}

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

button,
a,
textarea {
  outline: none;
}

button:focus-visible,
a:focus-visible,
textarea:focus-visible {
  box-shadow: 0 0 0 4px var(--focus-ring);
}

button:focus-visible,
textarea:focus-visible {
  border-color: var(--primary);
}

code {
  padding: 1px 4px;
  border-radius: 4px;
  color: var(--text);
  background: var(--surface-raised);
  font-family: ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", monospace;
  font-size: 0.92em;
}

.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;
}

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

.app-card {
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--card-bg);
  box-shadow: var(--shadow);
}

.app-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
  padding: 28px 30px;
  background: linear-gradient(180deg, var(--card-top), var(--card-bg));
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 9px;
  flex: 0 0 auto;
}

.api-docs-link {
  min-height: 38px;
  color: var(--primary);
}

.community-link {
  min-height: 38px;
  color: var(--primary);
  text-decoration: none;
}

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

.brand-icon {
  display: grid;
  flex: 0 0 auto;
  width: 44px;
  height: 44px;
  place-items: center;
  border: 1px solid color-mix(in srgb, var(--primary) 38%, var(--border));
  border-radius: 12px;
  color: var(--primary);
  background: var(--primary-soft);
}

.brand-icon svg {
  width: 25px;
  height: 25px;
  fill: currentColor;
}

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

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 5px;
  color: var(--text-strong);
  font-size: clamp(21px, 3vw, 26px);
  font-weight: 750;
  letter-spacing: -0.02em;
}

h2 {
  margin-bottom: 3px;
  color: var(--text-strong);
  font-size: 15px;
  font-weight: 700;
}

.app-header p,
.section-title-row p,
.action-copy p {
  margin-bottom: 0;
  color: var(--muted);
  font-size: 13px;
}

.product-badge,
.public-api-badge,
.country-badge,
.option-code {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid color-mix(in srgb, var(--primary) 34%, var(--border));
  border-radius: 999px;
  color: var(--primary);
  background: var(--primary-soft);
  font-size: 11px;
  font-weight: 750;
  letter-spacing: 0.04em;
}

.product-badge {
  min-width: 38px;
  height: 22px;
  padding: 0 8px;
}

.public-api-badge {
  height: 22px;
  padding: 0 9px;
  border-color: color-mix(in srgb, var(--success) 38%, var(--border));
  color: var(--success);
  background: var(--success-soft);
}

.icon-button,
.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  font-weight: 650;
  white-space: nowrap;
  cursor: pointer;
  transition: border-color 150ms ease, background-color 150ms ease, color 150ms ease, transform 150ms ease, opacity 150ms ease;
}

.icon-button:hover,
.button:hover:not(:disabled) {
  transform: translateY(-1px);
}

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

.button:disabled {
  cursor: not-allowed;
  opacity: 0.46;
  transform: none;
}

.button svg,
.icon-button svg,
.lock-note svg,
.storage-note svg,
.empty-state svg {
  width: 17px;
  height: 17px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.theme-toggle {
  flex: 0 0 auto;
  min-height: 38px;
  padding: 8px 11px;
  border-color: var(--border);
  color: var(--muted);
  background: var(--surface-soft);
  font-size: 12px;
}

.theme-toggle:hover {
  border-color: var(--border-strong);
  color: var(--text);
  background: var(--surface-raised);
}

.theme-icon {
  width: 17px;
  height: 17px;
}

:root[data-theme="dark"] .theme-icon-moon,
:root[data-theme="light"] .theme-icon-sun {
  display: none;
}

.status-overview {
  padding: 20px 30px 23px;
  border-top: 1px solid var(--border);
  background:
    linear-gradient(135deg, color-mix(in srgb, var(--primary-soft) 42%, transparent), transparent 55%),
    var(--surface-soft);
}

.status-overview-heading,
.tasks-view-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 14px;
}

.status-overview-heading h2,
.tasks-view-heading h2 {
  margin-bottom: 3px;
}

.status-overview-heading p,
.tasks-view-heading p {
  margin-bottom: 0;
  color: var(--muted);
  font-size: 12px;
}

#dashboard-updated-at {
  color: var(--subtle);
  font-size: 11px;
  white-space: nowrap;
}

.metric-grid {
  display: grid;
  grid-template-columns: 1.3fr repeat(6, minmax(0, 1fr));
  gap: 9px;
}

.metric-card {
  display: grid;
  gap: 4px;
  min-width: 0;
  min-height: 72px;
  padding: 11px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: color-mix(in srgb, var(--card-bg) 82%, transparent);
}

.metric-card span {
  color: var(--subtle);
  font-size: 10.5px;
}

.metric-card strong {
  align-self: end;
  color: var(--text-strong);
  font-size: 21px;
  font-variant-numeric: tabular-nums;
}

.success-rate-card strong {
  color: var(--success);
}

.duration-card strong {
  font-size: 18px;
  white-space: nowrap;
}

.success-rate-track {
  height: 4px;
  overflow: hidden;
  border-radius: 999px;
  background: var(--border);
}

.success-rate-track span {
  display: block;
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--success), var(--primary));
  transition: width 300ms ease;
}

.view-tabs {
  display: flex;
  gap: 6px;
  padding: 10px 30px 0;
  border-top: 1px solid var(--border);
  background: var(--card-bg);
}

.view-tab {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-width: 128px;
  min-height: 38px;
  padding: 8px 17px;
  border: 1px solid transparent;
  border-bottom: 0;
  border-radius: 10px 10px 0 0;
  color: var(--muted);
  background: transparent;
  font-weight: 700;
  cursor: pointer;
}

.view-tab.active {
  border-color: var(--border);
  color: var(--primary);
  background: var(--surface-soft);
}

.view-tab span {
  min-width: 20px;
  padding: 1px 6px;
  border-radius: 999px;
  color: var(--muted);
  background: var(--surface-raised);
  font-size: 10px;
}

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

.form-section,
.output-section {
  padding: 25px 30px;
  border-top: 1px solid var(--border);
}

.section-title-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 13px;
}

.compact-heading {
  align-items: center;
  margin-bottom: 17px;
}

textarea {
  display: block;
  width: 100%;
  min-height: 128px;
  resize: vertical;
  padding: 12px 13px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  color: var(--text);
  background: var(--field-bg);
  font-family: ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", monospace;
  font-size: 12.5px;
  line-height: 1.55;
  caret-color: var(--primary);
  transition: border-color 150ms ease, background-color 150ms ease, box-shadow 150ms ease;
}

textarea:hover {
  background: var(--field-hover);
}

textarea:focus {
  border-color: var(--primary);
  background: var(--field-bg);
}

textarea[aria-invalid="true"] {
  border-color: var(--danger);
  box-shadow: 0 0 0 3px var(--danger-soft);
}

textarea::placeholder {
  color: var(--subtle);
  opacity: 0.84;
}

textarea::-webkit-scrollbar,
.log-output::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

textarea::-webkit-scrollbar-thumb,
.log-output::-webkit-scrollbar-thumb {
  border: 3px solid transparent;
  border-radius: 999px;
  background: var(--border-strong);
  background-clip: padding-box;
}

.field-help {
  margin: 7px 0 0;
  color: var(--subtle);
  font-size: 12px;
}

.button {
  min-height: 40px;
  padding: 9px 16px;
}

.button[hidden] {
  display: none !important;
}

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

.button-subtle {
  border-color: var(--border);
  color: var(--text);
  background: var(--surface-soft);
}

.button-subtle:hover:not(:disabled) {
  border-color: var(--border-strong);
  background: var(--surface-raised);
}

.button-primary {
  min-width: 134px;
  border-color: var(--primary);
  color: var(--primary-contrast);
  background: var(--primary);
  box-shadow: 0 7px 20px color-mix(in srgb, var(--primary) 22%, transparent);
}

.button-primary:hover:not(:disabled) {
  border-color: var(--primary-hover);
  background: var(--primary-hover);
}

.button-danger {
  min-width: 124px;
  border-color: color-mix(in srgb, var(--danger) 46%, var(--border));
  color: var(--danger);
  background: var(--danger-soft);
}

.button-danger:hover:not(:disabled) {
  border-color: var(--danger);
  color: var(--danger-hover);
  background: color-mix(in srgb, var(--danger) 17%, transparent);
}

.button.is-loading svg,
.test-button.is-loading svg {
  animation: spin 850ms linear infinite;
}

.token-check-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.token-check-actions .button-primary,
.token-check-actions .button-danger {
  min-width: auto;
}

.token-profile {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  min-height: 35px;
  margin-top: 10px;
  padding: 7px 11px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--muted);
  background: var(--surface-soft);
  font-size: 12px;
}

.token-profile > span:not(.profile-dot, .profile-divider) {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.token-profile b {
  color: var(--subtle);
  font-weight: 550;
}

.profile-dot,
.state-dot {
  width: 7px;
  height: 7px;
  flex: 0 0 auto;
  border-radius: 50%;
  background: var(--subtle);
}

.profile-divider {
  width: 1px;
  height: 13px;
  background: var(--border-strong);
}

.token-profile.valid {
  border-color: color-mix(in srgb, var(--success) 32%, var(--border));
  background: var(--success-soft);
}

.token-profile.valid .profile-dot {
  background: var(--success);
  box-shadow: 0 0 0 3px var(--success-soft);
}

.token-profile.querying {
  border-color: color-mix(in srgb, var(--primary) 32%, var(--border));
  background: var(--primary-soft);
}

.token-profile.querying .profile-dot {
  background: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-soft);
  animation: pulse 1.1s ease-in-out infinite alternate;
}

.token-profile.expired,
.token-profile.invalid {
  border-color: color-mix(in srgb, var(--danger) 33%, var(--border));
  background: var(--danger-soft);
}

.token-profile.expired .profile-dot,
.token-profile.invalid .profile-dot {
  background: var(--danger);
}

.account-batch-panel {
  margin-top: 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: var(--field-bg);
}

.account-batch-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  background: var(--surface-soft);
  font-size: 12px;
}

.account-batch-heading strong {
  color: var(--text);
  font-weight: 650;
}

.account-batch-heading span {
  color: var(--muted);
  text-align: right;
}

.account-batch-heading-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
}

.account-batch-heading-actions .button {
  min-width: auto;
}

.account-table-wrap {
  max-height: 390px;
  overflow: auto;
  scrollbar-gutter: stable;
}

.account-table {
  width: 100%;
  min-width: 720px;
  border-collapse: collapse;
  table-layout: fixed;
  font-size: 12px;
}

.account-table th,
.account-table td {
  padding: 9px 11px;
  border-bottom: 1px solid var(--border);
  text-align: left;
  vertical-align: middle;
  overflow-wrap: anywhere;
}

.account-table th {
  position: sticky;
  top: 0;
  z-index: 1;
  color: var(--subtle);
  background: var(--card-top);
  font-weight: 600;
}

.account-table th:first-child,
.account-table td:first-child {
  width: 48px;
  text-align: center;
}

.account-table th:nth-child(2),
.account-table td:nth-child(2) {
  width: 34%;
}

.account-table th:nth-child(3),
.account-table td:nth-child(3) {
  width: 15%;
}

.account-table th:nth-child(4),
.account-table td:nth-child(4) {
  width: 25%;
}

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

.account-row.pending td {
  color: var(--subtle);
}

.account-row.success td:nth-child(4) {
  color: var(--success);
}

.account-row.error td:nth-child(4) {
  color: var(--danger);
}

.account-plan {
  display: inline-flex;
  align-items: center;
  min-height: 23px;
  padding: 2px 8px;
  border: 1px solid color-mix(in srgb, var(--primary) 34%, var(--border));
  border-radius: 999px;
  color: var(--primary);
  background: var(--primary-soft);
  font-weight: 650;
}

.lock-note,
.storage-note {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex: 0 0 auto;
  color: var(--subtle);
  font-size: 11px;
}

.lock-note svg,
.storage-note svg {
  width: 14px;
  height: 14px;
}

.method-choice {
  display: flex;
  align-items: center;
  gap: 13px;
  min-height: 76px;
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background:
    linear-gradient(90deg, var(--primary-soft), transparent 48%),
    var(--surface-soft);
}

.method-choice-radio {
  position: relative;
  width: 22px;
  height: 22px;
  flex: 0 0 auto;
  border: 2px solid var(--primary);
  border-radius: 50%;
}

.method-choice-radio::after {
  position: absolute;
  inset: 4px;
  border-radius: 50%;
  background: var(--primary);
  content: "";
}

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

.method-choice-copy strong {
  color: var(--text-strong);
  font-size: 15px;
}

.method-choice-copy small {
  color: var(--muted);
  font-size: 11.5px;
}

.method-choice-badge {
  margin-left: auto;
  padding: 4px 9px;
  border: 1px solid color-mix(in srgb, var(--primary) 34%, var(--border));
  border-radius: 999px;
  color: var(--primary);
  background: var(--primary-soft);
  font-size: 10px;
  font-weight: 700;
}

.task-query-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.task-id-input {
  width: 100%;
  min-width: 0;
  min-height: 42px;
  padding: 9px 12px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  color: var(--text);
  background: var(--field-bg);
  font-family: ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", monospace;
  font-size: 12.5px;
  outline: none;
  transition: border-color 150ms ease, box-shadow 150ms ease;
}

.task-id-input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-soft);
}

.task-id-input[aria-invalid="true"] {
  border-color: var(--danger);
  box-shadow: 0 0 0 3px var(--danger-soft);
}

.task-status-card {
  display: grid;
  grid-template-columns: auto minmax(110px, 0.6fr) minmax(220px, 1.4fr) minmax(130px, auto);
  align-items: center;
  gap: 12px;
  margin-top: 12px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-soft);
}

.task-status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--subtle);
}

.task-status-card.queued .task-status-dot,
.task-status-card.running .task-status-dot,
.task-status-card.cancelling .task-status-dot {
  background: var(--warning);
  box-shadow: 0 0 0 3px var(--warning-soft);
}

.task-status-card.succeeded .task-status-dot {
  background: var(--success);
  box-shadow: 0 0 0 3px var(--success-soft);
}

.task-status-card.failed .task-status-dot,
.task-status-card.timed_out .task-status-dot,
.task-status-card.cancelled .task-status-dot,
.task-status-card.interrupted .task-status-dot {
  background: var(--danger);
  box-shadow: 0 0 0 3px var(--danger-soft);
}

.task-status-card > div {
  display: grid;
  gap: 2px;
}

.task-status-caption {
  color: var(--subtle);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.task-status-card strong {
  color: var(--text-strong);
  font-size: 13px;
}

.task-status-card code,
.task-list-item code {
  overflow: hidden;
  color: var(--primary);
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.task-status-card > span:last-child {
  color: var(--muted);
  font-size: 11px;
  text-align: right;
}

.task-list-panel {
  margin-top: 14px;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}

.task-list-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  background: var(--surface-soft);
  font-size: 12px;
}

.task-list-heading span {
  color: var(--muted);
}

.task-list {
  margin: 0;
  padding: 0;
  list-style: none;
}

.task-list-item {
  display: grid;
  grid-template-columns: minmax(200px, 1.3fr) minmax(140px, 0.8fr) auto;
  align-items: center;
  gap: 14px;
  padding: 10px 12px;
}

.task-list-item + .task-list-item {
  border-top: 1px solid var(--border);
}

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

.task-list-details strong {
  color: var(--text);
  font-size: 12px;
}

.task-list-details small {
  overflow: hidden;
  color: var(--subtle);
  font-size: 10.5px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.action-section {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  background: color-mix(in srgb, var(--surface-soft) 48%, transparent);
}

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

.run-state {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  margin-bottom: 4px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 650;
}

.run-state.running {
  color: var(--primary);
}

.run-state.running .state-dot {
  background: var(--primary);
  box-shadow: 0 0 0 4px var(--primary-soft);
  animation: pulse 1.2s ease-in-out infinite;
}

.run-state.stopping {
  color: var(--warning);
}

.run-state.stopping .state-dot {
  background: var(--warning);
}

.run-state.success {
  color: var(--success);
}

.run-state.success .state-dot {
  background: var(--success);
}

.run-state.error {
  color: var(--danger);
}

.run-state.error .state-dot {
  background: var(--danger);
}

.primary-actions {
  display: flex;
  flex: 0 0 auto;
  gap: 10px;
}

.output-section {
  background: color-mix(in srgb, var(--field-bg) 28%, var(--card-bg));
}

.output-heading {
  align-items: center;
  margin-bottom: 12px;
}

.empty-state {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 84px;
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-md);
  color: var(--subtle);
  background: var(--field-bg);
  font-size: 12px;
}

.empty-state svg {
  width: 18px;
  height: 18px;
}

.empty-state[hidden] {
  display: none;
}

.result-list {
  display: grid;
  gap: 9px;
  margin: 0;
  padding: 0;
  list-style: none;
  counter-reset: result;
}

.result-item {
  display: grid;
  grid-template-columns: auto 148px minmax(0, 1fr);
  align-items: start;
  gap: 14px;
  padding: 13px;
  border: 1px solid color-mix(in srgb, var(--success) 26%, var(--border));
  border-radius: var(--radius-md);
  background: var(--success-soft);
  counter-increment: result;
}

.result-index {
  display: grid;
  width: 25px;
  height: 25px;
  place-items: center;
  border-radius: 7px;
  color: var(--success);
  background: color-mix(in srgb, var(--success) 13%, var(--card-bg));
  font-size: 11px;
  font-weight: 750;
}

.result-index::before {
  content: counter(result);
}

.result-qr {
  display: grid;
  width: 148px;
  height: 148px;
  place-items: center;
  overflow: hidden;
  border: 1px solid color-mix(in srgb, var(--success) 32%, var(--border));
  border-radius: 10px;
  background: #ffffff;
  text-decoration: none;
}

.result-qr img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.result-qr img[hidden],
.result-qr-error[hidden] {
  display: none !important;
}

.result-qr.error {
  padding: 12px;
  color: var(--danger);
  background: var(--danger-soft);
  text-align: center;
}

.result-qr-error {
  font-size: 12px;
}

.result-details {
  min-width: 0;
  align-self: center;
}

.result-link {
  display: block;
  min-width: 0;
  overflow: hidden;
  color: var(--success);
  font-family: ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", monospace;
  font-size: 11.5px;
  text-decoration: none;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.result-link:hover {
  text-decoration: underline;
}

.result-actions {
  display: flex;
  gap: 5px;
  margin-top: 12px;
}

.result-actions .icon-button {
  width: 31px;
  height: 31px;
  padding: 0;
  border-color: var(--border);
  color: var(--muted);
  background: var(--card-bg);
}

.result-actions .icon-button:hover {
  border-color: var(--border-strong);
  color: var(--text);
}

.result-actions svg {
  width: 15px;
  height: 15px;
}

.log-section {
  padding-bottom: 30px;
}

.log-output {
  min-height: 158px;
  max-height: 350px;
  overflow: auto;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--muted);
  background: var(--field-bg);
  font-family: ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", monospace;
  font-size: 11.5px;
  line-height: 1.6;
  scrollbar-gutter: stable;
}

.log-row {
  display: grid;
  grid-template-columns: 66px minmax(0, 1fr);
  gap: 8px;
  padding: 2px 0;
  overflow-wrap: anywhere;
}

.log-row time {
  color: var(--subtle);
  user-select: none;
}

.log-row.success span {
  color: var(--success);
}

.log-row.warn span {
  color: var(--warning);
}

.log-row.error span {
  color: var(--danger);
}

.log-row.muted span {
  color: var(--subtle);
}

.tasks-view {
  min-height: 480px;
  padding: 25px 30px 30px;
  border-top: 1px solid var(--border);
}

.history-empty {
  display: grid;
  min-height: 220px;
  place-content: center;
  gap: 5px;
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-md);
  color: var(--muted);
  text-align: center;
}

.history-empty strong {
  color: var(--text);
}

.history-empty span {
  color: var(--subtle);
  font-size: 12px;
}

.history-task-list {
  display: grid;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
}

.history-task-row {
  display: grid;
  grid-template-columns: minmax(225px, 1.15fr) minmax(145px, 0.75fr) minmax(150px, 0.8fr) auto;
  align-items: center;
  gap: 14px;
  min-width: 0;
  padding: 13px 14px;
  background: var(--card-bg);
}

.history-task-row + .history-task-row {
  border-top: 1px solid var(--border);
}

.history-task-row[data-status="running"],
.history-task-row[data-status="queued"],
.history-task-row[data-status="cancelling"] {
  box-shadow: inset 3px 0 0 var(--warning);
}

.history-task-row[data-status="succeeded"] {
  box-shadow: inset 3px 0 0 var(--success);
}

.history-task-row[data-status="failed"],
.history-task-row[data-status="timed_out"],
.history-task-row[data-status="cancelled"],
.history-task-row[data-status="interrupted"] {
  box-shadow: inset 3px 0 0 var(--danger);
}

.history-task-identity,
.history-task-state {
  display: grid;
  gap: 4px;
  min-width: 0;
}

.history-task-identity code {
  overflow: hidden;
  color: var(--primary);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.history-task-identity span,
.history-task-state span {
  overflow: hidden;
  color: var(--subtle);
  font-size: 10.5px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.history-task-state strong {
  color: var(--text);
  font-size: 12px;
}

.history-task-row[data-status="succeeded"] .history-task-state strong {
  color: var(--success);
}

.history-task-row[data-status="failed"] .history-task-state strong,
.history-task-row[data-status="timed_out"] .history-task-state strong,
.history-task-row[data-status="cancelled"] .history-task-state strong,
.history-task-row[data-status="interrupted"] .history-task-state strong {
  color: var(--danger);
}

.history-task-result {
  min-width: 0;
  overflow: hidden;
  color: var(--muted);
  font-size: 11px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.history-task-result a {
  color: var(--success);
  font-weight: 650;
  text-decoration: none;
}

.history-task-result a:hover {
  text-decoration: underline;
}

.history-task-actions {
  display: flex;
  gap: 6px;
}

.docs-shell {
  width: min(100% - 32px, 900px);
}

.docs-section {
  padding: 24px 30px;
  border-top: 1px solid var(--border);
}

.docs-section h2 {
  display: inline-block;
  margin: 0 0 9px 8px;
  vertical-align: middle;
}

.docs-section h3 {
  margin: 18px 0 8px;
  color: var(--text);
  font-size: 12px;
}

.docs-section p {
  margin-bottom: 12px;
  color: var(--muted);
  font-size: 12.5px;
  line-height: 1.7;
}

.docs-section pre {
  margin: 10px 0 0;
  overflow: auto;
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--field-bg);
}

.docs-section pre code {
  padding: 0;
  color: var(--text);
  background: transparent;
  font-size: 11.5px;
  line-height: 1.65;
  white-space: pre;
}

.docs-method {
  display: inline-flex;
  min-width: 44px;
  min-height: 22px;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 0.05em;
  vertical-align: middle;
}

.docs-method.get {
  color: var(--primary);
  background: var(--primary-soft);
}

.docs-method.post {
  color: var(--success);
  background: var(--success-soft);
}

.docs-callout {
  display: grid;
  gap: 4px;
  padding: 14px 16px;
  border: 1px solid color-mix(in srgb, var(--primary) 28%, var(--border));
  border-radius: var(--radius-md);
  background: var(--primary-soft);
}

.docs-callout strong {
  color: var(--primary);
  font-size: 12px;
}

.docs-callout span {
  color: var(--muted);
  font-size: 11.5px;
}

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

.docs-status-grid span {
  padding: 9px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--muted);
  background: var(--surface-soft);
  font-size: 11.5px;
}

.docs-security {
  padding-bottom: 30px;
}

.page-footnote {
  margin: 14px 0 0;
  color: var(--subtle);
  font-size: 10px;
  letter-spacing: 0.08em;
  text-align: center;
}

.toast-region {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 50;
  display: grid;
  gap: 8px;
  width: min(360px, calc(100vw - 36px));
  pointer-events: none;
}

.toast {
  padding: 10px 13px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  color: var(--text);
  background: var(--surface-raised);
  box-shadow: var(--shadow);
  font-size: 12px;
  animation: toast-in 180ms ease-out;
}

.toast.success {
  border-color: color-mix(in srgb, var(--success) 45%, var(--border));
}

.toast.error {
  border-color: color-mix(in srgb, var(--danger) 50%, var(--border));
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

@keyframes pulse {
  0%, 100% { opacity: 0.5; }
  50% { opacity: 1; }
}

@keyframes toast-in {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

@media (max-width: 760px) {
  .page-shell {
    width: min(100% - 20px, 1040px);
    padding: 14px 0 28px;
  }

  .app-header,
  .form-section,
  .output-section,
  .status-overview,
  .tasks-view {
    padding-left: 18px;
    padding-right: 18px;
  }

  .app-header {
    padding-top: 21px;
    padding-bottom: 21px;
  }

  .brand-icon {
    width: 39px;
    height: 39px;
  }

  .view-tabs {
    padding-right: 18px;
    padding-left: 18px;
  }

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

  .history-task-row {
    grid-template-columns: minmax(0, 1fr) auto;
  }

  .history-task-state,
  .history-task-result {
    grid-column: 1;
  }

  .history-task-actions {
    grid-column: 2;
    grid-row: 1 / span 3;
    flex-direction: column;
  }

  .section-title-row.compact-heading {
    align-items: flex-start;
  }

  .lock-note,
  .storage-note {
    margin-top: 2px;
  }

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

  .primary-actions {
    width: 100%;
  }

  .primary-actions .button {
    flex: 1 1 0;
  }

  .task-status-card {
    grid-template-columns: auto minmax(0, 1fr);
  }

  .task-status-card code,
  .task-status-card > span:last-child {
    grid-column: 2;
    text-align: left;
  }
}

@media (max-width: 520px) {
  .app-header {
    align-items: flex-start;
    flex-direction: column;
    gap: 12px;
  }

  .header-actions {
    width: 100%;
  }

  .api-docs-link,
  .community-link {
    flex: 1 1 auto;
  }

  .brand-icon {
    display: none;
  }

  .theme-toggle {
    width: 37px;
    padding: 8px;
  }

  .theme-toggle span {
    display: none;
  }

  .section-title-row {
    gap: 12px;
  }

  .status-overview-heading,
  .tasks-view-heading {
    flex-direction: column;
  }

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

  .success-rate-card {
    grid-column: 1 / -1;
  }

  .view-tabs {
    gap: 4px;
  }

  .view-tab {
    min-width: 0;
    flex: 1 1 0;
    padding-right: 10px;
    padding-left: 10px;
  }

  .section-title-row:not(.output-heading) {
    align-items: flex-start;
  }

  .token-section .section-title-row {
    flex-direction: column;
  }

  .token-section .section-title-row .button {
    align-self: flex-end;
    margin-top: -4px;
  }

  .token-check-actions {
    width: 100%;
  }

  .token-check-actions .button {
    flex: 1 1 auto;
    justify-content: center;
  }

  .account-batch-heading {
    align-items: flex-start;
    flex-direction: column;
  }

  .account-batch-heading-actions {
    align-items: flex-start;
    flex-direction: column;
  }

  .account-batch-heading-actions span {
    text-align: left;
  }

  .section-title-row.compact-heading {
    flex-direction: column;
  }

  .profile-divider {
    display: none;
  }

  .token-profile {
    align-items: flex-start;
    flex-direction: column;
  }

  .token-profile .profile-dot {
    position: absolute;
  }

  .token-profile > span:not(.profile-dot, .profile-divider) {
    padding-left: 13px;
  }

  .task-query-row {
    align-items: stretch;
    flex-direction: column;
  }

  .task-query-row .button {
    justify-content: center;
  }

  .task-list-item {
    grid-template-columns: minmax(0, 1fr) auto;
  }

  .task-list-details {
    grid-column: 1;
    grid-row: 2;
  }

  .method-choice {
    align-items: flex-start;
  }

  .method-choice-badge {
    display: none;
  }

  .history-task-row {
    grid-template-columns: minmax(0, 1fr);
  }

  .history-task-state,
  .history-task-result,
  .history-task-actions {
    grid-column: 1;
    grid-row: auto;
  }

  .history-task-actions {
    flex-direction: row;
  }

  .primary-actions {
    flex-direction: column;
  }

  .result-item {
    grid-template-columns: auto minmax(0, 1fr);
  }

  .result-qr,
  .result-details {
    grid-column: 2;
  }

  .result-qr {
    width: min(148px, 100%);
    height: auto;
    aspect-ratio: 1;
  }

  .result-actions {
    grid-column: 2;
  }

  .log-row {
    grid-template-columns: 1fr;
    gap: 0;
  }
}

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