:root {
  --bg: #0d1117;
  --bg-soft: #141a23;
  --panel: #182130;
  --panel-2: #1d2938;
  --border: #2c3a4d;
  --text: #e6edf3;
  --muted: #96a4b5;
  --accent: #4f9cf9;
  --accent-strong: #2f7de3;
  --green: #3fb27f;
  --yellow: #e3b341;
  --red: #d95f6b;
  --purple: #9d7bd8;
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.28);
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: var(--bg);
}

body {
  margin: 0;
  min-height: 100%;
  background:
    radial-gradient(circle at 12% -10%, rgba(79, 156, 249, 0.18), transparent 34rem),
    radial-gradient(circle at 90% 10%, rgba(157, 123, 216, 0.14), transparent 28rem),
    var(--bg);
  color: var(--text);
  font-family:
    -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei",
    sans-serif;
  line-height: 1.5;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

.app {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: 36px 0 64px;
}

.hero {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 28px;
  margin-bottom: 28px;
  flex-wrap: wrap;
}

.hero-title {
  display: flex;
  align-items: center;
  gap: 14px;
}

.logo {
  width: 58px;
  height: 58px;
  object-fit: cover;
  background: #0b0f16;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 18px;
  box-shadow: var(--shadow);
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 3px;
  font-size: clamp(24px, 4vw, 34px);
  letter-spacing: -0.02em;
}

.hero p {
  margin-bottom: 0;
  color: var(--muted);
}

.search-box {
  display: flex;
  width: min(100%, 480px);
  padding: 6px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: var(--shadow);
}

.search-box input {
  min-width: 0;
  flex: 1;
  padding: 12px 14px;
  color: var(--text);
  background: transparent;
  border: 0;
  outline: none;
}

.search-box input::placeholder {
  color: #718096;
}

.search-box button,
.add-button {
  padding: 11px 18px;
  color: white;
  background: linear-gradient(135deg, var(--accent), var(--accent-strong));
  border: 0;
  border-radius: 11px;
  font-weight: 700;
  white-space: nowrap;
  transition:
    transform 0.15s ease,
    filter 0.15s ease;
}

.search-box button:hover,
.add-button:hover {
  filter: brightness(1.08);
  transform: translateY(-1px);
}

.export-button {
  padding: 9px 14px;
  color: var(--text);
  background-color: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
  transition: border-color 0.15s ease, background-color 0.15s ease;
}

.export-button:hover {
  border-color: rgba(79, 156, 249, 0.5);
  background-color: var(--bg-soft);
}

.add-button:disabled {
  cursor: not-allowed;
  filter: none;
  transform: none;
  background: var(--panel-2);
  color: var(--muted);
}

.stats {
  margin-bottom: 20px;
}

.stats-summary {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

.stats-summary strong {
  color: var(--text);
}

.library-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
  flex-wrap: wrap;
}

.status-tabs {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.status-tab {
  padding: 9px 14px;
  color: var(--muted);
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 999px;
  transition:
    color 0.15s ease,
    border-color 0.15s ease,
    background 0.15s ease;
}

.status-tab:hover {
  color: var(--text);
}

.status-tab.active {
  color: white;
  background: var(--accent-strong);
  border-color: var(--accent-strong);
}

.status-count {
  margin-left: 5px;
  opacity: 0.7;
  font-size: 12px;
}

#local-filter {
  width: min(100%, 260px);
  padding: 10px 13px;
  color: var(--text);
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  outline: none;
}

#local-filter:focus {
  border-color: var(--accent);
}

.entries-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 18px;
  align-items: start;
}

.results-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 18px;
}

.anime-card,
.search-card {
  overflow: hidden;
  background: linear-gradient(180deg, var(--panel), var(--bg-soft));
  border: 1px solid var(--border);
  border-radius: 20px;
  box-shadow: 0 12px 34px rgba(0, 0, 0, 0.18);
  transition:
    transform 0.18s ease,
    border-color 0.18s ease;
}

.anime-card:hover,
.search-card:hover {
  transform: translateY(-2px);
  border-color: rgba(79, 156, 249, 0.5);
}

.cover-wrap {
  position: relative;
  overflow: hidden;
  background: #0a0f16;
}

.cover {
  width: 100%;
  height: auto;
  display: block;
  filter: saturate(0.9);
  transition: transform 0.35s ease, filter 0.35s ease;
}

.anime-card:hover .cover {
  transform: scale(1.05);
  filter: saturate(1.05);
}

.cover-wrap::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, transparent 62%, rgba(13, 17, 23, 0.85) 100%);
  pointer-events: none;
}

.bangumi-score {
  position: absolute;
  right: 12px;
  bottom: 12px;
  z-index: 1;
  padding: 5px 9px;
  color: #ffe28a;
  background: rgba(13, 17, 23, 0.72);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 999px;
  font-size: 13px;
  font-weight: 800;
  backdrop-filter: blur(8px);
}

.card-body {
  padding: 18px;
}

.title-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.title {
  margin-bottom: 5px;
  font-size: 19px;
  line-height: 1.3;
}

.bgm-link {
  flex: 0 0 auto;
  color: var(--accent);
  text-decoration: none;
  font-size: 13px;
}

.meta {
  min-height: 20px;
  margin-bottom: 10px;
  color: var(--muted);
  font-size: 13px;
}

.director {
  min-height: 18px;
  margin-bottom: 8px;
  color: #bdc8d4;
  font-size: 13px;
}

.summary {
  display: -webkit-box;
  min-height: 42px;
  margin-bottom: 15px;
  overflow: hidden;
  color: #c6d0da;
  font-size: 13px;
  line-height: 1.6;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

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

.field > span:first-child {
  color: var(--muted);
  font-size: 12px;
}

.field select,
.field input,
.field textarea {
  width: 100%;
  padding: 9px 10px;
  color: var(--text);
  background: #101722;
  border: 1px solid var(--border);
  border-radius: 10px;
  outline: none;
  resize: vertical;
}

.field select:focus,
.field input:focus,
.field textarea:focus {
  border-color: var(--accent);
}

.field-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.eps-text {
  display: grid;
  min-height: 38px;
  place-items: center;
  padding: 9px 10px;
  color: var(--text);
  background: #101722;
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 13px;
}

.card-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
  margin-top: 4px;
}

.delete-button {
  position: absolute;
  top: 10px;
  left: 10px;
  z-index: 3;
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  padding: 0;
  color: #fff;
  background: rgba(13, 17, 23, 0.72);
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 50%;
  font-size: 20px;
  line-height: 1;
  backdrop-filter: blur(8px);
  transition:
    background 0.15s ease,
    border-color 0.15s ease;
}

.delete-button:hover {
  background: rgba(217, 95, 107, 0.85);
  border-color: rgba(255, 255, 255, 0.5);
}

.updated-at {
  color: #6f7d8e;
  font-size: 11px;
}

.empty-state {
  padding: 70px 20px;
  text-align: center;
  color: var(--muted);
  border: 1px dashed var(--border);
  border-radius: 22px;
}

.empty-icon {
  font-size: 48px;
}

.empty-state h2 {
  margin: 16px 0 6px;
  color: var(--text);
}

.search-results {
  margin-bottom: 34px;
  padding: 20px;
  background: rgba(20, 26, 35, 0.68);
  border: 1px solid var(--border);
  border-radius: 22px;
}

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.section-head h2 {
  margin-bottom: 0;
  font-size: 20px;
}

.ghost-button {
  padding: 7px 12px;
  color: var(--muted);
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 9px;
}

.muted {
  color: var(--muted);
}

.search-card {
  display: grid;
  grid-template-columns: 132px 1fr;
  grid-template-rows: auto 1fr auto;
  min-height: 150px;
}

.search-cover {
  grid-row: 1 / -1;
  width: 132px;
  height: 100%;
  min-height: 150px;
  object-fit: cover;
  background: #0a0f16;
  transition: transform 0.35s ease;
}

.search-card:hover .search-cover {
  transform: scale(1.04);
}

.search-info {
  padding: 14px 15px 8px;
}

.search-title {
  margin-bottom: 5px;
  font-size: 16px;
}

.search-meta {
  margin-bottom: 5px;
  color: var(--muted);
  font-size: 12px;
}

.search-summary {
  display: -webkit-box;
  margin-bottom: 8px;
  overflow: hidden;
  color: #bdc8d4;
  font-size: 12px;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.search-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 0 15px 14px;
}

.search-rating {
  color: #ffe28a;
  font-weight: 800;
}

.toast {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 20;
  max-width: min(360px, calc(100vw - 44px));
  padding: 12px 16px;
  color: white;
  background: #202b38;
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: var(--shadow);
  opacity: 0;
  pointer-events: none;
  transform: translateY(12px);
  transition:
    opacity 0.2s ease,
    transform 0.2s ease;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

.toast.error {
  border-color: rgba(217, 95, 107, 0.7);
}

.hidden {
  display: none !important;
}

}

/* ── 列表视图 & 视图切换 ─────────────────────────── */
.view-toggle {
  flex: 0 0 auto;
  padding: 9px 14px;
  color: var(--text);
  background-color: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
  transition: border-color 0.15s ease, background-color 0.15s ease;
}

.view-toggle:hover {
  border-color: rgba(79, 156, 249, 0.5);
  background-color: var(--bg-soft);
}

.sort-select {
  flex: 0 0 auto;
  padding: 9px 30px 9px 14px;
  color: var(--text);
  background-color: var(--panel);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2396a4b5' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  border: 1px solid var(--border);
  border-radius: 12px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
  transition: border-color 0.15s ease, background 0.15s ease;
}

.sort-select:hover {
  border-color: rgba(79, 156, 249, 0.5);
  background-color: var(--bg-soft);
}

.filter-toggle {
  display: none;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  padding: 0;
  color: var(--text);
  background-color: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
  transition: border-color 0.15s ease;
}

.filter-toggle:hover {
  border-color: rgba(79, 156, 249, 0.5);
}

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

.anime-list-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 10px 12px;
  background: linear-gradient(180deg, var(--panel), var(--bg-soft));
  border: 1px solid var(--border);
  border-radius: 16px;
  transition: border-color 0.18s ease, transform 0.18s ease;
}

.anime-list-item:hover {
  border-color: rgba(79, 156, 249, 0.5);
  transform: translateY(-1px);
}

.list-cover {
  width: 84px;
  height: 118px;
  min-width: 84px;
  flex: 0 0 84px;
  object-fit: cover;
  display: block;
  border-radius: 8px;
  background: #0a0f16;
  filter: saturate(0.9);
  overflow: hidden;
}

.list-info {
  flex: 1 1 0%;
  min-width: 0;
  overflow: hidden;
}

.list-title {
  margin: 0;
  font-size: 16px;
  line-height: 1.35;
  min-width: 0;
  word-break: break-word;
}

.list-badges {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 3px 0 4px;
  flex-wrap: wrap;
}

.anime-list-item .bgm-link {
  font-size: 12px;
  flex: 0 0 auto;
}

.anime-list-item .meta {
  min-height: 0;
  margin-bottom: 4px;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.list-score {
  flex: 0 0 auto;
  color: #ffe28a;
  font-weight: 800;
  font-size: 12px;
}

.anime-list-item .summary {
  min-height: 0;
  margin-bottom: 4px;
  overflow-wrap: anywhere;
  word-break: break-word;
  max-height: 3.9em;
  line-height: 1.3;
  overflow: hidden;
}

.list-actions {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 8px;
  flex: 0 0 auto;
  align-self: center;
}

.anime-list-item .delete-button {
  position: static;
  width: auto;
  height: auto;
  padding: 5px 12px;
  border-radius: 999px;
  font-size: 12px;
  line-height: 1;
  display: inline-flex;
  align-items: center;
}

.anime-list-item .updated-at {
  font-size: 11px;
}


@media (max-width: 620px) {
  .app {
    width: min(100% - 20px, 1180px);
    padding-top: 22px;
  }

  .hero {
    align-items: stretch;
    flex-direction: column;
  }

  .search-box {
    width: 100%;
  }

  .entries-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .results-grid {
    grid-template-columns: 1fr;
  }

  .library-toolbar {
    align-items: center;
    flex-direction: row;
    flex-wrap: wrap;
    gap: 8px;
  }

  .filter-toggle {
    display: inline-flex;
  }

  #local-filter {
    display: none;
    width: auto;
  }

  .library-toolbar.filter-open #local-filter {
    display: block;
    flex: 1 1 100%;
  }

  .sort-select {
    padding: 9px 30px 9px 12px;
    font-size: 12px;
    flex: 0 0 auto;
  }

  .view-toggle {
    width: auto;
    padding: 9px 12px;
    font-size: 12px;
  }

  .export-button {
    align-self: flex-start;
    padding: 9px 12px;
    font-size: 12px;
  }

  .anime-list-item {
    flex-wrap: wrap;
  }

  .anime-list-item .list-actions {
    flex: 1 1 100%;
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    margin-top: 2px;
  }


/* ── 强制控件外观（不被 WebView/UA 默认样式覆盖成原生浅色，2026-08-26）── */
.filter-toggle,
.sort-select,
.view-toggle,
.export-button {
  color: var(--text) !important;
  background-color: var(--panel) !important;
  border: 1px solid var(--border) !important;
  border-radius: 12px !important;
  font-weight: 600 !important;
  -webkit-appearance: none !important;
  appearance: none !important;
}
.filter-toggle:hover,
.sort-select:hover,
.view-toggle:hover,
.export-button:hover {
  border-color: rgba(79, 156, 249, 0.5) !important;
  background-color: var(--bg-soft) !important;
}

/* ── 添加密码弹窗（2026-08-26）── */
.password-modal {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(0, 0, 0, 0.55);
  z-index: 1000;
}
.password-modal.hidden {
  display: none;
}
.password-modal-card {
  width: min(100%, 320px);
  background: linear-gradient(180deg, var(--panel), var(--bg-soft));
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 18px;
  box-shadow: var(--shadow);
}
.password-modal-card h3 {
  margin: 0 0 4px;
}
.password-modal-card .muted {
  margin: 0 0 12px;
}
#password-input {
  width: 100%;
  padding: 10px 12px;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text);
  font-size: 15px;
  box-sizing: border-box;
}
#password-input:focus {
  outline: none;
  border-color: rgba(79, 156, 249, 0.6);
}
.password-modal-actions {
  display: flex;
  gap: 10px;
  margin-top: 14px;
  justify-content: flex-end;
}
