:root {
  color-scheme: light dark;

  --bg-light: #f5f7fb;
  --bg-dark: #0b1120;
  --surface-light: #ffffff;
  --surface-dark: #111827;
  --surface-subtle-light: #f8fafc;
  --surface-subtle-dark: #1e293b;
  --text-light: #0f172a;
  --text-dark: #f1f5f9;
  --text-muted-light: #64748b;
  --text-muted-dark: #94a3b8;
  --border-light: #e2e8f0;
  --border-dark: #1f2937;
  --border-strong-light: #cbd5e1;
  --border-strong-dark: #334155;
  --primary-light: #2563eb;
  --primary-dark: #3b82f6;
  --primary-hover-light: #1d4ed8;
  --primary-hover-dark: #60a5fa;
  --primary-soft-light: #eff6ff;
  --primary-soft-dark: rgb(59 130 246 / 0.14);
  --danger-light: #dc2626;
  --danger-dark: #f87171;
  --danger-soft-light: #fef2f2;
  --danger-soft-dark: rgb(248 113 113 / 0.12);
  --success-light: #059669;
  --success-dark: #34d399;
  --success-soft-light: #ecfdf5;
  --success-soft-dark: rgb(52 211 153 / 0.12);

  /* Baseline fallback tokens for browsers without light-dark() */
  --bg: var(--bg-light);
  --surface: var(--surface-light);
  --surface-subtle: var(--surface-subtle-light);
  --text: var(--text-light);
  --text-muted: var(--text-muted-light);
  --border: var(--border-light);
  --border-strong: var(--border-strong-light);
  --primary: var(--primary-light);
  --primary-hover: var(--primary-hover-light);
  --primary-soft: var(--primary-soft-light);
  --danger: var(--danger-light);
  --danger-soft: var(--danger-soft-light);
  --success: var(--success-light);
  --success-soft: var(--success-soft-light);
  --shadow: 0 10px 30px rgb(15 23 42 / 0.06);
  --radius: 14px;

  @media (prefers-color-scheme: dark) {
    --bg: var(--bg-dark);
    --surface: var(--surface-dark);
    --surface-subtle: var(--surface-subtle-dark);
    --text: var(--text-dark);
    --text-muted: var(--text-muted-dark);
    --border: var(--border-dark);
    --border-strong: var(--border-strong-dark);
    --primary: var(--primary-dark);
    --primary-hover: var(--primary-hover-dark);
    --primary-soft: var(--primary-soft-dark);
    --danger: var(--danger-dark);
    --danger-soft: var(--danger-soft-dark);
    --success: var(--success-dark);
    --success-soft: var(--success-soft-dark);
    --shadow: 0 12px 32px rgb(0 0 0 / 0.45);
  }

  @supports (color: light-dark(white, black)) {
    --bg: light-dark(var(--bg-light), var(--bg-dark));
    --surface: light-dark(var(--surface-light), var(--surface-dark));
    --surface-subtle: light-dark(var(--surface-subtle-light), var(--surface-subtle-dark));
    --text: light-dark(var(--text-light), var(--text-dark));
    --text-muted: light-dark(var(--text-muted-light), var(--text-muted-dark));
    --border: light-dark(var(--border-light), var(--border-dark));
    --border-strong: light-dark(var(--border-strong-light), var(--border-strong-dark));
    --primary: light-dark(var(--primary-light), var(--primary-dark));
    --primary-hover: light-dark(var(--primary-hover-light), var(--primary-hover-dark));
    --primary-soft: light-dark(var(--primary-soft-light), var(--primary-soft-dark));
    --danger: light-dark(var(--danger-light), var(--danger-dark));
    --danger-soft: light-dark(var(--danger-soft-light), var(--danger-soft-dark));
    --success: light-dark(var(--success-light), var(--success-dark));
    --success-soft: light-dark(var(--success-soft-light), var(--success-soft-dark));
  }

  accent-color: var(--primary);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

.page {
  max-width: 780px;
  margin: 0 auto;
  padding: 28px 18px 60px;
}

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

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: var(--text);
}

.brand-icon {
  inline-size: 38px;
  block-size: 38px;
  border-radius: 10px;
  display: block;
  flex-shrink: 0;
}

.brand-title {
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.brand-sub {
  font-size: 12px;
  color: var(--text-muted);
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 26px;
  margin-bottom: 20px;
}

.card-title {
  margin: 0 0 6px;
  font-size: 18px;
  font-weight: 700;
}

.card-desc {
  margin: 0 0 20px;
  font-size: 14px;
  color: var(--text-muted);
}

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

.history-header .card-title {
  margin-bottom: 2px;
}

.hidden {
  display: none !important;
}

.dropzone {
  border: 2px dashed var(--border-strong);
  border-radius: 12px;
  background: var(--surface-subtle);
  padding: 36px 20px;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease;
}

.dropzone:hover,
.dropzone.dragover {
  border-color: var(--primary);
  background: var(--primary-soft);
}

.dropzone:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

.dropzone-icon {
  font-size: 32px;
  margin-bottom: 8px;
}

.dropzone-title {
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 4px;
}

.dropzone-hint {
  font-size: 13px;
  color: var(--text-muted);
}

.selected-file {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  border-radius: 10px;
  background: var(--surface-subtle);
  border: 1px solid var(--border);
  margin-top: 16px;
}

.file-meta {
  min-width: 0;
}

.file-name {
  font-weight: 600;
  font-size: 14px;
  word-break: break-all;
}

.file-size {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 2px;
}

.options-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  margin-top: 18px;
}

@media (max-width: 560px) {
  .options-grid {
    grid-template-columns: 1fr;
  }
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.field.full {
  grid-column: 1 / -1;
}

.field label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
}

.input,
.select {
  width: 100%;
  padding: 10px 12px;
  border-radius: 9px;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text);
  font-size: 14px;
  outline: none;
  transition: border-color 0.15s ease;
}

.input:focus-visible,
.select:focus-visible {
  border-color: var(--primary);
  outline: 2px solid color-mix(in srgb, var(--primary) 30%, transparent);
  outline-offset: 1px;
}

.btn-row {
  display: flex;
  gap: 10px;
  margin-top: 20px;
  flex-wrap: wrap;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-inline-size: 24px;
  min-block-size: 24px;
  padding: 10px 18px;
  border-radius: 9px;
  border: 1px solid transparent;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s ease, opacity 0.15s ease, border-color 0.15s ease;
}

.btn:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

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

.btn-primary {
  background: var(--primary);
  color: #fff;
}

.btn-primary:hover:not(:disabled) {
  background: var(--primary-hover);
}

.btn-secondary {
  background: var(--surface-subtle);
  color: var(--text);
  border-color: var(--border-strong);
}

.btn-secondary:hover:not(:disabled) {
  border-color: var(--primary);
}

.btn-danger {
  background: var(--danger-soft);
  color: var(--danger);
  border-color: transparent;
}

.btn-danger:hover:not(:disabled) {
  border-color: var(--danger);
}

.btn-sm {
  padding: 6px 11px;
  font-size: 12px;
  border-radius: 7px;
}

/* Native <progress> styling per Modern Web Guidance */
.progress-box {
  margin-top: 18px;
  padding: 16px;
  border-radius: 10px;
  background: var(--surface-subtle);
  border: 1px solid var(--border);
}

.progress-header {
  display: flex;
  justify-content: space-between;
  font-size: 13px;
  margin-bottom: 8px;
  gap: 8px;
}

.progress-native {
  appearance: none;
  display: block;
  inline-size: 100%;
  block-size: 10px;
  border: 0 solid;
  border-radius: 1e5px;
  overflow: clip;
  background: var(--border);
  box-shadow: inset 0 1px 2px rgb(0 0 0 / 0.1);
}

.progress-native::-webkit-progress-bar {
  background: transparent;
}

.progress-native::-webkit-progress-value {
  background: linear-gradient(90deg, #2563eb, #0ea5e9);
  border-radius: 1e5px;
  transition: inline-size 0.15s linear;
}

.progress-native::-moz-progress-bar {
  background: linear-gradient(90deg, #2563eb, #0ea5e9);
  border-radius: 1e5px;
}

@media (prefers-reduced-motion: reduce) {
  .progress-native::-webkit-progress-value {
    transition: none;
  }
}

.progress-sub {
  margin-top: 8px;
  font-size: 12px;
  color: var(--text-muted);
  display: flex;
  justify-content: space-between;
  gap: 8px;
}

.alert {
  padding: 12px 14px;
  border-radius: 10px;
  font-size: 13px;
  margin-top: 14px;
}

.alert-error {
  background: var(--danger-soft);
  color: var(--danger);
}

.alert-success {
  background: var(--success-soft);
  color: var(--success);
}

.share-box {
  margin-top: 18px;
  padding: 18px;
  border-radius: 12px;
  background: var(--success-soft);
  border: 1px solid rgb(5 150 105 / 0.25);
}

.share-title {
  font-weight: 700;
  color: var(--success);
  margin-bottom: 8px;
  font-size: 15px;
}

.share-link-row {
  display: flex;
  gap: 8px;
  margin-top: 8px;
  align-items: center;
}

.share-link-row .input {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 13px;
}

.copy-status {
  margin-top: 8px;
  min-block-size: 18px;
  font-size: 12px;
  color: var(--success);
  opacity: 0;
  transition: opacity 0.15s ease;
}

.copy-status[data-visible="true"] {
  opacity: 1;
}

.copy-status[data-error="true"] {
  color: var(--danger);
}

.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  background: var(--primary-soft);
  color: var(--primary);
}

.badge-warn {
  background: var(--danger-soft);
  color: var(--danger);
}

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

.history-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  border-radius: 10px;
  background: var(--surface-subtle);
  border: 1px solid var(--border);
  flex-wrap: wrap;
}

.history-info {
  min-width: 0;
  flex: 1;
}

.history-name {
  font-weight: 600;
  font-size: 14px;
  word-break: break-all;
}

.history-meta {
  font-size: 12px;
  color: var(--text-muted);
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 3px;
}

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

.empty-state {
  text-align: center;
  padding: 20px 10px;
  font-size: 13px;
  color: var(--text-muted);
}

.footer-note {
  text-align: center;
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 24px;
}

.download-summary {
  padding: 18px;
  border-radius: 12px;
  background: var(--surface-subtle);
  border: 1px solid var(--border);
  margin-bottom: 16px;
}

.download-filename {
  font-size: 17px;
  font-weight: 700;
  word-break: break-all;
  margin-bottom: 8px;
}

.download-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

/* Native <dialog> modal styling per Modern Web Guidance */
.confirm-dialog {
  max-inline-size: min(420px, calc(100vw - 32px));
  padding: 24px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow);
}

.confirm-dialog:modal {
  overscroll-behavior: contain;
}

.confirm-dialog::backdrop {
  background: rgb(15 23 42 / 0.55);
  overflow: hidden;
  overscroll-behavior: contain;
}

.confirm-dialog-title {
  margin: 0 0 8px;
  font-size: 17px;
  font-weight: 700;
}

.confirm-dialog-desc {
  margin: 0 0 20px;
  font-size: 14px;
  color: var(--text-muted);
}

.confirm-dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

/* Local vector QR code display (high-contrast white quiet zone in both light & dark modes) */
.share-qr-wrap {
  margin-top: 14px;
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
}

.share-qr-note {
  font-size: 12px;
  color: var(--text-muted);
  flex: 1;
  min-inline-size: 160px;
}

.qr-frame {
  background: #ffffff;
  border-radius: 10px;
  border: 1px solid var(--border);
  padding: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.qr-frame-sm {
  inline-size: 124px;
  block-size: 124px;
  flex-shrink: 0;
}

.qr-frame-lg {
  inline-size: 240px;
  block-size: 240px;
  margin: 0 auto 12px;
  display: flex;
}

.qr-svg {
  inline-size: 100%;
  block-size: 100%;
  display: block;
}

.qr-dialog {
  text-align: center;
}

.qr-dialog .confirm-dialog-desc {
  margin-bottom: 14px;
  word-break: break-all;
}

.qr-dialog-hint {
  margin: 0 0 8px;
  font-size: 12px;
  color: var(--text-muted);
}

.qr-dialog .confirm-dialog-actions {
  justify-content: center;
  margin-top: 10px;
}
