/* KnowYourMech? — the Mercenary HUD theme matching Mods.MechWarrior5.SaveEditor
   (shared/…/Theme/Palette.Mercenary.xaml): gunmetal panels on a faint tactical grid, Rajdhani
   throughout, accent-cut panel corners, outlined chips. */

:root {
  --void: #07090b;
  --base: #0c1014;
  --panel: #12181e;
  --panel-raised: #19212a;
  --line: #27323d;
  --line-bright: #3a4856;
  --accent: #f2a51a;
  --accent-hot: #ffc24a;
  --accent-dim: #7a5410;
  --accent-wash: rgba(242, 165, 26, .13);
  --accent-grad: linear-gradient(#ffb933, #e08e0b);
  --text: #e8eaec;
  --muted: #8d99a5;
  --faint: #56626e;
  --danger: #e4573d;
  --danger-wash: rgba(228, 87, 61, .13);
  --ok: #86c25b;
  --ok-wash: rgba(134, 194, 91, .13);
  --info: #4fb3d9;
  --panel-grad: linear-gradient(#161d24, #0f1419);
  --header-grad: linear-gradient(90deg, #1b232c, #10161c 60%, #0c1014);
  --grid: rgba(22, 32, 42, .6);
  color-scheme: dark;
}
/* Faction colours: amber for the Inner Sphere, ice for the Clans. */
:root { --is: #f2a51a; --clan: #4fd1e8; --hud: "Rajdhani", "Bahnschrift", "Arial Narrow", "Segoe UI", sans-serif; }

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; min-height: 100%; }
body {
  background-color: var(--base);
  background-image:
    linear-gradient(var(--grid) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid) 1px, transparent 1px);
  background-size: 32px 32px;
  color: var(--text);
  font: 500 17px/1.4 var(--hud);
  font-variant-numeric: tabular-nums;
  display: flex; flex-direction: column; min-height: 100vh;
}
button, input, select { font: inherit; color: inherit; }
svg { flex: none; }
b, strong { font-weight: 700; }
a { color: var(--accent); }
a:hover { color: var(--accent-hot); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ===== Title bar ===== */
.titlebar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px 24px; flex-wrap: wrap;
  padding: 8px max(16px, env(safe-area-inset-right)) 8px max(16px, env(safe-area-inset-left));
  background: var(--void); border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; white-space: nowrap; }
.brand-mark { width: 26px; height: 26px; }
.brand-mark path { fill: none; stroke: var(--accent); stroke-width: 2; }
.brand-mark .pip { fill: var(--accent); stroke: none; }
.brand-name { font-size: 22px; font-weight: 700; color: var(--clan); letter-spacing: .01em; }
.brand-name em { font-style: normal; color: var(--accent); }
.brand-sub { color: var(--muted); font-size: 18px; font-weight: 600; }

/* ===== Shell ===== */
.shell { flex: 1; display: grid; grid-template-columns: 250px minmax(0, 1fr); min-height: 0; }
.sidebar {
  background: var(--void); border-right: 1px solid var(--line);
  display: flex; flex-direction: column; gap: 22px; padding: 22px 0 18px;
}
.readouts { display: grid; gap: 16px; padding: 0 22px; }
.readout { display: grid; gap: 2px; min-width: 0; }
.label { font-size: 13px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.readout strong { font-size: 28px; line-height: 1.05; color: var(--accent); overflow-wrap: anywhere; }
.readout strong.rank { color: var(--text); font-size: 22px; }
.meter { height: 4px; background: var(--line); margin-top: 6px; }
.meter i { display: block; height: 100%; width: 0; background: var(--accent); transition: width .4s; }
.hint { margin: 0; color: var(--muted); font-size: 15px; }
.nav { display: grid; }
.nav-item {
  position: relative; display: flex; align-items: center; gap: 12px; width: 100%; padding: 12px 22px;
  border: 0; background: transparent; color: var(--text); cursor: pointer; text-align: left;
  font-size: 18px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; user-select: none;
}
.nav-item svg { width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linejoin: round; color: var(--muted); }
.nav-item:hover { background: var(--panel); }
.nav-item.active { background: var(--accent-wash); color: var(--accent); }
.nav-item.active svg { color: var(--accent); }
.nav-item.active::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 3px; background: var(--accent); }
.sidebar-foot { margin-top: auto; display: grid; gap: 12px; padding: 0 18px; }
.note {
  margin: 0; padding: 8px 10px; font-size: 15px; color: var(--accent);
  border: 1px solid var(--accent-dim); background: var(--accent-wash);
}

.main { padding: 24px clamp(16px, 3vw, 32px) 40px; min-width: 0; }
.page { display: grid; gap: 18px; max-width: 980px; }

/* ===== Panels: accent-cut top-left and bottom-right corners ===== */
.panel {
  position: relative; background: var(--panel-grad); border: 1px solid var(--line);
  padding: 18px 20px; display: grid; gap: 16px; align-content: start;
}
.panel::before, .panel::after {
  content: ""; position: absolute; width: 14px; height: 14px; pointer-events: none;
}
.panel::before {
  top: -1px; left: -1px;
  background: linear-gradient(135deg, var(--base) calc(50% - 1px), var(--accent) calc(50% - 1px) calc(50% + 1px), transparent calc(50% + 1px));
}
.panel::after {
  bottom: -1px; right: -1px;
  background: linear-gradient(315deg, var(--base) calc(50% - 1px), var(--accent) calc(50% - 1px) calc(50% + 1px), transparent calc(50% + 1px));
}
.page-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px 16px; flex-wrap: wrap; }
h1, h2 { margin: 0; font-weight: 700; text-transform: uppercase; letter-spacing: .03em; line-height: 1.1; }
h1 { font-size: 30px; }
h2 { font-size: 20px; }
.meta { font-size: 15px; font-weight: 600; letter-spacing: .05em; text-transform: uppercase; color: var(--muted); }
.lede { margin: 0; color: var(--muted); max-width: 68ch; }

/* ===== Controls ===== */
.field { display: grid; gap: 8px; }
.seg { display: flex; flex-wrap: wrap; gap: 6px; }
.seg label {
  position: relative; cursor: pointer; padding: 6px 14px; border: 1px solid var(--line); background: var(--base);
  font-weight: 700; font-size: 16px; letter-spacing: .02em;
}
.seg label small { color: var(--faint); font-size: 13px; margin-left: 4px; }
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg label:hover { border-color: var(--line-bright); }
.seg label:has(input:checked) { border-color: var(--accent); background: var(--accent-wash); color: var(--accent); }
.seg label:has(input:checked) small { color: var(--accent-dim); }
.seg label:has(input:focus-visible) { outline: 2px solid var(--accent); outline-offset: 2px; }
.check { display: flex; align-items: center; gap: 10px; cursor: pointer; font-weight: 600; }
.check input {
  appearance: none; width: 20px; height: 20px; margin: 0; border: 1px solid var(--line-bright); background: var(--base);
  display: grid; place-items: center; cursor: pointer;
}
.check input::after { content: ""; width: 12px; height: 12px; background: var(--accent); transform: scale(0); transition: transform .12s; }
.check input:checked { border-color: var(--accent); }
.check input:checked::after { transform: scale(1); }
.check input:disabled { opacity: .4; cursor: default; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 40px; padding: 0 18px;
  border: 1px solid var(--line); border-radius: 2px; background: var(--panel-raised); color: var(--text); cursor: pointer;
  font-size: 17px; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; white-space: nowrap;
  user-select: none;
}
.btn svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 1.6; }
.btn small { font-size: 13px; opacity: .75; }
.btn:hover { border-color: var(--line-bright); }
.btn.primary { background: var(--accent-grad); border-color: var(--accent); color: var(--base); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.ghost { background: transparent; }
.btn.danger { background: transparent; color: var(--danger); border-color: var(--line); }
.btn.danger:hover { border-color: var(--danger); background: var(--danger-wash); }
.btn.danger.solid { background: var(--danger); color: var(--base); border-color: var(--danger); }
.btn.small { min-height: 30px; padding: 0 10px; font-size: 14px; }
.btn:disabled { opacity: .45; cursor: default; filter: none; }
.actions { display: flex; flex-wrap: wrap; align-items: center; justify-content: flex-end; gap: 10px; }
.status-line { margin-right: auto; color: var(--muted); font-size: 15px; }
.status-line b { color: var(--text); }

.rules { border: 1px solid var(--line); background: var(--base); padding: 8px 12px; }
.rules summary { cursor: pointer; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; font-size: 15px; color: var(--accent); }
.rules ul { margin: 8px 0 2px; padding-left: 20px; color: var(--muted); display: grid; gap: 3px; }
.rules b { color: var(--text); }

.chip {
  display: inline-flex; align-items: center; padding: 1px 7px; border: 1px solid currentColor; border-radius: 2px;
  font-size: 13px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); white-space: nowrap;
}
.chip.ok { color: var(--ok); background: var(--ok-wash); }
.chip.no { color: var(--danger); background: var(--danger-wash); }

/* ===== Quiz ===== */
.progress { height: 3px; background: var(--line); margin: -18px -20px 0; }
.progress i { display: block; height: 100%; width: 0; background: var(--accent); transition: width .3s; }
.tally { display: flex; gap: 22px; }
.stat { display: grid; justify-items: end; }
.stat b { font-size: 24px; line-height: 1; color: var(--accent); }
.viewer {
  position: relative; height: clamp(260px, 58vh, 580px); border: 1px solid var(--line);
  background-color: var(--void);
  background-image: linear-gradient(var(--grid) 1px, transparent 1px), linear-gradient(90deg, var(--grid) 1px, transparent 1px);
  background-size: 24px 24px;
}
.viewer img { width: 100%; height: 100%; object-fit: contain; display: block; }
.viewer .wait { position: absolute; inset: 0; display: grid; place-items: center; padding: 16px; text-align: center; color: var(--muted); font-weight: 600; letter-spacing: .06em; text-transform: uppercase; }
.reticle { position: absolute; inset: 10px; pointer-events: none; }
.reticle::before, .reticle::after { content: ""; position: absolute; width: 22px; height: 22px; border: 0 solid var(--accent); opacity: .8; }
.reticle::before { top: 0; left: 0; border-width: 2px 0 0 2px; }
.reticle::after { bottom: 0; right: 0; border-width: 0 2px 2px 0; }
.viewer .src { position: absolute; left: 12px; bottom: 12px; background: rgba(7, 9, 11, .82); color: var(--text); border-color: var(--line-bright); }
.viewer .reroll { position: absolute; right: 12px; bottom: 12px; background: rgba(7, 9, 11, .82); }
.answer-row { display: flex; gap: 8px; flex-wrap: wrap; }
.choices { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.choices .btn { justify-content: flex-start; background: var(--base); text-transform: none; letter-spacing: .01em; font-size: 18px; }
.choices .btn.right { border-color: var(--ok); color: var(--ok); background: var(--ok-wash); opacity: 1; }
.choices .btn.wrong { border-color: var(--danger); color: var(--danger); background: var(--danger-wash); text-decoration: line-through; opacity: 1; }

.verdict { display: grid; gap: 8px; border-top: 1px solid var(--line); padding-top: 14px; }
.verdict-top { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.points { font-size: 22px; font-weight: 700; color: var(--accent); }
.points small { font-size: 14px; color: var(--muted); font-weight: 600; margin-left: 6px; }
.idline { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 16px; }
.idline .name { font-size: 34px; font-weight: 700; line-height: 1.05; }
.spec { color: var(--muted); font-weight: 600; }
.spec b { color: var(--text); }
.faction { margin: 0; font-weight: 700; letter-spacing: .02em; }
.faction.is { color: var(--is); }
.faction.clan { color: var(--clan); }
.tells { margin: 0; max-width: 70ch; }
.tells::before { content: "Tells  "; font-size: 13px; font-weight: 700; letter-spacing: .08em; color: var(--accent); }
.credit { margin: 0; font-size: 14px; color: var(--faint); overflow-wrap: anywhere; }
.credit a { color: var(--muted); }

/* ===== Debrief & record ===== */
.debrief, .tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 12px; }
.debrief .readout, .tiles .readout { border: 1px solid var(--line); background: var(--base); padding: 10px 14px; }
.readout.big strong { font-size: 44px; }
.misses { display: flex; flex-wrap: wrap; gap: 6px; }
.misses .chip { color: var(--danger); font-size: 14px; letter-spacing: .04em; }
.misses.ok .chip { color: var(--ok); }
.rows { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--line); }
.rows li { display: flex; align-items: center; gap: 8px 14px; flex-wrap: wrap; padding: 9px 4px; border-bottom: 1px solid var(--line); }
.rows li:hover { background: var(--panel-raised); }
.rows .row-name { font-weight: 700; font-size: 18px; flex: 1 1 160px; }
.rows .row-meta { color: var(--muted); font-size: 15px; }
.rows .row-val { margin-left: auto; font-weight: 700; color: var(--accent); }
.acc-bar { width: 90px; height: 4px; background: var(--line); }
.acc-bar i { display: block; height: 100%; background: var(--danger); }

.prose p { margin: 0; max-width: 72ch; color: var(--muted); }
.prose b { color: var(--text); }
.sources { border-collapse: collapse; width: 100%; font-size: 16px; }
.sources th { text-align: left; font-size: 13px; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); padding: 6px 8px; border-bottom: 1px solid var(--line-bright); }
.sources td { padding: 7px 8px; border-bottom: 1px solid var(--line); }
.sources td:first-child { font-weight: 700; }

dialog.confirm:not([open]) { display: none; }
dialog.confirm { max-width: min(460px, calc(100vw - 32px)); color: var(--text); padding: 22px; }
dialog.confirm::backdrop { background: rgba(5, 8, 12, .75); }
dialog.confirm form { display: grid; gap: 14px; }
dialog.confirm p { margin: 0; color: var(--muted); }

/* ===== Small screens: the sidebar becomes a top strip ===== */
@media (max-width: 760px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { border-right: 0; border-bottom: 1px solid var(--line); padding: 12px 0 0; gap: 10px; min-width: 0; }
  .nav { min-width: 0; scrollbar-width: none; }
  .nav-item svg { display: none; }
  .readouts { grid-template-columns: 1fr 1fr; padding: 0 16px; }
  .readout strong { font-size: 24px; }
  .nav { grid-auto-flow: column; overflow-x: auto; }
  .nav-item { padding: 10px 14px; font-size: 15px; justify-content: center; white-space: nowrap; }
  .nav-item.active::before { top: auto; right: 0; width: auto; height: 3px; }
  .sidebar-foot { padding: 0 16px 12px; }
  .main { padding: 16px 16px 32px; }
  .brand-sub { display: none; }
  .choices { grid-template-columns: 1fr; }
  h1 { font-size: 24px; }
  .tally { gap: 14px; }
}
@media (prefers-reduced-motion: reduce) { .progress i, .meter i, .check input::after { transition: none; } }
