/* 浅色（默认） */
:root,
[data-theme="light"] {
  --bg: #f5f7fa;
  --surface: #ffffff;
  --surface-hover: #f0f4f8;
  --border: #e2e8f0;
  --text: #1a202c;
  --text-muted: #64748b;
  --accent: #2563eb;
  --accent-hover: #1d4ed8;
  --success: #16a34a;
  --error: #dc2626;
  --tag-bg: rgba(37, 99, 235, 0.1);
  --tag-difficulty-bg: rgba(22, 163, 74, 0.1);
  --alert-error-bg: rgba(220, 38, 38, 0.08);
  --alert-error-border: rgba(220, 38, 38, 0.25);
  --alert-success-bg: rgba(22, 163, 74, 0.08);
  --alert-success-border: rgba(22, 163, 74, 0.25);
  --shadow: 0 4px 24px rgba(0, 0, 0, 0.06);
  --input-bg: #ffffff;
  --radius: 10px;
}

/* 深色 */
[data-theme="dark"] {
  --bg: #0f1419;
  --surface: #1a2332;
  --surface-hover: #243044;
  --border: #2d3a4f;
  --text: #e8edf5;
  --text-muted: #8b9cb3;
  --accent: #3b82f6;
  --accent-hover: #2563eb;
  --success: #22c55e;
  --error: #ef4444;
  --tag-bg: rgba(59, 130, 246, 0.15);
  --tag-difficulty-bg: rgba(34, 197, 94, 0.15);
  --alert-error-bg: rgba(239, 68, 68, 0.12);
  --alert-error-border: rgba(239, 68, 68, 0.3);
  --alert-success-bg: rgba(34, 197, 94, 0.12);
  --alert-success-border: rgba(34, 197, 94, 0.3);
  --shadow: 0 4px 24px rgba(0, 0, 0, 0.35);
  --input-bg: #0f1419;
}

/* 护眼色 */
[data-theme="eye-care"] {
  --bg: #e8f0e4;
  --surface: #f3f8f0;
  --surface-hover: #e5efe0;
  --border: #c5d8bc;
  --text: #2d3a28;
  --text-muted: #5a6b52;
  --accent: #4a7c59;
  --accent-hover: #3d6649;
  --success: #3d8b4f;
  --error: #c0392b;
  --tag-bg: rgba(74, 124, 89, 0.15);
  --tag-difficulty-bg: rgba(61, 139, 79, 0.15);
  --alert-error-bg: rgba(192, 57, 43, 0.08);
  --alert-error-border: rgba(192, 57, 43, 0.25);
  --alert-success-bg: rgba(61, 139, 79, 0.1);
  --alert-success-border: rgba(61, 139, 79, 0.25);
  --shadow: 0 4px 24px rgba(45, 58, 40, 0.08);
  --input-bg: #fafcf9;
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  transition: background 0.2s, color 0.2s;
}

main {
  flex: 1 0 auto;
}

a {
  color: var(--accent);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

.container {
  max-width: 960px;
  margin: 0 auto;
  padding: 0 1.25rem;
}

/* Header */
.site-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
  transition: background 0.2s, border-color 0.2s;
}

.site-header .container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 56px;
  gap: 1rem;
}

.logo {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text);
  text-decoration: none;
  flex-shrink: 0;
}

.logo span {
  color: var(--accent);
}

.header-right {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.nav {
  display: flex;
  gap: 1.25rem;
}

.nav a {
  color: var(--text-muted);
  font-size: 0.95rem;
  text-decoration: none;
  transition: color 0.15s;
  white-space: nowrap;
}

.nav a:hover,
.nav a.active {
  color: var(--text);
  text-decoration: none;
}

.theme-dropdown {
  position: relative;
  flex-shrink: 0;
}

.theme-dropdown-trigger {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.4rem 0.65rem 0.4rem 0.55rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text);
  font-size: 0.82rem;
  cursor: pointer;
  transition: border-color 0.2s, box-shadow 0.2s, background 0.2s;
  min-width: 96px;
}

.theme-dropdown-trigger:hover,
.theme-dropdown.open .theme-dropdown-trigger {
  border-color: var(--accent);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
}

.theme-trigger-icon {
  font-size: 0.95rem;
  line-height: 1;
}

.theme-trigger-label {
  flex: 1;
  text-align: left;
}

.theme-chevron {
  width: 14px;
  height: 14px;
  fill: none;
  stroke: var(--text-muted);
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  transition: transform 0.2s;
}

.theme-dropdown.open .theme-chevron {
  transform: rotate(180deg);
}

.theme-dropdown-menu {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  min-width: 140px;
  margin: 0;
  padding: 0.35rem;
  list-style: none;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: var(--shadow);
  z-index: 200;
}

.theme-dropdown-menu[hidden] {
  display: none;
}

.theme-option {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  padding: 0.55rem 0.65rem;
  border-radius: 8px;
  font-size: 0.85rem;
  color: var(--text);
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.theme-option:hover {
  background: var(--surface-hover);
}

.theme-option.active {
  background: var(--tag-bg);
  color: var(--accent);
  font-weight: 500;
}

.theme-option-icon {
  width: 18px;
  text-align: center;
  font-size: 0.95rem;
}

/* Hero */
.hero {
  padding: 3.5rem 0 2.5rem;
  text-align: center;
}

.hero h1 {
  font-size: 2.25rem;
  font-weight: 700;
  margin-bottom: 0.75rem;
  letter-spacing: -0.02em;
}

.hero p {
  color: var(--text-muted);
  font-size: 1.1rem;
  max-width: 520px;
  margin: 0 auto;
}

/* Sections */
.section {
  padding: 2rem 0 3rem;
}

.section-title {
  font-size: 1.35rem;
  font-weight: 600;
  margin-bottom: 1.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.section-title a {
  font-size: 0.875rem;
  font-weight: 400;
}

/* Cards grid */
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1rem;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  transition: border-color 0.15s, background 0.2s;
}

.card:hover {
  border-color: var(--accent);
  background: var(--surface-hover);
}

.card h3 {
  font-size: 1rem;
  margin-bottom: 0.5rem;
}

.card p {
  color: var(--text-muted);
  font-size: 0.875rem;
  margin-bottom: 0.75rem;
}

.card-meta {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.tag {
  display: inline-block;
  font-size: 0.75rem;
  padding: 0.15rem 0.5rem;
  border-radius: 4px;
  background: var(--tag-bg);
  color: var(--accent);
}

.tag.difficulty {
  background: var(--tag-difficulty-bg);
  color: var(--success);
}

.tag.reverse {
  background: var(--tag-bg);
  color: var(--accent);
}

/* Tool card with link */
.card-link {
  display: block;
  text-decoration: none;
  color: inherit;
}

.card-link:hover {
  text-decoration: none;
}

/* Form */
.tool-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  box-shadow: var(--shadow);
  transition: background 0.2s, border-color 0.2s;
}

.form-group {
  margin-bottom: 1rem;
}

.form-group label {
  display: block;
  font-size: 0.875rem;
  font-weight: 500;
  margin-bottom: 0.4rem;
  color: var(--text-muted);
}

.form-group textarea,
.form-group input {
  width: 100%;
  padding: 0.75rem 1rem;
  background: var(--input-bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-size: 0.95rem;
  font-family: inherit;
  resize: vertical;
  transition: background 0.2s, border-color 0.2s;
}

.form-group textarea:focus,
.form-group input:focus {
  outline: none;
  border-color: var(--accent);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.65rem 1.25rem;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 8px;
  font-size: 0.95rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s;
  text-decoration: none;
}

.btn:hover {
  background: var(--accent-hover);
  text-decoration: none;
}

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

/* Result */
.result-panel {
  margin-top: 1.5rem;
  display: none;
}

.result-panel.visible {
  display: block;
}

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

.result-header h3 {
  font-size: 1rem;
}

.result-grid {
  display: grid;
  gap: 0.75rem;
}

.result-item {
  display: flex;
  gap: 0.75rem;
  font-size: 0.875rem;
}

.result-item .label {
  color: var(--text-muted);
  min-width: 72px;
  flex-shrink: 0;
}

.result-item .value {
  word-break: break-all;
}

.video-preview {
  margin-top: 1rem;
  border-radius: 8px;
  overflow: hidden;
  background: #000;
}

.video-preview video {
  width: 100%;
  max-height: 400px;
  display: block;
}

.alert {
  padding: 0.75rem 1rem;
  border-radius: 8px;
  font-size: 0.875rem;
}

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

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

/* Footer */
.site-footer {
  flex-shrink: 0;
  border-top: 1px solid var(--border);
  padding: 1.5rem 0;
  margin-top: auto;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.8rem;
  background: var(--surface);
}

.page-title {
  font-size: 1.75rem;
  font-weight: 700;
  margin-bottom: 0.5rem;
}

.page-desc {
  color: var(--text-muted);
  margin-bottom: 2rem;
}

.form-row {
  display: flex;
  gap: 1rem;
  align-items: flex-end;
}

.form-group-grow {
  flex: 1;
}

.form-group-sm {
  width: 110px;
  flex-shrink: 0;
}

.form-group select {
  width: 100%;
  padding: 0.75rem 1rem;
  background: var(--input-bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-size: 0.95rem;
  font-family: inherit;
}

.form-group-inline {
  margin-bottom: 1rem;
}

.checkbox-label {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.875rem;
  color: var(--text-muted);
  cursor: pointer;
}

.checkbox-label input {
  width: auto;
}

.result-summary {
  font-size: 0.9rem;
  color: var(--text-muted);
  margin-bottom: 1rem;
}

.article-list {
  display: grid;
  gap: 0.85rem;
}

.article-card {
  display: flex;
  gap: 0.85rem;
  padding: 1rem 1.1rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  transition: border-color 0.15s;
}

.article-card:hover {
  border-color: var(--accent);
}

.article-index {
  flex-shrink: 0;
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: var(--tag-bg);
  color: var(--accent);
  font-size: 0.8rem;
  font-weight: 600;
}

.article-title {
  font-size: 0.95rem;
  margin-bottom: 0.35rem;
  line-height: 1.45;
}

.article-title a {
  color: var(--text);
  text-decoration: none;
}

.article-title a:hover {
  color: var(--accent);
  text-decoration: underline;
}

.article-summary {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 0.55rem;
  line-height: 1.55;
}

.article-meta {
  display: flex;
  gap: 0.4rem;
  flex-wrap: wrap;
}

.translate-results {
  display: grid;
  gap: 1rem;
}

.translate-results-group {
  display: grid;
  gap: 0.85rem;
}

.translate-promo {
  margin: 0 0 1.25rem;
  padding: 0.85rem 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--tag-bg);
}

.translate-promo-link {
  color: var(--accent);
  text-decoration: none;
  font-size: 0.92rem;
}

.translate-promo-link:hover {
  text-decoration: underline;
}

.translate-results-failed {
  display: grid;
  gap: 0.75rem;
  padding-top: 0.25rem;
}

.translate-failed-title {
  font-size: 0.9rem;
  color: var(--error);
  font-weight: 600;
}

.translate-card {
  padding: 1rem 1.1rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
}

.translate-card-error {
  border-color: rgba(220, 38, 38, 0.25);
}

.translate-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.65rem;
}

.translate-card-header h3 {
  font-size: 0.95rem;
}

.translate-text {
  font-size: 0.95rem;
  line-height: 1.65;
  white-space: pre-wrap;
  word-break: break-word;
}

.translate-error {
  font-size: 0.875rem;
  color: var(--error);
}

@media (max-width: 720px) {
  .form-row {
    flex-direction: column;
    align-items: stretch;
  }

  .form-group-sm {
    width: 100%;
  }

  .hero h1 {
    font-size: 1.75rem;
  }

  .nav {
    gap: 0.75rem;
  }

  .nav a {
    font-size: 0.85rem;
  }
}

@media (max-width: 520px) {
  .site-header .container {
    flex-wrap: wrap;
    height: auto;
    padding-top: 0.75rem;
    padding-bottom: 0.75rem;
  }

  .header-right {
    width: 100%;
    justify-content: space-between;
  }
}

/* DevTools */
.devtools-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-bottom: 1rem;
}

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

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

.code-output {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
  font-size: 0.875rem;
  line-height: 1.55;
}

.html-preview {
  width: 100%;
  min-height: 320px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: #fff;
}

.container-wide {
  max-width: 1280px;
}

.split-panel {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.25rem;
  align-items: stretch;
}

.split-panel-left,
.split-panel-right {
  display: flex;
  flex-direction: column;
  min-height: 520px;
}

.split-fill {
  flex: 1;
  display: flex;
  flex-direction: column;
}

.split-textarea {
  flex: 1;
  min-height: 420px;
  resize: vertical;
}

.split-preview,
.crypto-results,
.base64-preview-wrap {
  flex: 1;
  min-height: 420px;
}

.split-preview {
  min-height: 420px;
}

.mode-toggle {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
}

.mode-option {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.92rem;
  cursor: pointer;
}

.crypto-results {
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--input-bg);
  padding: 0.75rem;
  display: grid;
  gap: 0.75rem;
}

.crypto-result-card {
  padding: 0.85rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
}

.crypto-result-card-error {
  border-color: rgba(220, 38, 38, 0.25);
}

.crypto-result-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.5rem;
}

.crypto-result-text {
  margin: 0;
  white-space: pre-wrap;
  word-break: break-all;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 0.82rem;
  line-height: 1.55;
}

.crypto-result-error {
  font-size: 0.85rem;
  color: var(--error);
}

.crypto-empty,
.base64-empty {
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  font-size: 0.92rem;
}

.upload-zone {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  text-align: center;
  cursor: pointer;
  background: var(--bg);
  transition: border-color 0.2s, background 0.2s;
}

.upload-zone:hover,
.upload-zone.dragover {
  border-color: var(--accent);
  background: var(--tag-bg);
}

.upload-title {
  font-weight: 600;
  margin-bottom: 0.35rem;
}

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

.base64-preview-wrap {
  position: relative;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--input-bg);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: auto;
  padding: 1rem;
}

.base64-preview {
  max-width: 100%;
  max-height: 100%;
  display: none;
}

.base64-meta {
  margin-top: 0.75rem;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.btn-outline {
  background: var(--surface);
  color: var(--text) !important;
  border: 1px solid var(--border);
  text-decoration: none !important;
}

.btn-outline:hover {
  background: var(--surface-hover);
  color: var(--text) !important;
  text-decoration: none !important;
}

.video-actions .btn,
.image-card-actions .btn {
  text-decoration: none;
}

.url-meta {
  margin-bottom: 1rem;
  font-size: 0.9rem;
  color: var(--text-muted);
}

.diff-grid,
.diff-result-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

.diff-pane h3 {
  font-size: 0.95rem;
  margin-bottom: 0.5rem;
}

.diff-output {
  min-height: 280px;
  padding: 0.85rem;
  background: var(--input-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-word;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 0.85rem;
  line-height: 1.6;
}

.diff-same {
  display: block;
  color: var(--text);
}

.diff-add {
  display: block;
  background: rgba(22, 163, 74, 0.18);
}

.diff-remove {
  display: block;
  background: rgba(220, 38, 38, 0.18);
}

.diff-empty {
  display: block;
  background: rgba(100, 116, 139, 0.08);
}

.time-results {
  display: grid;
  gap: 0.65rem;
  margin-bottom: 1rem;
}

.time-card {
  padding: 0.75rem 0.9rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 0.92rem;
}

.crypto-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.crypto-tab {
  padding: 0.45rem 0.85rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text-muted);
  cursor: pointer;
  font-size: 0.85rem;
}

.crypto-tab.active {
  background: var(--tag-bg);
  color: var(--accent);
  border-color: rgba(37, 99, 235, 0.35);
}

@media (max-width: 720px) {
  .diff-grid,
  .diff-result-grid,
  .split-panel {
    grid-template-columns: 1fr;
  }

  .split-panel-left,
  .split-panel-right {
    min-height: auto;
  }

  .split-textarea,
  .split-preview,
  .crypto-results,
  .base64-preview-wrap {
    min-height: 280px;
  }
}

/* Search tools */
.search-list,
.video-list {
  display: grid;
  gap: 1rem;
}

.search-item,
.video-item {
  padding: 1rem 1.1rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
}

.search-item h3,
.video-item h3 {
  font-size: 1rem;
  margin-bottom: 0.45rem;
}

.search-item a,
.video-item a {
  color: var(--accent);
  text-decoration: none;
}

.search-item a:hover,
.video-item a:hover {
  text-decoration: underline;
}

.search-meta {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 0.5rem;
}

.search-desc {
  font-size: 0.92rem;
  line-height: 1.65;
  margin-bottom: 0.55rem;
}

.search-link {
  display: block;
  font-size: 0.82rem;
  word-break: break-all;
  color: var(--text-muted) !important;
}

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

.image-card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
}

.image-card img {
  width: 100%;
  height: 180px;
  object-fit: cover;
  display: block;
  background: var(--surface-hover);
}

.image-card img.image-broken {
  object-fit: contain;
  padding: 1rem;
  background: var(--surface-hover);
}

.image-card-link {
  display: block;
  text-decoration: none;
}

.image-card-body {
  padding: 0.85rem;
}

.image-card-title {
  font-size: 0.92rem;
  font-weight: 600;
  margin-bottom: 0.35rem;
}

.image-card-meta {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 0.75rem;
}

.image-card-actions,
.video-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
}

.btn-small {
  padding: 0.35rem 0.75rem;
  font-size: 0.82rem;
}

.video-item {
  display: grid;
  grid-template-columns: 180px 1fr;
  gap: 1rem;
  align-items: start;
}

.video-thumb {
  width: 100%;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  border-radius: 8px;
  background: var(--surface-hover);
}

.video-tip {
  font-size: 0.8rem;
  color: var(--text-muted);
}

@media (max-width: 720px) {
  .video-item {
    grid-template-columns: 1fr;
  }
}
