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

body {
  min-height: 100vh;
  background: #fbfbfb;
  color: #1f1f1f;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
    "Helvetica Neue", Arial, "PingFang SC", "Hiragino Sans GB",
    "Microsoft YaHei", sans-serif;
  line-height: 1.6;
}

.page {
  width: min(760px, 100%);
  margin: 0 auto;
  padding: clamp(20px, 5vw, 40px) clamp(16px, 4vw, 24px) 48px;
}

.page--narrow {
  width: min(420px, 100%);
}

.page--wide {
  width: min(980px, 100%);
}

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

.topbar--home {
  justify-content: flex-end;
}

.topbar__spacer {
  flex: 1;
}

.topbar__nav {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.topbar__title {
  font-size: 20px;
  font-weight: 600;
}

.topbar__link,
.topbar__button {
  border: none;
  background: transparent;
  color: #475569;
  font: inherit;
  font-size: 14px;
  cursor: pointer;
  text-decoration: none;
}

.topbar__link:hover,
.topbar__button:hover {
  color: #111827;
}

.hero {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 10px;
  margin-bottom: 24px;
}

.hero--compact {
  margin-bottom: 18px;
}

.hero__logo {
  width: min(200px, 28vw);
  height: auto;
}

.hero__title {
  font-size: clamp(20px, 4.5vw, 26px);
  font-weight: 600;
}

.hero__subtitle {
  color: #666;
  font-size: clamp(13px, 3.2vw, 15px);
}

.card {
  background: #fff;
  border: 1px solid #ececec;
  border-radius: 16px;
  padding: 20px;
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.04);
}

.input-card {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.input-stack {
  display: flex;
  flex-direction: column;
  gap: 0;
}

/* 用网格行高收起/展开，避免 display:none 导致按钮突然跳动 */
.clipboard-slot {
  display: grid;
  grid-template-rows: 0fr;
  opacity: 0;
  margin-top: 0;
  pointer-events: none;
  transition:
    grid-template-rows 0.22s ease,
    opacity 0.18s ease,
    margin-top 0.22s ease;
}

.clipboard-slot.is-open {
  grid-template-rows: 1fr;
  opacity: 1;
  margin-top: 12px;
  pointer-events: auto;
}

.clipboard-slot__inner {
  overflow: hidden;
  min-height: 0;
}

.clipboard-prompt {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 12px 12px 14px;
  border-radius: 12px;
  background: #f4f4f5;
  border: 1px solid transparent;
}

.clipboard-prompt__main {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.clipboard-prompt__icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: #fff;
  color: #111827;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.06);
}

.clipboard-prompt__body {
  min-width: 0;
}

.clipboard-prompt__title {
  margin: 0;
  font-size: 14px;
  font-weight: 600;
  line-height: 1.35;
  color: #111827;
}

.clipboard-prompt__hint {
  margin: 2px 0 0;
  font-size: 12px;
  line-height: 1.35;
  color: #6b7280;
}

.clipboard-prompt__actions {
  display: flex;
  align-items: center;
  flex-shrink: 0;
  gap: 6px;
}

.clipboard-prompt__actions .btn--small {
  min-width: 64px;
  padding: 7px 14px;
  font-size: 13px;
}

.clipboard-prompt__dismiss {
  border: none;
  background: transparent;
  color: #6b7280;
  font: inherit;
  font-size: 13px;
  padding: 7px 10px;
  cursor: pointer;
  border-radius: 999px;
}

.clipboard-prompt__dismiss:hover {
  color: #111827;
  background: rgba(15, 23, 42, 0.06);
}

@media (max-width: 420px) {
  .clipboard-prompt {
    align-items: flex-start;
    flex-direction: column;
  }

  .clipboard-prompt__actions {
    width: 100%;
    justify-content: flex-end;
  }
}

.label {
  font-size: 14px;
  font-weight: 600;
}

.textarea {
  width: 100%;
  border: 1px solid #ddd;
  border-radius: 12px;
  padding: 14px;
  font: inherit;
  font-size: 16px;
  resize: none;
  min-height: 120px;
  background: #fafafa;
}

.textarea:focus {
  outline: 2px solid #8ab4ff;
  border-color: #8ab4ff;
  background: #fff;
}

.hint {
  color: #888;
  font-size: 13px;
}

.form {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.input {
  width: 100%;
  border: 1px solid #ddd;
  border-radius: 12px;
  padding: 12px 14px;
  font: inherit;
  font-size: 16px;
  background: #fafafa;
}

.input:focus {
  outline: 2px solid #8ab4ff;
  border-color: #8ab4ff;
  background: #fff;
}

.btn--small {
  padding: 7px 12px;
  font-size: 12px;
}

.btn {
  border: none;
  border-radius: 999px;
  padding: 11px 18px;
  font: inherit;
  font-size: 14px;
  cursor: pointer;
  transition: transform 0.15s ease, opacity 0.15s ease, background 0.15s ease,
    border-color 0.15s ease, box-shadow 0.15s ease;
}

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

.btn:not(:disabled):active {
  transform: scale(0.98);
}

.btn--primary {
  background: #111;
  color: #fff;
}

.btn--secondary {
  background: #fff;
  border: 0.5px solid #c7cdd8;
  color: #111827;
  font-weight: 400;
  box-shadow: 0 1px 2px rgba(16, 24, 40, 0.08);
}

.btn--secondary:hover:not(:disabled) {
  background: #f8fafc;
  border-color: #94a3b8;
  box-shadow: 0 2px 6px rgba(16, 24, 40, 0.1);
}

.status {
  margin: 16px 0;
  padding: 14px 16px;
  border-radius: 12px;
  font-size: 14px;
}

.status--loading {
  background: #eef4ff;
  color: #1d4ed8;
}

.status--error {
  background: #fef2f2;
  color: #b91c1c;
  white-space: pre-wrap;
  line-height: 1.55;
}

.result {
  margin-top: 8px;
}

.result-card {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.result__toolbar {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

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

.tabs {
  display: inline-flex;
  align-self: flex-start;
  padding: 4px;
  border-radius: 999px;
  background: #f1f5f9;
  gap: 4px;
}

.tab {
  border: none;
  background: transparent;
  /* color: #64748b; */
  border-radius: 999px;
  padding: 8px 16px;
  font: inherit;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
}

.tab--active {
  background: #fff;
  color: #111827;
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.12);
}

.tab-panel {
  display: none;
}

.tab-panel--active {
  display: block;
}

.video-meta {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.video-meta__title {
  font-size: 17px;
  line-height: 1.5;
  color: #1f1f1f;
}

.video-meta__item {
  color: #555;
  font-size: 14px;
  word-break: break-all;
}

.video-meta__item a {
  color: #2563eb;
  text-decoration: none;
}

.video-meta__item a:hover {
  text-decoration: underline;
}

.content-box {
  white-space: pre-wrap;
  word-break: break-word;
  color: #333;
  font-size: 14px;
  line-height: 1.8;
}

.content-box--transcript {
  font-size: 14px;
  white-space: pre-wrap;
}

.content-box--summary {
  font-size: 15px;
  white-space: normal;
}

.markdown-body h1,
.markdown-body h2,
.markdown-body h3,
.markdown-body h4 {
  margin: 1.2em 0 0.6em;
  line-height: 1.35;
  color: #111827;
}

.markdown-body h1 {
  font-size: 1.5rem;
}

.markdown-body h2 {
  font-size: 1.25rem;
}

.markdown-body h3 {
  font-size: 1.1rem;
}

.markdown-body h4 {
  font-size: 1rem;
}

.markdown-body p,
.markdown-body ul,
.markdown-body ol,
.markdown-body blockquote,
.markdown-body table {
  margin: 0.8em 0;
}

.markdown-body ul,
.markdown-body ol {
  padding-left: 1.4em;
}

.markdown-body blockquote {
  padding-left: 1em;
  border-left: 3px solid #dbeafe;
  color: #475569;
}

.markdown-body table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

.markdown-body th,
.markdown-body td {
  border: 1px solid #e5e7eb;
  padding: 8px 10px;
  text-align: left;
}

.markdown-body strong {
  font-weight: 700;
  color: #111827;
}

.markdown-body a {
  color: #2563eb;
}

.markdown-body code {
  background: #f3f4f6;
  padding: 0.1em 0.35em;
  border-radius: 4px;
  font-size: 0.92em;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 32px;
  z-index: 1000;
  padding: 12px 22px;
  border-radius: 12px;
  background: rgba(17, 24, 39, 0.92);
  color: #fff;
  font-size: 14px;
  font-weight: 500;
  line-height: 1.4;
  box-shadow: 0 10px 30px rgba(15, 23, 42, 0.22);
  pointer-events: none;
  opacity: 0;
  transform: translateX(-50%) translateY(12px);
  transition: opacity 0.4s ease, transform 0.4s ease;
}

.toast--visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.toast--hiding {
  opacity: 0;
  transform: translateX(-50%) translateY(8px);
}

@media (min-width: 640px) {
  .result__toolbar {
    flex-direction: row;
    justify-content: space-between;
    align-items: center;
  }
}

.history-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.history-skeleton {
  border: 1px solid #ececec;
  border-radius: 14px;
  background: #fff;
  box-shadow: 0 4px 16px rgba(15, 23, 42, 0.04);
  padding: 16px;
}

.history-skeleton__meta {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
}

.history-skeleton__chip {
  display: block;
  height: 20px;
  width: 48px;
  border-radius: 999px;
  background: linear-gradient(90deg, #f1f5f9 25%, #e8edf3 50%, #f1f5f9 75%);
  background-size: 200% 100%;
  animation: history-skeleton-shimmer 1.4s ease-in-out infinite;
}

.history-skeleton__chip--sm {
  width: 56px;
}

.history-skeleton__title {
  height: 16px;
  width: 88%;
  border-radius: 6px;
  background: linear-gradient(90deg, #f1f5f9 25%, #e8edf3 50%, #f1f5f9 75%);
  background-size: 200% 100%;
  animation: history-skeleton-shimmer 1.4s ease-in-out infinite;
}

.history-skeleton__title--short {
  width: 62%;
}

.history-skeleton__title--medium {
  width: 76%;
}

@keyframes history-skeleton-shimmer {
  0% {
    background-position: 200% 0;
  }

  100% {
    background-position: -200% 0;
  }
}

.history-accordion {
  border: 1px solid #ececec;
  border-radius: 14px;
  background: #fff;
  box-shadow: 0 4px 16px rgba(15, 23, 42, 0.04);
  overflow: hidden;
}

.history-accordion__header {
  width: 100%;
  text-align: left;
  border: 0;
  background: transparent;
  padding: 16px;
  cursor: pointer;
  color: #1f1f1f;
  /* -webkit-text-fill-color: #1f1f1f; */
  font: inherit;
}

.history-accordion__header:hover {
  background: #fafafa;
}

.history-accordion__title-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.history-accordion__chevron {
  flex-shrink: 0;
  color: #94a3b8;
  font-size: 20px;
  line-height: 1.2;
  transition: transform 0.2s ease;
}

.history-accordion--open .history-accordion__chevron {
  transform: rotate(90deg);
}

.history-accordion__body {
  border-top: 1px solid #f1f5f9;
}

.history-accordion__content {
  margin: 0;
  border: 0;
  border-radius: 0;
  box-shadow: none;
}

.history-result__toolbar {
  flex-direction: row;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.history-result__toolbar .tabs {
  flex: 0 0 auto;
}

.history-result__toolbar .result__actions {
  flex: 0 0 auto;
}

.history-result__toolbar .tab {
  padding: 7px 12px;
  font-size: 13px;
}

.history-result__toolbar .btn--secondary {
  padding: 4px 14px;
  font-size: 13px;
}

.history-accordion__loading,
.history-accordion__error {
  padding: 20px 16px;
  color: #64748b;
  font-size: 14px;
}

.history-accordion__error {
  color: #b91c1c;
  line-height: 1.6;
}

.history-accordion__error-title {
  margin-bottom: 8px;
  font-weight: 700;
  font-size: 14px;
}

.history-accordion__error-body {
  margin: 0;
  padding: 12px 14px;
  border-radius: 10px;
  background: #fff7ed;
  border: 1px solid #fed7aa;
  color: #9a3412;
  font-size: 13px;
  line-height: 1.55;
  white-space: pre-wrap;
  word-break: break-word;
  font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
}

.history-accordion__error-body--inline {
  margin-top: 10px;
}

.history-item__error {
  margin: 8px 0 0;
  color: #b91c1c;
  font-size: 12px;
  line-height: 1.45;
  text-align: left;
}

.history-item {
  width: 100%;
  text-align: left;
  border: 1px solid #ececec;
  border-radius: 14px;
  background: #fff;
  padding: 16px;
  cursor: pointer;
  box-shadow: 0 4px 16px rgba(15, 23, 42, 0.04);
}

.history-item__meta {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 8px;
}

.history-item__time,
.history-item__status {
  font-size: 12px;
  color: #64748b;
}

.history-item__status--failed {
  color: #b91c1c;
}

.history-item__status--processing {
  color: #1d4ed8;
}

.history-item__status--queued {
  color: #64748b;
}

.records-section {
  margin-top: 8px;
}

.records-section .section-title {
  font-size: 17px;
  font-weight: 700;
  margin-bottom: 12px;
}

.records-section__footer {
  margin-top: 12px;
}

.btn--block {
  display: block;
  width: 100%;
  text-align: center;
  text-decoration: none;
}

.history-accordion__pending {
  padding: 20px 16px;
  color: #64748b;
  font-size: 14px;
  line-height: 1.6;
}

.history-item__title {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  overflow: hidden;
  font-size: 15px;
  font-weight: 600;
  line-height: 1.5;
  color: #1f1f1f;
  word-break: break-word;
}

.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 999px;
  background: #f1f5f9;
  color: #475569;
  font-size: 12px;
  font-weight: 600;
  line-height: 1.4;
}

.history-accordion__link {
  display: block;
  text-decoration: none;
  color: inherit;
  -webkit-text-fill-color: inherit;
}

.history-accordion__link:hover {
  background: #fafafa;
}

.detail-root {
  min-height: 120px;
}

.detail-card {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

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

.detail-card__meta-left {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  min-width: 0;
}

.detail-card__source {
  font-size: 12px;
  color: #2563eb;
  text-decoration: none;
  white-space: nowrap;
}

.detail-card__source:hover {
  text-decoration: underline;
}

.detail-card__title {
  font-size: 20px;
  font-weight: 700;
  line-height: 1.4;
  color: #1f1f1f;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.detail-card__title--pending {
  font-size: 15px;
  font-weight: 600;
  color: #64748b;
}

.detail-card__toolbar {
  margin-top: 2px;
}

.detail-card__pending {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  padding: 36px 12px 28px;
  color: #64748b;
  font-size: 14px;
  line-height: 1.6;
  text-align: center;
}

.detail-loading {
  display: flex;
  align-items: center;
  justify-content: center;
}

.detail-loading__spinner {
  width: 36px;
  height: 36px;
  border: 3px solid #e2e8f0;
  border-top-color: #111827;
  border-radius: 50%;
  animation: detail-spin 0.8s linear infinite;
}

.detail-card__pending-text {
  margin: 0;
  max-width: 280px;
}

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

.history-item__status--success {
  color: #64748b;
}

.empty-card {
  text-align: center;
  color: #64748b;
}

.admin-tabs {
  margin-bottom: 16px;
}

.admin-panel {
  display: none;
}

.admin-panel--active {
  display: block;
}

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

.stat-card {
  background: #fff;
  border: 1px solid #ececec;
  border-radius: 14px;
  padding: 16px;
}

.stat-card__label {
  color: #64748b;
  font-size: 13px;
  margin-bottom: 8px;
}

.stat-card__value {
  font-size: 24px;
  font-weight: 700;
}

.table-wrap {
  overflow-x: auto;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.data-table--recent {
  table-layout: fixed;
}

.data-table th,
.data-table td {
  border-bottom: 1px solid #eef2f7;
  padding: 10px 8px;
  text-align: left;
  vertical-align: middle;
}

.data-table th {
  color: #64748b;
  font-weight: 600;
  white-space: nowrap;
}

.data-table--admin .col-time {
  width: 108px;
  white-space: nowrap;
}

.data-table--admin .col-platform {
  width: 64px;
  white-space: nowrap;
}

.data-table--admin .col-charge {
  width: 72px;
  white-space: nowrap;
}

.data-table--admin .col-status {
  width: 64px;
  white-space: nowrap;
}

.data-table--admin .col-user {
  width: 180px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.data-table--admin .col-title {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.data-table--recent .col-title {
  width: auto;
}

.status-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 12px;
  line-height: 1.4;
  white-space: nowrap;
}

.status-badge--success {
  color: #166534;
  background: #dcfce7;
}

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

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

.status-badge--queued {
  color: #475569;
  background: #f1f5f9;
}

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

.quota-control {
  display: flex;
  align-items: center;
  gap: 6px;
}

.input--compact {
  width: 72px;
  min-width: 72px;
  padding: 6px 8px;
  font-size: 13px;
}

.dialog {
  width: min(92vw, 420px);
  border: 0;
  border-radius: 16px;
  padding: 0;
  box-shadow: 0 20px 50px rgba(15, 23, 42, 0.18);
}

.dialog::backdrop {
  background: rgba(15, 23, 42, 0.35);
}

.dialog__form {
  padding: 24px;
}

.dialog__title {
  margin: 0 0 8px;
  font-size: 18px;
}

.dialog__hint {
  margin: 0 0 16px;
  color: #64748b;
  font-size: 14px;
  word-break: break-all;
}

.dialog__actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 20px;
}

.records-filter {
  display: flex;
  gap: 10px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

@media (min-width: 768px) {
  .stats-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}
