/* Operator tools: document flow, ledger rules, and existing app states. */
body.operator-app {
	margin: 0; background: var(--paper); color: var(--ink);
	font: 400 21px/1.6 var(--serif); font-optical-sizing: auto;

	& #main {
		width: min(100% - var(--gutter) * 2, 1120px); margin: 0 auto;
		padding: 64px 0 80px; min-width: 0; overflow-wrap: anywhere;

		& *, & *::before, & *::after { box-sizing: border-box; }
		& h1, & h2, & h3, & .question, & .wine {
			font-family: var(--display); font-weight: 500; letter-spacing: -.012em;
			line-height: 1.12; color: var(--ink); text-wrap: balance;
		}
		& h1 { margin: 0 0 20px; font-size: clamp(44px, 6vw, 76px); }
		& h2 { margin: 0 0 12px; font-size: clamp(30px, 4vw, 42px); }
		& h3 { margin: 0 0 12px; font-size: 29px; }
		& h1 em, & h1 .no { font-family: var(--serif); color: var(--oxblood); }
		& p { margin: 0 0 20px; color: var(--ink); }
		& a { color: var(--oxblood); text-decoration-thickness: 1px; text-underline-offset: 5px; }
		& :focus-visible { outline: 2px solid var(--oxblood); outline-offset: 4px; }
		& > header { text-align: left; margin-bottom: 36px; }

		& .eyebrow, & .tag, & label, & th,
		& .k, & .s, & .qnum, & .glassno, & .hud, & .points,
		& .stp, & .stg, & .flag, & .verdict, & .res, & .stamp,
		& .credit, & .copied, & .clue b, & .note b, & footer {
			font-family: var(--mono); font-size: 13px; font-weight: 400;
			font-style: normal; line-height: 1.7; letter-spacing: .06em; color: var(--soft);
		}
		& .eyebrow, & .tag, & label, & th, & .k,
		& .qnum, & .glassno, & .hud, & .stp, & .stg, & .flag,
		& .res, & .stamp, & .credit, & .clue b, & .note b, & footer {
			text-transform: uppercase;
		}
		& .eyebrow { margin-bottom: 20px; }
		& .tag { margin: 0 0 16px; }
		& .privacy { max-width: 66ch; margin: 0; font-size: 18px; }
		& .sub { margin: 0 0 28px; font-size: 18px; }
		& label { display: block; margin-bottom: 8px; }
		& .lede, & .hint, & .coach, & .tell, & .why, & .describe-note {
			color: var(--ink); font-family: var(--serif);
			font-size: inherit; font-style: italic; line-height: 1.6;
		}
		& .lede { max-width: 48ch; margin: 24px auto 32px; }
		& .hint, & .coach { margin: 28px 0 0; border-top: 1px solid var(--hair); padding-top: 20px; }
		& .panel { padding: 28px 0; border-top: 1px solid var(--ink); }
		& .grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 210px), 1fr)); gap: 24px; margin-bottom: 28px; }
		& .grid > *, & .addrow > * { min-width: 0; }
		& input, & select, & textarea {
			display: block; width: 100%; min-width: 0; max-width: 100%; min-height: 48px;
			padding: 10px 12px; border: 1px solid var(--hair); border-radius: 0;
			background: var(--sheet); color: var(--ink); font: inherit; letter-spacing: normal;
		}
		& textarea { resize: vertical; }
		& input::placeholder, & textarea::placeholder { color: var(--soft); opacity: 1; font-style: italic; }
		& input:focus, & select:focus, & textarea:focus { border-color: var(--oxblood); outline: 2px solid var(--oxblood); outline-offset: 3px; }
		& button {
			max-width: 100%; min-height: 48px; padding: 12px 20px;
			border: 1px solid var(--oxblood); border-radius: 0;
			background: var(--oxblood); color: var(--sheet);
			font: 400 16px/1.5 var(--serif); letter-spacing: .06em; text-transform: uppercase;
			white-space: normal; overflow-wrap: anywhere; cursor: pointer;
		}
		& button:hover:not(:disabled) { background: var(--ink); border-color: var(--ink); color: var(--sheet); }
		& button:disabled { cursor: default; }
		& .ghost, & .ghostd, & .pill, & .opt, & .choice, & .tab, & .again {
			background: transparent; color: var(--ink); border-color: var(--hair);
		}
		& .pill, & .opt, & .choice { font: inherit; letter-spacing: normal; text-transform: none; }
		& .pill.sel, & .tab.on { background: var(--oxblood); border-color: var(--oxblood); color: var(--sheet); }
		& .tabs, & .steps, & .stages, & .pills, & .actions, & .actions2, & .endrow, & .endbtns {
			display: flex; flex-wrap: wrap; gap: 12px;
		}
		& .tabs, & .steps { margin: 28px 0 0; }
		& .stp, & .stg { padding: 6px 10px; border-bottom: 1px solid var(--hair); }
		& .stp.on, & .stg.on { color: var(--oxblood); border-color: var(--oxblood); }
		& .stp.done, & .stg.past { color: var(--ink); border-color: var(--ink); }
		& .actions2, & .endrow, & .endbtns { margin-top: 28px; }
		& .addrow { display: grid; grid-template-columns: minmax(0, 2fr) repeat(3, minmax(0, 1fr)) auto; gap: 14px; align-items: end; }
		& .results, & .totals { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 180px), 1fr)); gap: 24px; margin-top: 28px; }
		& .card { width: auto; margin: 0; padding: 20px 0 0; border: 0; border-top: 1px solid var(--hair); background: none; color: var(--ink); }
		& .card .k { margin-bottom: 12px; }
		& .card .v, & .totals .big {
			font-family: var(--display); font-weight: 500; font-size: clamp(34px, 4vw, 46px);
			line-height: 1.15; letter-spacing: -.012em; font-variant-numeric: lining-nums tabular-nums;
		}
		& .card.hero { border-color: var(--oxblood); }
		& .card.hero .v { color: var(--oxblood); }
		& .card .s { margin-top: 10px; }
		& #tableWrap { max-width: 100%; min-width: 0; overflow-x: auto; }
		& table { width: 100%; border-collapse: collapse; margin-top: 28px; color: var(--ink); font: inherit; }
		& th { padding: 12px 10px; border-bottom: 1px solid var(--ink); text-align: left; }
		& td { padding: 14px 10px; border-bottom: 1px dotted var(--hair); vertical-align: top; }
		& th.num, & td.num { text-align: right; white-space: nowrap; }
		& td.num, & .lrow .r { font: 400 14px/1.7 var(--mono); font-variant-numeric: tabular-nums; }
		& td .name { font-weight: 500; }
		& .flag { display: inline-block; padding: 3px 0; margin-top: 6px; border-bottom: 1px solid currentColor; }
		& .flag.lo { color: var(--oxblood); }
		& .flag.hi { color: var(--pen); }
		& .flag.ok { color: var(--ink); }
		& .del { background: none; color: var(--pen); border: 0; padding: 8px 12px; min-width: 44px; min-height: 44px; font-size: 22px; }
		& .empty { font-style: italic; text-align: left; padding: 24px 0; }
		& .note, & .ledger { width: 100%; text-align: left; padding: 24px 0; border-top: 1px solid var(--ink); border-bottom: 1px solid var(--hair); background: none; color: var(--ink); }
		& .head { border-bottom: 1px solid var(--hair); padding-bottom: 18px; margin-bottom: 20px; }
		& .head .t, & .head .title { font-family: var(--display); font-size: 30px; font-weight: 500; letter-spacing: -.012em; }
		& .head .s, & .head .sub { margin: 8px 0 0; }
		& .note p { font-size: inherit; line-height: 1.6; }
		& .note b { display: block; margin-bottom: 6px; }
		& .stamp, & .credit, & footer { margin-top: 28px; text-align: center; }
		& .copied { color: var(--oxblood); margin: 16px 0 0; min-height: 22px; }
	}

	&[data-app='the-pass'] #main, &[data-app='the-triage'] #main {
		& .panel { display: none; }
		& .panel.on { display: block; }
	}
	&[data-app='the-pass'] #main {
		& table { min-width: 780px; }
	}
	&[data-app='the-grid'] #main {
		max-width: 760px;
		& .q { margin-bottom: 28px; }
		& .panel .nav { width: 100%; display: flex; flex-wrap: wrap; justify-content: space-between; gap: 12px; padding: 0; margin: 28px 0 0; }
		& .hiddenx { display: none; }
	}
	&[data-app='the-triage'] #main {
		& .describe { border-bottom: 1px solid var(--hair); padding-bottom: 24px; margin-bottom: 28px; }
		& .describe-actions { display: flex; flex-wrap: wrap; align-items: baseline; gap: 18px; margin-top: 16px; }
		& .describe-note { flex: 1; min-width: min(100%, 220px); }
		& .describe-note.err { color: var(--pen); font-style: normal; }
		& .describe-hp { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }
		& .addrow.triage { grid-template-columns: repeat(3, minmax(0, 1fr)); }
		& .name-col { grid-column: 1 / -1; }
		& table { min-width: 860px; }
		& th:first-child { width: 44%; }
		& .verdict { display: inline-block; text-transform: uppercase; padding: 4px 0; margin-top: 8px; border-bottom: 1px solid currentColor; }
		& .v-first, & .v-second { color: var(--oxblood); }
		& .v-second { border-bottom-style: dashed; }
		& .v-inputs, & .v-assist, & .v-small { color: var(--ink); }
		& .v-small { border-bottom-style: dotted; }
		& .v-protect { color: var(--oxblood); }
		& .why { margin-top: 8px; }
		& .legend { margin-top: 24px; color: var(--ink); }
		& .close-note { border-top: 1px solid var(--hair); padding-top: 24px; margin-top: 32px; }
	}
	&[data-app='no-labels'] #main, &[data-app='the-oracle'] #main {
		max-width: 680px;
		text-align: center;
		& .actions, & .endbtns, & .stages { justify-content: center; }
		& .opts, & .choices { display: flex; flex-direction: column; align-items: center; gap: 12px; }
		& .opt, & .choice { width: min(100%, 480px); }
		& .ledger { max-width: 520px; margin: 24px auto 0; }
		& .ledger .head { text-align: center; }
		& .row { display: flex; gap: 20px; margin-bottom: 16px; }
		& .row .k { flex: 0 0 88px; padding-top: 4px; }
		& .row .v { flex: 1; min-width: 0; }
		& .row .big { font-weight: 500; }
		& .stamp { text-align: center; }
	}
	&[data-app='no-labels'] #main {
		& .hud { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 12px; margin-bottom: 28px; }
		& .hud .save { color: var(--oxblood); }
		& .glassno { margin-bottom: 12px; }
		& .stages { gap: 8px; margin: 20px 0 12px; }
		& .points { margin-bottom: 20px; }
		& .clues { min-height: 130px; display: flex; flex-direction: column; gap: 16px; margin-bottom: 28px; }
		& .clue { font-style: italic; line-height: 1.6; }
		& .clue b { margin-right: 10px; color: var(--oxblood); }
		& .actions { margin-bottom: 28px; }
		& .ghost:disabled { color: var(--soft); border-style: dotted; }
		& .choice.correct { border-color: var(--oxblood); color: var(--oxblood); }
		& .choice.wrong { border-color: var(--pen); color: var(--pen); }
		& .reveal { margin-top: 28px; }
		& .res { margin-bottom: 12px; }
		& .res.save { color: var(--oxblood); }
		& .res.goal { color: var(--pen); }
		& .wine { font-size: 32px; margin-bottom: 16px; }
		& .tell { max-width: 48ch; margin: 0 auto 28px; }
		& .lrow { display: flex; justify-content: space-between; align-items: baseline; gap: 16px; padding: 10px 0; border-bottom: 1px dotted var(--hair); }
		& .totals { display: block; margin-top: 20px; }
		& .rank { border-top: 1px solid var(--hair); margin-top: 20px; padding-top: 20px; font-style: italic; text-align: center; }
		& .hidden { display: none; }
	}
	&[data-app='the-oracle'] {
		& .glow { background: none; pointer-events: none; }
		& #main {
			position: relative;
			& .screen { transition: opacity .25s ease; }
			/* Keep the original hidden-screen positioning and pointer state. */
			& .screen.hidden { opacity: 0; visibility: hidden; pointer-events: none; position: absolute; inset: 0; }
			& .qnum { margin-bottom: 20px; }
			& .question { font-size: clamp(30px, 4vw, 42px); margin-bottom: 28px; }
			& .dots { display: flex; gap: 10px; justify-content: center; margin-top: 32px; }
			& .dot { width: 8px; height: 8px; background: var(--hair); }
			& .dot.lit { background: var(--oxblood); }
			& .ledger-wrap { display: flex; justify-content: center; }
			& .verdict { font-family: var(--serif); font-size: inherit; font-style: italic; letter-spacing: normal; color: var(--ink); border-top: 1px solid var(--hair); margin-top: 20px; padding-top: 20px; }
			& .again { margin-top: 28px; }
		}
	}
}
@media (max-width: 800px) {
	body.operator-app {
		font-size: 18px;
		& #main { padding: 40px 0 56px; }
		& #main .addrow, &[data-app='the-triage'] #main .addrow.triage { grid-template-columns: repeat(2, minmax(0, 1fr)); }
		& #main .addrow .name-col { grid-column: 1 / -1; }
		& #main .results, & #main .totals { gap: 20px; }
		&[data-app='no-labels'] #main .totals { display: block; }
	}
}
@media (prefers-reduced-motion: reduce) {
	body.operator-app #main .screen { transition: none; }
}
