/* Dashboard building blocks (DESIGN.md sections 7 and 10): tables that become stacked rows on phones, toolbars,
   stat cards, detail layouts and the near-black main button. Used inside [data-theme="admin"]. */

[data-theme="admin"] .btn-primary { background: var(--ink); color: #fff; }
[data-theme="admin"] .btn-primary:hover { background: #000; }
[data-theme="admin"] .btn-danger { background: var(--surface); color: var(--danger-ink); border-color: rgba(180, 35, 24, 0.3); }
[data-theme="admin"] .btn-sm { min-height: 36px; padding-inline: var(--s-3); font-size: 14px; }

.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s-2); margin-block-end: var(--s-4); }
.toolbar .search-field { flex: 1 1 260px; min-width: 0; max-width: 420px; display: flex; gap: var(--s-2); }
.toolbar input[type="search"], .toolbar select {
  flex: 1;
  min-width: 0;
  min-height: 40px;
  padding-inline: var(--s-3);
  border-radius: var(--r-control);
  border: 1px solid var(--line-strong);
  background: var(--surface);
}
/* width: 0 drops the search box's default width (about 20 characters), so it can never push the toolbar past a
   phone screen; flex: 1 still fills the field. */
.toolbar input[type="search"] { width: 0; }
/* A filter on its own (not inside a search field) keeps the width of its words instead of being squeezed. */
.toolbar > select { flex: 0 1 auto; }

.data-table { width: 100%; border-collapse: collapse; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; overflow: hidden; font-size: 14px; }
.data-table th { text-align: start; font-weight: 500; color: var(--ink-3); font-size: 13px; padding: 10px var(--s-3); border-bottom: 1px solid var(--line); background: #FCFCFC; }
.data-table td { padding: 10px var(--s-3); border-bottom: 1px solid var(--line); vertical-align: middle; }
.data-table tr:last-child td { border-bottom: 0; }
.data-table tbody tr:hover { background: #FCFCFC; }
.data-table a.row-link { color: var(--ink); font-weight: 500; text-decoration: none; }
.data-table a.row-link:hover { text-decoration: underline; text-underline-offset: 3px; }
.data-table .end { text-align: end; }
.data-table .muted { color: var(--ink-3); }

/* Phones: each row becomes a stacked card, labels from data-label. */
@media (max-width: 639.98px) {
  .data-table thead { display: none; }
  .data-table, .data-table tbody, .data-table tr, .data-table td { display: block; width: 100%; }
  .data-table tr { padding: var(--s-2) var(--s-3); border-bottom: 1px solid var(--line); }
  .data-table td { padding: 2px 0; border: 0; display: flex; justify-content: space-between; gap: var(--s-3); }
  .data-table td[data-label]::before { content: attr(data-label); color: var(--ink-3); }
  .data-table .end { text-align: start; }
}

.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 220px), 1fr)); gap: var(--s-3); margin-block-end: var(--s-5); }
.stat { padding: var(--s-4); border-radius: 12px; background: var(--surface); border: 1px solid var(--line); display: flex; flex-direction: column; gap: var(--s-1); }
.stat-label { font-size: 13px; color: var(--ink-3); }
.stat-value { font-size: 26px; font-weight: 500; font-variant-numeric: tabular-nums; }
.stat-note { font-size: 13px; color: var(--ink-2); }

.detail { display: grid; grid-template-columns: minmax(0, 1fr); gap: var(--s-4); }
@media (min-width: 1024px) { .detail { grid-template-columns: minmax(0, 2fr) minmax(280px, 1fr); align-items: start; } }
.detail-main, .detail-side { display: flex; flex-direction: column; gap: var(--s-4); min-width: 0; }

.kv { margin: 0; display: grid; grid-template-columns: max-content 1fr; gap: var(--s-1) var(--s-4); font-size: 14px; }
.kv dt { color: var(--ink-3); }
.kv dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }

.inline-form { display: inline-flex; flex-wrap: wrap; align-items: center; gap: var(--s-2); }
.inline-form input:not([type="checkbox"], [type="file"]), .inline-form select { min-height: 36px; padding-inline: var(--s-2); border-radius: var(--r-row); border: 1px solid var(--line-strong); background: var(--surface); }
.inline-form input[type="number"] { width: 5.5em; }

.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--ink-3); margin-inline-end: var(--s-2); }
.dot.warn { background: var(--warning); }
.dot.ok { background: var(--accent); }

.switch { display: inline-flex; align-items: center; gap: var(--s-2); cursor: pointer; }
.switch input { appearance: none; width: 36px; height: 20px; border-radius: 10px; background: var(--line-strong); position: relative; cursor: pointer; transition: background-color 120ms; }
.switch input::after { content: ""; position: absolute; top: 2px; inset-inline-start: 2px; width: 16px; height: 16px; border-radius: 50%; background: #fff; transition: inset-inline-start 120ms; }
.switch input:checked { background: var(--accent); }
.switch input:checked::after { inset-inline-start: 18px; }

.settings-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 420px), 1fr)); gap: var(--s-4); align-items: start; }
.thumb-sm { width: 40px; height: 40px; border-radius: var(--r-row); border: 1px solid var(--line); object-fit: contain; background: var(--surface); }

/* Row forms: one record per row of labelled fields (discounts, delivery methods, staff, synonyms). */
[data-theme="admin"] p.hint { margin-block-end: var(--s-3); font-size: 14px; }
[data-theme="admin"] .muted { color: var(--ink-3); }
.row-form { display: flex; flex-wrap: wrap; align-items: flex-end; gap: var(--s-2) var(--s-3); padding-block: var(--s-3); border-bottom: 1px solid var(--line); }
.row-form:last-of-type { border-bottom: 0; }
.row-form label:not(.switch) { display: flex; flex-direction: column; gap: 2px; font-size: 12px; color: var(--ink-3); }
.row-form input:not([type="checkbox"], [type="file"]), .row-form select { min-height: 36px; padding-inline: var(--s-2); border-radius: var(--r-row); border: 1px solid var(--line-strong); background: var(--surface); color: var(--ink); font-size: 14px; }
.row-form input[type="number"] { width: 6em; }
.row-form .code { text-transform: uppercase; width: 9em; }
.row-form .wide { flex: 1 1 280px; }
.row-form .wide input { width: 100%; }
.row-form .state { flex: 1 1 100%; font-size: 13px; }
.row-form .state:empty { display: none; }

/* Notices above a page's content (the one-time status message, form problems) keep a steady gap. */
[data-theme="admin"] .admin-main > .notice,
[data-theme="admin"] .admin-status { margin-block-end: var(--s-4); }

/* A column of panels with one steady gap (pages whose panels sit inside a form). */
.stack { display: flex; flex-direction: column; gap: var(--s-5); }
.stack > .settings-grid { align-items: stretch; }

/* Panels stacked on a page (not inside a flex layout with its own gap). */
.admin-main > :is(.panel, .data-table, .pager, .stat-grid, .settings-grid, form) + :is(.panel, .settings-grid, form) { margin-block-start: var(--s-5); }

/* Links that pick a range or preset, drawn as a segmented control (overview chart, reports). */
.segmented-links { display: inline-flex; flex-wrap: wrap; gap: 2px; padding: 2px; border-radius: var(--r-control); background: var(--raised); }
.segmented-links a { padding: 6px var(--s-3); border-radius: var(--r-row); color: var(--ink-2); font-size: 14px; text-decoration: none; }
.segmented-links a[aria-current="page"] { background: var(--surface); color: var(--ink); box-shadow: var(--shadow-segment); }

/* Multi-line text kept as written (import summaries, email bodies). */
.pre-line { white-space: pre-line; }

[data-theme="admin"] .form > .btn { align-self: flex-start; }

/* English | العربية tabs (LanguageTabs): radio buttons drawn as a segmented control; :has() shows one panel. */
.lang-tabs { display: flex; flex-direction: column; gap: var(--s-3); }
.lang-switch { display: inline-flex; align-self: flex-start; gap: 2px; padding: 2px; border-radius: var(--r-control); background: var(--raised); }
.lang-switch label { display: inline-flex; align-items: center; gap: var(--s-1); padding: 6px var(--s-3); border-radius: var(--r-row); color: var(--ink-2); font-size: 14px; cursor: pointer; }
.lang-switch input { position: absolute; opacity: 0; pointer-events: none; }
.lang-switch label:has(input:checked) { background: var(--surface); color: var(--ink); box-shadow: var(--shadow-segment); }
.lang-switch label:has(input:focus-visible) { outline: var(--focus-ring); outline-offset: 2px; }
.lang-switch .dot { margin: 0; }
.lang-tabs:has(.lang-switch input[value="ar"]:checked) > .lang-en,
.lang-tabs:not(:has(.lang-switch input[value="ar"]:checked)) > .lang-ar { display: none; }

/* A status as a coloured tag (orders, discounts): blue in progress, green done or running, grey closed, amber waiting. */
.status-tag {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
}

.status-tag.open { background: #E4F1FB; color: #1D4F7A; }
.status-tag.done { background: var(--accent-soft); color: #1F5A30; }
.status-tag.closed { background: var(--raised); color: var(--ink-2); }
.status-tag.hold { background: var(--warning-soft); color: var(--warning-ink); }

/* Edit pages: a fieldset that only groups (and disables for read-only staff), the save row, a number with its unit,
   codes typed in capitals, and the delete section kept apart at the bottom. */
fieldset.plain { margin: 0; padding: 0; border: 0; min-width: 0; }
.form-actions { display: flex; flex-wrap: wrap; gap: var(--s-2); align-items: center; }
.input-unit { display: flex; align-items: center; gap: var(--s-2); }
.field-row > .field.narrow { flex: 0 1 220px; }
.input-unit input { flex: 1; min-width: 0; }
.input-unit > span { color: var(--ink-3); }
.code-input { text-transform: uppercase; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; letter-spacing: 0.04em; }
.danger-zone { border-color: rgba(180, 35, 24, 0.25); }
.danger-zone p { margin-block: 0 var(--s-3); }

/* "Back to …" above an admin page's heading. */
.admin-main > .back { margin-block-end: var(--s-3); font-size: 14px; }
.link-accent.back { display: inline-flex; align-items: center; gap: var(--s-1); }

/* Icons on the quiet text buttons in tables and lists (Delete, Remove, Retry…). */
[data-theme="admin"] .link-button { display: inline-flex; align-items: center; gap: var(--s-1); }

/* A second, quieter line under a list entry (the Arabic name under a category or brand). */
.sub-line { display: block; font-size: 13px; }

/* A panel folded behind its title (the order status correction). */
details.panel > summary::marker { color: var(--ink-3); }

/* Banner previews (home page content): the strip as customers see it, with its status and an edit link. */
.banner-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: var(--s-3); }
.banner-item { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s-3); }
.banner-preview { flex: 1 1 320px; margin: 0; padding: 10px 14px; border-radius: var(--r-row); font-size: 14px; line-height: 20px; }
.swatches { display: flex; flex-wrap: wrap; gap: var(--s-2); margin: 0; padding: 0; border: 0; }
.swatch { display: inline-flex; align-items: center; gap: var(--s-2); padding: 8px 12px; border-radius: var(--r-row); cursor: pointer; border: 2px solid transparent; }
.swatch:has(input:checked) { border-color: currentColor; }
.swatch input { margin: 0; }
details.old-site > summary { cursor: pointer; font-weight: 500; padding-block: var(--s-2); }
details.old-site > summary + * { margin-block-start: var(--s-3); }
.field.narrow-field { max-width: 320px; }

/* Settings: the free-delivery amount only matters when free delivery is on; a panel's hint with its button. */
.free-delivery:not(:has(input[name="freeDelivery"]:checked)) .free-from { display: none; }
.free-from { margin-block-start: var(--s-3); }
.panel-head-row { display: flex; flex-wrap: wrap; align-items: flex-start; justify-content: space-between; gap: var(--s-3); }
.panel-head-row .hint { flex: 1 1 280px; margin: 0; }
/* A hint-and-button row keeps a steady gap above what follows it (a table, a list, a search, an empty state). Panels
   are plain blocks, so this margin merges with the next element's own top margin instead of adding to it. */
.panel-head-row { margin-block-end: var(--s-4); }
.panel-head-row:last-child { margin-block-end: 0; }
.admin-main > .settings-delivery { margin-block-start: var(--s-5); }

/* Staff: the area-by-area levels appear only for the Custom role. */
.levels-box { display: none; margin-block-start: var(--s-4); }
.staff-form:has(input[name="role"][value="custom"]:checked) .levels-box { display: block; }
.levels { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 220px), 1fr)); gap: var(--s-2) var(--s-3); margin-block-start: var(--s-3); }
.levels label { display: flex; flex-direction: column; gap: 2px; font-size: 13px; color: var(--ink-3); }
.levels select { min-height: 34px; border-radius: var(--r-row); border: 1px solid var(--line-strong); background: var(--surface); }
.choice-grid.roles { margin: 0; padding: 0; border: 0; }

/* Synonym editor: one list for "same meaning", two boxes for "one way". */
.synonym-form:has(input[name="kind"][value="one_way"]:checked) .only-equivalent,
.synonym-form:not(:has(input[name="kind"][value="one_way"]:checked)) .only-one-way { display: none; }

/* Amounts and short statuses never break across lines in a list. */
.data-table td.num, .data-table td:has(> .dot), .data-table td:has(> .status-tag) { white-space: nowrap; }

/* ---- Photos (ImageTools.razor, js/image-viewer.js, js/image-upload.js) ---- */

/* A thumbnail that opens the photo viewer; larger ones show a magnifier on hover. */
.zoomable { position: relative; display: inline-block; flex: 0 0 auto; vertical-align: middle; border-radius: var(--r-control); cursor: zoom-in; }
.zoomable img { display: block; }
.zoomable:focus-visible { outline: var(--focus-ring); outline-offset: 2px; }
.zoom-hint { position: absolute; inset: 0; display: grid; place-items: center; border-radius: inherit; background: rgb(0 0 0 / 0.35); color: #fff; opacity: 0; transition: opacity 150ms ease-out; }
.zoomable:is(:hover, :focus-visible) .zoom-hint { opacity: 1; }

/* The viewer and the crop step: modal dialogs over a dark backdrop that doesn't scroll the page behind. */
.image-viewer, .image-cropper {
  width: min(960px, calc(100vw - 2 * var(--s-4)));
  max-height: calc(100dvh - 2 * var(--s-4));
  padding: var(--s-4);
  border: 0;
  border-radius: var(--r-panel);
  background: var(--surface);
  color: var(--ink);
  box-shadow: var(--shadow-float);
  overscroll-behavior: contain;
}
.image-viewer[open], .image-cropper[open] { display: flex; flex-direction: column; gap: var(--s-3); }
.image-viewer::backdrop, .image-cropper::backdrop { background: rgb(0 0 0 / 0.6); overflow: hidden; overscroll-behavior: contain; }
@media (prefers-reduced-motion: no-preference) {
  .image-viewer[open], .image-cropper[open] { transition: opacity 150ms ease-out, transform 150ms ease-out; }
  @starting-style {
    .image-viewer[open], .image-cropper[open] { opacity: 0; transform: scale(0.97); }
  }
}

.iv-bar { display: flex; align-items: center; gap: var(--s-2); }
.iv-caption { flex: 1 1 auto; min-width: 0; margin: 0; overflow: hidden; color: var(--ink-2); font-size: 14px; text-overflow: ellipsis; white-space: nowrap; }
.iv-count { margin-inline-end: var(--s-2); color: var(--ink-3); }
.iv-stage { position: relative; display: grid; place-items: center; min-height: 240px; overflow: hidden; border-radius: var(--r-card); background: var(--raised); }
.iv-image { display: block; max-width: 100%; max-height: calc(100dvh - 140px); object-fit: contain; transition: opacity 150ms ease-out; }
.iv-stage[aria-busy="true"] .iv-image { opacity: 0.4; }
.iv-step { position: absolute; inset-block-start: 50%; translate: 0 -50%; box-shadow: var(--shadow-float); }
.iv-step[data-viewer-step="-1"] { inset-inline-start: var(--s-3); }
.iv-step[data-viewer-step="1"] { inset-inline-end: var(--s-3); }
.iv-step[hidden] { display: none; }
@media (max-width: 600px) {
  .image-viewer, .image-cropper { padding: var(--s-3); }
  .iv-open span { display: none; }
}

.crop-head { display: flex; align-items: center; justify-content: space-between; gap: var(--s-3); }
.crop-head h2 { margin: 0; font-size: 18px; }
.crop-tools { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s-3); }
.segmented-buttons { display: inline-flex; gap: 2px; padding: 2px; border-radius: var(--r-control); background: var(--raised); }
.segmented-buttons button { min-height: 32px; padding-inline: var(--s-3); border: 0; border-radius: var(--r-row); background: transparent; color: var(--ink-2); font: inherit; font-size: 14px; cursor: pointer; }
.segmented-buttons button[aria-pressed="true"] { background: var(--surface); color: var(--ink); box-shadow: var(--shadow-segment); }
.segmented-buttons button:focus-visible { outline: var(--focus-ring); }
/* The photo with the crop box over it. The box and its handles are placed on the picture itself, so they use physical
   left/top in both languages (the stage is always left to right). The frame clips the box's dimming shadow. */
.crop-frame { display: grid; place-items: center; padding: var(--s-4); overflow: hidden; border-radius: var(--r-card); background: var(--raised); }
.crop-stage { position: relative; direction: ltr; line-height: 0; touch-action: none; user-select: none; }
.crop-image { display: block; max-width: 100%; max-height: calc(100dvh - 340px); min-height: 120px; object-fit: contain; }
.crop-box {
  position: absolute;
  outline: 2px solid #fff;
  box-shadow: 0 0 0 100vmax rgb(0 0 0 / 0.55);
  cursor: move;
  touch-action: none;
  background:
    linear-gradient(rgb(255 255 255 / 0.5) 0 0) 33.333% 0 / 1px 100% no-repeat,
    linear-gradient(rgb(255 255 255 / 0.5) 0 0) 66.666% 0 / 1px 100% no-repeat,
    linear-gradient(rgb(255 255 255 / 0.5) 0 0) 0 33.333% / 100% 1px no-repeat,
    linear-gradient(rgb(255 255 255 / 0.5) 0 0) 0 66.666% / 100% 1px no-repeat;
}
.crop-box:focus-visible { outline: 3px solid var(--accent); }
.crop-handle { position: absolute; width: 22px; height: 22px; border: 0 solid #fff; touch-action: none; }
.crop-handle[data-handle="nw"] { top: -4px; left: -4px; border-width: 4px 0 0 4px; cursor: nwse-resize; }
.crop-handle[data-handle="ne"] { top: -4px; right: -4px; border-width: 4px 4px 0 0; cursor: nesw-resize; }
.crop-handle[data-handle="sw"] { bottom: -4px; left: -4px; border-width: 0 0 4px 4px; cursor: nesw-resize; }
.crop-handle[data-handle="se"] { bottom: -4px; right: -4px; border-width: 0 4px 4px 0; cursor: nwse-resize; }
@media (pointer: coarse) {
  .crop-handle { width: 32px; height: 32px; }
}
.image-cropper .hint { margin: 0; color: var(--ink-3); font-size: 13px; }

/* The files chosen in an upload field, before they are sent. */
.upload-list { list-style: none; width: 100%; margin: var(--s-2) 0 0; padding: 0; display: grid; gap: var(--s-2); }
.upload-list[hidden] { display: none; }
.upload-item { display: flex; align-items: center; gap: var(--s-3); padding: var(--s-2); border: 1px solid var(--line); border-radius: var(--r-control); background: var(--surface); }
.upload-thumb { width: 56px; height: 56px; flex: 0 0 auto; object-fit: contain; border-radius: var(--r-row); background: var(--raised); }
.upload-info { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.upload-name { overflow: hidden; font-size: 14px; text-overflow: ellipsis; white-space: nowrap; }
.upload-meta { color: var(--ink-3); font-size: 13px; }
.upload-actions { display: flex; align-items: center; gap: var(--s-2); }

/* An order's delete form, under its live editor (AdminOrderDetail). */
.order-delete { margin-block-start: var(--s-5); }

/* ---- Pages and news (AdminPageEdit, RichTextEditor, js/rich-editor.js) ---- */

/* The kind decides which address prefix and which fields show. */
.page-form .slug-prefix, .page-form .only-blog, .page-form .only-page { display: none; }
.page-form:has(input[name="kind"][value="page"]:checked) .slug-prefix[data-for="page"],
.page-form:has(input[name="kind"][value="blog_post"]:checked) .slug-prefix[data-for="blog"],
.page-form:has(input[name="kind"]:is([value="news"], [value="announcement"]):checked) .slug-prefix[data-for="news"] { display: inline; }
.page-form:has(input[name="kind"][value="page"]:checked) .only-page,
.page-form:has(input[name="kind"][value="blog_post"]:checked) .only-blog { display: flex; }
.slug-field { display: flex; align-items: center; border: 1px solid var(--line-strong); border-radius: var(--r-control); background: var(--surface); overflow: hidden; }
.slug-field:focus-within { outline: var(--focus-ring); outline-offset: 1px; }
.slug-prefix { padding-inline: var(--s-3) 2px; color: var(--ink-3); white-space: nowrap; }
.field .slug-field input { flex: 1 1 auto; min-width: 0; border: 0; outline: 0; padding-inline-start: 0; }
.page-kind-choices { grid-template-columns: repeat(auto-fit, minmax(min(100%, 240px), 1fr)); }
.cover-current { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s-3); }
.cover-preview { width: 160px; height: 90px; object-fit: cover; border-radius: var(--r-row); background: var(--raised); }

/* The editor: a toolbar that stays in view over a white writing area. */
.rich-editor { display: flex; flex-direction: column; border: 1px solid var(--line-strong); border-radius: var(--r-control); background: var(--surface); }
.rich-editor:focus-within { border-color: var(--ink-3); }
.re-head { position: sticky; inset-block-start: 0; z-index: 2; border-start-start-radius: inherit; border-start-end-radius: inherit; background: var(--surface); }
.re-toolbar { display: flex; flex-wrap: wrap; gap: var(--s-1) var(--s-2); padding: var(--s-2); border-block-end: 1px solid var(--line); border-start-start-radius: inherit; border-start-end-radius: inherit; background: var(--surface); }
.re-toolbar[hidden] { display: none; }
.re-group { display: flex; gap: 2px; }
.re-group + .re-group { padding-inline-start: var(--s-2); border-inline-start: 1px solid var(--line); }
.re-btn { display: grid; place-items: center; width: 36px; height: 36px; padding: 0; border: 0; border-radius: var(--r-row); background: transparent; color: var(--ink-2); cursor: pointer; }
.re-btn:hover { background: var(--raised); color: var(--ink); }
.re-btn[aria-pressed="true"] { background: var(--raised); color: var(--ink); box-shadow: inset 0 0 0 1px var(--line-strong); }
.re-btn:focus-visible { outline: var(--focus-ring); }
.re-context { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s-2); padding: var(--s-2); border-block-end: 1px solid var(--line); background: var(--raised); }
.re-context[hidden], .re-context [hidden] { display: none; }
.re-context-label { margin-inline-end: var(--s-1); color: var(--ink-3); font-size: 13px; }
.re-area { min-height: 320px; max-width: none; padding: var(--s-4) var(--s-5); outline: 0; cursor: text; }
.re-area[hidden] { display: none; }
.re-area figure { position: relative; cursor: pointer; user-select: none; }
.re-area figure.is-selected { outline: 2px solid var(--ink); outline-offset: 4px; border-radius: var(--r-card); }
/* A wide photo stays inside the editor: there is no room past the text's end here. */
.re-area.prose figure.size-wide { margin-inline-end: 0; }
.re-area .embed-video iframe { pointer-events: none; }
.re-area :is(th, td) { min-width: 80px; }
.re-source { min-height: 320px; border: 0; border-radius: var(--r-control); padding: var(--s-3); font-family: ui-monospace, monospace; font-size: 14px; }
.re-source[hidden] { display: none; }
.re-status { min-height: 0; margin: 0; padding-inline: var(--s-3); }
.re-status:not(:empty) { padding-block: var(--s-2); border-block-start: 1px solid var(--line); }
.rich-editor[aria-busy="true"] .re-area { opacity: 0.7; }
@media (max-width: 600px) {
  .re-area { padding: var(--s-3); }
  .re-group + .re-group { padding-inline-start: 0; border-inline-start: 0; }
}

/* Its dialogs (link, photo, video). */
.re-dialog { width: min(520px, calc(100vw - 2 * var(--s-4))); max-height: calc(100dvh - 2 * var(--s-4)); padding: var(--s-5); border: 0; border-radius: var(--r-panel); background: var(--surface); color: var(--ink); box-shadow: var(--shadow-float); }
.re-dialog[open] { display: flex; flex-direction: column; gap: var(--s-4); }
.re-dialog::backdrop { background: rgb(0 0 0 / 0.5); }
.re-dialog h2 { margin: 0; font-size: 18px; font-weight: 500; }
.re-dialog [hidden] { display: none; }
.re-dialog[aria-busy="true"] { cursor: progress; }
.re-dialog-error { margin: 0; color: var(--danger-ink); font-size: 14px; }
.re-pick { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s-2); }
/* A fixed box, so the dialog doesn't grow under the pointer when the photo loads. */
.re-preview { display: block; width: 100%; height: 180px; border-radius: var(--r-row); object-fit: contain; background: var(--raised); }
/* The link search's matches, under its box. */
.re-link-find { position: relative; }
.re-results { max-height: 280px; margin: 0; padding: var(--s-1); overflow-y: auto; list-style: none; border: 1px solid var(--line-strong); border-radius: var(--r-control); background: var(--surface); }
.re-results[hidden] { display: none; }
.re-results [role="option"] { display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px var(--s-2); padding: var(--s-2); border-radius: var(--r-row); cursor: pointer; }
.re-results [role="option"]:hover, .re-results [role="option"][aria-selected="true"] { background: var(--raised); }
.re-result-kind { flex: 0 0 auto; padding: 0 6px; border-radius: var(--r-tag); background: var(--raised); color: var(--ink-2); font-size: 12px; }
.re-results [aria-selected="true"] .re-result-kind { background: var(--surface); }
.re-result-label { font-weight: 500; }
.re-result-hint { flex-basis: 100%; color: var(--ink-3); font-size: 13px; }
.re-results-empty { padding: var(--s-2); color: var(--ink-3); font-size: 14px; }

/* Categories and brands (AdminCatalogue): two folding cards (details) with a search box over each list. Below 1024px
   they fold and the page scrolls as a whole. From 1024px they sit side by side and fill the screen under the page
   header, each list scrolling inside its card; there the cards can't be folded (the forced content needs
   ::details-content, so a browser without it still opens them by their heading). */
.data-table[hidden], .data-table tr[hidden] { display: none; }
.list-filter-empty { margin: var(--s-3) 0 0; font-size: 14px; }

.catalogue-lists { display: grid; gap: var(--s-4); }
.catalogue-list > summary { display: flex; align-items: center; justify-content: space-between; gap: var(--s-3); min-height: 40px; list-style: none; cursor: pointer; }
.catalogue-list > summary::-webkit-details-marker { display: none; }
.catalogue-list > summary .panel-title { margin: 0; }
.catalogue-list > summary .icon { flex: none; color: var(--ink-3); transition: transform 120ms; }
.catalogue-list[open] > summary { margin-block-end: var(--s-3); }
.catalogue-list[open] > summary .icon { transform: rotate(180deg); }
.catalogue-list > summary:focus-visible { outline: var(--focus-ring); outline-offset: 2px; border-radius: var(--r-row); }
.list-search { margin-block-end: var(--s-3); }

@media (min-width: 1024px) {
  .admin .admin-main:has(> .catalogue-lists) { display: flex; flex-direction: column; height: 100dvh; padding-block-end: var(--s-8); }
  .catalogue-lists { flex: 1; min-height: 0; grid-template-columns: repeat(2, minmax(0, 1fr)); grid-template-rows: minmax(0, 1fr); }
  .catalogue-list { display: grid; grid-template-rows: auto minmax(0, 1fr); min-height: 0; }
  .catalogue-list-body { height: 100%; display: flex; flex-direction: column; }
  .catalogue-list-scroll { flex: 1; min-height: 0; overflow-y: auto; }
}

@supports selector(::details-content) {
  @media (min-width: 1024px) {
    .catalogue-list::details-content { content-visibility: visible; min-height: 0; }
    .catalogue-list > summary { margin-block-end: var(--s-3); cursor: default; }
    .catalogue-list > summary .icon { display: none; }
  }
}
