:root {
  --bg: #07090a;
  --panel: #0e1213;
  --panel-2: #141a1b;
  --line: #1f2829;
  --text: #d9e4e1;
  --muted: #7d8f8b;
  --accent: #39ff88;
  --accent-dim: #1e7a47;
  --warn: #ffb45c;
  --radius: 12px;
  --ui: "IBM Plex Sans Arabic", system-ui, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, monospace;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--ui);
  font-size: 15px;
  line-height: 1.55;
  min-height: 100vh;
}
button, input, select, textarea { font: inherit; color: inherit; }
.mono { font-family: var(--mono); direction: ltr; unicode-bidi: isolate; }

.top {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 18px 24px; border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 14px; }
.brand-mark {
  width: 34px; height: 34px; border-radius: 50%;
  border: 2px solid var(--accent);
  box-shadow: 0 0 12px rgba(57, 255, 136, .45), inset 0 0 8px rgba(57, 255, 136, .35);
  background:
    radial-gradient(circle at 50% 50%, rgba(57,255,136,.9) 0 2px, transparent 3px),
    repeating-linear-gradient(0deg, transparent 0 7px, rgba(57,255,136,.15) 7px 8px);
}
h1 { margin: 0; font-size: 20px; font-weight: 600; }
.sub { margin: 2px 0 0; color: var(--muted); font-size: 13px; }

.layout {
  display: grid; grid-template-columns: minmax(0, 1fr) 380px; gap: 22px;
  padding: 22px 24px; max-width: 1400px; margin: 0 auto;
}
/* the screen stays put while the settings scroll past it */
.stage { min-width: 0; position: sticky; top: 16px; align-self: start; z-index: 5; }

.scope-wrap {
  position: relative; width: 100%; aspect-ratio: 1 / 1; max-height: calc(100vh - 250px);
  margin-inline: auto;
  border-radius: 18px; overflow: hidden;
  background: #000;
  border: 1px solid var(--line);
  box-shadow: 0 0 0 6px #0b0f10, 0 0 40px rgba(57, 255, 136, .06);
}
#scope { display: block; width: 100%; height: 100%; cursor: ns-resize; outline: none; }
#scope:focus-visible { box-shadow: inset 0 0 0 2px var(--accent-dim); }
.scope-hint {
  position: absolute; inset-inline: 0; bottom: 12px; text-align: center;
  color: rgba(217, 228, 225, .55); font-size: 12px; pointer-events: none;
  transition: opacity .6s;
}
.scope-hint.gone { opacity: 0; }
.scope-status {
  position: absolute; top: 12px; inset-inline-start: 14px;
  font-family: var(--mono); font-size: 12px; color: rgba(57, 255, 136, .7);
  pointer-events: none; direction: ltr;
}

.speed {
  margin-top: 16px; background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 14px 16px;
}
.speed-head { display: flex; justify-content: space-between; align-items: baseline; }
.speed-head label { font-weight: 600; }
#speedOut { color: var(--accent); font-size: 15px; }
.speed input[type=range] { width: 100%; margin: 10px 0 6px; }
.presets { display: flex; flex-wrap: wrap; gap: 8px; }
.presets button {
  background: var(--panel-2); border: 1px solid var(--line); border-radius: 999px;
  padding: 5px 12px; cursor: pointer; font-size: 13px;
}
.presets button:hover { border-color: var(--accent-dim); }
.speed-info { margin: 10px 0 0; color: var(--muted); font-size: 13px; }

.panel { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field > label, .label { font-weight: 600; font-size: 14px; }
.note { margin: 0; color: var(--muted); font-size: 12.5px; }
.warn { margin: 0; color: var(--warn); font-size: 12.5px; }

textarea, input[type=number], select {
  background: var(--panel); border: 1px solid var(--line); border-radius: 10px;
  padding: 10px 12px; width: 100%;
}
textarea { resize: vertical; font-size: 18px; min-height: 84px; unicode-bidi: plaintext; text-align: start; }
textarea:focus, input:focus, select:focus { outline: 2px solid var(--accent-dim); outline-offset: 1px; }

.fonts { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.font-chip {
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  background: var(--panel); border: 1px solid var(--line); border-radius: 10px;
  padding: 8px 4px 6px; cursor: pointer; min-width: 0;
}
.font-chip .sample { font-size: 22px; line-height: 1.3; white-space: nowrap; }
.font-chip .fname { font-size: 11px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.font-chip[aria-checked=true] { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent) inset; }
.font-chip[aria-checked=true] .fname { color: var(--accent); }
.upload { display: block; margin-top: 6px; font-size: 12.5px; color: var(--muted); cursor: pointer; }
.upload input { display: none; }
.upload span { text-decoration: underline; text-underline-offset: 3px; }

.actions { display: flex; align-items: center; gap: 14px; }
.vol { flex: 1; display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); }
.vol input { flex: 1; }

button { cursor: pointer; }
.primary, .export button:not(.ghost-btn) {
  background: var(--panel-2); border: 1px solid var(--line); border-radius: 10px;
  padding: 10px 14px; font-weight: 600;
}
.primary { background: var(--accent); color: #032010; border-color: var(--accent); min-width: 130px; }
.primary.on { background: transparent; color: var(--accent); }
.export button:not(.ghost-btn):hover { border-color: var(--accent-dim); }
button:disabled { opacity: .45; cursor: not-allowed; }
.ghost-btn {
  background: transparent; border: 1px solid var(--line); border-radius: 8px;
  padding: 6px 12px; color: var(--muted); font-size: 13px;
}
.ghost-btn:hover { color: var(--text); border-color: var(--accent-dim); }

.export, .advanced {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px 16px; display: flex; flex-direction: column; gap: 12px;
}
.export h2 { margin: 0; font-size: 15px; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.check { display: flex; align-items: center; gap: 8px; font-size: 13.5px; }
.progress .bar { height: 6px; background: var(--panel-2); border-radius: 99px; overflow: hidden; }
.progress .bar span { display: block; height: 100%; width: 0; background: var(--accent); transition: width .2s linear; }
.progress-row { display: flex; justify-content: space-between; align-items: center; margin-top: 8px; font-size: 12.5px; color: var(--muted); }

.advanced summary { cursor: pointer; font-weight: 600; }
.advanced h3 { margin: 6px 0 0; font-size: 12.5px; color: var(--accent); font-weight: 600; letter-spacing: .02em; }
.adv { display: flex; flex-direction: column; gap: 10px; }
.ctl { display: grid; grid-template-columns: 1fr auto; gap: 2px 10px; align-items: center; font-size: 13.5px; }
.ctl input[type=range] { grid-column: 1 / -1; width: 100%; }
.ctl output { color: var(--accent); font-size: 12.5px; }
.ctl select { grid-column: 1 / -1; padding: 7px 10px; }
.ctl input[type=color] { width: 44px; height: 28px; border: 1px solid var(--line); border-radius: 6px; background: none; padding: 0; }
.ctl.check-ctl { display: flex; gap: 8px; }

input[type=range] { accent-color: var(--accent); }
input[type=checkbox] { accent-color: var(--accent); width: 16px; height: 16px; }

.foot { text-align: center; color: var(--muted); font-size: 12.5px; padding: 8px 24px 28px; }

@media (max-width: 960px) {
  .layout { grid-template-columns: 1fr; padding: 0 16px 16px; gap: 14px; }
  .top { padding: 14px 16px; }
  .stage {
    top: 0; padding-top: 10px; padding-bottom: 10px;
    background: var(--bg); border-bottom: 1px solid var(--line);
    margin-inline: -16px; padding-inline: 16px;
  }
  .scope-wrap { width: min(100%, 44vh); max-height: none; box-shadow: 0 0 0 4px #0b0f10; }
  .speed { margin-top: 10px; padding: 8px 12px; }
  .speed input[type=range] { margin: 6px 0 4px; }
  .presets { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; }
  .presets button { flex: none; }
  .speed-info { display: none; }
  .fonts { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 420px) {
  .fonts { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .row2 { grid-template-columns: 1fr; }
  h1 { font-size: 18px; }
}
