:root {
	color-scheme: light;
	--ink: #172321;
	--muted: #71807b;
	--line: #dce3de;
	--paper: #f3f5f1;
	--panel: #fffefa;
	--forest: #142521;
	--mint: #b9e76a;
	--coral: #f2765c;
	--mono: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
}

* { box-sizing: border-box; }

body {
	margin: 0;
	background-color: var(--paper);
	background-image: radial-gradient(#cfd7d0 0.7px, transparent 0.7px);
	background-size: 18px 18px;
	color: var(--ink);
	font-family: "Trebuchet MS", "Segoe UI", sans-serif;
	min-width: 320px;
}

button, textarea { font: inherit; }

.topbar {
	height: 62px;
	padding: 0 6.4%;
	background: var(--forest);
	color: #f6f7ef;
	display: flex;
	align-items: center;
	justify-content: space-between;
}

.brand { display: inline-flex; align-items: center; gap: 11px; color: inherit; text-decoration: none; font-size: 11px; letter-spacing: 1.1px; }
.brand b { color: var(--mint); font-weight: 700; }
.brand-mark { font: 700 19px var(--mono); letter-spacing: 0; color: var(--mint); }
.brand-mark span { color: var(--coral); }
.topbar-meta { display: flex; align-items: center; gap: 8px; color: #b6c2bc; font: 10px var(--mono); letter-spacing: .5px; }
.live-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--mint); box-shadow: 0 0 0 3px #b9e76a20; }
.version { margin-left: 10px; color: #778681; }

.workspace { width: min(1200px, 87.2%); margin: 0 auto; }
.intro { display: flex; justify-content: space-between; align-items: end; gap: 26px; padding: 54px 0 28px; }
.eyebrow { margin: 0 0 11px; color: #568459; font: 10px var(--mono); letter-spacing: 1.5px; }
h1 { margin: 0; font-size: clamp(27px, 3.3vw, 40px); line-height: 1.15; font-weight: 700; letter-spacing: 0; }
h1 em { color: #568459; font-family: Georgia, serif; font-weight: 400; }
.intro-copy { margin: 10px 0 0; color: var(--muted); font-size: 13px; }
.supported-types { display: flex; flex-wrap: wrap; align-items: center; justify-content: end; gap: 7px; max-width: 370px; padding-bottom: 3px; }
.supported-types span { width: 100%; text-align: right; margin-bottom: 3px; color: var(--muted); font: 9px var(--mono); letter-spacing: 1px; }
.supported-types b { padding: 6px 9px; border: 1px solid #cfd8cd; color: #43564a; background: #fafbf6; font: 11px var(--mono); font-weight: 500; }

.workbench { display: grid; grid-template-columns: minmax(0, 1.12fr) 180px minmax(0, .88fr); align-items: stretch; border: 1px solid #d8dfd9; background: var(--panel); box-shadow: 0 12px 32px #1832280b; min-height: 470px; }
.editor-panel, .results-panel { display: flex; flex-direction: column; min-width: 0; }
.editor-panel { border-right: 1px solid var(--line); }
.panel-heading { min-height: 55px; padding: 0 20px; display: flex; justify-content: space-between; align-items: center; border-bottom: 1px solid var(--line); }
.panel-heading > div { display: flex; align-items: center; gap: 10px; }
.panel-heading h2 { margin: 0; font-size: 13px; }
.file-icon { color: #568459; font: 700 12px var(--mono); }
.file-name { padding-left: 11px; border-left: 1px solid var(--line); color: #8a9690; font: 10px var(--mono); }
.text-button { border: 0; padding: 6px 0 6px 8px; background: transparent; color: #63756b; font-size: 11px; cursor: pointer; }
.text-button:hover { color: #253d31; text-decoration: underline; }
#source-code { flex: 1; width: 100%; min-height: 322px; resize: vertical; border: 0; outline: 0; padding: 24px 22px; background: #fffefa; color: #23352e; font: 13px/1.9 var(--mono); tab-size: 4; }
#source-code:focus-visible { box-shadow: inset 0 0 0 2px #b9e76a; }
.editor-footer { display: flex; justify-content: space-between; gap: 12px; padding: 11px 20px; border-top: 1px solid var(--line); color: #88928b; font: 9px var(--mono); }

.run-column { display: flex; flex-direction: column; justify-content: center; gap: 17px; padding: 22px 15px; background: #f8faf5; border-right: 1px solid var(--line); }
.pipeline { display: flex; justify-content: center; align-items: center; gap: 8px; color: #52645b; font: 9px var(--mono); }
.pipeline span { display: flex; align-items: center; gap: 4px; }
.pipeline i { color: #9aa69d; font-style: normal; }
.pipeline b { color: #bdc8be; font-size: 14px; font-weight: 400; }
.compile-button { display: flex; align-items: center; justify-content: center; gap: 9px; min-height: 44px; border: 0; padding: 0 11px; color: #19291f; background: var(--mint); font-size: 12px; font-weight: 700; cursor: pointer; transition: background .15s ease, transform .15s ease; }
.compile-button:hover { background: #c8f383; transform: translateY(-1px); }
.compile-button:disabled { cursor: wait; opacity: .72; transform: none; }
.play-icon { font-size: 9px; }
.button-shortcut { margin-left: auto; color: #536740; font: 9px var(--mono); }
.run-note { margin: 0 auto; max-width: 145px; color: #89958d; text-align: center; font-size: 10px; line-height: 1.5; }

.results-heading { min-height: 55px; }
.result-mark { color: var(--coral); font: 700 18px var(--mono); }
.status-pill { padding: 5px 7px; font: 9px var(--mono); letter-spacing: .4px; }
.status-pill.idle { background: #edf0ec; color: #78847c; }
.status-pill.success { background: #e7f5d9; color: #43743c; }
.status-pill.error { background: #fff0eb; color: #b64e38; }
.result-content { flex: 1; min-height: 350px; padding: 19px 20px 24px; overflow: auto; }
.empty-state { min-height: 295px; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; }
.empty-glyph { color: #b6c6b2; font: 40px Georgia, serif; }
.empty-state p { margin: 10px 0 5px; color: #45584c; font-size: 12px; }
.empty-state > span:last-child { color: #8a9690; font-size: 10px; }
.summary { display: flex; gap: 7px; margin-bottom: 17px; }
.summary span { flex: 1; padding: 9px 8px; background: #f1f5ed; color: #607167; font: 9px var(--mono); text-align: center; }
.summary b { display: block; margin-bottom: 4px; color: #294232; font-size: 16px; }
.result-section + .result-section { margin-top: 18px; }
.result-section h3 { display: flex; align-items: center; gap: 7px; margin: 0 0 9px; color: #627269; font: 9px var(--mono); letter-spacing: .8px; }
.result-section h3::after { height: 1px; flex: 1; background: #e5e9e3; content: ""; }
.result-section pre { margin: 0; overflow: auto; color: #384b40; font: 10px/1.65 var(--mono); white-space: pre-wrap; overflow-wrap: anywhere; }
.token-list { display: flex; flex-wrap: wrap; gap: 5px; }
.token { padding: 4px 6px; border: 1px solid #e0e6dc; background: #fafbf8; color: #4e6054; font: 9px var(--mono); }
.token b { color: #55804e; font-weight: 500; }
.symbol-table { width: 100%; border-collapse: collapse; text-align: left; font-size: 10px; }
.symbol-table th { padding: 6px 5px; color: #87928a; font: 9px var(--mono); font-weight: 400; }
.symbol-table td { padding: 7px 5px; border-top: 1px solid #edf0eb; color: #3d5145; overflow-wrap: anywhere; }
.symbol-table td:first-child { font-family: var(--mono); font-weight: 700; }
.diagnostic { border-left: 3px solid var(--coral); padding: 12px 13px; background: #fff5f0; color: #a14632; font-size: 12px; line-height: 1.55; }
.diagnostic b { display: block; margin-bottom: 4px; font: 10px var(--mono); text-transform: uppercase; }
.diagnostic small { display: block; margin-top: 6px; color: #9d7267; font: 10px var(--mono); }
.page-footer { display: flex; justify-content: space-between; gap: 20px; padding: 18px 0 30px; color: #829087; font: 9px var(--mono); letter-spacing: .6px; }
.page-footer i { color: var(--coral); font-style: normal; }
.visually-hidden { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }

/* ── Result Tabs ──────────────────────────────────────────────────────── */
.result-tabs { display: flex; border-bottom: 1px solid var(--line); background: #f5f7f3; }
.tab-btn { border: 0; border-bottom: 2px solid transparent; padding: 9px 14px; background: transparent; color: #8a9690; font: 9px var(--mono); letter-spacing: .7px; cursor: pointer; transition: color .15s, border-color .15s; }
.tab-btn:hover { color: #3d5145; }
.tab-btn.active { color: #294232; border-bottom-color: var(--mint); }
.hidden { display: none !important; }

/* ── Pipeline stage state ──────────────────────────────────────────────── */
.stage { display: flex; align-items: center; gap: 4px; padding: 2px 5px; border-radius: 3px; transition: background .2s, color .2s; }
.stage i { color: #9aa69d; font-style: normal; }
.stage-ok    { background: #e7f5d9; color: #3d7434; }
.stage-ok i  { color: #6aaa60; }
.stage-error { background: #fff0eb; color: #b64e38; }
.stage-error i { color: #d9745a; }

/* ── Grammar table ─────────────────────────────────────────────────────── */
.grammar-table { width: 100%; border-collapse: collapse; font: 10px/1.7 var(--mono); }
.grammar-table td { padding: 4px 6px; vertical-align: top; color: #3d5145; border-top: 1px solid #edf0eb; }
.grammar-table td:first-child { white-space: nowrap; }
.grammar-table td:nth-child(2) { color: #9aa69d; padding: 4px 8px; }
.grammar-table code { background: #f0f4ed; border: 1px solid #dce4d9; padding: 1px 4px; font-size: 9px; color: #3d5145; }
.grammar-table .nt { color: #55804e; font-weight: 600; }
.pipe { color: #bdc8be; }
.set-vals { display: flex; flex-wrap: wrap; gap: 4px; }

/* ── Multiple semantic error list ──────────────────────────────────────── */
.error-list { margin: 10px 0 0; padding: 0 0 0 12px; }
.error-list li { margin-bottom: 6px; color: #a14632; font-size: 11px; }
.error-list small { display: block; color: #9d7267; font: 9px var(--mono); margin-top: 2px; }

@media (max-width: 900px) {
	.workspace { width: min(760px, 91%); }
	.intro { align-items: start; flex-direction: column; }
	.supported-types { justify-content: start; }
	.supported-types span { text-align: left; }
	.workbench { grid-template-columns: minmax(0, 1fr) 150px; }
	.run-column { grid-column: 2; grid-row: 1; border-right: 0; border-bottom: 1px solid var(--line); }
	.editor-panel { grid-column: 1; grid-row: 1 / span 2; }
	.results-panel { grid-column: 1 / -1; border-top: 1px solid var(--line); }
	.run-column { justify-content: flex-start; padding-top: 28px; }
}

@media (max-width: 600px) {
	.topbar { height: 54px; padding: 0 5%; }
	.topbar-meta { font-size: 8px; }
	.version { display: none; }
	.workspace { width: 90%; }
	.intro { padding: 35px 0 20px; }
	h1 { max-width: 400px; font-size: 29px; }
	.intro-copy { max-width: 300px; line-height: 1.5; }
	.workbench { display: flex; flex-direction: column; }
	.editor-panel { border-right: 0; }
	#source-code { min-height: 260px; font-size: 12px; padding: 19px 15px; }
	.run-column { order: 1; padding: 15px; border-right: 0; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
	.pipeline { justify-content: center; }
	.compile-button { width: 100%; }
	.run-note { max-width: 260px; }
	.results-panel { order: 2; border-top: 0; }
	.result-content { min-height: 260px; padding: 16px; }
	.empty-state { min-height: 220px; }
	.page-footer { flex-direction: column; gap: 7px; padding-top: 14px; }
}

@media (prefers-reduced-motion: reduce) {
	*, *::before, *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; }
}
