:root {
  --bg: #f6f7f9; --panel: #ffffff; --text: #1d2330; --muted: #667085; --border: #e3e6eb;
  --accent: #3b6fd8; --accent-text: #fff; --danger: #c43d3d; --ok: #2f8a4f; --row-hover: #f1f4fa;
  --tank: #3b6fd8; --healer: #2f9a57; --melee: #c9483f; --ranged: #d68a1a; --caster: #8a4fc9; --unknown: #888;
  --k-raidwide: #d4573b; --k-tankbuster: #3b6fd8; --k-targeted: #c99410; --k-auto: #8a94a6;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #12151b; --panel: #1b2029; --text: #e6e9ef; --muted: #98a2b3; --border: #2c3340;
    --accent: #6c97f0; --accent-text: #0d1117; --danger: #ef6b6b; --ok: #5cc184; --row-hover: #222936;
    --tank: #6c97f0; --healer: #5cc184; --melee: #ef6b6b; --ranged: #f0a947; --caster: #b384ef; --unknown: #999;
    --k-raidwide: #f07a5c; --k-tankbuster: #6c97f0; --k-targeted: #e8b53a; --k-auto: #8a94a6;
  }
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text);
       font: 14px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
.topbar { display: flex; gap: 16px; align-items: center; padding: 12px 24px;
          background: var(--panel); border-bottom: 1px solid var(--border); }
.brand { font-weight: 700; color: var(--text); font-size: 16px; }
#crumbs { color: var(--muted); }
#crumbs a { color: var(--muted); }
main { max-width: 1400px; margin: 0 auto; padding: 20px 24px 60px; }
h1 { font-size: 22px; margin: 0 0 4px; }
h2 { font-size: 16px; margin: 0 0 12px; }
.sub { color: var(--muted); margin-bottom: 18px; }
.panel { background: var(--panel); border: 1px solid var(--border); border-radius: 10px;
         padding: 16px 18px; margin-bottom: 18px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
@media (max-width: 900px) { .grid2 { grid-template-columns: 1fr; } }
.stats { display: flex; flex-wrap: wrap; gap: 12px; margin-bottom: 18px; }
.stat { background: var(--panel); border: 1px solid var(--border); border-radius: 10px; padding: 10px 16px; min-width: 130px; }
.stat .v { font-size: 20px; font-weight: 650; font-variant-numeric: tabular-nums; }
.stat .k { color: var(--muted); font-size: 12px; }

table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
th, td { padding: 6px 8px; border-bottom: 1px solid var(--border); text-align: right; white-space: nowrap; }
th { color: var(--muted); font-weight: 600; font-size: 12px; position: sticky; top: 0; background: var(--panel); }
th.sortable { cursor: pointer; user-select: none; }
th.sortable:hover { color: var(--text); }
td.l, th.l { text-align: left; }
tbody tr:hover { background: var(--row-hover); }
.scroll { overflow-x: auto; }
.tall { max-height: 520px; overflow: auto; }

form .row { display: flex; flex-wrap: wrap; gap: 12px; align-items: end; margin-bottom: 12px; }
label { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--muted); }
label.inline { flex-direction: row; align-items: center; gap: 6px; }
input, select, textarea, button { font: inherit; color: var(--text); background: var(--bg);
  border: 1px solid var(--border); border-radius: 6px; padding: 6px 8px; }
textarea { width: 100%; min-height: 64px; }
button { background: var(--accent); color: var(--accent-text); border-color: var(--accent); cursor: pointer; font-weight: 600; }
button.secondary { background: transparent; color: var(--accent); }
button:disabled { opacity: .5; cursor: default; }
input[type=search] { min-width: 240px; }

.log { background: var(--bg); border: 1px solid var(--border); border-radius: 6px; padding: 8px 10px;
       font: 12px/1.4 ui-monospace, Consolas, monospace; max-height: 220px; overflow: auto; white-space: pre-wrap; }
.muted { color: var(--muted); }
.err { color: var(--danger); }
.pill { display: inline-block; padding: 1px 7px; border-radius: 999px; font-size: 11px; font-weight: 600;
        color: #fff; margin-right: 3px; }
.pill.tank { background: var(--tank); } .pill.healer { background: var(--healer); }
.pill.melee { background: var(--melee); } .pill.ranged { background: var(--ranged); }
.pill.caster { background: var(--caster); } .pill.unknown { background: var(--unknown); }
.bar { height: 8px; background: var(--accent); border-radius: 4px; min-width: 1px; }
.chart-box { position: relative; height: 340px; }
.note { font-size: 12px; color: var(--muted); margin-top: 8px; }
details summary { cursor: pointer; font-weight: 600; }

/* ---------- nav / cards ---------- */
.nav-link { margin-left: auto; font-size: 13px; }
.admin-link { margin-left: 16px; color: var(--muted); font-size: 13px; }
.tabs { display: flex; gap: 4px; margin: -6px 0 16px; border-bottom: 1px solid var(--border); }
.tabs a { padding: 8px 14px; color: var(--muted); border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tabs a:hover { color: var(--text); text-decoration: none; }
.tabs a.active { color: var(--text); border-bottom-color: var(--accent); font-weight: 600; }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 14px; }
.card { display: block; background: var(--panel); border: 1px solid var(--border); border-radius: 10px; padding: 16px; color: var(--text); }
.card:hover { border-color: var(--accent); text-decoration: none; }
.card-zone { color: var(--muted); font-size: 12px; }
.card-title { font-size: 17px; font-weight: 650; margin: 2px 0 6px; }
.card-meta { color: var(--muted); font-size: 12px; }
h3 { font-size: 14px; margin: 16px 0 8px; }

/* ---------- timeline ---------- */
.tl-controls { display: flex; flex-wrap: wrap; gap: 16px; align-items: end; margin-bottom: 12px; }
.tl-filters { display: flex; flex-wrap: wrap; gap: 14px; align-items: center; padding-bottom: 6px; }
.tl-filters label { color: var(--text); font-size: 13px; }
.swatch { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 5px; vertical-align: -1px; }
.swatch.raidwide { background: var(--k-raidwide); } .swatch.tankbuster { background: var(--k-tankbuster); }
.swatch.targeted { background: var(--k-targeted); } .swatch.auto { background: var(--k-auto); }
.panel { position: relative; }
.tl-wrap { display: flex; border: 1px solid var(--border); border-radius: 8px; background: var(--bg); }
.tl-axis { flex: none; }
.tl-scroll { flex: 1; overflow-x: auto; overflow-y: hidden; }
.tl-scroll svg { display: block; }
.tl-grid { stroke: var(--border); stroke-width: 1; }
.tl-vgrid { stroke-dasharray: 2 4; }
.tl-lethal { stroke: var(--danger); stroke-width: 1; stroke-dasharray: 6 4; opacity: .7; }
.tl-label { fill: var(--muted); font-size: 11px; }
.tl-lethal-label { fill: var(--danger); font-size: 11px; opacity: .85; }
.tl-cast { cursor: pointer; }
.tl-cast .seg-taken { opacity: 1; }
.tl-cast .seg-shield { opacity: .55; }
.tl-cast .seg-mit { opacity: .3; }
.tl-cast .tl-head { stroke: var(--bg); stroke-width: 1.5; }
.tl-cast .tl-hit { fill: transparent; }
.tl-cast:hover .tl-head { stroke: var(--text); }
.tl-cast.selected .tl-head { stroke: var(--text); stroke-width: 2.5; }
.tl-cast.selected .tl-hit { fill: var(--text); opacity: .07; }
.tl-over { fill: var(--danger); font-size: 10px; font-weight: 700; }
.tl-death { fill: var(--danger); font-size: 12px; font-weight: 700; }
.tl-legend { display: flex; flex-wrap: wrap; gap: 16px; margin-top: 10px; font-size: 12px; align-items: center; }
.seg { display: inline-block; width: 14px; height: 10px; margin-right: 5px; vertical-align: -1px; background: var(--k-raidwide); border-radius: 2px; }
.seg.shield { opacity: .55; } .seg.mit { opacity: .3; }
.tl-tip { position: absolute; z-index: 10; pointer-events: none; background: var(--panel); border: 1px solid var(--border);
          border-radius: 8px; padding: 10px 12px; box-shadow: 0 6px 24px rgba(0,0,0,.25); min-width: 230px; font-size: 13px; }
.tip-title { font-weight: 650; font-size: 14px; }
.tip-sub { color: var(--muted); font-size: 12px; margin-bottom: 6px; }
.tip-grid { display: grid; grid-template-columns: auto auto; gap: 2px 14px; }
.tip-grid span { color: var(--muted); }
.tip-grid b { text-align: right; font-weight: 600; font-variant-numeric: tabular-nums; }

/* ---------- detail ---------- */
.detail-head { display: flex; justify-content: space-between; align-items: start; gap: 12px; flex-wrap: wrap; }
.detail-head h2 { margin-bottom: 2px; }
.detail-head .sub { margin-bottom: 12px; }
.detail-links { display: flex; gap: 16px; }
.buffs-cell { white-space: normal; min-width: 260px; color: var(--muted); font-size: 12px; }
.dead-row td { background: color-mix(in srgb, var(--danger) 10%, transparent); }
.hpbar { position: relative; width: 120px; height: 10px; background: var(--border); border-radius: 3px; overflow: hidden; }
.hpbar div { position: absolute; left: 0; top: 0; bottom: 0; }
.hp-before { background: var(--ok); opacity: .35; }
.hp-after { background: var(--ok); }
.hp-after.dead { background: var(--danger); }
.unsurv-row td { opacity: .55; }
.tag { display: inline-block; font-size: 10px; font-weight: 600; padding: 0 5px; border-radius: 4px;
       border: 1px solid var(--danger); color: var(--danger); vertical-align: 1px; }

/* ---------- icons ---------- */
.ab-icon { display: inline-flex; align-items: center; justify-content: center; flex: none; border-radius: 4px;
           color: #fff; margin-right: 6px; vertical-align: -4px; }
.ab-icon.k-raidwide { background: var(--k-raidwide); } .ab-icon.k-tankbuster { background: var(--k-tankbuster); }
.ab-icon.k-targeted { background: var(--k-targeted); } .ab-icon.k-auto { background: var(--k-auto); }
h1 .ab-icon, h2 .ab-icon { vertical-align: -3px; }
.st-icon { height: 20px; width: auto; vertical-align: -5px; margin-right: 5px; }
.buff-chip { display: inline-flex; align-items: center; margin: 1px 10px 1px 0; white-space: nowrap; }
.buff-chip .st-icon { height: 18px; margin-right: 3px; }

/* ---------- mitigation in the hover ---------- */
.tl-tip { position: fixed; max-width: 540px; }
.tl-mitjobs { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; margin: -2px 0 12px; font-size: 13px; }
.mitjobs-group { color: var(--muted); font-size: 12px; margin-left: 8px; }
.mitjob { gap: 4px; cursor: pointer; }
.mitjob .pill { margin: 0; }
.tip-mit { margin-top: 8px; padding-top: 8px; border-top: 1px solid var(--border); }
.tip-mit-h { font-weight: 600; font-size: 12px; margin-bottom: 6px; }
.mit-line { display: flex; align-items: flex-start; gap: 8px; padding: 3px 0; }
.mit-line + .mit-line { border-top: 1px dashed var(--border); }
.mit-line-label { flex: none; width: 56px; font-size: 12px; color: var(--muted); line-height: 22px; }
.mit-line-label .pill { margin: 0; }
.mit-chips { display: flex; flex-wrap: wrap; gap: 2px 10px; align-items: center; }
.mit-chip { display: inline-flex; align-items: center; gap: 3px; line-height: 22px; }
.mit-chip .st-icon { height: 20px; margin: 0; vertical-align: 0; }
.mit-chip b { font-size: 12px; font-weight: 600; font-variant-numeric: tabular-nums; }
.mit-chip.high b { color: var(--ok); }
.mit-chip.zero { opacity: .45; }
.mit-chip.na { opacity: .3; }
.mit-noicon { font-size: 10px; border: 1px solid var(--border); border-radius: 3px; padding: 0 3px; line-height: 16px; }
.mit-sep { font-size: 10px; color: var(--muted); border-left: 1px solid var(--border); padding-left: 8px; margin-left: 2px;
           text-transform: uppercase; letter-spacing: .04em; }
.mit-foot { font-size: 11px; margin-top: 4px; }

/* ---------- invulnerable hits ---------- */
.tl-immune { fill: var(--k-tankbuster); stroke: var(--bg); stroke-width: 1; }
.tag-immune { border-color: var(--k-tankbuster); color: var(--k-tankbuster); }

/* ---------- compare a log ---------- */
.cmp-form { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.cmp-form input { flex: 1; min-width: 260px; }
.cmp-form .note { flex-basis: 100%; margin-top: 0; }
.cmp-form.compact .note { display: none; }
.fight-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 8px; }
.fight-pick { display: flex; flex-wrap: wrap; gap: 4px 8px; padding: 8px 10px; border: 1px solid var(--border);
              border-radius: 8px; color: var(--text); }
.fight-pick:hover { border-color: var(--accent); text-decoration: none; }
.fight-pick.disabled { opacity: .45; cursor: not-allowed; }
.ok { color: var(--ok); }
.cmp-party { display: flex; flex-wrap: wrap; gap: 6px 14px; align-items: center; font-size: 13px; }
.cmp-member .pill { margin-right: 4px; }
.cmp-table td { vertical-align: middle; }
.cmp-row { cursor: pointer; }
.cmp-row.open td { background: var(--row-hover); }
.cmp-row.has-death td:first-child { box-shadow: inset 3px 0 0 var(--danger); }
.better { color: var(--ok); font-weight: 600; }
.worse { color: var(--danger); font-weight: 600; }
.note-chip { display: inline-flex; align-items: center; gap: 3px; font-size: 11px; padding: 1px 6px; border-radius: 10px;
             border: 1px solid var(--border); margin-right: 4px; white-space: nowrap; }
.note-chip .st-icon { height: 16px; margin: 0; vertical-align: 0; }
.note-chip.death { border-color: var(--danger); color: var(--danger); font-weight: 700; }
.note-chip.miss { border-color: var(--danger); color: var(--danger); }
.note-chip.fell { border-color: var(--k-targeted); color: var(--k-targeted); }
.note-chip.ready { border-color: var(--accent); color: var(--accent); }
.cmp-detail-row > td { background: var(--bg); text-align: left; white-space: normal; padding: 12px 14px 16px; }
.cmp-sec { margin-bottom: 14px; }
.cmp-sec h3 { margin: 4px 0 8px; }
.mit-chip.vs { padding: 0 4px; border-radius: 4px; border: 1px solid transparent; }
.mit-chip.vs .muted { font-size: 11px; }
.mit-chip.vs.missing { border-color: var(--danger); }
.mit-chip.vs.missing b { color: var(--danger); }
.mit-chip.vs.extra { border-color: var(--ok); }
.mit-chip.vs.extra b { color: var(--ok); }
.mit-legend { font-size: 11px; color: var(--muted); margin-top: 4px; }
.chip-wrap { display: flex; flex-wrap: wrap; gap: 6px 8px; }
.cmp-chip { display: inline-flex; align-items: center; gap: 5px; padding: 2px 8px; border: 1px solid var(--border);
            border-radius: 6px; font-size: 12px; background: var(--panel); }
.cmp-chip .st-icon { height: 18px; margin: 0; }
.cmp-chip .pill { margin: 0; }
.cmp-chip.strong { border-color: var(--accent); font-weight: 600; }
.cmp-chip.miss { border-color: var(--danger); }
.death-card { border: 1px solid var(--danger); border-radius: 8px; padding: 8px 10px; margin-bottom: 8px;
              background: color-mix(in srgb, var(--danger) 6%, transparent); white-space: normal; }
.death-missing { margin-top: 6px; display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }

/* ---------- boss portraits on the home page ---------- */
.cards { grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); }
.card-boss { display: flex; align-items: center; gap: 14px; padding: 12px; }
.boss-img { position: relative; flex: none; width: 76px; height: 76px; border-radius: 10px; overflow: hidden;
            background: var(--border); display: flex; align-items: center; justify-content: center; }
.boss-img::before { content: attr(data-initials); font-weight: 700; font-size: 22px; color: var(--muted); }
.boss-img img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.card-boss:hover .boss-img img { transform: scale(1.05); transition: transform .2s; }
.card-body { min-width: 0; }
.card-body .card-title { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
