* {
  box-sizing: border-box;
}

.alipay-order .qr-box,
.alipay-order [data-action="complete-alipay-order"] {
  display: none;
}

html {
  min-height: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  color: #1f2937;
  background:
    radial-gradient(circle at 12% 8%, rgba(255, 255, 255, .22), transparent 28%),
    linear-gradient(135deg, #6474e7 0%, #7b4bb5 100%);
  padding: 20px;
}

button,
input,
textarea,
select {
  font: inherit;
}

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

a {
  color: inherit;
}

.container {
  width: min(1640px, calc(100vw - 40px));
  margin: 0 auto;
}

.header,
.main-content,
.panel {
  background: rgba(255, 255, 255, .98);
  box-shadow: 0 8px 32px rgba(15, 23, 42, .13);
}

.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 20px 30px;
  border-radius: 16px;
  margin-bottom: 24px;
}

.logo {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  color: #111827;
  font-size: 24px;
  font-weight: 700;
  white-space: nowrap;
}

.logo-mark {
  width: 32px;
  height: 32px;
  display: block;
  border-radius: 8px;
}

.token-config {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
  flex-wrap: wrap;
}

.balance-info {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  color: #fff;
  background: linear-gradient(135deg, #10b981 0%, #2563eb 100%);
  border-radius: 999px;
  box-shadow: 0 4px 14px rgba(16, 185, 129, .24);
}

.balance-info strong {
  font-size: 18px;
}

.top-recharge-btn {
  min-height: 40px;
  padding: 0 16px;
  border-radius: 999px;
  box-shadow: 0 4px 14px rgba(22, 163, 74, .18);
}

.token-input {
  width: 300px;
  height: 42px;
  padding: 10px 14px;
  border: 2px solid #e5e7eb;
  border-radius: 8px;
  outline: none;
  transition: border-color .2s ease, box-shadow .2s ease;
}

.token-input:focus,
textarea:focus,
input[type="text"]:focus,
input[type="email"]:focus,
input[type="password"]:focus,
input[type="number"]:focus,
select:focus {
  border-color: #6366f1;
  box-shadow: 0 0 0 3px rgba(99, 102, 241, .12);
}

.btn {
  min-height: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 9px 18px;
  border: 1px solid transparent;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  line-height: 1;
  text-decoration: none;
  cursor: pointer;
  transition: transform .18s ease, box-shadow .18s ease, border-color .18s ease, background .18s ease, color .18s ease;
}

.btn:hover {
  transform: translateY(-1px);
}

.btn:disabled {
  opacity: .55;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.btn-primary {
  color: #fff;
  background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
  box-shadow: 0 4px 12px rgba(99, 102, 241, .26);
}

.btn-primary:hover {
  box-shadow: 0 7px 18px rgba(99, 102, 241, .34);
}

.btn-ghost {
  color: #4f46e5;
  background: #f8fafc;
  border-color: #e0e7ff;
}

.btn-ghost:hover {
  color: #3730a3;
  background: #eef2ff;
}

.btn-quiet {
  color: #64748b;
  background: #f8fafc;
  border-color: #e5e7eb;
}

.btn-quiet:hover {
  color: #dc2626;
  background: #fef2f2;
  border-color: #fecaca;
}

.btn-danger {
  color: #dc2626;
  background: #fff;
  border-color: #fecaca;
}

.btn-danger:hover {
  background: #fef2f2;
  border-color: #f87171;
}

.btn-success {
  color: #fff;
  background: linear-gradient(135deg, #10b981 0%, #059669 100%);
  box-shadow: 0 4px 12px rgba(16, 185, 129, .24);
}

.icon-btn {
  width: 36px;
  height: 36px;
  display: inline-grid;
  place-items: center;
  border: 0;
  border-radius: 50%;
  color: #64748b;
  background: transparent;
  font-size: 22px;
  cursor: pointer;
}

.icon-btn:hover {
  color: #111827;
  background: #eef2ff;
}

.tabs {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
  margin-bottom: 24px;
  padding: 8px;
  border: 1px solid rgba(226, 232, 240, .9);
  border-radius: 14px;
  background: rgba(248, 250, 252, .96);
  box-shadow: 0 10px 26px rgba(31, 41, 55, .1);
}

.tab {
  position: relative;
  min-height: 54px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 14px 18px;
  border: 1px solid #b9c4d3;
  border-radius: 10px;
  color: #334155;
  background: #e2e8f0;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  transition: background .2s ease, color .2s ease, box-shadow .2s ease, border-color .2s ease;
}

.tab:hover {
  color: #4338ca;
  border-color: #a5b4fc;
  background: #dbe4ff;
}

.tab.active {
  color: #312e81;
  border-color: #8b5cf6;
  background: linear-gradient(135deg, rgba(79, 70, 229, .4) 0%, rgba(124, 58, 237, .4) 100%);
  box-shadow: 0 8px 18px rgba(79, 70, 229, .18);
}

.tab.active::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: 5px;
  width: min(128px, 46%);
  height: 3px;
  border-radius: 999px;
  transform: translateX(-50%);
  background: #4f46e5;
}

.tab-symbol {
  width: 22px;
  height: 22px;
  display: inline-grid;
  place-items: center;
  border-radius: 7px;
  color: #fff;
  background: linear-gradient(135deg, #6366f1, #14b8a6);
  font-size: 13px;
  font-weight: 800;
}

.main-content,
.panel {
  border-radius: 16px;
}

.main-content {
  padding: 32px;
  margin-bottom: 24px;
}

.panel {
  padding: 24px;
  margin-bottom: 24px;
}

.tab-title {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: flex-start;
  margin-bottom: 18px;
}

.tab-title h2,
.panel h3 {
  margin: 0;
  color: #111827;
  font-size: 21px;
}

.tab-title p,
.muted {
  color: #64748b;
  font-size: 14px;
  line-height: 1.7;
}

.tab-title p {
  max-width: 760px;
  margin: 7px 0 0;
}

.mode-switch,
.prompt-mode-tabs,
.segmented {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

.mode-switch {
  padding-bottom: 12px;
  margin-bottom: 20px;
  border-bottom: 2px solid #e5e7eb;
}

.mode-btn,
.prompt-mode-tab,
.segment-btn {
  min-height: 42px;
  padding: 10px 20px;
  border: 2px solid #e5e7eb;
  border-radius: 8px;
  color: #64748b;
  background: #fff;
  font-weight: 700;
  cursor: pointer;
  transition: background .2s ease, color .2s ease, border-color .2s ease, box-shadow .2s ease;
}

.mode-btn:hover,
.prompt-mode-tab:hover,
.segment-btn:hover {
  color: #4f46e5;
  border-color: #a5b4fc;
  background: #f8faff;
}

.mode-btn.active,
.prompt-mode-tab.active,
.segment-btn.active {
  color: #fff;
  border-color: transparent;
  background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
  box-shadow: 0 4px 12px rgba(99, 102, 241, .24);
}

.workspace {
  max-width: 980px;
  margin: 0 auto;
}

.wide-workspace {
  max-width: 1160px;
}

.form-group {
  margin-bottom: 20px;
}

.form-group label,
.field-label {
  display: block;
  margin-bottom: 8px;
  color: #374151;
  font-size: 14px;
  font-weight: 700;
}

textarea,
input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
select {
  width: 100%;
  border: 2px solid #e5e7eb;
  border-radius: 8px;
  color: #1f2937;
  background: #fff;
  outline: none;
  transition: border-color .2s ease, box-shadow .2s ease, background .2s ease;
}

textarea {
  min-height: 132px;
  padding: 13px 16px;
  resize: vertical;
  line-height: 1.7;
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
select {
  min-height: 42px;
  padding: 9px 12px;
}

.user-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 40px;
  padding: 8px 14px;
  border: 1px solid #e0e7ff;
  border-radius: 999px;
  color: #312e81;
  background: #eef2ff;
  font-size: 14px;
  font-weight: 700;
}

select {
  cursor: pointer;
  appearance: none;
  padding-right: 36px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 16 16' fill='none'%3E%3Cpath d='M4 6l4 4 4-4' stroke='%236366f1' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
}

.prompt-hint {
  margin-top: 8px;
  color: #64748b;
  font-size: 12px;
  line-height: 1.6;
}

.form-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 18px;
  align-items: end;
}

.option-row {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) minmax(220px, 1.1fr) minmax(140px, .7fr) minmax(140px, .7fr);
  gap: 16px;
  align-items: end;
  margin: 18px 0;
}

.generate-action {
  margin-top: 34px;
}

.generate-submit {
  width: 100%;
  min-height: 70px;
  border-radius: 12px;
  font-size: 20px;
  font-weight: 800;
  box-shadow: 0 10px 24px rgba(99, 102, 241, .24);
}

.generate-submit:hover {
  box-shadow: 0 14px 30px rgba(99, 102, 241, .3);
}

.generate-price {
  margin-top: 12px;
  text-align: center;
  color: var(--muted);
  font-size: 14px;
}

.generate-price strong {
  color: var(--text);
  font-weight: 800;
}

.generate-submit.is-loading {
  opacity: 1;
  cursor: progress;
  transform: none;
  background: linear-gradient(135deg, #4f46e5 0%, #7c3aed 100%);
  box-shadow: 0 10px 24px rgba(79, 70, 229, .28);
}

.generate-submit.is-loading::before {
  content: "";
  width: 20px;
  height: 20px;
  border: 3px solid rgba(255, 255, 255, .45);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin .8s linear infinite;
}

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

.generate-submit.is-submitting {
  opacity: .92;
  cursor: wait;
  transform: none;
}

.number-input-group {
  width: max-content;
  display: inline-flex;
  overflow: hidden;
  border: 1px solid #dadce0;
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 1px 2px rgba(15, 23, 42, .06);
}

.number-input-group button {
  width: 38px;
  height: 40px;
  border: 0;
  color: #4f46e5;
  background: #f8fafc;
  font-size: 18px;
  cursor: pointer;
}

.number-input-group button:hover {
  color: #312e81;
  background: #eef2ff;
}

.number-input-group input {
  width: 58px;
  min-height: 40px;
  padding: 0 4px;
  border: 0;
  border-left: 1px solid #e5e7eb;
  border-right: 1px solid #e5e7eb;
  border-radius: 0;
  text-align: center;
  font-weight: 800;
  box-shadow: none;
}

.prompt-section {
  margin-top: 14px;
}

.section-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
  padding: 12px 16px;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  color: #1f2937;
  background: #f8fafc;
  font-weight: 800;
  cursor: pointer;
  transition: background .2s ease, border-color .2s ease;
}

.section-title:hover {
  border-color: #c7d2fe;
  background: #f1f5f9;
}

.collapse-icon {
  color: #64748b;
  font-size: 12px;
  transition: transform .2s ease;
}

.section-title[aria-expanded="true"] .collapse-icon {
  transform: rotate(180deg);
}

.chip-wrap {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  padding: 12px 0 4px;
}

.chip {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  padding: 7px 14px;
  border: 1px solid #dadce0;
  border-radius: 999px;
  color: #4b5563;
  background: #fff;
  font-size: 13px;
  cursor: pointer;
  transition: transform .18s ease, color .18s ease, border-color .18s ease, background .18s ease, box-shadow .18s ease;
}

.chip:hover {
  color: #4f46e5;
  border-color: #818cf8;
  background: #f0f4ff;
  transform: translateY(-1px);
  box-shadow: 0 2px 8px rgba(99, 102, 241, .14);
}

.prompt-card {
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  background: #fff;
  margin-bottom: 14px;
  overflow: hidden;
}

.prompt-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 13px 16px;
  background: #f8fafc;
  border-bottom: 1px solid #e5e7eb;
}

.prompt-card-header strong {
  color: #111827;
}

.prompt-card-body {
  padding: 16px;
}

.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin: 16px 0;
}

.tip-box,
.batch-box {
  margin: 14px 0;
  padding: 12px 14px;
  border-left: 4px solid #6366f1;
  border-radius: 8px;
  color: #475569;
  background: #f8fbff;
  font-size: 13px;
  line-height: 1.7;
}

.upload-area {
  min-height: 164px;
  display: grid;
  place-items: center;
  padding: 28px;
  border: 2px dashed #cbd5e1;
  border-radius: 12px;
  color: #64748b;
  background: #f8fafc;
  text-align: center;
  cursor: pointer;
  transition: background .2s ease, border-color .2s ease, color .2s ease;
}

.upload-area:hover,
.upload-area.dragover {
  color: #4f46e5;
  border-color: #818cf8;
  background: #f0f4ff;
}

.upload-area strong {
  display: block;
  margin-bottom: 7px;
  color: #334155;
  font-size: 16px;
}

.upload-summary {
  display: grid;
  justify-items: center;
  gap: 6px;
}

.upload-icon {
  width: 58px;
  height: 58px;
  display: grid;
  place-items: center;
  border: 4px solid #111827;
  background: #dbeafe;
  color: #2563eb;
  font-weight: 900;
  font-size: 24px;
  box-shadow: inset 0 0 0 4px #f8fafc;
}

.file-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.file-pill {
  max-width: 260px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  padding: 6px 10px;
  border: 1px solid #e0e7ff;
  border-radius: 999px;
  color: #4338ca;
  background: #eef2ff;
  font-size: 12px;
}

.upload-preview-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 14px;
}

.upload-thumb-card {
  width: 118px;
  display: grid;
  gap: 8px;
  align-content: start;
}

.upload-thumb {
  position: relative;
  width: 98px;
  height: 98px;
  overflow: hidden;
  border: 1px solid #dbe3ef;
  border-radius: 8px;
  background: #f8fafc;
}

.upload-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.upload-thumb small {
  position: absolute;
  right: 4px;
  bottom: 4px;
  padding: 2px 5px;
  border-radius: 4px;
  color: #fff;
  background: rgba(15, 23, 42, .72);
  font-size: 11px;
}

.upload-thumb-name {
  max-width: 112px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: #334155;
  font-size: 12px;
}

.upload-compressed {
  max-width: 112px;
  color: #059669;
  font-size: 11px;
  line-height: 1.35;
}

.retention-note {
  margin-top: 8px;
  color: #64748b;
  font-size: 13px;
}

.upload-config-tabs {
  margin: 10px 0 16px;
}

.per-image-editor {
  display: grid;
  gap: 12px;
  margin-bottom: 18px;
}

.per-image-card {
  overflow: hidden;
  border: 1px solid #dbe3ef;
  border-radius: 8px;
  background: #fff;
}

.per-image-head {
  display: grid;
  grid-template-columns: 54px 1fr auto;
  gap: 12px;
  align-items: center;
  padding: 12px;
  background: #f8fafc;
  border-bottom: 1px solid #e5edf6;
}

.per-image-head strong {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: #1e293b;
  font-size: 14px;
}

.per-image-head span,
.per-image-head em {
  color: #64748b;
  font-size: 12px;
  font-style: normal;
}

.per-image-thumb {
  width: 44px;
  height: 44px;
  overflow: hidden;
  border-radius: 6px;
  background: #e2e8f0;
}

.per-image-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.per-image-card textarea {
  min-height: 66px;
  border: 0;
  border-bottom: 1px solid #e5edf6;
  border-radius: 0;
  resize: vertical;
}

.per-image-prompt-groups {
  padding: 0 12px 12px;
}

.per-image-prompt-groups .prompt-section:first-child {
  margin-top: 12px;
}

.prompt-warning {
  margin: 0;
  padding: 10px 12px;
  color: #64748b;
  font-size: 12px;
  line-height: 1.5;
  background: #fbfdff;
}

.batch-table-wrap,
.history-table-wrap {
  overflow: auto;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  background: #fff;
}

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

th,
td {
  padding: 12px 14px;
  border-bottom: 1px solid #eef2f7;
  text-align: left;
  vertical-align: top;
  font-size: 13px;
}

th {
  color: #475569;
  background: #f8fafc;
  font-weight: 800;
}

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

.text-clip {
  max-width: 360px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.error-text {
  display: block;
  margin-top: 4px;
  color: #dc2626;
  font-size: 12px;
  white-space: normal;
}

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

.result-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 16px;
}

.result-card,
.task-card {
  overflow: hidden;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 1px 3px rgba(15, 23, 42, .08);
}

.result-thumb {
  position: relative;
  width: 100%;
  aspect-ratio: 1 / 1;
  overflow: hidden;
  background: #e5e7eb;
}

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

.result-check {
  position: absolute;
  top: 8px;
  left: 8px;
  width: 26px;
  height: 26px;
  display: grid;
  place-items: center;
  border-radius: 6px;
  background: rgba(255, 255, 255, .92);
  box-shadow: 0 1px 4px rgba(15, 23, 42, .14);
}

.result-info {
  padding: 12px;
}

.result-info h4 {
  margin: 0 0 8px;
  color: #111827;
  font-size: 14px;
}

.result-info p {
  height: 38px;
  margin: 0;
  overflow: hidden;
  color: #64748b;
  font-size: 12px;
  line-height: 1.55;
}

.card-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  padding: 0 12px 12px;
}

.mini-btn {
  min-height: 32px;
  padding: 7px 9px;
  border: 1px solid #dbe4ff;
  border-radius: 6px;
  color: #4f46e5;
  background: #fff;
  font-size: 12px;
  font-weight: 700;
  text-decoration: none;
  text-align: center;
  cursor: pointer;
}

.mini-btn:hover {
  background: #eef2ff;
}

.mini-note {
  min-height: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 7px 9px;
  border-radius: 6px;
  color: #64748b;
  background: #f8fafc;
  font-size: 12px;
  font-weight: 700;
}

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

.task-card {
  padding: 14px;
}

.task-submit-note {
  margin-bottom: 12px;
  padding: 10px 12px;
  border: 1px solid #dbeafe;
  border-radius: 8px;
  color: #1d4ed8;
  background: #eff6ff;
  font-size: 14px;
  font-weight: 700;
}

.task-top {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.task-id {
  color: #64748b;
  font-size: 12px;
}

.status {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 4px 9px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 800;
}

.task-meta-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
  color: #64748b;
  font-size: 13px;
}

.task-queue-text {
  flex: 1;
}

.task-progress-text {
  flex-shrink: 0;
  color: #0f172a;
  font-weight: 800;
}

.status.processing {
  color: #1d4ed8;
  background: #dbeafe;
}

.status.completed {
  color: #047857;
  background: #d1fae5;
}

.status.failed {
  color: #b91c1c;
  background: #fee2e2;
}

.progress-bar {
  width: 100%;
  height: 8px;
  overflow: hidden;
  border-radius: 999px;
  background: #e5e7eb;
}

.progress-fill {
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #6366f1 0%, #14b8a6 100%);
  transition: width .25s ease;
}

.history-controls {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

.filters {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.filters .field {
  width: 160px;
}

.history-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.empty-state {
  display: grid;
  place-items: center;
  min-height: 138px;
  padding: 24px;
  border: 1px dashed #cbd5e1;
  border-radius: 8px;
  color: #64748b;
  background: #f8fafc;
  text-align: center;
}

.empty-state strong {
  display: block;
  margin-bottom: 6px;
  color: #334155;
}

.stats {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.stat {
  min-width: 104px;
  padding: 10px 12px;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  background: #fff;
}

.stat span {
  display: block;
  color: #64748b;
  font-size: 12px;
}

.stat strong {
  display: block;
  margin-top: 3px;
  color: #111827;
  font-size: 18px;
}

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

.modal {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.modal-overlay {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, .62);
}

.modal-content {
  position: relative;
  z-index: 1;
  width: min(860px, 96vw);
  max-height: 90vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  border-radius: 12px;
  background: #fff;
  box-shadow: 0 24px 70px rgba(15, 23, 42, .35);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  padding: 16px 20px;
  border-bottom: 1px solid #e5e7eb;
  background: #f8fafc;
}

.modal-header h2 {
  margin: 0;
  font-size: 18px;
}

.modal-body {
  overflow: auto;
  padding: 22px;
  line-height: 1.8;
}

.auth-content {
  width: min(460px, 96vw);
}

.auth-tabs {
  margin-bottom: 20px;
}

.auth-form .form-group {
  margin-bottom: 16px;
}

.auth-form input {
  width: 100%;
}

.code-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 128px;
  gap: 10px;
  align-items: center;
}

.code-row .btn {
  width: 100%;
  white-space: nowrap;
}

.auth-submit {
  width: 100%;
  margin-top: 4px;
}

.account-content {
  width: min(920px, 96vw);
}

.account-layout {
  display: grid;
  grid-template-columns: 190px minmax(0, 1fr);
  gap: 20px;
  min-height: 420px;
}

.account-menu {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 8px;
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  background: #f8fafc;
}

.account-menu-btn {
  min-height: 42px;
  padding: 10px 12px;
  border: 1px solid transparent;
  border-radius: 8px;
  color: #475569;
  background: transparent;
  text-align: left;
  font-weight: 700;
  cursor: pointer;
}

.account-menu-btn:hover {
  color: #4f46e5;
  background: #eef2ff;
}

.account-menu-btn.active {
  color: #312e81;
  border-color: #c7d2fe;
  background: #eef2ff;
}

.account-panel {
  min-width: 0;
  padding: 4px 0;
}

.account-card {
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  background: #fff;
  overflow: hidden;
}

.account-card-header {
  padding: 16px 18px;
  border-bottom: 1px solid #e5e7eb;
  background: #f8fafc;
}

.account-card-header h3 {
  margin: 0;
  color: #111827;
  font-size: 18px;
}

.account-card-header p {
  margin: 6px 0 0;
  color: #64748b;
  font-size: 13px;
}

.account-card-body {
  padding: 18px;
}

.profile-list {
  display: grid;
  gap: 12px;
}

.profile-row {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 0;
  border-bottom: 1px solid #eef2f7;
}

.profile-row:last-child {
  border-bottom: 0;
}

.profile-row span {
  color: #64748b;
}

.profile-row strong {
  color: #111827;
}

.wallet-hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(220px, 300px);
  gap: 18px;
  align-items: stretch;
}

.alipay-panel {
  display: grid;
  gap: 14px;
}

.alipay-badge {
  display: inline-flex;
  align-items: center;
  width: max-content;
  min-height: 30px;
  padding: 5px 10px;
  border-radius: 999px;
  color: #0b66ff;
  background: #eaf2ff;
  font-size: 13px;
  font-weight: 800;
}

.alipay-order {
  display: grid;
  gap: 12px;
  padding: 14px;
  border: 1px solid #dbeafe;
  border-radius: 10px;
  background: #f8fbff;
}

.qr-box {
  display: grid;
  place-items: center;
  width: 148px;
  height: 148px;
  border: 1px solid #bfdbfe;
  border-radius: 8px;
  background:
    linear-gradient(90deg, #1d4ed8 10px, transparent 10px) 0 0 / 24px 24px,
    linear-gradient(#1d4ed8 10px, transparent 10px) 0 0 / 24px 24px,
    #fff;
  color: #0f172a;
  text-align: center;
  font-size: 12px;
  font-weight: 800;
}

.wallet-balance-card {
  padding: 22px;
  border-radius: 10px;
  color: #fff;
  background: linear-gradient(135deg, #6366f1 0%, #14b8a6 100%);
  box-shadow: 0 12px 28px rgba(79, 70, 229, .22);
}

.wallet-balance-card span {
  display: block;
  opacity: .88;
}

.wallet-balance-card strong {
  display: block;
  margin-top: 10px;
  font-size: 34px;
  line-height: 1;
}

.recharge-presets {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-bottom: 12px;
}

.preset-btn {
  min-height: 38px;
  border: 1px solid #dbe4ff;
  border-radius: 8px;
  color: #4f46e5;
  background: #fff;
  font-weight: 800;
  cursor: pointer;
}

.preset-btn:hover {
  background: #eef2ff;
}

.help-content h1 {
  margin: 0 0 14px;
}

.help-content h3 {
  margin-top: 22px;
}

.preview-content {
  width: min(980px, 96vw);
}

.preview-stage {
  min-height: 420px;
  display: grid;
  place-items: center;
  padding: 18px;
  background: #111827;
}

.preview-stage img {
  max-width: 100%;
  max-height: 70vh;
  border-radius: 8px;
  object-fit: contain;
}

.modal-footer {
  display: flex;
  justify-content: center;
  padding: 16px 20px;
  border-top: 1px solid #e5e7eb;
  background: #f8fafc;
}

.site-footer {
  display: flex;
  justify-content: center;
  padding: 22px 12px 6px;
  color: rgba(255, 255, 255, .84);
  font-size: 13px;
}

.site-footer a {
  text-decoration: none;
}

.site-footer a:hover,
.site-footer a:focus-visible {
  color: #fff;
  text-decoration: underline;
}

.toast-region {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 80;
  display: grid;
  gap: 10px;
}

.toast {
  width: min(360px, calc(100vw - 40px));
  padding: 12px 14px;
  border-radius: 8px;
  color: #fff;
  background: #111827;
  box-shadow: 0 12px 32px rgba(15, 23, 42, .28);
  font-size: 14px;
}

.toast.success {
  background: #047857;
}

.toast.error {
  background: #b91c1c;
}

.toast.info {
  background: #1d4ed8;
}

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

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

  .token-config {
    width: 100%;
    justify-content: flex-start;
  }

  .token-input {
    width: min(420px, 100%);
    flex: 1 1 240px;
  }

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

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

@media (max-width: 760px) {
  .account-layout,
  .wallet-hero {
    grid-template-columns: 1fr;
  }

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

  .account-menu {
    flex-direction: row;
    overflow: auto;
  }

  .account-menu-btn {
    white-space: nowrap;
  }
}

@media (max-width: 640px) {
  body {
    padding: 12px;
  }

  .container {
    width: 100%;
  }

  .header,
  .main-content,
  .panel {
    border-radius: 12px;
  }

  .header,
  .main-content,
  .panel {
    padding: 18px;
  }

  .logo {
    font-size: 20px;
  }

  .tabs,
  .option-row,
  .form-row {
    grid-template-columns: 1fr;
  }

  .tab-title {
    flex-direction: column;
  }

  .btn,
  .mode-btn,
  .prompt-mode-tab,
  .segment-btn {
    width: 100%;
  }

  .toolbar,
  .history-header,
  .results-header {
    align-items: stretch;
    flex-direction: column;
  }

  .filters .field,
  .history-actions,
  .history-actions .btn {
    width: 100%;
  }
}
