/* The Graphite try page, in Graphite's own look: its dark theme tokens (--gr-ground, --gr-surface, --gr-ink, --gr-accent, ...
   from web/tokens/graphite-tokens.css), system-ui for the page and JetBrains Mono for the terminal (self-hosted, so the page stays cross-origin isolated).
   Layout classes are the try pages'. */
@font-face { font-family:"JetBrains Mono"; src:url("fonts/jetbrains-mono.woff2") format("woff2"); font-weight:400; font-style:normal; font-display:swap; }
@font-face { font-family:"JetBrains Mono"; src:url("fonts/jetbrains-mono-semibold.woff2") format("woff2"); font-weight:600 800; font-style:normal; font-display:swap; }
:root {
	color-scheme:dark;
	--bg:#101216; --bg-2:#181b21; --raised:#252a33; --line:#262a32; --line-soft:#262a32; --line-2:#6b7380;
	--ink:#e6e9ee; --ink-2:#a3abb8; --ink-3:#a3abb8;
	--red:#ff7a6b; --orange:#f2b84b; --yellow:#f2b84b; --green:#4cc98a; --blue:#62a8ff; --accent:#62a8ff;
	--radius:8px;
	--mono:"JetBrains Mono", ui-monospace, "SF Mono", Menlo, Consolas, monospace;
	--sans:system-ui, -apple-system, "Segoe UI", sans-serif;
}
* { box-sizing:border-box; }
html, body { margin:0; height:100%; }
body { display:flex; flex-direction:column; background:var(--bg); color:var(--ink); font:14px/1.6 var(--sans); -webkit-font-smoothing:antialiased; overflow:hidden; }
a { color:inherit; text-decoration:none; }
b { font-weight:600; }
.sr { position:absolute; width:1px; height:1px; overflow:hidden; clip:rect(0 0 0 0); }
::selection { background:rgba(98,168,255,.3); }
:focus-visible { outline:2px solid var(--blue); outline-offset:2px; }

/* Header */
header { position:relative; z-index:2; display:flex; align-items:center; gap:16px; padding:12px clamp(14px, 2.4vw, 28px); border-bottom:1px solid var(--line-soft); background:rgba(16,18,22,.8); backdrop-filter:blur(14px); }
.brand { display:inline-flex; align-items:center; gap:10px; font:600 18px/1 var(--sans); letter-spacing:-.01em; }
.brand__mark { width:24px; height:24px; }
.kicker { font-size:12px; font-weight:500; letter-spacing:.12em; text-transform:uppercase; color:var(--ink-2); }
.grow { flex:1; }
#status { color:var(--ink-2); font-size:13px; white-space:nowrap; }
#status::before { content:""; display:inline-block; width:7px; height:7px; border-radius:50%; margin-right:8px; vertical-align:1px; background:var(--blue); }
body[data-state="ready"] #status { color:var(--ink); }
body[data-state="ready"] #status::before { background:var(--green); }
body[data-state="error"] #status { color:var(--red); }
body[data-state="error"] #status::before { background:var(--red); }
.btn { display:inline-flex; align-items:center; justify-content:center; gap:8px; border-radius:var(--radius); padding:9px 18px; border:1px solid transparent;
	font:600 14px var(--mono); white-space:nowrap; cursor:pointer; transition:.16s; }
.btn svg { width:16px; height:16px; }
.btn--light { background:var(--accent); color:#0f171d; }
.btn--light:hover { background:#8bbfff; }

/* One window: the terminal. */
main { position:relative; z-index:1; flex:1; min-height:0; display:grid; grid-template-columns:minmax(0, 1fr); gap:14px; padding:14px clamp(14px, 2.4vw, 28px) 12px; }
body[data-hide] main { grid-template-columns:minmax(0, 1fr) auto; }
.window { position:relative; display:flex; flex-direction:column; min-height:0; border:1px solid var(--line); border-radius:var(--radius); overflow:hidden; background:var(--bg); box-shadow:0 30px 70px -40px rgba(0,0,0,.8); }
.window__bar { display:flex; align-items:center; gap:12px; min-height:40px; padding:6px 12px; border-bottom:1px solid var(--line); background:var(--bg-2); font-size:13px; }
/* Window controls: minimize (the window becomes a chip on the desktop) and maximize (it fills the page). Marks show on hover and keyboard focus. */
.ctl { display:inline-flex; gap:7px; }
.ctl button { position:relative; width:12px; height:12px; padding:0; border:0; border-radius:50%; cursor:pointer; background:var(--line-2); transition:background .15s; }
.ctl button::before { content:""; position:absolute; inset:-6px; }
.ctl button::after { position:absolute; inset:0; display:flex; align-items:center; justify-content:center; font:700 10px/1 var(--mono); color:rgba(16,18,22,.8); opacity:0; }
.ctl__min::after { content:"\2013"; }
.ctl__max::after { content:"\2197"; }
body[data-max] .ctl__max::after { content:"\2199"; }
.window__bar:hover .ctl__min, .ctl__min:focus-visible { background:var(--yellow); }
.window__bar:hover .ctl__max, .ctl__max:focus-visible { background:var(--green); }
.window__bar:hover .ctl button::after, .ctl button:focus-visible::after { opacity:1; }
.fs { display:inline-flex; align-items:center; justify-content:center; width:28px; height:28px; padding:0; border:0; border-radius:6px; background:transparent; color:var(--ink-2); cursor:pointer; }
.fs:hover { color:var(--ink); background:rgba(255,255,255,.06); }
.fs svg { width:15px; height:15px; }
.fs[hidden] { display:none; }
.window__title { font-weight:600; }
.dim { color:var(--ink-3); font-weight:400; font-size:12px; margin-left:6px; }
.window__body { position:relative; flex:1; min-height:0; }

/* A minimized window hides and leaves a chip on the desktop, which brings it back; a maximized one covers the page (and the screen, in full screen). */
body[data-hide="term"] #term-window { display:none; }
#desk { display:flex; flex-direction:column; gap:10px; padding-top:4px; }
#desk[hidden] { display:none; }
.desk__chip { display:flex; flex-direction:column; align-items:center; gap:6px; width:84px; padding:10px 4px 8px; border:1px solid transparent; border-radius:var(--radius); background:transparent;
	color:var(--ink); font:500 12px var(--mono); cursor:pointer; transition:background .15s, border-color .15s; }
.desk__chip[hidden] { display:none; }
.desk__chip:hover { background:rgba(255,255,255,.05); border-color:var(--line-2); }
.desk__chip svg { width:30px; height:30px; color:var(--blue); }
body[data-max="term"] #term-window { position:fixed; inset:0; z-index:8; height:auto; min-height:0; border:0; border-radius:0; }
body[data-max] { overflow:hidden; }
body[data-max] main { z-index:8; }

/* The page terminal paints its own near-black screen and fills its layer with var(--ink): here that is the terminal's colour, not the text colour. */
#term-window .window__body { --ink:#0d0f12; background:#0d0f12; }
#term { position:absolute; inset:0; }
#term .xterm { padding:8px 0 0 10px; height:100%; }
#term .xterm-viewport { background-color:#0d0f12 !important; }

/* Boot screen over the terminal until the sandbox is up */
#boot { position:absolute; inset:0; z-index:3; display:flex; flex-direction:column; align-items:center; justify-content:center; gap:16px; background:var(--bg-2); transition:opacity 320ms ease, visibility 320ms; }
body:not([data-state="boot"]) #boot { opacity:0; visibility:hidden; }
body[data-state="error"] #boot { opacity:1; visibility:visible; }
.boot__word { font:600 34px/1 var(--sans); letter-spacing:-.02em; color:var(--ink); }
.boot__bar { position:relative; width:min(260px, 60%); height:1px; background:var(--line-2); overflow:hidden; }
.boot__bar span { position:absolute; top:0; bottom:0; width:30%; background:var(--blue); animation:sweep 1.4s ease-in-out infinite; }
@keyframes sweep { from { left:-30%; } to { left:100%; } }
@media (prefers-reduced-motion: reduce) { .boot__bar span { animation:none !important; } }
.boot__stage { color:var(--ink-2); font-size:13px; }
body[data-state="error"] .boot__bar span { animation:none; left:0; width:100%; background:var(--red); }
body[data-state="error"] .boot__stage { color:var(--red); }

footer { position:relative; z-index:1; display:flex; justify-content:space-between; align-items:center; gap:16px; padding:8px clamp(14px, 2.4vw, 28px) 12px; color:var(--ink-3); font-size:12px; }
.foot-actions { display:flex; align-items:center; gap:16px; white-space:nowrap; }
footer a { color:var(--ink-2); text-underline-offset:3px; text-decoration:underline; }
footer button { font:600 12px var(--mono); color:var(--ink); background:rgba(16,18,22,.2); border:1px solid var(--line); border-radius:var(--radius); padding:5px 12px; cursor:pointer; }
footer button:hover { border-color:var(--line-2); background:rgba(16,18,22,.35); }

/* Narrow screens: the page scrolls */
@media (max-width: 900px) {
	body { overflow:auto; height:auto; min-height:100%; }
	header { flex-wrap:wrap; gap:10px 14px; }
	.kicker { order:3; width:100%; }
	#status { display:none; }
	main { display:flex; flex-direction:column; }
	#term-window { height:70svh; min-height:380px; }
	footer { flex-direction:column; align-items:flex-start; }
	body[data-hide] #term-window { height:calc(100svh - 210px); }
	#desk { flex-direction:row; padding:0; }
}
/* Touch: bigger targets for the dots, and their marks always shown. */
@media (pointer: coarse) {
	.ctl { gap:12px; }
	.ctl button { width:16px; height:16px; }
	.ctl .ctl__min { background:var(--yellow); } .ctl .ctl__max { background:var(--green); }
	.ctl button::after { opacity:1; font-size:12px; }
}
