/* v3: charts, continue watching, lists, notifications, calendar, feed, party, revisions,
   chronology, timecode comments, spoilers, account security, imports, PWA, graph */

/* ---------- chart tokens (reference palette, single series → slot 1) ---------- */
:root { --viz-1: #2a78d6; --viz-grid: rgba(0, 0, 0, .08); --viz-axis: #52514e; }
:root[data-theme="dark"] { --viz-1: #3987e5; --viz-grid: rgba(255, 255, 255, .08); --viz-axis: #c3c2b7; }
.viz { margin: 0; }
.viz svg { width: 100%; height: auto; display: block; overflow: visible; }
.viz-grid { stroke: var(--viz-grid); stroke-width: 1; }
.viz-base { stroke: var(--line); stroke-width: 1; }
.viz-axis { fill: var(--viz-axis); font: 11px system-ui, sans-serif; }
.viz-bar { fill: var(--viz-1); transition: opacity .1s; }
.viz-hit { cursor: default; }
svg:has(.viz-hit.hover) .viz-bar { opacity: .55; }
svg .viz-hit.hover .viz-bar { opacity: 1; }
.viz-line { fill: none; stroke: var(--viz-1); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.viz-area { fill: var(--viz-1); opacity: .1; }
.viz-dot { fill: var(--viz-1); stroke: var(--panel-solid); stroke-width: 2; opacity: 0; }
.viz-hit.hover .viz-dot { opacity: 1; }
.viz-cross { stroke: var(--viz-axis); stroke-width: 1; stroke-dasharray: 3 3; }
.viz-tip { position: fixed; z-index: 200; pointer-events: none; background: var(--panel-solid); color: var(--text); border: 1px solid var(--line); border-radius: 6px; padding: 6px 10px; font: 13px system-ui, sans-serif; box-shadow: 0 6px 20px rgba(0, 0, 0, .3); white-space: nowrap; }
.viz-tip b { color: var(--head); }
.viz-table { margin-top: 6px; font-size: 13px; } .viz-table summary { cursor: pointer; color: var(--muted); }
.viz-table .tbl { margin-top: 6px; }
.hb { display: flex; flex-direction: column; gap: 6px; }
.hb-row { display: grid; grid-template-columns: minmax(80px, 34%) 1fr 54px; gap: 10px; align-items: center; font-size: 14px; }
.hb-l { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--text); }
.hb-track { height: 12px; }
.hb-track i { display: block; height: 100%; min-width: 4px; background: var(--viz-1); border-radius: 0 4px 4px 0; }
.hb-row.hover .hb-track i { filter: brightness(1.15); }
.hb-v { text-align: right; color: var(--muted); font-variant-numeric: tabular-nums; }
.heat svg { max-width: 100%; }
.heat rect.h0, .heat-key .h0 { fill: var(--viz-grid); background: var(--viz-grid); }
.heat rect.h1, .heat-key .h1 { fill: color-mix(in srgb, var(--viz-1) 30%, var(--panel-solid)); background: color-mix(in srgb, var(--viz-1) 30%, var(--panel-solid)); }
.heat rect.h2, .heat-key .h2 { fill: color-mix(in srgb, var(--viz-1) 55%, var(--panel-solid)); background: color-mix(in srgb, var(--viz-1) 55%, var(--panel-solid)); }
.heat rect.h3, .heat-key .h3 { fill: color-mix(in srgb, var(--viz-1) 78%, var(--panel-solid)); background: color-mix(in srgb, var(--viz-1) 78%, var(--panel-solid)); }
.heat rect.h4, .heat-key .h4 { fill: var(--viz-1); background: var(--viz-1); }
.heat rect.hover { stroke: var(--text); stroke-width: 1.5; }
.heat-key { display: flex; gap: 4px; align-items: center; justify-content: flex-end; font-size: 12px; color: var(--muted); margin-top: 6px; }
.heat-key i { width: 12px; height: 12px; border-radius: 2px; }
.stat-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; margin-bottom: 20px; }
.stat-grid .box { margin: 0; }
.stat-grid .span-2 { grid-column: span 2; }
.toolbar-range { margin: 0 0 14px; }
.views button { background: none; border: 0; padding: 5px 12px; font: inherit; font-size: 15px; color: var(--text); cursor: pointer; }
.views button.on { background: var(--accent); color: var(--accent-ink); }

/* ---------- progress bars & continue watching ---------- */
.prog { position: absolute; left: 0; right: 0; bottom: 0; height: 4px; background: rgba(255, 255, 255, .25); }
.prog i { display: block; height: 100%; background: var(--accent); }
.tile-img .prog { z-index: 2; }
.tile-img:has(.prog) .ep { bottom: 8px; }
.cont .ep-img { aspect-ratio: 16/9; }
.cont-play { position: absolute; inset: 0; display: grid; place-items: center; font-size: 28px; color: #fff; background: rgba(0, 0, 0, .25); }
.hist { display: flex; flex-direction: column; gap: 8px; }
.hist-row { display: grid; grid-template-columns: 160px minmax(0, 1fr) auto auto; gap: 14px; align-items: center; background: var(--panel); padding: 8px; border-radius: var(--radius); color: var(--text); }
.hist-img { position: relative; display: block; }
.hist-img img { width: 100%; aspect-ratio: 16/9; object-fit: cover; border-radius: 3px; }
.hist-t b { display: block; color: var(--head); } .hist-t small { display: block; }
.lst-prog { display: inline-block; width: 70px; height: 6px; background: var(--panel-2); border-radius: 3px; overflow: hidden; vertical-align: middle; }
.lst-prog i { display: block; height: 100%; background: var(--accent); }
.lst-t { display: inline-flex; gap: 8px; align-items: center; color: var(--head); }
.list-dd > summary.btn { list-style: none; }
.list-dd .dd-body a.on { color: var(--accent) !important; font-weight: 700; }
.ext-ids a { font-size: 12px; border: 1px solid var(--line); border-radius: 3px; padding: 1px 6px; margin-right: 4px; color: var(--muted); }

/* ---------- notifications ---------- */
.bell { position: relative; font-size: 18px; padding: 4px 6px; }
.bell b, .tb-badge { position: absolute; top: -2px; right: -4px; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; background: var(--accent); color: var(--accent-ink); font: 700 11px/18px system-ui, sans-serif; text-align: center; }
.tabbar > button, .tabbar > a { position: relative; }
.tabbar .tb-badge { top: 6px; right: calc(50% - 22px); }
.tb-badge.in { position: static; display: inline-block; margin-left: 6px; }
.notifs { display: flex; flex-direction: column; }
.notif { display: grid; grid-template-columns: 40px 1fr; gap: 12px; align-items: center; padding: 12px 10px; border-bottom: 1px solid var(--line); color: var(--text); }
.notif small { display: block; }
.notif.unread { background: color-mix(in srgb, var(--accent) 10%, transparent); }
.notif.unread .notif-ico { box-shadow: 0 0 0 2px var(--accent); }
.notif-ico { width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; background: var(--panel-2); font-size: 18px; }

/* ---------- calendar ---------- */
.cal { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 8px; margin-bottom: 14px; }
.cal-day { background: var(--panel); border-radius: var(--radius); padding: 10px 8px; min-height: 200px; }
:root[data-skin="retro"] .cal-day { border: 1px solid var(--line); }
.cal-day.today { outline: 2px solid var(--accent); }
.cal-day h3 { font-size: 16px; } .cal-day h3 small { color: var(--muted); font-weight: 400; }
.cal-item { position: relative; display: grid; grid-template-columns: 34px 1fr; gap: 8px; padding: 6px 0; border-top: 1px dashed var(--line); color: var(--text); font-size: 13px; line-height: 1.25; }
.cal-item b { display: block; color: var(--head); } .cal-item small { display: block; }
.cal-img { width: 34px; aspect-ratio: 2/3; object-fit: cover; border-radius: 2px; }
.cal-mine { position: absolute; right: 0; top: 6px; color: var(--gold); font-style: normal; }

/* ---------- feed ---------- */
.feed { display: flex; flex-direction: column; gap: 12px; }
.feed-it { background: var(--panel); border-radius: var(--radius); padding: 12px 14px; }
:root[data-skin="retro"] .feed-it { border: 1px solid var(--line); }
.feed-it > .muted { margin-left: 8px; }
.feed-body { display: block; color: var(--text); margin-top: 6px; }
.feed-body img { width: 100%; max-width: 520px; aspect-ratio: 16/9; object-fit: cover; border-radius: var(--radius); }
.feed-it.k-episode { border-left: 3px solid var(--green); }

/* ---------- watch party ---------- */
.party { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 16px; align-items: start; }
.party-h { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 10px; }
.party-h h1 { margin: 0; }
.party-sync { color: #8bc34a; font-size: 14px; } .party-sync.busy { color: var(--gold); }
.party-members { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.pm { display: flex; flex-direction: column; align-items: center; gap: 2px; font-size: 12px; color: var(--muted); }
.party-chat { position: sticky; top: 104px; display: flex; flex-direction: column; height: calc(100vh - 140px); min-height: 360px; background: var(--panel); border-radius: var(--radius); }
:root[data-skin="retro"] .party-chat { border: var(--border-w) solid var(--line); }
.chat-log { flex: 1; overflow: auto; padding: 12px; display: flex; flex-direction: column; gap: 8px; }
.chat-msg { font-size: 15px; } .chat-msg small { color: var(--muted); margin-left: 6px; font-size: 11px; }
.chat-msg b { color: var(--accent); } .chat-msg.me b { color: var(--green); }
.chat-form { display: flex; gap: 6px; padding: 10px; border-top: 1px solid var(--line); }
.chat-form input { flex: 1; min-width: 0; }

/* ---------- revisions ---------- */
.revs { display: flex; flex-direction: column; gap: 10px; }
.rev { margin: 0; }
.rev-h { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 4px; }
.rev.st-rejected, .rev.st-reverted { opacity: .7; }
.diff-t { width: 100%; border-collapse: collapse; margin: 6px 0 10px; font-size: 14px; }
.diff-t th { text-align: left; color: var(--muted); font-weight: 400; width: 120px; padding: 4px 8px 4px 0; vertical-align: top; }
.diff-t td { padding: 4px 8px; vertical-align: top; width: 45%; }
.diff-t del { color: #e57373; text-decoration: line-through; } .diff-t ins { color: #8bc34a; text-decoration: none; }

/* ---------- chronology ---------- */
.fr { display: flex; flex-direction: column; gap: 6px; }
.fr-row { display: grid; grid-template-columns: 28px auto 1fr; gap: 4px 10px; align-items: center; background: var(--panel); padding: 8px 12px; border-radius: var(--radius); color: var(--text); }
.fr-row .muted { grid-column: 3; }
.fr-row b { color: var(--head); }
.fr-n { grid-row: span 2; font: 700 20px var(--font-head); color: var(--accent); text-align: center; }
.fr-row.k-movie .badge { background: #6a1b9a; color: #fff; } .fr-row.k-ova .badge { background: #1565c0; color: #fff; } .fr-row.k-spinoff .badge { background: #ef6c00; color: #fff; }

/* ---------- timecode comments ---------- */
.hp-tcm { position: absolute; left: 0; right: 0; top: 7px; height: 4px; pointer-events: none; }
.hp-tcm i { position: absolute; width: 4px; height: 4px; border-radius: 50%; background: #ffd54f; transform: translateX(-50%); }
.hp-tcm i.mine { background: #8bc34a; width: 6px; height: 6px; top: -1px; }
.hp-bubble { position: absolute; left: 14px; bottom: 16%; max-width: 60%; background: rgba(0, 0, 0, .78); border-left: 3px solid #ffd54f; padding: 6px 10px; border-radius: 3px; font-size: 13px; animation: pvin .2s; }
.tc-list { display: flex; flex-direction: column; gap: 4px; margin-bottom: 10px; }
.tc { display: flex; gap: 10px; align-items: center; padding: 6px 4px; border-bottom: 1px dashed var(--line); flex-wrap: wrap; }
.tc.new { background: color-mix(in srgb, var(--green) 12%, transparent); }
.tc-t { font: 700 13px ui-monospace, Consolas, monospace; background: var(--panel-2); border: 1px solid var(--line); border-radius: 3px; padding: 2px 6px; color: var(--link); cursor: pointer; }
.tc-like { margin-left: auto; background: none; border: 0; color: var(--muted); cursor: pointer; }
.tc-form { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; background: var(--panel); padding: 10px; border-radius: var(--radius); }
.tc-form input:not([type=checkbox]) { flex: 1; min-width: 160px; }

/* ---------- spoilers ---------- */
.spoiler { background: currentColor; color: inherit; border-radius: 3px; cursor: pointer; transition: background .2s; padding: 0 2px; }
.spoiler:not(.open) { color: transparent; background: var(--muted); user-select: none; }
.spoiler.open { background: color-mix(in srgb, var(--accent) 18%, transparent); }

/* ---------- auth & account ---------- */
.oauth { margin-top: 16px; text-align: center; }
.oauth-btns { display: flex; gap: 6px; flex-wrap: wrap; justify-content: center; margin-top: 8px; }
.oauth-btns b { font-family: system-ui, sans-serif; }
.sec-2fa { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin: 0; }
.sec-2fa small { display: block; }
.tbl.sess td small { display: block; color: var(--muted); }
.otp { font: 700 28px ui-monospace, Consolas, monospace !important; letter-spacing: .5em; text-align: center; }

/* ---------- import / downloads ---------- */
.imports { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; margin-bottom: 20px; }
.imp { display: flex; flex-direction: column; gap: 8px; margin: 0; }
.imp-h { display: flex; gap: 10px; align-items: center; }
.imp-ico { width: 34px; height: 34px; border-radius: 8px; display: grid; place-items: center; background: var(--accent); color: var(--accent-ink); font: 700 16px system-ui; }
.drop.sm { padding: 10px; font-size: 14px; }
.dl-usage { display: flex; gap: 10px; align-items: center; margin-bottom: 12px; }
.dl-usage .lst-prog { width: 200px; }

/* ---------- PWA install banner ---------- */
.install { position: fixed; left: 10px; right: 10px; bottom: calc(110px + env(safe-area-inset-bottom)); z-index: 95; display: flex; gap: 10px; align-items: center; padding: 10px 12px; background: var(--panel-solid); color: var(--text); border-radius: 12px; box-shadow: 0 10px 30px rgba(0, 0, 0, .45); border: 1px solid var(--line); }
.install > span { width: 36px; height: 36px; border-radius: 8px; display: grid; place-items: center; background: #d9534f; color: #fff; flex: none; }
.install div { flex: 1; } .install small { display: block; color: var(--muted); }
@media (min-width: 761px) { .install { left: auto; width: 380px; bottom: 60px; } }

/* ---------- relation graph ---------- */
.graph { margin: 0; background: var(--panel); border-radius: var(--radius); padding: 10px; }
.graph svg { width: 100%; height: auto; }
.g-edge { stroke: var(--line); stroke-width: 1.5; transition: stroke .15s, opacity .15s; }
.g-edge.main { stroke: var(--viz-1); opacity: .5; }
.graph svg.focus .g-edge { opacity: .12; }
.graph svg.focus .g-edge.on { opacity: 1; stroke: var(--accent); stroke-width: 2.5; }
.g-node text { fill: var(--text); font: 12px system-ui, sans-serif; }
.g-node.t circle { fill: var(--viz-1); stroke: var(--panel-solid); stroke-width: 2; }
.g-node .ring { fill: none; stroke: var(--panel-solid); stroke-width: 2; }
.g-node.hover .ring { stroke: var(--accent); stroke-width: 3; }
.ring.me { fill: none; stroke: var(--accent); stroke-width: 3; }

/* ---------- phone ---------- */
@media (max-width: 760px) {
  .stat-grid { grid-template-columns: minmax(0, 1fr); }
  .stat-grid .span-2 { grid-column: auto; }
  .cal { grid-template-columns: minmax(0, 1fr); }
  .cal-day { min-height: 0; }
  .cal-day:not(:has(.cal-item)) { display: none; }
  .hist-row { grid-template-columns: 110px minmax(0, 1fr); }
  .hist-row > .btn, .hist-row > button { display: none; }
  .party { grid-template-columns: minmax(0, 1fr); }
  .party-chat { position: static; height: 50vh; }
  .party-h h1 { font-size: 19px; }
  .diff-t th { width: 80px; }
  .diff-t td { display: block; width: auto; padding: 2px 0; }
  .fr-row { padding: 8px; }
  .bell { display: none; }
  .hp-bubble { max-width: 80%; font-size: 12px; }
  .hb-row { grid-template-columns: minmax(70px, 38%) 1fr 44px; font-size: 13px; }
  .tbl.lists td:nth-child(3), .tbl.lists th:nth-child(3), .tbl.lists td:nth-child(6), .tbl.lists th:nth-child(6), .tbl.lists td:first-child, .tbl.lists th:first-child { display: none; }
  .sec-2fa { flex-direction: column; align-items: flex-start; }
}
