:root {
  --bg: #f5f5f7;
  --panel: #ffffff;
  --panel-2: #ececf0;
  --text: #1d1d1f;
  --muted: #6e6e73;
  --line: #d9d9de;
  --accent: #7a3d8f;
  --accent-text: #ffffff;
  --ok: #248a3d;
  --warn: #b25000;
  --bad: #d70015;
  --stage: #1c1c1e;
  --radius: 14px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #111113; --panel: #1c1c1f; --panel-2: #2a2a2f; --text: #f2f2f7; --muted: #a1a1aa; --line: #34343a;
    --accent: #c58ad8; --accent-text: #1b0d22; --ok: #30d158; --warn: #ff9f0a; --bad: #ff453a; --stage: #000;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #111113; --panel: #1c1c1f; --panel-2: #2a2a2f; --text: #f2f2f7; --muted: #a1a1aa; --line: #34343a;
  --accent: #c58ad8; --accent-text: #1b0d22; --ok: #30d158; --warn: #ff9f0a; --bad: #ff453a; --stage: #000;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--bg); color: var(--text); font: 15px/1.45 system-ui, -apple-system, "Segoe UI", sans-serif; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--accent); }

.shell { display: flex; min-height: 100vh; }
.sidebar { width: 260px; flex: none; background: var(--panel); border-right: 1px solid var(--line); display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; }
.brand { display: flex; align-items: center; gap: 10px; padding: 16px 16px 8px; font-weight: 700; font-size: 18px; }
.logo { display: inline-flex; align-items: center; justify-content: center; width: 32px; height: 32px; border-radius: 8px; color: #fff; font-weight: 700;
  background: linear-gradient(135deg, #29144d, #6b2a7a); }
.logo b { color: #fa9e6b; }
#nav { flex: 1; overflow-y: auto; padding: 4px 8px 12px; }
.nav-group { margin-top: 12px; }
.nav-group h3 { margin: 0 8px 4px; font-size: 12px; font-weight: 600; color: var(--muted); text-transform: none; }
.nav-item { display: flex; align-items: center; gap: 10px; width: 100%; padding: 8px 10px; border: 0; border-radius: 9px; background: none; text-align: left; cursor: pointer; }
.nav-item:hover { background: var(--panel-2); }
.nav-item[aria-current="page"] { background: var(--accent); color: var(--accent-text); }
.nav-item .icon { width: 20px; text-align: center; }
.status { margin: 8px; padding: 10px 12px; border-radius: 12px; background: var(--panel-2); font-size: 13px; }
.status .dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; background: var(--ok); margin-right: 6px; }
.status .muted { color: var(--muted); }
.about { margin: 0 16px 12px; font-size: 12px; line-height: 1.4; color: var(--muted); }

.content { flex: 1; min-width: 0; padding: 20px 24px 40px; }
.topbar { display: none; }
h1 { margin: 6px 0 14px; font-size: 28px; }
h2 { font-size: 17px; margin: 18px 0 8px; }

.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-bottom: 14px; }
select, input[type="text"], input[type="url"], input[type="number"], textarea {
  background: var(--panel); border: 1px solid var(--line); border-radius: 9px; padding: 7px 10px; max-width: 100%; }
textarea { width: 100%; resize: vertical; }
.button { display: inline-flex; align-items: center; gap: 6px; padding: 7px 14px; border-radius: 999px; border: 1px solid var(--line); background: var(--panel); cursor: pointer; }
.button:hover { border-color: var(--accent); }
.button.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); font-weight: 600; }
.button.danger { background: var(--bad); border-color: var(--bad); color: #fff; font-weight: 600; }
.button:disabled { opacity: 0.45; cursor: default; }
.icon-button { border: 0; background: none; font-size: 20px; cursor: pointer; padding: 4px 8px; }
.pill { display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: 12px; background: var(--panel-2); color: var(--muted); }
.pill.ok { color: var(--ok); }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.error { color: var(--bad); }

.layout { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 16px; align-items: start; }
.panel { background: var(--panel); border-radius: var(--radius); padding: 14px 16px; }
.stage { position: relative; background: var(--stage); border-radius: var(--radius); overflow: hidden; display: grid; place-items: center; min-height: 320px; }
.stage canvas { display: block; max-width: 100%; max-height: 75vh; }
.credit-tag { position: absolute; left: 8px; bottom: 8px; z-index: 2; max-width: calc(100% - 16px); padding: 3px 8px; border-radius: 999px;
  background: rgba(0, 0, 0, 0.55); color: #fff; font-size: 11px; line-height: 1.4; text-decoration: none; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.credit-tag:hover { background: rgba(0, 0, 0, 0.75); text-decoration: underline; }
.credit-tag[hidden] { display: none; }
.stage .placeholder { color: #aaa; padding: 40px; text-align: center; }
.stage.drop { outline: 3px dashed var(--accent); outline-offset: -8px; }
.big-number { font-size: 64px; font-weight: 800; line-height: 1; }
.list { list-style: none; margin: 0; padding: 0; }
.list li { display: flex; align-items: center; gap: 8px; padding: 6px 0; border-bottom: 1px solid var(--line); }
.list li:last-child { border-bottom: 0; }
.grow { flex: 1; min-width: 0; }
.bar { height: 6px; border-radius: 3px; background: var(--panel-2); overflow: hidden; }
.bar > span { display: block; height: 100%; background: var(--accent); }
table { border-collapse: collapse; width: 100%; }
td, th { text-align: left; padding: 6px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
.model-table td:last-child { text-align: right; white-space: nowrap; }

@media (max-width: 900px) {
  .layout { grid-template-columns: 1fr; }
}
@media (max-width: 720px) {
  .sidebar { position: fixed; z-index: 10; left: 0; top: 0; transform: translateX(-100%); transition: transform 0.2s; box-shadow: 0 0 30px rgba(0,0,0,0.3); }
  .sidebar.open { transform: none; }
  .topbar { display: flex; align-items: center; gap: 8px; margin: -8px 0 6px; font-weight: 600; }
  .content { padding: 12px 16px 32px; }
  h1 { font-size: 24px; }
}
@media (min-width: 721px) { .only-narrow { display: none; } }

/* The welcome page (index.html): shown instead of the apps while <html data-welcome> is set. */
.welcome { display: none; max-width: 680px; margin: 0 auto; padding: 32px max(16px, env(safe-area-inset-right, 0px)) 48px max(16px, env(safe-area-inset-left, 0px)); }
html[data-welcome] .welcome { display: block; }
html[data-welcome] .shell { display: none; }
.welcome-brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 18px; margin-bottom: 28px; }
.welcome h1 { font-size: 30px; line-height: 1.2; margin: 0 0 12px; }
.welcome h2 { font-size: 18px; margin: 28px 0 8px; }
.welcome p, .welcome li { line-height: 1.55; }
.welcome ul { padding-left: 20px; margin: 0; display: grid; gap: 6px; }
.welcome .muted { color: var(--muted); }
.welcome .small { font-size: 13px; }
html[data-edition="space"] .only-site { display: none; }
