/* ShadingLanguageX playground: shared styles for the editor and gallery pages. */
:root {
  --bg: #161b26; --panel: #1c2230; --sunk: #131822; --line: #2b3445; --text: #d8dee9; --muted: #8a94a7;
  --accent: #e3b341; --accent-ink: #1b1608; --err: #f07178; --ok: #8fd694; --errbg: rgba(240,113,120,.14);
  --t-kw: #c792ea; --t-type: #82aaff; --t-fn: #e3b341; --t-num: #f78c6c; --t-str: #c3e88d; --t-com: #66708a; --t-tag: #89ddff; --t-attr: #ffcb6b;
  --sans: "IBM Plex Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
  color-scheme: dark;
}
@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    --bg: #e9edf3; --panel: #f8f9fb; --sunk: #ffffff; --line: #cfd6e1; --text: #1b2230; --muted: #5d687c;
    --accent: #9a6a00; --accent-ink: #fffaf0; --err: #c03a3a; --ok: #2f7d3a; --errbg: rgba(192,58,58,.10);
    --t-kw: #7c3aed; --t-type: #1d5fd1; --t-fn: #8a5a00; --t-num: #b4461d; --t-str: #2f7d3a; --t-com: #8a94a7; --t-tag: #0b6e99; --t-attr: #8a5a00;
    color-scheme: light;
  }
}
:root[data-theme="light"] {
  --bg: #e9edf3; --panel: #f8f9fb; --sunk: #ffffff; --line: #cfd6e1; --text: #1b2230; --muted: #5d687c;
  --accent: #9a6a00; --accent-ink: #fffaf0; --err: #c03a3a; --ok: #2f7d3a; --errbg: rgba(192,58,58,.10);
  --t-kw: #7c3aed; --t-type: #1d5fd1; --t-fn: #8a5a00; --t-num: #b4461d; --t-str: #2f7d3a; --t-com: #8a94a7; --t-tag: #0b6e99; --t-attr: #8a5a00;
  color-scheme: light;
}
:root { box-sizing: border-box; padding-top: env(safe-area-inset-top, 0px); padding-bottom: env(safe-area-inset-bottom, 0px); }
*, *::before, *::after { box-sizing: inherit; }
html, body { height: 100%; margin: 0; }
body { background: var(--bg); color: var(--text); font: 14px/1.45 var(--sans); display: flex; flex-direction: column; }

header { display: flex; align-items: center; gap: 14px; padding: 10px 16px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
header h1 { font-size: 15px; font-weight: 600; margin: 0; letter-spacing: .01em; }
header h1 span { color: var(--muted); font-weight: 400; }
.credit { color: var(--muted); font-size: 13px; }
.credit a { color: var(--accent); }
a.home { color: var(--muted); font-size: 13px; text-decoration: none; }
a.home:hover { color: var(--text); }
.spacer { flex: 1; }
.ctrl { display: flex; align-items: center; gap: 6px; color: var(--muted); font-size: 13px; }
select, button { font: inherit; color: var(--text); background: var(--panel); border: 1px solid var(--line); border-radius: 6px; padding: 5px 10px; cursor: pointer; }
select:hover, button:hover { border-color: var(--muted); }
button.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); font-weight: 600; }
button.primary:hover { filter: brightness(1.08); }
button:disabled { opacity: .45; cursor: default; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
label.check { display: inline-flex; align-items: center; gap: 5px; color: var(--muted); font-size: 13px; cursor: pointer; user-select: none; }
label.check input { accent-color: var(--accent); margin: 0; }
details.opts { position: relative; }
details.opts summary { list-style: none; cursor: pointer; font-size: 13px; color: var(--muted); border: 1px solid var(--line); border-radius: 6px; padding: 5px 10px; background: var(--panel); }
details.opts summary::-webkit-details-marker { display: none; }
details.opts[open] summary { color: var(--text); }
details.opts .menu { position: absolute; right: 0; top: calc(100% + 6px); z-index: 5; background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; display: grid; gap: 8px; min-width: 230px; box-shadow: 0 8px 24px rgba(0,0,0,.25); }

main { flex: 1; min-height: 0; display: grid; grid-template-columns: 1fr 1fr; grid-template-rows: minmax(0,1fr) auto; }
.pane { display: flex; flex-direction: column; min-height: 0; min-width: 0; }
.pane + .pane { border-left: 1px solid var(--line); }
.pane-head { display: flex; align-items: center; gap: 8px; padding: 8px 12px; border-bottom: 1px solid var(--line); background: var(--panel); }
.pane-head h2 { margin: 0; font-size: 13px; font-weight: 600; }
.pane-head .hint { color: var(--muted); font-size: 12px; }
.pane-head button { padding: 3px 9px; font-size: 13px; }

.editor { position: relative; flex: 1; min-height: 0; display: flex; background: var(--sunk); font: 13px/20px var(--mono); }
.gutter { flex: none; width: 46px; overflow: hidden; color: var(--muted); text-align: right; padding: 10px 8px 10px 0; user-select: none; border-right: 1px solid var(--line); }
.gutter div { height: 20px; }
.gutter div.bad { color: var(--err); font-weight: 500; background: var(--errbg); }
.code { position: relative; flex: 1; min-width: 0; }
.code pre, .code textarea { position: absolute; inset: 0; margin: 0; padding: 10px 12px; font: inherit; white-space: pre; overflow: auto; tab-size: 4; border: 0; }
.code pre { pointer-events: none; color: var(--text); }
.code pre .badline { background: var(--errbg); display: inline-block; min-width: 100%; }
.code textarea { background: transparent; color: transparent; caret-color: var(--text); resize: none; outline: none; }
.code textarea::selection { background: rgba(130,170,255,.30); color: transparent; }
.code textarea[readonly] { caret-color: transparent; }
.kw { color: var(--t-kw); } .ty { color: var(--t-type); } .fn { color: var(--t-fn); } .nu { color: var(--t-num); }
.st { color: var(--t-str); } .co { color: var(--t-com); font-style: italic; } .tg { color: var(--t-tag); } .at { color: var(--t-attr); } .pp { color: var(--t-kw); }


.tabs { display: flex; gap: 2px; background: var(--sunk); border: 1px solid var(--line); border-radius: 7px; padding: 2px; }
.tabs button { border: 0; background: transparent; color: var(--muted); padding: 3px 12px; font-size: 13px; font-weight: 500; border-radius: 5px; }
.tabs button[aria-selected="true"] { background: var(--panel); color: var(--text); box-shadow: 0 0 0 1px var(--line); }
.pane.tab-preview .xml-only { display: none; }
.editor[hidden], .view[hidden] { display: none; }
.view { position: relative; flex: 1; min-height: 0; background: #0d1017; overflow: hidden; }
.view canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; cursor: grab; touch-action: none; }
.view canvas:active { cursor: grabbing; }
.pv-msg { position: absolute; inset: 0; display: grid; place-items: center; padding: 24px; text-align: center; color: #aeb7c7; font-size: 13px; pointer-events: none; }
.pv-msg[hidden] { display: none; }
.pv-msg.err { color: #f4a3a8; font: 12px/1.5 var(--mono); white-space: pre-wrap; place-items: center start; text-align: left; overflow: auto; }
.pv-bar { position: absolute; left: 10px; right: 10px; top: 10px; display: flex; flex-wrap: wrap; gap: 8px 12px; align-items: center; }
.pv-bar select, .pv-bar .seg, .pv-bar .check { background: rgba(22,27,38,.78); backdrop-filter: blur(6px); color: #d8dee9; border-color: rgba(255,255,255,.12); }
.pv-bar .check { padding: 4px 9px; border: 1px solid rgba(255,255,255,.12); border-radius: 6px; color: #c3cad6; }
.pv-field { display: inline-flex; align-items: center; gap: 6px; color: #c3cad6; font-size: 13px; background: rgba(22,27,38,.78); border: 1px solid rgba(255,255,255,.12); border-radius: 6px; padding: 0 0 0 9px; }
.pv-field select { border: 0; border-left: 1px solid rgba(255,255,255,.12); border-radius: 0 6px 6px 0; max-width: 220px; }
.seg { display: inline-flex; border: 1px solid; border-radius: 6px; overflow: hidden; }
.seg button { border: 0; border-radius: 0; background: transparent; color: #aeb7c7; padding: 4px 10px; font-size: 13px; }
.seg button + button { border-left: 1px solid rgba(255,255,255,.12); }
.seg button[aria-pressed="true"] { background: rgba(227,179,65,.92); color: #1b1608; font-weight: 600; }
.readout { grid-column: 1 / -1; border-top: 1px solid var(--line); display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr); background: var(--panel); }
.graph { padding: 10px 14px 12px; border-right: 1px solid var(--line); min-width: 0; }
.graph-top { display: flex; align-items: baseline; gap: 16px; flex-wrap: wrap; margin-bottom: 8px; }
.stat b { font: 600 20px/1 var(--sans); font-variant-numeric: tabular-nums; margin-right: 4px; }
.stat { color: var(--muted); font-size: 12px; }
.bar { display: flex; height: 14px; border-radius: 3px; overflow: hidden; background: var(--sunk); border: 1px solid var(--line); }
.bar span { display: block; height: 100%; min-width: 2px; }
.legend { display: flex; flex-wrap: wrap; gap: 4px 12px; margin-top: 8px; font: 12px/1.3 var(--mono); color: var(--muted); }
.legend i { display: inline-block; width: 8px; height: 8px; border-radius: 2px; margin-right: 5px; vertical-align: 0; }
.legend em { font-style: normal; color: var(--text); margin-left: 4px; }
.log { font: 12px/1.5 var(--mono); padding: 8px 12px; overflow: auto; max-height: 150px; min-height: 96px; }
.log div { white-space: pre-wrap; word-break: break-word; }
.log .e { color: var(--err); } .log .o { color: var(--ok); } .log .m { color: var(--muted); } .log .p { color: var(--text); }
.log .p::before { content: "print  "; color: var(--muted); }
.log a { color: inherit; text-decoration: underline dotted; cursor: pointer; }
.empty { color: var(--muted); font-size: 13px; }

#boot { position: fixed; inset: 0; display: grid; place-items: center; background: var(--bg); z-index: 20; text-align: center; padding: 24px; }
#boot p { color: var(--muted); margin: 6px 0 0; max-width: 46ch; }

@media (max-width: 820px) {
  main { grid-template-columns: 1fr; grid-template-rows: 380px 380px auto; }
  .pane + .pane { border-left: 0; border-top: 1px solid var(--line); }
  .readout { grid-template-columns: 1fr; }
  .graph { border-right: 0; border-bottom: 1px solid var(--line); }
  html, body { height: auto; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }

/* ---- projects: header dropdown, name field, view bar ---- */
details.projs { position: relative; }
details.projs summary { list-style: none; cursor: pointer; display: flex; align-items: center; gap: 6px; font-size: 13px; border: 1px solid var(--line); border-radius: 6px; padding: 5px 10px; background: var(--panel); max-width: 260px; }
details.projs summary::-webkit-details-marker { display: none; }
details.projs summary:hover { border-color: var(--muted); }
details.projs summary .lbl { color: var(--muted); }
details.projs summary .cur { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
details.projs summary .chev { color: var(--muted); font-size: 10px; }
.projs .drop { position: absolute; left: 0; top: calc(100% + 6px); z-index: 6; width: 340px; max-width: calc(100vw - 32px); max-height: min(560px, 75vh); display: flex; flex-direction: column; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 12px 32px rgba(0,0,0,.3); overflow: hidden; }
.drop-head { padding: 8px; border-bottom: 1px solid var(--line); }
.drop-head .tabs { display: grid; grid-template-columns: 1fr 1fr; }
.drop-head .tabs button { text-align: center; }
.plist { flex: 1; min-height: 0; overflow: hidden auto; padding: 6px; display: grid; grid-template-columns: minmax(0, 1fr); align-content: start; gap: 2px; }
.plist[hidden] { display: none; }
.pitem { display: grid; min-width: 0; gap: 2px; text-align: left; padding: 8px 10px; border-radius: 7px; border: 1px solid transparent; background: transparent; }
.pitem:hover { background: var(--sunk); border-color: var(--line); }
.pitem[aria-current="true"] { background: var(--sunk); border-color: var(--accent); }
.pitem .nm { font-weight: 600; font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pitem .meta { color: var(--muted); font-size: 12px; display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.badge { font-size: 11px; padding: 0 6px; border-radius: 9px; border: 1px solid var(--line); color: var(--muted); }
.badge.pub { border-color: var(--ok); color: var(--ok); }
.badge.mine { border-color: var(--accent); color: var(--accent); }
.side-empty { color: var(--muted); font-size: 13px; padding: 12px; }
.api { border-top: 1px solid var(--line); padding: 8px 12px 10px; font: 11px/1.5 var(--mono); }
.api[hidden] { display: none; }
.api-top { display: flex; align-items: center; gap: 6px; font: 600 12px var(--sans); margin-bottom: 4px; }
.api-top .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--accent); }
.api-top button { margin-left: auto; padding: 1px 8px; font-size: 12px; }
.api-log { max-height: 120px; overflow: auto; color: var(--muted); }
.api-log .s2 { color: var(--ok); } .api-log .s4 { color: var(--err); }
.api-badge { font-size: 11px; padding: 1px 7px; border-radius: 9px; border: 1px solid var(--accent); color: var(--accent); }
.api-badge[hidden] { display: none; }
.proj-name { font: 600 13px var(--sans); color: var(--text); background: transparent; border: 1px solid transparent; border-radius: 5px; padding: 3px 6px; min-width: 0; width: 15ch; flex: 0 1 auto; }
.proj-name:hover:not([readonly]), .proj-name:focus { border-color: var(--line); background: var(--sunk); outline: none; }
.viewbar { display: flex; align-items: center; gap: 8px; padding: 6px 12px; background: rgba(130,170,255,.12); border-bottom: 1px solid var(--line); font-size: 13px; }
.viewbar[hidden] { display: none; }
.viewbar button { padding: 2px 9px; font-size: 13px; }
a.navlink { color: var(--muted); font-size: 13px; text-decoration: none; border: 1px solid var(--line); border-radius: 6px; padding: 5px 10px; background: var(--panel); }
a.navlink:hover { color: var(--text); border-color: var(--muted); }
a.navlink[aria-current="page"] { color: var(--text); border-color: var(--accent); }

/* ---- dialogs and toast ---- */
dialog { background: var(--panel); color: var(--text); border: 1px solid var(--line); border-radius: 10px; padding: 18px; width: min(420px, calc(100vw - 32px)); }
dialog::backdrop { background: rgba(0,0,0,.45); }
dialog h3 { margin: 0 0 6px; font-size: 15px; }
dialog p { margin: 0 0 12px; color: var(--muted); font-size: 13px; }
dialog label { display: grid; gap: 4px; font-size: 13px; color: var(--muted); margin-bottom: 10px; }
dialog input { font: inherit; color: var(--text); background: var(--sunk); border: 1px solid var(--line); border-radius: 6px; padding: 6px 8px; }
dialog .row { display: flex; justify-content: flex-end; gap: 8px; margin-top: 6px; }
dialog .err { color: var(--err); font: 12px/1.4 var(--mono); white-space: pre-wrap; margin-bottom: 8px; }
.toast { position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 8px 14px; font-size: 13px; box-shadow: 0 8px 24px rgba(0,0,0,.3); z-index: 30; max-width: calc(100vw - 32px); }
.toast[hidden] { display: none; }
.toast.e { border-color: var(--err); color: var(--err); }

@media (max-width: 820px) {
  .projs .drop { position: fixed; left: 16px; right: 16px; top: 56px; width: auto; }
}

@media (max-width: 1180px) { header .credit { display: none; } }

button.primary.danger { background: var(--err); border-color: var(--err); color: #fff; }

/* ---- images panel ---- */
dialog.wide { width: min(560px, calc(100vw - 32px)); }
dialog code { font: 12px var(--mono); background: var(--sunk); padding: 1px 4px; border-radius: 4px; }
.img-bar { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.img-list { list-style: none; margin: 0 0 10px; padding: 0; display: grid; gap: 6px; max-height: 50vh; overflow: auto; }
.img-row { display: grid; grid-template-columns: 48px minmax(0, 1fr) auto auto; gap: 10px; align-items: center; padding: 6px; border: 1px solid var(--line); border-radius: 8px; background: var(--sunk); }
.img-row img { width: 48px; height: 48px; object-fit: cover; border-radius: 5px; background: #0d1017; }
.img-name { font: 500 13px var(--mono); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.img-meta { color: var(--muted); font-size: 12px; }
.img-meta .ok { color: var(--ok); }
.img-row button { padding: 3px 9px; font-size: 12px; }
.img-empty { color: var(--muted); font-size: 13px; padding: 10px 2px; }
.img-missing { color: var(--accent); font-size: 13px; }
#dlg-images .err { white-space: pre-wrap; }
.editor.drop, dialog.drop { outline: 2px dashed var(--accent); outline-offset: -4px; }

/* Screen mode: nothing to orbit, so Environment and Spin do not apply */
.view.screen-mode canvas { cursor: default; }
.view.screen-mode .pv-bar .check:has(input:disabled) { opacity: .45; }

.log .busy { color: var(--accent); }
