:root { --bg: #05080a; --panel: #0d1418; --line: #1f2c33; --fg: #c8d6dc; --dim: #7d8f97; --green: #3ddc84; --accent: #4fc3f7; }
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--fg); font: 14px/1.4 system-ui, -apple-system, "Segoe UI", sans-serif; }
button { font: inherit; color: var(--fg); background: var(--panel); border: 1px solid var(--line); border-radius: 4px; padding: 3px 10px; cursor: pointer; }
button:hover { border-color: var(--accent); }
button:active { background: #18262d; }
button:disabled { color: var(--dim); cursor: default; }
button:disabled:hover { border-color: var(--line); }
kbd { font: 12px ui-monospace, monospace; border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 3px; padding: 0 4px; }

#loader { position: fixed; inset: 0; display: grid; place-items: center; }
/* display: grid above beats the [hidden] attribute, so the hidden loader stayed under #app and showed through */
#loader[hidden] { display: none; }
.loader-box { width: min(520px, 90vw); text-align: center; }
.loader-box h1 { font: 600 34px ui-monospace, "SFMono-Regular", Menlo, monospace; color: var(--green); margin: 0 0 4px; letter-spacing: 2px; }
.loader-box .sub { color: var(--dim); margin: 0 0 22px; }
.bar { height: 6px; background: var(--panel); border: 1px solid var(--line); border-radius: 3px; overflow: hidden; }
#loader-bar { height: 100%; width: 0; background: var(--green); transition: width .2s; }
#loader-bar.indeterminate { width: 30%; animation: slide 1.2s ease-in-out infinite; }
@keyframes slide { 0% { margin-left: -30%; } 100% { margin-left: 100%; } }
#loader-text { color: var(--dim); font-family: ui-monospace, monospace; font-size: 13px; }

#app { position: fixed; inset: 0; display: flex; flex-direction: column; background: var(--bg); }
#app[hidden] { display: none; }
header { display: flex; align-items: center; gap: 12px; padding: 4px 8px; background: var(--panel); border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.brand { font: 600 15px ui-monospace, monospace; color: var(--green); letter-spacing: 1px; }
#tabs { display: flex; gap: 4px; }
.tab { border-radius: 4px 4px 0 0; border-bottom: 2px solid transparent; padding: 4px 14px; }
.tab.active { border-color: var(--line); border-bottom: 2px solid var(--green); color: #fff; background: #000; }
.tab.add { padding: 4px 9px; color: var(--dim); }
/* a tab under the mouse only lightens its text (the generic button hover border looked like a focus ring
   on the TSO tab after Shut down); the keyboard focus ring is shown only for keyboard focus */
.tab:hover { border-color: var(--line); border-bottom-color: transparent; color: #fff; }
.tab.active:hover { border-bottom-color: var(--green); }
button:focus { outline: none; }
button:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
/* the status text wraps (at most 2 lines) instead of being cut off; on a narrow window it takes its own row */
#ipl-status { flex: 1 1 260px; color: var(--dim); font: 12px/1.3 ui-monospace, monospace; min-width: 0; overflow: hidden;
  display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; line-clamp: 2; overflow-wrap: anywhere; }
#save-status { font: 600 12px ui-monospace, monospace; white-space: nowrap; padding: 1px 8px; border-radius: 10px; border: 1px solid var(--line); }
#save-status[hidden] { display: none; }
#save-status.saving { color: #000; background: #f5c542; border-color: #f5c542; }
#save-status.saved { color: var(--green); }
#dasd-status { color: var(--dim); font: 12px ui-monospace, monospace; white-space: nowrap; margin: 0 8px; }
#dasd-status[hidden] { display: none; }
.tools { display: flex; gap: 4px; }
.tool { padding: 2px 8px; font-size: 12px; }
#kbd-btn { display: none; }
@media (pointer: coarse) { #kbd-btn { display: inline-block; } }

#views { flex: 1; min-height: 0; position: relative; background: #000; }
.view { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; overflow: hidden; }
.view[hidden] { display: none; }
canvas.screen { display: block; image-rendering: pixelated; image-rendering: crisp-edges; touch-action: manipulation; }
.placeholder { position: absolute; inset: 0; display: grid; place-items: center; color: var(--dim); font: 14px ui-monospace, monospace; padding: 20px; text-align: center; background: #000; }
.placeholder[hidden] { display: none; }
.latelog { color: var(--green); font: 13px/1.35 ui-monospace, monospace; text-align: left; margin: 0; white-space: pre; }

#hint { padding: 5px 10px; font-size: 13px; color: var(--dim); background: var(--panel); border-top: 1px solid var(--line); }
#hint b { color: var(--fg); }
#hint .notice { color: #f5c542; font-weight: 600; }
#keypad { padding: 6px; background: var(--panel); border-top: 1px solid var(--line); display: flex; flex-direction: column; gap: 4px; }
#keypad[hidden] { display: none; }
.padrow { display: flex; flex-wrap: wrap; gap: 4px; }
.padrow button { flex: 1 0 auto; min-width: 48px; padding: 8px 4px; font: 12px ui-monospace, monospace; touch-action: manipulation; }
.padrow button.wide { min-width: 90px; color: var(--green); }
.padrow.pf button { min-width: 40px; padding: 6px 2px; }

#debug { height: 30vh; display: flex; flex-direction: column; border-top: 2px solid #a33; background: #0a0a0a; }
#debug[hidden] { display: none; }
#dbgstat { padding: 2px 8px; border-bottom: 1px solid var(--line); font: 11px ui-monospace, monospace; color: #fd8; white-space: pre; overflow: hidden; }
#herclog { flex: 1; margin: 0; overflow: auto; padding: 4px 8px; font: 11px/1.3 ui-monospace, monospace; color: #9fb; white-space: pre-wrap; }
#hcmd-form { padding: 4px 8px; border-top: 1px solid var(--line); font: 12px ui-monospace, monospace; color: #e88; }
#hcmd { width: 70%; background: #000; color: #fff; border: 1px solid var(--line); font: inherit; padding: 2px 4px; }

/* focusable (not display:none), 16px so iOS does not zoom on focus, at the top so focus does not scroll */
#kbd-capture { position: fixed; left: 0; top: 0; width: 2em; height: 1.5em; font-size: 16px; opacity: 0; border: 0; padding: 0; margin: 0; resize: none; pointer-events: none; caret-color: transparent; color: transparent; background: transparent; z-index: -1; }

dialog#about { max-width: min(640px, 94vw); background: var(--panel); color: var(--fg); border: 1px solid var(--line); border-radius: 8px; padding: 18px 22px; }
dialog#about::backdrop { background: rgba(0,0,0,.6); }
dialog h2 { margin: 0 0 8px; color: var(--green); font-family: ui-monospace, monospace; }
dialog h3 { margin: 14px 0 4px; font-size: 14px; }
dialog a { color: var(--accent); }
.keys { border-collapse: collapse; font-size: 12px; }
.keys td { padding: 2px 8px 2px 0; }
.keys td:nth-child(odd) { color: var(--dim); font-family: ui-monospace, monospace; }
.credits { padding-left: 18px; font-size: 13px; }
.actions { display: flex; justify-content: space-between; margin-top: 16px; }

/* console history pane (over the terminal views) */
#history { position: absolute; inset: 0; z-index: 5; display: flex; flex-direction: column; background: rgba(0, 0, 0, 0.94); }
#history[hidden] { display: none; }
#history .history-head { padding: 4px 10px; font-size: 13px; color: var(--dim); background: var(--panel); border-bottom: 1px solid var(--line); display: flex; gap: 10px; align-items: center; }
#history .history-head b { color: var(--fg); }
#history .history-head button { margin-left: auto; }
#history-text { flex: 1; margin: 0; padding: 8px 12px; overflow: auto; color: var(--green, #4f4); font: 13px/1.35 ui-monospace, monospace; white-space: pre; }
.attrib { flex: none; margin: 0; padding: 3px 10px; color: var(--dim); font-size: 12px; text-align: center; }
.attrib a { color: inherit; }
.loader-box .attrib { padding: 18px 0 0; }
/* /embed (the X player card): terminal only. bundle-hash.py adds class "embed" to <html> in embed.html. */
#open-full, #loader-open { display: none; }
.embed #open-full { display: inline-block; text-decoration: none; color: var(--fg); white-space: nowrap; }
.embed #loader-open { display: block; }
.embed .tools > :not(#open-full):not(#keys-btn), .embed #dasd-status, .embed #save-status, .embed #hint, .embed #add-tso { display: none !important; }
.embed header { gap: 8px; padding: 2px 6px; flex-wrap: nowrap; }
.embed #ipl-status { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 12px; }
.embed .attrib { font-size: 11px; padding: 2px 6px; }
#loader-open.big a { display: inline-block; margin-top: 8px; padding: 12px 22px; font-size: 18px; border-radius: 8px; background: var(--accent); color: #000; text-decoration: none; font-weight: 600; }
