/* DragonFly Mål, resultatsidor. Tokens, typsnitt och layout från den godkända prototypen (malwebb-prototyp).
   Klockans siffror i mono, nummerlappar i kondenserad. Ljust och mörkt via prefers-color-scheme. */
:root {
	--bg: #f3f5f7; --panel: #ffffff; --ink: #17202a; --mute: #5b6876; --line: #d9dfe5;
	--accent: #d9480f; --accent-ink: #ffffff; --accent-soft: #fde6db;
	--ok: #1f7a4d; --ok-soft: #dcf1e5; --warn: #a15c00; --warn-soft: #fbecd2; --bad: #b42318; --bad-soft: #fbe0dd;
	--bib: #fafaf7; --bib-ink: #111111; --shirt: #2f5d8a;
	--f-disp: "Barlow Condensed", "Arial Narrow", system-ui, sans-serif;
	--f-body: "Source Sans 3", system-ui, -apple-system, "Segoe UI", sans-serif;
	--f-mono: "JetBrains Mono", ui-monospace, Menlo, monospace;
}
@media (prefers-color-scheme: dark) {
	:root:not([data-theme="light"]) {
		--bg: #11161b; --panel: #1a2128; --ink: #e7ecf0; --mute: #97a4b0; --line: #2c3640;
		--accent: #ff7a3d; --accent-ink: #1a0d05; --accent-soft: #3a2216;
		--ok: #5cc98f; --ok-soft: #173326; --warn: #f0b75a; --warn-soft: #3a2c14; --bad: #ff8a7e; --bad-soft: #3d1a17;
		--bib: #e9e9e2; --bib-ink: #111111; --shirt: #3d6f9e; color-scheme: dark;
	}
}
:root[data-theme="dark"] {
	--bg: #11161b; --panel: #1a2128; --ink: #e7ecf0; --mute: #97a4b0; --line: #2c3640;
	--accent: #ff7a3d; --accent-ink: #1a0d05; --accent-soft: #3a2216;
	--ok: #5cc98f; --ok-soft: #173326; --warn: #f0b75a; --warn-soft: #3a2c14; --bad: #ff8a7e; --bad-soft: #3d1a17;
	--bib: #e9e9e2; --bib-ink: #111111; --shirt: #3d6f9e; color-scheme: dark;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
	margin: 0; background: var(--bg); color: var(--ink); font-family: var(--f-body); font-size: 15px; line-height: 1.45;
	padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px));
	padding-top: 16px; padding-bottom: 48px;
}
.wrap { max-width: 1080px; margin: 0 auto; display: flex; flex-direction: column; gap: 16px; }
h1, h2, h3 { font-family: var(--f-disp); font-weight: 700; letter-spacing: .01em; text-wrap: balance; margin: 0; }
h1 { font-size: 30px; } h2 { font-size: 22px; } h3 { font-size: 17px; }
p { margin: 0; }
a { color: var(--accent); }
.mute { color: var(--mute); }
.mono { font-family: var(--f-mono); font-variant-numeric: tabular-nums; }
.eyebrow { font-size: 12px; text-transform: uppercase; letter-spacing: .08em; color: var(--mute); font-weight: 600; }
.note { font-size: 13px; color: var(--mute); }
.err { color: var(--bad); font-size: 14px; }
.ok-text { color: var(--ok); font-size: 14px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

button, .btn {
	font: inherit; font-weight: 600; border: 1px solid var(--line); background: var(--panel); color: var(--ink);
	border-radius: 8px; padding: 9px 14px; cursor: pointer; text-decoration: none; display: inline-block; line-height: 1.3;
}
button:hover, .btn:hover { border-color: var(--mute); }
button:focus-visible, .btn:focus-visible, input:focus-visible, select:focus-visible, a:focus-visible, summary:focus-visible {
	outline: 2px solid var(--accent); outline-offset: 2px;
}
button.primary, .btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
button.ok { background: var(--ok); border-color: var(--ok); color: var(--panel); }
button.bad { color: var(--bad); border-color: var(--bad); }
button.bad.solid { background: var(--bad); color: var(--panel); }
button.small { padding: 4px 10px; font-size: 13px; }
button:disabled { opacity: .45; cursor: not-allowed; }
input, select {
	font: inherit; color: var(--ink); background: var(--panel); border: 1px solid var(--line); border-radius: 8px;
	padding: 9px 11px; max-width: 100%;
}
input[type="range"] { padding: 0; accent-color: var(--accent); }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 18px; }
.col { display: flex; flex-direction: column; gap: 14px; }
.row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.grow { flex: 1; min-width: 0; }

/* topbar */
header.top { display: flex; justify-content: space-between; align-items: flex-end; gap: 12px; flex-wrap: wrap; }
.brand { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.brand .url { font-family: var(--f-mono); font-size: 13px; color: var(--mute); overflow-wrap: anywhere; }
nav.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); overflow-x: auto; align-items: stretch; }
nav.tabs button, nav.tabs a {
	border: none; background: none; border-radius: 0; padding: 10px 14px; color: var(--mute);
	border-bottom: 3px solid transparent; white-space: nowrap; font: inherit; font-weight: 600; cursor: pointer; text-decoration: none;
}
nav.tabs button[aria-selected="true"] { color: var(--ink); border-bottom-color: var(--accent); }
nav.tabs .spacer { flex: 1; }
.badge {
	display: inline-block; min-width: 22px; padding: 0 6px; border-radius: 11px; background: var(--accent);
	color: var(--accent-ink); font-size: 12px; text-align: center; margin-left: 4px;
}

/* login */
.login { display: grid; grid-template-columns: minmax(0, 1fr); gap: 24px; max-width: 520px; margin: 0 auto; width: 100%; }
.login form { display: flex; flex-direction: column; gap: 14px; }
.codein { font-family: var(--f-mono); font-size: 22px; letter-spacing: .08em; text-transform: uppercase; width: 100%; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field .lbl { font-weight: 600; }

/* overview */
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 260px), 1fr)); gap: 16px; }
.stat { display: flex; flex-direction: column; gap: 2px; }
.stat b { font-family: var(--f-disp); font-size: 34px; line-height: 1; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(100px, 1fr)); gap: 12px; }
.dev { display: flex; gap: 12px; align-items: center; border: 1px solid var(--line); border-radius: 10px; padding: 12px; }
.dev .dot { width: 10px; height: 10px; border-radius: 50%; background: var(--ok); flex: none; }
.dev.stale .dot { background: var(--warn); }
.dev.gone .dot { background: var(--bad); }
.chip { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; font-weight: 600; padding: 2px 8px; border-radius: 999px; white-space: nowrap; }
.chip.ok { background: var(--ok-soft); color: var(--ok); } .chip.warn { background: var(--warn-soft); color: var(--warn); }
.chip.bad { background: var(--bad-soft); color: var(--bad); } .chip.n { background: var(--bg); color: var(--mute); border: 1px solid var(--line); }

/* settings */
.choices { display: flex; flex-direction: column; gap: 8px; }
.choice { display: flex; gap: 10px; align-items: flex-start; border: 1px solid var(--line); border-radius: 10px; padding: 12px; cursor: pointer; }
.choice:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }
.choice:has(input:focus-visible) { outline: 2px solid var(--accent); outline-offset: 2px; }
.choice input { margin-top: 4px; accent-color: var(--accent); }
.toggle { display: flex; gap: 10px; align-items: center; }
.toggle input { width: 18px; height: 18px; accent-color: var(--accent); }
.codebox { font-family: var(--f-mono); font-size: 12px; background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 10px; overflow-x: auto; white-space: pre; user-select: all; }
.danger { border-color: var(--bad); }
.confirmbox { border: 1px solid var(--bad); background: var(--bad-soft); border-radius: 10px; padding: 12px; display: flex; flex-direction: column; gap: 10px; }

/* review */
.review { display: grid; grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr); gap: 16px; align-items: start; }
.crop { width: 100%; aspect-ratio: 4/3; border-radius: 10px; overflow: hidden; background: var(--bg); border: 1px solid var(--line); display: flex; align-items: center; justify-content: center; }
.crop img { width: 100%; height: 100%; object-fit: contain; display: block; }
.crop .noimg { color: var(--mute); padding: 16px; text-align: center; }
.thumbs { display: flex; gap: 8px; margin-top: 8px; flex-wrap: wrap; align-items: center; }
.thumbs .t { width: 72px; aspect-ratio: 4/3; border-radius: 6px; overflow: hidden; border: 2px solid transparent; cursor: pointer; padding: 0; background: var(--bg); }
.thumbs .t[aria-pressed="true"] { border-color: var(--accent); }
.thumbs img { width: 100%; height: 100%; object-fit: cover; display: block; }
.readout { font-family: var(--f-disp); font-size: 54px; line-height: 1; font-weight: 700; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 4px 14px; font-size: 14px; margin: 0; }
.kv dt { color: var(--mute); } .kv dd { margin: 0; }
.sugg { display: flex; gap: 8px; flex-wrap: wrap; }
.sugg button { font-family: var(--f-disp); font-size: 20px; padding: 4px 14px; }
.actions { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.queue { display: flex; flex-direction: column; gap: 6px; max-height: 260px; overflow: auto; }
.qi { display: flex; justify-content: space-between; gap: 8px; padding: 8px 10px; border-radius: 8px; border: 1px solid var(--line); background: none; text-align: left; font-weight: 400; width: 100%; }
.qi[aria-current="true"] { border-color: var(--accent); background: var(--accent-soft); }
.empty { padding: 28px; text-align: center; color: var(--mute); }
.keypad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; max-width: 240px; }
.keypad button { font-family: var(--f-mono); font-size: 20px; padding: 10px 0; }
.passages { display: flex; flex-direction: column; gap: 10px; }
.passage { display: grid; grid-template-columns: 96px 1fr auto; gap: 10px; align-items: center; border: 1px solid var(--line); border-radius: 10px; padding: 8px; }
.passage img, .passage .noimg { width: 96px; aspect-ratio: 4/3; object-fit: cover; border-radius: 6px; background: var(--bg); display: block; }
.passage .noimg { display: flex; align-items: center; justify-content: center; font-size: 12px; color: var(--mute); }

/* results */
.tablewrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th { text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--mute); font-weight: 600; padding: 8px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
td { padding: 8px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
td.bib { font-family: var(--f-disp); font-size: 19px; font-weight: 700; }
td .inline { width: 110px; padding: 4px 6px; }
tr.hiddenrow td { color: var(--mute); }
.addform { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; border: 1px solid var(--line); border-radius: 10px; padding: 12px; }
.addform .field { min-width: 120px; }
.errlist { margin: 6px 0 0; padding-left: 18px; font-size: 13px; color: var(--bad); }

/* public */
.pub { max-width: 680px; margin: 0 auto; display: flex; flex-direction: column; gap: 14px; width: 100%; }
.pubhead { border-bottom: 4px solid var(--accent); padding-bottom: 10px; display: flex; flex-direction: column; gap: 4px; }
.live { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--mute); }
.live i { width: 8px; height: 8px; border-radius: 50%; background: var(--bad); animation: pulse 1.6s infinite; }
.live.off i { background: var(--mute); animation: none; }
@keyframes pulse { 50% { opacity: .3; } }
.pubrow { display: grid; grid-template-columns: 44px 72px 1fr auto; gap: 10px; align-items: baseline; padding: 8px 6px; border-bottom: 1px solid var(--line); }
.pubrow .pl { font-family: var(--f-disp); font-size: 20px; color: var(--mute); }
.pubrow .b { font-family: var(--f-disp); font-size: 22px; font-weight: 700; }
.pubrow .nm { min-width: 0; overflow-wrap: anywhere; }
.pubrow .nm small { display: block; color: var(--mute); font-size: 12px; }
.pubrow .tm { text-align: right; }
.pubrow .tm small { display: block; color: var(--mute); font-size: 12px; }
.pubrow.fresh { background: var(--accent-soft); }
body.embed { padding: 0; background: transparent; }
body.embed .pub { max-width: none; }
body.embed .panel { border: none; border-radius: 0; padding: 8px; background: transparent; }
body.embed .chrome { display: none !important; }

.toast {
	position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(20px + env(safe-area-inset-bottom, 0px));
	background: var(--ink); color: var(--panel); padding: 10px 16px; border-radius: 8px; font-weight: 600; z-index: 20; max-width: calc(100vw - 32px);
}
.toast.error { background: var(--bad); color: #fff; }

@media (max-width: 760px) {
	.review { grid-template-columns: minmax(0, 1fr); }
	.pubrow { grid-template-columns: 34px 60px 1fr auto; }
	.readout { font-size: 44px; }
	h1 { font-size: 26px; }
}
@media (prefers-reduced-motion: reduce) {
	*, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
	.live i { animation: none; }
}

.eyebrow.mono { text-transform: none; letter-spacing: .02em; overflow-wrap: anywhere; }
input.grow { min-width: 140px; }
@media (max-width: 480px) {
	nav.tabs button, nav.tabs a { padding: 10px 9px; font-size: 14px; }
	.passage { grid-template-columns: 72px 1fr; }
	.passage .noimg, .passage img { width: 72px; }
	.passage button { grid-column: 1 / -1; }
}
