/* Standalone TI-85 Emulator page styling (loaded outside PurgeCSS so dynamic states remain intact) */

.ti85-emu-page {
	margin-top: 0.5rem;
}

.ti85-emu-page [hidden] {
	display: none !important;
}

.ti85-emu-page *,
.ti85-emu-page *::before,
.ti85-emu-page *::after {
	box-sizing: border-box;
}

.ti85-emu-breadcrumb {
	margin: 0 0 1rem;
	font-size: 0.9rem;
}

.ti85-emu-intro {
	margin: 0 0 1.25rem;
	font-size: 0.95rem;
	color: color-mix(in srgb, var(--foreground) 88%, transparent);
}

.ti85-btn {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: 0.35rem;
	width: auto;
	max-width: none;
	margin: 0;
	padding: 0.4rem 0.75rem;
	font-size: 0.82rem;
	font-weight: 600;
	line-height: 1.25;
	border: 1px solid var(--accent);
	background: transparent;
	color: var(--accent);
	cursor: pointer;
	text-decoration: none;
}

.ti85-btn:hover {
	background: color-mix(in srgb, var(--accent) 18%, transparent);
}

.ti85-btn-primary {
	background: var(--accent);
	color: var(--background);
}

.ti85-btn-primary:hover {
	background: color-mix(in srgb, var(--accent) 85%, white);
	color: var(--background);
}

.ti85-btn-subtle {
	border-color: color-mix(in srgb, var(--foreground) 35%, transparent);
	color: var(--foreground);
}

.ti85-btn-subtle:hover {
	border-color: var(--accent);
	color: var(--accent);
}

.ti85-btn.is-open {
	border-color: var(--accent);
	color: var(--accent);
	background: color-mix(in srgb, var(--accent) 14%, transparent);
}

.ti85-btn:disabled {
	opacity: 0.45;
	cursor: not-allowed;
}

/* Main two-column workbench (3x 384x192 LCD on desktop, automatic fit on mobile) */
.ti85-workbench {
	display: grid;
	grid-template-columns: 430px minmax(0, 1fr);
	gap: 1.25rem;
	align-items: start;
}

/* Calculator hardware shell (Washington Devices HS-85) */
.ti85-shell {
	background: linear-gradient(175deg, #2b2e37 0%, #1d2027 55%, #16181e 100%);
	border: 2px solid #444956;
	border-radius: 16px 16px 26px 26px;
	padding: 0.85rem 0.625rem 1.05rem;
	box-shadow: 0 12px 28px rgba(0, 0, 0, 0.48), inset 0 1px 0 rgba(255, 255, 255, 0.09);
	user-select: none;
}

.ti85-shell-brand {
	display: flex;
	justify-content: space-between;
	align-items: center;
	gap: 0.45rem;
	padding: 0 0.35rem 0.48rem;
	font-size: 0.72rem;
	letter-spacing: 0.08em;
	text-transform: uppercase;
	color: #b7becb;
}

.ti85-shell-maker {
	min-width: 0;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}

.ti85-shell-brand-right {
	display: inline-flex;
	align-items: center;
	gap: 0.36rem;
	flex: 0 0 auto;
}

.ti85-brand-tag {
	display: inline-flex;
	align-items: center;
	padding: 0.1rem 0.3rem;
	border-radius: 3px;
	border: 1px solid #4d5669;
	background: #181d27;
	color: #c5cedc;
	font-size: 0.6rem;
	font-weight: 700;
	line-height: 1.1;
	letter-spacing: 0.04em;
	text-transform: uppercase;
}

.ti85-brand-tag.is-2nd {
	border-color: #776024;
	background: #292212;
	color: #f0c954;
}

.ti85-brand-tag.is-alpha {
	border-color: #365f87;
	background: #142434;
	color: #7cc4ff;
}

.ti85-brand-tag.is-rom {
	border-color: #4f6382;
	background: #182130;
	color: #a9c7ef;
}

.ti85-shell-model {
	font-weight: 700;
	font-size: 0.9rem;
	line-height: 1;
	color: #eec35e;
	letter-spacing: 0.1em;
}

.ti85-status-glyph {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 1.05rem;
	height: 1.05rem;
	border-radius: 3px;
	background: #12151b;
	border: 1px solid #383f4d;
	color: #848e9e;
	flex: 0 0 auto;
	cursor: help;
}

.ti85-status-glyph svg {
	display: block;
	width: 11px;
	height: 11px;
}

.ti85-status-glyph[data-status="running"] {
	border-color: #2f6140;
	color: #7ee09b;
}

.ti85-status-glyph[data-status="paused"],
.ti85-status-glyph[data-status="menu"] {
	border-color: #6b5626;
	color: #eec35e;
}

.ti85-status-glyph[data-status="input"] {
	border-color: #2c567a;
	color: #7cc4ff;
}

.ti85-status-glyph[data-status="rom"] {
	border-color: #355b84;
	color: #93c6ff;
}

.ti85-status-glyph[data-status="error"] {
	border-color: #7a3434;
	color: #f28b82;
}

.ti85-lcd-bezel {
	background: #101216;
	border: 2px solid #575d6d;
	border-radius: 8px;
	padding: 0.48rem;
	margin-bottom: 0.65rem;
}

/* Strictly locked 2:1 (128x64) TI-85 LCD aspect ratio across all viewports and browsers.
   Desktop renders exact 3x (384x192); mobile auto-fits available width at exact 2:1. */
.ti85-lcd-frame {
	box-sizing: border-box;
	width: 100%;
	max-width: 386px; /* 384px inner screen + 2px border */
	margin: 0 auto;
	border: 1px solid #2b3a2e;
	background: #aecdaf;
}

.ti85-lcd-screen {
	position: relative;
	width: 100%;
	height: 0;
	padding-top: 50%; /* exact 2:1 ratio independent of flex/canvas quirks */
	overflow: hidden;
}

.ti85-lcd-canvas {
	position: absolute;
	inset: 0;
	display: block;
	width: 100%;
	height: 100%;
	background: #aecdaf;
	image-rendering: pixelated;
	image-rendering: crisp-edges;
	cursor: pointer;
}

/* Non-calculator utility controls below keypad */
.ti85-calc-controls {
	display: flex;
	flex-wrap: wrap;
	gap: 0.4rem;
	margin-top: 0.8rem;
	padding-top: 0.65rem;
	border-top: 1px solid #2d323e;
}

.ti85-calc-controls .ti85-btn {
	flex: 1 1 auto;
	font-size: 0.74rem;
	padding: 0.32rem 0.5rem;
}

/* De-emphasized Options drawer (BYO TI-85 ROM + engine toggle) */
.ti85-options-panel {
	margin: 0.6rem 0 0;
	padding: 0.75rem 0.8rem;
	background: #13161d;
	border: 1px solid #3f4656;
	border-radius: 6px;
	user-select: text;
}

.ti85-options-header {
	display: flex;
	justify-content: space-between;
	align-items: center;
	gap: 0.5rem;
	margin-bottom: 0.55rem;
}

.ti85-options-title {
	font-size: 0.76rem;
	font-weight: 700;
	text-transform: uppercase;
	letter-spacing: 0.05em;
	color: #d6deea;
}

.ti85-options-badge {
	font-size: 0.68rem;
	padding: 0.1rem 0.4rem;
	border: 1px solid color-mix(in srgb, var(--accent) 55%, transparent);
	color: var(--accent);
	text-transform: uppercase;
	letter-spacing: 0.04em;
}

.ti85-options-engine-row {
	display: grid;
	grid-template-columns: repeat(2, minmax(0, 1fr));
	gap: 0.4rem;
	margin-bottom: 0.65rem;
}

.ti85-options-engine-row .ti85-btn {
	font-size: 0.74rem;
	padding: 0.34rem 0.45rem;
}

.ti85-options-rom {
	border-top: 1px solid #2a2f3b;
	padding-top: 0.55rem;
	display: flex;
	flex-direction: column;
	gap: 0.45rem;
}

.ti85-options-note {
	margin: 0;
	font-size: 0.74rem;
	line-height: 1.45;
	color: #a9b2c0;
}

.ti85-rom-dropzone {
	border: 1px dashed #4d566a;
	padding: 0.45rem 0.6rem;
	font-size: 0.74rem;
	color: #c2cad6;
	background: #0e1016;
	transition: background 0.15s ease, border-color 0.15s ease;
}

.ti85-rom-dropzone.is-dragover {
	border-color: var(--accent-alt);
	background: color-mix(in srgb, var(--accent-alt) 14%, #0e1016);
}

.ti85-rom-status {
	font-size: 0.72rem;
	line-height: 1.4;
	color: #9ba5b5;
}

.ti85-options-rom-actions {
	display: flex;
	flex-wrap: wrap;
	gap: 0.4rem;
}

.ti85-options-rom-actions .ti85-btn {
	font-size: 0.74rem;
	padding: 0.3rem 0.55rem;
}

/* TI-85 5-column Keypad */
.ti85-keypad {
	display: grid;
	grid-template-columns: repeat(5, minmax(0, 1fr));
	gap: 0.48rem 0.36rem;
}

.ti85-key-wrap {
	display: flex;
	flex-direction: column;
	gap: 0.08rem;
}

.ti85-key-legends {
	display: flex;
	justify-content: space-between;
	align-items: baseline;
	min-height: 0.8rem;
	padding: 0 0.1rem;
	font-size: 0.56rem;
	line-height: 1;
	letter-spacing: 0.01em;
}

.ti85-legend-2nd {
	color: #f0c954;
	font-weight: 600;
}

.ti85-legend-alpha {
	color: #7cc4ff;
	font-weight: 600;
}

.ti85-key {
	width: 100%;
	max-width: none;
	margin: 0;
	padding: 0.36rem 0.15rem;
	font-size: 0.74rem;
	font-weight: 700;
	line-height: 1.1;
	color: #f3f4f6;
	background: #353944;
	border: 1px solid #525868;
	border-bottom: 3px solid #16181d;
	border-radius: 5px;
	cursor: pointer;
	text-align: center;
	transition: transform 0.05s ease, background 0.08s ease;
}

.ti85-key:hover {
	background: #444a58;
}

.ti85-key:active,
.ti85-key.is-pressed {
	transform: translateY(1px);
	border-bottom-width: 1px;
	background: #555c6e;
}

.ti85-key.function {
	background: #232730;
	border-color: #636b7f;
	color: #d6deea;
	border-radius: 4px 4px 8px 8px;
}

.ti85-key.second {
	background: #c89d28;
	border-color: #e4be55;
	color: #16171e;
}

.ti85-key.alpha {
	background: #3871a8;
	border-color: #639fd9;
	color: #f5f9ff;
}

.ti85-key.number {
	background: #505665;
	border-color: #6c7386;
	font-size: 0.84rem;
}

.ti85-key.operator {
	background: #2a313e;
	border-color: #4a556a;
}

.ti85-key.arrow {
	background: #2c3a47;
	border-color: #4b6175;
	color: #cfe6ff;
}

.ti85-key.enter {
	background: #2e4a38;
	border-color: #4d7e5e;
	color: #e4f7ea;
}

.ti85-key.on {
	background: #4e2b2b;
	border-color: #7d4545;
}

/* Right Column: Program Library & Inspector */
.ti85-sidebar {
	display: flex;
	flex-direction: column;
	gap: 1.1rem;
	min-width: 0;
}

.ti85-card {
	border: 1px solid color-mix(in srgb, var(--accent) 45%, transparent);
	background: color-mix(in srgb, var(--background) 80%, #000);
	padding: 0.95rem 1.05rem;
}

.ti85-card h2,
.ti85-card h3 {
	margin: 0 0 0.65rem;
	font-size: 0.95rem;
	border-left: 0;
	border-bottom: 1px dotted color-mix(in srgb, var(--accent) 60%, transparent);
	padding-left: 0;
	padding-bottom: 0.35rem;
	color: var(--accent);
}

.ti85-picker-controls {
	display: flex;
	flex-direction: column;
	gap: 0.55rem;
}

.ti85-picker-controls select,
.ti85-picker-controls input {
	width: 100%;
	max-width: none;
	margin: 0;
	padding: 0.45rem 0.6rem;
	font-size: 0.86rem;
	background: #12141a;
	border: 1px solid color-mix(in srgb, var(--foreground) 35%, transparent);
	color: var(--foreground);
}

.ti85-program-list {
	max-height: 220px;
	overflow-y: auto;
	background: #101218;
	border: 1px solid color-mix(in srgb, var(--foreground) 20%, transparent);
	margin-top: 0.5rem;
}

/* Fully opaque sticky category header so scrolling program names never bleed through */
.ti85-program-group-label {
	padding: 0.32rem 0.55rem;
	font-size: 0.72rem;
	font-weight: 700;
	text-transform: uppercase;
	letter-spacing: 0.06em;
	background: color-mix(in srgb, var(--accent) 16%, #101218);
	border-bottom: 1px solid color-mix(in srgb, var(--accent) 28%, #101218);
	color: var(--accent);
	position: sticky;
	top: 0;
	z-index: 2;
}

.ti85-program-item {
	display: flex;
	justify-content: space-between;
	align-items: baseline;
	gap: 0.5rem;
	width: 100%;
	max-width: none;
	margin: 0;
	padding: 0.38rem 0.6rem;
	border: none;
	border-bottom: 1px solid color-mix(in srgb, var(--foreground) 10%, transparent);
	background: transparent;
	color: var(--foreground);
	text-align: left;
	font-size: 0.82rem;
	font-weight: 400;
	cursor: pointer;
}

.ti85-program-item:hover {
	background: color-mix(in srgb, var(--accent) 14%, transparent);
}

.ti85-program-item.is-selected {
	background: color-mix(in srgb, var(--accent) 22%, transparent);
	color: var(--accent);
	font-weight: 700;
}

.ti85-program-item-file {
	font-size: 0.72rem;
	color: color-mix(in srgb, var(--foreground) 60%, transparent);
	white-space: nowrap;
}

/* Selected program details */
.ti85-detail-meta {
	font-size: 0.82rem;
	color: color-mix(in srgb, var(--foreground) 72%, transparent);
	margin: 0 0 0.6rem;
}

.ti85-detail-body {
	display: flow-root;
	font-size: 0.88rem;
	line-height: 1.5;
}

.ti85-detail-body p {
	margin: 0 0 0.6rem;
}

.ti85-detail-shot {
	float: right;
	margin: 0 0 0.5rem 0.85rem;
	padding: 0;
	border: 1px solid color-mix(in srgb, var(--accent) 45%, transparent);
	max-width: 130px;
	height: auto;
	image-rendering: pixelated;
}

.ti85-detail-note {
	margin: 0.5rem 0 0.65rem;
	padding: 0.45rem 0.65rem;
	font-size: 0.8rem;
	border-left: 3px solid var(--accent-alt);
	background: color-mix(in srgb, var(--accent-alt) 10%, transparent);
}

.ti85-detail-links {
	display: flex;
	flex-wrap: wrap;
	gap: 0.45rem 0.85rem;
	font-size: 0.82rem;
	margin-top: 0.5rem;
}

/* Source tabs */
.ti85-source-tabs {
	display: flex;
	flex-wrap: wrap;
	gap: 0.35rem;
	margin-bottom: 0.5rem;
}

.ti85-source-tab {
	width: auto;
	max-width: none;
	margin: 0;
	padding: 0.25rem 0.55rem;
	font-size: 0.76rem;
	border: 1px solid color-mix(in srgb, var(--foreground) 30%, transparent);
	background: transparent;
	color: var(--foreground);
	cursor: pointer;
}

.ti85-source-tab.is-active {
	border-color: var(--accent);
	background: color-mix(in srgb, var(--accent) 18%, transparent);
	color: var(--accent);
}

.ti85-source-pre {
	margin: 0;
	padding: 0.7rem 0.8rem;
	max-height: 290px;
	overflow: auto;
	font-size: 0.78rem !important;
	line-height: 1.4;
	background: #0f1117 !important;
	border: 1px solid color-mix(in srgb, var(--foreground) 18%, transparent);
}

.ti85-shortcuts {
	font-size: 0.8rem;
	color: color-mix(in srgb, var(--foreground) 78%, transparent);
}

.ti85-shortcuts summary {
	cursor: pointer;
	color: var(--accent);
	font-weight: 600;
}

.ti85-shortcuts ul {
	margin: 0.5rem 0 0 1.2rem;
}

@media (max-width: 820px) {
	.ti85-workbench {
		grid-template-columns: 1fr;
	}

	.ti85-shell {
		max-width: 430px;
		margin: 0 auto;
		width: 100%;
	}
}

@media (max-width: 420px) {
	.ti85-shell {
		padding: 0.65rem 0.4rem 0.9rem;
	}

	.ti85-lcd-bezel {
		padding: 0.4rem;
	}

	.ti85-keypad {
		gap: 0.4rem 0.26rem;
	}

	.ti85-key {
		font-size: 0.68rem;
		padding: 0.34rem 0.1rem;
	}
}

@media (max-width: 360px) {
	.ti85-shell {
		padding: 0.55rem 0.25rem 0.8rem;
		margin: 0 auto;
		width: 100%;
		max-width: none;
	}

	.ti85-lcd-bezel {
		border-width: 1px;
		padding: 0.25rem;
	}

	.ti85-keypad {
		gap: 0.34rem 0.18rem;
	}

	.ti85-key {
		font-size: 0.62rem;
		padding: 0.3rem 0.05rem;
		min-width: 0;
	}

	.ti85-key-legends {
		font-size: 0.5rem;
	}
}

/* Visitor filenames may be longer than the built-in eight-character program names. */
#ti85-program-dropzone {
    margin-bottom: 0.65rem;
}

#ti85-import-status {
    margin-bottom: 0.65rem;
    overflow-wrap: anywhere;
}

.ti85-program-item-file {
    max-width: 50%;
    white-space: normal;
    overflow-wrap: anywhere;
    text-align: right;
}
