:root {
  --bg: #0b1012;
  --bg2: #11181b;
  --steel: #1a2428;
  --line: #24323a;
  --ink: #dfe8e6;
  --dim: #8fa3a0;
  --mint: #6ff2c4;
  --red: #e0453a;
  --paper: #efe8d8;
  --paper2: #e4dbc6;
  --type: #1e1c19;
  --stamp: #c3312a;
  --manila: #d9c49a;
  --mono: 'IBM Plex Mono', ui-monospace, monospace;
  --typew: 'Special Elite', 'Courier New', monospace;
  --head: 'Oswald', 'Arial Narrow', sans-serif;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink); font: 15px/1.5 var(--mono);
  background-image: linear-gradient(180deg, rgba(111, 242, 196, .05), transparent 240px),
    repeating-linear-gradient(90deg, rgba(255, 255, 255, .012) 0 1px, transparent 1px 64px);
  padding-bottom: 76px; overflow-x: hidden;
}
a { color: var(--mint); }
button { font: inherit; cursor: pointer; }
h2 { font: 700 18px/1.2 var(--head); letter-spacing: .06em; text-transform: uppercase; margin: 0 0 10px; }
h2 small { font: 400 11px var(--mono); letter-spacing: 0; text-transform: none; color: var(--dim); margin-left: 6px; }

/* ---------- top bar ---------- */
.bar { display: flex; align-items: center; gap: 10px; padding: 8px 16px; height: 52px; border-bottom: 1px solid var(--line); background: rgba(11, 16, 18, .92); position: sticky; top: 0; z-index: 20; backdrop-filter: blur(6px); }
.logo { display: flex; align-items: center; gap: 8px; color: var(--ink); text-decoration: none; }
.logo svg { width: 28px; height: 28px; }
.logo b { font: 700 20px var(--head); letter-spacing: .14em; }
.pill { margin-left: auto; font-size: 10px; letter-spacing: .08em; padding: 4px 8px; border: 1px solid var(--line); border-radius: 99px; color: var(--dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.pill.live { color: var(--mint); border-color: rgba(111, 242, 196, .4); }
.pill.live::before { content: ''; display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--red); margin-right: 6px; animation: blink 1.2s infinite; vertical-align: 0; }
@keyframes blink { 50% { opacity: .2; } }
.mute { width: 44px; height: 44px; flex: none; border-radius: 10px; border: 1px solid var(--line); background: var(--bg2); color: var(--mint); font-size: 18px; }
.mute.off { color: var(--dim); }
.mute.off span { text-decoration: line-through; }
.announce { background: var(--stamp); color: #fff; text-align: center; padding: 8px 16px; font-size: 13px; }

/* ---------- monitor ---------- */
.monitor { position: relative; height: 74px; border-bottom: 1px solid var(--line); background: #070b0c; overflow: hidden; }
.monitor canvas { position: absolute; inset: 0; width: 100%; height: 100%; }
.vitals { position: absolute; right: 12px; top: 8px; display: grid; grid-template-columns: auto auto; gap: 0 8px; font-size: 11px; align-items: baseline; background: rgba(7, 11, 12, .75); padding: 4px 8px; border-radius: 6px; }
.vitals .lbl { color: var(--dim); font-size: 9px; letter-spacing: .1em; }
.vitals b { color: var(--mint); font-weight: 700; }
.flat { position: absolute; left: 16px; top: 8px; font: 700 13px var(--head); letter-spacing: .3em; color: var(--red); opacity: 0; transition: opacity .2s; }
.monitor.flatline .flat { opacity: 1; }

/* ---------- layout ---------- */
.layout { max-width: 1240px; margin: 0 auto; padding: 14px 16px 0; display: grid; gap: 18px; }
@media (min-width: 980px) {
  .layout { grid-template-columns: minmax(0, 1fr) 400px; align-items: start; padding-top: 22px; }
  .slab { grid-row: span 2; }
  .drawers, .lookup, .about { grid-column: 1 / -1; }
}

/* ---------- the slab ---------- */
.slab { position: relative; scroll-margin-top: 64px; }
.slabhead { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; min-height: 30px; }
.tag { font: 700 12px var(--head); letter-spacing: .18em; color: var(--dim); }
.tag.hot { color: var(--red); animation: blink .8s 4; }
.back { margin-left: auto; min-height: 36px; padding: 4px 12px; border-radius: 8px; border: 1px solid var(--line); background: var(--bg2); color: var(--ink); font-size: 12px; }
.certwrap { perspective: 1200px; }

.cert {
  position: relative; background: var(--paper); color: var(--type); border-radius: 4px; padding: 18px 16px 16px;
  font-family: var(--typew); box-shadow: 0 18px 50px rgba(0, 0, 0, .5), inset 0 0 60px rgba(120, 90, 40, .15);
  background-image: linear-gradient(transparent 31px, rgba(60, 50, 30, .06) 32px), radial-gradient(circle at 80% 10%, rgba(255, 255, 255, .5), transparent 60%);
  background-size: 100% 32px, 100% 100%;
  overflow: hidden;
}
.cert.empty { min-height: 420px; display: grid; place-items: center; text-align: center; }
.cert .wait { font-size: 16px; color: #5c5547; max-width: 300px; }
.cert.in { animation: slidein .7s cubic-bezier(.2, .8, .2, 1); }
@keyframes slidein { from { transform: translateY(40px) rotateX(18deg); opacity: 0; } to { transform: none; opacity: 1; } }
.cert::before { content: ''; position: absolute; inset: 6px; border: 1.5px solid rgba(30, 28, 25, .35); border-radius: 2px; pointer-events: none; }
.cert .hd { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; border-bottom: 2px solid var(--type); padding-bottom: 6px; }
.cert .hd h3 { margin: 0; font: 700 17px var(--head); letter-spacing: .14em; }
.cert .hd .no { font-size: 13px; white-space: nowrap; }
.cert .who { display: flex; gap: 12px; align-items: center; margin: 14px 0 10px; }
.cert .who img, .cert .who .noimg { width: 64px; height: 64px; border-radius: 6px; object-fit: cover; filter: grayscale(1) contrast(1.1) sepia(.25); border: 1.5px solid var(--type); flex: none; background: var(--paper2); }
.cert .who .noimg { display: grid; place-items: center; font-size: 26px; }
.cert .who .nm { min-width: 0; }
.cert .who .sym { font: 700 28px/1.05 var(--head); letter-spacing: .02em; word-break: break-all; }
.cert .who .full { font-size: 14px; color: #4d473c; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cert dl { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 14px; margin: 8px 0 0; }
.cert dl div { border-bottom: 1px dotted rgba(30, 28, 25, .4); padding-bottom: 3px; min-width: 0; }
.cert dt { font: 500 9px var(--mono); letter-spacing: .12em; text-transform: uppercase; color: #6a6253; }
.cert dd { margin: 0; font-size: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cert dd.big { font-size: 20px; }
.cert .cause { margin-top: 12px; border: 2px solid var(--type); padding: 8px 10px; }
.cert .cause dt { font: 500 9px var(--mono); letter-spacing: .12em; color: #6a6253; }
.cert .cause b { display: block; font: 700 20px var(--head); letter-spacing: .06em; color: var(--stamp); }
.cert .cause span { font-size: 15px; }
.cert .words { margin: 10px 0 0; font-size: 14px; color: #3f3a31; }
.cert .words i { color: #6a6253; font-style: normal; font-size: 9px; letter-spacing: .12em; font-family: var(--mono); display: block; }
.cert .sig { display: flex; justify-content: space-between; align-items: end; gap: 8px; margin-top: 12px; font-size: 12px; color: #5c5547; }
.cert .sig .hand { font: 400 22px/1 'Special Elite', cursive; color: #26446e; transform: rotate(-4deg); }
.cert .sig a { color: #26446e; }
.cert .stamp {
  position: absolute; right: 10px; top: 76px; padding: 4px 10px; border: 4px double var(--stamp); color: var(--stamp);
  font: 700 30px var(--head); letter-spacing: .14em; transform: rotate(-14deg); opacity: .85; mix-blend-mode: multiply;
  pointer-events: none;
}
.cert.in .stamp { animation: slam .45s 1.5s cubic-bezier(.3, 1.6, .5, 1) both; }
@keyframes slam { from { transform: rotate(-14deg) scale(2.6); opacity: 0; } 70% { opacity: .95; } to { transform: rotate(-14deg) scale(1); opacity: .85; } }
.cert.in dl div, .cert.in .cause, .cert.in .words { animation: type .35s both; }
.cert.in dl div:nth-child(1) { animation-delay: .25s; } .cert.in dl div:nth-child(2) { animation-delay: .35s; }
.cert.in dl div:nth-child(3) { animation-delay: .45s; } .cert.in dl div:nth-child(4) { animation-delay: .55s; }
.cert.in dl div:nth-child(5) { animation-delay: .65s; } .cert.in dl div:nth-child(6) { animation-delay: .75s; }
.cert.in dl div:nth-child(7) { animation-delay: .85s; } .cert.in dl div:nth-child(8) { animation-delay: .95s; }
.cert.in .cause { animation-delay: 1.1s; } .cert.in .words { animation-delay: 1.25s; }
@keyframes type { from { clip-path: inset(0 100% 0 0); } to { clip-path: inset(0 0 0 0); } }
.cert.self { background-color: #f3d9d4; }
.cert.alive .stamp { color: #1f7a55; border-color: #1f7a55; }

.toast { position: absolute; left: 10px; right: 10px; bottom: 10px; background: rgba(7, 11, 12, .94); color: var(--ink); border: 1px solid var(--mint); border-radius: 10px; padding: 10px 12px; font-size: 13px; box-shadow: 0 10px 30px rgba(0, 0, 0, .5); animation: up .35s ease-out; z-index: 3; }
.toast b { color: var(--mint); }
.toast .f { color: var(--manila); }
@keyframes up { from { transform: translateY(16px); opacity: 0; } }

/* ---------- counters ---------- */
.counts { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.counts div { background: var(--bg2); border: 1px solid var(--line); border-radius: 10px; padding: 10px; min-width: 0; }
.counts b { display: block; font: 700 24px/1.1 var(--head); color: var(--ink); }
.counts span { font-size: 10px; color: var(--dim); line-height: 1.25; display: block; margin-top: 2px; }
.counts .bump b { animation: bump .6s; }
@keyframes bump { 30% { color: var(--red); transform: scale(1.12); } }

/* ---------- intake ---------- */
.intake { margin-top: 16px; background: var(--bg2); border: 1px solid var(--line); border-radius: 12px; padding: 12px; }
.intake ol { list-style: none; margin: 0; padding: 0; max-height: 300px; overflow-y: auto; }
.intake li { display: grid; grid-template-columns: auto 1fr auto; gap: 2px 10px; padding: 8px 0; border-top: 1px solid var(--line); font-size: 13px; align-items: baseline; }
.intake li:first-child { border-top: 0; }
.intake li.new { animation: flashrow 1.6s; }
@keyframes flashrow { from { background: rgba(111, 242, 196, .18); } }
.intake .no { color: var(--dim); font-size: 11px; }
.intake .w { color: var(--mint); }
.intake .s { color: var(--dim); font-size: 12px; text-align: right; }
.intake .rec { grid-column: 2 / -1; color: var(--manila); font-size: 12px; }
.intake .rec.clean { color: var(--dim); }
.empty-note { color: var(--dim); font-size: 12px; margin: 0; }

/* ---------- drawers (toe tags) ---------- */
.drawers { margin-top: 6px; }
.tags { display: grid; grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); gap: 10px; }
.toe {
  position: relative; background: var(--manila); color: #2a241a; border: 0; border-radius: 4px 14px 14px 4px; padding: 10px 10px 8px 22px;
  text-align: left; font-family: var(--typew); min-height: 74px; box-shadow: 0 6px 14px rgba(0, 0, 0, .35); transform: rotate(var(--r, 0deg));
  transition: transform .15s;
}
.toe::before { content: ''; position: absolute; left: 7px; top: 50%; width: 9px; height: 9px; margin-top: -4.5px; border-radius: 50%; background: var(--bg); box-shadow: inset 0 0 0 2px #a8925f; }
.toe b { display: block; font: 700 15px/1.1 var(--head); word-break: break-all; }
.toe span { display: block; font-size: 11px; color: #5a4e37; }
.toe .c { color: var(--stamp); font-size: 10px; }
.toe.on { outline: 3px solid var(--mint); }
.toe.self { background: #e9b4aa; }
.toe:active { transform: scale(.97); }

/* ---------- lookup ---------- */
.lookup { background: var(--bg2); border: 1px solid var(--line); border-radius: 12px; padding: 14px; }
.lookup p { color: var(--dim); font-size: 13px; margin: 0 0 10px; }
.lookup form { display: flex; gap: 8px; }
.lookup input { flex: 1; min-width: 0; min-height: 46px; padding: 0 12px; border-radius: 10px; border: 1px solid var(--line); background: var(--bg); color: var(--ink); font: 14px var(--mono); }
.lookup button { min-height: 46px; padding: 0 16px; border-radius: 10px; border: 0; background: var(--mint); color: #062018; font-weight: 700; }
#lookout { margin-top: 14px; }
#lookout .msg { color: var(--dim); font-size: 13px; }

/* ---------- about ---------- */
.mascot { display: block; width: 140px; height: 140px; border-radius: 12px; margin: 0 auto 12px; filter: sepia(.15); }
.mascot.sm { float: right; width: 96px; height: 96px; margin: 0 0 10px 14px; }
.cert.empty { grid-auto-flow: row; align-content: center; }
.about ol { padding-left: 20px; margin: 0 0 10px; color: var(--ink); }
.about li { margin-bottom: 8px; font-size: 14px; }
.about b { color: var(--mint); font-weight: 500; }
.fine { color: var(--dim); font-size: 12px; }

footer { max-width: 1240px; margin: 26px auto 0; padding: 0 16px 20px; color: var(--dim); font-size: 11px; }

/* ---------- CA bar ---------- */
.cabar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; display: flex; align-items: center; gap: 8px; padding: 10px 16px calc(10px + env(safe-area-inset-bottom)); background: rgba(11, 16, 18, .96); border-top: 1px solid var(--line); backdrop-filter: blur(6px); }
.cabar .ca-label { font: 700 13px var(--head); letter-spacing: .1em; color: var(--manila); }
.cabar code { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 12px; color: var(--dim); }
.cabar.live code { color: var(--ink); }
.cabar button, .cabar .buy { min-height: 44px; min-width: 64px; padding: 0 14px; border-radius: 10px; border: 1px solid var(--line); background: var(--bg2); color: var(--ink); font-weight: 700; display: grid; place-items: center; text-decoration: none; font-size: 14px; }
.cabar .buy { background: var(--mint); color: #062018; border: 0; }
.cabar .buy[aria-disabled="true"], .cabar button:disabled { opacity: .45; pointer-events: none; }

/* ---------- hourly report ---------- */
.report { position: fixed; inset: 0; z-index: 50; background: rgba(5, 8, 9, .9); display: grid; place-items: center; padding: 16px; animation: fadein .4s; }
@keyframes fadein { from { opacity: 0; } }
.report .sheet { background: var(--paper); color: var(--type); font-family: var(--typew); width: min(560px, 100%); border-radius: 4px; padding: 22px 18px; box-shadow: 0 30px 80px rgba(0, 0, 0, .6); }
.report h3 { margin: 0; font: 700 26px var(--head); letter-spacing: .12em; }
.report .when { font-size: 14px; color: #5c5547; border-bottom: 2px solid var(--type); padding-bottom: 8px; margin-bottom: 12px; }
.report .row { display: flex; justify-content: space-between; gap: 10px; border-bottom: 1px dotted rgba(30, 28, 25, .4); padding: 7px 0; font-size: 17px; }
.report .row span:first-child { font: 500 10px var(--mono); letter-spacing: .12em; text-transform: uppercase; color: #6a6253; align-self: center; }
.report .row b { font-weight: 400; text-align: right; }
.report .close { margin-top: 14px; width: 100%; min-height: 44px; border: 2px solid var(--type); background: transparent; font: 700 14px var(--head); letter-spacing: .12em; }

/* ---------- stream mode: one screen, no scroll ---------- */
body.stream { padding-bottom: 0; height: 100vh; overflow: hidden; }
body.stream .bar, body.stream .lookup, body.stream .about, body.stream footer, body.stream .slabhead .back { display: none; }
body.stream .layout { max-width: none; height: calc(100vh - 74px - 60px); grid-template-columns: minmax(0, 1fr) minmax(320px, 38vw); grid-template-rows: auto 1fr; padding: 16px 24px 0; }
body.stream .slab { grid-row: span 2; display: flex; flex-direction: column; justify-content: center; }
body.stream .cert { max-width: 640px; margin: 0 auto; width: 100%; }
body.stream .drawers { grid-column: 2; overflow: hidden; }
body.stream .tags { grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); max-height: 40vh; overflow: hidden; }
body.stream .intake ol { max-height: 26vh; }
body.stream .cabar { position: fixed; }

/* phones: lighter effects */
@media (max-width: 600px) {
  .cert { box-shadow: 0 10px 26px rgba(0, 0, 0, .5); }
  .cert .who .sym { font-size: 24px; }
  .cert dd { font-size: 15px; }
  .cert .stamp { font-size: 21px; top: 66px; right: 6px; opacity: .72; }
  .counts b { font-size: 20px; }
  .bar { backdrop-filter: none; }
  body.stream .layout { grid-template-columns: 1fr; height: auto; }
  body.stream { overflow: auto; height: auto; }
}
@media (prefers-reduced-motion: reduce) {
  .cert.in, .cert.in .stamp, .cert.in dl div, .cert.in .cause, .cert.in .words { animation: none; }
}
