:root {
  /* الألوان من design/README.md: الخلفيات العامة، ولون الأداة «صانع الرموز» الفحمي للتمييز، والذهبي للتنبيه */
  --bg: #eef1ef;
  --surface: #ffffff;
  --ink: #10201d;
  --muted: #5b6b68;
  --line: #d5dcd9;
  --field-line: #84948f;
  --accent: #5a6270;
  --accent-strong: #2e333c;
  --accent-soft: #eef1ff;
  --accent-ink: #ffffff;
  --ok: #12806f;
  --gold: #d4a853;
  --gold-ink: #5e4412;
  --gold-soft: #f8efd9;
  --danger: #b42318;
  --danger-soft: #fbe9e7;
  --stage: #dfe4e2;
  --shadow: 0 1px 2px rgba(20,25,35,.06), 0 4px 14px rgba(20,25,35,.06);
  --font-display: "Readex Pro", "IBM Plex Sans Arabic", Tahoma, sans-serif;
  --font-body: "IBM Plex Sans Arabic", "Segoe UI", Tahoma, sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0b1211; --surface: #151f1d; --ink: #edf2f0; --muted: #8fa19d; --line: #2a3634; --field-line: #66807a;
    --accent: #dce1eb; --accent-strong: #dce1eb; --accent-soft: #2e333c; --accent-ink: #121418;
    --ok: #2fb5a0;
    --gold-soft: #3a2f16; --gold-ink: #f0d9a3;
    --danger: #f07167; --danger-soft: #3a1f1d;
    --stage: #060a09;
    --shadow: 0 1px 2px rgba(0,0,0,.3), 0 4px 14px rgba(0,0,0,.25);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--ink); font-family: var(--font-body); font-size: 14px; line-height: 1.55; }
button, input, select, textarea { font: inherit; color: inherit; }
h1, h2 { font-family: var(--font-display); font-weight: 600; text-wrap: balance; margin: 0; }
p { margin: 0; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.spacer { flex: 1; }
svg { flex: none; }

header.top {
  display: flex; flex-wrap: wrap; align-items: center; gap: 10px 20px;
  padding: 14px 20px; background: var(--surface); border-bottom: 1px solid var(--line);
}
header.top h1 { font-size: 19px; }
header.top .brand { color: var(--accent); margin-inline-end: 4px; }
header.top .sub { color: var(--muted); font-size: 13px; }

.mode { display: inline-flex; padding: 4px; gap: 4px; border-radius: 12px; background: var(--bg); border: 1px solid var(--line); }
.mode button {
  min-height: 38px; padding: 6px 18px; border: 0; border-radius: 9px; background: none; cursor: pointer; font-weight: 600; color: var(--muted);
}
.mode button[aria-selected="true"] { background: var(--accent); color: var(--accent-ink); }

main { padding: 18px 20px 40px; max-width: 1180px; margin: 0 auto; display: flex; flex-direction: column; gap: 14px; }

.btn {
  min-height: 40px; padding: 7px 16px; border-radius: 10px; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  background: var(--surface); border: 1px solid var(--field-line); font-weight: 500;
}
.btn:hover:not(:disabled) { background: var(--accent-soft); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 600; }
.btn.primary:hover:not(:disabled) { background: var(--accent-strong); border-color: var(--accent-strong); }
.btn:disabled { opacity: .5; cursor: default; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 16px; box-shadow: var(--shadow); }
.card h2 { font-size: 15px; margin-bottom: 10px; }
.card h2.gap { margin-top: 18px; }

.panel {
  padding: 12px 14px; border-radius: 12px;
  background: var(--surface); border: 1px solid var(--line); border-inline-start: 4px solid var(--gold);
}
.panel.ok { border-inline-start-color: var(--ok); }
.panel h2 { font-size: 14.5px; margin-bottom: 2px; }
.privacy p { color: var(--muted); }

.grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 14px; align-items: start; }
@media (max-width: 860px) { .grid { grid-template-columns: minmax(0, 1fr); } }
.preview-card { position: sticky; top: 14px; display: flex; flex-direction: column; gap: 10px; }
@media (max-width: 860px) { .preview-card { position: static; } }
.settings, .settings > div { display: flex; flex-direction: column; gap: 14px; }

/* المعاينة: نقش مربعات خفيف يُظهر الخلفية الشفافة والحدود */
.stage {
  display: flex; align-items: center; justify-content: center; aspect-ratio: 1; padding: 24px;
  border-radius: 12px; background-color: var(--stage);
  background-image: linear-gradient(45deg, rgba(127,127,127,.12) 25%, transparent 25%, transparent 75%, rgba(127,127,127,.12) 75%),
    linear-gradient(45deg, rgba(127,127,127,.12) 25%, transparent 25%, transparent 75%, rgba(127,127,127,.12) 75%);
  background-size: 20px 20px; background-position: 0 0, 10px 10px;
}
.stage.wide { aspect-ratio: 4 / 3; }
.stage svg { width: 100%; height: 100%; max-width: 100%; max-height: 100%; border-radius: 6px; box-shadow: 0 6px 20px -10px rgba(0,0,0,.35); }
.placeholder { text-align: center; color: var(--muted); padding: 20px; }

.status { padding: 9px 12px; border-radius: 10px; background: var(--bg); color: var(--muted); font-size: 13.5px; }
.status.ok { background: var(--bg); color: var(--ok); border-inline-start: 4px solid var(--ok); font-weight: 500; }
.status.warn { background: var(--gold-soft); color: var(--gold-ink); border-inline-start: 4px solid var(--gold); }
.status.bad { background: var(--danger-soft); color: var(--danger); border-inline-start: 4px solid var(--danger); }
.payload { overflow-wrap: anywhere; }

.actions { display: flex; flex-wrap: wrap; gap: 8px; }

.field { display: flex; flex-direction: column; gap: 4px; font-size: 12.5px; color: var(--muted); }
.field + .field, .fields .check { margin-top: 10px; }
.field select, .field input, .field textarea {
  min-height: 40px; padding: 7px 10px; border-radius: 10px; width: 100%;
  border: 1px solid var(--field-line); background: var(--surface); color: var(--ink); font-size: 14px;
}
.field textarea { resize: vertical; min-height: 64px; }
.field select:disabled { opacity: .6; }
.field-label { font-size: 12.5px; color: var(--muted); margin: 12px 0 6px; }
.card h2 + .field-label { margin-top: 0; }
.fields { margin-top: 12px; }
.fields > p { margin-top: 8px; }
.check { display: flex; align-items: center; gap: 8px; min-height: 36px; margin-top: 8px; }
.check input { width: 18px; height: 18px; accent-color: var(--accent); }

.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  min-height: 34px; padding: 4px 13px; border-radius: 999px; cursor: pointer;
  border: 1px solid var(--line); background: var(--bg); font-size: 13.5px;
}
.chip:hover { border-color: var(--field-line); }
.chip[aria-checked="true"] { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 600; }

.seg { display: grid; grid-template-columns: repeat(auto-fit, minmax(84px, 1fr)); gap: 6px; }
.seg button {
  min-height: 44px; padding: 6px 10px; border-radius: 10px; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: 1px solid var(--line); background: var(--bg); font-size: 13.5px;
}
.seg button svg { width: 20px; height: 20px; color: var(--muted); }
.seg button:hover { border-color: var(--field-line); }
.seg button[aria-checked="true"] { border-color: var(--accent); background: var(--accent-soft); font-weight: 600; box-shadow: inset 0 0 0 1px var(--accent); }
.seg button[aria-checked="true"] svg { color: var(--ink); }

.swatches { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.swatch {
  position: relative; width: 36px; height: 36px; padding: 3px; border-radius: 50%; cursor: pointer;
  border: 2px solid transparent; background: none; display: inline-flex;
}
.swatch span { flex: 1; border-radius: 50%; border: 1px solid var(--line); }
.swatch[aria-checked="true"], .swatch.custom.on { border-color: var(--accent); }
.swatch.text { width: auto; border-radius: 999px; padding: 0 12px; border-color: var(--line); background: var(--bg); font-size: 13px; align-items: center; }
.swatch.text[aria-checked="true"] { border-color: var(--accent); background: var(--accent-soft); font-weight: 600; }
/* «لون آخر»: دائرة ألوان، وتأخذ اللون المختار عند استخدامها */
.swatch.custom span { background: conic-gradient(#e0355b, #d4a853, #2fae6b, #14b8c9, #3d27b8, #d24bc8, #e0355b); }
.swatch.custom.on span { background-image: none; }
.swatch.custom input { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; border: 0; padding: 0; }
.swatch.custom:focus-within { outline: 2px solid var(--accent); outline-offset: 2px; }

.logo-row { display: flex; align-items: center; gap: 12px; }
.logo-thumb {
  width: 64px; height: 64px; border-radius: 12px; border: 1px dashed var(--field-line); flex: none;
  display: flex; align-items: center; justify-content: center; overflow: hidden; background: var(--bg);
}
.logo-thumb img { max-width: 100%; max-height: 100%; }
.logo-btns { display: flex; flex-wrap: wrap; gap: 8px; }
.file-btn { position: relative; overflow: hidden; }
.file-btn input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.file-btn:focus-within { outline: 2px solid var(--accent); outline-offset: 2px; }

details.more summary { cursor: pointer; font-family: var(--font-display); font-weight: 600; font-size: 15px; }
details.more[open] summary { margin-bottom: 10px; }
