*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --bg: #d4dde5;
  --card: #ffffff;
  --text: #1a1a1a;
  --text-muted: #888888;
  --primary: #6226c2;
  --primary-dark: #4e1a9e;
  --primary-light: #f3ecff;
  --primary-border: #6226c2;
  --border: #e8e8ec;
  --border-light: #f0f0f3;
  --status-bg: #fafafa;
  --radius: 14px;
  --radius-sm: 10px;
  --shadow: 0 2px 12px rgba(0, 0, 0, 0.06);
  --max-width: 720px;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  min-height: 100vh;
}

.page {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 20px 16px 48px;
}

/* ── Topbar ── */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 28px;
}

.topbar-logo {
  width: 56px;
  height: 56px;
  object-fit: contain;
  border-radius: 14px;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.topbar-actions[hidden],
.topbar-admin[hidden],
[hidden] {
  display: none !important;
}

.btn-outline {
  padding: 7px 18px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--card);
  color: var(--text);
  font-size: 0.875rem;
  cursor: pointer;
  transition: border-color 0.15s;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
}

.topbar-username {
  font-size: 0.875rem;
  color: var(--text-muted);
  margin-right: 4px;
}

.btn-outline:disabled {
  opacity: 0.7;
  cursor: default;
}

.btn-recharge {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  border: none;
  border-radius: 999px;
  background: var(--primary);
  color: #fff;
  font-size: 0.8125rem;
  cursor: pointer;
  transition: background 0.15s;
}

.btn-recharge:disabled {
  opacity: 0.85;
  cursor: default;
}

.btn-recharge:not(:disabled):hover {
  filter: brightness(1.05);
}

.btn-recharge-text {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 6px;
  line-height: 1.2;
  white-space: nowrap;
}

.btn-recharge-text small {
  font-size: 0.8125rem;
  opacity: 0.95;
  font-weight: 600;
}

.icon-wallet {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
}

.icon-sparkle {
  width: 14px;
  height: 14px;
  opacity: 0.8;
}

/* ── Brand ── */
.brand {
  text-align: center;
  margin-bottom: 28px;
}

.brand-title {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-size: 1.75rem;
  font-weight: 700;
  margin-bottom: 10px;
}

.brand-title-text {
  background: linear-gradient(90deg, #6226c2, #3b5bdb);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  text-decoration: none;
}

a.brand-title-text:hover {
  opacity: 0.88;
}

.brand-slogan {
  font-size: 0.9375rem;
  letter-spacing: 0.15em;
}

.brand-domain {
  color: var(--text);
  font-weight: 500;
  text-decoration: none;
}

.brand-domain:hover {
  text-decoration: underline;
}

.brand-slogan-text {
  color: var(--text);
}

/* ── Card ── */
.card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px 22px;
  margin-bottom: 16px;
}

.section-label {
  font-size: 0.9375rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 14px;
}

.section-label-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.section-label-row .section-label {
  margin-bottom: 0;
}

.btn-inspiration {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: none;
  border-radius: 10px;
  padding: 7px 12px;
  background: var(--primary-light);
  color: var(--primary);
  font-size: 0.8125rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s ease, color 0.15s ease, opacity 0.15s ease;
}

.btn-inspiration:hover:not(:disabled) {
  background: #e8dcff;
  color: var(--primary-dark);
}

.btn-inspiration:disabled {
  opacity: 0.65;
  cursor: wait;
}

.btn-inspiration svg {
  flex-shrink: 0;
}

.section-label-mt {
  margin-top: 20px;
}

.panel[hidden] {
  display: none;
}

/* ── Type Tabs ── */
.type-card {
  padding: 18px 22px;
}

.type-tabs {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
}

.type-tab {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 10px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--card);
  color: var(--text);
  font-size: 0.9375rem;
  font-weight: 500;
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s, background 0.15s;
}

.type-tab svg {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
}

.type-tab:hover:not(.active) {
  border-color: #ccc;
}

.type-tab.active {
  border-color: var(--primary-border);
  color: var(--primary);
  background: var(--primary-light);
}

.type-tab.active svg {
  stroke: var(--primary);
}

/* ── Voice grid ── */
.voice-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px 10px;
}

.voice-grid-loading,
.voice-grid-empty {
  grid-column: 1 / -1;
  margin: 0;
  color: var(--muted);
  font-size: 0.875rem;
  text-align: center;
  padding: 12px 0;
}

.voice-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 0;
  border: none;
  background: transparent;
  cursor: pointer;
  color: inherit;
}

.voice-card-avatar {
  width: 100%;
  aspect-ratio: 1;
  border-radius: 50%;
  overflow: hidden;
  border: 2px solid transparent;
  background: #f3f0f8;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.voice-card-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
  /* Zoom past source-image white margins so the face fills the circle. */
  transform: scale(1.18);
  transform-origin: center;
  display: block;
}

.voice-card:hover .voice-card-avatar {
  border-color: #c4b5fd;
}

.voice-card.active .voice-card-avatar {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(124, 58, 237, 0.18);
}

.voice-card-name {
  font-size: 0.8125rem;
  font-weight: 500;
  text-align: center;
  line-height: 1.2;
}

.voice-card-custom {
  position: relative;
}

.voice-card-select {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 0;
  border: none;
  background: transparent;
  cursor: pointer;
  color: inherit;
  width: 100%;
}

.voice-card-custom .voice-card-avatar {
  border-radius: 50%;
  background: #ebe4f7;
}

.voice-card-custom .voice-card-avatar img {
  border-radius: 50%;
}

.voice-card-slot {
  cursor: pointer;
  border-radius: 12px;
  transition: transform 0.15s ease, background 0.15s ease;
}

.voice-card-slot:hover {
  transform: translateY(-2px);
}

.voice-card-slot:focus-visible {
  outline: 2px solid #7c3aed;
  outline-offset: 3px;
}

.voice-card-slot .voice-card-avatar {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: #ebe4f7;
  border: 2px dashed #c4b5fd;
  transition: border-color 0.15s ease, background 0.15s ease;
}

.voice-card-slot:hover .voice-card-avatar {
  background: #e2d8f7;
  border-color: #a78bfa;
}

.voice-card-slot-silhouette {
  width: 48%;
  height: 48%;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.88);
  position: relative;
}

.voice-card-slot-silhouette::before {
  content: "";
  position: absolute;
  left: 50%;
  top: 18%;
  width: 38%;
  height: 38%;
  transform: translateX(-50%);
  border-radius: 50%;
  background: #c4b5fd;
}

.voice-card-slot-silhouette::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: 6%;
  width: 70%;
  height: 42%;
  transform: translateX(-50%);
  border-radius: 50% 50% 40% 40%;
  background: #c4b5fd;
}

.voice-card-slot-btn {
  position: absolute;
  left: 50%;
  bottom: 8%;
  transform: translateX(-50%);
  border: none;
  border-radius: 999px;
  padding: 3px 7px;
  font-size: 0.5625rem;
  font-weight: 600;
  color: #fff;
  background: #7c3aed;
  pointer-events: none;
  white-space: nowrap;
  box-shadow: 0 4px 10px rgba(124, 58, 237, 0.28);
  transition: background 0.15s ease;
}

.voice-card-slot:hover .voice-card-slot-btn {
  background: #6d28d9;
}

.voice-card-delete {
  position: absolute;
  top: -4px;
  right: 8%;
  z-index: 2;
  width: 22px;
  height: 22px;
  border: none;
  border-radius: 50%;
  background: rgba(15, 23, 42, 0.72);
  color: #fff;
  font-size: 14px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.15s;
}

.voice-card-custom:hover .voice-card-delete,
.voice-card-custom:focus-within .voice-card-delete {
  opacity: 1;
}

.voice-clone-hint {
  margin-top: 10px;
}

.voice-clone-modal-card {
  max-width: 420px;
}

.voice-clone-modal-hint {
  margin: 0 0 14px;
  color: var(--muted);
  font-size: 0.875rem;
  line-height: 1.5;
}

.voice-clone-modal-card .field {
  margin-bottom: 12px;
}

.voice-clone-modal-card .field label {
  display: block;
  margin-bottom: 6px;
  font-size: 0.875rem;
  font-weight: 500;
}

.voice-clone-modal-card .field input[type="text"] {
  width: 100%;
  border: 1px solid var(--border, #e5e7eb);
  border-radius: 10px;
  padding: 10px 12px;
  font: inherit;
}

.voice-clone-avatar-row {
  display: flex;
  align-items: center;
  gap: 12px;
}

.voice-clone-avatar-btn {
  width: 56px;
  height: 56px;
  flex: 0 0 56px;
  border-radius: 50%;
  border: 2px dashed #c4b5fd;
  background: #ebe4f7;
  padding: 0;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease;
}

.voice-clone-avatar-btn:hover {
  background: #e2d8f7;
  border-color: #a78bfa;
}

.voice-clone-avatar-btn img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 50%;
}

.voice-clone-avatar-btn img[hidden] {
  display: none;
}

.voice-clone-avatar-plus {
  color: #7c3aed;
  font-size: 1.5rem;
  font-weight: 500;
  line-height: 1;
}

.voice-clone-avatar-meta {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.voice-clone-avatar-state {
  color: var(--muted);
  font-size: 0.8125rem;
}

.voice-clone-record {
  border: 1px solid var(--border, #e5e7eb);
  border-radius: 12px;
  padding: 12px;
  background: #faf8ff;
}

.voice-clone-record-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
}

.voice-clone-record-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #ef4444;
  box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.45);
  animation: voice-clone-pulse 1.2s ease-out infinite;
}

.voice-clone-record-dot[hidden] {
  display: none;
}

@keyframes voice-clone-pulse {
  0% {
    box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.45);
  }
  70% {
    box-shadow: 0 0 0 8px rgba(239, 68, 68, 0);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(239, 68, 68, 0);
  }
}

.voice-clone-timer {
  font-variant-numeric: tabular-nums;
  font-size: 1.05rem;
}

.voice-clone-record-state {
  color: var(--muted);
  font-size: 0.8125rem;
}

.voice-clone-record-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.voice-clone-playback {
  display: block;
  width: 100%;
  margin-top: 10px;
}

.voice-clone-playback[hidden] {
  display: none;
}

.field-hint {
  display: block;
  margin-top: 6px;
  color: var(--muted);
  font-size: 0.75rem;
  line-height: 1.4;
}

.voice-result-player {
  width: 100%;
  margin-top: 12px;
}

.work-thumb-voice {
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(145deg, #1f2937, #0f766e);
}

.work-thumb-voice img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 0;
}

.work-thumb-voice-fallback {
  color: #fff;
  font-size: 0.875rem;
  font-weight: 600;
}

/* ── Prompt ── */
.prompt-wrap {
  position: relative;
  margin-bottom: 14px;
}

.prompt-wrap textarea {
  width: 100%;
  padding: 14px 16px 32px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.9375rem;
  font-family: inherit;
  color: var(--text);
  background: var(--card);
  resize: vertical;
  min-height: 120px;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.prompt-wrap textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(98, 38, 194, 0.12);
}

#panel-text .prompt-wrap textarea:focus {
  border-color: var(--primary);
}

.char-count {
  position: absolute;
  right: 14px;
  bottom: 10px;
  font-size: 0.75rem;
  color: var(--text-muted);
  pointer-events: none;
}

/* ── Text Preview ── */
.text-preview-box {
  border: 1.5px solid var(--primary);
  border-radius: var(--radius-sm);
  min-height: 120px;
  padding: 24px 16px;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  justify-content: center;
  gap: 12px;
  margin-bottom: 20px;
}

.text-preview-box.has-result {
  justify-content: flex-start;
  padding: 16px;
  background: #fbfaff;
  max-height: 420px;
  overflow-y: auto;
}

.text-preview-placeholder {
  color: var(--primary);
  font-size: 1rem;
  letter-spacing: 0.05em;
  text-align: center;
}

.text-preview-box .text-block {
  width: 100%;
  text-align: left;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  background: var(--card);
  padding: 14px 16px;
  margin-bottom: 0;
}

/* ── Prompt Actions ── */
.prompt-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}

.btn-action {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--card);
  color: var(--text);
  font-size: 0.8125rem;
  cursor: pointer;
  transition: border-color 0.15s;
  white-space: nowrap;
}

.btn-action svg {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}

.btn-action:hover:not(:disabled) {
  border-color: var(--primary);
}

.btn-action:disabled {
  opacity: 0.6;
  cursor: default;
}

.ref-label {
  font-size: 0.9375rem;
  font-weight: 600;
  color: var(--text);
}

.ref-count {
  font-size: 0.8125rem;
  color: var(--text-muted);
  flex-shrink: 0;
}

/* ── Upload Preview ── */
.upload-preview-area {
  margin-bottom: 16px;
}

.upload-preview-area.dragover {
  border-color: var(--primary);
  background: var(--primary-light);
}

.upload-drop-zone {
  min-height: 112px;
  padding: 12px;
  border: 1.5px dashed #cfcfd6;
  border-radius: var(--radius-sm);
  background: #fafafa;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}

.upload-drop-zone:hover {
  border-color: var(--primary);
}

.upload-drop-placeholder {
  min-height: 86px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  color: var(--text-muted);
  text-align: center;
  pointer-events: none;
}

.upload-drop-placeholder svg {
  width: 24px;
  height: 24px;
  margin-bottom: 2px;
  color: var(--primary);
}

.upload-drop-placeholder span {
  font-size: 0.875rem;
}

.upload-drop-placeholder small {
  font-size: 0.75rem;
}

.upload-preview-area.has-image .upload-drop-placeholder,
.upload-preview-area.has-images .upload-drop-placeholder {
  display: none;
}

.upload-single-preview {
  position: relative;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: #fafafa;
}

.upload-preview-img {
  width: 100%;
  max-height: 200px;
  object-fit: contain;
  display: block;
}

.upload-replace-hint {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  padding: 8px 12px;
  font-size: 0.75rem;
  color: #fff;
  text-align: center;
  background: rgba(0, 0, 0, 0.55);
  opacity: 0;
  transition: opacity 0.15s;
  pointer-events: none;
}

.upload-single-preview:hover .upload-replace-hint,
.upload-preview-area.dragover .upload-replace-hint {
  opacity: 1;
}

.btn-clear-ref {
  margin-top: 8px;
  padding: 0;
  border: none;
  background: none;
  color: var(--primary);
  font-size: 0.8125rem;
  cursor: pointer;
}

.btn-clear-ref:hover {
  text-decoration: underline;
}

.upload-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
  gap: 10px;
}

.upload-grid-item {
  position: relative;
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  aspect-ratio: 1;
}

.upload-grid-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.upload-grid-remove {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 22px;
  height: 22px;
  border: none;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.65);
  color: #fff;
  font-size: 0.875rem;
  line-height: 1;
  cursor: pointer;
}

.upload-grid-remove:hover {
  background: rgba(185, 28, 28, 0.88);
}

/* ── Settings ── */
.settings-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 20px;
}

.setting-field label {
  display: block;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 8px;
}

.setting-field select {
  width: 100%;
  padding: 10px 32px 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.9375rem;
  font-family: inherit;
  color: var(--text);
  background: var(--card) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23888' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E") no-repeat right 12px center;
  appearance: none;
  cursor: pointer;
  transition: border-color 0.15s;
}

.setting-field select:focus {
  outline: none;
  border-color: var(--primary);
}

.setting-hint {
  display: block;
  margin-top: 4px;
  font-size: 0.75rem;
  color: var(--text-muted);
}

.video-model-field {
  margin-bottom: 20px;
}

.video-voice-field {
  margin: 16px 0 20px;
}

.video-real-meta {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin: -8px 0 16px;
}

.video-real-hint {
  margin: 0;
  flex: 1;
  min-width: 0;
}

.video-real-duration-est {
  flex-shrink: 0;
  margin-top: 1px;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--primary);
  white-space: nowrap;
}

.video-auto-duration {
  margin: -8px 0 16px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  background: color-mix(in srgb, var(--primary) 12%, transparent);
  color: var(--primary);
  font-size: 0.8125rem;
}

/* ── Generate Button ── */
.btn-generate {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 14px;
  border: none;
  border-radius: 999px;
  background: var(--primary);
  color: #fff;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
}

.btn-generate svg {
  width: 20px;
  height: 20px;
}

.btn-generate:hover:not(:disabled) {
  background: var(--primary-dark);
}

.btn-generate:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.cost-hint {
  text-align: center;
  font-size: 0.8125rem;
  color: var(--text-muted);
  margin-top: 10px;
  margin-bottom: 16px;
}

.gen-runner {
  margin: 0 0 12px;
}

.gen-runner-track {
  position: relative;
  height: 44px;
  border-radius: var(--radius-sm);
  background: linear-gradient(180deg, #eef2f6 0%, #e4ebf0 100%);
  overflow: hidden;
}

.gen-runner-person {
  position: absolute;
  top: 50%;
  left: 0;
  font-size: 1.75rem;
  line-height: 1;
  transform: translateY(-50%);
  animation: gen-runner-move 2.4s ease-in-out infinite;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.12));
}

@keyframes gen-runner-move {
  0% {
    left: 4%;
    transform: translateY(-50%) scaleX(-1);
  }
  48% {
    left: calc(100% - 2.2rem);
    transform: translateY(-50%) scaleX(-1);
  }
  52% {
    left: calc(100% - 2.2rem);
    transform: translateY(-50%) scaleX(1);
  }
  100% {
    left: 4%;
    transform: translateY(-50%) scaleX(1);
  }
}

#panel-image .progress-panel,
#panel-video .progress-panel {
  display: none !important;
}

.cost-free {
  color: var(--primary);
}

/* ── Status & Progress ── */
.status {
  background: var(--status-bg);
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  font-size: 0.875rem;
  color: var(--text-muted);
  min-height: 44px;
  display: flex;
  align-items: center;
}

.status.error {
  color: #b91c1c;
  background: #fef2f2;
}

.status.success {
  color: #166534;
  background: #f0fdf4;
}

button.is-loading,
.btn-primary.is-loading,
.btn-generate.is-loading {
  opacity: 0.75;
  cursor: wait;
  pointer-events: none;
}

button:disabled,
.btn-primary:disabled,
.btn-generate:disabled {
  opacity: 0.65;
  cursor: not-allowed;
}

.progress-panel {
  margin-top: 12px;
}

.progress-panel[hidden] {
  display: none;
}

.progress-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
  font-size: 0.8125rem;
  color: var(--text-muted);
}

.progress-wrap {
  height: 6px;
  background: var(--border);
  border-radius: 999px;
  overflow: hidden;
}

.progress-bar {
  height: 100%;
  width: 0%;
  background: var(--primary);
  border-radius: 999px;
  transition: width 0.35s ease;
}

.progress-bar.indeterminate {
  width: 40%;
  animation: indeterminate 1.4s ease-in-out infinite;
}

@keyframes indeterminate {
  0% { transform: translateX(-100%); }
  100% { transform: translateX(350%); }
}

/* ── Result ── */
.result {
  margin-top: 16px;
}

#text-result {
  display: none;
}

.result img,
.result video {
  width: 100%;
  border-radius: var(--radius-sm);
  display: block;
}

.result a {
  display: inline-block;
  margin-top: 10px;
  font-size: 0.875rem;
  color: var(--primary);
  text-decoration: none;
}

.result a:hover {
  text-decoration: underline;
}

.text-block {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  margin-bottom: 12px;
  background: #fafafa;
}

.text-block:last-child {
  margin-bottom: 0;
}

.text-block-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}

.text-block-label {
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--text-muted);
}

.text-block-copy {
  padding: 0;
  border: none;
  background: none;
  color: var(--primary);
  font-size: 0.8125rem;
  cursor: pointer;
}

.text-block-copy:hover {
  text-decoration: underline;
}

.text-block-body {
  font-size: 0.9375rem;
  line-height: 1.7;
  white-space: pre-wrap;
  word-break: break-word;
  color: var(--text);
  /* Prefer fonts with broader Unicode / emoji coverage across browsers */
  font-family:
    "Segoe UI Emoji", "Segoe UI Symbol", "Apple Color Emoji", "Noto Color Emoji",
    "Noto Sans Symbols 2", "Noto Sans Math", "Cambria Math",
    "PingFang SC", "Microsoft YaHei", "Segoe UI", sans-serif;
}

/* ── Recent Works ── */
.works-card {
  padding: 18px 22px 22px;
}

.page-footer {
  text-align: center;
  margin: 4px 0 16px;
}

.page-footer-brand {
  margin: 8px 0 20px;
}

.page-footer-text {
  font-size: 0.75rem;
  color: var(--text-muted);
  letter-spacing: 0.02em;
}

.btn-symbols {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 24px;
  border: 1.5px solid var(--primary);
  border-radius: 999px;
  background: var(--card);
  color: var(--primary);
  font-size: 0.875rem;
  text-decoration: none;
  transition: background 0.15s;
}

.btn-symbols:hover {
  background: var(--primary-light);
}

.works-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}

.works-header .section-label {
  margin-bottom: 0;
}

.works-nav {
  display: flex;
  gap: 4px;
}

.works-arrow {
  width: 32px;
  height: 32px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--card);
  color: var(--text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: border-color 0.15s, color 0.15s;
}

.works-arrow svg {
  width: 18px;
  height: 18px;
}

.works-arrow:hover:not(:disabled) {
  border-color: var(--primary);
  color: var(--primary);
}

.works-arrow:disabled {
  opacity: 0.35;
  cursor: default;
}

.works-track-wrap {
  overflow: hidden;
}

.works-track {
  display: flex;
  gap: 12px;
  transition: transform 0.3s ease;
}

.works-empty {
  width: 100%;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.875rem;
  padding: 32px 0;
}

.work-item {
  flex: 0 0 calc(33.333% - 8px);
  min-width: 0;
}

.work-thumb {
  position: relative;
  border-radius: var(--radius-sm);
  overflow: hidden;
  aspect-ratio: 1;
  background: var(--border-light);
  box-shadow: 0 4px 14px rgba(26, 32, 44, 0.08);
}

.work-thumb img,
.work-thumb video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.work-thumb-preview {
  cursor: zoom-in;
}

.work-thumb-preview:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

.work-badge {
  position: absolute;
  top: 8px;
  right: 8px;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 0.6875rem;
  font-weight: 600;
  color: #fff;
  letter-spacing: 0.02em;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.18);
}

.work-badge.image {
  background: #e53e3e;
}

.work-badge.video {
  background: var(--primary);
}

.work-badge.voice {
  background: #0f766e;
}

.work-badge.generating {
  background: #d97706;
}

.work-badge.deleting {
  background: #dc2626;
}

.work-badge.busy {
  background: #4f46e5;
}

.work-thumb.is-generating img,
.work-thumb.is-busy img,
.work-thumb.is-busy video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.work-item.is-busy {
  pointer-events: none;
}

.work-thumb.is-busy .work-thumb-overlay {
  background: rgba(26, 26, 26, 0.62);
}

.work-busy-spinner {
  width: 22px;
  height: 22px;
  border: 2px solid rgba(255, 255, 255, 0.35);
  border-top-color: #fff;
  border-radius: 50%;
  animation: ui-spin 0.75s linear infinite;
}

.work-thumb-overlay .ui-spinner {
  color: #fff;
  border-color: rgba(255, 255, 255, 0.35);
  border-right-color: transparent;
}

.voice-clone-record-state.is-loading {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

@keyframes work-spin {
  to {
    transform: rotate(360deg);
  }
}

.work-thumb-placeholder {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  font-size: 0.875rem;
  background: #e8ecf0;
}

.work-thumb-overlay {
  position: absolute;
  inset: 0;
  background: rgba(26, 26, 26, 0.52);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px;
}

.work-progress-label {
  color: #fff;
  font-size: 0.75rem;
  font-weight: 500;
  text-align: center;
  line-height: 1.35;
}

.work-progress-percent {
  color: rgba(255, 255, 255, 0.92);
  font-size: 0.8125rem;
  font-weight: 600;
}

.work-gen-bar {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 4px;
  background: rgba(255, 255, 255, 0.25);
}

.work-gen-fill {
  height: 100%;
  background: var(--primary);
  transition: width 0.35s ease;
}

.work-meta {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
  margin-top: 10px;
  font-size: 0.75rem;
  color: var(--text-muted);
}

.work-meta-text {
  flex: 1;
  min-width: 0;
}

.work-prompt {
  margin: 0 0 4px;
  font-size: 0.8125rem;
  line-height: 1.35;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.work-time {
  display: block;
  font-size: 0.75rem;
  color: var(--text-muted);
}

.work-meta-actions {
  display: flex;
  gap: 6px;
  align-items: center;
}

.work-actions {
  position: relative;
}

.work-actions-trigger {
  width: 30px;
  height: 30px;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: #fff;
  color: #6b7280;
  font-size: 1.05rem;
  line-height: 1;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: border-color 0.15s, color 0.15s, background 0.15s, box-shadow 0.15s;
}

.work-actions-trigger:hover,
.work-actions-trigger[aria-expanded="true"] {
  border-color: var(--primary);
  color: var(--primary);
  background: var(--primary-light);
  box-shadow: 0 2px 8px rgba(98, 38, 194, 0.12);
}

.work-actions-menu {
  position: absolute;
  right: 0;
  bottom: calc(100% + 10px);
  display: none;
  min-width: 124px;
  padding: 8px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 14px;
  background: linear-gradient(180deg, #2a2433 0%, #1c1722 100%);
  box-shadow: 0 12px 28px rgba(18, 12, 28, 0.35);
  z-index: 30;
}

.work-actions-menu.open {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.work-actions-menu button {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid transparent;
  border-radius: 10px;
  background: transparent;
  color: rgba(255, 255, 255, 0.92);
  font-size: 0.8125rem;
  font-weight: 500;
  text-align: center;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, transform 0.12s;
}

.work-actions-menu button:hover {
  transform: translateY(-1px);
}

.work-action-edit {
  background: rgba(59, 130, 246, 0.16) !important;
  border-color: rgba(96, 165, 250, 0.55) !important;
}

.work-action-edit:hover {
  background: rgba(59, 130, 246, 0.28) !important;
}

.work-action-regen {
  background: rgba(98, 38, 194, 0.22) !important;
  border-color: rgba(167, 139, 250, 0.55) !important;
}

.work-action-regen:hover {
  background: rgba(98, 38, 194, 0.34) !important;
}

.work-action-delete {
  background: rgba(185, 28, 28, 0.18) !important;
  border-color: rgba(248, 113, 113, 0.5) !important;
  color: #fecaca !important;
}

.work-action-delete:hover {
  background: rgba(185, 28, 28, 0.3) !important;
}

.work-meta-actions a,
.work-meta-actions > button:not(.work-actions-trigger) {
  width: 30px;
  height: 30px;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: #fff;
  color: #6b7280;
  cursor: pointer;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: border-color 0.15s, color 0.15s, background 0.15s;
}

.work-meta-actions svg {
  width: 15px;
  height: 15px;
}

.work-meta-actions a:hover,
.work-meta-actions > button:not(.work-actions-trigger):hover {
  border-color: var(--primary);
  color: var(--primary);
  background: var(--primary-light);
}

/* ── Responsive ── */
@media (max-width: 640px) {
  .page {
    padding: 14px 12px 36px;
  }

  .topbar-logo {
    width: 44px;
    height: 44px;
  }

  .btn-outline {
    padding: 6px 12px;
    font-size: 0.8125rem;
  }

  .btn-recharge {
    padding: 6px 12px;
  }

  .btn-recharge-text span {
    font-size: 0.75rem;
  }

  .brand-title {
    font-size: 1.375rem;
  }

  .brand-slogan {
    font-size: 0.8125rem;
    letter-spacing: 0.08em;
  }

  .card {
    padding: 16px;
  }

  .type-tab {
    padding: 10px 6px;
    font-size: 0.8125rem;
    gap: 4px;
  }

  .type-tab svg {
    width: 18px;
    height: 18px;
  }

  .voice-grid {
    grid-template-columns: repeat(4, 1fr);
  }

  .prompt-actions {
    flex-direction: column;
    align-items: stretch;
  }

  .btn-action {
    justify-content: center;
    white-space: normal;
    text-align: center;
  }

  .ref-label,
  .ref-count {
    text-align: center;
  }

  .settings-row {
    grid-template-columns: 1fr;
    gap: 12px;
  }

  .work-item {
    flex: 0 0 calc(50% - 6px);
  }
}

@media (min-width: 641px) and (max-width: 1024px) {
  .page {
    padding: 24px 20px 40px;
  }
}

/* Recharge modal */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(20, 16, 40, 0.48);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  z-index: 1000;
  overflow-y: auto;
}

.modal-overlay[hidden] {
  display: none;
}

.modal-card {
  width: 100%;
  max-width: 440px;
  margin: auto;
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: 0 16px 48px rgba(40, 20, 80, 0.18);
  padding: 22px 22px 20px;
}

.recharge-modal-card {
  max-width: 420px;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 18px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border-light);
}

.modal-header h3 {
  margin: 0;
  font-size: 1.0625rem;
  font-weight: 650;
  flex: 1;
  min-width: 0;
}

.modal-header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.btn-get-usdt,
.btn-contact-service {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 6px 12px;
  border: 1.5px solid var(--primary);
  border-radius: 10px;
  background: var(--primary);
  color: #fff;
  font-size: 0.8125rem;
  font-weight: 600;
  line-height: 1.2;
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease;
}

.btn-get-usdt:hover,
.btn-contact-service:hover {
  background: var(--primary-dark);
  border-color: var(--primary-dark);
  color: #fff;
}

.modal-close {
  border: none;
  background: none;
  width: 32px;
  height: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
  font-size: 1.375rem;
  line-height: 1;
  color: var(--text-muted);
  cursor: pointer;
}

.modal-close:hover {
  color: var(--text);
  background: var(--bg);
}

.confirm-modal-card {
  max-width: 360px;
}

.confirm-modal-message {
  margin: 0 0 4px;
  font-size: 0.9375rem;
  color: var(--text);
  line-height: 1.55;
}

.work-preview-modal-card {
  max-width: min(920px, 96vw);
  padding-bottom: 18px;
}

.work-preview-media {
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: #0f1419;
  max-height: min(72vh, 720px);
  display: flex;
  align-items: center;
  justify-content: center;
}

.work-preview-media img,
.work-preview-media video {
  max-width: 100%;
  max-height: min(72vh, 720px);
  width: auto;
  height: auto;
  display: block;
}

.work-preview-media audio {
  width: min(100%, 420px);
  margin: 24px 16px;
}

.work-preview-actions {
  display: flex;
  justify-content: center;
  margin-top: 16px;
}

.work-preview-download {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  text-decoration: none;
}

.work-preview-download svg {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

.confirm-modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid var(--border-light);
}

.btn-confirm-danger {
  padding: 7px 18px;
  border: none;
  border-radius: 999px;
  background: #dc2626;
  color: #fff;
  font-size: 0.875rem;
  cursor: pointer;
  transition: background 0.15s;
}

.btn-confirm-danger:hover {
  background: #b91c1c;
}

.btn-confirm-danger:disabled {
  opacity: 0.7;
  cursor: default;
}

.recharge-hint {
  font-size: 0.875rem;
  color: #666;
  line-height: 1.55;
  margin: 0 0 14px;
}

.recharge-packages {
  display: grid;
  gap: 10px;
}

.recharge-package-btn {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: #fafafb;
  cursor: pointer;
  text-align: left;
  transition: border-color 0.15s, background 0.15s, box-shadow 0.15s;
}

.recharge-package-btn:hover {
  border-color: var(--primary);
  background: var(--primary-light);
  box-shadow: 0 0 0 3px rgba(98, 38, 194, 0.08);
}

.recharge-package-btn strong {
  font-size: 1.0625rem;
  color: var(--text);
}

.recharge-package-btn span {
  color: var(--text-muted);
  font-size: 0.875rem;
}

.recharge-pay {
  display: grid;
  gap: 14px;
}

.recharge-qr-block {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 14px 12px 10px;
  background: linear-gradient(180deg, #faf8ff 0%, #fff 100%);
  border: 1px solid var(--border-light);
  border-radius: 14px;
}

.recharge-qr {
  width: 168px;
  height: 168px;
  display: block;
  border-radius: 10px;
  background: #fff;
}

.recharge-qr-caption {
  margin: 10px 0 0;
  font-size: 0.75rem;
  color: var(--text-muted);
  letter-spacing: 0.02em;
}

.recharge-amount-block,
.recharge-field {
  display: grid;
  gap: 8px;
}

.recharge-label {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-weight: 500;
}

.recharge-amount-row,
.recharge-address-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.recharge-amount {
  flex: 1;
  font-size: 1.5rem;
  line-height: 1.2;
  color: var(--primary);
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.recharge-address {
  flex: 1;
  min-width: 0;
  font-size: 0.75rem;
  line-height: 1.45;
  word-break: break-all;
  background: var(--bg);
  border: 1px solid var(--border-light);
  padding: 10px 12px;
  border-radius: 10px;
  color: var(--text);
}

.btn-copy {
  flex-shrink: 0;
  border: 1px solid var(--primary-border);
  background: var(--primary-light);
  color: var(--primary);
  border-radius: 999px;
  padding: 7px 12px;
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s, color 0.15s;
}

.btn-copy:hover {
  background: var(--primary);
  color: #fff;
}

.recharge-meta-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.recharge-meta-item {
  display: grid;
  gap: 4px;
  padding: 10px 12px;
  background: var(--bg);
  border-radius: 10px;
}

.recharge-meta-item strong {
  font-size: 0.9375rem;
  font-variant-numeric: tabular-nums;
}

.recharge-countdown {
  color: var(--primary);
}

.recharge-warn {
  margin: 0;
  padding: 10px 12px;
  font-size: 0.8125rem;
  color: #8a4b00;
  line-height: 1.5;
  background: #fff7eb;
  border: 1px solid #f0d9a8;
  border-radius: 10px;
}

.recharge-status {
  margin: 0;
  justify-content: center;
  text-align: center;
}

.recharge-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 2px;
  padding-top: 4px;
}

.recharge-actions .btn-outline {
  justify-content: center;
  width: 100%;
  padding: 10px 14px;
  border-radius: 999px;
  font-size: 0.875rem;
}

.recharge-actions .btn-outline:hover {
  border-color: var(--primary);
  color: var(--primary);
  background: var(--primary-light);
}
