:root {
  --bg: #070a14;
  --bg-2: #0b1020;
  --panel: rgba(13, 18, 36, 0.86);
  --panel-2: rgba(18, 25, 48, 0.9);
  --line: rgba(79, 216, 255, 0.14);
  --line-2: rgba(255, 255, 255, 0.08);
  --ink: #e9fbff;
  --muted: #8f9bb8;
  --cyan: #4fd8ff;
  --gold: #f2c46b;
  --green: #3ddc84;
  --red: #ff5d6c;
  --purple: #a970ff;
  --mono: "JetBrains Mono", ui-monospace, Menlo, monospace;
  --sans: "Cairo", system-ui, -apple-system, "Segoe UI", sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--ink); font-family: var(--sans); font-size: 14px; }
a { color: var(--cyan); text-decoration: none; }
#bg-grid {
  position: fixed; inset: 0; z-index: 0; pointer-events: none;
  background-image: linear-gradient(rgba(79, 216, 255, 0.045) 1px, transparent 1px), linear-gradient(90deg, rgba(79, 216, 255, 0.045) 1px, transparent 1px);
  background-size: 36px 36px;
  mask-image: radial-gradient(ellipse at 30% 0%, #000 0%, transparent 70%);
  animation: drift 40s linear infinite;
}
@keyframes drift { from { background-position: 0 0, 0 0; } to { background-position: 0 36px, 36px 0; } }
#app { position: relative; z-index: 1; display: grid; grid-template-columns: 232px 1fr; min-height: 100vh; }
#sidebar { position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; padding: 18px 14px; border-right: 1px solid var(--line); background: linear-gradient(180deg, rgba(11, 16, 32, 0.95), rgba(7, 10, 20, 0.95)); }
.brand { display: flex; gap: 10px; align-items: center; padding: 6px 8px 18px; }
.brand-mark { width: 36px; height: 36px; border-radius: 9px; display: grid; place-items: center; font-weight: 700; color: #061018; background: linear-gradient(135deg, var(--cyan), #2d7dff); box-shadow: 0 0 22px rgba(79, 216, 255, 0.45); }
.brand-name { font-weight: 700; letter-spacing: 0.22em; font-size: 13px; }
.brand-sub { color: var(--muted); font-size: 11px; }
#nav { display: flex; flex-direction: column; gap: 2px; }
#nav a { display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: 8px; color: var(--muted); border: 1px solid transparent; transition: all .15s; }
#nav a .ico { width: 18px; text-align: center; color: var(--cyan); opacity: .7; font-family: var(--mono); }
#nav a:hover { color: var(--ink); background: rgba(79, 216, 255, 0.06); }
#nav a.active { color: var(--ink); background: rgba(79, 216, 255, 0.1); border-color: var(--line); box-shadow: inset 2px 0 0 var(--cyan); }
.side-foot { margin-top: auto; padding: 10px 8px; border-top: 1px solid var(--line-2); display: flex; flex-direction: column; gap: 8px; }
.who { color: var(--muted); font-size: 12px; font-family: var(--mono); word-break: break-all; }
#main { padding: 26px 30px 60px; max-width: 1400px; }
.loading { color: var(--muted); padding: 40px; }
h1 { font-size: 22px; margin: 0 0 4px; letter-spacing: .02em; }
h2 { font-size: 15px; margin: 22px 0 10px; color: var(--cyan); letter-spacing: .08em; text-transform: uppercase; }
.sub { color: var(--muted); margin: 0 0 20px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.grid { display: grid; gap: 14px; }
.grid.c4 { grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); }
.grid.c2 { grid-template-columns: repeat(auto-fit, minmax(380px, 1fr)); }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 16px 18px; position: relative; overflow: hidden; backdrop-filter: blur(6px); animation: rise .35s ease both; }
.card::before { content: ""; position: absolute; inset: 0 0 auto 0; height: 1px; background: linear-gradient(90deg, transparent, rgba(79, 216, 255, 0.5), transparent); }
@keyframes rise { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.stat .label { color: var(--muted); font-size: 12px; letter-spacing: .08em; text-transform: uppercase; }
.stat .value { font-size: 30px; font-weight: 700; font-family: var(--mono); margin-top: 6px; color: var(--ink); }
.stat .value.gold { color: var(--gold); } .stat .value.cyan { color: var(--cyan); } .stat .value.green { color: var(--green); }
.stat .hint { color: var(--muted); font-size: 12px; margin-top: 4px; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th { text-align: left; color: var(--muted); font-weight: 600; font-size: 11px; letter-spacing: .08em; text-transform: uppercase; padding: 8px 10px; border-bottom: 1px solid var(--line); }
td { padding: 9px 10px; border-bottom: 1px solid var(--line-2); vertical-align: top; }
tr:hover td { background: rgba(79, 216, 255, 0.04); }
td.mono, .mono { font-family: var(--mono); font-size: 12px; }
td.ar, .ar { direction: rtl; text-align: right; font-family: var(--sans); }
.pill { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 11px; font-weight: 600; letter-spacing: .04em; border: 1px solid var(--line-2); color: var(--muted); }
.pill.approved { color: var(--green); border-color: rgba(61, 220, 132, 0.4); background: rgba(61, 220, 132, 0.08); }
.pill.review { color: var(--gold); border-color: rgba(242, 196, 107, 0.4); background: rgba(242, 196, 107, 0.08); }
.pill.draft { color: var(--muted); }
.pill.retired { color: var(--red); border-color: rgba(255, 93, 108, 0.4); }
.pill.published, .pill.active, .pill.official { color: var(--cyan); border-color: rgba(79, 216, 255, 0.4); background: rgba(79, 216, 255, 0.08); }
.pill.paused { color: var(--gold); } .pill.archived { color: var(--red); } .pill.teacher { color: var(--purple); border-color: rgba(169, 112, 255, 0.4); }
.pill.live { color: #061018; background: var(--green); border-color: var(--green); }
.btn { font-family: var(--sans); font-weight: 700; font-size: 13px; padding: 8px 14px; border-radius: 8px; border: 1px solid var(--cyan); background: rgba(79, 216, 255, 0.12); color: var(--ink); cursor: pointer; transition: all .15s; box-shadow: 0 0 0 rgba(79, 216, 255, 0); }
.btn:hover { background: rgba(79, 216, 255, 0.22); box-shadow: 0 0 18px rgba(79, 216, 255, 0.25); }
.btn:disabled { opacity: .45; cursor: not-allowed; box-shadow: none; }
.btn.ghost { border-color: var(--line-2); background: transparent; color: var(--muted); }
.btn.ghost:hover { color: var(--ink); border-color: var(--line); background: rgba(255, 255, 255, 0.04); box-shadow: none; }
.btn.gold { border-color: var(--gold); background: rgba(242, 196, 107, 0.12); }
.btn.green { border-color: var(--green); background: rgba(61, 220, 132, 0.12); }
.btn.red { border-color: var(--red); background: rgba(255, 93, 108, 0.12); }
.btn.small { padding: 4px 10px; font-size: 12px; }
input, select, textarea { font-family: var(--sans); font-size: 13px; color: var(--ink); background: var(--bg-2); border: 1px solid var(--line-2); border-radius: 8px; padding: 8px 10px; outline: none; transition: border .15s, box-shadow .15s; }
input:focus, select:focus, textarea:focus { border-color: var(--cyan); box-shadow: 0 0 0 3px rgba(79, 216, 255, 0.12); }
textarea { min-height: 70px; resize: vertical; width: 100%; }
input[dir=rtl], textarea[dir=rtl] { text-align: right; }
label.field { display: flex; flex-direction: column; gap: 5px; font-size: 12px; color: var(--muted); }
label.field > input, label.field > select, label.field > textarea { width: 100%; }
.form { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
.form .full { grid-column: 1 / -1; }
.bar { height: 8px; background: rgba(255, 255, 255, 0.06); border-radius: 999px; overflow: hidden; }
.bar > i { display: block; height: 100%; background: linear-gradient(90deg, var(--cyan), #2d7dff); border-radius: 999px; transition: width .6s ease; }
.bar.gold > i { background: linear-gradient(90deg, var(--gold), #ff9a3d); }
.empty { color: var(--muted); padding: 24px; text-align: center; border: 1px dashed var(--line-2); border-radius: 10px; }
.err { color: var(--red); font-family: var(--mono); font-size: 12px; white-space: pre-wrap; }
.ok { color: var(--green); }
.muted { color: var(--muted); }
.spacer { flex: 1; }
.login { max-width: 400px; margin: 12vh auto 0; }
.login .brand-mark { width: 52px; height: 52px; font-size: 24px; margin-bottom: 14px; }
#toast { position: fixed; right: 20px; bottom: 20px; z-index: 50; display: flex; flex-direction: column; gap: 8px; }
.toast { padding: 10px 14px; border-radius: 10px; background: var(--panel-2); border: 1px solid var(--line); color: var(--ink); box-shadow: 0 10px 30px rgba(0, 0, 0, .5); animation: rise .25s ease; max-width: 420px; }
.toast.err { border-color: var(--red); } .toast.ok { border-color: var(--green); }
#modal-root:empty { display: none; }
.modal-bg { position: fixed; inset: 0; z-index: 40; background: rgba(3, 5, 12, 0.72); display: grid; place-items: center; padding: 20px; backdrop-filter: blur(3px); }
.modal { width: min(880px, 100%); max-height: 92vh; overflow: auto; background: var(--panel-2); border: 1px solid var(--line); border-radius: 14px; padding: 20px 22px; box-shadow: 0 30px 80px rgba(0, 0, 0, .6); animation: rise .25s ease; }
.modal h3 { margin: 0 0 14px; font-size: 16px; }
.options-editor { display: grid; gap: 8px; }
.options-editor .opt { display: grid; grid-template-columns: 24px 1fr 1fr 30px; gap: 8px; align-items: center; }
.kbd { font-family: var(--mono); font-size: 12px; padding: 2px 6px; border: 1px solid var(--line-2); border-radius: 5px; color: var(--muted); }
.code-big { font-family: var(--mono); font-size: 30px; letter-spacing: .18em; color: var(--gold); text-align: center; padding: 18px; border: 1px dashed rgba(242, 196, 107, 0.5); border-radius: 10px; margin: 10px 0; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line-2); margin-bottom: 14px; }
.tabs button { background: none; border: none; color: var(--muted); padding: 8px 12px; cursor: pointer; font-family: var(--sans); font-weight: 600; border-bottom: 2px solid transparent; }
.tabs button.active { color: var(--ink); border-bottom-color: var(--cyan); }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 3px 9px; border-radius: 999px; background: rgba(255, 255, 255, 0.05); border: 1px solid var(--line-2); font-size: 12px; margin: 2px; }
.rank-1 { color: var(--gold); font-weight: 700; } .rank-2 { color: #cfd6e6; font-weight: 700; } .rank-3 { color: #d8a070; font-weight: 700; }
.me td { background: rgba(79, 216, 255, 0.08) !important; }
.dropzone { border: 1px dashed var(--line); border-radius: 10px; padding: 24px; text-align: center; color: var(--muted); cursor: pointer; }
.dropzone:hover { border-color: var(--cyan); color: var(--ink); }
.villain-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 12px; }
.subject-dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 6px; vertical-align: middle; }
@media (max-width: 900px) {
  #app { grid-template-columns: 1fr; }
  #sidebar { position: relative; height: auto; }
  #nav { flex-direction: row; flex-wrap: wrap; }
  .form { grid-template-columns: 1fr; }
}

/* ---- world builder (builder.js) */
.modal.wide { width: min(1320px, 100%); }
.editor { display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: 18px; align-items: start; }
.editor-canvas { background: #05070e; border: 1px solid var(--line); border-radius: 10px; padding: 8px; display: flex; justify-content: center; }
.map-svg { height: 74vh; max-width: 100%; touch-action: none; user-select: none; }
.map-svg .h { cursor: grab; transition: stroke-width .1s; }
.map-svg .h:hover { filter: brightness(1.35); }
.map-svg .h.on { stroke: #fff !important; stroke-width: 6px; }
.map-svg .lbl { font-family: var(--sans); font-weight: 700; pointer-events: none; paint-order: stroke; stroke: rgba(0, 0, 0, .65); stroke-width: 6px; }
.editor-side h2 { margin: 16px 0 8px; }
.month-card { display: flex; gap: 14px; }
.month-thumb, .theme-thumb { flex: none; border-radius: 8px; border: 1px solid var(--line-2); background-size: cover; background-position: center top; display: grid; place-items: center; color: var(--muted); font-size: 11px; }
.month-thumb { width: 84px; height: 120px; }
.theme-card { cursor: pointer; transition: border-color .15s, transform .15s; }
.theme-card:hover { border-color: var(--cyan); transform: translateY(-2px); }
.theme-thumb { width: 100%; height: 230px; }
.code-chip { font-family: var(--mono); font-size: 22px; letter-spacing: .18em; color: var(--gold); padding: 6px 14px; border: 1px dashed rgba(242, 196, 107, 0.5); border-radius: 10px; }
.slot-list { display: grid; gap: 8px; margin-top: 10px; }
.asset-thumb { width: 54px; height: 54px; object-fit: contain; image-rendering: pixelated; background: #05070e; border-radius: 6px; border: 1px solid var(--line-2); }
.sheet-thumb { width: 100%; max-height: 120px; object-fit: contain; image-rendering: pixelated; background: #05070e; border-radius: 6px; margin-top: 8px; }
@media (max-width: 1100px) { .editor { grid-template-columns: 1fr; } .map-svg { height: 62vh; } }
input[type=color] { padding: 3px; height: 36px; min-width: 52px; cursor: pointer; }
input[type=color]::-webkit-color-swatch-wrapper { padding: 0; }
input[type=color]::-webkit-color-swatch { border: none; border-radius: 6px; }
.help { font-size: 12px; padding-left: 18px; margin: 8px 0; }

/* curriculum (0008) */
.tabs { flex-wrap: wrap; }
.chip.unit { padding: 1px 7px; font-size: 11px; color: var(--cyan); }
.unit-picks { display: flex; flex-wrap: wrap; gap: 2px; max-height: 180px; overflow: auto; padding: 4px; border: 1px solid var(--line-2); border-radius: 10px; }
.unit-picks .chip { cursor: pointer; }
.plan-table { font-size: 12px; min-width: 980px; }
.plan-table th { white-space: nowrap; }
.plan-table td { padding: 6px 6px; }
.plan-week a { color: var(--cyan); font-weight: 700; text-decoration: none; font-family: var(--mono); }
.plan-cell { min-width: 84px; }
.plan-v { font-family: var(--mono); font-size: 11px; line-height: 1.5; white-space: nowrap; padding: 0 4px; border-left: 3px solid var(--line-2); margin: 1px 0; }
.plan-v .n { color: var(--muted); }
.plan-v.ok { border-left-color: var(--green); }
.plan-v.warn { border-left-color: var(--gold); }
.plan-v.bad { border-left-color: var(--red); }
.month-row td { background: rgba(79, 216, 255, 0.05); color: var(--ink); padding: 8px 10px; }
