/* PHILOCALIST · Artist Studio — tokens from the Artist Studio designs */
:root {
  /* Colours, shadows and overlays come from core/design_tokens.py ({{ design_tokens_css }} in each base template). */
  --radius: 8px;
  --radius-sm: 6px;
  --ease: cubic-bezier(.2, .7, .2, 1);
  --dur: .18s;
  --serif: "Source Serif 4", "Source Serif Pro", Georgia, serif;
  --sans: "Source Serif 4", Georgia, serif;
  --ar-display: "Amiri", "Alexandria", serif;
  --ar-body: "Alexandria", "IBM Plex Sans Arabic", system-ui, sans-serif;
}
[dir="rtl"] { --serif: var(--ar-display); --sans: var(--ar-body); }

* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink); }
body { font-family: var(--sans); font-size: 14px; line-height: 1.5; }
[dir="rtl"] body { font-size: 13.5px; }
a { color: inherit; text-decoration: none; }
h1, h2, h3 { font-family: var(--serif); font-weight: 400; margin: 0; color: var(--ink); }
h1 { font-size: 32px; line-height: 1.2; }
h2 { font-size: 22px; }
h3 { font-size: 17px; }
[dir="rtl"] h1 { font-weight: 700; font-size: 34px; }
[dir="rtl"] h2 { font-weight: 700; }
p { margin: 0; }
img { max-width: 100%; display: block; }
button, input, select, textarea { font: inherit; color: inherit; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.danger-text { color: var(--primary); }
.num { font-variant-numeric: tabular-nums; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* ---------- Shell ---------- */
.shell { display: grid; grid-template-columns: 232px 1fr; min-height: 100vh; }
.side { background: var(--side); border-inline-end: 1px solid var(--line); padding: 26px 18px 18px;
  display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; }
.side .brand { letter-spacing: .16em; font-family: var(--serif); font-size: 14px; font-weight: 600; padding: 0 10px; }
[dir="rtl"] .side .brand { letter-spacing: .1em; font-family: Georgia, serif; }
.side .brand { display: flex; align-items: center; gap: 10px; }
.side .brand-mark { display: none; }
.side .brand small { display: block; letter-spacing: 0; font-weight: 400; color: var(--muted); font-size: 12.5px; }
.side nav { margin-top: 30px; display: flex; flex-direction: column; gap: 2px; }
.side nav a { display: flex; align-items: center; gap: 10px; padding: 7px 10px; border-radius: var(--radius-sm);
  color: var(--ink-2); font-size: 14px; }
.side nav a:hover { background: var(--soft-2); }
.side nav a[aria-current="page"] { background: var(--bg); color: var(--ink); box-shadow: 0 0 0 1px var(--line); }
.side nav a .count { margin-inline-start: auto; background: var(--primary); color: var(--primary-ink); border-radius: 99px;
  font-size: 11px; min-width: 18px; text-align: center; padding: 0 5px; }
.side nav hr { border: 0; border-top: 1px solid var(--line-strong); margin: 14px 10px; }
.side .me { margin-top: auto; display: flex; gap: 10px; align-items: center; padding: 10px; }
.side .me small { display: block; color: var(--muted); font-size: 12px; }
.side .me-text { min-width: 0; }
.workspace { min-width: 0; }
.side-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.side nav a .nav-text { flex: 1; min-width: 0; }
/* Phone/tablet-only pieces stay out of the desktop layout. */
.shell .side-close, .shell .side-foot, .shell .side-backdrop, .shell .nav-toggle, .shell .top-brand, .shell .search-toggle, .shell .tabbar { display: none; }
.add-work .nav-text { display: inline; }
.avatar { width: 34px; height: 34px; border-radius: 50%; background: var(--avatar); flex: none; display: grid;
  place-items: center; font-size: 12px; color: var(--ink-2); overflow: hidden; }
.avatar.lg { width: 76px; height: 76px; font-size: 22px; }
.avatar.xl { width: 92px; height: 92px; font-size: 26px; }
.avatar img { width: 100%; height: 100%; object-fit: cover; }

.top { display: flex; align-items: center; gap: 14px; padding: 12px 28px; border-bottom: 1px solid var(--line);
  position: sticky; top: 0; background: var(--glass); backdrop-filter: saturate(1.4) blur(10px); z-index: 5; }
.search { flex: 0 1 380px; display: flex; align-items: center; gap: 8px; background: var(--soft); border-radius: var(--radius-sm);
  padding: 7px 12px; color: var(--muted); }
.search input { border: 0; background: transparent; outline: none; flex: 1; min-width: 0; }
.top .spacer { flex: 1; }
.icon-btn { width: 34px; height: 34px; border-radius: 50%; background: var(--soft); display: grid; place-items: center;
  position: relative; border: 0; cursor: pointer; }
.icon-btn .dot { position: absolute; top: 7px; inset-inline-end: 8px; width: 6px; height: 6px; background: var(--primary); border-radius: 50%; }
.lang-switch { font-size: 13px; color: var(--muted); border: 1px solid var(--line); border-radius: 99px; padding: 4px 12px; }

.main { padding: 28px 28px 56px; max-width: 1180px; width: 100%; }
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 22px; }
.page-head .sub { color: var(--muted); margin-top: 6px; }
.page-head .actions { display: flex; gap: 10px; flex-wrap: wrap; }
.crumbs { color: var(--muted); font-size: 12.5px; margin-bottom: 6px; }
.crumbs a:hover { color: var(--ink); }

/* ---------- Buttons & inputs ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; border-radius: var(--radius-sm);
  padding: 8px 16px; font-size: 13.5px; border: 1px solid transparent; cursor: pointer; background: var(--soft);
  color: var(--ink); white-space: nowrap; line-height: 1.3; }
.btn:hover { filter: brightness(.97); }
.btn.primary { background: var(--primary); color: var(--primary-ink); }
.btn.outline { background: var(--bg); border-color: var(--primary); color: var(--primary); }
.btn.ghost { background: transparent; }
.btn.dark { background: var(--dark); color: var(--primary-ink); }
.btn.sm { padding: 5px 12px; font-size: 12.5px; }
.btn.block { width: 100%; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
.link { color: var(--primary); font-size: 13px; cursor: pointer; background: none; border: 0; padding: 0; }
.link:hover { text-decoration: underline; }

.field { display: flex; flex-direction: column; gap: 5px; }
.field label, .label { font-size: 12.5px; color: var(--ink-2); }
.input, select.input, textarea.input { border: 1px solid var(--line-strong); border-radius: var(--radius-sm); padding: 8px 11px;
  background: var(--bg); width: 100%; outline: none; }
.input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
.input.error { border-color: var(--primary); }
textarea.input { min-height: 84px; resize: vertical; }
select.input { appearance: none; -webkit-appearance: none; padding-inline-end: 30px; cursor: pointer;
  background-color: var(--bg); appearance: auto; -webkit-appearance: auto; }
[dir="rtl"] select.input { background-position: left 11px center; }
select.input[multiple] { background-image: none; padding-inline-end: 11px; }
.row { display: flex; gap: 12px; align-items: center; }
.row.wrap { flex-wrap: wrap; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.stack { display: flex; flex-direction: column; gap: 12px; }
.stack.sm { gap: 6px; }
.between { display: flex; justify-content: space-between; align-items: center; gap: 12px; }

.switch { position: relative; width: 34px; height: 19px; flex: none; }
.switch input { opacity: 0; width: 0; height: 0; position: absolute; }
.switch span { position: absolute; inset: 0; background: var(--line-strong); border-radius: 99px; transition: .15s; cursor: pointer; }
.switch span::after { content: ""; position: absolute; top: 3px; inset-inline-start: 3px; width: 13px; height: 13px;
  background: var(--bg); border-radius: 50%; transition: .15s; }
.switch input:checked + span { background: var(--primary); }
.switch input:checked + span::after { inset-inline-start: 18px; }
.toggle-row { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 7px 0; }
.toggle-row .hint { display: block; color: var(--muted); font-size: 12px; }

.check { display: inline-flex; gap: 9px; align-items: center; cursor: pointer; }
.check input { accent-color: var(--primary); width: 15px; height: 15px; }
.radio-card { display: flex; justify-content: space-between; align-items: center; gap: 12px; border: 1px solid var(--line);
  border-radius: var(--radius-sm); padding: 10px 14px; cursor: pointer; }
.radio-card:has(input:checked) { border-color: var(--primary); background: var(--soft); }
.radio-card input { accent-color: var(--primary); }
.radio-card .hint { color: var(--muted); font-size: 12.5px; }

.seg { display: inline-flex; background: var(--soft); border-radius: var(--radius-sm); padding: 3px; }
.seg a, .seg label { padding: 5px 14px; border-radius: 5px; cursor: pointer; font-size: 13px; }
.seg a.on, .seg label:has(input:checked) { background: var(--bg); box-shadow: 0 0 0 1px var(--line); }
.seg.dark a.on { background: var(--dark); color: var(--primary-ink); box-shadow: none; }
.seg input { display: none; }
.pills { display: flex; gap: 6px; flex-wrap: wrap; }
.pill { border: 1px solid var(--line-strong); border-radius: 99px; padding: 3px 13px; font-size: 12.5px; cursor: pointer; background: var(--bg); }
.pill.on, .pill:has(input:checked) { background: var(--dark); color: var(--primary-ink); border-color: var(--dark); }
.pill input { display: none; }

/* ---------- Cards, chips, tables ---------- */
.card { border: 1px solid var(--line); border-radius: var(--radius); background: var(--bg); padding: 18px 20px; }
.card.soft { background: var(--soft); border-color: var(--soft); }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 14px; }
.card-head .link { white-space: nowrap; }
.cols { display: grid; grid-template-columns: minmax(0, 1.55fr) minmax(0, 1fr); gap: 16px; align-items: start; }
.cols.even { grid-template-columns: 1fr 1fr; }
.cols.wide-side { grid-template-columns: minmax(0, 1fr) minmax(0, 1.25fr); }

.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 16px; }
.stat { border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 16px 14px; }
.stat .k { color: var(--ink-2); font-size: 12.5px; }
.stat .v { font-family: var(--serif); font-size: 26px; line-height: 1.3; margin: 2px 0 12px; }
.stat .s { color: var(--muted); font-size: 12px; }

.chip { display: inline-block; border-radius: 99px; padding: 1px 10px; font-size: 12px; background: var(--soft-2); color: var(--ink-2); white-space: nowrap; }
.chip.acquisition, .chip.commission, .chip.reserved, .chip.needs_document, .chip.interested, .chip.awaiting,
.chip.needs-update, .chip.under_review, .chip.pending { background: var(--primary-soft); color: var(--primary); }
.chip.available, .chip.verified, .chip.collector, .chip.up-to-date, .chip.active, .chip.confirmed, .chip.paid,
.chip.protected { background: var(--olive-soft); color: var(--olive); }
.chip.dark { background: var(--dark); color: var(--primary-ink); }
.chip.lg { padding: 3px 12px; }
.tag { display: inline-block; background: var(--soft); border-radius: 99px; padding: 2px 11px; font-size: 12px; color: var(--ink-2); }

.list > * + * { border-top: 1px solid var(--line); }
.list-row { display: flex; gap: 12px; align-items: center; padding: 12px 0; }
.list-row .grow { flex: 1; min-width: 0; }
.list-row .title { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.list-row .when { color: var(--muted); font-size: 12.5px; white-space: nowrap; }
.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.table-wrap { border: 1px solid var(--line); border-radius: var(--radius); overflow: auto; }
table.t { width: 100%; border-collapse: collapse; font-size: 13.5px; }
table.t th { background: var(--side); text-align: start; font-weight: 400; color: var(--ink-2); padding: 10px 14px; font-size: 12.5px; }
table.t td { padding: 10px 14px; border-top: 1px solid var(--line); vertical-align: middle; }
table.t tr.clickable { cursor: pointer; }
table.t tr.clickable:hover td { background: var(--side); }
.work-cell { display: flex; gap: 12px; align-items: center; }
.work-cell small { display: block; color: var(--muted); font-size: 12px; }
.thumb { width: 40px; height: 40px; border-radius: 3px; background: var(--soft-2); object-fit: cover; flex: none; }
.thumb.md { width: 56px; height: 56px; }
.thumb.lg { width: 92px; height: 92px; }
.thumb.xl { width: 150px; height: 150px; }
.dots { color: var(--muted); letter-spacing: 1px; cursor: pointer; }

.tabs { display: flex; gap: 22px; border-bottom: 1px solid var(--line); margin-bottom: 18px; overflow-x: auto; }
.tabs a { padding: 8px 0 10px; color: var(--ink-2); white-space: nowrap; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tabs a[aria-current="page"], .tabs a.on { color: var(--ink); border-color: var(--ink); }
.filters { display: flex; gap: 10px; align-items: center; margin-bottom: 14px; flex-wrap: wrap; }
.filters .input { width: auto; min-width: 140px; }
.filters .grow { flex: 1; }

.steps { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; margin: 4px 0 18px; }
.steps div { border-top: 3px solid var(--line); padding-top: 8px; font-size: 13px; color: var(--ink-2); }
.steps div.on { border-color: var(--primary); color: var(--ink); }
.steps.five { grid-template-columns: repeat(5, 1fr); }
.steps.compact div { font-size: 12px; padding-top: 6px; }
.stepper { display: flex; align-items: center; gap: 12px; margin-bottom: 18px; color: var(--ink-2); flex-wrap: wrap; }
.stepper .n { display: inline-grid; place-items: center; width: 20px; height: 20px; border-radius: 50%; background: var(--soft-2); font-size: 11px; margin-inline-end: 6px; }
.stepper .on .n { background: var(--primary); color: var(--primary-ink); }
.stepper .done .n { background: var(--olive); color: var(--primary-ink); }
.stepper .line { width: 40px; height: 1px; background: var(--line-strong); }

.notice { border-inline-start: 3px solid var(--primary); background: var(--soft); padding: 12px 16px; border-radius: var(--radius-sm); margin-bottom: 18px; }
.alert { border: 1px solid var(--primary-line); background: var(--warn-bg); color: var(--primary); padding: 10px 14px; border-radius: var(--radius-sm); }
.alert p { color: var(--ink-2); font-size: 12.5px; margin-top: 2px; }
.flash { margin-bottom: 16px; padding: 10px 14px; border-radius: var(--radius-sm); background: var(--olive-soft); color: var(--olive); }
.flash.error { background: var(--primary-soft); color: var(--primary); }

.timeline { position: relative; }
.timeline .ev { display: grid; grid-template-columns: 14px 1fr auto; gap: 10px; padding: 9px 0 18px; position: relative; }
.timeline .ev::before { content: ""; position: absolute; inset-inline-start: 3px; top: 18px; bottom: -6px; width: 1px; background: var(--line-strong); }
.timeline .ev:last-child::before { display: none; }
.timeline .pin { width: 7px; height: 7px; border-radius: 50%; background: var(--sold); margin-top: 6px; }
.timeline .pin.hot { background: var(--primary); }
.timeline .pin.green { background: var(--olive); }
.timeline small { color: var(--muted); display: block; }

.progress { height: 6px; background: var(--soft-2); border-radius: 99px; overflow: hidden; margin: 12px 0 16px; }
.progress span { display: block; height: 100%; background: var(--olive); border-radius: 99px; }

.art-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.art-grid .art img, .art-grid .art .ph { aspect-ratio: 1.3; width: 100%; object-fit: cover; border-radius: 2px; background: var(--soft-2); }
.art-grid .art span { font-size: 12.5px; display: block; margin-top: 4px; }
/* Status badges under a work stay compact pills, not full-width bars. */
.art-grid .art span.chip { display: inline-block; width: auto; margin-top: 2px; font-size: 11.5px; line-height: 1.6; padding: 1px 10px; }
.chip.collected, .chip.sold, .chip.sold_out { background: var(--soft-2); color: var(--ink-2); }
.art-strip { display: flex; gap: 8px; }
.art-strip img, .art-strip .ph { width: 36px; height: 44px; object-fit: cover; background: var(--soft-2); }
.art-strip.lg img, .art-strip.lg .ph { width: 36px; height: 44px; }

/* Calendar */
.cal { display: grid; grid-template-columns: 52px repeat(7, 1fr); }
.cal .h { text-align: center; padding: 8px 0; font-size: 12.5px; color: var(--ink-2); border-bottom: 1px solid var(--line); }
.cal .h.on { color: var(--ink); font-weight: 600; }
.cal .hours { position: relative; }
.cal .hour { height: 110px; font-size: 12px; color: var(--muted); }
.cal .day { position: relative; border-inline-start: 1px solid var(--bg); background: var(--side); }
.cal .day.open { background: var(--bg); }
.cal .day .line { position: absolute; inset-inline: 0; border-top: 1px solid var(--line); }
.cal .slot { position: absolute; inset-inline: 3px; border-radius: 3px; padding: 5px 7px; font-size: 12px; overflow: hidden;
  border: 0; border-inline-start: 3px solid var(--sold); background: var(--soft-2); line-height: 1.35; color: var(--ink-2); }
.cal .slot.pending, .cal .slot.proposed { border-color: var(--primary); background: var(--primary-soft); color: var(--primary); }
.cal .slot.confirmed { border-color: var(--olive); background: var(--olive-soft); }
.cal .slot.block { border-color: var(--sold); background: var(--soft-2); color: var(--ink-2); }

/* Editions grid */
.copies { display: grid; grid-template-columns: repeat(6, 1fr); gap: 10px; }
.copy { border: 1px solid var(--line-strong); border-radius: 3px; text-align: center; padding: 10px 4px; font-size: 12px; background: var(--bg); }
.copy b { display: block; font-weight: 400; font-size: 13px; }
.copy.sold { background: var(--sold); color: var(--primary-ink); border-color: var(--sold); }
.copy.reserved { background: var(--primary-soft); border-color: var(--primary-line); }
.copy.with_gallery { background: var(--soft-2); }
.copy.artist { background: var(--soft); }
.copy.archived { opacity: .5; }

/* Modal */
dialog.modal { border: 0; border-radius: 12px; padding: 0; width: min(560px, calc(100vw - 32px)); box-shadow: var(--shadow-lg); color: var(--ink); }
dialog.modal::backdrop { background: var(--backdrop); backdrop-filter: blur(2px); }
dialog.modal.wide { width: min(720px, calc(100vw - 32px)); }
.modal-head { padding: 22px 24px 0; position: relative; }
.modal-head .eyebrow { color: var(--primary); font-size: 11.5px; letter-spacing: .08em; text-transform: uppercase; margin-bottom: 4px; }
.modal-head h2 { font-size: 24px; padding-inline-end: 30px; }
.modal-close { position: absolute; top: 18px; inset-inline-end: 18px; background: none; border: 0; font-size: 22px; cursor: pointer; color: var(--ink-2); }
.modal-body { padding: 16px 24px; display: flex; flex-direction: column; gap: 12px; }
.modal-foot { padding: 4px 24px 22px; display: flex; gap: 10px; }
.modal-foot.end { justify-content: flex-end; border-top: 1px solid var(--line); padding-top: 16px; }
.kv { display: grid; grid-template-columns: 130px 1fr; }
.kv > * { padding: 7px 0; border-bottom: 1px solid var(--line); }
.kv > :nth-child(odd) { color: var(--muted); font-size: 12.5px; }

/* Chat */
.thread { display: flex; flex-direction: column; gap: 6px; padding: 8px 0; max-height: 380px; overflow: auto; }
.bubble { max-width: 72%; padding: 10px 14px; border-radius: 6px; background: var(--soft); }
.bubble.me { align-self: flex-start; }
.bubble.them { align-self: flex-end; background: var(--bg); border: 1px solid var(--line); }
.bubble.failed { border: 1px solid var(--primary-line); background: var(--warn-bg); }
.meta { font-size: 12px; color: var(--muted); }
.meta.them { align-self: flex-end; }
.composer { border: 1px solid var(--line); border-radius: var(--radius); padding: 10px; }
.composer textarea { border: 0; width: 100%; outline: none; resize: vertical; min-height: 48px; }
.inbox { display: grid; grid-template-columns: 300px 1fr; gap: 16px; align-items: start; }
.inbox-list a { display: block; padding: 12px; border-radius: var(--radius-sm); position: relative; }
.inbox-list a.on { background: var(--soft); }
.inbox-list a .unread { position: absolute; top: 18px; inset-inline-start: 2px; width: 6px; height: 6px; border-radius: 50%; background: var(--primary); }

/* Invoice / document sheet */
.sheet { border: 1px solid var(--line); border-radius: 4px; padding: 28px 30px; box-shadow: var(--shadow-md); background: var(--bg); }
.sheet h2.big { font-size: 30px; }
.sheet table { width: 100%; border-collapse: collapse; }
.sheet .lines th { background: var(--soft); text-align: start; font-weight: 400; padding: 9px 10px; font-size: 12.5px; }
.sheet .lines td { padding: 12px 10px; border-bottom: 1px solid var(--line); }
.sheet .total { display: flex; justify-content: space-between; border-top: 1.5px solid var(--ink); padding-top: 10px; margin-top: 8px; font-family: var(--serif); font-size: 20px; }
.end-text { text-align: end; }
.doc-preview { background: var(--side); border-radius: var(--radius); padding: 14px; }

.map { height: 150px; border-radius: var(--radius-sm); background:
  repeating-linear-gradient(0deg, transparent 0 23px, var(--line) 23px 24px),
  repeating-linear-gradient(90deg, transparent 0 39px, var(--line) 39px 40px), var(--soft); position: relative; }
.map .pin-dot { position: absolute; top: 40%; left: 50%; width: 12px; height: 12px; border: 2px solid var(--primary); border-radius: 50%; }
.map small { position: absolute; bottom: 8px; inset-inline-start: 10px; color: var(--muted); }

.empty { padding: 30px; text-align: center; color: var(--muted); }


/* ---------- Icons ---------- */
.icon { display: inline-block; vertical-align: -0.18em; flex: none; }
[dir="rtl"] .icon.flip { transform: scaleX(-1); }
.btn .icon, .link .icon { vertical-align: -0.2em; }
.side nav a .icon { opacity: .7; transition: opacity var(--dur) var(--ease), transform var(--dur) var(--ease); }
.side nav a:hover .icon, .side nav a[aria-current="page"] .icon { opacity: 1; }
.icon-btn .icon { width: 17px; height: 17px; }
.modal-close .icon { width: 20px; height: 20px; }
.dots { display: inline-grid; place-items: center; width: 28px; height: 28px; border-radius: 50%; background: none; border: 0;
  transition: background var(--dur) var(--ease), color var(--dur) var(--ease); }
.dots:hover { background: var(--soft); color: var(--ink); }

/* ---------- Motion & depth ---------- */
a, button, .btn, .pill, .chip, .tabs a, .side nav a, .input, .card, .stat, .copy, .radio-card, .switch span,
.switch span::after, .inbox-list a, table.t td, .art img, .art .ph, .list-row {
  transition-property: background-color, border-color, color, box-shadow, transform, opacity, filter;
  transition-duration: var(--dur); transition-timing-function: var(--ease);
}
.btn { box-shadow: var(--shadow-xs); }
.btn:hover { transform: translateY(-1px); box-shadow: var(--shadow-sm); filter: none; }
.btn:active { transform: translateY(0); box-shadow: var(--shadow-xs); }
.btn.primary:hover { background: var(--primary-strong); }
.btn.outline:hover { background: var(--primary-soft); }
.btn.ghost, .btn.ghost:hover { box-shadow: none; }
.btn:focus-visible, .link:focus-visible, a:focus-visible, .pill:focus-within, .seg label:focus-within {
  outline: none; box-shadow: var(--focus-ring); border-radius: var(--radius-sm); }
.card, .stat, .table-wrap { box-shadow: var(--shadow-xs); }
a.card:hover, .stat:hover, .card.hoverable:hover { box-shadow: var(--shadow-md); transform: translateY(-2px); }
.art { display: block; }
.art img, .art .ph { box-shadow: var(--shadow-xs); }
.art:hover img, .art:hover .ph { transform: translateY(-3px); box-shadow: var(--shadow-md); }
.copy:hover { transform: translateY(-1px); box-shadow: var(--shadow-sm); }
.tabs a:hover { color: var(--ink); }
.inbox-list a:hover { background: var(--side); }
.side nav a:hover .icon { transform: translateX(1px); }
[dir="rtl"] .side nav a:hover .icon { transform: translateX(-1px); }
.sheet { animation: rise .5s var(--ease) both; }

@keyframes rise { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes pop { from { opacity: 0; transform: translateY(12px) scale(.98); } to { opacity: 1; transform: none; } }
@keyframes slide-in { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; transform: none; } }
@keyframes pulse { 0%, 100% { box-shadow: 0 0 0 0 var(--primary-line); } 50% { box-shadow: 0 0 0 5px transparent; } }
@keyframes shimmer { from { background-position: -200% 0; } to { background-position: 200% 0; } }

.main > * { animation: rise .45s var(--ease) both; }
.main > :nth-child(2) { animation-delay: .04s; }
.main > :nth-child(3) { animation-delay: .08s; }
.main > :nth-child(4) { animation-delay: .12s; }
.main > :nth-child(5) { animation-delay: .16s; }
.stats .stat { animation: rise .5s var(--ease) both; }
.stats .stat:nth-child(2) { animation-delay: .05s; } .stats .stat:nth-child(3) { animation-delay: .1s; }
.stats .stat:nth-child(4) { animation-delay: .15s; }
dialog.modal[open] { animation: pop .26s var(--ease); }
dialog.modal[open]::backdrop { animation: fade .26s var(--ease); }
.flash { animation: slide-in .3s var(--ease) both; box-shadow: var(--shadow-sm); }
.flash.leaving { opacity: 0; transform: translateY(-6px); transition: opacity .4s var(--ease), transform .4s var(--ease); }
.icon-btn .dot, .side nav a .count { animation: pulse 2.4s var(--ease) infinite; }
.skeleton { background: linear-gradient(90deg, var(--soft) 25%, var(--soft-2) 37%, var(--soft) 63%); background-size: 400% 100%;
  animation: shimmer 1.4s ease infinite; border-radius: var(--radius-sm); }
.cal .slot { box-shadow: var(--shadow-xs); }
.cal .slot:hover { transform: translateY(-1px); box-shadow: var(--shadow-sm); }

/* Map picker (Leaflet) */
.map-picker { height: 240px; border-radius: var(--radius-sm); overflow: hidden; border: 1px solid var(--line); z-index: 0; }
.map-public { height: 220px; border-radius: var(--radius); overflow: hidden; border: 1px solid var(--line); }
.leaflet-container { font: inherit; background: var(--soft); }

/* Result marks (payment return, request sent) */
.state-mark { width: 72px; height: 72px; border-radius: 50%; display: grid; place-items: center; margin: 0 auto 18px;
  animation: pop .45s var(--ease) both; box-shadow: var(--shadow-sm); }
.state-mark.ok { background: var(--olive-soft); color: var(--olive); }
.state-mark.warn { background: var(--primary-soft); color: var(--primary); }

/* ZATCA QR */
.qr { width: 96px; height: 96px; color: var(--ink); }
.qr svg { width: 100%; height: 100%; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important;
    transition-duration: .01ms !important; scroll-behavior: auto !important; }
}

/* ---------- Entrance (sign in / sign up) ---------- */
.entrance-body { background: var(--bg); }
.entrance { display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr); min-height: 100vh; }
.entrance-art { position: relative; overflow: hidden; background: var(--side); border-inline-end: 1px solid var(--line);
  display: flex; flex-direction: column; justify-content: space-between; padding: 36px 44px; }
.entrance-art::before { content: ""; position: absolute; inset: auto -20% -30% -20%; height: 70%;
  background: radial-gradient(closest-side, var(--soft-2), transparent); opacity: .9; }
.entrance-brand { position: relative; letter-spacing: .18em; font-weight: 600; font-family: Georgia, serif; font-size: 15px; color: var(--ink); }
.entrance-brand.mobile { display: none; }
.entrance-gallery { position: relative; height: clamp(320px, 56vh, 520px); margin: 24px 0; }
.entrance-frame { position: absolute; margin: 0; background: var(--bg); padding: 10px 10px 12px; box-shadow: var(--shadow-lg);
  border-radius: 3px; animation: float 9s var(--ease) infinite alternate, rise .9s var(--ease) both; }
.entrance-frame img, .entrance-frame .ph { display: block; width: 100%; aspect-ratio: .8; object-fit: cover; background: var(--soft-2); }
.entrance-frame figcaption { font-size: 12px; margin-top: 8px; color: var(--ink-2); }
.entrance-frame figcaption small { display: block; color: var(--muted); font-size: 11px; }
.entrance-frame.f1 { width: 40%; inset-inline-start: 6%; top: 8%; transform: rotate(-3deg); }
.entrance-frame.f2 { width: 36%; inset-inline-start: 50%; top: 0; animation-delay: -3s, .15s; transform: rotate(2deg); }
.entrance-frame.f3 { width: 32%; inset-inline-start: 36%; top: 46%; animation-delay: -6s, .3s; transform: rotate(-1deg); }
@keyframes float { from { translate: 0 0; } to { translate: 0 -12px; } }
.entrance-copy { position: relative; max-width: 440px; }
.entrance-eyebrow { color: var(--primary); font-size: 11.5px; letter-spacing: .14em; text-transform: uppercase; margin-bottom: 8px; }
.entrance-quote { font-family: var(--serif); font-size: 24px; line-height: 1.4; color: var(--ink); font-style: italic; }
[dir="rtl"] .entrance-quote { font-style: normal; font-size: 26px; }
.entrance-main { display: flex; flex-direction: column; padding: 28px clamp(20px, 5vw, 64px); }
.entrance-top { display: flex; justify-content: flex-end; align-items: center; gap: 12px; }
.entrance-card { width: min(420px, 100%); margin: auto; padding: 24px 0; animation: rise .5s var(--ease) both; }
.entrance-foot { text-align: center; color: var(--muted); font-size: 12px; }
.auth-title, .entrance-card h1 { font-size: 34px; margin-bottom: 8px; }
.auth-lead { color: var(--muted); margin-bottom: 18px; }
.auth-lead a, .entrance-card a:not(.btn) { color: var(--primary); text-decoration: underline; text-underline-offset: 3px; }
.auth-form { display: flex; flex-direction: column; gap: 14px; margin: 8px 0; }
.auth-actions { display: flex; flex-direction: column; gap: 10px; margin-top: 6px; }
.auth-actions .btn { padding: 11px 16px; font-size: 14.5px; }
.auth-field label { font-size: 13px; color: var(--ink-2); }
.input-wrap { position: relative; }
.input-wrap .input { padding-inline-start: 38px; padding-block: 10px; }
.input-wrap .input-icon { position: absolute; inset-inline-start: 12px; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; }
.input-wrap:focus-within .input-icon { color: var(--primary); }
.input-wrap .reveal { position: absolute; inset-inline-end: 6px; top: 50%; transform: translateY(-50%); background: none; border: 0;
  color: var(--muted); padding: 6px; cursor: pointer; border-radius: 50%; }
.input-wrap .reveal:hover { color: var(--ink); background: var(--soft); }
.field-error { color: var(--primary); font-size: 12.5px; }
.field-help { color: var(--muted); font-size: 12px; }
.field-help ul { margin: 4px 0 0; padding-inline-start: 18px; }
.auth-check { font-size: 13px; color: var(--ink-2); }
.auth-hr { display: block; height: 1px; background: var(--line); margin: 18px 0; }
.auth-divider { display: flex; align-items: center; gap: 12px; color: var(--muted); font-size: 12.5px; margin: 18px 0 12px; }
.auth-divider::before, .auth-divider::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.provider-list { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 10px; }
.provider-list .btn { color: var(--ink); border-color: var(--line-strong); justify-content: center; gap: 10px; }
.provider-list .btn:hover { background: var(--side); border-color: var(--ink-2); }
.btn.danger { background: var(--primary); color: var(--primary-ink); }

@media (max-width: 900px) {
  .entrance { grid-template-columns: 1fr; }
  .entrance-art { display: none; }
  .entrance-brand.mobile { display: block; margin-inline-end: auto; }
}

@media (max-width: 1100px) {
  .cols, .cols.even, .cols.wide-side { grid-template-columns: minmax(0, 1fr); }
  .stats { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 820px) {
  .main { padding: 20px 16px 40px; }
  .inbox { grid-template-columns: minmax(0, 1fr); }
  .copies { grid-template-columns: repeat(4, 1fr); }
  .page-head { flex-direction: column; }
  .grid-3 { grid-template-columns: 1fr; }
}
@media print {
  .side, .top, .no-print { display: none !important; }
  .shell { display: block; }
  .main { padding: 0; }
  .sheet { box-shadow: none; border: 0; }
}

/* Quiet gallery entrance: generous type, framed art and a grounded form. */
.entrance { min-height: 100svh; }
.entrance-art { padding: clamp(28px, 4vw, 64px); }
.entrance-gallery { isolation: isolate; container-type: size; flex: 0 1 auto; min-height: 0; }
.entrance-frame { border: 1px solid var(--line); padding: 12px 12px 16px; }
/* Frames scale with the gallery's height too, so short viewports never push them onto the quote. */
.entrance-frame.f1 { width: min(44%, 45cqh); inset-inline-start: 1%; top: 10%; }
.entrance-frame.f2 { width: min(40%, 41cqh); inset-inline-start: 52%; top: 2%; }
.entrance-frame.f3 { width: min(35%, 36cqh); inset-inline-start: 34%; top: 40%; }
.entrance-quote { font-size: clamp(24px, 2.4vw, 36px); line-height: 1.35; }
.entrance-main { background: var(--bg); padding-block: 32px; }
.entrance-card { width: min(420px, 100%); padding-block: 48px; }
.entrance-card h1 { font-size: clamp(32px, 3.2vw, 44px); line-height: 1.12; letter-spacing: -.025em; }
[dir="rtl"] .entrance-card h1 { letter-spacing: normal; line-height: 1.5; }
.entrance-card .auth-lead { font-size: 15px; line-height: 1.8; margin-block: 16px 28px; }
.entrance-card .input { min-height: 50px; background-color: var(--side); border-color: var(--line); }
.entrance-card .input:focus { background-color: var(--bg); border-color: var(--primary); box-shadow: var(--focus-ring); }
.entrance-card .auth-form { gap: 18px; }
.entrance-card .auth-actions .btn { min-height: 50px; box-shadow: var(--shadow-sm); }
.entrance-card .auth-actions .btn:hover { box-shadow: var(--shadow-md); }
.input-wrap:has(.reveal) .input { padding-inline-end: 48px; }
.entrance-card .provider-list .btn { min-height: 48px; }
.entrance-foot { border-top: 1px solid var(--line); padding-block-start: 22px; }
:focus-visible { outline: 2px solid var(--primary); outline-offset: 3px; }

@media (max-width: 820px) {
  .tabs { overflow-x: auto; flex-wrap: nowrap; max-width: 100%; }
  .tabs > * { flex-shrink: 0; }
  .table-wrap, .calendar-wrap { overflow-x: auto; max-width: 100%; }
  .table-wrap table { min-width: 620px; }
  dialog.modal { width: calc(100% - 24px); max-height: calc(100svh - 32px); overflow-y: auto; }
  .btn, .input { min-height: 44px; }
  .input, select.input, textarea.input { font-size: 16px; }
  .entrance-main { min-height: 100svh; padding: 24px; }
  .entrance-card { padding-block: 40px; }
}
@media (max-width: 420px) {
  .stats { gap: 10px; }
  .stat { padding: 14px; }
}
@media (max-width: 820px) {
  .cols[style*="grid-template-columns"] { grid-template-columns: minmax(0, 1fr) !important; }
  .calendar-wrap .cal { min-width: 650px; }
  .grid-2 { grid-template-columns: minmax(0, 1fr); }
}

/* ---------- Mobile (phones and small tablets) ---------- */
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
.main, .card, .sheet { min-width: 0; overflow-wrap: anywhere; }

@media (max-width: 820px) {
  h1, [dir="rtl"] h1 { font-size: 26px; }
  h2 { font-size: 19px; }
  .page-head .actions { width: 100%; }
  .page-head .actions .btn { flex: 1 1 auto; }
  .card { padding: 14px; }
  .card-head { flex-wrap: wrap; }
  /* List rows (overview, activity): name and preview keep the line, time and action drop below when tight. */
  .list-row { flex-wrap: wrap; row-gap: 6px; }
  .list-row .grow { flex: 1 1 160px; }
  .entrance { grid-template-columns: minmax(0, 1fr); }
  .stat .v { font-size: 22px; margin-bottom: 8px; }

  /* Filters and inline-width inputs fill the row. */
  .filters .input, .filters form, .filters form .input { flex: 1 1 160px; min-width: 0; width: 100%; }
  .filters .input[style*="width"], form .input[style*="width:220px"] { width: 100% !important; }
  .seg { max-width: 100%; overflow-x: auto; }
  .seg a, .seg label { white-space: nowrap; }

  /* Templates with fixed inline grids. */
  .art-grid, .art-grid[style*="grid-template-columns"] { grid-template-columns: repeat(2, minmax(0, 1fr)) !important; gap: 12px !important; }
  .grid-3[style*="grid-template-columns"] { grid-template-columns: repeat(2, minmax(0, 1fr)) !important; }
  .steps.five { overflow-x: auto; grid-template-columns: repeat(5, minmax(64px, 1fr)); }
  .stepper .line { width: 16px; }
  .thumb.xl, .thumb.xl[style] { width: 110px !important; height: 136px !important; }
  .work-cell { min-width: 180px; }

  /* Requests: the thread list scrolls in a short box so the open conversation stays on screen. */
  .inbox-list { max-height: 260px; overflow-y: auto; }
  .bubble { max-width: 88%; }
  .thread { max-height: 55vh; }
  .composer .row .btn { flex: 1 1 auto; }

  /* Modals become near-full-width sheets. */
  .modal-head { padding: 18px 16px 0; }
  .modal-head h2 { font-size: 20px; }
  .modal-close { top: 14px; inset-inline-end: 12px; }
  .modal-body { padding: 14px 16px; }
  .modal-foot { padding: 4px 16px 18px; flex-wrap: wrap; }
  .modal-foot .btn { flex: 1 1 auto; }

  /* Documents (invoices, price lists) keep their layout and scroll sideways when too wide. */
  .sheet { padding: 18px 16px; overflow-x: auto; }
  .sheet h2.big { font-size: 24px; }
  .sheet .lines { min-width: 480px; }
  .sheet .total { font-size: 17px; }

  .timeline .ev { grid-template-columns: 14px minmax(0, 1fr); }
  .timeline .ev > :nth-child(3) { grid-column: 2; }
  .toggle-row, .radio-card { flex-wrap: wrap; }
  .pills { gap: 8px; }
  .pill { padding: 6px 14px; }
  .empty { padding: 20px 12px; }
  .pub-foot { flex-wrap: wrap; gap: 8px; }
}

@media (max-width: 420px) {
  .main { padding-inline: 12px; }
  .copies { grid-template-columns: repeat(3, 1fr); }
  .kv { grid-template-columns: minmax(0, 1fr); }
  .kv > :nth-child(odd) { border-bottom: 0; padding-bottom: 0; }
  .art-grid, .art-grid[style*="grid-template-columns"] { gap: 10px !important; }
  .grid-3[style*="grid-template-columns"] { grid-template-columns: minmax(0, 1fr) !important; }
  .page-head .actions .btn { flex-basis: 100%; }
  .entrance-main { padding: 20px 16px; }
  .entrance-card h1 { font-size: 30px; }
}

@media (hover: none) {
  .btn:hover, a.card:hover, .stat:hover, .card.hoverable:hover, .copy:hover, .cal .slot:hover { transform: none; }
  .art:hover img, .art:hover .ph { transform: none; }
}

@media print {
  .sheet { overflow: visible; }
  .sheet .lines { min-width: 0; }
}


/* =====================================================================
   Studio navigation at tablet and phone widths
   - 821–1100px: the sidebar folds into an icon rail (labels show as tooltips).
   - ≤820px: a slim app bar, a slide-in drawer with the full navigation, and a
     bottom tab bar for the four everyday sections. studio.js opens the drawer.
   ===================================================================== */
@media (min-width: 821px) and (max-width: 1100px) {
  .shell { grid-template-columns: 76px minmax(0, 1fr); }
  .side { padding: 20px 12px 14px; align-items: center; }
  .side-head { justify-content: center; }
  .side .brand { padding: 0; }
  .side .brand-text { display: none; }
  .side .brand-mark { display: grid; }
  .side nav { margin-top: 22px; align-items: center; width: 100%; }
  .side nav a { position: relative; justify-content: center; width: 48px; height: 44px; padding: 0; }
  .side nav a .nav-text { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  .side nav a .count { position: absolute; top: 4px; inset-inline-end: 4px; min-width: 16px; font-size: 10px; padding: 0 4px; margin: 0; }
  .side nav hr { width: 32px; margin: 10px auto; }
  .side .me { padding: 6px 0; }
  .side .me-text { display: none; }
  .top { padding: 12px 20px; }
  .main { padding: 24px 22px 48px; }
}
.brand-mark { width: 38px; height: 38px; place-items: center; border-radius: 12px; background: var(--dark); color: var(--primary-ink);
  font-family: Georgia, serif; font-size: 18px; letter-spacing: 0; box-shadow: var(--shadow-sm); }

@media (max-width: 820px) {
  .shell { display: block; min-height: 100svh; }

  /* --- App bar --- */
  .top { position: sticky; top: 0; z-index: 20; flex-wrap: wrap; gap: 4px; padding: 8px 10px; min-height: 60px;
    padding-top: max(8px, env(safe-area-inset-top)); }
  .shell .top .nav-toggle, .shell .top-brand, .shell .search-toggle { display: inline-grid; }
  .shell .tabbar .nav-toggle { display: flex; }
  .top .icon-btn { width: 44px; height: 44px; background: transparent; }
  .top .icon-btn:hover, .top .icon-btn[aria-expanded="true"] { background: var(--soft); }
  .top .icon-btn .dot { top: 10px; inset-inline-end: 11px; }
  .top-brand { align-items: center; padding-inline: 6px; font-family: Georgia, serif; letter-spacing: .16em; font-weight: 600; font-size: 14px; }
  .top .spacer { display: block; flex: 1; }
  .top .lang-switch, .top-logout { display: none; }
  .add-work { width: 40px; height: 40px; min-height: 40px; padding: 0; border-radius: 50%; margin-inline: 2px; }
  .add-work .nav-text { display: none; }
  /* Search folds behind its icon and opens as a full-width row under the bar. */
  .top .search { display: none; order: 10; flex: 1 1 100%; margin: 4px 2px 2px; min-height: 44px; }
  .top.search-open .search { display: flex; animation: slide-in .2s var(--ease) both; }
  .search input { font-size: 16px; }

  /* --- Drawer --- */
  .side { position: fixed; z-index: 40; inset-block: 0; inset-inline-start: 0; height: 100%; width: min(320px, 86vw);
    padding: max(18px, env(safe-area-inset-top)) 14px max(14px, env(safe-area-inset-bottom));
    background: var(--bg); border-inline-end: 0; box-shadow: var(--shadow-lg); overflow-y: auto; overscroll-behavior: contain;
    transform: translateX(-104%); visibility: hidden;
    transition: transform .32s cubic-bezier(.32, .72, 0, 1), visibility 0s linear .32s; }
  [dir="rtl"] .side { transform: translateX(104%); }
  .shell.nav-open .side { transform: none; visibility: visible; transition: transform .32s cubic-bezier(.32, .72, 0, 1), visibility 0s; }
  .shell .side-backdrop { display: block; position: fixed; inset: 0; z-index: 30; background: var(--backdrop); backdrop-filter: blur(3px);
    opacity: 0; pointer-events: none; transition: opacity .3s var(--ease); }
  .shell.nav-open .side-backdrop { opacity: 1; pointer-events: auto; }
  body.nav-locked { overflow: hidden; }

  .side-head { padding: 2px 4px 14px; border-bottom: 1px solid var(--line); }
  .side .brand { padding: 0; }
  .side .brand-mark { display: grid; }
  .shell .side-close { display: inline-grid; width: 40px; height: 40px; background: var(--soft); }
  /* Profile card sits at the top of the drawer. */
  .side .me { order: -1; margin: 12px 0 2px; padding: 10px 12px; border-radius: 14px; background: var(--side); border: 1px solid var(--line); }
  .side .me .avatar { width: 42px; height: 42px; font-size: 14px; }
  .side-head { order: -2; }
  .side nav { margin-top: 10px; gap: 2px; }
  .side nav a { min-height: 44px; padding: 0 12px; gap: 14px; border-radius: 12px; font-size: 15px; color: var(--ink); }
  .side nav a .icon { opacity: .75; }
  .side nav a[aria-current="page"] { background: var(--primary-soft); color: var(--primary); box-shadow: none; }
  .side nav a[aria-current="page"] .icon { opacity: 1; }
  .side nav a .count { font-size: 11.5px; min-width: 22px; line-height: 20px; }
  .side nav hr { margin: 10px 12px; border-color: var(--line); }
  /* Staggered entrance for the links. */
  .shell.nav-open .side nav a { animation: drawer-item .36s var(--ease) both; }
  .shell.nav-open .side nav a:nth-child(2) { animation-delay: .03s; } .shell.nav-open .side nav a:nth-child(3) { animation-delay: .06s; }
  .shell.nav-open .side nav a:nth-child(4) { animation-delay: .09s; } .shell.nav-open .side nav a:nth-child(5) { animation-delay: .12s; }
  .shell.nav-open .side nav a:nth-child(6) { animation-delay: .15s; } .shell.nav-open .side nav a:nth-child(7) { animation-delay: .18s; }
  .shell.nav-open .side nav a:nth-child(n+8) { animation-delay: .21s; }
  .shell .side-foot { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: auto; padding-top: 16px; }
  .side-foot form { display: contents; }
  .side-action { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 46px; padding: 0 12px;
    border: 1px solid var(--line-strong); border-radius: 12px; background: var(--bg); color: var(--ink-2); font-size: 13.5px; cursor: pointer; }
  .side-action:hover { background: var(--side); color: var(--ink); }

  /* --- Bottom tab bar --- */
  .shell .tabbar { display: grid; grid-template-columns: repeat(5, minmax(0, 132px)); justify-content: center; column-gap: 2px; position: fixed; z-index: 20; inset-inline: 0; bottom: 0;
    padding: 6px 6px max(6px, env(safe-area-inset-bottom)); background: var(--glass); backdrop-filter: saturate(1.6) blur(14px);
    border-top: 1px solid var(--line); }
  .tabbar a, .tabbar button { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
    min-height: 56px; padding: 4px 1px; border: 0; border-radius: 12px; background: none; color: var(--muted); font-size: 12px;
    line-height: 1.25; cursor: pointer; text-align: center; }
  [dir="rtl"] .tabbar a, [dir="rtl"] .tabbar button { font-size: 12.5px; }
  .tabbar a > span:last-child, .tabbar button > span:last-child { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .tab-icon { position: relative; display: grid; place-items: center; width: 48px; height: 28px; border-radius: 99px;
    transition: background var(--dur) var(--ease), color var(--dur) var(--ease); }
  .tabbar a[aria-current="page"] { color: var(--ink); font-weight: 500; }
  .tabbar a[aria-current="page"] .tab-icon { background: var(--primary-soft); color: var(--primary); }
  .tabbar .count { position: absolute; top: -2px; inset-inline-end: 6px; min-width: 17px; height: 17px; padding: 0 4px; border-radius: 99px;
    background: var(--primary); color: var(--primary-ink); font-size: 10px; line-height: 17px; box-shadow: 0 0 0 2px var(--bg); }
  .main { padding-bottom: calc(96px + env(safe-area-inset-bottom)); }
}
@keyframes drawer-item { from { opacity: 0; transform: translateX(-10px); } to { opacity: 1; transform: none; } }
[dir="rtl"] .shell.nav-open .side nav a { animation-name: drawer-item-rtl; }
@keyframes drawer-item-rtl { from { opacity: 0; transform: translateX(10px); } to { opacity: 1; transform: none; } }
@media print { .tabbar, .side-backdrop { display: none !important; } }

/* ---------- Content fixes for tablets and phones ---------- */
/* Copy-link buttons never squeeze into a vertical stack of letters. */
[data-copy] { white-space: nowrap; flex: none; }
@media (max-width: 1100px) {
  /* Tables scroll sideways inside their frame; cells keep to one line instead of breaking words. */
  table.t th, table.t td { white-space: nowrap; }
  table.t td .work-cell { min-width: 200px; }
  .table-wrap { -webkit-overflow-scrolling: touch; scrollbar-width: thin; }
  .sheet .num, .sheet .end-text, .sheet td:last-child { white-space: nowrap; }
}
@media (max-width: 820px) {
  .table-wrap table { min-width: 0; }
  /* Hints and notices sitting beside buttons take their own full row. */
  .row.wrap > .notice, .row.wrap > p[style*="flex"] { flex: 1 1 100% !important; }
  /* Radio rows with a field beside them (settings → visit location) wrap cleanly. */
  label.between { flex-wrap: wrap; }
  label.between > .check { flex: none; }
  label.between > .input, label.between > select { flex: 1 1 200px; min-width: 0; }
  .row > label.check[style*="width"] { width: auto !important; min-width: 96px; }
  .calendar-wrap { margin-inline: -4px; }
}

/* ---------- Shared form layout (shell/form.html) ---------- */
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px 16px; }
.form-grid .form-wide { grid-column: 1 / -1; }
.form-grid fieldset { border: 0; padding: 0; margin: 0; }
.form-grid .has-error .input, .form-grid .has-error input, .form-grid .has-error select, .form-grid .has-error textarea { border-color: var(--primary); }
.form-grid input[type="file"] { font-size: 13px; }
.check-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 6px 14px; max-height: 260px; overflow: auto;
  padding: 10px 12px; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--side); }
.side-switch { margin: 14px 0 0; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--bg); }
.side-switch summary { display: flex; align-items: center; gap: 8px; padding: 8px 10px; cursor: pointer; list-style: none; font-size: 13px; }
.side-switch summary::-webkit-details-marker { display: none; }
.side-switch a { display: block; padding: 7px 12px; font-size: 13px; border-top: 1px solid var(--line); }
.side-switch a[aria-current] { color: var(--primary); }
@media (max-width: 820px) { .form-grid { grid-template-columns: minmax(0, 1fr); } }
@media (min-width: 821px) and (max-width: 1100px) { .side-switch { display: none; } }

/* ---------- Portal components (Gallery Portal & Admin) ---------- */
.subhead { font-size: 15px; font-family: var(--sans); font-weight: 600; margin: 18px 0 6px; }
[dir="rtl"] .subhead { font-weight: 600; }
.show-row { padding: 14px 0; border-bottom: 1px solid var(--line); }
.show-row:last-of-type { border-bottom: 0; }
.show-row h3 { font-size: 18px; }
.mini-stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; margin: 12px 0; }
.mini-stats div { background: var(--side); border-radius: var(--radius-sm); padding: 8px 10px; }
.mini-stats b { display: block; font-family: var(--serif); font-size: 18px; font-weight: 400; }
.mini-stats span { font-size: 11.5px; color: var(--muted); }
.pick-list { display: flex; flex-direction: column; border: 1px solid var(--line); border-radius: var(--radius-sm); max-height: 520px; overflow: auto; }
.pick { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-bottom: 1px solid var(--line); cursor: pointer; }
.pick:last-child { border-bottom: 0; }
.pick:hover { background: var(--side); }
.pick .grow { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.pick small { color: var(--muted); font-size: 12px; }
.pick input[type="checkbox"] { accent-color: var(--primary); width: 16px; height: 16px; flex: none; }
.bars { display: flex; align-items: flex-end; gap: 10px; height: 170px; padding: 8px 0 0; border-bottom: 1px solid var(--line); margin-bottom: 8px; }
.bar { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; gap: 4px; min-width: 0; }
.bar span { display: block; width: 100%; max-width: 42px; min-height: 4px; background: var(--primary); border-radius: 4px 4px 0 0; opacity: .85; }
.bar b { font-size: 12px; font-weight: 600; }
.bar small { font-size: 11px; color: var(--muted); }
.location-request { padding: 14px 0; border-top: 1px solid var(--line); }
.location-request:first-of-type { border-top: 0; padding-top: 4px; }
.thread-block { padding: 14px 0; border-top: 1px solid var(--line); }
.thread-block:first-of-type { border-top: 0; }
table.t.matrix td, table.t.matrix th { text-align: center; }
table.t.matrix td:first-child, table.t.matrix th:first-child { text-align: start; }
.chip.paid, .chip.complete, .chip.settled { background: var(--olive-soft); color: var(--olive); }
.chip.sent, .chip.deposit_paid, .chip.delivered { background: var(--primary-soft); color: var(--primary); }
.card.hoverable { color: inherit; }
.queue-item { display: flex; gap: 12px; align-items: center; padding: 12px; border-radius: var(--radius-sm); border: 1px solid var(--line); background: var(--bg); }
.queue-item.on { border-color: var(--primary); background: var(--primary-soft); }
.queue-item + .queue-item { margin-top: 8px; }
.review-pane { position: sticky; top: 76px; }
.evidence { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border: 1px solid var(--line); border-radius: var(--radius-sm); }
.evidence + .evidence { margin-top: 8px; }
.compare { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.compare figure { margin: 0; }
.compare img, .compare .ph { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: var(--radius-sm); background: var(--soft-2); display: block; }
.locked { position: relative; }
.locked::after { content: ""; position: absolute; inset: 0; background: linear-gradient(180deg, transparent, var(--bg) 85%); pointer-events: none; }
@media (max-width: 820px) {
  .mini-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .review-pane { position: static; }
  .pick input.input.num { width: 84px !important; }
}
/* Amounts and counts never break across lines. */
table.t td.num, table.t th.num, .num { white-space: nowrap; }
table.t th { vertical-align: bottom; }

/* Brand: the wordmark image; the square "P" mark only in the collapsed (icon-only) sidebar. */
.brand-word { display: block; width: auto; height: 21px; }
.side .brand-text .brand-word { margin-bottom: 6px; }
.side .brand-mark.brand-img { display: none; width: auto; height: 30px; background: none; box-shadow: none; border-radius: 0; flex: none; }
@media (min-width: 821px) and (max-width: 1100px) { .side .brand-mark.brand-img { display: block; } }
.pub-top .brand-word { display: inline-block; vertical-align: middle; }
@media (max-width: 820px) { .shell .top-brand { display: inline-flex; } .top-brand .brand-word { height: 18px; } }

/* ---------- Design fidelity pass (Artist Studio PDFs, Nov 2026) ---------- */
/* .grow had no general rule, so "grow" children of flex rows never stretched. */
.row > .grow, .between > .grow { flex: 1; min-width: 0; }
.nowrap { white-space: nowrap; }
.inbox { grid-template-columns: minmax(300px, 380px) minmax(0, 1fr); }
.interest-row .link { flex: none; }

/* Studio visits: blackout periods on one line. */
.blackout-row { padding: 8px 0; border-bottom: 1px solid var(--line); }
.blackout-form { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 12px; }
.blackout-form .field { margin: 0; }
.blackout-form .field.grow { flex: 1 1 220px; }

/* Collector page: works they liked as even tiles. */
.liked-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.liked-grid .art img, .liked-grid .art .ph { width: 100%; height: auto; aspect-ratio: 3 / 2; object-fit: cover; }

/* Payment methods as outlined pills (invoice form). */
.pills.outline .pill:has(input:checked) { background: var(--bg); color: var(--ink); border-color: var(--primary); }

/* Consigned-work confirmation. */
.alert.warn { background: var(--warn-bg); }
.kv.wide { grid-template-columns: 170px 1fr; }

/* Price list sharing: recipients as removable chips, "+ From collectors" as a link-styled select. */
.chip-picker { gap: 8px; }
.pick-chip { display: inline-flex; align-items: center; gap: 8px; padding: 4px 12px; border-radius: 99px; background: var(--soft-2); cursor: pointer; font-size: 13px; }
.pick-chip input { position: absolute; opacity: 0; pointer-events: none; }
.pick-chip:hover { background: var(--line); }
.link-select { appearance: none; border: 0; background: none; color: var(--primary); padding: 0; cursor: pointer; font-size: 13.5px; align-self: flex-start; }

/* New price list: quick preview miniature. */
.mini-preview { background: var(--side); border-radius: var(--radius-sm); padding: 10px 0 0; display: flex; justify-content: center; }
.mini-sheet { width: 132px; min-height: 150px; background: var(--bg); box-shadow: var(--shadow-xs); padding: 14px 12px; display: flex; flex-direction: column; gap: 9px; }
.mini-title { display: block; width: 58px; height: 4px; background: var(--ink); margin-bottom: 4px; }
.mini-empty { display: none; }
.mini-sheet.is-empty .mini-empty { display: block; height: 4px; width: 70%; background: var(--line); }
.mini-row { display: grid; grid-template-columns: 22px 1fr 22px; gap: 8px; align-items: center; }
.mini-thumb { width: 22px; height: 18px; background: var(--soft-2) center / cover; }
.mini-row i { height: 3px; background: var(--line-strong); }
.mini-row b { height: 3px; background: var(--ink); }

/* Desktop type scale from the designs (body 15px, titles 38px). Phones keep the compact scale. */
@media (min-width: 1101px) {
  .shell { grid-template-columns: 256px minmax(0, 1fr); }
  body { font-size: 15px; }
  [dir="rtl"] body { font-size: 14.5px; }
  h1 { font-size: 38px; }
  [dir="rtl"] h1 { font-size: 38px; }
  h2 { font-size: 25px; }
  h3 { font-size: 18px; }
  .small { font-size: 13px; }
  .side nav a { font-size: 15px; padding: 8px 10px; }
  .stat .k { font-size: 13.5px; }
  .stat .v { font-size: 32px; }
  table.t { font-size: 14.5px; }
  table.t th { font-size: 13.5px; }
  .tabs a { font-size: 15.5px; }
  .kv > :nth-child(odd) { font-size: 13.5px; }
}
.cal .slot { overflow-wrap: normal; hyphens: auto; }
