:root { color-scheme: dark; --bg: #17191e; --panel: #202329; --ink: #f4f5f7; --muted: #b6bbc7; --border: #393d46; --accent: #c5b5ff; }
:root[data-theme="light"] { color-scheme: light; --bg: #f4f5f8; --panel: #fff; --ink: #17212f; --muted: #586476; --border: #d8dce4; --accent: #6440b8; }
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; font: 14px/1.45 system-ui, sans-serif; letter-spacing: 0; background: var(--bg); color: var(--ink); }
body { display: grid; grid-template-rows: auto minmax(0, 1fr) 28px; height: 100dvh; }
a { color: inherit; text-decoration: none; }
button, a { -webkit-tap-highlight-color: transparent; }
button { font: inherit; cursor: pointer; }
button, .header-actions a { border: 1px solid var(--border); border-radius: 6px; padding: 7px 12px; background: var(--panel); color: var(--ink); min-height: 36px; }
button:hover, .header-actions a:hover { border-color: var(--accent); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
.studio-header { display: flex; align-items: center; gap: 20px; padding: 10px 16px; background: var(--panel); border-bottom: 1px solid var(--border); min-width: 0; }
.brand { font-size: 17px; font-weight: 750; white-space: nowrap; }
.brand span { font-weight: 400; color: var(--muted); }
nav { display: flex; gap: 4px; }
nav a { padding: 7px 14px; border-radius: 6px; color: var(--muted); }
nav a[aria-current="page"] { background: var(--bg); color: var(--accent); box-shadow: inset 0 0 0 1px var(--border); }
.engine-label { color: var(--muted); font-size: 12px; }
.header-actions { margin-left: auto; display: flex; gap: 8px; align-items: center; }
.header-actions .primary { background: #7650d2; border-color: #7650d2; color: #fff; }
.studio-workspace { position: relative; min-width: 0; min-height: 0; overflow: auto; }
iframe { width: 100%; min-width: 1100px; height: 100%; min-height: 600px; border: 0; display: block; background: #262626; }
.load-panel { position: absolute; inset: 0; display: grid; place-items: center; padding: 24px; background: var(--bg); }
[hidden] { display: none !important; }
.load-content { max-width: 500px; text-align: center; }
.load-content h1 { font-size: 24px; margin: 20px 0 8px; }
.load-content p { color: var(--muted); }
#load-progress { width: min(320px, 100%); height: 8px; accent-color: var(--accent); }
#error-details { text-align: left; margin-top: 16px; }
#error-details summary { cursor: pointer; color: var(--accent); }
#error-text { max-height: 160px; overflow: auto; white-space: pre-wrap; overflow-wrap: anywhere; font-size: 12px; padding: 12px; background: var(--panel); border: 1px solid var(--border); }
.loader { width: 30px; height: 30px; margin: auto; border: 3px solid var(--border); border-top-color: var(--accent); border-radius: 50%; animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
#recovery-actions { display: flex; flex-wrap: wrap; gap: 12px; justify-content: center; margin-top: 24px; }
#recovery-actions a { padding: 8px; text-decoration: underline; }
.studio-status { display: flex; justify-content: space-between; gap: 10px; align-items: center; padding: 0 16px; color: var(--muted); font-size: 11px; border-top: 1px solid var(--border); }
dialog { width: min(540px, calc(100vw - 32px)); max-height: calc(100dvh - 40px); overflow: auto; background: var(--panel); color: var(--ink); border: 1px solid var(--border); border-radius: 8px; padding: 24px; }
dialog::backdrop { background: #0009; }
dialog h2 { font-size: 22px; margin-top: 12px; }
dialog p { color: var(--muted); }
dialog form { text-align: right; }
.about-links { display: flex; flex-wrap: wrap; gap: 18px; color: var(--accent); }
.about-links a { text-decoration: underline; }
@media (max-width: 980px) { .engine-label { display: none; } .studio-header { gap: 12px; } }
@media (max-width: 600px) {
  .studio-header { flex-wrap: wrap; padding: 8px; gap: 8px; }
  .brand { margin-right: auto; font-size: 15px; }
  .header-actions { width: 100%; justify-content: flex-end; }
  .header-actions a, .header-actions button { min-height: 40px; }
  .studio-status { padding: 0 8px; font-size: 10px; }
  .studio-status > span:last-child { display: none; }
}
@media (prefers-reduced-motion: reduce) { .loader { animation: none; } }
