/* Monster Gear Inc. — field operations design system.
 *
 * The premise: this is the internal portal of an outfitter that equips monster
 * hunters. Pages are company forms (MG-xx codes), cards are riveted spec plates,
 * characters carry manila gear tags, and anything the GM hides is stamped
 * CLASSIFIED. Dark by default because it is used at a table at night.
 *
 * Tokens first; every page's own <style> should use them, never raw colours.
 */

@font-face { font-family: "Barlow"; font-weight: 400; font-style: normal; font-display: swap;
  src: url("fonts/barlow-latin-400-normal.woff2") format("woff2"); }
@font-face { font-family: "Barlow"; font-weight: 400; font-style: italic; font-display: swap;
  src: url("fonts/barlow-latin-400-italic.woff2") format("woff2"); }
@font-face { font-family: "Barlow"; font-weight: 500; font-style: normal; font-display: swap;
  src: url("fonts/barlow-latin-500-normal.woff2") format("woff2"); }
@font-face { font-family: "Barlow"; font-weight: 600; font-style: normal; font-display: swap;
  src: url("fonts/barlow-latin-600-normal.woff2") format("woff2"); }
@font-face { font-family: "Barlow Condensed"; font-weight: 500; font-display: swap;
  src: url("fonts/barlow-condensed-latin-500-normal.woff2") format("woff2"); }
@font-face { font-family: "Barlow Condensed"; font-weight: 600; font-display: swap;
  src: url("fonts/barlow-condensed-latin-600-normal.woff2") format("woff2"); }
@font-face { font-family: "Barlow Condensed"; font-weight: 700; font-display: swap;
  src: url("fonts/barlow-condensed-latin-700-normal.woff2") format("woff2"); }
@font-face { font-family: "IBM Plex Mono"; font-weight: 400; font-display: swap;
  src: url("fonts/ibm-plex-mono-latin-400-normal.woff2") format("woff2"); }
@font-face { font-family: "IBM Plex Mono"; font-weight: 600; font-display: swap;
  src: url("fonts/ibm-plex-mono-latin-600-normal.woff2") format("woff2"); }

:root {
  color-scheme: dark;
  /* surfaces: gunmetal, darkest to lightest */
  --ink: #121416;          /* page */
  --well: #0d0f11;         /* inputs, sunken areas */
  --plate: #1a1e22;        /* panels */
  --plate-2: #22272d;      /* raised controls */
  --rule: #333a42;         /* borders */
  --rule-soft: #262b31;
  /* type */
  --text: #ece7dc;
  --text-2: #c9c3b6;
  --muted: #968f82;
  --faint: #6b665d;
  /* brand */
  --safety: #f2a900;       /* safety amber: primary action, focus, current */
  --safety-ink: #1a1405;   /* text on amber */
  --safety-dim: #3a2d0a;
  --rust: #c8553d;         /* stamps, danger, monsters */
  --rust-dim: #3a1d17;
  --verdigris: #5fa89a;    /* party, success, live */
  --verdigris-dim: #173029;
  --manila: #e6d7b5;       /* gear tags, paper */
  --manila-2: #d8c79f;
  --manila-ink: #2b2417;
  /* shape */
  --r: 4px;
  --r-lg: 8px;
  --gap: .9rem;
  --appbar-h: 58px;
  --shadow: 0 1px 0 rgba(255,255,255,.03) inset, 0 8px 24px rgba(0,0,0,.35);
  /* type families */
  --f-body: "Barlow", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --f-head: "Barlow Condensed", "Barlow", system-ui, sans-serif;
  --f-mono: "IBM Plex Mono", ui-monospace, "SFMono-Regular", Menlo, monospace;
  --hazard: repeating-linear-gradient(-45deg, var(--safety) 0 9px, var(--ink) 9px 18px);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--ink); color: var(--text);
  font: 400 16px/1.45 var(--f-body);
  /* faint blueprint grid: reads as "technical document" without competing */
  background-image:
    linear-gradient(rgba(255,255,255,.018) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,.018) 1px, transparent 1px);
  background-size: 28px 28px;
}
a { color: var(--safety); }
a:hover { color: #ffc22e; }
::selection { background: var(--safety); color: var(--safety-ink); }
:focus-visible { outline: 2px solid var(--safety); outline-offset: 2px; }
h1, h2, h3 { font-family: var(--f-head); font-weight: 700; letter-spacing: .02em; margin: 0; }
.mono { font-family: var(--f-mono); }
.muted { color: var(--muted); }
.faint { color: var(--faint); }
[hidden] { display: none !important; }

/* ---------- app bar (rendered by nav.js) ---------- */
.mg-appbar {
  position: sticky; top: 0; z-index: 60; height: var(--appbar-h);
  display: flex; align-items: center; gap: .75rem;
  padding: 0 .75rem 0 .6rem; background: #0b0c0e;
  border-bottom: 1px solid var(--rule);
}
.mg-appbar::after {            /* hazard tape under the bar */
  content: ""; position: absolute; left: 0; right: 0; bottom: -4px; height: 3px;
  background: var(--hazard); opacity: .85;
}
.mg-brand { display: flex; align-items: center; gap: .5rem; text-decoration: none; color: var(--text); flex: 0 0 auto; }
.mg-brand img { width: 30px; height: 30px; display: block; }
.mg-brand b { font: 700 1.05rem/1 var(--f-head); letter-spacing: .08em; text-transform: uppercase; }
.mg-brand small { display: block; font: 500 .6rem/1 var(--f-mono); letter-spacing: .14em; color: var(--muted); margin-top: .2rem; }
.mg-tabs { display: flex; gap: .15rem; overflow-x: auto; flex: 1 1 auto; scrollbar-width: none; align-self: stretch; align-items: center; }
.mg-tabs::-webkit-scrollbar { display: none; }
.mg-tabs a {
  flex: 0 0 auto; text-decoration: none; color: var(--muted);
  font: 600 .95rem/1 var(--f-head); letter-spacing: .06em; text-transform: uppercase;
  padding: .55rem .7rem; border-radius: var(--r); white-space: nowrap;
}
.mg-tabs a:hover { color: var(--text); background: var(--plate); }
.mg-tabs a.active { color: var(--safety-ink); background: var(--safety); }
.mg-tabs a.gm { color: var(--rust); }
.mg-tabs a.gm.active { background: var(--rust); color: #fff; }
.mg-who { display: flex; align-items: center; gap: .45rem; flex: 0 0 auto; }
.mg-badge {
  font: 600 .66rem/1 var(--f-mono); letter-spacing: .12em; text-transform: uppercase;
  padding: .3rem .45rem; border-radius: 2px; border: 1px solid var(--verdigris); color: var(--verdigris);
}
.mg-badge.gm { border-color: var(--rust); color: var(--rust); }
.mg-badge.hero { border-color: var(--safety); color: var(--safety); max-width: 11rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mg-who button { background: none; border: 0; color: var(--faint); font: 500 .75rem var(--f-body); cursor: pointer; padding: .3rem; }
.mg-who button:hover { color: var(--text); }
@media (max-width: 720px) {
  .mg-brand b, .mg-brand small { display: none; }
  .mg-who button { display: none; }
}

/* ---------- page frame ---------- */
.mg-page { max-width: 1100px; margin: 0 auto; padding: 1.4rem 1rem 5rem; }
.mg-page.narrow { max-width: 860px; }
.mg-head { margin: .2rem 0 1.2rem; }
.mg-code {                      /* FORM MG-07 · ENGAGEMENT LOG */
  font: 500 .7rem/1 var(--f-mono); letter-spacing: .16em; text-transform: uppercase; color: var(--muted);
  display: flex; align-items: center; gap: .6rem;
}
.mg-code::before { content: ""; width: 18px; height: 3px; background: var(--safety); }
.mg-title { font: 700 clamp(1.9rem, 5vw, 2.7rem)/1 var(--f-head); text-transform: uppercase; letter-spacing: .03em; margin-top: .45rem; }
.mg-sub { color: var(--muted); margin-top: .4rem; max-width: 60ch; }

/* section label strip: black band with an amber edge */
.mg-section {
  display: flex; align-items: center; gap: .6rem; margin: 1.6rem 0 .7rem;
  font: 700 .95rem/1 var(--f-head); letter-spacing: .1em; text-transform: uppercase; color: var(--text);
}
.mg-section::after { content: ""; flex: 1; height: 1px; background: var(--rule); }
.mg-section .n { font: 500 .7rem var(--f-mono); color: var(--safety); letter-spacing: .08em; }

/* ---------- plates (cards) ---------- */
.plate {
  position: relative; background: var(--plate); border: 1px solid var(--rule);
  border-radius: var(--r-lg); padding: 1rem 1.1rem; box-shadow: var(--shadow);
}
.plate.rivets::before {        /* four rivets, one gradient per corner */
  --rivet: radial-gradient(circle, #59626d 0 2px, #2a2f35 2.4px, transparent 3px);
  content: ""; position: absolute; inset: 6px; pointer-events: none;
  background: var(--rivet) 0 0 / 7px 7px no-repeat, var(--rivet) 100% 0 / 7px 7px no-repeat,
              var(--rivet) 0 100% / 7px 7px no-repeat, var(--rivet) 100% 100% / 7px 7px no-repeat;
}
.plate + .plate { margin-top: var(--gap); }
.plate-h {
  font: 600 .72rem/1 var(--f-mono); letter-spacing: .14em; text-transform: uppercase;
  color: var(--muted); margin: 0 0 .7rem;
}
.grid { display: grid; gap: var(--gap); grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
.grid > .plate + .plate { margin-top: 0; }
.grid > .empty { grid-column: 1 / -1; }

/* ---------- gear tag (manila luggage tag) ---------- */
.tag-card {
  position: relative; display: block; text-decoration: none; color: var(--manila-ink);
  background: linear-gradient(180deg, var(--manila) 0%, var(--manila-2) 100%);
  border-radius: 6px 6px 6px 6px; padding: 1rem 1rem 1rem 2.6rem;
  clip-path: polygon(22px 0, 100% 0, 100% 100%, 22px 100%, 0 calc(100% - 22px), 0 22px);
  box-shadow: 0 10px 24px rgba(0,0,0,.35);
  transition: transform .15s ease, box-shadow .15s ease;
}
.tag-card::before {            /* grommet */
  content: ""; position: absolute; left: 11px; top: 50%; width: 14px; height: 14px; margin-top: -7px;
  border-radius: 50%; background: var(--ink); box-shadow: 0 0 0 3px #b9a57a;
}
a.tag-card:hover { transform: translateY(-2px) rotate(-.4deg); box-shadow: 0 16px 30px rgba(0,0,0,.45); color: var(--manila-ink); }
.tag-card .tag-no { font: 600 .64rem/1 var(--f-mono); letter-spacing: .14em; color: #6d5f3f; }
.tag-card .tag-name { font: 700 1.45rem/1.05 var(--f-head); text-transform: uppercase; letter-spacing: .02em; margin-top: .35rem; }
.tag-card .tag-line { font-weight: 600; font-size: .9rem; margin-top: .3rem; color: #4a3d22; }
.tag-card .tag-hc { font-style: italic; font-size: .88rem; margin-top: .5rem; color: #5c4f33; }
.tag-card .tag-foot { display: flex; gap: .5rem; align-items: center; margin-top: .75rem;
  font: 500 .68rem var(--f-mono); letter-spacing: .08em; text-transform: uppercase; color: #6d5f3f; }

/* ---------- stamps ---------- */
.stamp {
  display: inline-block; font: 700 .78rem/1 var(--f-head); letter-spacing: .16em; text-transform: uppercase;
  color: var(--rust); border: 2px solid currentColor; border-radius: 3px; padding: .28rem .5rem .22rem;
  transform: rotate(-4deg); opacity: .92;
  -webkit-mask-image: radial-gradient(circle at 30% 40%, #000 60%, rgba(0,0,0,.72) 100%);
}
.stamp.ok { color: var(--verdigris); }
.stamp.amber { color: var(--safety); }
.classified {                  /* marks GM-only content wherever it appears */
  border-left: 3px solid var(--rust);
  background: linear-gradient(90deg, rgba(200,85,61,.10), transparent 40%);
}

/* ---------- buttons ---------- */
.btn, button.btn, a.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
  font: 600 .92rem/1 var(--f-head); letter-spacing: .08em; text-transform: uppercase;
  text-decoration: none; cursor: pointer; white-space: nowrap;
  color: var(--text); background: var(--plate-2); border: 1px solid var(--rule);
  border-radius: var(--r); padding: .6rem .85rem; min-height: 40px;
}
.btn:hover { border-color: var(--safety); color: var(--text); }
.btn.primary { background: var(--safety); color: var(--safety-ink); border-color: var(--safety); }
.btn.primary:hover { background: #ffbb1f; color: var(--safety-ink); }
.btn.danger { color: #f0a493; border-color: #5a2b22; background: var(--rust-dim); }
.btn.danger:hover { border-color: var(--rust); }
.btn.ghost { background: transparent; }
.btn.sm { min-height: 30px; padding: .35rem .55rem; font-size: .8rem; }
.btn[disabled] { opacity: .45; cursor: default; }
.iconbtn {
  font: 600 .85rem/1 var(--f-body); cursor: pointer; color: var(--text-2);
  background: var(--plate-2); border: 1px solid var(--rule); border-radius: var(--r);
  min-width: 32px; min-height: 32px; padding: .25rem .45rem;
}
.iconbtn:hover { border-color: var(--safety); color: var(--text); }
.iconbtn.rm { color: #e0907f; }

/* ---------- forms ---------- */
.lbl {
  display: block; font: 500 .66rem/1 var(--f-mono); letter-spacing: .14em; text-transform: uppercase;
  color: var(--muted); margin: .75rem 0 .3rem;
}
input[type=text], input[type=number], input[type=password], input[type=search], input[type=date], select, textarea {
  width: 100%; font: 400 1rem/1.35 var(--f-body); color: var(--text);
  background: var(--well); border: 1px solid var(--rule); border-radius: var(--r);
  padding: .55rem .65rem; min-height: 40px;
}
textarea { resize: vertical; min-height: 4.2rem; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--safety); box-shadow: 0 0 0 3px rgba(242,169,0,.15); }
input::placeholder, textarea::placeholder { color: var(--faint); }
input[type=checkbox] { accent-color: var(--safety); width: 20px; height: 20px; }
.row { display: flex; gap: .8rem; flex-wrap: wrap; }
.row > * { flex: 1 1 160px; min-width: 0; }

/* ---------- toolbars (page-level, sticky under the app bar) ---------- */
.toolbar {
  position: sticky; top: calc(var(--appbar-h) + 3px); z-index: 40;
  display: flex; align-items: center; gap: .5rem; flex-wrap: wrap;
  padding: .55rem 1rem; background: rgba(18,20,22,.94); backdrop-filter: blur(6px);
  border-bottom: 1px solid var(--rule-soft);
}
.toolbar .spacer { flex: 1; }

/* ---------- chips ---------- */
.chips { display: flex; flex-wrap: wrap; gap: .4rem; }
.chip {
  display: inline-flex; align-items: center; gap: .35rem; cursor: pointer;
  font: 500 .9rem/1 var(--f-body); color: var(--text-2);
  background: var(--plate-2); border: 1px solid var(--rule); border-radius: 999px; padding: .42rem .75rem;
}
.chip:hover { border-color: var(--safety); color: var(--text); }
.chip.pc { border-color: #2c5248; color: #a9d8cc; background: var(--verdigris-dim); }
.chip.mon { border-color: #5a2f24; color: #f0b3a3; background: var(--rust-dim); }
.chip.sel { background: var(--safety); border-color: var(--safety); color: var(--safety-ink); }

/* ---------- live status ---------- */
.status { font: 500 .72rem var(--f-mono); letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.status::before { content: "●"; margin-right: .35rem; }
.status.live { color: var(--verdigris); }
.status.off { color: var(--rust); }

/* ---------- stress boxes / pips ---------- */
.boxes { display: inline-flex; gap: 4px; }
.box {
  width: 26px; height: 26px; display: inline-flex; align-items: center; justify-content: center;
  font: 600 .72rem var(--f-mono); color: var(--muted); cursor: pointer;
  border: 1.5px solid #4e5660; border-radius: 3px; background: var(--well); user-select: none;
}
.box:hover { border-color: var(--safety); }
.box.on { background: var(--rust); border-color: var(--rust); color: #fff; }

/* ---------- fate dice ---------- */
.die {
  width: 34px; height: 34px; display: inline-flex; align-items: center; justify-content: center;
  font: 700 1.25rem/1 var(--f-mono); border-radius: 6px;
  background: var(--manila); color: var(--manila-ink); box-shadow: 0 2px 0 #9c8a60;
}
.die.plus { color: #1f5c50; }
.die.minus { color: #8f2f1d; }

/* ---------- tokens (circular PNGs from the forge) ---------- */
.tok { width: 44px; height: 44px; border-radius: 50%; object-fit: cover; flex: 0 0 auto;
  background: var(--well); box-shadow: 0 0 0 1px var(--rule), 0 3px 8px rgba(0,0,0,.4); }
.tok.xs { width: 22px; height: 22px; box-shadow: 0 0 0 1px var(--rule); }
.tok.sm { width: 30px; height: 30px; }
.tok.lg { width: 96px; height: 96px; }
.maketok { font: 500 .66rem var(--f-mono); letter-spacing: .1em; text-transform: uppercase;
  color: var(--safety); text-decoration: none; white-space: nowrap; }
.maketok:hover { text-decoration: underline; }

/* ---------- modal ---------- */
.modal { position: fixed; inset: 0; z-index: 90; display: none; align-items: center; justify-content: center;
  padding: 1rem; background: rgba(5,6,7,.8); }
.modal.open { display: flex; }
.modal-box { width: 100%; max-width: 640px; max-height: 88vh; display: flex; flex-direction: column;
  background: var(--plate); border: 1px solid var(--rule); border-radius: var(--r-lg); box-shadow: var(--shadow); }
.modal-h { font: 700 1.1rem var(--f-head); letter-spacing: .06em; text-transform: uppercase;
  padding: .85rem 1rem; border-bottom: 1px solid var(--rule); }
.modal-body { padding: 1rem; overflow-y: auto; white-space: pre-wrap; line-height: 1.6; }
.modal-act { display: flex; gap: .5rem; padding: .75rem 1rem; border-top: 1px solid var(--rule); flex-wrap: wrap; }

/* ---------- empty state ---------- */
.empty { text-align: center; padding: 2.2rem 1rem; color: var(--muted); border: 1px dashed var(--rule); border-radius: var(--r-lg); }
.empty b { display: block; font: 700 1.1rem var(--f-head); letter-spacing: .08em; text-transform: uppercase; color: var(--text-2); margin-bottom: .3rem; }

/* ---------- print: plain black on white ---------- */
@media print {
  body { background: #fff !important; color: #000 !important; }
  .mg-appbar, .toolbar, .noprint { display: none !important; }
  .plate { box-shadow: none; border-color: #999; background: #fff; }
}

/* ---------- work in progress ---------- */
/* Hazard tape that loops without a seam: one tile is exactly one stripe period
   wide (18px measured across a -45° stripe = 18√2 ≈ 25.46px) and the slide
   travels exactly one tile, so the pattern lands back on itself. */
.mg-work { display: flex; flex-direction: column; gap: .5rem; }
.mg-work .lbl { font-size: .92rem; color: var(--text-2); letter-spacing: 0; text-transform: none; font-family: var(--f-body); }
.mg-progress { height: 10px; border: 1px solid var(--rule); border-radius: 2px; background: var(--well); overflow: hidden; }
.mg-progress::before { content: ""; display: block; height: 100%;
  background: var(--hazard); background-size: 25.456px 100%; opacity: .95;
  animation: mg-hazard 1.1s linear infinite; }
@keyframes mg-hazard { from { background-position: 0 0; } to { background-position: 25.456px 0; } }
@media (prefers-reduced-motion: reduce) { .mg-progress::before { animation: none; } }

/* ---------- lightbox ---------- */
.mg-light { position: fixed; inset: 0; z-index: 120; display: flex; flex-direction: column;
  background: rgba(5,6,7,.94); padding: 1rem; gap: .6rem; }
.mg-light img { flex: 1 1 auto; min-height: 0; width: 100%; object-fit: contain;
  image-rendering: auto; border-radius: var(--r); }
.mg-light .cap { flex: 0 0 auto; text-align: center; font: 500 .72rem var(--f-mono);
  letter-spacing: .1em; text-transform: uppercase; color: var(--muted); }
.mg-light .x { position: absolute; top: .6rem; right: .6rem; z-index: 2; }
.mg-light .nav { position: absolute; top: 50%; transform: translateY(-50%); z-index: 2;
  font: 700 1.4rem var(--f-head); padding: .4rem .7rem; }
.mg-light .nav.prev { left: .6rem; } .mg-light .nav.next { right: .6rem; }
img.zoom, .zoom img { cursor: zoom-in; }
/* Every picture that can be blown up says so, top right, always visible. */
.zoomwrap { position: relative; display: inline-block; line-height: 0; cursor: zoom-in; }
.zoomwrap.fill { display: block; width: 100%; }
.zoomwrap::after { content: "\2922"; position: absolute; top: .35rem; right: .35rem;
  width: 1.55rem; height: 1.55rem; display: flex; align-items: center; justify-content: center;
  font: 600 .95rem/1 var(--f-mono); color: var(--safety);
  background: rgba(10,11,12,.78); border: 1px solid var(--rule); border-radius: 2px; pointer-events: none; }
.zoomwrap:hover::after { border-color: var(--safety); background: rgba(10,11,12,.92); }

/* ---------- front desk (rendered by nav.js) ---------- */
.mg-desk-bell {
  position: fixed; right: max(1rem, env(safe-area-inset-right)); bottom: max(1rem, env(safe-area-inset-bottom));
  z-index: 85; width: 58px; height: 58px; padding: 0; border-radius: 50%; cursor: pointer;
  display: grid; place-items: center; overflow: hidden; color: var(--safety);
  background: var(--plate-2); border: 2px solid var(--safety);
  box-shadow: 0 0 0 3px rgba(0,0,0,.45), 0 8px 22px rgba(0,0,0,.5);
  transition: transform .15s ease;
}
.mg-desk-bell:hover { transform: translateY(-2px); }
.mg-desk-bell img, .mg-desk-h .mg-desk-face img { width: 100%; height: 100%; object-fit: cover; display: block; }
.mg-desk-bell svg { width: 28px; height: 28px; }
.mg-desk-bell img + svg, .mg-desk-h .mg-desk-face img + svg { display: none; }
.mg-desk-open .mg-desk-bell { display: none; }
.mg-desk {
  position: fixed; right: max(1rem, env(safe-area-inset-right)); bottom: max(1rem, env(safe-area-inset-bottom));
  z-index: 85; width: min(390px, calc(100vw - 2rem)); height: min(580px, calc(100dvh - var(--appbar-h) - 2rem));
  display: flex; flex-direction: column; background: var(--plate); border: 1px solid var(--rule);
  border-top: 3px solid var(--safety); border-radius: var(--r-lg); box-shadow: 0 18px 48px rgba(0,0,0,.6);
}
.mg-desk[hidden] { display: none !important; }
.mg-desk-h { display: flex; align-items: center; gap: .55rem; padding: .6rem .6rem .6rem .7rem; border-bottom: 1px solid var(--rule-soft); }
.mg-desk-h .mg-desk-face { width: 38px; height: 38px; padding: 0; cursor: zoom-in; border-radius: 50%; overflow: hidden; flex: 0 0 auto;
  display: grid; place-items: center; color: var(--safety); background: var(--plate-2); border: 1px solid var(--safety); }
.mg-desk-h .mg-desk-face svg { width: 20px; height: 20px; }
.mg-desk-h .who { flex: 1 1 auto; min-width: 0; line-height: 1.1; }
.mg-desk-h .who b { font: 700 1.1rem/1 var(--f-head); letter-spacing: .05em; text-transform: uppercase; display: block; }
.mg-desk-h .who small { font: 500 .62rem/1 var(--f-mono); letter-spacing: .14em; text-transform: uppercase; color: var(--muted); }
.mg-desk-log { flex: 1 1 auto; overflow-y: auto; padding: .8rem .75rem; display: flex; flex-direction: column; gap: .6rem; overscroll-behavior: contain; }
.mg-desk-m { max-width: 88%; }
.mg-desk-m .b { padding: .5rem .7rem; border-radius: var(--r-lg); font-size: .93rem; line-height: 1.45; overflow-wrap: anywhere; }
.mg-desk-m .b p { margin: 0; }
.mg-desk-m .b p + p, .mg-desk-m .b ul + p, .mg-desk-m .b p + ul { margin-top: .45rem; }
.mg-desk-m .b ul { margin: 0; padding-left: 1.1rem; }
.mg-desk-m.her { align-self: flex-start; }
.mg-desk-m.her .b { background: var(--plate-2); border: 1px solid var(--rule); border-bottom-left-radius: 2px; }
.mg-desk-m.me { align-self: flex-end; }
.mg-desk-m.me .b { background: var(--safety-dim); border: 1px solid #5c4710; border-bottom-right-radius: 2px; }
.mg-desk-m.err .b { color: #f0a493; border-color: #5a2b22; background: var(--rust-dim); }
.mg-desk-m .acts { display: flex; flex-wrap: wrap; gap: .35rem; margin-top: .4rem; }
.mg-desk-sug { display: flex; flex-wrap: wrap; gap: .35rem; }
.mg-desk-in { display: flex; gap: .45rem; align-items: flex-end; padding: .6rem; border-top: 1px solid var(--rule-soft); }
.mg-desk-in textarea { flex: 1 1 auto; resize: none; min-height: 38px; max-height: 120px; padding: .5rem .6rem;
  font: 400 .95rem/1.35 var(--f-body); color: var(--text); background: var(--well); border: 1px solid var(--rule); border-radius: var(--r); }
.mg-desk-in textarea:focus { outline: none; border-color: var(--safety); }
.mg-desk-in .btn { min-height: 38px; }
.mg-desk .dots { display: inline-flex; gap: 4px; padding: .2rem 0; }
.mg-desk .dots i { width: 6px; height: 6px; border-radius: 50%; background: var(--muted); animation: mg-dot 1.2s infinite ease-in-out; }
.mg-desk .dots i:nth-child(2) { animation-delay: .15s; }
.mg-desk .dots i:nth-child(3) { animation-delay: .3s; }
@keyframes mg-dot { 0%, 80%, 100% { opacity: .25; transform: none; } 40% { opacity: 1; transform: translateY(-3px); } }
@media (prefers-reduced-motion: reduce) { .mg-desk .dots i { animation: none; opacity: .7; } }
@media (max-width: 560px) {
  .mg-desk { right: 0; left: 0; bottom: 0; width: 100%; height: min(78dvh, 640px);
    border-radius: var(--r-lg) var(--r-lg) 0 0; border-left: 0; border-right: 0; border-bottom: 0; }
  .mg-desk-in textarea { font-size: 16px; }      /* iOS zooms into anything smaller */
}
@media print { .mg-desk, .mg-desk-bell { display: none !important; } }

/* ---------- the room you're in (rendered by nav.js) ---------- */
.mg-room { position: relative; overflow: hidden; height: 62px; background: var(--plate); border-bottom: 1px solid var(--rule); }
.mg-room.art { height: 104px; }
.mg-room .bg { position: absolute; inset: -16px; background: center / cover no-repeat;
  filter: blur(9px) brightness(.4) saturate(1.15); }
.mg-room .in { position: relative; max-width: 1100px; height: 100%; margin: 0 auto; padding: 4px 1rem 0;
  display: flex; align-items: center; gap: .75rem; }
.mg-room .pic { flex: 0 0 auto; width: 136px; height: 85px; padding: 0; border-radius: 4px; cursor: zoom-in;
  background: var(--well) center / cover no-repeat;
  border: 1px solid rgba(242,169,0,.6); box-shadow: 0 3px 14px rgba(0,0,0,.55); transition: transform .15s ease; }
.mg-room .pic:hover { transform: scale(1.04); }
.mg-room:not(.art) .pic { display: none; }
.mg-room .where { min-width: 0; line-height: 1.05; }
.mg-room .where small { display: block; font: 600 .6rem/1 var(--f-mono); letter-spacing: .16em; text-transform: uppercase; color: var(--muted); }
.mg-room.art .where small { color: #d9cfbd; }
.mg-room .where b { font: 700 1.15rem/1.1 var(--f-head); letter-spacing: .06em; text-transform: uppercase; }
.mg-room.art .where b { font-size: 1.5rem; text-shadow: 0 2px 8px rgba(0,0,0,.6); }
.mg-room .back { margin-left: auto; }
.mg-room.art .back { background: rgba(11,12,14,.55); }
@media (max-width: 560px) {
  .mg-room, .mg-room.art { height: 64px; }
  .mg-room .pic { width: 80px; height: 50px; }
  .mg-room.art .where b { font-size: 1.15rem; }
}
.mg-desk-hero { display: block; width: calc(100% + 1.5rem); margin: -.8rem -.75rem .2rem; aspect-ratio: 16 / 10;
  object-fit: cover; border-bottom: 1px solid var(--rule); }
@media print { .mg-room { display: none !important; } }

/* ---------- front desk: the GM's cards, documents being read, wide mode ---------- */
.mg-desk.wide { width: min(760px, calc(100vw - 2rem)); height: min(88dvh, calc(100dvh - var(--appbar-h) - 2rem)); }
.mg-desk-m.wide { max-width: 100%; width: 100%; }
.mg-desk .wk { margin-top: .35rem; font: 500 .72rem/1.2 var(--f-mono); letter-spacing: .06em; color: var(--safety); }
.mg-desk-in .clip { min-height: 38px; padding: 0 .5rem; font-size: 1rem; }
.mg-card { margin-top: .45rem; border: 1px solid var(--rule); border-left: 3px solid var(--safety); border-radius: var(--r);
  background: var(--well); overflow: hidden; }
.mg-card-h { padding: .45rem .65rem; font: 600 .66rem/1 var(--f-mono); letter-spacing: .14em; text-transform: uppercase;
  color: var(--safety); border-bottom: 1px solid var(--rule-soft); }
.mg-card .ci { padding: .55rem .65rem .6rem; border-bottom: 1px solid var(--rule-soft); }
.mg-card .ci.off { opacity: .5; }
.mg-card .ci.off .fld, .mg-card .ci.off .wn, .mg-card .ci.off .nt { display: none; }
.mg-card .ci.done { opacity: .85; }
.mg-card .top { display: flex; align-items: center; gap: .45rem; flex-wrap: wrap; cursor: pointer; }
.mg-card .top b { font: 600 .92rem/1.25 var(--f-body); }
.mg-card input[type=checkbox] { accent-color: var(--safety); width: 16px; height: 16px; margin: 0; }
.mg-card .bdg { font: 600 .56rem/1 var(--f-mono); letter-spacing: .1em; text-transform: uppercase; padding: .2rem .35rem;
  border-radius: 2px; border: 1px solid var(--rule); color: var(--muted); }
.mg-card .bdg.new { color: var(--verdigris); border-color: var(--verdigris-dim); }
.mg-card .bdg.update { color: var(--safety); border-color: var(--safety-dim); }
.mg-card .bdg.hidden, .mg-card .bdg.gm-only { color: var(--rust); border-color: var(--rust-dim); }
.mg-card .nt { font-size: .8rem; color: var(--muted); margin-top: .3rem; }
.mg-card .wn { font-size: .8rem; color: #f0c26b; margin-top: .3rem; }
.mg-card .fld { display: block; margin-top: .45rem; font-size: .78rem; color: var(--text-2); }
.mg-card .fld > span { display: flex; align-items: center; gap: .4rem; margin-bottom: .2rem; }
.mg-card .fld.chk { display: flex; align-items: center; gap: .4rem; }
.mg-card .who { font: 600 .56rem/1 var(--f-mono); letter-spacing: .1em; text-transform: uppercase; }
.mg-card .who.party { color: var(--verdigris); }
.mg-card .who.gm { color: var(--rust); }
.mg-card textarea, .mg-card input[type=text] { width: 100%; resize: vertical; padding: .4rem .5rem;
  font: 400 .86rem/1.4 var(--f-body); color: var(--text); background: var(--ink); border: 1px solid var(--rule); border-radius: var(--r); }
.mg-card textarea:focus, .mg-card input[type=text]:focus { outline: none; border-color: var(--safety); }
.mg-card .res { display: flex; align-items: center; gap: .45rem; flex-wrap: wrap; margin-top: .35rem; font-size: .84rem; color: var(--verdigris); }
.mg-card .res.bad { color: #f0a493; }
.mg-card-f { display: flex; gap: .4rem; padding: .55rem .65rem; background: var(--plate); }
.mg-job { padding: .6rem .7rem; border: 1px solid var(--rule); border-radius: var(--r); background: var(--well); }
.mg-job b { display: block; font-size: .9rem; margin-bottom: .45rem; }
.mg-job .bar { height: 6px; border-radius: 3px; background: var(--plate-2); overflow: hidden; }
.mg-job .bar i { display: block; height: 100%; background: var(--hazard); background-size: 25.456px 100%;
  animation: mg-hazard 1s linear infinite; transition: width .6s ease; }
.mg-job small { display: block; margin-top: .4rem; font: 500 .7rem/1.3 var(--f-mono); color: var(--muted); }
.mg-job.bad small { color: #f0a493; }
@media (prefers-reduced-motion: reduce) { .mg-job .bar i { animation: none; } }
@media (max-width: 560px) { .mg-desk.wide { width: 100%; height: min(92dvh, 900px); } }

.mg-who .mg-desk-top { display: none; width: 34px; height: 34px; padding: 0; border-radius: 50%; overflow: hidden; cursor: pointer;
  place-items: center; color: var(--safety); background: var(--plate-2); border: 1.5px solid var(--safety); }
.mg-who .mg-desk-top img { width: 100%; height: 100%; object-fit: cover; display: block; }
.mg-who .mg-desk-top svg { width: 18px; height: 18px; }
.mg-who .mg-desk-top img + svg { display: none; }
@media (max-width: 560px) {
  .mg-desk-bell { display: none; }
  .mg-who .mg-desk-top { display: grid; flex: 0 0 auto; }
}

/* ---------- library names in text (MG.autolink) ---------- */
a.mention { color: inherit; text-decoration: underline; text-decoration-style: dotted; text-decoration-color: var(--safety);
  text-underline-offset: 2px; }
a.mention:hover { color: var(--safety); text-decoration-style: solid; }
