/* QR Pages — app chrome (login, dashboard, editor, admin).
   Apple-style system: grouped surfaces, one tint colour, translucent bars, press feedback.
   The public page (page.css) is the owner's own design and is intentionally not styled here. */

:root {
  color-scheme: light dark;
  --bg: #f2f2f7;
  --surface: #ffffff;
  --fill: rgba(118, 118, 128, .12);       /* grey fill for inputs, segmented tracks, icon buttons */
  --fill-strong: rgba(118, 118, 128, .2);
  --text: #1d1d1f;
  --text-2: #6e6e73;                       /* secondary label: 5.0:1 on white, 4.6:1 on --bg */
  --sep: rgba(60, 60, 67, .16);
  --tint: #0071e3;                         /* filled buttons: white text 4.6:1 */
  --tint-text: #0066cc;                    /* tinted text/links: 5.6:1 on white */
  --tint-soft: rgba(0, 113, 227, .1);
  --danger: #d70015;
  --danger-soft: rgba(255, 59, 48, .1);
  --ok: #1a7f37;
  --ok-soft: rgba(52, 199, 89, .14);
  --warn: #a64b00;
  --warn-soft: rgba(255, 149, 0, .16);
  --bar: rgba(249, 249, 251, .78);
  --shadow: 0 1px 2px rgba(0, 0, 0, .04), 0 4px 16px rgba(0, 0, 0, .04);
  --r-lg: 16px; --r-md: 12px; --r-sm: 10px;
  --press: cubic-bezier(.2, .8, .2, 1);
  --sheet: cubic-bezier(.32, .72, 0, 1);  /* iOS sheet curve */
  /* kept for older selectors */
  --primary: var(--tint); --muted: var(--text-2); --line: var(--sep); --card: var(--surface); --radius: var(--r-lg);
  font: 100%/1.55 -apple-system, BlinkMacSystemFont, system-ui, "SF Arabic", "Segoe UI", Tahoma, "Noto Sans Arabic", sans-serif;
  -webkit-font-smoothing: antialiased;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #000000; --surface: #1c1c1e; --fill: rgba(118, 118, 128, .24); --fill-strong: rgba(118, 118, 128, .36);
    --text: #f5f5f7; --text-2: #a1a1a6; --sep: rgba(84, 84, 88, .55);
    --tint-text: #4da3ff; --tint-soft: rgba(10, 132, 255, .2);
    --danger: #ff6961; --danger-soft: rgba(255, 69, 58, .18); --ok: #30d158; --ok-soft: rgba(48, 209, 88, .18);
    --warn: #ffb340; --warn-soft: rgba(255, 159, 10, .2);
    --bar: rgba(22, 22, 24, .76); --shadow: none;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; -webkit-tap-highlight-color: transparent; }
body { margin: 0; background: var(--bg); color: var(--text); }
a { color: var(--tint-text); text-decoration: none; }
a:hover { text-decoration: underline; }
/* Arabic letters join: never letter-space Arabic text; hierarchy comes from size + weight + leading. */
h1 { font-size: 1.75rem; line-height: 1.2; font-weight: 700; margin: 0 0 .5rem; }
h2 { font-size: 1.0625rem; line-height: 1.35; font-weight: 600; margin: 0 0 .75rem; }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.muted { color: var(--text-2); }
.small { font-size: .8125rem; }
.hint { color: var(--text-2); font-size: .8125rem; margin: -.35rem 0 .9rem; }
.error-text { color: var(--danger); }
.ok { color: var(--ok); }
.warn { color: var(--warn); }

/* ---------- top bar: translucent material, content scrolls underneath ---------- */
.topbar {
  position: sticky; top: 0; z-index: 30;
  display: flex; justify-content: space-between; align-items: center; gap: .75rem; flex-wrap: wrap;
  padding: .35rem max(1rem, env(safe-area-inset-right)) .35rem max(1rem, env(safe-area-inset-left));
  min-height: 52px; background: var(--bar);
  -webkit-backdrop-filter: saturate(180%) blur(20px); backdrop-filter: saturate(180%) blur(20px);
  box-shadow: 0 .5px 0 var(--sep);
}
.brand { font-weight: 700; font-size: 1.0625rem; color: var(--text); display: inline-flex; align-items: center; gap: .5rem; }
.brand::before {
  content: ""; width: 26px; height: 26px; border-radius: 7px; flex-shrink: 0;
  background:
    linear-gradient(#fff 0 0) 6px 6px / 5px 5px no-repeat,
    linear-gradient(#fff 0 0) 15px 6px / 5px 5px no-repeat,
    linear-gradient(#fff 0 0) 6px 15px / 5px 5px no-repeat,
    linear-gradient(#fff 0 0) 15px 15px / 3px 3px no-repeat,
    linear-gradient(135deg, #0a84ff, #5e5ce6);
}
.brand:hover { text-decoration: none; }
.topbar nav { display: flex; align-items: center; gap: .15rem; flex-wrap: wrap; }
.topbar nav form { margin: 0; }
.navlink { display: inline-flex; align-items: center; min-height: 44px; padding: 0 .7rem; color: var(--tint-text); border-radius: var(--r-sm); font-weight: 500; }
.navlink:hover { background: var(--fill); text-decoration: none; }
.topbar .btn.ghost { color: var(--text-2); }

/* ---------- layout ---------- */
main { max-width: 720px; margin: 1.25rem auto 2rem; padding: 0 1rem; }
main.wide { max-width: 1200px; }
.page-head { margin: .5rem .25rem 1.25rem; }
.page-head > a.muted { display: inline-flex; align-items: center; min-height: 44px; color: var(--tint-text); font-weight: 500; }
.card { background: var(--surface); border-radius: var(--r-lg); padding: 1.1rem 1.1rem; margin-bottom: 1rem; box-shadow: var(--shadow); }
.link-line { color: var(--text-2); font-size: .875rem; }
.link-line code, .link-line a { word-break: break-all; font-size: .8125rem; font-family: ui-monospace, "SF Mono", Menlo, monospace; }

/* ---------- forms ---------- */
label { display: block; margin-bottom: .9rem; font-weight: 500; font-size: .9375rem; }
input[type=text], input[type=email], input[type=password], input[type=url], input[type=tel], input:not([type]), textarea, .ctl select {
  display: block; width: 100%; margin-top: .35rem; min-height: 44px; padding: .6rem .8rem;
  border: 0; border-radius: var(--r-sm); background: var(--fill); color: var(--text);
  font: inherit; font-size: 1rem; /* 16px stops iOS zooming on focus */
  transition: background-color .15s, box-shadow .15s;
}
input::placeholder, textarea::placeholder { color: var(--text-2); opacity: .8; }
input:focus, textarea:focus, .ctl select:focus { outline: none; background: var(--surface); box-shadow: 0 0 0 1px var(--tint), 0 0 0 4px var(--tint-soft); }
textarea { resize: vertical; line-height: 1.6; }
.ctl select { appearance: none; -webkit-appearance: none; padding-inline-end: 2.2rem; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 8'%3E%3Cpath d='M1 1.5l5 5 5-5' fill='none' stroke='%238e8e93' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-size: 12px 8px; background-repeat: no-repeat; background-position: left .9rem center; }
input[type=color] { -webkit-appearance: none; appearance: none; background: none; border: 0; padding: 0; cursor: pointer; }
input[type=color]::-webkit-color-swatch-wrapper { padding: 0; }
input[type=color]::-webkit-color-swatch { border: 0; border-radius: 50%; box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .12); }
input[type=color]::-moz-color-swatch { border: 0; border-radius: 50%; }

/* ---------- buttons: feedback on press, instantly ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .35rem;
  min-height: 44px; padding: 0 1rem; border: 0; border-radius: var(--r-md);
  background: var(--fill); color: var(--tint-text); font: inherit; font-size: .9375rem; font-weight: 600;
  cursor: pointer; white-space: nowrap; text-decoration: none; user-select: none;
  transition: transform .1s var(--press), background-color .15s, opacity .15s;
}
.btn:hover { background: var(--fill-strong); text-decoration: none; }
.btn:active:not(:disabled) { transform: scale(.97); }
.btn:focus-visible { outline: 2px solid var(--tint); outline-offset: 2px; }
.btn:disabled { opacity: .4; cursor: default; }
.btn.primary { background: var(--tint); color: #fff; }
.btn.primary:hover { background: #0062c4; }
.btn.danger { background: var(--danger-soft); color: var(--danger); }
.btn.ghost { background: transparent; }
.btn.ghost:hover { background: var(--fill); }
.btn.small { padding: 0 .65rem; min-width: 44px; font-size: 1rem; }
.toggle-btn[aria-pressed="true"] { background: var(--tint); color: #fff; }
.file-btn { position: relative; overflow: hidden; }
.file-btn input { position: absolute; inset: 0; opacity: 0; cursor: pointer; font-size: 0; }
.file-btn:focus-within { outline: 2px solid var(--tint); outline-offset: 2px; }

/* ---------- status messages ---------- */
.error, .notice { padding: .75rem .9rem; border-radius: var(--r-md); margin: 0 0 1rem; font-size: .9375rem; }
.error { background: var(--danger-soft); color: var(--danger); }
.notice { background: var(--ok-soft); color: var(--ok); }
.credentials p { margin: 0 0 .5rem; color: var(--text); }
.credentials dl { display: grid; grid-template-columns: auto 1fr; gap: .4rem .9rem; margin: 0; text-align: left; padding: .7rem .8rem; background: var(--surface); border-radius: var(--r-sm); }
.credentials dt { font-weight: 600; color: var(--text-2); }
.credentials dd { margin: 0; color: var(--text); }
.credentials code { font-size: 1.0625rem; user-select: all; word-break: break-all; font-family: ui-monospace, "SF Mono", Menlo, monospace; }

.badge { display: inline-flex; align-items: center; padding: .1rem .55rem; border-radius: 99px; font-size: .75rem; font-weight: 600; line-height: 1.5; }
.badge.on { background: var(--ok-soft); color: var(--ok); }
.badge.off, .badge.hidden { background: var(--fill); color: var(--text-2); }
.badge.new { background: transparent; color: var(--text-2); box-shadow: inset 0 0 0 1px var(--sep); }
.badge.changes { background: var(--warn-soft); color: var(--warn); }

/* ---------- login ---------- */
.auth { max-width: 400px; margin: 10vh auto 2rem; padding: 1.75rem 1.4rem; }
.auth h1 { text-align: center; margin-bottom: 1.25rem; }
.auth .btn.primary { width: 100%; min-height: 50px; font-size: 1.0625rem; margin-top: .35rem; }
.auth > p.muted { text-align: center; font-size: .875rem; margin: 1.1rem 0 0; }

/* ---------- dashboard ---------- */
.create { display: flex; gap: .6rem; align-items: flex-end; flex-wrap: wrap; }
.create label { flex: 1; min-width: 200px; margin: 0; }
.qr-list { list-style: none; padding: 0; margin: 0; }
/* Row: QR tile at the start, title + status beside it, actions underneath across the full card. */
.qr-item { display: grid; grid-template-columns: 76px minmax(0, 1fr); column-gap: .9rem; align-items: start; }
.qr-thumb { grid-row: 1 / span 3; width: 76px; height: 76px; border-radius: var(--r-md); background: #fff; padding: 4px; box-shadow: 0 0 0 1px var(--sep); }
.qr-info { display: contents; }
.qr-info h2 { margin: .1rem 0 .15rem; font-size: 1.0625rem; overflow-wrap: anywhere; }
.qr-info h2 a { color: var(--text); }
.qr-info p { margin: 0 0 .15rem; font-size: .875rem; }
.qr-info .link-line code { display: block; direction: ltr; text-align: right; line-height: 1.4; }
.actions { grid-column: 1 / -1; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: .5rem; margin-top: .9rem; }
.actions > .btn:first-child { grid-column: 1 / -1; background: var(--tint); color: #fff; }
.actions > .btn:first-child:hover { background: #0062c4; }
.actions .btn { padding: 0 .4rem; font-size: .875rem; }
.actions form { margin: 0; display: contents; }
.empty { text-align: center; color: var(--text-2); }
.empty-state { text-align: center; padding: 2.25rem 1.25rem; }
.empty-state h2 { margin: 0 0 .35rem; font-size: 1.25rem; }
.empty-state ol { list-style: none; padding: 0; margin: 1.25rem auto 0; max-width: 320px; text-align: start; display: grid; gap: .7rem; }
.empty-state li { display: flex; gap: .75rem; align-items: center; }
.empty-state li span { flex-shrink: 0; width: 30px; height: 30px; border-radius: 50%; background: var(--tint-soft); color: var(--tint-text); display: grid; place-items: center; font-weight: 700; font-size: .875rem; }

/* ---------- admin / account ---------- */
.user-list { list-style: none; padding: 0; margin: 0; }
.user-head { display: flex; align-items: center; gap: .5rem; }
.user-head h2 { margin: 0; word-break: break-all; }
.user-item p { margin: .15rem 0 0; font-size: .875rem; }
.user-item .actions { display: flex; flex-wrap: wrap; }
.user-item .actions > .btn:first-child { grid-column: auto; }
.inline-form { display: flex; gap: .5rem; flex: 1; min-width: 220px; }
.inline-form input { margin: 0; flex: 1; }
.inline-form .btn { background: var(--fill); color: var(--tint-text); }

/* ---------- editor ---------- */
.editor { display: grid; grid-template-columns: minmax(0, 1fr) 380px; gap: 1.75rem; align-items: start; }
.editor-form > h2 { margin: 1.5rem .25rem .6rem; font-size: 1.25rem; font-weight: 700; }
.editor-preview { position: sticky; top: 68px; }
.editor-preview > h2 { font-size: .875rem; font-weight: 600; color: var(--text-2); margin-bottom: .6rem; text-align: center; }
.editor-preview > h2 .muted { font-weight: 400; }
.phone {
  height: 760px; max-height: calc(100vh - 120px); background: #fff; overflow: hidden;
  border-radius: 44px; border: 11px solid #1d1d1f;
  box-shadow: 0 0 0 1px #3a3a3c, 0 24px 48px -12px rgba(0, 0, 0, .25);
}
.phone iframe { width: 100%; height: 100%; border: 0; display: block; }
.blocks { list-style: none; padding: 0; margin: 0; }
.block { transition: box-shadow .2s; }
.block-head { display: flex; justify-content: space-between; align-items: center; gap: .5rem; margin-bottom: .75rem; }
.block-head strong { font-size: 1rem; font-weight: 600; }
.block-head .row { gap: .35rem; flex-wrap: nowrap; flex-shrink: 0; }
.block-head .btn.small { min-width: 40px; width: 44px; padding: 0; border-radius: 50%; background: var(--fill); color: var(--text); font-size: 1rem; }
.block-head .btn.small.danger { background: var(--danger-soft); color: var(--danger); }
.block-head .btn.small:disabled { opacity: .3; }
.block.has-error { box-shadow: 0 0 0 2px var(--danger), var(--shadow); }
.publish-error { margin: 0 0 .9rem; }
.publish-error button { background: none; border: 0; padding: 0; color: inherit; font: inherit; text-decoration: underline; cursor: pointer; min-height: 0; }
.row { display: flex; gap: .6rem; align-items: center; flex-wrap: wrap; }
.check { display: flex; gap: .6rem; align-items: center; margin: 0; min-height: 44px; cursor: pointer; }
.check input { width: 22px; height: 22px; accent-color: var(--tint); }
.color { display: inline-flex; gap: .6rem; align-items: center; margin: 0; padding: .3rem .4rem .3rem .75rem; border-radius: var(--r-md); background: var(--fill); }
.color input, .color-ctl input[type=color] { width: 36px; height: 36px; margin: 4px; }
.color-ctl { display: flex; align-items: center; gap: .6rem; flex-wrap: wrap; }
.color-ctl .is-auto { font-size: .8125rem; color: var(--text-2); }
.contrast-hint { font-size: .8125rem; color: var(--warn); }
.image-picker { margin-bottom: .9rem; }
.image-picker .label, .add .label { display: block; font-weight: 500; font-size: .9375rem; margin-bottom: .4rem; }
.thumb { display: block; max-width: 180px; max-height: 120px; border-radius: var(--r-md); margin-bottom: .6rem; object-fit: cover; box-shadow: 0 0 0 1px var(--sep); }
.add { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; }
.add .label { width: 100%; }

/* vertical rhythm between stacked controls inside a card */
.card > .ctl, .card > .row, .card > .style-grid { margin-bottom: 1rem; }

/* collapsible "تنسيق" panel */
.style-panel { margin-top: .4rem; border-top: .5px solid var(--sep); }
.style-panel > summary { list-style: none; display: flex; align-items: center; gap: .5rem; min-height: 48px; cursor: pointer; font-weight: 600; color: var(--tint-text); }
.style-panel > summary::-webkit-details-marker { display: none; }
.style-panel > summary::before {
  content: ""; width: 8px; height: 8px; border: solid currentColor; border-width: 0 0 2px 2px; flex-shrink: 0;
  transform: rotate(45deg); transition: transform .3s var(--sheet); margin-inline: .15rem .1rem;
}
.style-panel[open] > summary::before { transform: rotate(-45deg); }
.style-panel .style-summary { color: var(--text-2); font-weight: 400; font-size: .8125rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.style-panel[open] > .style-grid { animation: reveal .3s var(--sheet); }
.style-grid { display: grid; gap: 1rem; padding: .25rem 0 .5rem; }
.ctl { display: grid; gap: .4rem; }
.ctl > .ctl-label { font-size: .8125rem; font-weight: 500; color: var(--text-2); }

/* iOS segmented control: grey track, raised white thumb on the selected option */
.seg { display: inline-flex; padding: 2px; border-radius: 11px; background: var(--fill); max-width: 100%; }
.seg label { margin: 0; font-weight: 500; font-size: .875rem; }
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg span {
  display: inline-flex; align-items: center; justify-content: center; min-width: 44px; min-height: 40px; padding: 0 .75rem;
  border-radius: 9px; cursor: pointer; white-space: nowrap; color: var(--text);
  transition: background-color .2s var(--press), box-shadow .2s var(--press), transform .1s var(--press);
}
.seg label:active span { transform: scale(.96); }
.seg input:checked + span { background: var(--surface); box-shadow: 0 3px 8px rgba(0, 0, 0, .12), 0 1px 1px rgba(0, 0, 0, .04); font-weight: 600; }
@media (prefers-color-scheme: dark) { .seg input:checked + span { background: #636366; } }
.seg input:focus-visible + span { outline: 2px solid var(--tint); outline-offset: -2px; }
.seg svg { width: 20px; height: 20px; fill: currentColor; }
.ctl .seg { display: flex; width: 100%; }
.ctl .seg label { flex: 1; min-width: 0; }
.ctl .seg span { width: 100%; padding: 0 .35rem; }

.social-fields label { display: grid; grid-template-columns: 30px 1fr; align-items: center; column-gap: .6rem; }
.social-fields label .soc-mini { width: 30px; height: 30px; border-radius: 8px; display: grid; place-items: center; grid-row: span 2; color: #fff; }
.social-fields label .soc-mini svg { width: 16px; height: 16px; fill: currentColor; }
.social-fields input { grid-column: 2; }

/* theme presets */
.themes { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: .6rem; margin-bottom: .25rem; }
.theme-swatch {
  display: grid; gap: .4rem; justify-items: center; align-content: center; min-height: 92px; padding: .65rem .4rem;
  border: 0; border-radius: 14px; cursor: pointer; font: inherit;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .08);
  transition: transform .1s var(--press), box-shadow .2s;
}
.theme-swatch:active { transform: scale(.96); }
.theme-swatch .sw-text { font-size: 1.25rem; line-height: 1; }
.theme-swatch .sw-btn { width: 64%; height: 12px; border-radius: 99px; }
.theme-swatch .sw-name { font-size: .75rem; font-weight: 500; }
.theme-swatch[aria-pressed="true"] { box-shadow: 0 0 0 2.5px var(--tint), inset 0 0 0 1px rgba(0, 0, 0, .08); }
.theme-swatch:focus-visible { outline: 2px solid var(--tint); outline-offset: 3px; }
@media (min-width: 900px) { .themes { grid-template-columns: repeat(6, minmax(0, 1fr)); } }

/* publish state */
.state-row { display: flex; align-items: center; justify-content: space-between; gap: .75rem; flex-wrap: wrap; min-height: 44px; margin-top: -.25rem; }
.pub-state { display: inline-flex; align-items: center; gap: .5rem; font-weight: 600; font-size: .9375rem; }
.pub-state::before { content: ""; width: 9px; height: 9px; border-radius: 50%; background: var(--dot); flex-shrink: 0; box-shadow: 0 0 0 3px color-mix(in srgb, var(--dot) 22%, transparent); }
.pub-state.st-new { --dot: #8e8e93; }
.pub-state.st-live { --dot: #34c759; }
.pub-state.st-changes { --dot: #ff9500; }
.pub-state.st-hidden { --dot: #636366; }
.state-row .btn.ghost { color: var(--danger); }

/* publish bar: floating translucent toolbar */
.publishbar {
  position: sticky; bottom: 0; z-index: 20; margin: 1rem -1rem 0; padding: .6rem 1rem calc(.6rem + env(safe-area-inset-bottom));
  display: flex; align-items: center; gap: .5rem;
  background: var(--bar); -webkit-backdrop-filter: saturate(180%) blur(20px); backdrop-filter: saturate(180%) blur(20px);
  box-shadow: 0 -.5px 0 var(--sep);
}
.publishbar .save-state { flex: 1; min-width: 0; font-size: .8125rem; color: var(--text-2); display: flex; align-items: center; gap: .4rem; }
.publishbar .save-state.saving::before { content: ""; width: 12px; height: 12px; border-radius: 50%; border: 2px solid var(--fill-strong); border-top-color: var(--tint); animation: spin .8s linear infinite; flex-shrink: 0; }
.publishbar .save-state.saved { color: var(--ok); }
.publishbar .save-state.saved::before { content: "✓"; font-weight: 700; }
.publishbar .save-state.failed { color: var(--danger); }
.publishbar .btn.primary { min-width: 104px; border-radius: 99px; }
.publishbar .btn.primary:disabled { background: var(--ok-soft); color: var(--ok); opacity: 1; }
.preview-toggle { display: none; }
.sheet-head { display: none; }

@keyframes spin { to { transform: rotate(360deg); } }
@keyframes reveal { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: none; } }
@keyframes sheet-in { from { transform: translateY(100%); } to { transform: none; } }

/* ---------- phone layout ---------- */
@media (max-width: 900px) {
  .editor { grid-template-columns: 1fr; }
  .preview-toggle { display: inline-flex; border-radius: 99px; }
  .editor-preview { display: none; position: static; }
  /* preview opens as a sheet rising from the bottom bar that opened it */
  .editor-preview.sheet-open {
    display: flex; flex-direction: column; position: fixed; inset: 0; z-index: 40;
    padding: max(.6rem, env(safe-area-inset-top)) .6rem calc(.6rem + env(safe-area-inset-bottom));
    background: rgba(0, 0, 0, .92); -webkit-backdrop-filter: blur(20px); backdrop-filter: blur(20px);
    animation: sheet-in .45s var(--sheet);
  }
  .editor-preview.sheet-open > h2 { display: none; }
  .sheet-head { display: flex; align-items: center; justify-content: space-between; gap: .5rem; color: #fff; padding: 0 .35rem .6rem; }
  .sheet-head strong { font-size: 1.0625rem; }
  .sheet-head .btn { background: rgba(255, 255, 255, .16); color: #fff; border-radius: 99px; }
  .editor-preview.sheet-open .phone { flex: 1; height: auto; max-height: none; border: 0; border-radius: 22px; box-shadow: none; }
}
@media (max-width: 520px) {
  main { margin-top: .75rem; padding: 0 .75rem; }
  .card { padding: 1rem .9rem; }
  .publishbar { margin: 1rem -.75rem 0; padding-inline: .75rem; }
  h1 { font-size: 1.625rem; }
  .create .btn { width: 100%; }
  .topbar { padding-inline: .75rem; }
  .navlink { padding: 0 .5rem; }
  /* one-row bar on phones: the mark stays, the name is kept for screen readers only */
  .brand { font-size: 0; gap: 0; }
  .brand::before { width: 30px; height: 30px; background-position: 7px 7px, 18px 7px, 7px 18px, 18px 18px, 0 0; background-size: 6px 6px, 6px 6px, 6px 6px, 4px 4px, auto; }
  .topbar { flex-wrap: nowrap; }
}

/* ---------- accessibility preferences ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before { animation-duration: .01ms !important; transition-duration: .01ms !important; }
  .editor-preview.sheet-open { animation: fade .2s ease; }
  .btn:active:not(:disabled), .seg label:active span, .theme-swatch:active { transform: none; }
}
@keyframes fade { from { opacity: 0; } }
@media (prefers-reduced-transparency: reduce) {
  .topbar, .publishbar { background: var(--surface); -webkit-backdrop-filter: none; backdrop-filter: none; }
}
@media (prefers-contrast: more) {
  :root { --text-2: #3a3a3c; --sep: rgba(0, 0, 0, .5); }
  .card, input, textarea, .seg { box-shadow: 0 0 0 1px var(--sep); }
}
/* touch targets: the whole brand link and the standalone colour well are ≥44px */
.brand { min-height: 44px; min-width: 44px; }
.color-ctl input[type=color] { width: 44px; height: 44px; margin: 0; }
