/* «موقعي», the site editor (package E2). Phone first (320–430px), a two-column home and wider forms from 1024px.
   Colours only through tokens.css; every control at least 44px; no text clipped at 320px in Arabic. */
.site { display: grid; gap: 14px; min-width: 0; max-width: 1100px; }
.site__head { display: grid; gap: 6px; }
.site__cols { display: grid; gap: 18px; min-width: 0; }
.site__list, .site__side { display: grid; gap: 10px; align-content: start; min-width: 0; }
.backlink.backlink--always { display: inline-flex; }  /* beats forms.css's desktop .backlink { display: none } by specificity */
@media (min-width: 1024px) { .site__cols { grid-template-columns: minmax(0, 1fr) 320px; } }

/* ---------------------------------------------------------------- state card, pending, undo */
.sitestate { display: grid; gap: 12px; }
.sitestate__row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; }
.sitestate__design { font-weight: 650; }
.sitestate .note { display: flex; gap: 8px; align-items: flex-start; }
.sitepending { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; }
.undobar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px;
  background: var(--info-soft); color: var(--info-text); box-shadow: none; }
.undobar p { font-weight: 650; }

/* ---------------------------------------------------------------- the section list */
.secrows, .sitelinks, .histlist, .designs, .publist, .conflict, .rows, .library__grid { list-style: none; }
.secrows { display: grid; gap: 8px; }
.secrow { display: flex; align-items: center; gap: 8px; padding: 6px 10px 6px 6px; }
[dir="rtl"] .secrow { padding: 6px 6px 6px 10px; }
.secrow__main { display: flex; align-items: center; gap: 8px; flex: 1; min-width: 0; min-height: 56px; padding: 6px 8px;
  border-radius: var(--r-sm); color: var(--ink); text-decoration: none; }
.secrow__main--still { cursor: default; }
.secrow__text { display: grid; gap: 3px; flex: 1; min-width: 0; }
.secrow__name { font-weight: 700; }
.secrow__state { font-size: 14px; color: var(--muted); overflow-wrap: anywhere; }
.secrow__state--on { color: var(--ok-text); font-weight: 650; }
.secrow__state--incomplete { color: var(--warn-text); }
.secrow__chips { display: flex; flex-wrap: wrap; gap: 6px; }
.secrow__chips .chip { white-space: normal; }
.secrow__control { flex: none; }
.sitelinks { display: grid; gap: 8px; }

/* the switch: a real button, role="switch", its state in words beside the track */
.switch { display: inline-flex; align-items: center; gap: 8px; min-height: var(--tap); min-width: var(--tap); padding: 6px 8px;
  border: 0; border-radius: var(--r-sm); background: transparent; color: var(--ink); font-weight: 650; font-size: 14px; cursor: pointer; }
.switch__track { position: relative; width: 46px; height: 28px; border-radius: 99px; background: var(--line); flex: none;
  transition: background-color .15s; }
.switch__knob { position: absolute; top: 3px; inset-inline-start: 3px; width: 22px; height: 22px; border-radius: 50%;
  background: var(--card); box-shadow: var(--shadow); transition: inset-inline-start .15s; }
.switch[aria-checked="true"] .switch__track { background: var(--accent); }
.switch[aria-checked="true"] .switch__knob { inset-inline-start: 21px; }
.switch:disabled { cursor: not-allowed; opacity: .55; }
.switch[aria-busy="true"] { cursor: progress; }

/* ---------------------------------------------------------------- one section */
.secswitch { display: grid; gap: 8px; }
.secswitch__row { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; }
.sform { display: grid; gap: 22px; }
.sfield { display: grid; gap: 6px; min-width: 0; }
.sfield__top { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.sfield__count { font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; }
.sfield__count.is-over { color: var(--hot-text); font-weight: 700; }
.sfield__status { font-size: 14px; color: var(--muted); min-height: 1.4em; }
.sfield__status:empty { min-height: 0; }
.sfield__status[data-kind="ok"] { color: var(--ok-text); }
.sfield__status[data-kind="bad"] { color: var(--hot-text); font-weight: 650; }
.input[aria-invalid] { border-color: var(--hot); }
input[type="date"].input, input[type="number"].input { max-width: 260px; }

.rowsbox, .colour { border: 0; margin: 0; padding: 0; min-width: 0; display: grid; gap: 8px; }
.rowsbox > legend, .colour > legend { padding: 0; margin-bottom: 4px; width: 100%; }
.rows { display: grid; gap: 10px; }
.row { display: grid; gap: 10px; padding: 12px; border: 1px solid var(--line); border-radius: var(--r); background: var(--bg); min-width: 0; }
.row__head { display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; }
.row__title { font-weight: 700; }
.row__tools { display: flex; gap: 6px; }
.rows__empty { padding: 6px 0; }
.iconbtn:disabled { opacity: .45; cursor: not-allowed; }
.iconbtn--bad { color: var(--hot-text); background: var(--hot-soft); }
.icon--up { transform: rotate(90deg); }
.icon--down { transform: rotate(-90deg); }
[dir="rtl"] .icon--up { transform: rotate(90deg); }

.swatches { display: flex; flex-wrap: wrap; gap: 6px; }
.swatch { display: grid; place-items: center; width: var(--tap); height: var(--tap); border-radius: 50%; border: 2px solid transparent;
  background: var(--card); cursor: pointer; padding: 0; }
.swatch[aria-pressed="true"] { border-color: var(--ink); }
.swatch__dot { width: 32px; height: 32px; }
.colour__row { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.colour__label { font-size: 15px; font-weight: 600; }
.colour__pick { width: 64px; height: var(--tap); padding: 2px; border: 1px solid var(--line); border-radius: var(--r-sm); background: var(--card); cursor: pointer; }
.colour__note.is-bad { color: var(--hot-text); font-weight: 650; }

/* ---------------------------------------------------------------- photos */
.imgslot { display: grid; gap: 8px; min-width: 0; }
.imgslot__empty { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; padding: 14px;
  border: 2px dashed var(--line); border-radius: var(--r); }
.imgslot__img { width: 100%; max-width: 420px; border-radius: var(--r-sm); background: var(--soft); object-fit: cover; display: block; }
.imgslot__img--wide { aspect-ratio: 16 / 9; }
.imgslot__img--photo { aspect-ratio: 4 / 3; }
.imgslot__img--square { aspect-ratio: 1; max-width: 180px; object-fit: contain; }
.imgslot__alt { display: grid; gap: 6px; padding-top: 6px; }
.picker { display: grid; gap: 12px; }
.filepick { cursor: pointer; }
.library__grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; }
.library__item { display: grid; gap: 6px; padding: 8px; background: var(--card); border-radius: var(--r-sm); box-shadow: var(--shadow); min-width: 0; }
.library__img { width: 100%; aspect-ratio: 4 / 3; object-fit: cover; border-radius: 8px; background: var(--soft); }
.library__tools { display: flex; align-items: center; justify-content: space-between; gap: 6px; }
.crop { display: grid; gap: 10px; padding: 12px; background: var(--card); border-radius: var(--r); box-shadow: var(--shadow); }
.crop__canvas { width: 100%; height: auto; max-height: 52vh; object-fit: contain; border-radius: var(--r-sm); background: var(--soft); }
.crop__canvas--square { max-width: 320px; }
.crop__controls { display: grid; gap: 8px; }
.range { width: 100%; margin: 0; min-height: var(--tap); accent-color: var(--accent); }

/* ---------------------------------------------------------------- publish, history, designs */
.pubblock { display: grid; gap: 8px; padding: 14px; background: var(--card); border-radius: var(--r); box-shadow: var(--shadow); }
.pubblock .chip { justify-self: start; }
.sheet--publish .sheet__body > * + * { margin-top: 12px; }
.publist { display: grid; gap: 8px; }
.publist li { display: grid; gap: 2px; padding-bottom: 8px; border-bottom: 1px solid var(--line); min-width: 0; }
.publist li:last-child { border-bottom: 0; padding-bottom: 0; }
.publist__sec { font-weight: 650; }
.publist__value, .publist__fields { color: var(--muted); font-size: 15px; overflow-wrap: anywhere; }
.pubdone { display: flex; align-items: center; gap: 8px; font-weight: 700; }
.histlist { display: grid; gap: 10px; }
.histrow { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.histrow__main { display: grid; gap: 4px; flex: 1; min-width: 200px; }
.histrow__title { font-weight: 750; }
.designs { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.designcard { display: grid; gap: 8px; justify-items: start; align-content: start; }
.designcard.is-chosen { box-shadow: inset 0 0 0 2px var(--accent); }
.designcard__name { display: flex; align-items: center; gap: 8px; font-weight: 700; }
.designcard__n { display: inline-grid; place-items: center; width: 26px; height: 26px; border-radius: 50%; background: var(--soft);
  font-size: 13px; }
.designcard__marks { display: flex; flex-wrap: wrap; gap: 6px; }
.layout { width: 100%; max-width: 120px; aspect-ratio: 3 / 5; justify-self: center; background: var(--bg); border-radius: 10px;
  border: 1px solid var(--line); }
.layout__hero { fill: var(--accent); opacity: .85; }
.layout__block { fill: var(--line); }

/* ---------------------------------------------------------------- the conflict */
.conflict { display: grid; gap: 10px; margin: 12px 0; }
.conflict__row { display: grid; gap: 8px; }
.conflict__label { font-weight: 700; }
.conflict__pair { display: grid; gap: 8px; grid-template-columns: minmax(0, 1fr); }
@media (min-width: 560px) { .conflict__pair { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.conflict__side { padding: 10px; border-radius: var(--r-sm); background: var(--soft); min-width: 0; }
.conflict__side--mine { background: var(--accent-soft); }
.conflict__who { font-size: 13px; font-weight: 700; color: var(--muted-text); margin-bottom: 4px; }
.conflict__value { white-space: pre-line; overflow-wrap: anywhere; }
.site .page-title:focus { outline: none; }
.sfield__held { justify-self: start; }
.designcard__marks { max-width: 100%; min-width: 0; }
.designcard__marks .chip, .designcard .btn { white-space: normal; max-width: 100%; }
.designcard { min-width: 0; }
.sitestate { grid-template-columns: minmax(0, 1fr); }
.sitestate .chip, .pubblock .chip { white-space: normal; max-width: 100%; }
.nowrap { white-space: nowrap; }
