:root {
  --bg: #0d0f13;
  --surface: #151922;
  --surface-2: #1c2230;
  --text: #f6f7fb;
  --muted: #9da6b5;
  --border: #2a3242;
  --accent: #8fa7ff;
  --accent-strong: #6f8cff;
  --danger: #ff8b93;
  --radius: 18px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}
* { box-sizing: border-box; }
html { background: var(--bg); color: var(--text); }
body { margin: 0; min-width: 320px; background: radial-gradient(circle at 50% -20%, #202a46 0, var(--bg) 42%); min-height: 100vh; }
a { color: inherit; text-decoration: none; }
button, input { font: inherit; }
.app-shell { width: min(1180px, 100%); margin: 0 auto; padding: 0 16px 48px; }
.topbar { min-height: 68px; display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.brand { display: inline-flex; align-items: center; gap: 9px; font-weight: 800; letter-spacing: -0.03em; }
.brand-icon { width: 30px; height: 30px; border-radius: 8px; flex: 0 0 auto; box-shadow: 0 0 0 1px rgba(255,255,255,.08); }
.topbar-actions { display: flex; align-items: center; gap: 10px; }
.nickname { color: var(--muted); max-width: 140px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.page { padding-top: 28px; }
.center-card { width: min(520px, 100%); margin: 10vh auto 0; padding: 28px; border: 1px solid var(--border); background: color-mix(in srgb, var(--surface) 92%, transparent); border-radius: 24px; box-shadow: 0 24px 70px rgba(0,0,0,.25); }
.hero-card h1, .library-head h1, .center-card h1 { margin: 8px 0 12px; line-height: 1.05; letter-spacing: -.04em; }
.hero-card h1 { font-size: clamp(2rem, 9vw, 3.4rem); }
.eyebrow { color: var(--accent); font-weight: 700; font-size: .82rem; text-transform: uppercase; letter-spacing: .12em; }
.muted, .empty-state p, .franchise-card p { color: var(--muted); }
.notice { margin: 18px 0; padding: 12px 14px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface-2); color: var(--muted); }
.button { display: inline-flex; min-height: 44px; align-items: center; justify-content: center; border: 1px solid var(--border); border-radius: 12px; padding: 0 16px; cursor: pointer; background: var(--surface-2); color: var(--text); }
.button.primary { border-color: transparent; background: var(--accent-strong); color: white; font-weight: 700; }
.button.ghost { background: transparent; }
.button.wide { width: 100%; margin-top: 8px; }
.stack-form { display: grid; gap: 10px; margin-top: 22px; }
.stack-form input, .search-box input { width: 100%; border: 1px solid var(--border); background: #0f131b; color: var(--text); outline: none; }
.stack-form input { height: 48px; border-radius: 12px; padding: 0 14px; }
.stack-form input:focus, .search-box:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 18%, transparent); }
.field-error { color: var(--danger); font-size: .9rem; }
.library-head { display: flex; justify-content: space-between; align-items: end; margin-bottom: 22px; }
.library-head h1 { font-size: clamp(2rem, 7vw, 3.2rem); }
.search-panel { position: relative; z-index: 5; }
.search-box { min-height: 58px; display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 10px; padding: 0 16px; border: 1px solid var(--border); border-radius: 16px; background: var(--surface); transition: .15s ease; }
.search-box input { height: 56px; border: 0; padding: 0; background: transparent; font-size: 1rem; }
.search-state { color: var(--muted); font-size: .82rem; }
.search-results { margin-top: 10px; padding: 8px; border: 1px solid var(--border); border-radius: 16px; background: var(--surface); max-height: min(66vh, 620px); overflow: auto; }
.search-result { display: grid; grid-template-columns: 48px minmax(0, 1fr); gap: 12px; padding: 9px; border-radius: 12px; }
.search-result:hover { background: var(--surface-2); }
.search-result img, .search-result .poster-placeholder { width: 48px; height: 68px; object-fit: cover; border-radius: 8px; background: var(--surface-2); }
.search-result-title { margin: 2px 0 5px; font-weight: 700; }
.search-result-meta { color: var(--muted); font-size: .86rem; }
.empty-state { min-height: 42vh; display: grid; place-content: center; text-align: center; padding: 38px 18px; }
.empty-state h2 { margin: 12px 0 4px; }
.empty-icon { font-size: 2.2rem; color: var(--muted); }
.franchise-grid { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 14px; margin-top: 26px; }
.franchise-card { overflow: hidden; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
.cover-placeholder { aspect-ratio: 2 / 3; display: grid; place-items: center; font-size: 4rem; color: var(--muted); background: var(--surface-2); }
.franchise-card-body { padding: 14px; }
.franchise-card h2 { margin: 0; font-size: 1rem; }
.franchise-card p { margin: 5px 0 0; font-size: .86rem; }
@media (min-width: 700px) {
  .app-shell { padding-left: 28px; padding-right: 28px; }
  .page { padding-top: 56px; }
  .center-card { padding: 38px; }
  .search-box { min-height: 66px; padding: 0 20px; }
  .search-box input { height: 64px; font-size: 1.08rem; }
  .franchise-grid { grid-template-columns: repeat(4, minmax(0,1fr)); gap: 18px; }
}
@media (min-width: 1050px) {
  .franchise-grid { grid-template-columns: repeat(6, minmax(0,1fr)); }
}
@media (prefers-color-scheme: light) {
  :root { --bg:#f5f7fb; --surface:#fff; --surface-2:#eef1f7; --text:#171a21; --muted:#687184; --border:#dde2ec; --accent:#526fd2; --accent-strong:#4e6ee0; }
  body { background: radial-gradient(circle at 50% -20%, #dfe7ff 0, var(--bg) 42%); }
  .stack-form input { background: #fff; }
}
.search-result { grid-template-columns: 48px minmax(0, 1fr) auto; align-items: center; cursor: pointer; }
.search-result:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.search-result-main { min-width: 0; }
.add-anime-button { min-height: 38px; padding: 0 12px; }
.add-anime-button:disabled { opacity: .65; cursor: wait; }
.franchise-head { margin-bottom: 20px; }
.franchise-head h1 { margin: 8px 0 0; font-size: clamp(2rem, 7vw, 3.2rem); letter-spacing: -.04em; }
.back-link { display: inline-block; margin-bottom: 24px; color: var(--muted); }
.kind-filters { display: flex; gap: 8px; overflow-x: auto; padding: 4px 0 14px; scrollbar-width: thin; }
.filter-chip { flex: 0 0 auto; display: inline-flex; align-items: center; gap: 7px; min-height: 38px; padding: 0 12px; border: 1px solid var(--border); border-radius: 999px; background: var(--surface); color: var(--muted); cursor: pointer; }
.filter-chip:has(input:checked) { color: var(--text); border-color: color-mix(in srgb, var(--accent) 55%, var(--border)); }
.anime-list { display: grid; gap: 10px; margin-top: 6px; }
.anime-row { display: grid; grid-template-columns: 64px minmax(0, 1fr); gap: 14px; padding: 10px; border: 1px solid var(--border); border-radius: 14px; background: var(--surface); }
.anime-row[hidden] { display: none; }
.anime-row img, .anime-row .poster-placeholder { width: 64px; height: 90px; object-fit: cover; border-radius: 9px; background: var(--surface-2); }
.anime-row-body { min-width: 0; align-self: center; }
.anime-row-date { color: var(--accent); font-size: .8rem; font-weight: 700; }
.anime-row h2 { margin: 5px 0; font-size: 1rem; }
.anime-row p { margin: 0; color: var(--muted); font-size: .88rem; }
@media (max-width: 520px) {
  .search-result { grid-template-columns: 44px minmax(0,1fr); }
  .search-result img, .search-result .poster-placeholder { width: 44px; height: 62px; }
  .add-anime-button { grid-column: 2; width: fit-content; }
}
@media (min-width: 700px) {
  .anime-row { grid-template-columns: 74px minmax(0,1fr); padding: 12px; }
  .anime-row img, .anime-row .poster-placeholder { width: 74px; height: 104px; }
  .anime-row h2 { font-size: 1.08rem; }
}

/* v0.2.1: search result action stays on the right at every viewport width. */
.search-result {
  grid-template-columns: 48px minmax(0, 1fr) 88px;
  align-items: center;
  column-gap: 12px;
}
.search-result-main { min-width: 0; overflow: hidden; }
.search-result-title,
.search-result-meta { overflow: hidden; text-overflow: ellipsis; }
.search-result-title { white-space: nowrap; }
.search-result-meta { white-space: nowrap; }
.add-anime-button {
  width: 88px;
  min-width: 88px;
  min-height: 38px;
  padding: 0 9px;
  justify-self: end;
  font-size: .78rem;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
}
.add-spinner { display: none; width: 15px; height: 15px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: add-spin .7s linear infinite; }
.add-anime-button.is-loading .add-label { display: none; }
.add-anime-button.is-loading .add-spinner { display: block; }
@keyframes add-spin { to { transform: rotate(360deg); } }
@media (max-width: 520px) {
  .search-result { grid-template-columns: 42px minmax(0, 1fr) 80px; gap: 9px; padding: 8px; }
  .search-result img, .search-result .poster-placeholder { width: 42px; height: 59px; }
  .add-anime-button { grid-column: auto; width: 80px; min-width: 80px; min-height: 36px; padding: 0 6px; font-size: .72rem; }
}

/* v0.3 library: franchises are a vertical, clickable list. */
.library-list { display: grid; gap: 10px; margin-top: 26px; }
.library-franchise { display: grid; grid-template-columns: 34px 66px minmax(0,1fr) 28px; align-items: center; gap: 14px; min-height: 96px; padding: 10px 12px 10px 10px; border: 1px solid var(--border); border-radius: 16px; background: var(--surface); transition: transform .15s ease, border-color .15s ease, background .15s ease; }
.library-franchise:hover { transform: translateY(-1px); border-color: color-mix(in srgb, var(--accent) 50%, var(--border)); background: var(--surface-2); }
.library-franchise-cover img, .cover-placeholder.compact { width: 66px; height: 92px; object-fit: cover; border-radius: 10px; background: var(--surface-2); }
.cover-placeholder.compact { aspect-ratio: auto; font-size: 1.8rem; }
.library-franchise-main { min-width: 0; }
.library-franchise-main h2 { margin: 0 0 7px; font-size: 1.02rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.library-franchise-main p { margin: 0; color: var(--muted); font-size: .88rem; }
.library-franchise-arrow { font-size: 2rem; color: var(--muted); justify-self: end; }

.franchise-hero { margin-bottom: 20px; }
.franchise-hero-content { display: grid; grid-template-columns: 92px minmax(0,1fr); gap: 18px; align-items: center; }
.franchise-cover-large img, .franchise-cover-large .cover-placeholder { width: 92px; height: 130px; border-radius: 13px; object-fit: cover; background: var(--surface-2); }
.franchise-cover-large .cover-placeholder { aspect-ratio: auto; font-size: 2.3rem; }
.franchise-hero h1 { margin: 8px 0 8px; font-size: clamp(1.8rem, 7vw, 3.3rem); line-height: 1.03; letter-spacing: -.04em; }

.view-tabs { display: flex; gap: 8px; margin: 18px 0; border-bottom: 1px solid var(--border); }
.view-tab { border: 0; border-bottom: 2px solid transparent; background: transparent; color: var(--muted); padding: 12px 14px; cursor: pointer; font-weight: 750; }
.view-tab.is-active { color: var(--text); border-bottom-color: var(--accent); }
.view-panel[hidden] { display: none !important; }

.anime-list { gap: 12px; }
.anime-item { display: grid; grid-template-columns: 68px minmax(0,1fr); gap: 12px; padding: 10px; border: 1px solid var(--border); border-radius: 15px; background: var(--surface); transition: border-color .2s ease, box-shadow .2s ease; }
.anime-item[hidden] { display: none; }
.anime-item.flash { border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 20%, transparent); }
.anime-poster-link img, .anime-poster-link .poster-placeholder { width: 68px; height: 96px; object-fit: cover; border-radius: 9px; background: var(--surface-2); }
.anime-info { min-width: 0; }
.anime-info h2 { margin: 5px 0; font-size: 1rem; }
.anime-info p { margin: 0; color: var(--muted); font-size: .86rem; }
.anime-progress { grid-column: 1 / -1; display: grid; gap: 9px; }
.status-buttons { display: flex; flex-wrap: wrap; gap: 6px; }
.status-button { min-height: 34px; border: 1px solid var(--border); border-radius: 999px; background: transparent; color: var(--muted); padding: 0 10px; cursor: pointer; font-size: .78rem; }
.status-button:hover { color: var(--text); }
.status-button.is-active { background: var(--accent-strong); border-color: transparent; color: white; }
.progress-fields { display: flex; align-items: end; flex-wrap: wrap; gap: 9px; }
.progress-fields label { display: grid; gap: 4px; color: var(--muted); font-size: .75rem; }
.progress-fields input, .progress-fields select { height: 38px; min-width: 78px; border: 1px solid var(--border); border-radius: 9px; background: #0f131b; color: var(--text); padding: 0 9px; outline: none; }
.save-state { min-width: 72px; color: var(--muted); font-size: .78rem; padding-bottom: 9px; }

.graph-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 10px; color: var(--muted); font-size: .85rem; }
.graph-toolbar p { margin: 0; }
.graph-canvas { height: min(72vh, 760px); min-height: 520px; overflow: hidden; border: 1px solid var(--border); border-radius: 16px; background: var(--surface); touch-action: none; }
.graph-svg { width: 100%; height: 100%; cursor: grab; user-select: none; }
.graph-svg:active { cursor: grabbing; }
.graph-edge { fill: none; stroke: var(--border); stroke-width: 2; opacity: .85; }
.graph-arrow { fill: var(--muted); }
.graph-relation { fill: var(--muted); font-size: 10px; paint-order: stroke; stroke: var(--surface); stroke-width: 4px; }
.graph-kind { fill: var(--muted); font-size: 12px; font-weight: 700; }
.graph-node { cursor: pointer; }
.graph-node rect { fill: var(--surface-2); stroke: var(--border); stroke-width: 1.5; }
.graph-node:hover rect, .graph-node:focus rect { stroke: var(--accent); stroke-width: 2.5; }
.graph-node-id { fill: var(--text); font-size: 12px; font-weight: 800; }
.graph-node-year { fill: var(--muted); font-size: 10px; }

@media (min-width: 700px) {
  .library-franchise { grid-template-columns: 42px 76px minmax(0,1fr) 32px; min-height: 110px; padding: 12px; }
  .library-franchise-cover img, .cover-placeholder.compact { width: 76px; height: 106px; }
  .library-franchise-main h2 { font-size: 1.12rem; }
  .franchise-hero-content { grid-template-columns: 124px minmax(0,1fr); gap: 24px; }
  .franchise-cover-large img, .franchise-cover-large .cover-placeholder { width: 124px; height: 176px; }
  .anime-item { grid-template-columns: 82px minmax(220px,1fr) minmax(330px,1.4fr); align-items: center; padding: 12px; }
  .anime-poster-link img, .anime-poster-link .poster-placeholder { width: 82px; height: 116px; }
  .anime-progress { grid-column: auto; }
}
@media (prefers-color-scheme: light) {
  .progress-fields input, .progress-fields select { background: #fff; }
}

/* v0.4 preview/open flow, richer list metadata and visual graph. */
:root {
  --status-planned: #8f9bb2;
  --status-watching: #55a7ff;
  --status-completed: #59c98b;
  --status-on-hold: #f0b85a;
  --status-dropped: #e66f78;
}

.open-anime-button {
  width: 88px;
  min-width: 88px;
  min-height: 38px;
  padding: 0 9px;
  justify-self: end;
  font-size: .78rem;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
}
.open-anime-button:disabled { opacity: .65; cursor: wait; }
.open-anime-button.is-loading .add-label { display: none; }
.open-anime-button.is-loading .add-spinner { display: block; margin: 0 auto; }
@media (max-width: 520px) {
  .open-anime-button { width: 80px; min-width: 80px; min-height: 36px; padding: 0 6px; font-size: .72rem; }
}

.franchise-hero-main { min-width: 0; }
.franchise-actions { display: flex; align-items: center; flex-wrap: wrap; gap: 10px; margin-top: 15px; }
.library-state-badge { display: inline-flex; min-height: 38px; align-items: center; padding: 0 12px; border-radius: 999px; color: var(--status-completed); background: color-mix(in srgb, var(--status-completed) 12%, transparent); border: 1px solid color-mix(in srgb, var(--status-completed) 38%, var(--border)); font-size: .84rem; font-weight: 750; }
.compact-note { font-size: .82rem; }
.button.danger-outline { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 45%, var(--border)); background: transparent; }
.button.danger { color: white; border-color: transparent; background: #b94d58; font-weight: 700; }
.preview-note { margin: 4px 0 14px; padding: 11px 13px; border: 1px solid var(--border); border-radius: 12px; color: var(--muted); background: var(--surface-2); font-size: .88rem; }

.anime-poster-static { position: relative; width: 68px; height: 96px; align-self: center; }
.anime-poster-static img, .anime-poster-static .poster-placeholder { width: 68px; height: 96px; object-fit: cover; border-radius: 9px; background: var(--surface-2); display: block; }
.poster-status-icon { position: absolute; right: -7px; bottom: -7px; display: grid; place-items: center; width: 28px; height: 28px; border: 3px solid var(--surface); border-radius: 999px; color: white; font-size: .82rem; font-weight: 900; line-height: 1; }
.poster-status-icon.status-planned { background: var(--status-planned); }
.poster-status-icon.status-watching { background: var(--status-watching); }
.poster-status-icon.status-completed { background: var(--status-completed); }
.poster-status-icon.status-on_hold { background: var(--status-on-hold); }
.poster-status-icon.status-dropped { background: var(--status-dropped); }
.anime-original-name { color: var(--muted); font-size: .78rem; margin: -1px 0 5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.runtime-line { margin-top: 5px !important; color: color-mix(in srgb, var(--accent) 78%, var(--muted)) !important; }

.anime-item.status-watching { border-left: 3px solid var(--status-watching); }
.anime-item.status-completed { border-left: 3px solid var(--status-completed); }
.anime-item.status-on_hold { border-left: 3px solid var(--status-on-hold); }
.anime-item.status-dropped { border-left: 3px solid var(--status-dropped); }
.anime-item.status-planned { border-left: 3px solid var(--status-planned); }
.status-button.status-planned.is-active { background: var(--status-planned); }
.status-button.status-watching.is-active { background: var(--status-watching); }
.status-button.status-completed.is-active { background: var(--status-completed); }
.status-button.status-on_hold.is-active { background: var(--status-on-hold); color: #1a1a1a; }
.status-button.status-dropped.is-active { background: var(--status-dropped); }

.confirm-dialog { width: min(440px, calc(100% - 28px)); border: 1px solid var(--border); border-radius: 18px; padding: 0; background: var(--surface); color: var(--text); box-shadow: 0 28px 90px rgba(0,0,0,.45); }
.confirm-dialog::backdrop { background: rgba(0,0,0,.62); backdrop-filter: blur(3px); }
.confirm-dialog form { padding: 22px; }
.confirm-dialog h2 { margin: 0 0 8px; }
.confirm-dialog p { margin: 0; color: var(--muted); line-height: 1.5; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 9px; margin-top: 22px; }

.graph-toolbar > div { min-width: 0; }
.graph-toolbar p + p { margin-top: 4px; }
.graph-canvas { background-image: radial-gradient(circle, color-mix(in srgb, var(--border) 65%, transparent) 1px, transparent 1px); background-size: 22px 22px; }
.graph-edge { fill: none; stroke-linecap: round; }
.graph-edge-main { stroke: color-mix(in srgb, var(--text) 72%, var(--border)); stroke-width: 3; opacity: .9; }
.graph-edge-secondary { stroke: color-mix(in srgb, var(--muted) 86%, var(--text)); stroke-width: 2.2; stroke-dasharray: 7 7; opacity: .76; }
.graph-arrow-main { fill: color-mix(in srgb, var(--text) 72%, var(--border)); }
.graph-arrow-secondary { fill: none; stroke: color-mix(in srgb, var(--muted) 82%, var(--text)); stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
.graph-node { pointer-events: none; }
.graph-node-card { fill: var(--surface-2); stroke: var(--border); stroke-width: 2; }
.graph-node.status-planned .graph-node-card { stroke: var(--status-planned); }
.graph-node.status-watching .graph-node-card { stroke: var(--status-watching); stroke-width: 3; }
.graph-node.status-completed .graph-node-card { stroke: var(--status-completed); stroke-width: 3; }
.graph-node.status-on_hold .graph-node-card { stroke: var(--status-on-hold); stroke-width: 3; }
.graph-node.status-dropped .graph-node-card { stroke: var(--status-dropped); stroke-width: 3; }
.graph-poster { opacity: 1; }
.graph-poster-placeholder { fill: var(--surface); }
.graph-node-title { fill: var(--text); font-size: 11px; font-weight: 800; }
.graph-node-meta { fill: var(--muted); font-size: 10px; }
.graph-status-badge { fill: var(--surface); stroke: var(--border); stroke-width: 1.5; }
.graph-node.status-planned .graph-status-badge { fill: var(--status-planned); stroke: var(--status-planned); }
.graph-node.status-watching .graph-status-badge { fill: var(--status-watching); stroke: var(--status-watching); }
.graph-node.status-completed .graph-status-badge { fill: var(--status-completed); stroke: var(--status-completed); }
.graph-node.status-on_hold .graph-status-badge { fill: var(--status-on-hold); stroke: var(--status-on-hold); }
.graph-node.status-dropped .graph-status-badge { fill: var(--status-dropped); stroke: var(--status-dropped); }
.graph-status-text { fill: white; font-size: 12px; font-weight: 900; }
.graph-node.status-none .graph-status-badge { opacity: .35; }
.graph-node.status-none .graph-status-text { display: none; }

@media (min-width: 700px) {
  .anime-poster-static, .anime-poster-static img, .anime-poster-static .poster-placeholder { width: 82px; height: 116px; }
}
@media (max-width: 620px) {
  .franchise-actions { align-items: stretch; }
  .franchise-actions .button { flex: 1 1 auto; }
  .compact-note { flex-basis: 100%; }
  .graph-toolbar { align-items: flex-start; flex-direction: column; }
  .graph-canvas { min-height: 62vh; }
}

/* v0.5 */
.library-head { display:flex; justify-content:space-between; align-items:flex-end; gap:16px; }
.library-head-actions { display:flex; flex-wrap:wrap; gap:8px; }
.stats-grid { display:grid; grid-template-columns:repeat(auto-fit,minmax(150px,1fr)); gap:12px; margin:18px 0; }
.stat-card { padding:18px; border:1px solid var(--border); border-radius:16px; background:var(--surface); display:flex; flex-direction:column; gap:5px; }
.stat-card strong { font-size:1.55rem; }
.stat-card span { color:var(--muted); font-size:.86rem; }
.stats-breakdown { border:1px solid var(--border); border-radius:18px; background:var(--surface); padding:18px; }
.stats-breakdown h2 { margin:10px 0; font-size:1rem; }
.status-stat-row { display:flex; justify-content:space-between; gap:15px; padding:9px 0; border-bottom:1px solid var(--border); }
.public-row { cursor:default; }
.report-list { display:grid; gap:12px; }
.report-card { border:1px solid var(--border); border-radius:16px; background:var(--surface); padding:16px; }
.report-card p { color:var(--muted); white-space:pre-wrap; }
.report-actions { display:flex; gap:8px; margin-top:12px; flex-wrap:wrap; }
.report-textarea { width:100%; min-height:120px; resize:vertical; margin-top:14px; padding:12px; border-radius:12px; border:1px solid var(--border); background:var(--surface-2); color:var(--text); font:inherit; }
.admin-edit-form { margin-top:14px; padding:14px; border:1px solid var(--border); border-radius:14px; background:var(--surface-2); display:flex; flex-wrap:wrap; gap:10px; align-items:end; }
.admin-edit-form[hidden] { display:none; }
.admin-edit-form label { display:grid; gap:5px; color:var(--muted); font-size:.8rem; }
.admin-edit-form input { min-height:38px; border:1px solid var(--border); border-radius:9px; background:var(--surface); color:var(--text); padding:0 9px; }
.shared-kind-filters { margin-bottom:14px; }
.graph-node { pointer-events:auto; cursor:pointer; }
.graph-node:hover .graph-node-card { filter:brightness(1.16); stroke-width:3; }
.anime-item.flash-highlight { animation:flashAnime 2.2s ease; }
@keyframes flashAnime { 0%,100% { box-shadow:none; } 12%,55% { box-shadow:0 0 0 3px var(--accent), 0 0 28px color-mix(in srgb,var(--accent) 35%,transparent); } }
@media (max-width:620px) {
  .library-head { align-items:flex-start; flex-direction:column; }
  .library-head-actions { width:100%; }
  .library-head-actions .button { flex:1 1 auto; }
}

/* v0.6 genres, franchise rating and public read-only details */
.library-genre-filter { display:flex; gap:7px; overflow-x:auto; padding:4px 0 8px; margin:18px 0 4px; scrollbar-width:thin; }
.genre-filter-button { flex:0 0 auto; min-height:34px; padding:0 11px; border:1px solid var(--border); border-radius:999px; background:var(--surface); color:var(--muted); cursor:pointer; font:inherit; font-size:.8rem; }
.genre-filter-button.is-active { background:var(--accent-strong); color:white; border-color:transparent; }
.genre-tags { display:flex; flex-wrap:wrap; gap:5px; margin-top:8px; }
.genre-tags span { padding:3px 7px; border-radius:999px; background:var(--surface-2); border:1px solid var(--border); color:var(--muted); font-size:.7rem; }
.library-rating-line { display:flex; flex-wrap:wrap; gap:8px 14px; margin-top:8px; color:var(--muted); font-size:.78rem; }
.library-rating-line strong { color:var(--text); }
.franchise-rating-box { display:flex; align-items:center; flex-wrap:wrap; gap:10px 14px; margin-top:13px; padding:11px 13px; border:1px solid var(--border); border-radius:13px; background:var(--surface-2); }
.franchise-score-control { display:flex; align-items:center; gap:9px; color:var(--muted); font-size:.82rem; }
.franchise-score-control select { min-width:66px; height:36px; border:1px solid var(--border); border-radius:9px; background:var(--surface); color:var(--text); padding:0 8px; }
.rating-label { color:var(--muted); font-size:.78rem; display:block; }
.rating-value { font-size:1.35rem; }
.calculated-rating { flex-basis:100%; margin:0; color:var(--muted); font-size:.8rem; }
.inline-form { display:inline-flex; }
.public-progress { grid-column:1 / -1; display:flex; flex-wrap:wrap; gap:8px 14px; color:var(--muted); font-size:.82rem; }
.public-status { font-weight:700; }
.public-status.status-watching { color:var(--status-watching); }
.public-status.status-completed { color:var(--status-completed); }
.public-status.status-on_hold { color:var(--status-on-hold); }
.public-status.status-dropped { color:var(--status-dropped); }
.public-status.status-planned { color:var(--status-planned); }
.library-franchise[hidden] { display:none !important; }
@media (min-width:700px) { .public-progress { grid-column:auto; justify-content:flex-end; } }

/* v0.7 library controls, status filters and graph text containment */
.library-tools { display:flex; align-items:end; flex-wrap:wrap; gap:9px; margin:18px 0 12px; padding:12px; border:1px solid var(--border); border-radius:15px; background:var(--surface); }
.library-count { min-height:38px; display:flex; align-items:center; padding:0 11px; border-radius:10px; background:var(--surface-2); font-weight:800; white-space:nowrap; }
.filter-control-button { min-height:38px; border:1px solid var(--border); border-radius:10px; background:var(--surface-2); color:var(--text); padding:0 12px; cursor:pointer; font:inherit; font-weight:700; }
.filter-control-button:hover { border-color:var(--accent); }
.library-select-control { display:grid; gap:4px; color:var(--muted); font-size:.72rem; }
.library-select-control select { min-height:38px; min-width:140px; padding:0 9px; border:1px solid var(--border); border-radius:10px; background:var(--surface-2); color:var(--text); font:inherit; }
.filter-dialog { width:min(520px,calc(100% - 24px)); max-height:min(720px,calc(100vh - 30px)); padding:0; border:1px solid var(--border); border-radius:18px; background:var(--surface); color:var(--text); box-shadow:0 26px 90px rgba(0,0,0,.5); }
.filter-dialog::backdrop { background:rgba(0,0,0,.64); backdrop-filter:blur(4px); }
.filter-dialog-inner { padding:18px; display:grid; gap:13px; }
.filter-dialog-head { display:flex; justify-content:space-between; align-items:center; gap:12px; }
.filter-dialog-head h2 { margin:2px 0 0; }
.icon-button { width:38px; height:38px; border-radius:10px; border:1px solid var(--border); background:var(--surface-2); color:var(--text); font-size:1.4rem; cursor:pointer; }
.filter-search { width:100%; min-height:42px; padding:0 12px; border:1px solid var(--border); border-radius:11px; background:var(--surface-2); color:var(--text); font:inherit; }
.filter-choice-list { max-height:400px; overflow:auto; display:grid; grid-template-columns:repeat(auto-fit,minmax(180px,1fr)); gap:6px; padding:3px; }
.filter-choice-list.compact { max-height:300px; }
.filter-choice-list label { display:flex; align-items:center; gap:8px; min-height:38px; padding:7px 9px; border:1px solid transparent; border-radius:9px; cursor:pointer; color:var(--muted); }
.filter-choice-list label:hover { background:var(--surface-2); border-color:var(--border); color:var(--text); }
.library-index { flex:0 0 auto; align-self:center; min-width:42px; color:var(--muted); font-size:.78rem; font-weight:800; text-align:center; }
.filter-section-label { display:inline-flex; align-items:center; color:var(--muted); font-size:.78rem; font-weight:800; padding-right:3px; }
.status-filters { margin-top:-3px; }
.graph-node-title { pointer-events:none; }
@media (max-width:620px) {
  .library-tools { align-items:stretch; }
  .library-count, .filter-control-button { flex:1 1 calc(50% - 6px); justify-content:center; }
  .library-select-control { flex:1 1 100%; }
  .library-select-control select { width:100%; }
  .library-index { min-width:28px; font-size:.7rem; }
  .filter-choice-list { grid-template-columns:1fr; }
}


/* v0.8 library repair, profile and two-level administration */
.profile-link:hover { color:var(--text); }
.profile-page { width:min(760px,100%); margin:0 auto; }
.profile-page h1,.admin-page h1 { margin:7px 0 10px; font-size:clamp(2rem,6vw,3rem); }
.profile-form { display:grid; gap:16px; margin-top:22px; padding:20px; border:1px solid var(--border); border-radius:18px; background:var(--surface); }
.profile-form label,.admin-card label { display:grid; gap:6px; color:var(--muted); font-size:.82rem; font-weight:700; }
.profile-form input,.profile-form textarea,.admin-card input,.admin-card textarea { width:100%; border:1px solid var(--border); border-radius:11px; background:#0f131b; color:var(--text); padding:11px 12px; outline:none; resize:vertical; }
.field-hint { color:var(--muted); font-size:.72rem; font-weight:400; }
.profile-actions { display:flex; flex-wrap:wrap; gap:9px; }
.notice.success { color:var(--status-completed); }
.admin-page-head,.admin-franchise-head { display:flex; justify-content:space-between; align-items:center; gap:12px; flex-wrap:wrap; }
.admin-user-list { display:grid; gap:9px; margin-top:20px; }
.admin-user-row { display:flex; justify-content:space-between; align-items:center; gap:12px; padding:14px 15px; border:1px solid var(--border); border-radius:14px; background:var(--surface); }
.admin-user-row:hover { border-color:var(--accent); background:var(--surface-2); }
.admin-user-row>div:first-child { display:grid; gap:4px; min-width:0; }
.admin-user-row span { color:var(--muted); font-size:.78rem; }
.admin-user-badges { display:flex; align-items:center; gap:7px; }
.role-badge { padding:4px 7px; border-radius:999px; border:1px solid var(--accent); color:var(--accent)!important; font-weight:800; font-size:.65rem!important; }
.role-badge.super { border-color:var(--status-completed); color:var(--status-completed)!important; }
.role-badge.banned { border-color:var(--danger); color:var(--danger)!important; }
.admin-user-grid { display:grid; gap:12px; grid-template-columns:repeat(auto-fit,minmax(280px,1fr)); margin:18px 0 28px; }
.admin-card,.admin-franchise-card { padding:16px; border:1px solid var(--border); border-radius:16px; background:var(--surface); }
.admin-card h2,.admin-franchise-card h3 { margin:0 0 12px; }
.admin-section-title { margin:28px 0 12px; }
.admin-franchise-list { display:grid; gap:14px; }
.admin-franchise-head span { color:var(--muted); font-size:.78rem; }
.admin-score-form { display:flex; align-items:end; gap:8px; margin:12px 0; }
.admin-score-form label { display:grid; gap:4px; color:var(--muted); font-size:.75rem; }
.admin-score-form input { width:90px; min-height:38px; border:1px solid var(--border); border-radius:9px; background:#0f131b; color:var(--text); padding:0 9px; }
.admin-anime-table { display:grid; gap:6px; }
.admin-anime-row { display:grid; grid-template-columns:minmax(180px,1fr) 130px 90px 70px 44px; gap:6px; align-items:center; padding:7px; border-radius:10px; background:var(--surface-2); }
.admin-anime-name { min-width:0; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; font-size:.82rem; }
.admin-anime-row select,.admin-anime-row input { min-width:0; width:100%; height:36px; border:1px solid var(--border); border-radius:8px; background:#0f131b; color:var(--text); padding:0 7px; }
.back-link { display:inline-block; margin-bottom:15px; color:var(--muted); }
/* Library has four actual children: number, poster, content, arrow. */
.library-franchise { grid-template-columns:34px 66px minmax(0,1fr) 28px; }
.library-index { min-width:0; width:100%; }
@media (min-width:700px){ .library-franchise { grid-template-columns:42px 76px minmax(0,1fr) 32px; } }
@media (max-width:700px){ .admin-anime-row { grid-template-columns:1fr 1fr; } .admin-anime-name { grid-column:1/-1; white-space:normal; } }
@media (max-width:520px){ .library-franchise { grid-template-columns:24px 58px minmax(0,1fr) 20px; gap:8px; padding:9px 8px; } .library-franchise-cover img,.cover-placeholder.compact { width:58px; height:82px; } .library-franchise-main h2 { white-space:normal; display:-webkit-box; -webkit-line-clamp:2; -webkit-box-orient:vertical; } .library-franchise-main p { font-size:.75rem; } .genre-tags { display:none; } .library-rating-line { font-size:.72rem; } }

.public-profile-description{max-width:720px;white-space:pre-wrap;color:var(--text);opacity:.9;margin:7px 0;}

/* v0.9: impersonation, notes, hidden works, admin polish */
.admin-view-banner { margin:0 0 14px; padding:10px 13px; border:1px solid var(--accent); border-radius:12px; background:color-mix(in srgb,var(--accent) 9%,var(--surface)); color:var(--text); }
.franchise-note-box { margin-top:12px; max-width:760px; }
.personal-note label { display:grid; gap:6px; color:var(--muted); font-size:.78rem; font-weight:700; }
.personal-note textarea,.anime-note { width:100%; min-height:78px; border:1px solid var(--border); border-radius:11px; background:#0f131b; color:var(--text); padding:10px 11px; resize:vertical; outline:none; }
.anime-note-details { margin-top:6px; border-top:1px dashed var(--border); padding-top:8px; }
.anime-note-details summary { cursor:pointer; color:var(--muted); font-size:.78rem; user-select:none; }
.anime-note-details textarea { margin-top:8px; min-height:68px; }
.hidden-toggle { display:flex!important; align-items:center; gap:7px!important; min-height:38px; padding:0 10px; border:1px solid var(--border); border-radius:9px; background:#0f131b; color:var(--muted)!important; }
.hidden-toggle input { min-width:auto!important; width:auto!important; height:auto!important; }
.hidden-filter-chip { border-style:dashed; }
.anime-item[data-hidden="1"] { opacity:.72; border-style:dashed; }
.admin-page { width:min(1120px,100%); margin:0 auto; }
.admin-page .button { white-space:nowrap; }
.admin-user-list { margin-bottom:28px; }
.admin-user-row strong { font-size:1rem; overflow:hidden; text-overflow:ellipsis; }
@media (max-width:640px) {
  .admin-user-row { align-items:flex-start; }
  .admin-user-badges { flex-wrap:wrap; justify-content:flex-end; }
  .franchise-note-box { width:100%; }
}

/* v0.10 — library filters, individual status results, graph badge */
.library-tools { align-items:center; }
.library-count, .filter-control-button, .library-select-control { font-family:inherit; font-size:.88rem; font-weight:700; }
.library-count { min-height:40px; display:flex; align-items:center; padding:0 12px; border-radius:10px; background:var(--surface-2); }
.filter-control-button { min-height:40px; }
.library-select-control { display:flex; align-items:center; gap:8px; color:var(--text); white-space:nowrap; }
.library-select-control select { min-height:40px; font-family:inherit; font-size:.88rem; font-weight:600; }
.library-anime-list { display:grid; gap:9px; }
.library-anime-list[hidden] { display:none !important; }
.library-anime-entry { display:grid; grid-template-columns:58px minmax(0,1fr) 24px; gap:12px; align-items:center; padding:9px 12px; border:1px solid var(--border); border-radius:14px; background:var(--surface); transition:.15s ease; }
.library-anime-entry:hover { border-color:color-mix(in srgb,var(--accent) 55%,var(--border)); background:var(--surface-2); transform:translateY(-1px); }
.library-anime-entry[hidden] { display:none !important; }
.library-anime-cover img, .library-anime-cover .cover-placeholder { width:58px; height:82px; border-radius:9px; object-fit:cover; }
.library-anime-main { min-width:0; }
.library-anime-main h2 { margin:2px 0 5px; font-size:1rem; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.library-anime-main p { margin:0; color:var(--muted); font-size:.82rem; }
.library-anime-franchise { color:var(--accent); font-size:.72rem; font-weight:700; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.library-anime-status { margin-top:5px; color:var(--muted); font-size:.8rem; }
.anime-title-link:hover { color:var(--accent); text-decoration:underline; text-underline-offset:3px; }
.anime-shikimori-link { cursor:pointer; }
.anime-shikimori-link:hover img { filter:brightness(1.08); }
@media (max-width:620px) {
  .library-tools { align-items:stretch; }
  .library-count,.filter-control-button { min-height:42px; }
  .library-select-control { display:grid; gap:5px; font-size:.82rem; }
  .library-anime-entry { grid-template-columns:50px minmax(0,1fr) 18px; gap:9px; padding:8px; }
  .library-anime-cover img,.library-anime-cover .cover-placeholder { width:50px; height:72px; }
  .library-anime-main h2 { white-space:normal; display:-webkit-box; -webkit-line-clamp:2; -webkit-box-orient:vertical; }
}

/* v0.10.2 — reports polish and admin notification badge */
.admin-button-with-badge { position:relative; overflow:visible; }
.admin-alert-badge {
  position:absolute;
  top:-8px;
  right:-8px;
  display:flex;
  align-items:center;
  justify-content:center;
  min-width:20px;
  height:20px;
  padding:0 5px;
  border:2px solid var(--page, #0b0f16);
  border-radius:999px;
  background:#ef4444;
  color:#fff;
  font-size:.65rem;
  line-height:1;
  font-weight:900;
  font-family:inherit;
  box-shadow:0 2px 10px rgba(239,68,68,.35);
  pointer-events:none;
}
.admin-reports-page { width:min(1040px,100%); }
.admin-reports-head { align-items:flex-end; margin-bottom:20px; }
.admin-reports-head h1 { margin:6px 0 7px; font-size:clamp(2rem,5vw,3rem); line-height:1.02; }
.admin-reports-head p { margin:0; max-width:650px; }
.admin-nav-actions { display:flex; align-items:center; gap:9px; flex-wrap:wrap; }
.admin-open-count { display:inline-flex; align-items:center; min-height:40px; padding:0 12px; border:1px solid var(--border); border-radius:10px; background:var(--surface-2); color:var(--muted); font-size:.8rem; font-weight:800; }
.report-list { display:grid; gap:12px; }
.report-card { padding:16px 18px; }
.report-card-head,.report-card-foot { display:flex; align-items:center; justify-content:space-between; gap:12px; }
.report-card-head > div { display:flex; align-items:baseline; gap:7px; flex-wrap:wrap; min-width:0; }
.report-card-head strong { font-size:1rem; overflow-wrap:anywhere; }
.report-id { flex:0 0 auto; color:var(--muted); font-size:.72rem; font-weight:800; }
.report-card p { margin:13px 0; color:var(--text); line-height:1.55; }
.report-card-foot { padding-top:11px; border-top:1px solid var(--border); }
.report-actions { margin-top:0; }
.report-actions form { margin:0; }
.admin-empty-state { margin-top:18px; }
@media (max-width:640px) {
  .admin-reports-head { align-items:stretch; }
  .admin-nav-actions { width:100%; }
  .admin-nav-actions .button,.admin-open-count { flex:1 1 auto; justify-content:center; }
  .report-card-head,.report-card-foot { align-items:flex-start; flex-direction:column; }
  .report-actions { width:100%; }
  .report-actions .button,.report-actions form { flex:1 1 auto; }
  .report-actions form .button { width:100%; }
}


/* v0.11 — compact filters, reliable status mode, admin correction without ID hunting */
.library-list[hidden], .library-anime-list[hidden], .view-panel[hidden], .admin-edit-form[hidden] { display:none !important; }

.franchise-filter-toolbar {
  display:flex;
  align-items:center;
  flex-wrap:wrap;
  gap:9px;
  margin:14px 0 18px;
  padding:11px 12px;
  border:1px solid var(--border);
  border-radius:14px;
  background:var(--surface);
}
.franchise-filter-toolbar .filter-control-button { min-width:130px; justify-content:center; }
.franchise-filter-dialog .filter-dialog-inner { width:min(520px, calc(100vw - 28px)); }
.franchise-choice-list { max-height:min(56vh, 520px); overflow:auto; padding-right:4px; }
.franchise-choice-list label { min-height:42px; }

.admin-franchise-correction {
  display:grid;
  grid-template-columns:minmax(210px,1fr) minmax(260px,1.45fr) minmax(260px,1.45fr) auto;
  gap:10px;
  align-items:end;
}
.admin-franchise-correction label { min-width:0; }
.admin-franchise-correction select,
.admin-franchise-correction input {
  width:100%;
  min-width:0;
  min-height:42px;
  border:1px solid var(--border);
  border-radius:10px;
  background:var(--surface);
  color:var(--text);
  padding:0 10px;
  font:inherit;
}
.admin-correction-help { grid-column:1/-1; }

@media (max-width:900px) {
  .admin-franchise-correction { grid-template-columns:1fr 1fr; }
  .admin-correction-title { grid-column:1/-1; }
}
@media (max-width:620px) {
  .franchise-filter-toolbar { display:grid; grid-template-columns:1fr 1fr; }
  .franchise-filter-toolbar .filter-control-button { width:100%; min-width:0; }
  .admin-franchise-correction { grid-template-columns:1fr; }
  .admin-correction-title,.admin-correction-help { grid-column:auto; }
}

/* v0.12: status-mode cards use the same status language as franchise rows/graph. */
.library-anime-entry.status-planned { border-left: 4px solid var(--status-planned); background: color-mix(in srgb, var(--status-planned) 5%, var(--surface)); }
.library-anime-entry.status-watching { border-left: 4px solid var(--status-watching); background: color-mix(in srgb, var(--status-watching) 6%, var(--surface)); }
.library-anime-entry.status-completed { border-left: 4px solid var(--status-completed); background: color-mix(in srgb, var(--status-completed) 6%, var(--surface)); }
.library-anime-entry.status-on_hold { border-left: 4px solid var(--status-on-hold); background: color-mix(in srgb, var(--status-on-hold) 6%, var(--surface)); }
.library-anime-entry.status-dropped { border-left: 4px solid var(--status-dropped); background: color-mix(in srgb, var(--status-dropped) 6%, var(--surface)); }
.library-anime-entry.status-none { border-left: 4px solid var(--border); }
.library-anime-entry .library-anime-status { font-weight: 700; }
.library-anime-entry.status-planned .library-anime-status { color: var(--status-planned); }
.library-anime-entry.status-watching .library-anime-status { color: var(--status-watching); }
.library-anime-entry.status-completed .library-anime-status { color: var(--status-completed); }
.library-anime-entry.status-on_hold .library-anime-status { color: var(--status-on-hold); }
.library-anime-entry.status-dropped .library-anime-status { color: var(--status-dropped); }

/* Profile display preferences. */
.profile-preferences { margin: 8px 0 0; padding: 16px; border: 1px solid var(--border); border-radius: 14px; background: var(--surface); }
.profile-preferences legend { padding: 0 7px; font-weight: 800; }
.profile-preferences p { margin: 0 0 12px; line-height: 1.45; }
.preference-kind-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; max-height: 320px; overflow: auto; padding-right: 4px; }
.preference-kind-option { display: flex !important; flex-direction: row !important; align-items: center; gap: 8px; min-height: 40px; padding: 8px 10px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface-2); cursor: pointer; }
.preference-kind-option input { width: auto !important; margin: 0; }
.preference-kind-option:has(input:checked) { border-color: var(--accent); color: var(--muted); }


/* v0.14.2 graph selection: one click = neighbourhood, double click = open in list. */
.graph-node, .graph-edge { transition: opacity .14s ease, filter .14s ease; }
.graph-node.graph-node-dimmed { opacity: .16; }
.graph-edge.graph-edge-dimmed { opacity: .08; }
.graph-node.graph-node-connected { opacity: 1; }
.graph-node.graph-node-connected .graph-node-card { stroke-width: 2.5; }
.graph-node.graph-node-selected { opacity: 1; filter: brightness(1.12); }
.graph-node.graph-node-selected .graph-node-card { stroke: var(--accent) !important; stroke-width: 4; }
.graph-edge.graph-edge-selected { opacity: 1; stroke-width: 4; }


/* v0.15.1 — graph root/source emphasis */
.graph-node.graph-node-root .graph-node-card {
  stroke: #f4c95d !important;
  stroke-width: 5 !important;
  filter: drop-shadow(0 0 7px rgba(244, 201, 93, .42));
}
.graph-root-badge { pointer-events: none; }
.graph-root-badge-bg { fill: #f4c95d; stroke: #fff0b4; stroke-width: 1; }
.graph-root-badge-text { fill: #17130a; font-size: 10px; font-weight: 900; letter-spacing: .7px; }
.graph-node.graph-node-root.graph-node-dimmed { opacity: .38; }

/* v0.15.4 library filter mode switch */
.filter-control-button[hidden] { display: none !important; }

/* v0.15.6 — franchise header visual polish */
.franchise-hero {
  margin-bottom: 26px;
}
.franchise-hero > .back-link {
  margin-bottom: 16px;
}
.franchise-hero-content {
  grid-template-columns: 148px minmax(0, 1fr);
  gap: 24px;
  align-items: start;
  padding: 20px;
  border: 1px solid var(--border);
  border-radius: 20px;
  background: color-mix(in srgb, var(--surface) 96%, transparent);
}
.franchise-cover-large {
  align-self: start;
}
.franchise-cover-large img,
.franchise-cover-large .cover-placeholder {
  width: 148px;
  height: 210px;
  border-radius: 15px;
  box-shadow: 0 10px 28px rgba(0,0,0,.24);
}
.franchise-hero-main {
  display: grid;
  align-content: start;
  gap: 0;
}
.franchise-hero-main .eyebrow {
  margin-top: 2px;
}
.franchise-hero h1 {
  margin: 10px 0 10px;
  font-size: clamp(2.25rem, 5vw, 3.5rem);
  line-height: 1;
}
.franchise-hero-main > .muted {
  margin: 0 0 16px;
  font-size: .9rem;
}
.franchise-rating-box {
  margin-top: 0;
  padding: 14px 15px;
  border-radius: 14px;
  background: var(--surface-2);
}
.franchise-score-control {
  color: var(--text);
  font-weight: 650;
}
.franchise-score-control select {
  min-width: 72px;
}
.calculated-rating {
  margin-top: 2px;
  line-height: 1.5;
}
.franchise-note-box {
  width: 100%;
  max-width: none;
  margin-top: 14px;
}
.franchise-note-box label {
  color: var(--text);
}
.franchise-note-box textarea {
  min-height: 92px;
  margin-top: 2px;
  background: color-mix(in srgb, var(--bg) 78%, var(--surface));
}
.franchise-actions {
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}
.franchise-actions .button,
.franchise-actions .library-state-badge {
  min-height: 42px;
}

@media (max-width: 760px) {
  .franchise-hero-content {
    grid-template-columns: 112px minmax(0, 1fr);
    gap: 16px;
    padding: 16px;
  }
  .franchise-cover-large img,
  .franchise-cover-large .cover-placeholder {
    width: 112px;
    height: 158px;
    border-radius: 13px;
  }
  .franchise-hero h1 {
    font-size: clamp(1.9rem, 8vw, 2.7rem);
  }
}

@media (max-width: 560px) {
  .franchise-hero-content {
    grid-template-columns: 82px minmax(0, 1fr);
    gap: 13px;
    padding: 13px;
    border-radius: 16px;
  }
  .franchise-cover-large img,
  .franchise-cover-large .cover-placeholder {
    width: 82px;
    height: 116px;
    border-radius: 11px;
  }
  .franchise-hero-main .eyebrow {
    font-size: .68rem;
    letter-spacing: .09em;
  }
  .franchise-hero h1 {
    margin: 7px 0 7px;
    font-size: clamp(1.55rem, 8vw, 2.15rem);
  }
  .franchise-hero-main > .muted {
    margin-bottom: 12px;
    font-size: .76rem;
  }
  .franchise-rating-box,
  .franchise-note-box,
  .franchise-actions,
  .admin-franchise-correction {
    grid-column: 1 / -1;
  }
  .franchise-rating-box {
    margin-left: -95px;
    margin-top: 14px;
  }
  .franchise-note-box,
  .franchise-actions,
  .admin-franchise-correction {
    margin-left: -95px;
  }
  .franchise-actions {
    display: grid;
    grid-template-columns: 1fr;
  }
  .franchise-actions .button,
  .franchise-actions .library-state-badge,
  .franchise-actions .inline-form,
  .franchise-actions .inline-form .button {
    width: 100%;
  }
  .library-state-badge {
    justify-content: center;
  }
}


/* v0.15.7 — long-page navigation + local franchise search */
.back-to-top {
  position: fixed;
  right: max(18px, env(safe-area-inset-right));
  bottom: max(18px, env(safe-area-inset-bottom));
  z-index: 90;
  width: 48px;
  height: 48px;
  border: 1px solid color-mix(in srgb, var(--accent) 65%, var(--border));
  border-radius: 50%;
  background: color-mix(in srgb, var(--surface) 88%, var(--accent) 12%);
  color: var(--text);
  font: inherit;
  font-size: 1.45rem;
  font-weight: 800;
  line-height: 1;
  cursor: pointer;
  box-shadow: 0 8px 28px rgba(0,0,0,.28);
  transition: transform .16s ease, border-color .16s ease, opacity .16s ease;
}
.back-to-top[hidden] { display: none !important; }
.back-to-top:hover { transform: translateY(-2px); border-color: var(--accent); }
.back-to-top:active { transform: translateY(0); }

.franchise-filter-area {
  display: grid;
  gap: 10px;
  margin: 14px 0;
}
.franchise-object-search {
  position: relative;
  display: flex;
  align-items: center;
  min-width: 0;
}
.franchise-object-search-icon {
  position: absolute;
  left: 14px;
  pointer-events: none;
  color: var(--muted);
  font-size: 1rem;
}
.franchise-object-search input {
  width: 100%;
  min-height: 44px;
  padding: 0 44px 0 40px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface-2);
  color: var(--text);
  font: inherit;
  outline: none;
}
.franchise-object-search input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent) 22%, transparent);
}
.search-clear-button {
  position: absolute;
  right: 7px;
  width: 32px;
  height: 32px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 1.25rem;
  cursor: pointer;
}
.search-clear-button:hover { background: var(--surface); color: var(--text); }
.search-clear-button[hidden] { display: none !important; }
.franchise-search-count {
  margin-left: auto;
  align-self: center;
  color: var(--muted);
  font-size: .86rem;
  white-space: nowrap;
}

@media (max-width: 600px) {
  .back-to-top {
    width: 46px;
    height: 46px;
    right: max(12px, env(safe-area-inset-right));
    bottom: max(12px, env(safe-area-inset-bottom));
  }
  .franchise-search-count {
    width: 100%;
    margin-left: 0;
    text-align: right;
  }
}


/* v0.15.8 — list-only franchise search and unified page background */
.view-panel-list,
.view-panel-list .anime-list {
  background: transparent;
}
.franchise-list-search-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  margin: 0 0 14px;
  background: transparent;
}
.franchise-list-search-row .franchise-search-count {
  margin-left: 0;
}
@media (max-width: 600px) {
  .franchise-list-search-row {
    grid-template-columns: 1fr;
  }
  .franchise-list-search-row .franchise-search-count {
    width: 100%;
    text-align: right;
  }
}

/* v1.0.1 backup status */
.backup-panel{margin-top:20px;padding:18px;border:1px solid var(--border);border-radius:18px;background:var(--surface);}
.backup-panel-head{display:flex;align-items:center;justify-content:space-between;gap:16px;flex-wrap:wrap;}
.backup-panel h2{margin:4px 0 0;font-size:1.2rem;}
.backup-status-grid{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:10px;margin-top:16px;}
.backup-status-grid>div{min-width:0;padding:12px;border:1px solid var(--border);border-radius:12px;background:var(--surface-2);}
.backup-status-grid span,.backup-status-grid strong{display:block;overflow-wrap:anywhere;}
.backup-status-grid span{font-size:.74rem;color:var(--muted);margin-bottom:5px;}
.backup-status-grid strong{font-size:.88rem;}
.backup-error{margin:12px 0 0;padding:10px 12px;border:1px solid var(--danger);border-radius:10px;color:var(--danger);font-size:.85rem;overflow-wrap:anywhere;}
.backup-help{margin:12px 0 0;font-size:.8rem;}
@media(max-width:760px){.backup-status-grid{grid-template-columns:1fr 1fr;}}
@media(max-width:480px){.backup-status-grid{grid-template-columns:1fr}.backup-panel{padding:14px}.backup-panel-head .button{width:100%;}}

/* v1.2 — main-story continuations */
.library-section-tabs {
  display: flex;
  gap: 8px;
  margin: 0 0 22px;
  padding-bottom: 1px;
  border-bottom: 1px solid var(--border);
  overflow-x: auto;
  scrollbar-width: thin;
}
.library-section-tab {
  flex: 0 0 auto;
  padding: 11px 14px;
  border-bottom: 2px solid transparent;
  color: var(--muted);
  font-weight: 750;
  white-space: nowrap;
}
.library-section-tab:hover { color: var(--text); }
.library-section-tab.is-active { color: var(--text); border-bottom-color: var(--accent); }

.continuation-head { margin-bottom: 14px; }
.continuation-head h1 { margin-bottom: 8px; }
.continuation-head p { max-width: 780px; margin: 0; line-height: 1.55; }
.continuation-summary {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin: 2px 0 14px;
  color: var(--muted);
}
.continuation-summary strong { color: var(--text); font-size: 1.35rem; }
.continuation-list { display: grid; gap: 14px; }
.continuation-card {
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 18px;
  background: var(--surface);
}
.continuation-franchise-link {
  display: grid;
  grid-template-columns: 70px minmax(0, 1fr) 28px;
  align-items: center;
  gap: 14px;
  padding: 12px;
  border-bottom: 1px solid var(--border);
  transition: background .15s ease;
}
.continuation-franchise-link:hover { background: var(--surface-2); }
.continuation-cover img,
.continuation-cover .cover-placeholder.compact {
  width: 70px;
  height: 98px;
  object-fit: cover;
  border-radius: 10px;
}
.continuation-main { min-width: 0; }
.continuation-main h2 { margin: 4px 0 7px; font-size: 1.08rem; }
.continuation-main p { margin: 0; color: var(--muted); font-size: .88rem; }
.continuation-next-list { display: grid; gap: 1px; background: var(--border); }
.continuation-next-item {
  display: grid;
  grid-template-columns: 48px minmax(0, 1fr);
  gap: 12px;
  align-items: center;
  padding: 10px 12px;
  background: var(--surface);
  transition: background .15s ease;
}
.continuation-next-item:hover { background: var(--surface-2); }
.continuation-next-cover img,
.continuation-next-cover .poster-placeholder {
  width: 48px;
  height: 68px;
  object-fit: cover;
  border-radius: 8px;
  background: var(--surface-2);
}
.continuation-next-info { min-width: 0; display: grid; gap: 3px; }
.continuation-next-info strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.continuation-next-info > span { color: var(--muted); font-size: .82rem; }
.continuation-next-label { color: var(--accent); font-size: .72rem; font-weight: 800; text-transform: uppercase; letter-spacing: .06em; }
.continuation-progress.status-watching { color: var(--status-watching); }
.continuation-progress.status-planned { color: var(--status-planned); }
.continuation-progress.status-on_hold { color: var(--status-on-hold); }
.continuation-state-badge {
  display: inline-flex;
  align-items: center;
  min-height: 36px;
  padding: 0 11px;
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--muted);
  font-size: .78rem;
  font-weight: 750;
}
.continuation-state-dropped { color: var(--status-dropped); border-color: color-mix(in srgb, var(--status-dropped) 45%, var(--border)); }
.continuation-empty { margin-top: 34px; }

@media (min-width: 720px) {
  .continuation-franchise-link { grid-template-columns: 82px minmax(0, 1fr) 32px; padding: 14px; }
  .continuation-cover img, .continuation-cover .cover-placeholder.compact { width: 82px; height: 114px; }
  .continuation-next-list { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1px; }
}

@media (max-width: 560px) {
  .library-section-tabs { margin-bottom: 18px; }
  .library-section-tab { padding: 10px 11px; font-size: .86rem; }
  .continuation-franchise-link { grid-template-columns: 58px minmax(0, 1fr) 22px; gap: 10px; padding: 10px; }
  .continuation-cover img, .continuation-cover .cover-placeholder.compact { width: 58px; height: 82px; }
  .continuation-main h2 { font-size: .98rem; }
  .continuation-main p { font-size: .8rem; }
}

/* v1.2.2 — compact mobile franchise header/actions */
@media (max-width: 560px) {
  .franchise-hero-content {
    position: relative;
    display: block;
    padding: 13px;
    overflow: hidden;
  }

  .franchise-cover-large {
    position: absolute;
    top: 13px;
    left: 13px;
    width: 82px;
    height: 116px;
    z-index: 1;
  }

  .franchise-cover-large img,
  .franchise-cover-large .cover-placeholder {
    display: block;
    width: 82px;
    height: 116px;
    max-width: 82px;
    object-fit: cover;
    overflow: hidden;
  }

  .franchise-hero-main {
    display: block;
    min-width: 0;
  }

  .franchise-hero-main > .eyebrow,
  .franchise-hero-main > h1,
  .franchise-hero-main > .muted {
    margin-left: 95px;
    min-width: 0;
    overflow-wrap: anywhere;
  }

  .franchise-hero-main > .eyebrow {
    padding-top: 2px;
  }

  .franchise-hero-main > h1 {
    min-height: 44px;
    line-height: 1.02;
  }

  .franchise-hero-main > .muted {
    min-height: 42px;
    margin-bottom: 14px;
    line-height: 1.28;
  }

  .franchise-rating-box,
  .franchise-note-box,
  .franchise-actions,
  .admin-franchise-correction {
    width: 100%;
    margin-left: 0;
  }

  .franchise-rating-box {
    margin-top: 8px;
    padding: 13px;
  }

  .franchise-note-box {
    margin-top: 12px;
  }

  .franchise-note-box textarea {
    min-height: 88px;
  }

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

  .franchise-actions .button,
  .franchise-actions .library-state-badge,
  .franchise-actions .continuation-state-badge,
  .franchise-actions .inline-form,
  .franchise-actions .inline-form .button {
    width: 100%;
    min-width: 0;
    min-height: 40px;
    margin: 0;
  }

  .franchise-actions .button {
    padding: 8px 9px;
    font-size: .82rem;
    line-height: 1.18;
    white-space: normal;
    text-align: center;
  }

  .franchise-actions .library-state-badge,
  .franchise-actions .continuation-state-badge {
    grid-column: 1 / -1;
    justify-content: center;
    min-height: 38px;
  }

  .franchise-actions .inline-form {
    display: block;
  }
}

@media (max-width: 390px) {
  .franchise-hero-content { padding: 11px; }
  .franchise-cover-large { top: 11px; left: 11px; width: 76px; height: 108px; }
  .franchise-cover-large img,
  .franchise-cover-large .cover-placeholder { width: 76px; height: 108px; max-width: 76px; }
  .franchise-hero-main > .eyebrow,
  .franchise-hero-main > h1,
  .franchise-hero-main > .muted { margin-left: 88px; }
  .franchise-hero h1 { font-size: clamp(1.45rem, 7.7vw, 1.95rem); }
  .franchise-actions .button { font-size: .77rem; padding-inline: 7px; }
}

/* v1.2.3 — switch between modern force graph and classic chronological graph. */
.graph-toolbar-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 8px;
  flex: 0 0 auto;
}
.graph-mode-switch {
  display: inline-flex;
  align-items: center;
  padding: 3px;
  border: 1px solid var(--border);
  border-radius: 11px;
  background: color-mix(in srgb, var(--surface-2) 88%, transparent);
}
.graph-mode-button {
  min-height: 34px;
  border: 0;
  border-radius: 8px;
  padding: 0 12px;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: .8rem;
  font-weight: 750;
  cursor: pointer;
}
.graph-mode-button:hover { color: var(--text); }
.graph-mode-button.is-active {
  background: var(--accent-strong);
  color: #fff;
  box-shadow: 0 1px 0 rgba(255,255,255,.08) inset;
}
.graph-svg-classic .graph-kind {
  paint-order: stroke;
  stroke: var(--surface);
  stroke-width: 5px;
}
@media (max-width: 680px) {
  .graph-toolbar { align-items: stretch; flex-direction: column; }
  .graph-toolbar-actions { justify-content: space-between; width: 100%; }
  .graph-mode-switch { flex: 1 1 auto; }
  .graph-mode-button { flex: 1 1 50%; padding-inline: 8px; }
  .graph-toolbar-actions #graph-reset { flex: 0 0 auto; }
}

/* v1.2.5 — stable continuation tabs + admin episode override */
.section-tab-count{display:inline-flex;align-items:center;justify-content:center;min-width:1.65em;height:1.65em;margin-left:5px;padding:0 .42em;border:1px solid var(--border);border-radius:999px;font-size:.72em;line-height:1;color:var(--muted);font-variant-numeric:tabular-nums;vertical-align:middle;}
.library-section-tab.is-active .section-tab-count{color:var(--text);}
.admin-episodes-inline{display:grid;justify-items:start;gap:5px;margin-top:8px;padding:0;border:0;border-radius:0;background:transparent;}
.admin-episodes-label{font-size:.72rem;color:var(--muted);line-height:1.2;}
.admin-episodes-controls{display:flex;align-items:center;gap:8px;max-width:100%;}
.admin-episodes-inline input[type=number]{width:96px;min-height:34px;padding:6px 8px;border:1px solid var(--border);border-radius:8px;background:var(--surface);color:var(--text);}
.admin-episodes-note{font-size:.72rem;color:var(--muted);line-height:1.3;}
.compact-button{min-height:34px;padding:6px 10px;}
@media(max-width:560px){.admin-episodes-controls{max-width:100%}.section-tab-count{min-width:1.55em;height:1.55em;}}

/* v1.2.8 — progressive library loading */
.library-load-sentinel {
  min-height: 48px;
  display: grid;
  place-items: center;
  color: var(--muted);
  font-size: .86rem;
}
.library-load-spinner:not([hidden]) { display: inline-flex; align-items: center; gap: 8px; }
.library-load-spinner:not([hidden])::before {
  content: '';
  width: 14px;
  height: 14px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: library-spin .7s linear infinite;
}
@keyframes library-spin { to { transform: rotate(360deg); } }

/* Mobile graph gestures: allow Pointer Events to own one-finger pan and two-finger pinch zoom. */
.graph-svg { touch-action: none; }


/* v1.2.12 — public legal pages for Google OAuth branding. */
.site-footer {
  display: flex;
  justify-content: center;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  padding: 18px 16px 28px;
  color: var(--muted);
  font-size: .82rem;
}
.site-footer a { color: var(--muted); text-decoration: none; }
.site-footer a:hover { color: var(--text); text-decoration: underline; }
.legal-page {
  width: min(880px, 100%);
  margin: 22px auto;
  padding: clamp(22px, 4vw, 42px);
}
.legal-page h1 { margin: 4px 0 6px; }
.legal-page h2 { margin: 28px 0 9px; font-size: 1.08rem; }
.legal-page p { line-height: 1.68; }
.legal-updated { margin-top: 0; color: var(--muted); font-size: .86rem; }
.legal-links { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 30px; }
@media (max-width: 560px) {
  .legal-page { margin: 10px auto; padding: 18px 16px; }
  .legal-page h2 { margin-top: 24px; }
  .legal-links .button { flex: 1 1 100%; text-align: center; }
}

/* Profile public-share controls */
.profile-share-card{margin-top:22px;padding:18px 20px;border:1px solid var(--border);border-radius:18px;background:var(--surface);}
.profile-share-card h2{margin:5px 0 8px;font-size:1.15rem;}
.profile-share-card form{margin:0;}
.profile-share-url{display:flex;gap:8px;align-items:center;margin:12px 0;}
.profile-share-url input{min-width:0;flex:1;border:1px solid var(--border);border-radius:11px;background:#0f131b;color:var(--text);padding:11px 12px;outline:none;}
@media(max-width:620px){.profile-share-url{align-items:stretch;flex-direction:column}.profile-share-url .button{width:100%}}

/* v1.2.13 — export, toast notifications and Continue Watching. */
.toast-container {
  position: fixed; right: max(14px, env(safe-area-inset-right)); bottom: max(16px, env(safe-area-inset-bottom));
  z-index: 1200; display: grid; gap: 8px; width: min(380px, calc(100vw - 28px)); pointer-events: none;
}
.toast {
  opacity: 0; transform: translateY(8px); transition: .18s ease; pointer-events: auto; cursor: pointer;
  padding: 11px 14px; border: 1px solid var(--border); border-radius: 12px; background: color-mix(in srgb, var(--surface) 94%, #000 6%);
  color: var(--text); box-shadow: 0 12px 36px rgba(0,0,0,.28); font-size: .88rem; line-height: 1.35;
}
.toast.is-visible { opacity: 1; transform: translateY(0); }
.toast-success { border-color: color-mix(in srgb, var(--status-completed) 55%, var(--border)); }
.toast-error { border-color: color-mix(in srgb, #e85d67 65%, var(--border)); }
.toast-info { border-color: color-mix(in srgb, var(--accent) 55%, var(--border)); }

.export-menu { position: relative; }
.export-menu > summary { list-style: none; cursor: pointer; user-select: none; }
.export-menu > summary::-webkit-details-marker { display: none; }
.export-menu-popover {
  position: absolute; right: 0; top: calc(100% + 7px); z-index: 50; width: min(290px, calc(100vw - 28px));
  display: grid; padding: 7px; border: 1px solid var(--border); border-radius: 13px; background: var(--surface); box-shadow: 0 16px 42px rgba(0,0,0,.28);
}
.export-menu-popover a { display: grid; gap: 2px; padding: 9px 10px; border-radius: 9px; color: var(--text); text-decoration: none; font-weight: 750; }
.export-menu-popover a:hover { background: var(--surface-2); }
.export-menu-popover span { color: var(--muted); font-size: .72rem; font-weight: 500; }

.continue-watching { margin: 18px 0; padding: 14px; border: 1px solid var(--border); border-radius: 16px; background: var(--surface); }
.continue-watching-head { display: flex; align-items: end; justify-content: space-between; gap: 12px; margin-bottom: 11px; }
.continue-watching-head h2 { margin: 2px 0 0; font-size: 1.15rem; }
.continue-watching-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 330px), 1fr)); gap: 9px; }
.continue-card { display: grid; grid-template-columns: 52px minmax(0,1fr) auto; gap: 10px; align-items: center; min-width: 0; padding: 8px; border: 1px solid var(--border); border-radius: 13px; background: var(--surface-2); }
.continue-cover img, .continue-cover .cover-placeholder { width: 52px; height: 74px; border-radius: 8px; object-fit: cover; }
.continue-card-main { min-width: 0; }
.continue-franchise { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--accent); font-size: .7rem; font-weight: 750; }
.continue-title { display: block; margin-top: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text); text-decoration: none; font-weight: 800; }
.continue-progress { margin-top: 7px; color: var(--muted); font-size: .78rem; font-weight: 700; }
.continue-progress-bar { height: 4px; margin-top: 5px; overflow: hidden; border-radius: 999px; background: color-mix(in srgb, var(--border) 70%, transparent); }
.continue-progress-bar span { display: block; height: 100%; border-radius: inherit; background: var(--accent); transition: width .2s ease; }
.continue-controls { display: grid; gap: 6px; }
.continue-step { width: 34px; height: 32px; border: 1px solid var(--border); border-radius: 9px; background: var(--surface); color: var(--text); font: inherit; font-size: 1.1rem; font-weight: 850; cursor: pointer; }
.continue-step:hover { border-color: var(--accent); }
.continue-step:disabled { opacity: .5; cursor: wait; }
.continue-step.primary-step { background: var(--accent); border-color: var(--accent); color: #fff; }
@media (max-width: 560px) {
  .continue-watching { padding: 10px; }
  .continue-watching-head { align-items: flex-start; }
  .continue-watching-head > .muted { display: none; }
  .continue-card { grid-template-columns: 46px minmax(0,1fr) auto; gap: 8px; }
  .continue-cover img, .continue-cover .cover-placeholder { width: 46px; height: 66px; }
  .export-menu { flex: 1 1 auto; }
  .export-menu > summary { justify-content: center; }
}

/* v1.2.14 — JSON import, remembered library filters, recent franchises. */
.import-library-inner { width: min(620px, calc(100vw - 30px)); }
.import-file-picker { display: grid; gap: 7px; margin-top: 14px; font-size: .82rem; font-weight: 750; }
.import-file-picker input[type=file] {
  width: 100%; padding: 10px; border: 1px dashed var(--border); border-radius: 11px;
  background: var(--surface-2); color: var(--text); font: inherit; font-size: .82rem;
}
.import-library-state { margin-top: 12px; padding: 9px 11px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface-2); font-size: .82rem; }
.import-library-state[data-type="success"] { border-color: color-mix(in srgb, var(--status-completed) 55%, var(--border)); }
.import-library-state[data-type="error"] { border-color: color-mix(in srgb, #e85d67 65%, var(--border)); }
.import-library-preview { display: grid; gap: 1px; margin-top: 10px; overflow: hidden; border: 1px solid var(--border); border-radius: 11px; }
.import-library-preview > div { display: flex; justify-content: space-between; gap: 16px; padding: 8px 10px; background: var(--surface-2); font-size: .8rem; }
.import-library-preview > div + div { border-top: 1px solid var(--border); }
.import-library-preview > div span { color: var(--muted); }
.import-library-preview > p { margin: 0; padding: 9px 10px; border-top: 1px solid var(--border); font-size: .76rem; }


/* v1.2.15 — library search, pinned franchises, undo toast and profile import. */
.library-search-control {
  display:flex; align-items:center; gap:7px; min-height:38px; min-width:min(300px,100%); flex:1 1 260px;
  padding:0 10px; border:1px solid var(--border); border-radius:10px; background:#0f131b; color:var(--muted);
}
.library-search-control:focus-within { border-color:var(--accent); }
.library-search-control input { min-width:0; width:100%; border:0; outline:0; background:transparent; color:var(--text); font:inherit; }
.library-franchise-actions { display:flex; align-items:center; justify-self:end; gap:4px; }
.library-pin {
  display:grid; place-items:center; width:30px; height:30px; padding:0; border:0; border-radius:8px; background:transparent;
  color:var(--muted); font:inherit; font-size:1.05rem; cursor:pointer; transition:.15s ease;
}
.library-pin:hover { background:var(--surface-2); color:var(--accent); }
.library-pin.is-pinned { color:#f2c94c; text-shadow:0 0 12px color-mix(in srgb,#f2c94c 45%,transparent); }
.library-pin:disabled { opacity:.5; cursor:wait; }
.toast { display:flex; align-items:center; gap:10px; }
.toast-message { flex:1; min-width:0; }
.toast-action { flex:0 0 auto; border:1px solid var(--accent); border-radius:8px; background:transparent; color:var(--accent); padding:5px 8px; font:inherit; font-size:.78rem; font-weight:800; cursor:pointer; }
.toast-action:hover { background:color-mix(in srgb,var(--accent) 10%,transparent); }
.toast-action:disabled { opacity:.55; cursor:wait; }
.import-profile-option { display:flex; align-items:flex-start; gap:9px; margin-top:11px; padding:10px 11px; border:1px solid var(--border); border-radius:11px; background:var(--surface-2); cursor:pointer; }
.import-profile-option input { margin-top:3px; }
.import-profile-option span { display:grid; gap:3px; font-size:.82rem; }
.import-profile-option small { color:var(--muted); font-size:.72rem; font-weight:500; }
@media(max-width:560px){ .library-search-control{flex-basis:100%}.library-pin{width:26px;height:26px}.library-franchise-actions{gap:1px} }
.library-franchise { grid-template-columns:34px 66px minmax(0,1fr) auto; }
@media(min-width:700px){ .library-franchise { grid-template-columns:42px 76px minmax(0,1fr) auto; } }
@media(max-width:520px){ .library-franchise { grid-template-columns:24px 58px minmax(0,1fr) auto; } }

/* v1.2.16 — user tags, bulk library editing and watch history. */
.franchise-tags { display:flex; flex-wrap:wrap; gap:5px; margin-top:7px; }
.franchise-tags span { padding:3px 7px; border-radius:999px; border:1px solid color-mix(in srgb,var(--accent) 42%,var(--border)); background:color-mix(in srgb,var(--accent) 9%,var(--surface-2)); color:var(--text); font-size:.7rem; }
.library-tag-edit,.library-pin { width:30px; height:30px; display:grid; place-items:center; border:1px solid transparent; border-radius:8px; background:transparent; color:var(--muted); cursor:pointer; font:inherit; }
.library-tag-edit:hover,.library-pin:hover { border-color:var(--border); background:var(--surface-2); color:var(--text); }
.library-tag-new { display:grid; gap:7px; color:var(--muted); font-size:.85rem; font-weight:700; }
.library-bulk-bar { position:sticky; top:10px; z-index:18; display:flex; align-items:center; flex-wrap:wrap; gap:8px; margin:10px 0 12px; padding:10px 12px; border:1px solid color-mix(in srgb,var(--accent) 55%,var(--border)); border-radius:14px; background:color-mix(in srgb,var(--surface) 94%,transparent); box-shadow:0 10px 34px rgba(0,0,0,.2); backdrop-filter:blur(10px); }
.library-bulk-bar[hidden] { display:none !important; }
.library-bulk-bar select,.bulk-tag-input { min-height:36px; border:1px solid var(--border); border-radius:9px; background:var(--surface-2); color:var(--text); padding:0 9px; font:inherit; }
.bulk-tag-input { width:min(190px,45vw); }
.library-franchise,.library-anime-entry { position:relative; }
.bulk-select { position:absolute; z-index:8; left:7px; top:7px; width:28px; height:28px; display:grid; place-items:center; border:1px solid var(--border); border-radius:8px; background:var(--surface); box-shadow:0 3px 12px rgba(0,0,0,.25); cursor:pointer; }
.bulk-select[hidden] { display:none !important; }
.bulk-select input { width:17px; height:17px; accent-color:var(--accent); }
.library-bulk-mode .library-index { opacity:.08; }
.library-bulk-mode .library-franchise:hover,.library-bulk-mode .library-anime-entry:hover { transform:none; }
.history-head { margin-bottom:16px; }
.history-list { display:grid; gap:8px; }
.history-item { display:grid; grid-template-columns:150px minmax(0,1fr); gap:16px; padding:13px 15px; border:1px solid var(--border); border-radius:14px; background:var(--surface); }
.history-item time { color:var(--muted); font-size:.8rem; padding-top:2px; }
.history-main { min-width:0; }
.history-title { color:var(--text); font-weight:800; text-decoration:none; }
a.history-title:hover { color:var(--accent); }
.history-franchise { margin-top:3px; color:var(--muted); font-size:.78rem; }
.history-change { display:flex; flex-wrap:wrap; gap:6px; margin-top:7px; }
.history-change span { padding:4px 8px; border-radius:8px; background:var(--surface-2); border:1px solid var(--border); font-size:.78rem; }
@media(max-width:620px){ .history-item{grid-template-columns:1fr;gap:5px}.library-bulk-bar{top:6px}.library-bulk-bar strong{width:100%}.franchise-tags{display:none}.library-tag-edit,.library-pin{width:27px;height:27px} }

/* v1.2.17 — history analytics, colored tags, maintenance page. */
.history-stats-grid{display:grid;grid-template-columns:repeat(4,minmax(0,1fr));gap:10px;margin-bottom:14px}.history-stats-grid article{padding:15px;border:1px solid var(--border);border-radius:14px;background:var(--surface);display:grid;gap:4px}.history-stats-grid span,.history-stats-grid small{color:var(--muted);font-size:.76rem}.history-stats-grid strong{font-size:1.45rem}.history-chart-card{padding:16px;border:1px solid var(--border);border-radius:16px;background:var(--surface);margin-bottom:14px}.history-section-head{display:flex;justify-content:space-between;align-items:center;margin-bottom:12px}.history-section-head h2{margin:2px 0 0}.history-bars{height:190px;display:grid;grid-template-columns:repeat(30,minmax(5px,1fr));align-items:end;gap:3px;border-bottom:1px solid var(--border);padding-top:12px;overflow:hidden}.history-bar-col{height:100%;display:grid;grid-template-rows:18px 1fr 22px;min-width:0;text-align:center}.history-bar-value{font-size:.62rem;color:var(--muted);overflow:hidden}.history-bar-track{height:100%;display:flex;align-items:end;justify-content:center}.history-bar-track i{display:block;width:min(14px,80%);min-height:0;border-radius:5px 5px 1px 1px;background:var(--accent)}.history-bar-col small{font-size:.58rem;color:var(--muted);white-space:nowrap;transform:rotate(-38deg);transform-origin:center top;padding-top:4px}.history-best-days{display:flex;flex-wrap:wrap;gap:7px;margin-top:13px;font-size:.76rem}.history-best-days span{padding:4px 7px;border:1px solid var(--border);border-radius:999px;background:var(--surface-2)}.history-filters{display:grid;grid-template-columns:repeat(4,minmax(130px,1fr)) auto auto;gap:9px;align-items:end;margin:0 0 14px;padding:12px;border:1px solid var(--border);border-radius:14px;background:var(--surface)}.history-filters label{display:grid;gap:5px;color:var(--muted);font-size:.72rem}.history-filters select{min-width:0;width:100%;padding:9px;border:1px solid var(--border);border-radius:9px;background:var(--surface-2);color:var(--text)}
.franchise-tags span{--tag-color:#8b93a7;border-color:color-mix(in srgb,var(--tag-color) 55%,var(--border));background:color-mix(in srgb,var(--tag-color) 16%,var(--surface-2));}.tag-color-dot{display:inline-block;width:10px;height:10px;border-radius:50%;background:var(--tag-color,#8b93a7);box-shadow:0 0 0 1px color-mix(in srgb,var(--tag-color,#8b93a7) 65%,var(--border))}.tag-manager-row{display:grid;grid-template-columns:minmax(0,1fr) auto;gap:10px;align-items:center}.tag-manager-name{display:flex;align-items:center;gap:8px;min-width:0}.tag-manager-row input[type=color]{width:42px;height:30px;padding:2px;border:1px solid var(--border);border-radius:8px;background:var(--surface)}
.maintenance-grid{display:grid;grid-template-columns:repeat(4,minmax(0,1fr));gap:10px;margin:14px 0}.maintenance-card{padding:14px;border:1px solid var(--border);border-radius:14px;background:var(--surface)}.maintenance-card strong{display:block;font-size:1.3rem;margin-top:5px}.maintenance-actions{display:flex;flex-wrap:wrap;gap:9px;margin:14px 0}.maintenance-table{width:100%;border-collapse:collapse}.maintenance-table th,.maintenance-table td{text-align:left;padding:9px;border-bottom:1px solid var(--border);font-size:.8rem}.maintenance-log{display:grid;gap:7px}.maintenance-log article{padding:10px 12px;border:1px solid var(--border);border-radius:10px;background:var(--surface)}.maintenance-log code{font-size:.75rem;word-break:break-word}.maintenance-muted{color:var(--muted);font-size:.76rem}
@media(max-width:900px){.history-stats-grid,.maintenance-grid{grid-template-columns:repeat(2,minmax(0,1fr))}.history-filters{grid-template-columns:repeat(2,minmax(0,1fr))}.history-bars{gap:2px}.maintenance-table{display:block;overflow:auto}}@media(max-width:560px){.history-stats-grid,.maintenance-grid,.history-filters{grid-template-columns:1fr}.history-bars{height:150px}.history-bar-value{display:none}}

.tag-new-row{display:grid;grid-template-columns:minmax(0,1fr) 46px;gap:8px;align-items:center}.tag-new-row input[type=color]{width:46px;height:38px;padding:2px;border:1px solid var(--border);border-radius:9px;background:var(--surface)}

.history-change .history-undo-badge{border-style:dashed;color:var(--muted)}

/* Tag CRUD + DB integrity additions */
.tag-manager-row{grid-template-columns:minmax(0,1fr) auto auto auto;}
.tag-manager-rename-input{width:100%;min-width:110px;border:1px solid var(--border);border-radius:8px;background:var(--surface-2);color:var(--text);padding:7px 9px;font:inherit;}
.integrity-list{display:grid;gap:8px;margin-top:12px;}
.integrity-check{border:1px solid var(--border);border-radius:12px;background:var(--surface-2);padding:0 12px;}
.integrity-check.has-issues{border-color:color-mix(in srgb,#d59a3a 60%,var(--border));}
.integrity-check summary{display:flex;align-items:center;gap:10px;cursor:pointer;padding:11px 0;}
.integrity-check summary span{margin-left:auto;min-width:28px;text-align:center;font-weight:800;}
.integrity-check summary small{color:var(--muted);}
.integrity-check p{margin:0 0 10px;}
.integrity-samples{display:grid;gap:5px;padding:0 0 12px;overflow:auto;}
.integrity-samples code{display:block;white-space:nowrap;padding:6px 8px;border-radius:7px;background:var(--surface);color:var(--muted);}
.maintenance-ok{margin:8px 0 0;font-weight:750;}
@media(max-width:760px){.tag-manager-row{grid-template-columns:minmax(0,1fr) auto;}.tag-manager-row [data-tag-rename],.tag-manager-row [data-tag-delete]{grid-column:auto;}.tag-manager-rename-input{min-width:0;}}

/* v1.2.19 — history pagination and backup maintenance. */
.history-pagination-head{display:flex;justify-content:space-between;gap:12px;margin:8px 2px;color:var(--muted);font-size:.78rem}.history-pagination{display:flex;justify-content:center;align-items:center;flex-wrap:wrap;gap:7px;margin:14px 0 4px}.history-pagination .button{min-width:38px;text-align:center}.backup-list{display:grid;gap:8px}.backup-row{display:grid;grid-template-columns:minmax(210px,1fr) 120px 150px auto;gap:10px;align-items:center;padding:10px 12px;border:1px solid var(--border);border-radius:10px;background:var(--surface-2)}.backup-row code{overflow:hidden;text-overflow:ellipsis}.backup-row-actions{display:flex;gap:6px;justify-content:flex-end}.backup-ok{font-weight:750}.backup-bad{color:var(--danger,#d9534f);font-weight:750}.maintenance-report-actions{display:flex;flex-wrap:wrap;gap:8px;align-items:center}@media(max-width:760px){.backup-row{grid-template-columns:1fr}.backup-row-actions{justify-content:flex-start}.history-pagination-head{display:grid;gap:3px}}

/* v1.2.20 — readonly sharing and compact continue controls. */
/* v1.2.21 — exact on-demand “Где посмотреть” provider lookup. */
.watch-search { position: relative; margin-top: 9px; width: fit-content; max-width: 100%; }
.watch-search-trigger {
  cursor: pointer; width: fit-content; padding: 6px 10px; border: 1px solid var(--border); border-radius: 9px;
  color: var(--text); background: var(--surface-2); font: inherit; font-size: .78rem; font-weight: 750;
}
.watch-search-trigger:hover, .watch-search.is-open .watch-search-trigger { border-color: color-mix(in srgb, var(--accent) 55%, var(--border)); }
/* v1.2.22 — compact, properly toggleable provider lookup. */
.watch-search-menu {
  position: relative; z-index: 10; display: grid; gap: 5px; box-sizing: border-box;
  width: min(360px, 100%); max-width: 100%; max-height: 230px; overflow: auto; margin-top: 6px;
  padding: 7px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface);
  box-shadow: 0 10px 24px rgba(0,0,0,.18);
}
.watch-search-menu[hidden] { display: none !important; }
.watch-search-query { color: var(--muted); font-size: .68rem; line-height: 1.3; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.watch-search-query strong { color: var(--text); }
.watch-search-loading, .watch-search-empty { padding: 7px 8px; border-radius: 8px; background: var(--surface-2); color: var(--muted); font-size: .72rem; line-height: 1.35; }
.watch-search-empty { border: 1px solid var(--border); }
.watch-search-failed { color: var(--danger, #e85d67); }
.watch-provider { display: grid; grid-template-columns: minmax(0,1fr) auto; gap: 8px; align-items: center; padding: 7px 8px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface-2); }
.watch-provider-found { border-color: color-mix(in srgb, var(--status-completed, #62c98d) 45%, var(--border)); }
.watch-provider-text { min-width: 0; display: grid; gap: 1px; }
.watch-provider-text strong { font-size: .74rem; }
.watch-provider-text small { color: var(--muted); font-size: .64rem; line-height: 1.25; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.watch-provider-open { padding: 5px 7px; border-radius: 7px; background: color-mix(in srgb, var(--accent) 13%, var(--surface)); color: var(--accent); text-decoration: none; font-size: .68rem; font-weight: 800; white-space: nowrap; }
.watch-provider-open:hover { outline: 1px solid color-mix(in srgb, var(--accent) 60%, transparent); }
.watch-provider-status { color: var(--muted); font-size: .68rem; font-weight: 750; white-space: nowrap; }
.continue-controls { display: flex; align-items: center; gap: 4px; padding: 3px; border: 1px solid var(--border); border-radius: 999px; background: var(--surface); }
.continue-step { width: 30px; height: 30px; border: 0; border-radius: 999px; background: transparent; color: var(--muted); font: inherit; font-size: 1rem; font-weight: 850; cursor: pointer; transition: background .15s ease,color .15s ease,transform .15s ease; }
.continue-step:hover { background: var(--surface-2); color: var(--text); transform: translateY(-1px); }
.continue-step[data-step="1"]:hover { color: var(--accent); }
.continue-step:disabled { opacity: .45; cursor: wait; transform: none; }

@media (max-width: 560px) {
  .continue-controls { align-self: center; }
}
.integrity-progress-sample { display:flex; align-items:center; justify-content:space-between; gap:12px; padding:9px 10px; border-radius:10px; background:var(--surface-2); }
.integrity-progress-sample > div:first-child { display:grid; gap:3px; min-width:0; }
.integrity-progress-sample strong { overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.integrity-progress-sample span { color:var(--muted); font-size:.76rem; }
.integrity-progress-values { display:flex; align-items:center; gap:9px; flex:0 0 auto; }
.integrity-progress-values > span { color:var(--warning,#d7a84f); font-weight:800; }
@media(max-width:650px){.integrity-progress-sample{align-items:flex-start;flex-direction:column}.integrity-progress-values{width:100%;justify-content:space-between;}}


/* v1.3.2 — personal watch URL inside “Где посмотреть”. */
.watch-provider-custom { border-color: color-mix(in srgb, var(--accent) 35%, var(--border)); }
.watch-provider-actions { display:flex; align-items:center; justify-content:flex-end; gap:5px; flex:0 0 auto; }
.watch-provider-edit, .watch-provider-remove {
  appearance:none; border:1px solid var(--border); background:var(--surface-3, var(--surface-2)); color:var(--text);
  border-radius:8px; min-height:27px; padding:4px 8px; font:inherit; font-size:.68rem; font-weight:700; cursor:pointer;
}
.watch-provider-edit:hover, .watch-provider-remove:hover { border-color:color-mix(in srgb, var(--accent) 55%, var(--border)); }
.watch-provider-remove { width:27px; padding:0; font-size:1rem; line-height:1; color:var(--muted); }
.watch-provider-custom-editor { display:grid; grid-template-columns:minmax(0,1fr) auto; gap:7px; align-items:center; }
.watch-provider-custom-editor input {
  width:100%; min-width:0; min-height:31px; border:1px solid var(--border); border-radius:8px; background:var(--surface-1, var(--surface));
  color:var(--text); padding:5px 8px; font:inherit; font-size:.72rem; outline:none;
}
.watch-provider-custom-editor input:focus { border-color:var(--accent); box-shadow:0 0 0 2px color-mix(in srgb, var(--accent) 18%, transparent); }
.watch-custom-editor-actions { display:flex; gap:5px; align-items:center; }
@media(max-width:440px){
  .watch-provider-actions{flex-wrap:wrap}.watch-provider-custom-editor{grid-template-columns:1fr}.watch-custom-editor-actions{justify-content:flex-end}
}

/* v1.3.3 — persistent provider links and compact admin editor. */
.watch-provider-admin { border-style:dashed; }
.watch-provider-admin-editor {
  display:grid; gap:7px; padding:8px; border:1px dashed color-mix(in srgb, var(--accent) 45%, var(--border));
  border-radius:8px; background:var(--surface-2);
}
.watch-admin-editor-title { font-size:.74rem; }
.watch-admin-provider-line { display:grid; grid-template-columns:82px minmax(0,1fr); gap:7px; align-items:center; }
.watch-admin-provider-line > span { color:var(--muted); font-size:.68rem; font-weight:750; }
.watch-admin-provider-line input {
  width:100%; min-width:0; min-height:30px; border:1px solid var(--border); border-radius:8px;
  background:var(--surface); color:var(--text); padding:5px 7px; font:inherit; font-size:.68rem; outline:none;
}
.watch-admin-provider-line input:focus { border-color:var(--accent); box-shadow:0 0 0 2px color-mix(in srgb, var(--accent) 16%, transparent); }
.watch-admin-editor-actions { display:flex; gap:5px; justify-content:flex-end; flex-wrap:wrap; }
@media(max-width:440px){.watch-admin-provider-line{grid-template-columns:1fr}.watch-admin-editor-actions{justify-content:flex-start}}

/* v1.3.4 — sane history activity and legacy anomaly markers. */
.history-item.is-anomalous{border-color:color-mix(in srgb,var(--warning,#d7a84f) 38%,var(--border));opacity:.78}.history-change .history-anomaly-badge{color:var(--warning,#d7a84f);border-color:color-mix(in srgb,var(--warning,#d7a84f) 55%,var(--border));background:color-mix(in srgb,var(--warning,#d7a84f) 10%,var(--surface-2));font-weight:750}
