:root {
  --bg: #0d0f16;
  --bg-elev: #141826;
  --card: #171b28;
  --edge: #262b3d;
  --edge-strong: #343a52;
  --text: #e9ebf3;
  --muted: #9aa2b8;
  --accent: #8f70ff;
  --accent-strong: #a58fff;
  --accent-soft: rgba(143, 112, 255, 0.16);
  --ok: #3fbf7f;
  --warn: #ffd166;
  --err: #ff6b6b;
  --radius: 14px;
  --radius-sm: 9px;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
  --motion: 0.15s;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans Arabic", "Noto Kufi Arabic", sans-serif;
  color-scheme: dark;
  font-size: 16px;
}
:root[data-theme="light"] {
  --bg: #f4f5fb;
  --bg-elev: #ffffff;
  --card: #ffffff;
  --edge: #e1e4f0;
  --edge-strong: #c9cee0;
  --text: #171a2b;
  --muted: #5e6580;
  --accent: #5b3fe0;
  --accent-strong: #4a2fd0;
  --accent-soft: rgba(91, 63, 224, 0.12);
  --ok: #1f9d63;
  --warn: #9a6a00;
  --err: #d64545;
  --shadow: 0 10px 30px rgba(20, 24, 60, 0.08);
  color-scheme: light;
}

* {
  box-sizing: border-box;
}
html {
  scroll-behavior: smooth;
}
@media (prefers-reduced-motion: reduce) {
  :root {
    --motion: 0s;
  }
  html {
    scroll-behavior: auto;
  }
}
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}
[dir="rtl"] body {
  font-family: "Noto Sans Arabic", "Noto Kufi Arabic", var(--font);
}
a {
  color: var(--accent-strong);
}
h1,
h2,
h3,
h4 {
  margin: 0;
  line-height: 1.3;
}
h2 {
  font-size: 1.15rem;
}
h3 {
  font-size: 0.95rem;
  margin-bottom: 0.45rem;
}
h4 {
  font-size: 0.88rem;
  margin-bottom: 0.4rem;
  color: var(--muted);
  font-weight: 600;
}
p {
  margin: 0.35rem 0;
}
.hint,
.fine {
  color: var(--muted);
  font-size: 0.88rem;
}
.fine {
  font-size: 0.8rem;
}
.fine.warn {
  color: var(--warn);
}
[hidden] {
  /* biome-ignore lint/complexity/noImportantStyles: must beat every display rule below */
  display: none !important;
}

button,
.button {
  background: var(--bg-elev);
  color: var(--text);
  border: 1px solid var(--edge);
  border-radius: var(--radius-sm);
  padding: 0.6rem 1rem;
  font: inherit;
  font-size: 0.92rem;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  transition:
    border-color 0.15s,
    background 0.15s;
}
button:hover,
.button:hover {
  border-color: var(--accent);
}
input:focus-visible,
button:focus-visible,
a:focus-visible,
summary:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
button:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}
button.primary,
.button.primary {
  background: var(--accent);
  border-color: transparent;
  color: #fff;
  font-weight: 600;
}
button.primary:hover:not(:disabled),
.button.primary:hover {
  background: var(--accent-strong);
}
button.big {
  padding: 0.8rem 1.4rem;
  font-size: 1rem;
}
.button.ghost {
  background: transparent;
}
/* ---- header ------------------------------------------------------------- */
.top {
  max-width: 1180px;
  margin: 0 auto;
  padding: 1rem 1rem 0.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}
.brand {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  text-decoration: none;
  color: inherit;
}
.logo {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  box-shadow: var(--shadow);
}
.brand-text {
  display: flex;
  flex-direction: column;
}
.brand-name {
  font-size: 1.3rem;
  font-weight: 700;
  letter-spacing: -0.01em;
}
.tagline {
  color: var(--muted);
  font-size: 0.85rem;
}
.top-actions {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}
.icon-btn,
.pill-btn {
  background: var(--card);
  color: var(--text);
  border: 1px solid var(--edge);
  border-radius: 999px;
  cursor: pointer;
  font: inherit;
  font-size: 0.9rem;
}
.pill-btn {
  padding: 0.45rem 1rem;
}
.icon-btn {
  width: 2.4rem;
  height: 2.4rem;
  display: inline-grid;
  place-items: center;
}
.icon-btn:hover,
.pill-btn:hover {
  border-color: var(--accent);
}
.theme-icon {
  width: 1rem;
  height: 1rem;
  border-radius: 50%;
  background: var(--text);
  box-shadow: inset -0.35rem -0.2rem 0 0 var(--card);
}
:root[data-theme="light"] .theme-icon {
  box-shadow: none;
  background: radial-gradient(circle, var(--warn) 45%, transparent 48%);
  outline: 2px dotted var(--warn);
  outline-offset: 2px;
  width: 0.8rem;
  height: 0.8rem;
}

/* ---- layout ------------------------------------------------------------- */
.layout {
  max-width: 1180px;
  margin: 0 auto;
  padding: 0.5rem 1rem 5rem;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 1.25rem;
}
.steps {
  display: flex;
  gap: 0.4rem;
  overflow-x: auto;
  padding-bottom: 0.25rem;
  scrollbar-width: none;
}
.steps a {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.45rem 0.85rem;
  border-radius: 999px;
  border: 1px solid var(--edge);
  background: var(--card);
  color: var(--muted);
  text-decoration: none;
  font-size: 0.88rem;
  white-space: nowrap;
}
.steps a.active {
  color: var(--text);
  border-color: var(--accent);
  background: var(--accent-soft);
}
.step-num {
  display: inline-grid;
  place-items: center;
  width: 1.4rem;
  height: 1.4rem;
  border-radius: 50%;
  background: var(--edge);
  font-size: 0.75rem;
  font-weight: 700;
}
.steps a.active .step-num {
  background: var(--accent);
  color: #fff;
}
.content {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  min-width: 0;
}
.summary {
  position: sticky;
  bottom: 0.75rem;
  z-index: 5;
}
.summary-card {
  background: var(--card);
  border: 1px solid var(--edge);
  border-radius: var(--radius);
  padding: 0.9rem 1rem;
  box-shadow: var(--shadow);
  display: flex;
  align-items: center;
  gap: 1rem;
}
.summary-card h2,
.summary-card dl {
  display: none;
}
.summary-card button {
  flex: 1;
}
@media (min-width: 1100px) {
  .layout {
    grid-template-columns: 190px minmax(0, 1fr) 290px;
    align-items: start;
  }
  .steps {
    position: sticky;
    top: 1rem;
    flex-direction: column;
    overflow: visible;
  }
  .steps a {
    border-radius: var(--radius-sm);
  }
  .summary {
    top: 1rem;
    bottom: auto;
  }
  .summary-card {
    flex-direction: column;
    align-items: stretch;
    gap: 0.75rem;
  }
  .summary-card h2 {
    display: block;
    font-size: 1rem;
  }
  .summary-card dl {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 0.35rem 0.75rem;
    margin: 0;
    font-size: 0.86rem;
  }
  .summary-card dt {
    color: var(--muted);
  }
  .summary-card dd {
    margin: 0;
    overflow-wrap: anywhere;
  }
}

/* ---- cards -------------------------------------------------------------- */
.card {
  background: var(--card);
  border: 1px solid var(--edge);
  border-radius: var(--radius);
  padding: 1.25rem;
  scroll-margin-top: 1rem;
}
.card-head {
  margin-bottom: 0.9rem;
}
.intro p {
  font-size: 0.93rem;
}
.notice {
  border: 1px solid var(--edge);
  border-inline-start: 4px solid var(--accent);
  background: var(--card);
  border-radius: var(--radius);
  padding: 0.7rem 1rem;
  font-size: 0.9rem;
}
.notice.error {
  border-inline-start-color: var(--err);
}
.pref {
  margin-top: 1.1rem;
}
.pref:first-child {
  margin-top: 0;
}
.grid2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}
@media (max-width: 640px) {
  .grid2 {
    grid-template-columns: 1fr;
  }
}
.stack {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  margin-top: 1rem;
}
.feature {
  border: 1px solid var(--edge);
  border-radius: var(--radius);
  padding: 1rem;
  background: var(--bg-elev);
}
.feature-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
}
.feature-body {
  margin-top: 0.9rem;
  display: flex;
  flex-direction: column;
  gap: 0.8rem;
}
details.advanced {
  margin-top: 0.6rem;
  border-top: 1px dashed var(--edge);
  padding-top: 0.5rem;
}
details.advanced summary {
  cursor: pointer;
  color: var(--muted);
  font-size: 0.85rem;
  user-select: none;
}
details.advanced[open] summary {
  margin-bottom: 0.5rem;
}

/* ---- controls ----------------------------------------------------------- */
input[type="text"],
input[type="password"],
input[type="search"],
input[type="number"] {
  flex: 1;
  min-width: 8rem;
  background: var(--bg-elev);
  border: 1px solid var(--edge);
  color: var(--text);
  border-radius: var(--radius-sm);
  padding: 0.6rem 0.75rem;
  font: inherit;
  font-size: 0.92rem;
}
.field-row {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.5rem;
  flex-wrap: wrap;
}
.actions {
  display: flex;
  gap: 0.6rem;
  margin-top: 0.8rem;
  flex-wrap: wrap;
}
.generate-row {
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
}
#manifestUrl {
  direction: ltr;
  text-align: left;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.8rem;
}
input[type="range"] {
  width: 100%;
  accent-color: var(--accent);
  margin-top: 0.4rem;
}
output {
  display: inline-block;
  min-width: 2ch;
  padding: 0 0.45rem;
  margin-inline-start: 0.4rem;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent-strong);
  font-weight: 700;
  font-size: 0.85rem;
}

/* switch */
.switch {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  cursor: pointer;
  position: relative;
  font-size: 0.92rem;
}
.switch input {
  position: absolute;
  opacity: 0;
  width: 1px;
  height: 1px;
}
.switch .track {
  flex: none;
  width: 2.4rem;
  height: 1.35rem;
  border-radius: 999px;
  background: var(--edge-strong);
  position: relative;
  transition: background var(--motion);
}
.switch .track::after {
  content: "";
  position: absolute;
  top: 0.15rem;
  inset-inline-start: 0.15rem;
  width: 1.05rem;
  height: 1.05rem;
  border-radius: 50%;
  background: #fff;
  transition: transform var(--motion);
}
.switch input:checked + .track {
  background: var(--accent);
}
.switch input:checked + .track::after {
  transform: translateX(1.05rem);
}
[dir="rtl"] .switch input:checked + .track::after {
  transform: translateX(-1.05rem);
}
.switch input:focus-visible + .track {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* segmented radio group */
.segmented {
  display: inline-flex;
  padding: 3px;
  gap: 3px;
  background: var(--bg-elev);
  border: 1px solid var(--edge);
  border-radius: var(--radius-sm);
  max-width: 100%;
  flex-wrap: wrap;
}
.segmented.vertical {
  flex-direction: column;
  display: flex;
}
.segmented label {
  position: relative;
  flex: 1;
  cursor: pointer;
}
.segmented input {
  position: absolute;
  opacity: 0;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  cursor: pointer;
}
.segmented span {
  display: block;
  padding: 0.5rem 0.8rem;
  border-radius: 7px;
  font-size: 0.88rem;
  color: var(--muted);
  text-align: center;
  white-space: nowrap;
}
.segmented.vertical span {
  text-align: start;
  white-space: normal;
}
.segmented input:checked + span {
  background: var(--accent-soft);
  color: var(--text);
  font-weight: 600;
}
.segmented input:focus-visible + span {
  outline: 2px solid var(--accent);
}

/* radio cards */
.choice-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.choice {
  display: flex;
  gap: 0.7rem;
  align-items: flex-start;
  padding: 0.7rem 0.85rem;
  border: 1px solid var(--edge);
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 0.9rem;
  background: var(--bg-elev);
}
.choice:has(input:checked) {
  border-color: var(--accent);
  background: var(--accent-soft);
}
.choice input {
  margin-top: 0.25rem;
  accent-color: var(--accent);
}
.choice strong {
  display: block;
}
.choice-hint {
  display: block;
  color: var(--muted);
  font-size: 0.83rem;
}

/* ---- providers ---------------------------------------------------------- */
.provider-list,
.lang-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}
.provider {
  border: 1px solid var(--edge);
  border-radius: var(--radius);
  padding: 0.85rem 0.9rem;
  background: var(--bg-elev);
}
.provider.dragging,
.lang-item.dragging {
  opacity: 0.5;
}
.provider.drop-target,
.lang-item.drop-target {
  border-color: var(--accent);
}
.provider-head {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  flex-wrap: wrap;
}
.handle {
  cursor: grab;
  color: var(--muted);
  user-select: none;
  padding: 0 0.2rem;
  letter-spacing: -0.15em;
  font-size: 1.1rem;
  line-height: 1;
}
.order-badge {
  display: inline-grid;
  place-items: center;
  width: 1.5rem;
  height: 1.5rem;
  border-radius: 50%;
  background: var(--edge);
  font-size: 0.75rem;
  font-weight: 700;
}
.provider.enabled .order-badge {
  background: var(--accent);
  color: #fff;
}
.provider-name {
  font-weight: 600;
  flex: 1;
}
.provider-head a {
  font-size: 0.84rem;
  text-decoration: none;
}
.provider-head a:hover {
  text-decoration: underline;
}
.tag {
  font-size: 0.72rem;
  padding: 0.1rem 0.5rem;
  border-radius: 999px;
  background: var(--edge);
  color: var(--muted);
}
.arrows {
  display: inline-flex;
  gap: 0.2rem;
}
.arrows button,
.lang-item button.icon {
  padding: 0.25rem 0.5rem;
  font-size: 0.85rem;
  line-height: 1;
}
.provider-body {
  margin-top: 0.7rem;
}
.provider .hint {
  margin: 0.35rem 0 0;
}
button.reveal {
  flex: 0;
  padding-inline: 0.7rem;
}
.test-result {
  font-size: 0.85rem;
  margin: 0.45rem 0 0;
  min-height: 1.2em;
}
.test-result.ok {
  color: var(--ok);
}
.test-result.err {
  color: var(--err);
}
.test-result.busy {
  color: var(--muted);
}

/* ---- languages ---------------------------------------------------------- */
.code {
  margin-inline-start: auto;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.75rem;
  color: var(--muted);
  text-transform: uppercase;
}
.native {
  color: var(--muted);
  font-size: 0.85rem;
}
.lang-picker {
  position: relative;
  margin-bottom: 0.7rem;
}
.lang-picker input {
  width: 100%;
}
.lang-picker .listbox {
  position: absolute;
  inset-inline: 0;
  top: calc(100% + 4px);
  z-index: 20;
  margin: 0;
  padding: 0.3rem;
  list-style: none;
  max-height: 280px;
  overflow-y: auto;
  background: var(--bg-elev);
  border: 1px solid var(--edge-strong);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow);
}
.lang-picker .option {
  display: flex;
  align-items: baseline;
  gap: 0.6rem;
  padding: 0.5rem 0.7rem;
  border-radius: 7px;
  cursor: pointer;
  font-size: 0.9rem;
}
.lang-picker .option.active,
.lang-picker .option:hover {
  background: var(--accent-soft);
}
.lang-picker .empty {
  padding: 0.6rem 0.7rem;
  color: var(--muted);
  font-size: 0.88rem;
}
.lang-item {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.55rem 0.75rem;
  border: 1px solid var(--edge);
  border-radius: var(--radius-sm);
  background: var(--bg-elev);
}
.lang-item.primary {
  border-color: var(--accent);
}
.lang-item .name {
  font-weight: 600;
}
.badge {
  font-size: 0.7rem;
  font-weight: 700;
  padding: 0.1rem 0.5rem;
  border-radius: 999px;
  background: var(--accent);
  color: #fff;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.lang-picker.single input {
  max-width: 24rem;
}
.lang-picker.single .selected {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.4rem;
  font-size: 0.92rem;
  font-weight: 600;
}

/* ---- preview ------------------------------------------------------------ */
.preview {
  margin-top: 1.1rem;
  padding: 0.8rem 0.9rem;
  border-radius: var(--radius-sm);
  background: var(--bg);
  border: 1px solid var(--edge);
}
.preview-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  direction: ltr;
  text-align: left;
}
.preview-list li {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.8rem;
  overflow-wrap: anywhere;
}
.preview-list li .lang-chip {
  display: inline-block;
  min-width: 2.2rem;
  margin-inline-end: 0.5rem;
  padding: 0 0.4rem;
  border-radius: 5px;
  background: var(--edge);
  color: var(--muted);
  font-size: 0.7rem;
  text-align: center;
}

footer {
  max-width: 1180px;
  margin: 0 auto;
  padding: 0 1rem 2rem;
  text-align: center;
}
.version {
  opacity: 0.7;
}

/* ---- appearance preview ------------------------------------------------- */
.preview-stage {
  margin: 0.8rem 0 1rem;
}
.preview-video {
  position: relative;
  aspect-ratio: 16 / 7;
  border-radius: var(--radius-sm);
  background:
    radial-gradient(ellipse at 30% 20%, rgba(143, 112, 255, 0.35), transparent 55%),
    radial-gradient(ellipse at 80% 70%, rgba(255, 209, 102, 0.25), transparent 50%),
    linear-gradient(160deg, #2b2f45, #0c0e16);
  overflow: hidden;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}
.preview-lines {
  width: 100%;
  text-align: center;
  padding: 0 1rem;
  transition: padding-bottom 0.15s;
}
.preview-line {
  margin: 0.15rem auto;
  display: inline-block;
  line-height: 1.35;
  white-space: nowrap;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  font-family: "SubFusion Embedded", "Noto Sans Arabic", var(--font);
}
.preview-line + .preview-line {
  display: block;
}
.preview-caption {
  margin: 0.35rem 0 0;
  text-align: center;
}
.color-row {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}
.color-row input[type="color"] {
  flex: none;
  width: 2.6rem;
  height: 2.4rem;
  padding: 0.15rem;
  border: 1px solid var(--edge);
  border-radius: var(--radius-sm);
  background: var(--bg-elev);
  cursor: pointer;
}
.color-row input.hex {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  text-transform: lowercase;
  direction: ltr;
  max-width: 8rem;
}
#styleReset {
  margin-top: 0.4rem;
}
input.hex.invalid {
  border-color: var(--err);
}
