:root {
  --bg: #f6f7f9;
  --card: #ffffff;
  --text: #15181d;
  --muted: #5f6774;
  --line: #e2e5ea;
  --accent: #0f766e;
  --accent-ink: #ffffff;
  --accent-soft: #e6f4f2;
  --warn: #b45309;
  --warn-soft: #fef3e2;
  --bad: #b42318;
  --bad-soft: #fdecea;
  --ok: #067647;
  --ok-soft: #e7f6ee;
  --radius: 14px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1216;
    --card: #181c22;
    --text: #e8ebef;
    --muted: #9aa3ae;
    --line: #2a3038;
    --accent: #2dd4bf;
    --accent-ink: #062320;
    --accent-soft: #10302c;
    --warn: #f5b25c;
    --warn-soft: #33260f;
    --bad: #f97066;
    --bad-soft: #3a1714;
    --ok: #47cd89;
    --ok-soft: #0f2d1e;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.55 system-ui, -apple-system, "Segoe UI", Tahoma, "Noto Sans Arabic", sans-serif;
}
.wrap { max-width: 680px; margin: 0 auto; padding: 16px 16px calc(32px + env(safe-area-inset-bottom)); }
h1 { font-size: 1.45rem; margin: 8px 0 4px; }
h2 { font-size: 1.05rem; margin: 0 0 6px; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.top { margin-bottom: 14px; }
.top p { margin: 0; }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  margin: 12px 0;
}
details.card > summary { font-weight: 600; cursor: pointer; list-style: none; display: flex; align-items: center; gap: 8px; min-height: 28px; }
details.card > summary::-webkit-details-marker { display: none; }
details.card > summary::after { content: "⌄"; margin-inline-start: auto; color: var(--muted); transition: transform .15s; }
details[open].card > summary::after { transform: rotate(180deg); }
details[open].card > summary { margin-bottom: 12px; }

.drop {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
  min-height: 150px; padding: 20px;
  border: 2px dashed var(--accent); border-radius: var(--radius);
  background: var(--accent-soft); cursor: pointer; text-align: center;
  transition: background .15s;
}
.drop.compact { min-height: 0; flex-direction: row; gap: 10px; padding: 12px 14px; border-style: solid; border-width: 1px; }
.drop.compact .drop-icon { font-size: 1.2rem; }
.drop.compact .drop-title { font-size: 1rem; }
.drop.busy { opacity: .6; pointer-events: none; }
.drop input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.drop-icon { font-size: 2rem; }
.drop-title { font-weight: 700; font-size: 1.15rem; color: var(--accent); overflow-wrap: anywhere; }

.alert { border-radius: 10px; padding: 10px 12px; margin: 12px 0; }
.alert.error { background: var(--bad-soft); color: var(--bad); }
.alert.ok { background: var(--ok-soft); color: var(--ok); }

.summary { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; }
.summary .file { width: 100%; font-weight: 600; overflow-wrap: anywhere; }
.pill { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 999px; font-size: .88rem; background: var(--bg); border: 1px solid var(--line); }
.pill.ready { color: var(--ok); }
.pill.warn { color: var(--warn); }
.pill.excluded { color: var(--bad); }
.dot { width: 8px; height: 8px; border-radius: 50%; background: currentColor; flex: none; }

.field { display: flex; flex-direction: column; gap: 4px; margin-bottom: 12px; font-size: .9rem; color: var(--muted); }
input[type=text], input[type=search], select {
  width: 100%; font: inherit; font-size: 16px; color: var(--text);
  background: var(--bg); border: 1px solid var(--line); border-radius: 10px;
  padding: 11px 12px; min-height: 46px;
}
#prefix { font-size: 1.15rem; font-weight: 700; letter-spacing: .02em; }
input:focus, select:focus, button:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.check { display: flex; align-items: center; gap: 8px; min-height: 40px; font-size: .95rem; }
.check input { width: 20px; height: 20px; accent-color: var(--accent); flex: none; }
.check.sens em { font-style: normal; font-size: .75rem; color: var(--bad); background: var(--bad-soft); padding: 1px 6px; border-radius: 6px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 10px; align-items: end; }
@media (max-width: 420px) { .grid2 { grid-template-columns: 1fr; } }
fieldset.fields { border: 1px solid var(--line); border-radius: 10px; margin: 8px 0 12px; padding: 6px 12px; display: grid; grid-template-columns: 1fr 1fr; }
fieldset.fields legend { font-size: .85rem; color: var(--muted); padding: 0 4px; }

.preview { background: var(--bg); border-radius: 10px; padding: 4px 12px; margin-bottom: 14px; }
.preview .row { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.preview .row:last-child { border-bottom: 0; }
.avatar { width: 34px; height: 34px; border-radius: 50%; background: var(--accent-soft); color: var(--accent); display: grid; place-items: center; font-weight: 700; flex: none; font-size: .9rem; }
.preview .nm { font-weight: 600; overflow-wrap: anywhere; }
.preview .ph { font-size: .82rem; color: var(--muted); direction: ltr; unicode-bidi: isolate; }

.btn { display: block; width: 100%; font: inherit; font-weight: 700; border-radius: 12px; border: 1px solid var(--line); background: var(--card); color: var(--text); padding: 12px 16px; min-height: 48px; cursor: pointer; margin: 8px 0; }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn.big { font-size: 1.12rem; min-height: 58px; }
.btn.ghost { background: transparent; color: var(--accent); border-color: var(--accent); }
.btn:disabled { opacity: .5; cursor: default; }
.btn.small { display: inline-block; width: auto; min-height: 34px; padding: 4px 12px; margin: 4px 0 0; font-size: .85rem; font-weight: 600; }

ol#steps { margin: 0; padding-inline-start: 22px; }
ol#steps li { margin: 6px 0; }

.badge { font-size: .78rem; font-weight: 600; background: var(--warn-soft); color: var(--warn); padding: 2px 8px; border-radius: 999px; }
.badge:empty { display: none; }
.tabs { display: flex; gap: 6px; margin-bottom: 10px; }
.tabs button { flex: 1; font: inherit; font-size: .9rem; padding: 8px; border-radius: 10px; border: 1px solid var(--line); background: var(--bg); color: var(--text); min-height: 40px; cursor: pointer; }
.tabs button.on { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.search { margin-bottom: 8px; }

.list { list-style: none; margin: 0; padding: 0; }
.item { display: flex; gap: 10px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.item:last-child { border-bottom: 0; }
.item .body { flex: 1; min-width: 0; }
.item .nm { width: 100%; font-weight: 600; background: transparent; border: 1px solid transparent; padding: 4px 6px; margin: -4px -6px 2px; min-height: 0; border-radius: 8px; font-size: 1rem; }
.item .nm:focus { background: var(--bg); border-color: var(--line); }
.item .ph { direction: ltr; unicode-bidi: isolate; font-size: .88rem; color: var(--muted); display: inline-block; }
.item .meta { font-size: .8rem; color: var(--muted); }
.item .warns { margin: 4px 0 0; padding: 0; list-style: none; font-size: .84rem; color: var(--warn); }
.item.excluded .warns { color: var(--bad); }
.item .notes { font-size: .8rem; color: var(--muted); }
.item .side { display: flex; flex-direction: column; align-items: center; gap: 6px; }
.item .status { color: var(--ok); margin-top: 6px; }
.item.warn .status { color: var(--warn); }
.item.excluded .status { color: var(--bad); }
.item.excluded .nm { text-decoration: line-through; opacity: .7; }
.toggle { font: inherit; font-size: .78rem; border: 1px solid var(--line); background: var(--bg); color: var(--muted); border-radius: 8px; padding: 4px 8px; cursor: pointer; white-space: nowrap; }

.header-rows { display: flex; flex-direction: column; gap: 6px; }
.header-rows button { text-align: start; font: inherit; font-size: .85rem; padding: 10px; border: 1px solid var(--line); border-radius: 10px; background: var(--bg); color: var(--text); overflow: hidden; white-space: nowrap; text-overflow: ellipsis; cursor: pointer; }

details.sub { border-top: 1px solid var(--line); padding-top: 10px; margin-top: 10px; }
details.sub > summary { cursor: pointer; font-weight: 600; margin-bottom: 8px; }
.tokens { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.tokens button { font: inherit; font-size: .85rem; border: 1px solid var(--line); background: var(--bg); color: var(--text); border-radius: 8px; padding: 6px 10px; cursor: pointer; }
.mapping .mrow { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 8px; align-items: center; padding: 4px 0; font-size: .88rem; }
.mapping .mrow .lbl { overflow-wrap: anywhere; }
.mapping .mrow .lbl b { color: var(--muted); font-weight: 600; }
.mapping select { min-height: 38px; padding: 6px 8px; font-size: 14px; }

[hidden] { display: none !important; }
