/* RuinLogs — iron-slate base, meter colours carried over from in-game damage meters */
:root {
  --bg: #14181d;
  --surface: #1b2027;
  --raised: #232a33;
  --line: #313a45;
  --line-soft: #262d36;
  --text: #ece6da;
  --muted: #9ba4ae;
  --faint: #6e7781;
  --ember: #e9a23b;      /* damage, primary actions */
  --ember-ink: #241703;
  --heal: #3fb89a;
  --taken: #e06a5f;
  --danger: #e06a5f;
  --s1: #3987e5; --s2: #d95926; --s3: #199e70; --s4: #c98500; --s5: #d55181;
  --radius-lg: 12px;
  --radius: 8px;
  --radius-sm: 5px;
  --ui: "Barlow Semi Condensed", "Arial Narrow", system-ui, sans-serif;
  --body: "Barlow", system-ui, -apple-system, "Segoe UI", sans-serif;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.55 var(--body);
}
a { color: var(--ember); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 3px; }
:focus-visible { outline: 2px solid var(--ember); outline-offset: 2px; border-radius: 3px; }
.num { font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.faint { color: var(--faint); }
[hidden] { display: none !important; }

/* ---------- layout ---------- */
.wrap { width: 100%; max-width: 1080px; margin: 0 auto; padding-left: 16px; padding-right: 16px; }
.site-main { flex: 1; padding-top: 36px; padding-bottom: 72px; }
.site-header { border-bottom: 1px solid var(--line-soft); background: var(--surface); }
.site-header .wrap { display: flex; align-items: center; gap: 28px; min-height: 60px; flex-wrap: wrap; }
.brand { display: flex; align-items: center; gap: 9px; color: var(--text); font: 700 22px/1 var(--ui); letter-spacing: .01em; }
.brand:hover { text-decoration: none; }
.brand svg { flex: none; }
.nav { display: flex; gap: 4px; flex-wrap: wrap; flex: 1; }
.nav a { color: var(--muted); font: 600 15px/1 var(--ui); padding: 9px 11px; border-radius: var(--radius-sm); }
.nav a:hover { color: var(--text); background: var(--raised); text-decoration: none; }
.nav a[aria-current="page"] { color: var(--text); box-shadow: inset 0 -2px 0 var(--ember); border-radius: 0; }
.account { display: flex; align-items: center; gap: 10px; font: 600 15px/1 var(--ui); }
.account img { width: 28px; height: 28px; border-radius: 50%; }
.account a.quiet { color: var(--muted); }
.site-footer { border-top: 1px solid var(--line-soft); color: var(--faint); font-size: 14px; padding: 22px 0; }

/* ---------- type ---------- */
h1, h2, h3 { font-family: var(--ui); font-weight: 700; line-height: 1.15; margin: 0; letter-spacing: .005em; }
h1 { font-size: clamp(28px, 4vw, 38px); }
h2 { font-size: 22px; margin-bottom: 14px; }
h3 { font-size: 18px; }
.lede { color: var(--muted); max-width: 62ch; margin: 8px 0 0; }
.section { margin-top: 44px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.meta-line { color: var(--muted); margin: 8px 0 0; display: flex; flex-wrap: wrap; gap: 4px 18px; }

/* ---------- controls ---------- */
input[type=text], input[type=search], select, textarea {
  width: 100%; padding: 10px 12px; border-radius: var(--radius);
  border: 1px solid var(--line); background: var(--bg); color: var(--text); font: inherit; font-size: 15px;
}
input::placeholder, textarea::placeholder { color: var(--faint); }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--ember); }
label.field { display: block; }
label.field > span { display: block; font: 600 14px/1 var(--ui); color: var(--muted); margin-bottom: 7px; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 10px 18px; border-radius: var(--radius); border: 1px solid transparent; cursor: pointer;
  font: 700 16px/1 var(--ui); background: var(--ember); color: var(--ember-ink); white-space: nowrap;
}
.btn:hover { filter: brightness(1.08); text-decoration: none; }
.btn:disabled { background: var(--raised); color: var(--faint); cursor: default; filter: none; }
.btn.secondary { background: transparent; color: var(--text); border-color: var(--line); }
.btn.secondary:hover { background: var(--raised); }
.btn.small { padding: 7px 12px; font-size: 14px; }
.btn.danger { background: transparent; color: var(--danger); border-color: color-mix(in srgb, var(--danger) 45%, transparent); }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

.status { min-height: 24px; margin-top: 12px; font-size: 15px; }
.status.err { color: var(--danger); }
.status.ok { color: var(--heal); }

/* ---------- upload ---------- */
.upload { background: var(--surface); border: 1px solid var(--line-soft); border-radius: var(--radius-lg); padding: 20px; margin-top: 24px; }
.drop {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px;
  min-height: 150px; padding: 24px 16px; text-align: center; cursor: pointer;
  border: 2px dashed var(--line); border-radius: var(--radius); background: var(--bg);
  transition: border-color .15s, background-color .15s;
}
.drop:hover, .drop.over { border-color: var(--ember); background: color-mix(in srgb, var(--ember) 6%, var(--bg)); }
.drop:focus-within { border-color: var(--ember); }
.drop .big { font: 700 20px/1.2 var(--ui); }
.drop .file-picked { color: var(--text); font-weight: 600; }
.upload-fields { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)) auto; gap: 12px; align-items: end; margin-top: 16px; }
@media (max-width: 760px) { .upload-fields { grid-template-columns: 1fr; } }
.ts-box { margin-top: 12px; }

/* ---------- tables ---------- */
.table-scroll { overflow-x: auto; margin: 0 -4px; padding: 0 4px; }
table { width: 100%; border-collapse: collapse; font-size: 15px; }
th, td { text-align: left; padding: 11px 10px; border-bottom: 1px solid var(--line-soft); vertical-align: top; }
th { color: var(--muted); font: 600 14px/1.2 var(--ui); white-space: nowrap; }
td.r, th.r { text-align: right; font-variant-numeric: tabular-nums; }
tbody tr:hover td { background: var(--surface); }
td .sub { display: block; color: var(--faint); font-size: 13.5px; margin-top: 2px; }
.empty { color: var(--muted); padding: 28px 10px; }
.toolbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: end; margin-bottom: 14px; }
.toolbar > * { flex: 1 1 180px; }
.toolbar > .btn { flex: 0 0 auto; }

/* ---------- stat strip ---------- */
.stats { display: flex; flex-wrap: wrap; gap: 0; margin: 26px 0 0; border: 1px solid var(--line-soft); border-radius: var(--radius-lg); background: var(--surface); }
.stat { flex: 1 1 140px; padding: 14px 18px; border-right: 1px solid var(--line-soft); }
.stat:last-child { border-right: 0; }
.stat b { display: block; font: 700 26px/1.1 var(--ui); font-variant-numeric: tabular-nums; }
.stat span { color: var(--muted); font-size: 14px; }

/* ---------- tabs ---------- */
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); margin: 34px 0 16px; overflow-x: auto; }
.tabs button {
  background: none; border: 0; color: var(--muted); font: 600 16px/1 var(--ui); padding: 12px 14px; cursor: pointer;
  box-shadow: inset 0 -2px 0 transparent; white-space: nowrap;
}
.tabs button:hover { color: var(--text); }
.tabs button[aria-selected="true"] { color: var(--text); box-shadow: inset 0 -2px 0 var(--ember); }

/* ---------- the meter: name sits on the bar, like the in-game meter ---------- */
.meter { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; }
.meter-row { display: grid; grid-template-columns: 26px 1fr; gap: 8px; align-items: stretch; }
.meter-rank { color: var(--faint); font: 600 14px/34px var(--ui); text-align: right; font-variant-numeric: tabular-nums; }
.meter-bar {
  position: relative; display: flex; align-items: center; justify-content: space-between; gap: 12px;
  min-height: 34px; padding: 0 12px; border-radius: var(--radius-sm); background: var(--surface);
  color: var(--text); font: 600 15px/1.2 var(--ui); text-align: left; width: 100%; border: 0; cursor: default; overflow: hidden;
}
button.meter-bar { cursor: pointer; }
button.meter-bar:hover { background: var(--raised); }
.meter-bar .fill {
  position: absolute; inset: 0 auto 0 0; background: color-mix(in srgb, var(--fill, var(--ember)) 26%, var(--surface));
  border-right: 2px solid var(--fill, var(--ember)); border-radius: var(--radius-sm) 0 0 var(--radius-sm);
}
.meter-bar > span { position: relative; }
.meter-bar .who { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: flex; align-items: baseline; gap: 8px; }
.meter-bar .who small { color: #c9c3b8; font-weight: 500; font-size: 13px; }
.meter-bar .val { white-space: nowrap; font-variant-numeric: tabular-nums; }
.meter-bar .val small { color: #c9c3b8; font-weight: 500; margin-left: 10px; }
.meter.heal { --fill: var(--heal); }
.meter.taken { --fill: var(--taken); }
.meter-row.open .meter-bar { border-radius: var(--radius-sm) var(--radius-sm) 0 0; }
.detail { grid-column: 2; background: var(--surface); border-radius: 0 0 var(--radius-sm) var(--radius-sm); padding: 4px 12px 12px; margin-top: -4px; }
.detail table { font-size: 14px; }
.detail th, .detail td { padding: 8px 8px; }
.detail .actions { margin-top: 10px; display: flex; gap: 14px; flex-wrap: wrap; font-size: 14px; }

/* ---------- chart ---------- */
.chart-card { background: var(--surface); border: 1px solid var(--line-soft); border-radius: var(--radius-lg); padding: 16px 16px 10px; }
.chart-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 8px; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: 14px; color: var(--text); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 14px; height: 3px; border-radius: 2px; display: inline-block; }
.chart { position: relative; }
.chart svg { display: block; width: 100%; height: auto; overflow: visible; }
.chart .grid line { stroke: var(--line-soft); }
.chart .axis text { fill: var(--faint); font: 12px var(--body); font-variant-numeric: tabular-nums; }
.chart .series path { fill: none; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart .death line { stroke: var(--taken); stroke-dasharray: 3 3; stroke-width: 1.5; }
.chart .cross { stroke: var(--muted); stroke-width: 1; }
.tip {
  position: absolute; pointer-events: none; background: var(--raised); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 8px 10px; font-size: 13.5px; min-width: 160px; z-index: 5;
  box-shadow: 0 6px 18px rgba(0,0,0,.35);
}
.tip b { font-family: var(--ui); display: block; margin-bottom: 4px; }
.tip div { display: flex; justify-content: space-between; gap: 14px; font-variant-numeric: tabular-nums; }
.tip i { display: inline-block; width: 10px; height: 3px; border-radius: 2px; margin-right: 6px; vertical-align: middle; }

/* ---------- deaths ---------- */
.death-list { display: grid; gap: 10px; }
.death { background: var(--surface); border: 1px solid var(--line-soft); border-left: 3px solid var(--taken); border-radius: var(--radius); }
.death summary { cursor: pointer; padding: 12px 14px; display: flex; gap: 14px; align-items: baseline; flex-wrap: wrap; list-style: none; }
.death summary::-webkit-details-marker { display: none; }
.death summary .t { color: var(--faint); font-variant-numeric: tabular-nums; min-width: 44px; }
.death summary .who { font: 700 16px/1.2 var(--ui); }
.death .recap { padding: 0 14px 12px; }
.death td.dmg { color: var(--taken); }
.death td.heal { color: var(--heal); }

/* ---------- compare ---------- */
.diff-up { color: var(--heal); }
.diff-down { color: var(--taken); }

/* ---------- misc ---------- */
.pill { display: inline-block; font: 600 12.5px/1 var(--ui); padding: 4px 7px; border-radius: 4px; background: var(--raised); color: var(--muted); vertical-align: middle; }
.notice { background: var(--surface); border: 1px solid var(--line-soft); border-radius: var(--radius); padding: 14px 16px; color: var(--muted); }
pre.raw { white-space: pre-wrap; word-break: break-word; max-height: 560px; overflow: auto; background: var(--surface); border: 1px solid var(--line-soft); border-radius: var(--radius); padding: 14px; font-size: 13px; }
dialog { background: var(--surface); color: var(--text); border: 1px solid var(--line); border-radius: var(--radius-lg); padding: 22px; width: min(440px, calc(100vw - 32px)); }
dialog::backdrop { background: rgba(5, 7, 9, .6); }
dialog h3 { margin-bottom: 10px; }
dialog textarea { min-height: 90px; resize: vertical; margin: 12px 0; }

@media (max-width: 640px) {
  .site-main { padding-top: 24px; }
  .site-header .wrap { gap: 10px 18px; padding-top: 10px; padding-bottom: 6px; }
  .nav { order: 3; flex-basis: 100%; margin: 0 -11px; }
  .stat { border-right: 0; border-bottom: 1px solid var(--line-soft); flex-basis: 50%; }
  .meter-row { grid-template-columns: 1fr; }
  .meter-rank { display: none; }
  .detail { grid-column: 1; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }

/* ---------- settings.txt help ---------- */
.fight-pick { margin-top: 16px; }
.where { margin-top: 14px; border: 1px solid var(--line-soft); border-radius: var(--radius); background: var(--bg); padding: 12px 16px; }
.where summary { cursor: pointer; font: 600 16px/1.3 var(--ui); color: var(--ember); }
.where p, .where ol { margin: 10px 0; }
.where ol { padding-left: 22px; }
.where li { margin: 5px 0; }
.where code { background: var(--raised); border: 1px solid var(--line-soft); border-radius: var(--radius-sm); padding: 1px 6px; font-size: 14px; overflow-wrap: anywhere; }
.where kbd { background: var(--raised); border: 1px solid var(--line); border-bottom-width: 2px; border-radius: var(--radius-sm); padding: 0 6px; font: 600 13px/1.6 var(--ui); }
.path-row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.path-row code { flex: 1 1 220px; padding: 8px 10px; font-size: 15px; }
.small-print { font-size: 14px; }
