/* Overview library + film detail, styled after HappyQuQu/library-cover-studio. */
:root {
  --lc-bg: var(--bg); --lc-surface: var(--surface); --lc-raised: var(--surface-subtle);
  --lc-line: var(--border); --lc-line-strong: var(--border-strong);
  --lc-text: var(--text); --lc-soft: var(--text-secondary); --lc-muted: var(--text-muted); --lc-faint: var(--text-faint); --lc-faint-text: var(--text-muted);
  --lc-accent: #9b4dca; --lc-accent-hover: #8841b5; --lc-accent-soft: #9b4dca1a;
  --lc-accent-text: #7e3aa8; --lc-dialog-bg: var(--surface); --lc-hover: var(--surface-muted);
  --lc-accent-border: #9b4dca80; --lc-shadow: #10182822;
}
:root[data-theme="dark"] {
  --lc-accent: #9f50c2; --lc-accent-hover: #984bbd; --lc-accent-soft: #b366d62e;
  --lc-accent-text: #d8b4fe; --lc-dialog-bg: #111113; --lc-hover: #2a2a2f;
  --lc-accent-border: #b366d680; --lc-shadow: #00000073;
}

[data-panel="overview"] { color: var(--lc-text); }
[data-panel="overview"] .lc-overview { display: grid; gap: 24px; }
[data-panel="overview"] svg { fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
[data-panel="overview"] .button { display: inline-flex; align-items: center; justify-content: center; gap: 6px; border-radius: 10px; }
[data-panel="overview"] .button svg { width: 16px; height: 16px; }
[data-panel="overview"] .button.primary { background: var(--lc-accent); color: var(--on-accent); box-shadow: 0 6px 18px var(--lc-accent-soft); }
[data-panel="overview"] .button.primary:hover { background: var(--lc-accent-hover); }
[data-panel="overview"] .button.secondary { background: var(--lc-raised); color: var(--lc-soft); border: 1px solid var(--control-border); }
[data-panel="overview"] .button.secondary:hover:not(:disabled) { background: var(--lc-hover); color: var(--lc-text); }
[data-panel="overview"] .icon-button { background: transparent; color: var(--lc-muted); border: 1px solid var(--control-border); border-radius: 10px; }
[data-panel="overview"] .icon-button:hover:not(:disabled) { color: var(--lc-text); border-color: var(--lc-faint); }
[data-panel="overview"] :is(input, select) { background: var(--lc-bg); color: var(--lc-text); border: 1px solid var(--control-border); border-radius: 10px; }
[data-panel="overview"] :is(input, select):focus { border-color: var(--lc-accent); box-shadow: 0 0 0 3px var(--lc-accent-soft); }
[data-panel="overview"] label { color: var(--lc-muted); }
[data-panel="overview"] .overview-panel { padding: 0; margin: 0; border: 0; background: none; box-shadow: none; overflow: visible; }
[data-panel="overview"] #overview-tasks { display: block; padding: 0; border: 0; background: none; box-shadow: none; }
.lc-loading { color: var(--lc-muted); padding: 40px 0; text-align: center; }

/* Use the theme text color so focus remains visible on either surface. */
[data-panel="overview"] .button.primary:focus-visible,
.lc-tabs button:focus-visible,
#task-detail-dialog .button.primary:focus-visible { outline: 2px solid var(--lc-text); outline-offset: 3px; }

/* ---------- Stats ---------- */
[data-panel="overview"] .lc-stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; margin: 0; }
[data-panel="overview"] .lc-stat { position: relative; overflow: hidden; display: grid; gap: 4px; padding: 22px 24px; background: var(--lc-surface); border: 1px solid var(--lc-line); border-radius: 16px; box-shadow: none; --tone: #8b5cf6 /* theme: fixed */; }
[data-panel="overview"] .lc-stat::after { content: ''; position: absolute; right: -40px; top: -40px; width: 140px; height: 140px; border-radius: 50%; background: radial-gradient(circle, color-mix(in srgb, var(--tone) 18%, transparent), transparent 70%); pointer-events: none; }
[data-panel="overview"] .lc-stat[data-tone="pink"] { --tone: #ec4899 /* theme: fixed */; }
[data-panel="overview"] .lc-stat[data-tone="amber"] { --tone: #f59e0b /* theme: fixed */; }
[data-panel="overview"] .lc-stat[data-tone="green"] { --tone: #22c55e /* theme: fixed */; }
[data-panel="overview"] .lc-stat .lc-stat-icon { display: grid; place-items: center; width: 44px; height: 44px; margin-bottom: 14px; border-radius: 12px; color: color-mix(in srgb, var(--tone) 60%, var(--lc-text)); background: color-mix(in srgb, var(--tone) 20%, var(--lc-surface)); }
[data-panel="overview"] .lc-stat .lc-stat-icon svg { width: 22px; height: 22px; stroke-width: 2; }
[data-panel="overview"] .lc-stat strong { margin: 0; color: var(--lc-text); font-size: 30px; line-height: 1.1; font-weight: 800; }
[data-panel="overview"] .lc-stat > span:last-child { color: var(--lc-muted); font-size: 13px; }

/* ---------- Toolbar ---------- */
.lc-toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 12px 16px; }
.lc-tabs { display: inline-flex; gap: 4px; padding: 4px; background: var(--lc-surface); border: 1px solid var(--lc-line); border-radius: 12px; }
.lc-tabs button { border: 0; padding: 8px 16px; border-radius: 9px; background: transparent; color: var(--lc-muted); font-weight: 600; cursor: pointer; transition: background .15s, color .15s; }
.lc-tabs button:hover { color: var(--lc-text); background: var(--lc-raised); }
.lc-tabs button.active { background: var(--lc-accent); color: var(--on-accent); }
.lc-tabs button.active:not([aria-selected="false"]):hover { background: var(--lc-accent-hover); }
.lc-tabs button.active[aria-selected="false"] { background: var(--lc-accent-soft); color: var(--lc-accent-text); }
[data-panel="overview"] .lc-search { flex: 1 1 260px; display: flex; align-items: center; gap: 8px; min-width: 0; margin: 0; padding: 0; border: 0; background: none; box-shadow: none; }
[data-panel="overview"] .lc-search label { position: relative; flex: 1; display: block; min-width: 0; }
[data-panel="overview"] .lc-search label svg { position: absolute; left: 12px; top: 50%; width: 16px; height: 16px; transform: translateY(-50%); color: var(--lc-faint); }
[data-panel="overview"] .lc-search input { width: 100%; padding: 9px 12px 9px 36px; background: var(--lc-surface); border-color: var(--control-border); }
[data-panel="overview"] .lc-search .button, [data-panel="overview"] .lc-search .icon-button { padding: 9px 14px; }
.lc-toolbar-actions { display: flex; align-items: center; gap: 14px; margin-left: auto; }
[data-panel="overview"] .switch-label { color: var(--lc-soft); }
[data-panel="overview"] .switch-track { background: var(--lc-line-strong); }
[data-panel="overview"] .switch-label input:checked + .switch-track { background: var(--lc-accent); }

/* ---------- Library cover cards ---------- */
.lc-section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin: 4px 0 16px; }
.lc-section-head h3 { margin: 0; color: var(--lc-text); font-size: 18px; }
.lc-section-head span { color: var(--lc-faint-text); font-size: 12px; }
.lc-library-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 330px), 1fr)); gap: 20px; }
.lc-library-card { display: grid; gap: 0; min-width: 0; padding: 12px; background: var(--lc-surface); border: 1px solid var(--lc-line); border-radius: 18px; color: inherit; text-align: left; cursor: pointer; transition: border-color .18s, transform .18s, box-shadow .18s; }
.lc-library-card:hover, .lc-library-card:focus-visible { border-color: var(--lc-accent-border); transform: translateY(-3px); box-shadow: 0 14px 34px var(--lc-shadow); outline: 0; }
.lc-library-card:hover .lc-cover { filter: brightness(1.06); }
.lc-library-meta { display: grid; gap: 3px; min-width: 0; padding: 14px 6px 4px; }
.lc-library-meta strong { overflow: hidden; color: var(--lc-text); font-size: 15px; white-space: nowrap; text-overflow: ellipsis; }
.lc-library-meta small, .lc-group-count { display: flex; align-items: center; gap: 7px; color: var(--lc-muted); font-size: 12px; }
.lc-library-meta small i, .lc-group-count i { width: 6px; height: 6px; border-radius: 50%; background: var(--lc-accent); }

/* ---------- 16:9 cover templates (sizes in cqw so every card scales like a 1920×1080 image) ---------- */
.lc-cover { --hue: 270; position: relative; display: block; aspect-ratio: 16 / 9; overflow: hidden; container-type: inline-size; isolation: isolate; border-radius: 12px; color: #fff /* theme: fixed */; background: linear-gradient(115deg, hsl(var(--hue) 32% 26%), hsl(var(--hue) 38% 44%)); transition: filter .2s; }
.lc-cover::before { content: ''; position: absolute; inset: 0; z-index: 1; pointer-events: none; }
.lc-cover img { display: block; width: 100%; height: 100%; object-fit: cover; }
.lc-blank { display: block; width: 100%; height: 100%; background: linear-gradient(150deg, hsl(var(--hue) 45% 72% / .45), hsl(var(--hue) 40% 32% / .5)); }
.lc-poster { display: block; aspect-ratio: 2 / 3; overflow: hidden; border-radius: 2.2cqw; background: #ffffff14 /* theme: fixed */; box-shadow: 0 1.2cqw 2.8cqw #0000006b /* theme: fixed */; }
.lc-cover-title { position: absolute; z-index: 3; left: 6.5cqw; top: 50%; display: grid; justify-items: start; gap: 1.3cqw; max-width: 40cqw; transform: translateY(-50%); pointer-events: none; }
.lc-cover-title b { display: -webkit-box; overflow: hidden; -webkit-line-clamp: 2; -webkit-box-orient: vertical; font: 800 calc(9.6cqw * var(--title-scale, 1)) / 1.12 "PingFang SC", "Microsoft YaHei", "Noto Sans CJK SC", "Noto Sans SC", sans-serif; letter-spacing: .02em; overflow-wrap: anywhere; text-shadow: .25cqw .3cqw .8cqw #0000008c /* theme: fixed */; }
.lc-cover-title em { padding-left: 1.3cqw; border-left: .55cqw solid hsl(var(--hue) 75% 72%); font: 700 2.5cqw/1.2 Inter, "Segoe UI", system-ui, sans-serif; font-style: normal; letter-spacing: .2em; text-shadow: .15cqw .2cqw .5cqw #00000080 /* theme: fixed */; }
.lc-backdrop { position: absolute; inset: 0; z-index: 0; overflow: hidden; }
.lc-backdrop img { transform: scale(1.25); filter: blur(2.6cqw) brightness(.5) saturate(1.15); }

/* 倾斜圆角海报墙 */
.lc-tpl-tilted { background: #202020 /* theme: fixed */; }
.lc-tpl-tilted::before { background: linear-gradient(90deg, #000000b3 0%, #00000073 34%, transparent 62%) /* theme: fixed */; }
.lc-tilt { position: absolute; z-index: 2; left: 41cqw; top: 50%; width: 66cqw; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 2.2cqw; transform: translateY(-50%) rotate(15deg); }
.lc-tpl-tilted .lc-cover-title { z-index: 3; }

/* 直列海报墙 */
.lc-tpl-upright { background: linear-gradient(180deg, hsl(var(--hue) 30% 34%), hsl(var(--hue) 34% 24%)); }
.lc-wall { position: absolute; z-index: 2; right: 0; top: -7cqw; width: 66.6cqw; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); }
.lc-wall .lc-poster { border-radius: 0; box-shadow: none; }
.lc-tpl-upright .lc-cover-title { max-width: 29cqw; left: 4cqw; }
.lc-tpl-upright .lc-cover-title b { font-size: calc(8cqw * var(--title-scale, 1)); }

/* 柔彩扇形 */
.lc-tpl-fan { background: linear-gradient(130deg, hsl(var(--hue) 70% 80%), hsl(calc(var(--hue) + 70) 62% 70%)); }
.lc-tpl-fan::before { background: radial-gradient(ellipse at 50% 0%, #ffffff59, transparent 60%) /* theme: fixed */; }
.lc-tpl-fan .lc-cover-title { left: 50%; top: 5.5cqw; justify-items: center; max-width: 80cqw; transform: translateX(-50%); text-align: center; }
.lc-tpl-fan .lc-cover-title b { font-size: calc(8.2cqw * var(--title-scale, 1)); -webkit-line-clamp: 1; }
.lc-tpl-fan .lc-cover-title em { padding: 0; border: 0; font-size: 2.4cqw; letter-spacing: .32em; }
.lc-fan { position: absolute; z-index: 2; inset: 0; }
.lc-fan .lc-poster { position: absolute; left: 50%; bottom: -9cqw; width: 19cqw; transform-origin: 50% 115%; transform: translateX(-50%) translateX(calc((var(--i) - 2) * 15.5cqw)) rotate(calc((var(--i) - 2) * 9deg)); }
.lc-fan .lc-poster:nth-child(2), .lc-fan .lc-poster:nth-child(4) { z-index: 1; }
.lc-fan .lc-poster:nth-child(3) { z-index: 2; width: 23cqw; bottom: -6cqw; }

/* 横幅背景海报列 */
.lc-tpl-strip::before { background: linear-gradient(180deg, #00000066 0%, transparent 45%, #000000a6 100%) /* theme: fixed */; }
.lc-tpl-strip .lc-backdrop img { filter: blur(1.2cqw) brightness(.6) saturate(1.1); }
.lc-tpl-strip .lc-cover-title { top: 6cqw; left: 5cqw; transform: none; max-width: 70cqw; }
.lc-tpl-strip .lc-cover-title b { font-size: calc(6.6cqw * var(--title-scale, 1)); -webkit-line-clamp: 1; }
.lc-strip { position: absolute; z-index: 2; left: 4cqw; right: 4cqw; bottom: 3.6cqw; display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 1.6cqw; }
.lc-strip .lc-poster { border-radius: 1.5cqw; }

/* 圆角叠卡 */
.lc-tpl-stacked { background: linear-gradient(120deg, hsl(var(--hue) 42% 28%), hsl(var(--hue) 48% 44%)); }
.lc-stack { position: absolute; z-index: 2; right: 9cqw; top: 50%; width: 29cqw; aspect-ratio: 1; transform: translateY(-50%); }
.lc-stack .lc-poster { position: absolute; inset: 0; width: 100%; height: 100%; aspect-ratio: auto; border-radius: 3cqw; }
.lc-stack .lc-poster:nth-child(1) { opacity: .3; transform: translateX(-5cqw) rotate(-9deg) scale(.94); }
.lc-stack .lc-poster:nth-child(2) { opacity: .45; transform: translateX(3.5cqw) rotate(6deg) scale(.97); }
.lc-stack .lc-main img { object-position: 50% 22%; }

/* 斜切大图 */
.lc-tpl-diagonal { background: linear-gradient(160deg, hsl(var(--hue) 40% 32%), hsl(var(--hue) 44% 22%)); }
.lc-diagonal { position: absolute; z-index: 2; top: 0; right: 0; bottom: 0; width: 64cqw; clip-path: polygon(24% 0, 100% 0, 100% 100%, 0 100%); }
.lc-diagonal img { object-position: 50% 22%; }
.lc-tpl-diagonal .lc-cover-title { max-width: 34cqw; }

/* 柔雾居中标题 */
.lc-tpl-plain { background: radial-gradient(circle at 20% 20%, hsl(calc(var(--hue) + 40) 60% 70% / .55), transparent 55%), radial-gradient(circle at 85% 80%, hsl(var(--hue) 60% 60% / .6), transparent 55%), linear-gradient(135deg, hsl(var(--hue) 40% 40%), hsl(var(--hue) 45% 26%)); }
.lc-tpl-plain .lc-cover-title { left: 50%; justify-items: center; max-width: 84cqw; transform: translate(-50%, -50%); text-align: center; }
.lc-tpl-plain .lc-cover-title em { padding: 0; border: 0; letter-spacing: .3em; }

/* ---------- Group header + film wall ---------- */
.lc-group-head { display: grid; grid-template-columns: minmax(0, 520px) minmax(0, 1fr); align-items: center; gap: 32px; margin-bottom: 26px; padding: 16px; background: var(--lc-surface); border: 1px solid var(--lc-line); border-radius: 20px; }
.lc-group-art .lc-cover { border-radius: 14px; }
.lc-group-info { display: grid; justify-items: start; gap: 10px; min-width: 0; }
.lc-group-info h2 { margin: 0; max-width: 100%; color: var(--lc-text); font-size: clamp(26px, 3vw, 40px); line-height: 1.15; overflow-wrap: anywhere; }
.lc-eyebrow { margin: 6px 0 0; color: var(--lc-accent-text); font-size: 11px; font-weight: 700; letter-spacing: .2em; }
.lc-back { display: inline-flex; align-items: center; gap: 4px; padding: 6px 12px 6px 8px; border: 1px solid var(--control-border); border-radius: 999px; background: var(--lc-raised); color: var(--lc-soft); font-weight: 600; cursor: pointer; }
.lc-back:hover { color: var(--lc-text); border-color: var(--lc-accent); }
.lc-back svg { width: 16px; height: 16px; }
[data-panel="overview"] .overview-cover-toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; margin: 0 0 18px; padding: 0 0 16px; border: 0; border-bottom: 1px solid var(--lc-line); border-radius: 0; background: none; }
[data-panel="overview"] .overview-cover-toolbar label { display: inline-flex; align-items: center; gap: 8px; color: var(--lc-muted); font-weight: 600; }
[data-panel="overview"] .overview-cover-toolbar select { padding: 7px 30px 7px 10px; }
[data-panel="overview"] .overview-selection-tools { display: flex; gap: 8px; margin-right: auto; }
[data-panel="overview"] .overview-selection-all svg, [data-panel="overview"] .overview-selection-delete svg { width: 16px; height: 16px; }
[data-panel="overview"] .overview-selection-delete { display: inline-grid; place-items: center; padding: 8px 10px; }
[data-panel="overview"] .overview-selection-delete:hover:not(:disabled) { color: var(--danger); border-color: var(--danger-border); background: var(--danger-soft); }

.lc-film-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 22px 18px; }
.lc-film { position: relative; display: grid; min-width: 0; background: var(--lc-surface); border: 1px solid var(--lc-line); border-radius: 14px; overflow: hidden; transition: border-color .18s, transform .18s, box-shadow .18s; }
.lc-film:hover { border-color: var(--lc-accent-border); transform: translateY(-3px); box-shadow: 0 14px 30px var(--lc-shadow); }
.lc-film.selected { border-color: var(--lc-accent); box-shadow: 0 0 0 2px var(--lc-accent); }
.lc-film-art { position: relative; aspect-ratio: 2 / 3; overflow: hidden; background: var(--lc-raised); }
.lc-film-cover { display: block; width: 100%; height: 100%; padding: 0; border: 0; background: none; cursor: pointer; }
.lc-film-cover img { display: block; width: 100%; height: 100%; object-fit: cover; transition: transform .35s; }
.lc-film:hover .lc-film-cover img { transform: scale(1.04); }
.lc-film-cover .overview-cover-placeholder { display: grid; place-content: center; justify-items: center; gap: 8px; width: 100%; height: 100%; color: #a1a1aa /* theme: fixed */; background: linear-gradient(160deg, #27272a, #18181b) /* theme: fixed */; }
.lc-film-cover .overview-cover-placeholder svg { width: 34px; height: 34px; fill: none; stroke: currentColor; }
.lc-film-cover .overview-cover-placeholder b { font-size: 12px; font-weight: 600; }
.lc-film-badges { position: absolute; left: 8px; top: 8px; display: flex; flex-wrap: wrap; gap: 6px; pointer-events: none; }
.lc-chip { display: inline-flex; align-items: center; padding: 3px 8px; border-radius: 7px; background: #09090bcc /* theme: fixed */; color: #d4d4d8 /* theme: fixed */; font-size: 11px; font-weight: 700; line-height: 1.4; backdrop-filter: blur(6px); }
.lc-chip-accent { background: #9f50c2 /* theme: fixed */; color: #fff /* theme: fixed */; }
.lc-chip-danger { background: #7f1d1dcc /* theme: fixed */; color: #fecaca /* theme: fixed */; }
.lc-film-caption { display: grid; gap: 4px; min-width: 0; padding: 11px 13px 13px; border: 0; background: none; color: inherit; text-align: left; cursor: pointer; }
.lc-film-id { color: var(--lc-accent-text); font: 700 11px/1.3 ui-monospace, SFMono-Regular, Consolas, monospace; letter-spacing: .04em; }
.lc-film-title { display: -webkit-box; overflow: hidden; -webkit-line-clamp: 2; -webkit-box-orient: vertical; min-height: 2.6em; color: var(--lc-text); font-size: 13px; font-weight: 600; line-height: 1.3; }
.lc-film-caption small { overflow: hidden; color: var(--lc-faint-text); font-size: 11px; white-space: nowrap; text-overflow: ellipsis; }
[data-panel="overview"] .overview-cover-select { position: absolute; z-index: 3; top: 8px; right: 8px; display: grid; place-items: center; width: 30px; height: 30px; padding: 4px; border: 1px solid #ffffff59 /* theme: fixed */; border-radius: 9px; background: #09090bb3 /* theme: fixed */; color: #fff /* theme: fixed */; cursor: pointer; }
[data-panel="overview"] .overview-cover-select.selected { background: var(--lc-accent); border-color: var(--lc-accent); }
[data-panel="overview"] .overview-cover-select svg { width: 18px; height: 18px; }

.library-play { position: absolute; z-index: 2; right: 10px; bottom: 10px; display: grid; place-items: center; width: 40px; height: 40px; padding: 0; border: 0; border-radius: 50%; background: var(--lc-accent); box-shadow: 0 6px 16px #0000008c /* theme: fixed */; cursor: pointer; opacity: .92; transition: transform .15s, background .15s, opacity .15s; }
.library-play img { width: 16px; height: 16px; margin-left: 2px; filter: brightness(0) invert(1); pointer-events: none; }
.library-play:hover, .library-play:focus-visible { background: var(--lc-accent-hover); opacity: 1; transform: scale(1.1); outline: 2px solid #fff /* theme: fixed */; outline-offset: 2px; }
.library-play:disabled { opacity: .45; cursor: wait; }

[data-panel="overview"] .overview-pagination { display: flex; flex-wrap: wrap; align-items: center; justify-content: flex-end; gap: 10px; margin-top: 26px; padding-top: 18px; border-top: 1px solid var(--lc-line); color: var(--lc-muted); }
[data-panel="overview"] .overview-pagination label { display: inline-flex; align-items: center; gap: 8px; }
[data-panel="overview"] .overview-pagination select { padding: 6px 28px 6px 10px; }
[data-panel="overview"] .lc-empty-state { display: grid; justify-items: center; gap: 10px; padding: 64px 20px; border: 1px dashed var(--lc-line-strong); border-radius: 18px; background: var(--lc-surface); color: var(--lc-muted); text-align: center; }
[data-panel="overview"] .lc-empty-state > span { display: grid; place-items: center; width: 56px; height: 56px; border-radius: 16px; background: var(--lc-accent-soft); color: var(--lc-accent-text); font-size: 24px; }
[data-panel="overview"] .lc-empty-state h3 { margin: 0; color: var(--lc-text); }
[data-panel="overview"] .lc-empty-state p { margin: 0; }
[data-panel="overview"] .form-error { color: var(--danger); }

/* ---------- Film detail dialog (执行历史-style dark modal) ---------- */
#task-detail-dialog { width: min(1120px, calc(100vw - 40px)); max-width: none; max-height: calc(100dvh - 40px); padding: 0; border: 1px solid var(--lc-line); border-radius: 18px; background: var(--lc-dialog-bg); color: var(--lc-soft); box-shadow: 0 30px 80px var(--lc-shadow); }
#task-detail-dialog::backdrop { background: var(--backdrop); backdrop-filter: blur(6px); }
#task-detail-dialog .film-detail-shell { padding: 0 0 24px; }
#task-detail-dialog .film-detail-shell > .panel-heading { position: static; display: flex; align-items: center; gap: 14px; margin: 0; padding: 18px 24px; background: var(--lc-dialog-bg); border-bottom: 1px solid var(--lc-line); backdrop-filter: blur(10px); }
#task-detail-dialog .film-detail-shell > .panel-heading > div { flex: 1; min-width: 0; }
.lc-dialog-icon { display: grid; place-items: center; flex: none; width: 44px; height: 44px; border-radius: 12px; background: var(--lc-accent); color: var(--on-accent); }
.lc-dialog-icon svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linejoin: round; }
#task-detail-dialog h2 { margin: 0; color: var(--lc-text); font-size: 18px; }
#task-detail-dialog h3 { color: var(--lc-text); }
#task-detail-dialog .muted { color: var(--lc-muted); }
#task-detail-dialog .icon-button { background: var(--lc-raised); color: var(--lc-soft); border: 1px solid var(--control-border); border-radius: 10px; }
#task-detail-dialog .icon-button:hover { color: var(--lc-text); }
#task-detail-dialog .button { border-radius: 10px; }
#task-detail-dialog .button.primary { display: inline-flex; align-items: center; gap: 8px; background: var(--lc-accent); color: var(--on-accent); }
#task-detail-dialog .button.primary:hover { background: var(--lc-accent-hover); }
#task-detail-dialog .button.primary img { width: 14px; height: 14px; filter: brightness(0) invert(1); }
#task-detail-dialog .button.secondary { background: var(--lc-raised); color: var(--lc-soft); border: 1px solid var(--control-border); }
#task-detail-dialog .button.danger { background: var(--danger-fill); color: var(--on-accent); }
#task-detail-dialog :is(input, textarea, select) { background: var(--lc-bg); color: var(--lc-text); border: 1px solid var(--control-border); border-radius: 10px; }
#task-detail-dialog label { color: var(--lc-soft); }
#task-detail-dialog .film-navigation { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 6px; margin: 0; padding: 10px 24px; border-bottom: 1px solid var(--lc-line); background: var(--lc-dialog-bg); backdrop-filter: blur(10px); }
#task-detail-dialog .film-navigation button { padding: 6px 14px; border: 0; font-size: 13px; border-radius: 999px; background: transparent; color: var(--lc-muted); font-weight: 600; cursor: pointer; }
#task-detail-dialog .film-navigation button:hover { background: var(--lc-raised); color: var(--lc-text); }
#task-detail-dialog .film-navigation .film-nav-close { margin-left: auto; }
#task-detail-dialog .task-detail-content { display: grid; gap: 22px; padding: 22px 24px 0; }

.lc-film-hero { position: relative; isolation: isolate; display: grid; grid-template-columns: 220px minmax(0, 1fr); gap: 32px; padding: 28px; overflow: hidden; background: var(--lc-surface); border: 1px solid var(--lc-line); border-radius: 18px; }
.lc-film-backdrop { position: absolute; inset: -60px; z-index: -1; overflow: hidden; }
.lc-film-backdrop img { width: 100%; height: 100%; object-fit: cover; transform: scale(1.2); filter: blur(28px) brightness(.38) saturate(1.2); }
.lc-film-hero::after { content: ''; position: absolute; inset: 0; z-index: -1; background: linear-gradient(90deg, color-mix(in srgb, var(--lc-surface) 85%, transparent) 0%, color-mix(in srgb, var(--lc-surface) 55%, transparent) 55%, color-mix(in srgb, var(--lc-surface) 25%, transparent) 100%); }
/* Light text labels need a bright reading surface even over a black cover.
   This also covers privacy mode; the dark hero and image filters stay intact. */
:root:not([data-theme="dark"]) .lc-film-hero::after { background: linear-gradient(90deg, color-mix(in srgb, var(--lc-surface) 98%, transparent) 0%, color-mix(in srgb, var(--lc-surface) 97%, transparent) 55%, color-mix(in srgb, var(--lc-surface) 96%, transparent) 100%); }
:root[data-theme="dark"] .lc-film-hero::after { background: linear-gradient(90deg, color-mix(in srgb, var(--lc-surface) 88%, transparent) 0%, color-mix(in srgb, var(--lc-surface) 72%, transparent) 55%, color-mix(in srgb, var(--lc-surface) 60%, transparent) 100%); }
#task-detail-dialog .lc-film-hero .detail-poster-wrap { position: relative; width: 100%; height: auto; aspect-ratio: 2 / 3; margin: 0; overflow: hidden; border-radius: 14px; background: var(--lc-raised); box-shadow: 0 18px 40px var(--lc-shadow); }
#task-detail-dialog .lc-film-hero .detail-poster { display: block; width: 100%; height: 100%; max-height: none; margin: 0; object-fit: cover; border: 0; border-radius: 0; }
#task-detail-dialog .lc-film-hero .detail-poster-empty { display: grid; place-content: center; justify-items: center; gap: 8px; width: 100%; height: 100%; color: var(--lc-faint); }
#task-detail-dialog .lc-film-hero .detail-poster-empty svg { width: 34px; height: 34px; fill: none; stroke: currentColor; }
.lc-film-copy { display: grid; align-content: center; justify-items: start; gap: 14px; min-width: 0; }
.lc-film-copy .lc-film-badges { position: static; pointer-events: auto; }
#task-detail-dialog .film-title { margin: 0; color: var(--lc-text); font-size: clamp(20px, 2.2vw, 26px); line-height: 1.35; overflow-wrap: anywhere; }
.lc-actress { display: flex; flex-wrap: wrap; gap: 8px; }
.lc-actress span { padding: 4px 12px; border-radius: 999px; background: var(--lc-accent-soft); color: var(--lc-accent-text); font-size: 13px; font-weight: 600; }
.lc-facts { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px 28px; width: 100%; margin: 4px 0; }
.lc-facts div { min-width: 0; }
.lc-facts dt { color: var(--lc-faint-text); font-size: 12px; }
.lc-facts dd { margin: 2px 0 0; overflow: hidden; color: var(--lc-text); font-size: 14px; white-space: nowrap; text-overflow: ellipsis; }
.lc-film-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 4px; }

#task-detail-dialog .task-metadata-editor { padding: 22px; background: var(--lc-surface); border: 1px solid var(--lc-line); border-radius: 18px; }
#task-detail-dialog .detail-fanarts, #task-detail-dialog .comments-section { margin: 0; padding: 20px 22px; background: var(--lc-surface); border: 1px solid var(--lc-line); border-radius: 18px; }
#task-detail-dialog .film-section-heading h3 { display: flex; align-items: center; gap: 8px; margin: 0 0 14px; font-size: 16px; }
#task-detail-dialog .film-section-heading h3 span { padding: 1px 8px; border-radius: 999px; background: var(--lc-raised); color: var(--lc-muted); font-size: 12px; }
#task-detail-dialog .detail-fanart-grid { display: flex; gap: 10px; overflow-x: auto; overscroll-behavior-x: contain; scroll-snap-type: x proximity; padding-bottom: 6px; }
#task-detail-dialog .detail-fanart-grid > * { flex: 0 0 180px; scroll-snap-align: start; }
#task-detail-dialog .detail-fanart-grid img { display: block; flex: 0 0 180px; width: 180px; min-width: 0; height: 120px; aspect-ratio: 3 / 2; object-fit: cover; border-radius: 10px; background: var(--lc-raised); }
#task-detail-dialog .detail-fanart-empty { aspect-ratio: 3 / 2; border-radius: 10px; background: var(--lc-raised); border: 1px dashed var(--lc-line-strong); color: var(--lc-faint); }
#task-detail-dialog .film-files { margin: 0; padding: 0; background: var(--lc-surface); border: 1px solid var(--lc-line); border-radius: 18px; }
#task-detail-dialog .film-files[open] { padding-bottom: 16px; }
#task-detail-dialog .film-files > summary { display: flex; align-items: center; padding: 16px 22px; color: var(--lc-text); font-size: 14px; font-weight: 700; cursor: pointer; }
#task-detail-dialog details > summary::after { border-color: var(--control-border); background: var(--lc-raised); color: var(--lc-soft); }
#task-detail-dialog .film-files .detail-images { background: var(--lc-bg); border: 1px solid var(--lc-line); border-radius: 12px; }
#task-detail-dialog .film-file-data { margin: 0 22px; }
#task-detail-dialog :is(.film-file-data, .task-detail-data) dt { color: var(--lc-faint-text); }
#task-detail-dialog :is(.film-file-data, .task-detail-data) dd { color: var(--lc-soft); }
#task-detail-dialog .detail-images { border-color: var(--lc-line); }
#task-detail-dialog :is(.task-detail-log, .task-log-wrap) { border-color: var(--lc-line); background: var(--lc-bg); color: var(--lc-soft); }
#task-detail-dialog .task-detail-log summary { color: var(--lc-text); }

/* ---------- Privacy mode ---------- */
html[data-privacy-mode="1"] :is(.lc-poster, .lc-diagonal, .lc-film-cover, .lc-film-hero .detail-poster-wrap) img { filter: blur(18px); transform: scale(1.12); }
html[data-privacy-mode="1"] .lc-backdrop img { filter: blur(5cqw) brightness(.4); }
html[data-privacy-mode="1"] .lc-film-backdrop img { filter: blur(40px) brightness(.3); }
html[data-privacy-mode="1"] #task-detail-dialog .detail-fanart-grid img { filter: blur(18px); }
html[data-privacy-mode="1"] #task-detail-dialog .detail-fanart-grid { overflow-x: auto; }

/* Keep film information, stills and comments together on desktop. */
#task-detail-dialog { width: min(1320px, calc(100vw - 32px)); }
#task-detail-dialog .film-detail-shell { display: grid; grid-template-columns: minmax(0, 1fr) 330px; padding-bottom: 12px; }
#task-detail-dialog .film-detail-shell > .panel-heading, #task-detail-dialog .film-navigation { grid-column: 1 / -1; }
#task-detail-dialog .task-detail-content { min-width: 0; gap: 12px; padding: 14px 14px 0; }
#task-detail-dialog .comments-section:not([hidden]) { grid-column: 2; grid-row: 3; align-self: start; max-height: calc(100dvh - 180px); overflow-y: auto; margin: 14px 14px 0 0; padding: 14px; }
#task-detail-dialog .comments-list { max-height: 240px; overflow-y: auto; overscroll-behavior: contain; }
#task-detail-dialog .comment-form textarea { min-height: 64px; }
#task-detail-dialog .comments-section .comment-form { display: grid; grid-template-columns: minmax(0, 1fr); padding: 12px; background: var(--lc-bg); border: 1px solid var(--lc-line); }
#task-detail-dialog .comment-item, #task-detail-dialog .comment-item-head strong, #task-detail-dialog .comment-item p { color: var(--lc-soft); }
#task-detail-dialog .comment-author, #task-detail-dialog .comment-author > span { color: var(--lc-soft); }
#task-detail-dialog .comment-profile-link { color: var(--lc-accent-text); }
#task-detail-dialog .comments-heading { gap: 10px; align-items: start; }
#task-detail-dialog .comments-heading > button { flex: none; white-space: nowrap; padding: 7px 10px; font-size: 12px; }
#task-detail-dialog .lc-film-hero .detail-poster-empty { background: var(--lc-raised); padding: 12px; border: 1px dashed var(--lc-line-strong); color: var(--lc-faint); }
#task-detail-dialog .lc-film-hero { grid-template-columns: 150px minmax(0, 1fr); gap: 20px; padding: 16px; }
#task-detail-dialog .lc-film-copy { gap: 9px; }
#task-detail-dialog .film-title { font-size: 20px; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
#task-detail-dialog .lc-facts { gap: 8px 16px; }
#task-detail-dialog .detail-fanarts { min-width: 0; padding: 12px 16px; }
#task-detail-dialog .film-section-heading h3 { margin-bottom: 10px; font-size: 14px; }
#task-detail-dialog .detail-fanart-empty { flex: 0 0 180px; width: 180px; height: 120px; min-width: 0; }
.artwork-edit-strip { display: flex; gap: 10px; overflow-x: auto; padding: 6px 0 12px; }
.artwork-edit-strip article { flex: 0 0 160px; display: flex; flex-wrap: wrap; gap: 6px; }
.artwork-edit-strip img { width: 160px; height: 108px; object-fit: cover; border-radius: 8px; }
.artwork-add { flex: none; align-self: center; cursor: pointer; }
.artwork-editor { min-width: 0; }
.artwork-editor h4 { margin: 12px 0 0; }

@media (max-width: 1000px) {
  #task-detail-dialog .film-detail-shell { grid-template-columns: minmax(0, 1fr); }
  #task-detail-dialog .comments-section:not([hidden]) { grid-column: 1; grid-row: auto; max-height: none; margin: 12px 14px; }
}

/* ---------- Responsive ---------- */
@media (max-width: 1100px) {
  [data-panel="overview"] .lc-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .lc-group-head { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 720px) {
  [data-panel="overview"] .lc-overview { gap: 18px; }
  [data-panel="overview"] .lc-stat { padding: 16px; }
  [data-panel="overview"] .lc-stat strong { font-size: 24px; }
  [data-panel="overview"] .lc-stat .lc-stat-icon { width: 36px; height: 36px; margin-bottom: 8px; }
  .lc-toolbar { align-items: stretch; }
  .lc-tabs { width: 100%; overflow-x: auto; }
  .lc-tabs button { flex: 1 0 auto; }
  .lc-toolbar-actions { width: 100%; justify-content: space-between; margin-left: 0; }
  .lc-library-grid { grid-template-columns: minmax(0, 1fr); gap: 14px; }
  .lc-library-card { padding: 8px; border-radius: 14px; }
  .lc-group-head { gap: 16px; padding: 10px; }
  .lc-film-grid { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 14px 12px; }
  #task-detail-dialog { width: calc(100vw - 16px); max-height: calc(100dvh - 16px); }
  #task-detail-dialog .film-detail-shell > .panel-heading { padding: 14px 16px; }
  #task-detail-dialog .film-navigation { padding: 10px 16px; overflow-x: auto; }
  #task-detail-dialog .task-detail-content { padding: 16px 12px 0; }
  .lc-film-hero { grid-template-columns: minmax(0, 1fr); gap: 20px; padding: 18px; }
  #task-detail-dialog .lc-film-hero .detail-poster-wrap { width: min(200px, 60%); justify-self: center; }
  .lc-facts { grid-template-columns: minmax(0, 1fr); }
}

/* =====================================================================
   Console-wide refresh. The overview is the reference: violet accent,
   soft surfaces, 16–18px cards, 10–12px controls, quiet semantic state.
   Low-specificity class rules loaded last, so each view keeps its own layout
   rules while success/warning/danger states stay semantic rather than violet.
   ===================================================================== */

/* ---------- Shell ---------- */
.sidebar { border-right: 1px solid var(--sidebar-control); }
.nav-item { border-radius: 10px; font-weight: 600; transition: background-color .15s ease, color .15s ease; }
.nav-item:hover { background: var(--sidebar-hover); color: var(--text-on-dark); }
.nav-item.active { background: var(--lc-accent); color: var(--on-accent); box-shadow: 0 6px 16px var(--lc-accent-soft); }
.nav-item:focus-visible { outline: 2px solid var(--on-accent); outline-offset: 2px; }
.sidebar-toggle { border-radius: 9px; }
@media (min-width: 801px) {
  /* Phone layouts keep the existing 21–23px titles from overrides.css. */
  .topbar { align-items: center; margin-bottom: 24px; }
  .topbar h1 { font-size: 26px; font-weight: 700; letter-spacing: -.02em; }
}
.eyebrow { color: var(--lc-accent-text); font-weight: 700; letter-spacing: .16em; }
.account-profile { border-radius: 999px; }
.account-profile:hover { border-color: var(--control-border); background: var(--lc-raised); }

/* ---------- Panels and headings ---------- */
.panel { border-color: var(--lc-line); border-radius: 16px; background: var(--lc-surface); box-shadow: none; }
.panel-heading { align-items: flex-start; gap: 16px; margin-bottom: 18px; }
.panel h2 { color: var(--lc-text); font-size: 17px; letter-spacing: -.01em; }
.panel h3 { color: var(--lc-text); font-size: 14px; }
.panel-heading .muted, .panel > .muted, .tab-intro span { color: var(--lc-muted); font-size: 12px; line-height: 1.6; }
.panel .muted { color: var(--lc-muted); }
.field-hint { color: var(--lc-muted); }
.form-message { color: var(--success); }
.form-error { color: var(--danger); }
.tab-intro { border-bottom-color: var(--lc-line); }
.mode-panel .code-editor { border-radius: 12px; }

/* ---------- Buttons ---------- */
.button { display: inline-flex; align-items: center; justify-content: center; gap: 6px; border-radius: 10px; font-weight: 600; transition: background-color .15s ease, border-color .15s ease, color .15s ease, box-shadow .15s ease; }
.button svg { flex: none; width: 16px; height: 16px; }
.button.primary { background: var(--lc-accent); color: var(--on-accent); box-shadow: 0 6px 18px var(--lc-accent-soft); }
.button.primary:hover:not(:disabled) { background: var(--lc-accent-hover); }
.button.secondary { border: 1px solid var(--control-border); background: var(--lc-raised); color: var(--lc-soft); }
.button.secondary:hover:not(:disabled) { background: var(--lc-hover); color: var(--lc-text); }
.button.danger { color: var(--on-accent); }
.button:focus-visible, .icon-button:focus-visible { outline: 2px solid var(--lc-accent); outline-offset: 2px; }
.button.primary:focus-visible { outline-color: var(--lc-text); }
.icon-button { border: 1px solid var(--control-border); border-radius: 10px; background: transparent; color: var(--lc-muted); }
.icon-button:hover:not(:disabled) { border-color: var(--lc-faint); background: var(--lc-hover); color: var(--lc-text); }
.task-delete, .task-card-tools .task-delete { border-radius: 9px; }
.task-toggle { border-radius: 9px; }

/* ---------- Form controls ---------- */
label { color: var(--lc-muted); }
input, select { padding: 9px 11px; border: 1px solid var(--control-border); border-radius: 10px; background: var(--lc-bg); color: var(--lc-text); }
textarea { border: 1px solid var(--control-border); border-radius: 10px; color: var(--lc-text); }
input:where([type="checkbox"], [type="radio"], [type="file"], [type="range"]) { padding: 0; border: 0; border-radius: 4px; background: none; }
input:focus, select:focus, textarea:focus { border-color: var(--lc-accent); box-shadow: 0 0 0 3px var(--lc-accent-soft); }
.check-label { color: var(--lc-soft); }
.switch-label { color: var(--lc-soft); }
.switch-track { background: var(--lc-line-strong); }
.switch-label input:checked + .switch-track { background: var(--lc-accent); }
.code-editor { border-radius: 12px; }

/* ---------- Segmented navigation (presets, downloads) ---------- */
.preset-tabs, .downloader-tabs { display: flex; gap: 4px; padding: 4px; margin: 0 0 18px; border: 1px solid var(--lc-line); border-radius: 12px; background: var(--lc-raised); overflow-x: auto; }
.preset-tab, .downloader-tab { flex: 0 0 auto; padding: 8px 15px; border: 1px solid transparent; border-radius: 9px; background: transparent; color: var(--lc-muted); font-size: 13px; font-weight: 600; cursor: pointer; transition: background-color .15s ease, color .15s ease; }
.preset-tab:hover, .downloader-tab:hover { background: var(--lc-surface); color: var(--lc-text); }
.preset-tab.active, .downloader-tab.active { border-color: transparent; background: var(--lc-accent); color: var(--on-accent); }
.preset-tab.active:hover, .downloader-tab.active:hover { background: var(--lc-accent-hover); color: var(--on-accent); }

/* ---------- Task cards, list rows and empty states ---------- */
.task-card, .auto-scrape-schedule-row, .auto-scrape-history-row, .schedule-run-task, .downloader-item,
.media-server-row, .preset-item, .crawler-config-group, .media-type-rule, .path-browser-row,
.crawler-test-panel, .download-table-wrap, .comment-item, .crawler-code-item, .progress-panel,
.google-cover-option, .avatar-option, .ai-action {
  border-color: var(--lc-line); border-radius: 12px; background: var(--lc-surface);
}
.task-card { border-radius: 14px; transition: border-color .18s ease, box-shadow .18s ease; }
.task-card:hover { border-color: var(--lc-accent-border); box-shadow: 0 10px 24px var(--lc-shadow); }
.task-list.empty, .download-list.empty {
  padding: 40px 20px; border: 1px dashed var(--lc-line-strong); border-radius: 16px;
  background: var(--lc-surface); color: var(--lc-muted); font-size: 13px; text-align: center;
}
.auto-scrape-schedule-main code, .overview-pagination select { border-radius: 8px; }
.auto-scrape-schedule-main code { background: var(--lc-raised); color: var(--lc-soft); }
.auto-scrape-schedule-actions .schedule-delete { color: var(--danger); border-color: var(--danger-border); }
.progress-track i { background: var(--lc-accent); }
.progress-panel { border-radius: 12px; }

/* ---------- Presets ---------- */
.preset-item { padding: 12px 14px; }
.preset-item:hover { border-color: var(--lc-accent-border); }
.preset-item.active { border-color: var(--lc-accent); background: var(--lc-accent-soft); color: var(--lc-text); }
.preset-item.active span { color: var(--lc-accent-text); }
.config-field-name { color: var(--lc-soft); }
.config-field small { color: var(--lc-muted); }
.config-field em { color: var(--lc-faint-text); }
.required-key-list, .config-array-tag, .crawler-tag { border-radius: 9px; }
.media-type-rule { padding: 12px; }

/* ---------- Downloads ---------- */
.download-filter-bar { gap: 10px; padding: 13px; border: 1px solid var(--lc-line); border-radius: 12px; background: var(--lc-raised); }
.download-summary span { padding: 4px 10px; border-radius: 999px; }
.download-table-wrap { border-color: var(--lc-line); }
.download-table th { border-color: var(--lc-line); background: var(--lc-raised); }
.download-table td { border-color: var(--lc-line); }
.download-progress em, .download-progress-cell em { background: var(--lc-accent); }
.download-progress i, .download-progress-cell i { background: var(--surface-track); }
.download-policy-section { border-top-color: var(--lc-line); }
.download-policy-header h2 { font-size: 17px; }
.download-auto-scrape { border-color: var(--lc-accent-border); border-radius: 12px; background: var(--lc-accent-soft); }
.download-auto-scrape > strong { color: var(--lc-accent-text); }
.downloader-item:hover { border-color: var(--lc-accent-border); background: var(--lc-accent-soft); }
.downloader-item strong { color: var(--lc-text); }
.download-state-dot { background: var(--surface-control); }
.download-column-sort { color: var(--lc-muted); }
.download-column-sort:hover { background: var(--lc-raised); color: var(--lc-accent-text); }
.download-sort-mark { color: var(--lc-accent-text); }
.download-row-remove { color: var(--danger); }

/* ---------- Crawler configuration ---------- */
.crawler-config-group { padding: 16px; gap: 12px; }
.crawler-group-heading h3 { font-size: 15px; }
.crawler-group-heading p { color: var(--lc-muted); }
.crawler-group-source { color: var(--lc-accent-text); }
.crawler-group-selection { border-top-color: var(--lc-line); }
.crawler-tag { border-color: var(--lc-accent-border); background: var(--lc-accent-soft); color: var(--lc-accent-text); }
.crawler-tag-remove { color: var(--lc-accent-text); }
.crawler-tag-remove:hover { background: var(--accent-surface); color: var(--accent-ink); }
.crawler-code-item { padding: 10px; }
.crawler-code-item.active, .crawler-code-item:hover { border-color: var(--lc-accent); background: var(--lc-accent-soft); }
.crawler-unit { border-radius: 8px; }
.crawler-code-disabled { border-top-color: var(--lc-line); }
.crawler-test-panel { padding: 16px; }
.media-type-control-heading strong { font-size: 15px; }
.translator-engine-fields, .media-library-options, .path-mapping-row, .proxy-test-result { border-color: var(--lc-line); border-radius: 12px; }
.media-library-options { background: var(--lc-surface); }
.media-library-fieldset legend { color: var(--lc-soft); font-size: 14px; }
.translator-engine-field { color: var(--lc-muted); }
.naming-rule-popover { border-color: var(--lc-line); border-radius: 12px; }
.naming-rule-variable { border-radius: 8px; }

/* ---------- Settings and profile ---------- */
.user-row { border-bottom: 1px solid var(--lc-line); }
.user-row:last-child { border-bottom: 0; }
.media-server-row { padding: 14px; }
.cookiecloud-panel > summary { padding: 16px 18px; }
.cookiecloud-panel[open] > summary { border-bottom-color: var(--lc-line); }
.profile-form { border-color: var(--lc-line); border-radius: 14px; background: var(--lc-raised); }
.profile-comments { border-top-color: var(--lc-line); }
.avatar-option { padding: 10px 6px; }
.avatar-option.selected { border-color: var(--lc-accent); background: var(--lc-accent-soft); }
.empty-profile { border-radius: 12px; background: var(--lc-raised); color: var(--lc-muted); }
.comment-timestamp { border-radius: 5px; background: var(--lc-accent-soft); color: var(--lc-accent-text); }
.comment-markdown { color: var(--lc-soft); }
.comment-reply-quote { border-left-color: var(--lc-line-strong); color: var(--lc-muted); }
.comment-like, .comment-reply, .comment-profile-link { color: var(--lc-muted); }
.comment-reply:hover, .comment-profile-link { color: var(--lc-accent-text); }
.comment-like[aria-pressed="true"] { color: var(--lc-accent-text); }
.comments-section { border-top-color: var(--lc-line); }
.comments-heading h3 { color: var(--lc-text); font-size: 15px; }

/* ---------- AI workspace: keep the conversation layout, unify the surfaces ---------- */
.ai-history { border: 1px solid var(--lc-line); border-radius: 16px; background: var(--lc-raised); }
.ai-history-item.selected { background: var(--lc-accent-soft); }
.ai-history-select { color: var(--lc-soft); }
.ai-turn-user { background: var(--lc-accent-soft); color: var(--lc-text); }
.ai-composer { border: 1px solid var(--control-border); border-radius: 20px; background: var(--lc-surface); box-shadow: 0 6px 24px var(--lc-shadow); }
.ai-composer:focus-within { border-color: var(--lc-accent); box-shadow: 0 0 0 3px var(--lc-accent-soft); }
.ai-action { border-color: var(--lc-accent-border); }
.ai-code-block { border-color: var(--lc-line); border-radius: 12px; }
.ai-code-heading { background: var(--lc-raised); }
.ai-settings-card > summary { color: var(--lc-text); }
.ai-setting-group { border-color: var(--lc-line); border-radius: 12px; }
.ai-skill-row { border-bottom-color: var(--lc-line); }
.ai-empty h2 { color: var(--lc-text); }

/* ---------- Common dialogs ---------- */
dialog { border-radius: 18px; }
.app-dialog, .profile-dialog, .avatar-picker-dialog, .path-browser-dialog, .google-cover-dialog, .stills-dialog, .confirm-dialog {
  border: 1px solid var(--lc-line); border-radius: 18px; box-shadow: 0 30px 80px var(--lc-shadow);
}
dialog::backdrop { background: var(--backdrop); backdrop-filter: blur(6px); }
.dialog-heading { gap: 14px; padding: 18px 22px; border-bottom-color: var(--lc-line); }
.dialog-heading h2 { color: var(--lc-text); font-size: 17px; letter-spacing: -.01em; }
.dialog-close { display: inline-grid; place-items: center; min-width: 32px; min-height: 32px; padding: 0 9px; border: 1px solid var(--control-border); border-radius: 10px; background: var(--lc-raised); color: var(--lc-soft); font-size: 12px; font-weight: 600; }
.dialog-close:hover { border-color: var(--lc-faint); background: var(--lc-hover); color: var(--lc-text); }
.dialog-content { padding: 20px 22px; }
.dialog-text { padding: 20px 22px; color: var(--lc-soft); }
.dialog-actions { gap: 10px; padding: 16px 22px; border-top-color: var(--lc-line); }
.dialog-message { padding: 0 22px; }
.path-browser-toolbar code { border-color: var(--lc-line); border-radius: 8px; background: var(--lc-raised); color: var(--lc-soft); }
.path-browser-entry:hover { color: var(--lc-accent-text); background: var(--lc-accent-soft); }
.path-browser-enter { color: var(--lc-accent-text); }
.google-cover-option:hover { border-color: var(--lc-accent); }
.profile-dialog h2, .profile-dialog h3 { color: var(--lc-text); }
.verification-dialog { border-radius: 18px; }
.update-overlay-card { border-radius: 18px; }

/* ---------- Film detail: one close entry, viewable stills ---------- */
#task-detail-dialog .film-navigation button[hidden] { display: none; }
#task-detail-dialog .film-navigation .film-nav-close {
  display: inline-flex; align-items: center; gap: 6px; margin-left: auto; padding: 6px 14px;
  border: 1px solid var(--control-border); border-radius: 999px; background: var(--lc-raised);
  color: var(--lc-soft); font-weight: 600;
}
#task-detail-dialog .film-navigation .film-nav-close:hover { border-color: var(--lc-accent-border); background: var(--lc-hover); color: var(--lc-text); }
#task-detail-dialog .detail-fanart {
  flex: 0 0 180px; display: block; padding: 0; overflow: hidden; border: 1px solid var(--lc-line);
  border-radius: 10px; background: var(--lc-raised); cursor: zoom-in; scroll-snap-align: start;
  transition: border-color .15s ease, transform .15s ease;
}
#task-detail-dialog .detail-fanart:hover { border-color: var(--lc-accent-border); transform: translateY(-2px); }
#task-detail-dialog .detail-fanart:focus-visible { outline: 2px solid var(--lc-accent); outline-offset: 2px; }
#task-detail-dialog .detail-fanart img { display: block; width: 100%; height: 120px; aspect-ratio: 3 / 2; object-fit: cover; border-radius: 0; background: var(--lc-raised); }

/* ---------- Stills viewer ---------- */
.stills-dialog { width: min(1180px, calc(100vw - 40px)); max-width: none; max-height: calc(100dvh - 40px); padding: 0; border: 1px solid var(--lc-line); border-radius: 18px; background: var(--lc-dialog-bg); color: var(--lc-soft); box-shadow: 0 30px 80px var(--lc-shadow); overflow: hidden; }
.stills-shell { display: grid; grid-template-rows: auto minmax(0, 1fr) auto; max-height: calc(100dvh - 40px); }
.stills-heading { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 14px 18px; border-bottom: 1px solid var(--lc-line); }
.stills-heading h2 { margin: 0; color: var(--lc-text); font-size: 16px; }
.stills-heading .muted { margin: 2px 0 0; font-variant-numeric: tabular-nums; }
.stills-stage { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 12px; min-height: 0; padding: 14px 16px; }
.stills-figure { display: grid; place-items: center; gap: 10px; min-width: 0; margin: 0; }
.stills-image { display: block; width: auto; height: auto; max-width: 100%; max-height: calc(100dvh - 250px); object-fit: contain; border-radius: 12px; background: var(--lc-bg); }
.stills-image:not([src]) { display: none; }
.stills-error { margin: 0; padding: 40px 20px; border: 1px dashed var(--danger-border); border-radius: 12px; color: var(--danger); font-size: 13px; text-align: center; }
.stills-error[hidden] { display: none; }
.stills-nav { display: grid; place-items: center; width: 40px; height: 40px; padding: 0; border: 1px solid var(--control-border); border-radius: 12px; background: var(--lc-raised); color: var(--lc-soft); font-size: 22px; line-height: 1; cursor: pointer; }
.stills-nav:hover:not(:disabled) { border-color: var(--lc-accent-border); background: var(--lc-hover); color: var(--lc-text); }
.stills-nav:disabled { opacity: .4; cursor: not-allowed; }
.stills-nav:focus-visible { outline: 2px solid var(--lc-accent); outline-offset: 2px; }
.stills-hint { margin: 0; padding: 0 18px 14px; font-size: 11px; text-align: center; }
html[data-privacy-mode="1"] .stills-image { filter: blur(22px); transform: scale(1.02); }

@media (max-width: 720px) {
  .stills-dialog { width: calc(100vw - 16px); max-height: calc(100dvh - 16px); }
  .stills-shell { max-height: calc(100dvh - 16px); }
  .stills-heading { padding: 12px 14px; }
  .stills-stage { grid-template-columns: 34px minmax(0, 1fr) 34px; gap: 6px; padding: 10px; }
  .stills-nav { width: 34px; height: 34px; border-radius: 10px; font-size: 18px; }
  .stills-image { max-height: calc(100dvh - 230px); }
  .stills-hint { display: none; }
  #task-detail-dialog .detail-fanart, #task-detail-dialog .detail-fanart-empty { flex: 0 0 min(180px, 72vw); }
}

@media (max-width: 640px) {
  /* Preset tabs stay tappable as a 3-column grid on phones. */
  .preset-tabs { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; padding: 0; border: 0; background: none; overflow: visible; }
  .preset-tab { width: 100%; min-width: 0; min-height: 38px; padding: 7px 5px; border: 1px solid var(--control-border); border-radius: 10px; white-space: normal; overflow-wrap: anywhere; font-size: 12px; line-height: 1.25; }
  .preset-tab.active { border-color: var(--lc-accent); background: var(--lc-accent-soft); color: var(--lc-accent-text); }
  .preset-tab.active:hover { background: var(--lc-accent-soft); color: var(--lc-accent-text); }
  .dialog-heading, .dialog-content, .dialog-actions { padding-left: 16px; padding-right: 16px; }
  .dialog-message { padding-left: 16px; padding-right: 16px; }
}

@media (max-width: 360px) {
  .preset-tabs { grid-template-columns: 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  .nav-item, .button, .preset-tab, .downloader-tab, .task-card, #task-detail-dialog .detail-fanart { transition: none; }
}

/* ---------- Auth shell (login.html) ----------
   The login page loads this sheet for the same violet accent, radii and soft
   glow as the console. Only surface styling belongs here: the form markup, the
   login request, its hints and the theme bootstrap stay in login.html. */
.auth-shell { background: var(--bg); }
.auth-card { border: 1px solid var(--lc-line); border-radius: 18px; background: var(--lc-surface); box-shadow: 0 22px 56px var(--lc-shadow), 0 18px 44px -26px var(--lc-accent-border); }
.auth-card h1 { color: var(--lc-text); font-weight: 700; letter-spacing: -.01em; }
.auth-card label { color: var(--lc-soft); }
.auth-card .muted { color: var(--lc-muted); }
.auth-card .hint { color: var(--lc-faint-text); }
.auth-card input { border-radius: 10px; border-color: var(--control-border); }
.auth-card input:focus { border-color: var(--lc-accent); box-shadow: 0 0 0 3px var(--lc-accent-soft); }
.auth-card .button { border-radius: 10px; }
.auth-card .button.primary { background: var(--lc-accent); color: var(--on-accent); box-shadow: 0 8px 20px var(--lc-accent-soft); }
.auth-card .button.primary:hover:not(:disabled) { background: var(--lc-accent-hover); }
.auth-card .button.primary:focus-visible { outline: 2px solid var(--lc-accent-text); outline-offset: 3px; }
.auth-shell .auth-theme-toggle { border-radius: 10px; }
@media (max-width: 560px) {
  .auth-card { border-radius: 14px; }
}
