:root {
  color-scheme: dark;
  --bg: #0f172a;
  --header-bg: rgba(15, 23, 42, 0.9);
  --surface: #1e293b;
  --surface-2: #0b1220;
  --border: #334155;
  --text: #f1f5f9;
  --muted: #94a3b8;
  --primary: #3b82f6;
  --primary-hover: #2563eb;
  --danger: #ef4444;
  --danger-hover: #dc2626;
  --error-bg: rgba(239, 68, 68, 0.15);
  --error-border: rgba(239, 68, 68, 0.4);
  --error-text: #fecaca;
  --toast-bg: #0f172a;
  --toast-text: #f8fafc;
  --thumb-bg: #000000;
  --radius: 12px;
}

@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    color-scheme: light;
    --bg: #f8fafc;
    --header-bg: rgba(255, 255, 255, 0.9);
    --surface: #ffffff;
    --surface-2: #f1f5f9;
    --border: #cbd5e1;
    --text: #0f172a;
    --muted: #475569;
    --primary: #2563eb;
    --primary-hover: #1d4ed8;
    --danger: #dc2626;
    --danger-hover: #b91c1c;
    --error-bg: #fef2f2;
    --error-border: #fca5a5;
    --error-text: #991b1b;
    --toast-bg: #0f172a;
    --toast-text: #f8fafc;
    --thumb-bg: #e2e8f0;
  }
}

:root[data-theme="light"] {
  color-scheme: light;
  --bg: #f8fafc;
  --header-bg: rgba(255, 255, 255, 0.9);
  --surface: #ffffff;
  --surface-2: #f1f5f9;
  --border: #cbd5e1;
  --text: #0f172a;
  --muted: #475569;
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --danger: #dc2626;
  --danger-hover: #b91c1c;
  --error-bg: #fef2f2;
  --error-border: #fca5a5;
  --error-text: #991b1b;
  --toast-bg: #0f172a;
  --toast-text: #f8fafc;
  --thumb-bg: #e2e8f0;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Noto Sans TC", sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  min-height: 100vh;
}

.container {
  max-width: 820px;
  margin: 0 auto;
  padding: 0 16px;
}

.header {
  border-bottom: 1px solid var(--border);
  background: var(--header-bg);
  position: sticky;
  top: 0;
  z-index: 10;
  backdrop-filter: blur(8px);
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  height: 60px;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

.lang-select {
  padding: 5px 8px;
  font-size: 0.82rem;
}

.icon-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--muted);
  text-decoration: none;
  flex-shrink: 0;
  transition: color 0.15s ease, border-color 0.15s ease;
}

.icon-link:hover,
.icon-link:focus-visible {
  color: var(--text);
  border-color: var(--muted);
  outline: none;
}

.icon-link svg {
  width: 18px;
  height: 18px;
  fill: currentColor;
}

.brand {
  color: var(--text);
  text-decoration: none;
  font-weight: 700;
  font-size: 1.2rem;
  letter-spacing: -0.02em;
}

.badge {
  font-size: 0.8rem;
  color: var(--muted);
  background: var(--surface);
  border: 1px solid var(--border);
  padding: 4px 10px;
  border-radius: 999px;
}

.main {
  padding-top: 28px;
  padding-bottom: 48px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
}

.ttl-bar {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  margin-bottom: 14px;
  font-size: 0.9rem;
  color: var(--muted);
}

.select {
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 6px 10px;
  font-size: 0.9rem;
}

.drop-zone {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 48px 20px;
  text-align: center;
  cursor: pointer;
  background: var(--surface-2);
  transition: border-color 0.15s ease, background-color 0.15s ease;
}

.drop-zone:hover,
.drop-zone:focus-visible,
.drop-zone.drag-over {
  border-color: var(--primary);
  background: rgba(59, 130, 246, 0.08);
  outline: none;
}

.drop-icon {
  font-size: 2.2rem;
  margin-bottom: 8px;
}

.drop-title {
  margin: 0 0 6px;
  font-size: 1.2rem;
}

.drop-sub {
  margin: 0 0 12px;
  color: var(--muted);
}

.upload-actions {
  margin-top: 14px;
  display: flex;
  justify-content: center;
}

.paste-btn {
  padding: 10px 20px;
  font-size: 0.94rem;
  gap: 6px;
}

.link-text {
  color: var(--primary);
  text-decoration: underline;
}

.drop-hint {
  margin: 0;
  font-size: 0.82rem;
  color: var(--muted);
}

.progress-wrap {
  margin-top: 16px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.progress-track {
  width: 100%;
  height: 8px;
  background: var(--surface-2);
  border-radius: 999px;
  overflow: hidden;
}

.progress-bar {
  height: 100%;
  width: 0%;
  background: var(--primary);
  transition: width 0.12s ease;
}

.progress-text {
  font-size: 0.85rem;
  color: var(--muted);
}

.alert {
  margin-top: 14px;
  padding: 10px 14px;
  border-radius: 8px;
  font-size: 0.9rem;
}

.alert-error {
  background: var(--error-bg);
  border: 1px solid var(--error-border);
  color: var(--error-text);
}

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

.result-header h2 {
  margin: 0;
  font-size: 1.05rem;
}

.result-preview-wrap {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 16px;
  background: var(--surface-2);
  padding: 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
}

.result-preview {
  max-width: 120px;
  max-height: 90px;
  border-radius: 6px;
  object-fit: contain;
  background: var(--thumb-bg);
}

.result-meta {
  font-size: 0.88rem;
  color: var(--muted);
}

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

.copy-row label {
  display: block;
  font-size: 0.82rem;
  color: var(--muted);
  margin-bottom: 4px;
}

.input-group {
  display: flex;
  gap: 8px;
}

.input-group input {
  flex: 1;
  min-width: 0;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  padding: 8px 10px;
  font-size: 0.88rem;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: none;
  border-radius: 8px;
  padding: 8px 14px;
  font-size: 0.88rem;
  font-weight: 500;
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
  transition: background-color 0.15s ease;
}

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

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

.btn-secondary {
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--border);
}

.btn-secondary:hover {
  border-color: var(--muted);
}

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

.btn-danger:hover {
  background: var(--danger-hover);
}

.btn-ghost {
  background: transparent;
  color: var(--muted);
}

.btn-ghost:hover {
  color: var(--text);
}

.image-stage {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 16px;
  text-align: center;
  margin-bottom: 16px;
}

.shared-image {
  max-width: 100%;
  max-height: 75vh;
  height: auto;
  border-radius: 4px;
}

.meta-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 12px 20px;
  font-size: 0.88rem;
  color: var(--muted);
  margin-bottom: 16px;
}

.meta-bar strong {
  color: var(--text);
}

.view-actions {
  margin-top: 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.recent-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

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

.recent-left {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.recent-thumb {
  width: 48px;
  height: 48px;
  object-fit: cover;
  border-radius: 6px;
  background: var(--thumb-bg);
  flex-shrink: 0;
}

.recent-info {
  min-width: 0;
}

.recent-link {
  color: var(--text);
  text-decoration: none;
  font-weight: 500;
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.recent-link:hover {
  color: var(--primary);
}

.recent-sub {
  font-size: 0.78rem;
  color: var(--muted);
}

.recent-actions {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
}

.notfound-card {
  text-align: center;
  padding: 40px 20px;
}

.notfound-card p {
  color: var(--muted);
  margin-bottom: 20px;
}

.footer {
  text-align: center;
  padding: 0 0 28px;
  font-size: 0.78rem;
  color: var(--muted);
}

.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--toast-bg);
  color: var(--toast-text);
  border: 1px solid var(--border);
  padding: 10px 18px;
  border-radius: 999px;
  font-size: 0.88rem;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25);
  z-index: 100;
}

.hidden {
  display: none !important;
}

@media (max-width: 600px) {
  .badge {
    display: none;
  }
  .result-preview-wrap {
    flex-direction: column;
    align-items: flex-start;
  }
  .recent-item {
    flex-direction: column;
    align-items: stretch;
  }
  .recent-actions {
    justify-content: flex-end;
  }
}
