:root {
  color-scheme: dark;
  --bg: #0b1020;
  --bg-glow: #1a2748;
  --panel: #121a2f;
  --panel-mix: color-mix(in srgb, #121a2f 92%, black);
  --border: #243049;
  --text: #e8eefc;
  --muted: #93a0bd;
  --accent: #6ea8ff;
  --accent-soft: #9ec5ff;
  --ok: #3dd68c;
  --bad: #ff6b7a;
  --chip: #1b2744;
  --quote: #1a243b;
  --surface: #0d1528;
  --surface-2: #0b1324;
  --surface-3: #121a2f;
  --input-bg: #0b1324;
  --btn-bg: #18233d;
  --on-accent: #081018;
  --danger-fg: #ffb4bc;
  --star: #fbbf24;
  --shadow: rgba(0, 0, 0, 0.35);
  --pager-bg: color-mix(in srgb, #0d1528 92%, black);
  --combo-side: color-mix(in srgb, #121a2f 80%, #000);
  --bar-track: #1a243b;
  --media-bg: #08101d;
  --theme-color: #0b1020;
  font-family: "Segoe UI", "Noto Sans TC", system-ui, sans-serif;
}

html[data-theme="light"] {
  color-scheme: light;
  --bg: #f3f6fb;
  --bg-glow: #d9e6fb;
  --panel: #ffffff;
  --panel-mix: #ffffff;
  --border: #cfd8ea;
  --text: #152033;
  --muted: #5b6b86;
  --accent: #2563eb;
  --accent-soft: #3b82f6;
  --ok: #059669;
  --bad: #dc2626;
  --chip: #e8eef9;
  --quote: #eef3fc;
  --surface: #ffffff;
  --surface-2: #f5f8fc;
  --surface-3: #eef2f9;
  --input-bg: #ffffff;
  --btn-bg: #e8eef9;
  --on-accent: #ffffff;
  --danger-fg: #b91c1c;
  --star: #d97706;
  --shadow: rgba(15, 23, 42, 0.1);
  --pager-bg: color-mix(in srgb, #ffffff 92%, #e2e8f0);
  --combo-side: #eef2f9;
  --bar-track: #e2e8f0;
  --media-bg: #f1f5f9;
  --theme-color: #f3f6fb;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  background: radial-gradient(1200px 600px at 10% -10%, var(--bg-glow), var(--bg));
  color: var(--text);
  min-height: 100vh;
  transition: background 0.2s ease, color 0.15s ease;
}
.app { max-width: 1100px; margin: 0 auto; padding: 28px 18px 80px; }
.btn-theme {
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 0.8rem;
  cursor: pointer;
  white-space: nowrap;
  line-height: 1.2;
}
.btn-theme:hover {
  border-color: var(--accent);
  color: var(--accent);
}
.defer-ob-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  user-select: none;
  margin: 0;
}
.defer-ob-toggle input {
  width: auto;
  margin: 0;
  accent-color: var(--accent);
}
.defer-ob-ui {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 5px 10px;
  background: var(--surface);
  font-size: 0.78rem;
  color: var(--muted);
}
.defer-ob-toggle input:checked + .defer-ob-ui {
  border-color: color-mix(in srgb, var(--accent) 50%, var(--border));
  color: var(--accent);
  background: color-mix(in srgb, var(--accent) 10%, var(--surface));
  font-weight: 600;
}
.pending-ob-badge {
  min-width: 1.25rem;
  padding: 0 5px;
  border-radius: 999px;
  background: #d97706;
  color: #fff;
  font-size: 0.7rem;
  font-weight: 700;
  text-align: center;
  font-variant-numeric: tabular-nums;
}
.pending-ob-badge.hidden {
  display: none !important;
}
html[data-theme="dark"] .pending-ob-badge {
  background: #f59e0b;
  color: #1a1200;
}
.library-pager {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 40;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--pager-bg);
  box-shadow: 0 8px 28px var(--shadow);
  backdrop-filter: blur(8px);
}
.library-pager[hidden] {
  display: none !important;
}
.pager-btn {
  min-width: 2.4rem;
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface-3);
  color: var(--text);
  font: inherit;
  font-weight: 700;
  letter-spacing: 0.04em;
  cursor: pointer;
  line-height: 1.2;
}
.pager-btn:hover:not(:disabled) {
  border-color: var(--accent);
  color: var(--accent);
}
.pager-btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}
.pager-ind {
  min-width: 3.6rem;
  text-align: center;
  font-size: 0.85rem;
  font-variant-numeric: tabular-nums;
  color: var(--muted);
  user-select: none;
  padding: 0 4px;
}
.header { display: flex; justify-content: space-between; gap: 16px; align-items: center; }
.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}
.brand-logo {
  flex: 0 0 auto;
  width: 40px;
  height: 40px;
  border-radius: 10px;
  display: block;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.25);
}
.brand h1 {
  margin: 0;
  font-size: 1.7rem;
  letter-spacing: 0.02em;
  line-height: 1.15;
}
h1 { margin: 0 0 6px; font-size: 1.7rem; letter-spacing: 0.02em; }
.muted { color: var(--muted); font-size: 0.92rem; }
.muted.small { font-size: 0.82rem; }
.pill {
  border: 1px solid var(--border);
  background: var(--panel);
  border-radius: 999px;
  padding: 8px 12px;
  font-size: 0.82rem;
  white-space: nowrap;
}
.status-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  justify-content: flex-end;
}
.btn-logout {
  border: 1px solid transparent;
  background: transparent;
  color: var(--muted);
  border-radius: 999px;
  padding: 6px 10px;
  font-size: 0.78rem;
  cursor: pointer;
  opacity: 0.75;
}
.btn-logout:hover {
  opacity: 1;
  color: var(--text);
  border-color: var(--border);
  background: var(--surface);
}
.status-ind {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1px solid var(--border);
  background: var(--panel);
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 0.82rem;
  white-space: nowrap;
}
.status-ind.sm {
  padding: 2px 8px;
  font-size: 0.75rem;
  font-weight: 500;
  vertical-align: middle;
  margin-left: 8px;
}
.status-ind .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #6b7280;
  box-shadow: 0 0 0 2px rgba(107, 114, 128, 0.25);
}
.status-ind.on .dot {
  background: var(--ok);
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--ok) 30%, transparent);
}
.status-ind.off .dot {
  background: #6b7280;
}
.status-ind.on {
  border-color: color-mix(in srgb, var(--ok) 45%, var(--border));
}
.status-ind.off {
  border-color: var(--border);
  color: var(--muted);
}
.status-ind.warn {
  border-color: color-mix(in srgb, #f59e0b 50%, var(--border));
  color: #b45309;
}
.status-ind.warn .dot {
  background: #f59e0b;
  box-shadow: 0 0 0 2px rgba(245, 158, 11, 0.3);
}
.settings-card h2 {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 4px;
}
.date-field {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.85rem;
  color: var(--muted);
  white-space: nowrap;
}
.date-field input[type="date"] {
  width: auto;
  min-width: 9.5rem;
  padding: 8px 10px;
}
.star-filter {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.85rem;
  color: var(--muted);
  white-space: nowrap;
}
.star-filter select {
  width: auto;
  min-width: 5.5rem;
  padding: 8px 10px;
  border-radius: 8px;
  border: 1px solid var(--border, #333);
  background: var(--input-bg);
  color: inherit;
  font: inherit;
}
.md-img-link {
  display: inline-block;
  max-width: 100%;
  line-height: 0;
}
.md-img-link:hover img {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
.md-figure a.md-img-link::after {
  content: " ↗ 原圖";
  display: block;
  margin-top: 4px;
  font-size: 0.78rem;
  line-height: 1.2;
  color: var(--muted);
}
.tabs { display: flex; gap: 8px; margin: 22px 0 14px; flex-wrap: wrap; }
.tab {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 10px;
  padding: 8px 14px;
  cursor: pointer;
}
.tab.active { background: var(--accent); color: var(--on-accent); border-color: transparent; font-weight: 600; }
.panel {
  background: var(--panel-mix);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 16px;
}
.hidden { display: none !important; }
.label { display: block; margin: 10px 0 6px; font-weight: 600; font-size: 0.9rem; }
.import-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin: 0 0 10px;
  flex-wrap: wrap;
}
.url-slots {
  display: grid;
  gap: 8px;
}
.url-slot {
  display: grid;
  grid-template-columns: 1.75rem 1fr;
  gap: 8px;
  align-items: center;
}
.url-slot-num {
  color: var(--muted);
  font-size: 0.82rem;
  font-variant-numeric: tabular-nums;
  text-align: right;
  user-select: none;
}
.url-slot input {
  width: 100%;
  padding: 9px 12px;
  font-size: 0.9rem;
}
textarea, input, select {
  width: 100%;
  background: var(--input-bg);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 12px;
  padding: 12px;
  font: inherit;
}
textarea { resize: vertical; line-height: 1.45; font-family: ui-monospace, Consolas, monospace; font-size: 0.9rem; }
.row { display: flex; align-items: center; gap: 12px; margin-top: 12px; flex-wrap: wrap; }
.row.tight { margin-top: 8px; }
.btn {
  border: 1px solid var(--border);
  background: var(--btn-bg);
  color: var(--text);
  border-radius: 10px;
  padding: 10px 14px;
  cursor: pointer;
  font: inherit;
}
.btn.primary { background: var(--accent); color: var(--on-accent); border-color: transparent; font-weight: 700; }
.btn.danger { border-color: color-mix(in srgb, var(--bad) 50%, var(--border)); color: var(--danger-fg); }
.btn.linkish { margin-top: 8px; padding: 6px 10px; font-size: 0.85rem; }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }
.results { margin-top: 10px; display: grid; gap: 6px; }
.card {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px;
  background: var(--surface);
}
.card.ok { border-color: color-mix(in srgb, var(--ok) 50%, var(--border)); }
.card.bad { border-color: color-mix(in srgb, var(--bad) 50%, var(--border)); }
.card.dup { border-color: color-mix(in srgb, #eab308 50%, var(--border)); }
.btn-star,
.btn-star-detail {
  border: 1px solid var(--border);
  background: transparent;
  color: var(--muted);
  border-radius: 8px;
  cursor: pointer;
  font-size: 1.05rem;
  line-height: 1;
  padding: 4px 8px;
  flex-shrink: 0;
}
.btn-star.on,
.btn-star-detail.on {
  color: var(--star);
  border-color: color-mix(in srgb, var(--star) 45%, var(--border));
}
.btn-star-detail {
  font-size: 0.85rem;
  padding: 6px 10px;
}
.item.is-starred {
  border-color: color-mix(in srgb, var(--star) 40%, var(--border));
}
.search-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 12px;
  align-items: center;
}
.search-combo {
  display: flex;
  align-items: stretch;
  flex: 1 1 260px;
  min-width: 200px;
  max-width: 100%;
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
  background: var(--input-bg);
}
.search-combo select {
  flex: 0 0 auto;
  width: auto;
  min-width: 5.5rem;
  border: none;
  border-right: 1px solid var(--border);
  border-radius: 0;
  padding: 8px 8px;
  background: var(--combo-side);
  color: inherit;
  font: inherit;
  font-size: 0.85rem;
  cursor: pointer;
}
.search-combo input[type="search"] {
  flex: 1 1 auto;
  min-width: 0;
  border: none;
  border-radius: 0;
  background: transparent;
  padding: 8px 10px;
}
.search-combo:focus-within {
  outline: 2px solid color-mix(in srgb, var(--accent, #38bdf8) 50%, transparent);
  outline-offset: 0;
}
.star-filter select {
  min-width: 5.5rem;
}
.btn-delete:disabled,
.btn-delete.is-locked {
  opacity: 0.45;
  cursor: not-allowed;
}
.library-layout {
  display: grid;
  grid-template-columns: minmax(240px, 340px) 1fr;
  gap: 14px;
  align-items: start;
}
@media (max-width: 860px) {
  .search-bar, .library-layout, .settings-grid { grid-template-columns: 1fr; }
  .header { flex-direction: column; }
}
.bulk-bar {
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  gap: 10px 14px;
  margin: 0 0 12px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
  overflow-x: auto;
  white-space: nowrap;
}
.bulk-check {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.88rem;
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
  flex-shrink: 0;
}
.bulk-bar .meta,
.bulk-bar .btn {
  flex-shrink: 0;
  white-space: nowrap;
}
.item-check-wrap {
  display: flex;
  align-items: center;
  padding: 2px 4px 0 0;
  cursor: pointer;
  flex-shrink: 0;
}
.item-check-wrap input {
  width: auto;
  margin: 0;
  accent-color: var(--accent);
}
.tag-panel {
  margin-bottom: 12px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
  overflow: hidden;
}
.tag-panel-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  margin: 0;
  padding: 8px 12px;
  border: none;
  background: transparent;
  color: var(--text);
  font: inherit;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  text-align: left;
}
.tag-panel-toggle:hover {
  background: color-mix(in srgb, var(--accent, #38bdf8) 8%, transparent);
}
.tag-panel-chevron {
  display: inline-block;
  width: 1em;
  color: var(--muted);
  transition: transform 0.15s ease;
  font-size: 0.85rem;
}
.tag-panel.is-open .tag-panel-chevron {
  transform: rotate(90deg);
}
.tag-panel-title {
  flex: 0 0 auto;
}
.tag-panel-count {
  margin-left: auto;
  font-weight: 400;
}
.tag-cloud {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 0 12px 12px;
  border-top: 1px solid transparent;
}
.tag-panel.is-open .tag-cloud {
  border-top-color: var(--border);
  padding-top: 10px;
}
.tag-cloud[hidden] {
  display: none !important;
}
.tag-cloud .chip.is-active {
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 18%, transparent);
}
.chip {
  background: var(--chip);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 0.82rem;
  cursor: pointer;
  color: var(--text);
}
.chip.mini { cursor: default; padding: 2px 8px; font-size: 0.75rem; }
.tags-line { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.list { display: grid; gap: 10px; max-height: 75vh; overflow: auto; }
.item {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px;
  background: var(--surface);
  cursor: pointer;
}
.item:hover { border-color: var(--accent); }
.item h3 { margin: 0; font-size: 1rem; line-height: 1.35; flex: 1; min-width: 0; }
.item-top {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  margin-bottom: 6px;
}
.item-top h2 { margin: 0; flex: 1; min-width: 0; font-size: 1.35rem; line-height: 1.35; }
.btn.sm { padding: 4px 10px; font-size: 0.8rem; flex-shrink: 0; }
.btn-delete { opacity: 0.85; }
.item:hover .btn-delete { opacity: 1; }
.meta { color: var(--muted); font-size: 0.82rem; line-height: 1.45; }
.author-line {
  margin: 6px 0 8px;
  font-size: 1rem;
  font-weight: 600;
  color: var(--text);
  line-height: 1.4;
}
.author-line .author-name {
  color: var(--accent);
  text-decoration: none;
  border-bottom: 1px solid color-mix(in srgb, var(--accent) 45%, transparent);
  padding-bottom: 1px;
}
.author-line .author-name:hover {
  color: var(--accent-soft);
  border-bottom-color: var(--accent-soft);
}
.item .author-line {
  font-size: 0.88rem;
  font-weight: 500;
  color: var(--muted);
}
.detail {
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 16px;
  background: var(--surface);
  min-height: 320px;
}
.detail-head h2 { margin: 0 0 8px; font-size: 1.35rem; line-height: 1.35; }
.media-gallery {
  display: grid;
  gap: 12px;
  margin: 14px 0;
}
.md-body {
  line-height: 1.7;
  font-size: 1rem;
  color: var(--text);
}
.md-body h1, .md-body h2, .md-body h3 {
  margin: 1.1em 0 0.5em;
  line-height: 1.3;
}
.md-body h1 { font-size: 1.4rem; }
.md-body h2 { font-size: 1.2rem; border-bottom: 1px solid var(--border); padding-bottom: 0.25em; }
.md-body h3 { font-size: 1.05rem; }
.md-body p { margin: 0.7em 0; white-space: pre-wrap; }
.md-body ul { margin: 0.6em 0; padding-left: 1.3em; }
.md-body li { margin: 0.25em 0; }
.md-body blockquote {
  margin: 0.9em 0;
  padding: 0.6em 0.9em;
  border-left: 3px solid var(--accent);
  background: var(--quote);
  border-radius: 0 10px 10px 0;
  color: #d5def3;
}
.md-body a { color: var(--accent); }
.md-body code {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.1em 0.35em;
  font-size: 0.9em;
}
.media-block {
  margin: 16px 0 8px;
  padding-top: 8px;
  border-top: 1px solid var(--border);
}
.media-count {
  margin-bottom: 10px;
}
.media-empty {
  margin: 12px 0;
  padding: 10px;
  border: 1px dashed var(--border);
  border-radius: 10px;
}
.md-figure {
  margin: 0.8em 0;
}
.md-figure.img-error {
  border: 1px dashed var(--bad);
  border-radius: 12px;
  padding: 8px;
  color: var(--bad);
  font-size: 0.85rem;
}
.md-figure img,
.media-gallery img,
.media-block img {
  display: block;
  max-width: 100%;
  height: auto;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--media-bg);
}
.md-video {
  margin: 0.8em 0;
}
.md-video video,
.media-gallery video {
  display: block;
  width: 100%;
  max-height: 70vh;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: #000;
}
.md-video-caption {
  margin-top: 6px;
  font-size: 0.85rem;
  color: var(--muted);
}
.md-raw {
  white-space: pre-wrap;
  word-break: break-word;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px;
  max-height: 60vh;
  overflow: auto;
  font-size: 0.86rem;
}
/* —— Stats tab —— */
.stats-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}
.stats-heading {
  margin: 0 0 4px;
  font-size: 1.25rem;
}
.stats-summary {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 10px;
  margin-bottom: 16px;
}
.stats-kpi {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px 14px;
  background: var(--surface);
}
.stats-kpi .kpi-label {
  font-size: 0.78rem;
  color: var(--muted);
  margin-bottom: 4px;
}
.stats-kpi .kpi-value {
  font-size: 1.45rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  font-variant-numeric: tabular-nums;
}
.stats-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}
.stats-card {
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 14px;
  background: var(--surface);
  min-width: 0;
}
.stats-card-wide { min-width: 0; }
.stats-card-full {
  grid-column: 1 / -1;
}
.stats-card-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 6px 12px;
  margin-bottom: 10px;
}
.stats-card-head h3 {
  margin: 0;
  font-size: 1.05rem;
}
.stats-table-wrap {
  overflow: auto;
  max-height: 420px;
}
.stats-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
}
.stats-table th,
.stats-table td {
  padding: 8px 10px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.stats-table th {
  position: sticky;
  top: 0;
  background: var(--surface-3);
  color: var(--muted);
  font-weight: 600;
  font-size: 0.8rem;
  z-index: 1;
}
.stats-table td.num,
.stats-table th.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}
.stats-table tr:hover td {
  background: color-mix(in srgb, var(--accent) 6%, transparent);
}
.stats-bar-cell {
  min-width: 80px;
  width: 28%;
}
.stats-bar {
  height: 8px;
  border-radius: 999px;
  background: var(--bar-track);
  overflow: hidden;
}
.stats-bar > i {
  display: block;
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, #3b82f6, #6ea8ff);
}
.stats-bar.followers > i {
  background: linear-gradient(90deg, #a78bfa, #f472b6);
}
.stats-bar.daily > i {
  background: linear-gradient(90deg, #34d399, #6ea8ff);
}
.stats-daily-chart {
  display: flex;
  align-items: flex-end;
  gap: 4px;
  min-height: 140px;
  padding: 8px 4px 4px;
  margin-bottom: 12px;
  border-bottom: 1px solid var(--border);
  overflow-x: auto;
}
.stats-day-col {
  flex: 0 0 40px;
  max-width: 48px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  min-height: 120px;
  justify-content: flex-end;
}
.stats-day-bars {
  display: flex;
  align-items: flex-end;
  gap: 2px;
  height: 100px;
  width: 100%;
  justify-content: center;
}
.stats-day-bar {
  width: 9px;
  border-radius: 4px 4px 0 0;
  background: #34d399;
  min-height: 2px;
}
.stats-day-bar.cum {
  width: 9px;
  background: color-mix(in srgb, #6ea8ff 70%, transparent);
}
.stats-day-label {
  font-size: 0.62rem;
  color: var(--muted);
  writing-mode: horizontal-tb;
  text-align: center;
  line-height: 1.15;
  white-space: nowrap;
}
.stats-day-val {
  font-size: 0.68rem;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}
.stats-author-link {
  color: var(--accent);
  text-decoration: none;
}
.stats-author-link:hover {
  text-decoration: underline;
}
.stats-tags-cloud {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 12px;
  max-height: 180px;
  overflow: auto;
  align-items: center;
}
.stats-tag-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 4px 10px;
  background: var(--chip);
  color: var(--text);
  font: inherit;
  font-size: 0.82rem;
  cursor: pointer;
  line-height: 1.3;
  text-decoration: none;
}
.stats-tag-chip:hover {
  border-color: var(--accent);
  color: var(--accent);
}
.stats-tag-chip .tag-n {
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  font-size: 0.78rem;
}
.stats-tag-chip.top {
  border-color: color-mix(in srgb, var(--accent) 50%, var(--border));
  background: color-mix(in srgb, var(--accent) 12%, var(--chip));
}
.stats-tag-link {
  color: var(--accent);
  font-weight: 600;
  text-decoration: none;
  border-bottom: 1px solid color-mix(in srgb, var(--accent) 40%, transparent);
}
.stats-tag-link:hover {
  color: var(--accent-soft);
  border-bottom-color: var(--accent-soft);
}
.stats-bar.tags > i {
  background: linear-gradient(90deg, #f59e0b, #fbbf24);
}
@media (max-width: 860px) {
  .stats-grid { grid-template-columns: 1fr; }
}

/* Import live process list — compact: 1–2 lines, don’t push results off-screen */
.import-progress {
  margin-top: 10px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
}
.import-progress-head {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 6px 10px;
  align-items: center;
  margin-bottom: 6px;
  font-size: 0.88rem;
}
.import-progress-head strong {
  font-size: 0.88rem;
  font-weight: 600;
}
.import-progress-bar {
  height: 4px;
  border-radius: 999px;
  background: var(--chip);
  border: 1px solid var(--border);
  overflow: hidden;
  margin-bottom: 6px;
}
.import-progress-bar > i {
  display: block;
  height: 100%;
  width: 0%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--accent), #34d399);
  transition: width 0.25s ease;
}
.import-process-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 3px;
  /* ~3 compact rows; more items scroll instead of eating the page */
  max-height: 5.5rem;
  overflow: auto;
}
.import-process-list li {
  display: grid;
  grid-template-columns: 1.25rem minmax(0, 1fr) auto;
  column-gap: 6px;
  align-items: center;
  padding: 3px 6px;
  border-radius: 6px;
  border: 1px solid transparent;
  background: transparent;
  font-size: 0.8rem;
  line-height: 1.25;
  min-height: 0;
}
.import-process-list li.run {
  border-color: color-mix(in srgb, var(--accent) 35%, var(--border));
  background: color-mix(in srgb, var(--accent) 6%, transparent);
}
.import-process-list li.ok {
  border-color: color-mix(in srgb, var(--ok) 25%, transparent);
}
.import-process-list li.dup {
  border-color: color-mix(in srgb, #eab308 30%, transparent);
}
.import-process-list li.bad {
  border-color: color-mix(in srgb, var(--bad) 30%, transparent);
}
.import-step-num {
  font-weight: 700;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  font-size: 0.75rem;
}
.import-step-main {
  min-width: 0;
  display: flex;
  flex-wrap: nowrap;
  align-items: baseline;
  gap: 6px;
  overflow: hidden;
}
.import-step-main .url {
  color: var(--muted);
  font-size: 0.75rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 0 1 auto;
  max-width: 42%;
}
.import-step-main .detail {
  margin: 0;
  color: var(--text);
  font-size: 0.8rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1 1 auto;
  min-width: 0;
}
.import-step-badge {
  font-size: 0.7rem;
  font-weight: 700;
  white-space: nowrap;
  padding: 1px 6px;
  border-radius: 999px;
  border: 1px solid var(--border);
  color: var(--muted);
  line-height: 1.3;
}
.import-step-badge.run {
  color: var(--accent);
  border-color: color-mix(in srgb, var(--accent) 40%, var(--border));
  animation: import-pulse 1.2s ease-in-out infinite;
}
.import-step-badge.ok {
  color: var(--ok);
  border-color: color-mix(in srgb, var(--ok) 40%, var(--border));
}
.import-step-badge.dup {
  color: #ca8a04;
  border-color: color-mix(in srgb, #eab308 40%, var(--border));
}
.import-step-badge.bad {
  color: var(--bad);
  border-color: color-mix(in srgb, var(--bad) 40%, var(--border));
}
@keyframes import-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.45; }
}

.user-note-box {
  margin-top: 16px;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface-2);
}
.user-note-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 8px;
}
.user-note-box textarea {
  width: 100%;
  min-height: 5rem;
  resize: vertical;
  font-family: inherit;
  font-size: 0.92rem;
  line-height: 1.5;
}
.notes-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 8px;
}
.notes-list {
  display: grid;
  gap: 12px;
}
.note-card {
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 14px 16px;
  background: var(--surface);
  cursor: pointer;
  transition: border-color 0.15s ease;
}
.note-card:hover {
  border-color: var(--accent);
}
.note-card-top {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 12px;
  align-items: baseline;
  margin-bottom: 6px;
}
.note-date {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--accent);
  font-variant-numeric: tabular-nums;
}
.note-title {
  margin: 0 0 8px;
  font-size: 1rem;
  line-height: 1.35;
}
.note-body {
  margin: 0 0 12px;
  white-space: pre-wrap;
  line-height: 1.55;
  font-size: 0.95rem;
  color: var(--text);
}
.note-card-foot {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  justify-content: space-between;
}
.note-card-foot a {
  color: var(--accent);
  font-size: 0.88rem;
}
.note-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}
.note-edit textarea {
  width: 100%;
  margin: 8px 0;
  font: inherit;
  font-size: 0.92rem;
  line-height: 1.5;
}
.note-card.note-card {
  cursor: default;
}
.note-card:hover {
  border-color: var(--border);
}

/* Infinitum-like model API panel */
.model-api-panel-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 10px;
}
.model-api-active-banner {
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: 14px;
  padding: 14px 16px;
  margin-bottom: 14px;
}
.model-api-active-banner .active-banner-label {
  font-size: 0.85rem;
  color: var(--text);
  margin-bottom: 10px;
  font-weight: 700;
}
.mapi-enabled-summary {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 8px;
}
.mapi-enabled-summary li {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 10px;
  padding: 8px 10px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface-2);
}
.mapi-enabled-summary li.is-current {
  border-color: color-mix(in srgb, var(--accent) 50%, var(--border));
  background: color-mix(in srgb, var(--accent) 8%, var(--surface));
}
.mapi-sum-rank {
  width: 1.4rem;
  height: 1.4rem;
  border-radius: 999px;
  background: var(--accent);
  color: var(--on-accent);
  font-size: 0.75rem;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.mapi-sum-name {
  font-weight: 600;
  min-width: 5rem;
}
.model-api-list {
  display: grid;
  gap: 16px;
  margin-top: 4px;
}
.mapi-empty {
  text-align: center;
  padding: 28px 16px;
  border: 1px dashed var(--border);
  border-radius: 14px;
}
.model-api-card {
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 16px 18px;
  background: var(--surface);
}
.model-api-card.is-active {
  border-color: color-mix(in srgb, var(--accent) 40%, var(--border));
}
.model-api-card.is-legacy {
  border-style: dashed;
}
.mapi-legacy-note {
  margin: 10px 0 0;
  font-size: 0.85rem;
  color: var(--muted);
  line-height: 1.45;
}
.model-api-card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}
.mapi-title-line {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}
.mapi-name {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 700;
}
.mapi-inf-fields {
  display: grid;
  gap: 6px;
  font-size: 0.9rem;
  color: var(--muted);
}
.mapi-inf-fields > div {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 8px;
}
.mapi-label {
  font-weight: 600;
  color: var(--text);
  flex: 0 0 auto;
}
.mapi-code {
  font-family: ui-monospace, Consolas, monospace;
  font-size: 0.86rem;
  padding: 2px 8px;
  border-radius: 6px;
  background: var(--chip);
  border: 1px solid var(--border);
  color: var(--text);
  word-break: break-all;
}
.mapi-key-code {
  letter-spacing: 0.04em;
}
/* Highlight last-4 serial so each key is identifiable */
.mapi-key-serial {
  color: var(--accent);
  font-weight: 800;
  letter-spacing: 0.08em;
  margin-left: 1px;
}
.mapi-key-id-tag {
  font-size: 0.8rem;
  color: var(--muted);
  padding: 2px 8px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--chip);
}
.mapi-key-id-tag strong {
  color: var(--accent);
  font-family: ui-monospace, Consolas, monospace;
  letter-spacing: 0.06em;
}
.mapi-key-row {
  align-items: center !important;
}
.mapi-counters {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 4px;
}
.mapi-counter {
  font-size: 0.8rem;
  padding: 3px 8px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--chip);
  color: var(--muted);
}
.mapi-counter b {
  color: var(--text);
  font-variant-numeric: tabular-nums;
  margin-right: 2px;
}
.mapi-counter.ok b { color: var(--ok); }
.mapi-counter.bad b { color: var(--bad); }
.mapi-counter.limit b { color: #d97706; }
html[data-theme="dark"] .mapi-counter.limit b { color: #fbbf24; }
.badge {
  display: inline-block;
  font-size: 0.72rem;
  padding: 2px 8px;
  border-radius: 999px;
  border: 1px solid var(--border);
  color: var(--muted);
  background: var(--chip);
  font-weight: 600;
}
.badge.default {
  color: #1d4ed8;
  border-color: color-mix(in srgb, #3b82f6 40%, var(--border));
  background: color-mix(in srgb, #3b82f6 14%, transparent);
}
html[data-theme="dark"] .badge.default {
  color: #93c5fd;
}
.badge.on {
  color: #047857;
  border-color: color-mix(in srgb, var(--ok) 40%, var(--border));
  background: color-mix(in srgb, var(--ok) 14%, transparent);
}
html[data-theme="dark"] .badge.on {
  color: #6ee7b7;
}
.badge.using {
  color: #b45309;
  border-color: color-mix(in srgb, #f59e0b 45%, var(--border));
  background: color-mix(in srgb, #f59e0b 16%, transparent);
}
html[data-theme="dark"] .badge.using {
  color: #fcd34d;
}
.badge.rank {
  color: var(--accent);
  border-color: color-mix(in srgb, var(--accent) 35%, var(--border));
}
.badge.off {
  color: var(--muted);
}
.model-api-icon-actions {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
}
.model-api-icon-actions .btn.sm {
  white-space: nowrap;
}
.icon-btn {
  width: 2rem;
  height: 2rem;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 0.95rem;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.icon-btn:hover:not(:disabled) {
  border-color: var(--border);
  color: var(--text);
  background: var(--chip);
}
.icon-btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}
.icon-btn.danger:hover:not(:disabled) {
  color: var(--bad);
  border-color: color-mix(in srgb, var(--bad) 40%, var(--border));
}
.model-api-form {
  margin-top: 14px;
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 16px;
  background: var(--surface-2);
}
.model-api-form h3 {
  margin: 0 0 10px;
  font-size: 1rem;
}
.ai-status-chain {
  display: grid;
  gap: 8px;
  margin: 12px 0;
}
.ai-chain-item {
  display: grid;
  grid-template-columns: 2rem 1fr auto;
  gap: 10px;
  align-items: start;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px 12px;
  background: var(--surface);
}
.ai-chain-rank {
  width: 1.6rem;
  height: 1.6rem;
  border-radius: 999px;
  background: var(--accent);
  color: var(--on-accent);
  font-size: 0.8rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
}
.ai-status-h3 {
  margin: 16px 0 8px;
  font-size: 0.95rem;
}
.event-pill {
  display: inline-block;
  font-size: 0.75rem;
  padding: 2px 8px;
  border-radius: 999px;
  border: 1px solid var(--border);
}
.event-pill.success {
  color: var(--ok);
  border-color: color-mix(in srgb, var(--ok) 40%, var(--border));
}
.event-pill.failure,
.event-pill.exhausted {
  color: var(--bad);
  border-color: color-mix(in srgb, var(--bad) 40%, var(--border));
}
.event-pill.fallback,
.event-pill.attempt {
  color: var(--accent);
  border-color: color-mix(in srgb, var(--accent) 40%, var(--border));
}

.settings-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}
.settings-card-wide {
  grid-column: 1 / -1;
}
.settings-card {
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 14px;
  background: var(--surface);
}
.settings-card h2 { margin: 0 0 8px; font-size: 1.1rem; }
.help-list {
  margin: 8px 0 12px 1.1em;
  padding: 0;
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.5;
}
.help-list code, .settings-card code {
  background: var(--surface-2);
  border-radius: 4px;
  padding: 0 4px;
  font-size: 0.8em;
}

/* —— Backup / import —— */
.backup-card .backup-h3 {
  margin: 0 0 8px;
  font-size: 0.95rem;
  font-weight: 600;
}
.backup-section {
  padding: 10px 0;
  border-top: 1px dashed color-mix(in srgb, var(--border) 70%, transparent);
}
.backup-section:first-of-type {
  border-top: none;
  padding-top: 4px;
}
.backup-checks {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 14px;
  margin-bottom: 10px;
}
.backup-select {
  max-width: 360px;
  width: 100%;
}
.backup-file {
  font-size: 0.85rem;
  max-width: 100%;
  color: var(--muted);
}
.backup-preview {
  margin-top: 8px;
  padding: 8px 10px;
  border-radius: 8px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  white-space: pre-wrap;
  line-height: 1.45;
  font-size: 0.82rem;
}
.backup-preview:empty {
  display: none;
}

/* —— X Cookie: quiet set-and-forget strip —— */
.cookie-strip {
  padding: 10px 14px;
  background: color-mix(in srgb, var(--surface) 70%, transparent);
  border-color: color-mix(in srgb, var(--border) 80%, transparent);
}
.cookie-strip-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}
.cookie-strip-title {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  min-width: 0;
}
.cookie-strip-label {
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--muted);
  letter-spacing: 0.01em;
}
.cookie-strip-meta {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.75rem;
  opacity: 0.85;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: min(48vw, 420px);
}
.cookie-strip-actions {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}
.btn.ghost {
  background: transparent;
  border: 1px solid transparent;
  color: var(--muted);
  box-shadow: none;
}
.btn.ghost:hover {
  color: var(--text);
  background: var(--surface-2);
  border-color: var(--border);
}
.btn.ghost.danger-text:hover {
  color: var(--bad);
  border-color: color-mix(in srgb, var(--bad) 35%, var(--border));
  background: color-mix(in srgb, var(--bad) 8%, transparent);
}
.cookie-editor {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px dashed color-mix(in srgb, var(--border) 70%, transparent);
}
.cookie-hint {
  margin: 0 0 8px;
  line-height: 1.45;
}
.cookie-help {
  display: inline;
  margin-left: 4px;
}
.cookie-help summary {
  display: inline;
  cursor: pointer;
  color: var(--accent);
  font-size: 0.8rem;
}
.cookie-help summary:hover {
  text-decoration: underline;
}
.cookie-help .help-list {
  margin: 6px 0 0 1.1em;
  display: block;
}
.cookie-editor-row {
  display: flex;
  gap: 8px;
  align-items: stretch;
}
.cookie-editor-row input {
  flex: 1;
  min-width: 0;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.82rem;
  padding: 8px 10px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
}
.cookie-editor-row input:focus {
  outline: none;
  border-color: color-mix(in srgb, var(--accent) 55%, var(--border));
}
.cookie-editor-row .btn {
  flex-shrink: 0;
}
.cookie-strip.is-open .cookie-strip-label {
  color: var(--text);
}
