/* ==========================================================================
   Packet Detective - styles.css
   Black backgrounds, white text, tan panels, gold accents. System fonts only.
   ========================================================================== */
:root {
  --color-black: #000000;
  --color-tan: #86745c;
  --color-light-tan: #c2baab;
  --color-dark-tan: #6a5c48;
  --color-white: #ffffff;
  --color-black-63: rgba(0, 0, 0, 0.63);
  --color-black-80: rgba(0, 0, 0, 0.8);
  --color-black-88: rgba(0, 0, 0, 0.88);
  --color-gold: #b19977;
  --color-accent: #b19977;
  --color-accent-light: #c2baab;
}
:root {   /* extra tokens for states; always paired with text or an icon */
  --color-ok: #a6e8b0;
  --color-error: #ffa59c;
  --color-warn: #ffdc8f;
  --font-ui: "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif;
  --font-display: Georgia, "Gelasio", "Times New Roman", serif;
  --font-mono: "Roboto Mono", "DejaVu Sans Mono", Consolas, Menlo, "Liberation Mono", "Courier New", monospace;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--color-black); color: var(--color-white); font: 16px/1.5 var(--font-ui); }
h1, h2, h3, h4 { font-family: var(--font-display); line-height: 1.2; margin: 0 0 .5em; font-weight: 700; }
h1 { font-size: clamp(1.8rem, 4.5vw, 2.8rem); }
h2 { font-size: 1.4rem; } h3 { font-size: 1.15rem; } h4 { font-size: 1rem; }
p { margin: 0 0 .85em; }
a { color: var(--color-light-tan); }
.mono, code, pre, input.mono, textarea.mono { font-family: var(--font-mono); }
.small { font-size: .875rem; }
.sr-only { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.skip-link { position: absolute; left: 8px; top: -60px; z-index: 100; background: var(--color-gold); color: #000; padding: .6rem 1rem; font-weight: 700; }
.skip-link:focus { top: 8px; }
.noscript { background: var(--color-dark-tan); padding: 1rem; margin: 1rem; border: 2px solid var(--color-gold); }
[hidden] { display: none !important; }

:focus-visible { outline: 3px solid var(--color-gold); outline-offset: 2px; }
h1[tabindex="-1"]:focus, h2[tabindex="-1"]:focus, .vm-title[tabindex="-1"]:focus, #main:focus, .win-body:focus { outline: none; }
.panel :focus-visible, .card :focus-visible, dialog :focus-visible { outline-color: var(--color-white); }

/* ---------- layout shell ---------- */
#shell { min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column; }
#main { flex: 1 1 auto; min-height: 0; outline: none; }
body[data-screen="desktop"] #shell { height: 100vh; height: 100dvh; }
body[data-screen="desktop"] #main { overflow: hidden; }
#site-footer { flex: none; display: flex; flex-wrap: wrap; justify-content: space-between; gap: .25rem 1.5rem; padding: .4rem 1rem; background: var(--color-black);
  border-top: 2px solid var(--color-gold); font-size: .8125rem; color: var(--color-light-tan); }
#site-footer span:first-child { color: var(--color-white); font-weight: 600; }
.screen { padding: 1rem; }
.screen.desktop { padding: 0; height: 100%; min-width: 0; overflow: hidden; }
#main { min-width: 0; }

/* ---------- buttons, fields, messages ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: .4rem; min-height: 44px; padding: .55rem 1.1rem; border: 2px solid var(--color-gold);
  border-radius: 6px; background: var(--color-gold); color: #000; font: 700 1rem/1.2 var(--font-ui); text-decoration: none; cursor: pointer; }
.btn:hover { background: var(--color-light-tan); border-color: var(--color-light-tan); }
.btn:disabled { opacity: .6; cursor: progress; }
.btn-secondary { background: transparent; color: var(--color-white); }
.btn-secondary:hover { background: rgba(177, 153, 119, .25); border-color: var(--color-gold); }
.btn-small { min-height: 36px; padding: .3rem .75rem; font-size: .875rem; }
.btn[aria-pressed="true"] { box-shadow: inset 0 0 0 2px #000; }
.btn-row { display: flex; flex-wrap: wrap; gap: .6rem; margin: .8rem 0; }
.field { margin-bottom: 1rem; }
label { display: block; font-weight: 600; margin-bottom: .3rem; }
input[type="text"], input[type="search"], textarea { width: 100%; min-height: 44px; padding: .55rem .7rem; background: var(--color-black); color: var(--color-white);
  border: 2px solid var(--color-light-tan); border-radius: 6px; font-size: 1rem; }
input[readonly] { border-style: dashed; }
textarea { resize: vertical; min-height: 4rem; }
input::placeholder, textarea::placeholder { color: #b9b1a3; }
label.check { display: inline-flex; align-items: center; gap: .4rem; font-weight: 500; margin: 0; }
input[type="checkbox"] { width: 1.15rem; height: 1.15rem; accent-color: var(--color-gold); }
.msg { margin: .6rem 0; }
.msg:empty { display: none; }
.msg-error, .msg-ok, .msg-warn { padding: .5rem .75rem; background: var(--color-black-88); border-left: 5px solid currentColor; border-radius: 4px; }
.msg-error { color: var(--color-error); } .msg-ok { color: var(--color-ok); } .msg-warn { color: var(--color-warn); }
.panel { background: var(--color-dark-tan); border: 1px solid var(--color-tan); border-top: 4px solid var(--color-gold); border-radius: 8px; padding: 1.25rem 1.5rem; color: var(--color-white); }
.panel a { color: var(--color-white); }
.table-wrap { overflow-x: auto; max-width: 100%; }

/* ---------- welcome ---------- */
.welcome { background: radial-gradient(ellipse at 15% -10%, rgba(177, 153, 119, .22), transparent 55%), var(--color-black); }
.welcome-inner { max-width: 1060px; margin: 0 auto; padding: 1rem 0 2rem; }
.hero { display: flex; gap: 1.5rem; align-items: center; margin-bottom: 1.75rem; flex-wrap: wrap; }
.hero-logo { width: 120px; height: 120px; object-fit: contain; flex: none; }
.eyebrow { color: var(--color-light-tan); font-size: .95rem; margin: 0 0 .25rem; letter-spacing: .02em; }
.hero h1 { margin: 0 0 .35rem; }
.credit { color: var(--color-gold); font-weight: 600; margin: 0; font-size: 1.05rem; }
.welcome-grid { display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr); gap: 1.25rem; align-items: start; }
.steps { padding-left: 1.3rem; margin: 0 0 1rem; } .steps li { margin-bottom: .45rem; }
.note { font-size: .9375rem; margin: 0; padding-top: .6rem; border-top: 1px solid var(--color-tan); }

/* ---------- access ---------- */
.access { display: flex; justify-content: center; }
.access-inner { width: min(760px, 100%); }
.access-head { display: flex; gap: 1rem; align-items: center; margin-bottom: .5rem; } .access-head img { object-fit: contain; flex: none; }
.access-head h2 { margin-bottom: .2rem; } .access-head p { margin: 0; }
.encoded-row { display: flex; gap: .6rem; flex-wrap: wrap; } .encoded-row input { flex: 1 1 260px; font-size: 1.15rem; letter-spacing: .04em; }
.instructions { background: var(--color-black-80); padding: .7rem .9rem; border-left: 4px solid var(--color-gold); border-radius: 4px; margin: .9rem 0; }

/* ---------- desktop shell ---------- */
.vm { height: 100%; width: 100%; min-width: 0; display: grid; grid-template-columns: minmax(0, 1fr); grid-template-rows: auto minmax(0, 1fr); background:
  linear-gradient(rgba(177, 153, 119, .05) 1px, transparent 1px) 0 0 / 40px 40px,
  linear-gradient(90deg, rgba(177, 153, 119, .05) 1px, transparent 1px) 0 0 / 40px 40px,
  radial-gradient(ellipse at 80% 0%, rgba(177, 153, 119, .18), transparent 60%), var(--color-black); }
.vm-top { display: flex; flex-wrap: wrap; align-items: center; gap: .4rem 1.25rem; padding: .4rem .9rem; background: var(--color-dark-tan); border-bottom: 3px solid var(--color-gold); }
.vm-brand { display: flex; align-items: center; gap: .6rem; margin-right: auto; } .vm-brand img { object-fit: contain; border-radius: 50%; background: #000; }
.vm-title { display: block; font-family: var(--font-display); font-size: 1.1rem; line-height: 1.1; }
.vm-sub { display: block; font-size: .8125rem; color: var(--color-white); }
.vm-user { font-size: .95rem; overflow-wrap: anywhere; max-width: 30ch; }
.vm-progress { display: grid; gap: .2rem; min-width: 150px; font-size: .875rem; }
.bar { height: 10px; background: #000; border: 1px solid var(--color-light-tan); border-radius: 6px; overflow: hidden; }
.bar span { display: block; height: 100%; width: 0; background: var(--color-gold); transition: width .3s; }
.vm-body { display: grid; grid-template-columns: 188px minmax(0, 1fr); gap: .6rem; padding: .6rem; min-height: 0; min-width: 0; }
.dock-list { display: flex; flex-direction: column; gap: .35rem; }
.dock-btn { display: flex; align-items: center; gap: .6rem; width: 100%; text-align: left; padding: .6rem .7rem; min-height: 48px; background: var(--color-black-80); color: var(--color-white);
  border: 2px solid var(--color-tan); border-radius: 8px; font: 600 .9rem/1.2 var(--font-ui); cursor: pointer; }
.dock-btn:hover { background: var(--color-dark-tan); }
.dock-btn.active { background: var(--color-gold); color: #000; border-color: var(--color-gold); }
.dock-icon { flex: none; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.windows { min-height: 0; min-width: 0; display: flex; }
.win { flex: 1; min-width: 0; min-height: 0; display: flex; flex-direction: column; background: var(--color-black-88); border: 2px solid var(--color-tan); border-radius: 8px; overflow: hidden; box-shadow: 0 10px 30px rgba(0, 0, 0, .6); }
.win-title { display: flex; align-items: center; gap: .7rem; padding: .4rem .8rem; background: var(--color-dark-tan); border-bottom: 2px solid var(--color-gold); flex: none; }
.win-title h2 { margin: 0; font-size: 1rem; font-family: var(--font-ui); }
.win-dots { display: inline-flex; gap: 5px; } .win-dots i { width: 11px; height: 11px; border-radius: 50%; background: var(--color-light-tan); display: block; opacity: .85; }
.win-body { flex: 1; min-height: 0; overflow: auto; padding: .9rem; }
.win-body:focus { outline: none; }

/* ---------- briefing ---------- */
.brief { display: grid; gap: .8rem; max-width: 980px; }
.card { background: var(--color-dark-tan); border: 1px solid var(--color-tan); border-left: 5px solid var(--color-gold); border-radius: 6px; padding: .9rem 1.1rem; color: var(--color-white); }
.card h3 { margin-bottom: .4rem; } .card ul, .card ol { margin: 0; padding-left: 1.3rem; } .card li { margin-bottom: .3rem; }
.narrative { font-size: 1.05rem; margin: 0; }
table.ref { border-collapse: collapse; width: 100%; max-width: 560px; margin-bottom: .6rem; }
table.ref th, table.ref td { text-align: left; padding: .35rem .6rem; border: 1px solid var(--color-tan); }
table.ref thead th { background: var(--color-light-tan); color: #000; }
table.ref tbody th { font-weight: 600; background: rgba(0, 0, 0, .25); } table.ref td { background: rgba(0, 0, 0, .45); }

/* ---------- packet viewer + auth log ---------- */
.win-body.pv-body, .win-body.term-body { display: flex; flex-direction: column; overflow: hidden; padding: .6rem; gap: .45rem; }
.pv-sim { background: var(--color-black); border: 1px dashed var(--color-gold); padding: .3rem .6rem; font-size: .8125rem; border-radius: 4px; margin: 0; }
.pv-sim strong { color: var(--color-gold); margin-right: .35rem; }
.pv-toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: .4rem .6rem; }
.pv-toolbar label:not(.check) { margin: 0; white-space: nowrap; }
.pv-toolbar input[type="text"], .pv-toolbar input[type="search"] { flex: 1 1 280px; min-width: 0; width: auto; min-height: 38px; font-size: .9375rem; }
.pv-count { font-size: .875rem; color: var(--color-light-tan); margin-left: auto; }
.pv-tools { display: flex; flex-wrap: wrap; gap: .4rem .6rem; align-items: center; }
.pv-tools .small { flex: 1 1 260px; color: var(--color-light-tan); }
.pv-tools { position: relative; }
.filter-ref summary { display: inline-flex; align-items: center; min-height: 36px; padding: .3rem .75rem; border: 2px solid var(--color-gold); border-radius: 6px; font: 700 .875rem/1.2 var(--font-ui); cursor: pointer; list-style: none; }
.filter-ref summary::-webkit-details-marker { display: none; } .filter-ref summary::before { content: "\25B8"; margin-right: .4rem; } .filter-ref[open] summary::before { content: "\25BE"; }
.filter-ref[open] summary { background: rgba(177, 153, 119, .25); }
.fr-body { position: absolute; left: 0; top: calc(100% + 6px); z-index: 30; width: min(800px, 94vw); max-height: 60vh; overflow: auto; background: #000; border: 2px solid var(--color-gold); border-radius: 6px; padding: .7rem; box-shadow: 0 12px 30px rgba(0, 0, 0, .7); }
.fr-body table { margin: 0 0 .5rem; max-width: none; } .fr-body .small { margin: 0; }
.pv-split { flex: 1; min-height: 0; display: grid; grid-template-columns: minmax(0, 1fr) 310px; gap: .6rem; }
.pv-list { min-height: 0; display: flex; border: 1px solid var(--color-tan); border-radius: 4px; background: #000; }
.pv-list-scroll { flex: 1; overflow: auto; min-width: 0; }
table.pkt, table.log { border-collapse: collapse; width: 100%; font-size: .78rem; }
table.pkt thead th, table.log thead th { position: sticky; top: 0; z-index: 2; background: var(--color-light-tan); color: #000; text-align: left; padding: .3rem .5rem; font-family: var(--font-ui); font-size: .8125rem; white-space: nowrap; }
table.pkt td, table.log td { padding: .12rem .4rem; white-space: nowrap; border-bottom: 1px solid rgba(194, 186, 171, .15); }
table.pkt tbody tr:nth-child(even), table.log tbody tr:nth-child(even) { background: rgba(177, 153, 119, .09); }
table.pkt tbody tr { cursor: pointer; } table.pkt tbody tr:hover { background: rgba(177, 153, 119, .28); }
table.pkt tr.sel, table.pkt tr.sel:hover { background: var(--color-gold); color: #000; }
table.pkt tr:focus-visible { outline: 3px solid var(--color-white); outline-offset: -3px; }
table.pkt tr.sel:focus-visible { outline-color: #000; }
table.pkt td.c-info { max-width: 34ch; overflow: hidden; text-overflow: ellipsis; }
@media (min-width: 1500px) { table.pkt td.c-info { max-width: 64ch; } } .c-num, .c-no { text-align: right; } .c-star { text-align: center; width: 2rem; padding: 0 !important; }
.star { background: transparent; border: 0; color: inherit; font-size: 1.05rem; line-height: 1; padding: 0 .3rem; min-width: 28px; min-height: 22px; cursor: pointer; vertical-align: middle; }
@media (pointer: coarse) { .star { min-height: 38px; min-width: 38px; } }
tr.sel .star:focus-visible { outline-color: #000; }
.pv-details { min-height: 0; overflow: auto; background: var(--color-black-80); border: 1px solid var(--color-tan); border-radius: 4px; padding: .6rem; }
.det-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: .4rem; margin-bottom: .3rem; } .det-head h3 { margin: 0; font-size: 1rem; }
.det-sum { background: #000; border-left: 4px solid var(--color-gold); padding: .35rem .6rem; font-size: .8125rem; margin: 0 0 .5rem; overflow-wrap: anywhere; }
details.tree { margin-bottom: .3rem; } details.tree > summary { cursor: pointer; background: rgba(194, 186, 171, .2); padding: .3rem .5rem; font: 600 .8125rem var(--font-mono); border-radius: 3px; overflow-wrap: anywhere; }
details.tree ul { list-style: none; margin: .2rem 0 0 .6rem; padding: 0 0 0 .7rem; border-left: 2px solid var(--color-tan); font: .8125rem/1.5 var(--font-mono); } details.tree li { overflow-wrap: anywhere; }
.empty { color: var(--color-light-tan); }
.log-wrap { flex: 1; min-height: 0; overflow: auto; border: 1px solid var(--color-tan); border-radius: 4px; background: #000; }
table.log td.log-text { white-space: pre-wrap; overflow-wrap: anywhere; } table.log tr.bm { background: rgba(177, 153, 119, .3); }
mark { background: var(--color-gold); color: #000; padding: 0 2px; border-radius: 2px; }
#body-authlog { display: flex; flex-direction: column; overflow: hidden; padding: .6rem; gap: .45rem; }

/* ---------- notebook ---------- */
.nb { max-width: 900px; display: grid; gap: .7rem; } .ev h4 { margin-bottom: .2rem; } .ev-detail { font-size: .8125rem; overflow-wrap: anywhere; background: rgba(0, 0, 0, .45); padding: .35rem .5rem; border-radius: 4px; }
.ev textarea, .nb > textarea { min-height: 3rem; margin-bottom: .5rem; font-size: .875rem; }

/* ---------- terminal ---------- */
.term-actions { display: flex; flex-wrap: wrap; gap: .4rem; }
.term-out { flex: 1; min-height: 140px; overflow: auto; background: #000; border: 2px solid var(--color-tan); border-radius: 6px; padding: .6rem .8rem; font-size: .9rem; line-height: 1.45; }
.tl { white-space: pre-wrap; overflow-wrap: anywhere; min-height: 1.2em; }
.t-prompt { color: var(--color-gold); } .t-title { color: var(--color-gold); font-weight: 700; } .t-info { color: var(--color-light-tan); }
.t-ok { color: var(--color-ok); } .t-err { color: var(--color-error); } .t-hint { color: var(--color-warn); }
.term-form { display: flex; gap: .5rem; align-items: center; } .term-prompt { margin: 0; white-space: nowrap; color: var(--color-gold); font-weight: 500; font-size: .875rem; }
.term-form input { flex: 1; min-width: 0; font-family: var(--font-mono); }

/* ---------- completion ---------- */
.complete { position: relative; display: flex; justify-content: center; overflow: hidden; background: radial-gradient(ellipse at 50% -20%, rgba(177, 153, 119, .3), transparent 60%), var(--color-black); }
.complete-inner { width: min(900px, 100%); position: relative; z-index: 1; text-align: center; margin: 1rem 0; }
.complete-inner > * { text-align: left; } .complete-inner .big-check, .complete-inner h2, .complete-inner .lead { text-align: center; }
.big-check { display: block; margin: 0 auto .5rem; color: var(--color-gold); background: #000; border-radius: 50%; }
.complete h2 { font-size: clamp(1.5rem, 4vw, 2.2rem); overflow-wrap: anywhere; } .lead { font-size: 1.1rem; }
.scorecard { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: .6rem; margin: 1rem 0; }
.scorecard div { background: var(--color-black-80); border: 1px solid var(--color-gold); border-radius: 6px; padding: .6rem .8rem; } .scorecard dt { font-size: .85rem; color: var(--color-light-tan); } .scorecard dd { margin: 0; font-weight: 700; font-size: 1.1rem; overflow-wrap: anywhere; }
table.results { width: 100%; border-collapse: collapse; font-size: .9rem; } table.results th { background: var(--color-light-tan); color: #000; text-align: left; padding: .4rem .6rem; }
table.results td { padding: .4rem .6rem; border-bottom: 1px solid var(--color-tan); background: rgba(0, 0, 0, .35); vertical-align: top; overflow-wrap: anywhere; }
.confetti i { position: absolute; top: -20px; width: 9px; height: 16px; background: var(--color-gold); opacity: .9; animation: fall 3s linear infinite; }
.confetti i:nth-child(3n) { background: var(--color-light-tan); } .confetti i:nth-child(3n+1) { background: var(--color-white); width: 7px; }
@keyframes fall { to { transform: translateY(110vh) rotate(540deg); } }

/* ---------- toast + dialog ---------- */
.toast { position: fixed; left: 50%; bottom: 52px; transform: translateX(-50%); max-width: min(680px, 92vw); background: var(--color-light-tan); color: #000; padding: .6rem 1rem; border-radius: 8px;
  border: 2px solid var(--color-gold); font-weight: 600; z-index: 60; opacity: 0; pointer-events: none; transition: opacity .2s; } .toast.show { opacity: 1; } .toast:empty { display: none; }
dialog { background: var(--color-dark-tan); color: var(--color-white); border: 3px solid var(--color-gold); border-radius: 10px; padding: 1.4rem; max-width: min(520px, 92vw); }
dialog::backdrop { background: rgba(0, 0, 0, .8); } dialog h2 { margin-top: 0; }

/* ---------- responsive ---------- */
@media (max-width: 1100px) {
  .win-body.pv-body { overflow: auto; } .pv-split { display: block; flex: none; } .pv-list { max-height: 52vh; } .pv-list-scroll { max-height: 52vh; } .pv-details { margin-top: .6rem; overflow: visible; }
  #body-authlog { overflow: auto; } .log-wrap { flex: none; max-height: 60vh; }
}
@media (max-width: 900px) {
  .welcome-grid { grid-template-columns: 1fr; }
  .vm-body { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto minmax(0, 1fr); padding: .4rem; gap: .4rem; }
  .dock-list { flex-direction: row; overflow-x: auto; padding-bottom: 2px; }
  .dock-btn { flex-direction: column; justify-content: center; text-align: center; min-width: 92px; width: auto; font-size: .75rem; padding: .4rem; gap: .2rem; }
  .vm-sub { display: none; } .vm-top { padding: .35rem .6rem; gap: .3rem .8rem; } .vm-user { max-width: 16ch; }
}
@media (max-width: 520px) { .hero-logo { width: 84px; height: 84px; } .vm-progress { min-width: 120px; } .term-form { flex-wrap: wrap; } .term-prompt { width: 100%; } }
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; scroll-behavior: auto !important; } }
@media (prefers-contrast: more) { table.pkt td, table.log td { border-bottom-color: var(--color-light-tan); } }
@media print { body { background: #fff; color: #000; } .dock, .vm-top, .toast, #site-footer { display: none; } }
