/* Viewer-specific styles. The shared look (colours, bar, buttons, fields, television frame, dialogs) is in ui.css. */
:root {
  /* the page and its controls share one width: as wide as fits, never taller than the window */
  --tvw: min(calc(100vw - 24px), 920px, calc((100vh - 270px) * 1.3333));
}
@supports (height: 100dvh) { :root { --tvw: min(calc(100vw - 24px), 920px, calc((100dvh - 270px) * 1.3333)); } }
main { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 12px; padding: 16px 12px 24px; }
main > * { width: var(--tvw); }

/* the CRT effect */
.crt { position: absolute; inset: 0; pointer-events: none; opacity: 0; transition: opacity .2s; }
body.crt-on .crt { opacity: 1; }
body.crt-on .screen { border-radius: 4% / 5%; }
body.crt-on .screen canvas { filter: saturate(1.15) contrast(1.05) drop-shadow(0 0 2px rgba(190, 230, 255, .45)); }
.crt::before { content: ""; position: absolute; inset: 0; background: repeating-linear-gradient(to bottom, rgba(0,0,0,.28) 0, rgba(0,0,0,.28) 1px, transparent 1px, transparent 3px); mix-blend-mode: multiply; }
.crt::after { content: ""; position: absolute; inset: 0; background: radial-gradient(ellipse at center, transparent 55%, rgba(0,0,0,.55) 100%), linear-gradient(rgba(255,255,255,.05), transparent 25%); }
@media (prefers-reduced-motion: no-preference) { body.crt-on .crt { animation: flicker 5s infinite steps(1); } }
@keyframes flicker { 0%, 100% { filter: none; } 47% { filter: brightness(1.04); } 48% { filter: brightness(.97); } 49% { filter: none; } }

/* typed digits, shown like a television's on-screen display */
#osd { position: absolute; left: 2.2%; top: 2%; padding: 2px 8px; font: 700 clamp(14px, 3.2vw, 26px)/1.2 "Bedstead", monospace; letter-spacing: .12em; color: #7dff8f; background: #000; border-radius: 3px; display: none; }
#osd.on { display: block; }

/* coloured keys */
.keys { display: flex; gap: 6px; }
.keys button { flex: 1; min-width: 0; border: 0; border-radius: 4px; padding: 9px 4px 8px; font: 700 12px/1.1 ui-monospace, Menlo, Consolas, monospace; color: #000; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; box-shadow: inset 0 -3px 0 rgba(0,0,0,.25); }
.keys button:disabled { opacity: .24; box-shadow: none; }
.keys .red { background: #ff4a4a; } .keys .green { background: #3fe05a; } .keys .yellow { background: #f2e93a; } .keys .cyan { background: #3ee6e6; }
.keys button:hover:not(:disabled) { filter: brightness(1.12); }
.keys button.index { flex: .65; background: #e4e6ea; }

#subbar { display: flex; align-items: center; justify-content: center; gap: 10px; color: #b4bac4; }
#subbar .dots { display: flex; gap: 5px; } #subbar .dots i { width: 8px; height: 8px; border-radius: 50%; background: #3a3f48; display: block; } #subbar .dots i.on { background: var(--accent); }
#subCount { min-width: 3ch; text-align: center; font-variant-numeric: tabular-nums; }

.nav { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.nav button { min-width: 84px; }
#entry { flex: 1; text-align: center; font: 700 22px/1.2 ui-monospace, Menlo, Consolas, monospace; letter-spacing: .28em; color: #e9edf3; min-height: 1.2em; }

#pad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; max-width: 360px; }
#pad button { padding: 14px 0; font-size: 20px; font-weight: 600; }
.hint { margin: 0; text-align: center; color: var(--dim); font-size: 13px; }
@media (pointer: coarse) { .hint { display: none; } .keys button { padding: 12px 4px; } }

/* report dialog */
#rmsg { min-height: 1.3em; margin: 8px 0 0; } #rmsg.err { color: #ff8a8a; } #rmsg.ok { color: #8fe0a0; }

@media (max-width: 520px) { .bar { padding: 8px 10px; } .tools button { padding: 5px 9px; } .nav button { min-width: 70px; } }
