/* =====================================================================
   MT-Themes v2 — components (DESIGN.md §4): device frames, storefront
   card + grid + scroll-snap row, price ledger, stat strip, navy proof
   band, rows, FAQ, CTA. Logical properties only.
   ===================================================================== */

/* ---- Device frames ---- */
.frame {
  background: var(--card);
  border: 1px solid var(--line-strong);
  border-radius: var(--r-2);
  box-shadow: var(--shadow-2);
  overflow: hidden;
}

.frame-bar {
  direction: ltr;
  display: flex;
  align-items: center;
  gap: 5px;
  height: 24px;
  padding: 0 9px;
  background: var(--paper-2);
  border-bottom: 1px solid var(--line);
}

.frame-bar i {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--line-strong);
}

.frame-url {
  flex: 1;
  margin-inline-start: 8px;
  height: 14px;
  line-height: 14px;
  border-radius: var(--r-pill);
  background: var(--card);
  color: var(--ink-3);
  font-family: var(--font-mono);
  font-size: 10px;
  text-align: center;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  padding: 0 8px;
}

.frame-screen {
  position: relative;
  overflow: hidden;
  aspect-ratio: 16 / 10;
  background: var(--card);
}

.frame-screen img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: top center;
}

.phone {
  position: relative;
  overflow: hidden;
  aspect-ratio: 9 / 19.5;
  border-radius: var(--r-3);
  background: var(--card);
  border: 3px solid var(--card);
  outline: 1px solid var(--line-strong);
  box-shadow: var(--shadow-2);
}

.phone img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: top center;
}

/* ---- Storefront card (signature) ---- */
.storefronts {
  position: relative; /* contains the .vh spans of the cards when the row scrolls */
  display: grid;
  gap: var(--s-6) var(--s-6);
}

@media (min-width: 600px) {
  .storefronts {
    grid-template-columns: 1fr 1fr;
  }
}

@media (min-width: 960px) {
  .storefronts {
    grid-template-columns: repeat(3, 1fr);
    gap: var(--s-7) var(--s-6);
  }
}

.storefront a {
  display: block;
  color: inherit;
  text-decoration: none;
}

.sf-stage {
  position: relative;
}

.sf-stage.has-phone {
  aspect-ratio: 4 / 3;
}

.sf-desktop {
  transition:
    transform var(--dur) var(--ease),
    box-shadow var(--dur) var(--ease);
}

.has-phone .sf-desktop {
  position: absolute;
  top: 0;
  inset-inline-start: 0;
  width: 100%;
}

.sf-phone {
  position: absolute;
  bottom: 0;
  inset-inline-end: 4%;
  width: 28%;
  transition:
    transform var(--dur) var(--ease),
    box-shadow var(--dur) var(--ease);
}

/* The one authored moment: the phone lifts forward, the browser settles back.
   Without a phone image the browser frame alone lifts. */
.storefront a:hover .sf-phone,
.storefront a:focus-visible .sf-phone {
  transform: translateY(-14px) scale(1.06);
  box-shadow: var(--shadow-3);
}

.storefront a:hover .has-phone .sf-desktop,
.storefront a:focus-visible .has-phone .sf-desktop {
  transform: translateY(6px);
  box-shadow: var(--shadow-1);
}

.storefront a:hover .sf-stage:not(.has-phone) .sf-desktop,
.storefront a:focus-visible .sf-stage:not(.has-phone) .sf-desktop {
  transform: translateY(-6px);
  box-shadow: var(--shadow-3);
}

.sf-meta {
  display: flex;
  align-items: baseline;
  gap: var(--s-2) var(--s-3);
  margin-top: var(--s-4);
  flex-wrap: wrap;
}

.sf-meta h3 {
  font-size: var(--fs-3);
  font-weight: 700;
}

/* The price always takes its own line under name + chips: every card's price
   then sits on the same baseline as its neighbours', whatever the name and
   chips add up to. */
.sf-price {
  flex: 0 0 100%;
  display: inline-flex;
  align-items: baseline;
  gap: var(--s-2);
}

.sf-meta .price {
  font-size: var(--fs-2);
}

.sf-desc {
  margin-top: var(--s-1);
  color: var(--ink-2);
  font-size: var(--fs-1);
  max-width: 44ch;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.storefront a:hover h3 {
  color: var(--link);
}

/* On ≤959px the home grid is a scroll-snap row with two 44px arrow buttons
   (arrows follow reading direction: "next" points inline-end). */
.snap-nav {
  display: none;
}

@media (max-width: 959px) {
  /* The row bleeds to the screen edges and pads itself back by the gutter;
     scroll-padding keeps the snap points at the gutter too, so the first card
     starts at 16px (scrollLeft 0 at load) instead of being pulled flush to
     the bezel by the mandatory snap. */
  .snap-row .storefronts {
    display: flex;
    gap: var(--s-4);
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    scroll-padding-inline: var(--gutter);
    -webkit-overflow-scrolling: touch;
    padding-block-end: var(--s-3);
    padding-inline: var(--gutter);
    margin-inline: calc(-1 * var(--gutter));
    scrollbar-width: thin;
  }

  .snap-row .storefronts > li {
    flex: 0 0 min(78vw, 420px);
    scroll-snap-align: start;
  }

  .snap-nav {
    display: flex;
    gap: var(--s-2);
    justify-content: flex-end;
    margin-top: var(--s-3);
  }
}

.snap-btn {
  width: 44px;
  height: 44px;
  border-radius: var(--r-2);
  border: 1.5px solid var(--line-strong);
  background: var(--card);
  color: var(--blue-ink);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.snap-btn:hover {
  border-color: var(--blue-ink);
}

.snap-btn:disabled {
  opacity: 0.4;
  cursor: default;
}

.themes-foot {
  margin-top: var(--s-6);
  display: flex;
  flex-wrap: wrap;
  gap: var(--s-4) var(--s-6);
  align-items: center;
  justify-content: space-between;
  padding-top: var(--s-5);
  border-top: 1px solid var(--line);
  color: var(--ink-2);
}

/* ---- Stat strip: five hairline-separated mono numbers ----
   <900px: a 3-column grid (3 + 2, the same in both languages, no orphan
   hairline at a row's end); ≥900px: one row of five equal cells. */
.stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: var(--s-4) 0;
  margin-top: var(--s-6);
  padding: var(--s-4) var(--s-2);
  background: var(--paper-2);
  border: 1px solid var(--line);
  border-radius: 14px;
}

.stats > div {
  min-width: 0;
  display: flex;
  flex-direction: column-reverse;
  align-items: center;
  justify-content: flex-end;
  gap: 2px;
  padding-inline: var(--s-2);
  text-align: center;
  border-inline-end: 1px solid var(--line);
}

.stats > div:nth-child(3n),
.stats > div:last-child {
  border-inline-end: 0;
}

@media (min-width: 900px) {
  .stats {
    grid-template-columns: repeat(5, minmax(0, 1fr));
    padding-block: var(--s-5);
  }

  .stats > div:nth-child(3n) {
    border-inline-end: 1px solid var(--line);
  }

  .stats > div:last-child {
    border-inline-end: 0;
  }
}

.stats dd {
  font-family: var(--font-lat);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  font-size: clamp(1.5rem, 2.2vw, 1.875rem);
  line-height: 1.1;
  letter-spacing: -0.02em;
  color: var(--blue-ink);
}

.stats dt {
  font-size: var(--fs-0);
  font-weight: 500;
  line-height: 1.3;
  color: var(--ink-2);
  white-space: nowrap;
}

/* ---- Price ledger ---- */
.ledger-wrap {
  position: relative; /* contains the .vh spans: they must scroll with the table */
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.ledger {
  width: 100%;
  border-collapse: collapse;
  border-top: 1px solid var(--line-strong);
}

.ledger th,
.ledger td {
  padding: var(--s-1) var(--s-3);
  border-bottom: 1px solid var(--line);
  text-align: start;
  vertical-align: middle;
}

.ledger th {
  font-size: var(--fs-0);
  font-weight: 600;
  color: var(--ink-2);
  white-space: nowrap;
}

.ledger td {
  min-height: 48px;
}

.ledger .col-idx {
  width: 3ch;
  color: var(--ink-3);
  text-align: start;
}

.ledger .col-num,
.ledger .col-price {
  text-align: end;
  white-space: nowrap;
}

.ledger .col-act {
  text-align: end;
  width: 1%;
}

/* The gap between the two names sits on the name link, which shares the row's
   direction. The other-language <bdi> resolves its own direction (Latin → ltr
   on the Arabic page), so a logical margin on it would land on the far side
   and the names would touch ("Amerأمير") — DESIGN.md §10. */
.ledger .ledger-name {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  margin-inline-end: 0.6em;
  font-weight: 600;
  color: var(--ink);
  text-decoration: none;
}

.ledger .ledger-name:hover {
  color: var(--link);
  text-decoration: underline;
}

.ledger .ledger-alt {
  font-size: var(--fs-0);
  color: var(--ink-3);
}

.ledger .price {
  font-size: var(--fs-1);
}

.ledger-preview td {
  padding: var(--s-3) var(--s-3) var(--s-5);
  background: var(--paper-2);
}

.ledger-preview .frame {
  max-width: 640px;
  margin-inline: auto;
}

.ledger-preview[hidden] {
  display: none;
}

.ledger .ledger-chip {
  display: none;
}

/* On phones the ledger is theme (with its platform chip) · price · preview.
   The index, the other-language name, the platform column and the optional
   numbers are hidden — header and cells together (they share one class) —
   so the table fits 358px with no horizontal scroll (see the probe in
   scripts/design-preview). */
@media (max-width: 767px) {
  .ledger .col-idx,
  .ledger .col-opt,
  .ledger .col-platform,
  .ledger .ledger-alt {
    display: none;
  }

  .ledger .ledger-chip {
    display: inline-flex;
  }

  .ledger .col-name {
    white-space: normal;
  }

  .ledger .col-price,
  .ledger .col-act {
    white-space: nowrap;
  }

  .ledger .col-act .btn {
    padding-inline: var(--s-3);
  }

  .ledger th,
  .ledger td {
    padding-inline: var(--s-2);
  }

  .ledger th:first-child,
  .ledger td:first-child,
  .ledger .col-name {
    padding-inline-start: 0;
  }

  /* td only: the th holds a visually-hidden 1px span that would otherwise
     sit past the table edge and add 1px of scroll. */
  .ledger td.col-act {
    padding-inline-end: 0;
  }
}

/* ---- Navy proof band (one per page) ---- */
.band {
  background: var(--navy);
  color: var(--on-navy);
}

.band h2 {
  color: var(--on-navy);
}

.band-grid {
  display: grid;
  gap: var(--s-6);
}

@media (min-width: 960px) {
  .band-grid {
    grid-template-columns: 4fr 8fr;
    gap: var(--s-9);
  }
}

.band-lead {
  margin-top: var(--s-4);
  color: var(--on-navy-2);
  max-width: 36ch;
  font-size: var(--fs-2);
}

.quotes {
  display: grid;
  gap: var(--s-4);
}

@media (min-width: 700px) {
  .quotes {
    grid-template-columns: 1fr 1fr;
  }

  .quotes > li:first-child {
    grid-column: 1 / -1;
  }
}

.quote {
  background: var(--navy-2);
  border-radius: var(--r-2);
  padding: var(--s-5);
  display: flex;
  flex-direction: column;
  gap: var(--s-4);
}

.quote blockquote {
  font-size: var(--fs-2);
  line-height: 1.7;
}

.quotes > li:first-child .quote blockquote {
  font-size: clamp(var(--fs-2), 1.8vw, var(--fs-3));
}

@media (max-width: 699px) {
  .quote {
    padding: var(--s-4);
  }

  .quote blockquote,
  .quotes > li:first-child .quote blockquote {
    font-size: var(--fs-1);
  }
}

.quote footer {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--s-2) var(--s-3);
  margin-top: auto;
  font-size: var(--fs-0);
  color: var(--on-navy-2);
}

.quote footer strong {
  color: var(--on-navy);
  font-weight: 600;
  font-size: var(--fs-1);
}

.quote-logo {
  height: 28px;
  width: auto;
  max-width: 96px;
  object-fit: contain;
  background: #fff;
  border-radius: 4px;
  padding: 3px 6px;
}

.stars {
  display: inline-flex;
  gap: 2px;
  margin-inline-start: auto;
}

.stars .icon {
  width: 14px;
  height: 14px;
  color: var(--star);
}

/* ---- Rows: apps, add-ons, services, blog ---- */
.rows {
  border-top: 1px solid var(--line-strong);
}

.row {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: var(--s-2) var(--s-4);
  align-items: center;
  padding: var(--s-3) 0;
  border-bottom: 1px solid var(--line);
  color: inherit;
  text-decoration: none;
}

/* paper-2 behind the thumb: a picture still decoding reads as a placeholder,
   not as a broken white box. */
.row-thumb {
  width: 88px;
  height: 88px;
  border-radius: var(--r-2);
  object-fit: cover;
  border: 1px solid var(--line);
  background: var(--paper-2);
}

.row-logo {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  object-fit: contain;
  background: var(--card);
  border: 1px solid var(--line);
}

.row h3 {
  font-size: var(--fs-2);
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: var(--s-2);
  flex-wrap: wrap;
  text-wrap: pretty;
}

.row p {
  color: var(--ink-2);
  font-size: var(--fs-1);
  max-width: 60ch;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.row-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--s-2) var(--s-3);
  color: var(--ink-3);
  font-size: var(--fs-0);
  margin-top: var(--s-1);
}

.row-meta .mono {
  color: var(--ink-2);
}

.row-chips {
  display: flex;
  gap: var(--s-2);
  flex-wrap: wrap;
}

.row-app {
  grid-template-columns: 40px 1fr auto;
}

@media (max-width: 599px) {
  .row-app p {
    -webkit-line-clamp: 1;
  }
}

.row-app .row-chips {
  grid-column: 2;
}

.row-app > .link-arrow {
  grid-column: 3;
  grid-row: 1 / span 2;
  align-self: center;
}

@media (min-width: 800px) {
  .row-app {
    grid-template-columns: 40px 1fr auto auto;
    gap: var(--s-5);
  }

  .row-app .row-chips,
  .row-app > .link-arrow {
    grid-column: auto;
    grid-row: auto;
  }
}

.row.is-ab h3 {
  color: var(--autoblog-ink);
}

a.row:hover h3 {
  color: var(--link);
}

a.row.is-ab:hover h3 {
  color: var(--autoblog-ink);
}

/* Price list card (add-ons) */
.pricelist {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--r-2);
  padding: var(--s-5);
  box-shadow: var(--shadow-1);
}

.pricelist h3 {
  font-size: var(--fs-2);
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: var(--s-3);
}

.pricelist h3 span {
  font-size: var(--fs-0);
  color: var(--ink-3);
  font-weight: 500;
}

.pricelist table {
  width: 100%;
  border-collapse: collapse;
  margin-top: var(--s-3);
}

.pricelist td {
  padding: var(--s-3) 0;
  border-top: 1px solid var(--line);
  vertical-align: top;
  text-align: start;
}

.pricelist td:last-child {
  text-align: end;
  white-space: nowrap;
}

.pricelist td a {
  color: var(--ink);
  text-decoration: none;
  font-weight: 600;
}

.pricelist td a:hover {
  color: var(--link);
  text-decoration: underline;
}

.pricelist small {
  display: block;
  color: var(--ink-3);
  font-size: var(--fs-0);
}

.pricelist .is-ab a {
  color: var(--autoblog-ink);
}

.pricelist-foot {
  margin-top: var(--s-3);
  padding-top: var(--s-3);
  border-top: 1px solid var(--line);
}

/* Services: hairline list, not numbered; two columns on wide screens */
.svc-list {
  margin-top: var(--s-4);
  border-top: 1px solid var(--line-strong);
}

.svc-list li {
  padding: var(--s-3) 0;
  border-bottom: 1px solid var(--line);
}

@media (min-width: 700px) {
  .svc-list {
    display: grid;
    grid-template-columns: 1fr 1fr;
    column-gap: var(--s-7);
  }
}

.svc-list span {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.svc-list strong {
  display: block;
  font-weight: 600;
  font-size: var(--fs-1);
}

.svc-list span {
  color: var(--ink-2);
}

/* ---- FAQ: native details, plus/minus SVG, first open ---- */
.qa {
  border-top: 1px solid var(--line-strong);
}

.qa details {
  border-bottom: 1px solid var(--line);
}

.qa summary {
  list-style: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: var(--s-4);
  min-height: 48px;
  padding: var(--s-3) 0;
  font-weight: 600;
  font-size: var(--fs-2);
  color: var(--ink);
}

.qa summary::-webkit-details-marker {
  display: none;
}

.qa summary .icon {
  width: 22px;
  height: 22px;
  margin-inline-start: auto;
  color: var(--link);
}

.qa summary .icon-minus,
.qa details[open] summary .icon-plus {
  display: none;
}

.qa details[open] summary .icon-minus {
  display: block;
}

.qa .qa-a {
  padding: 0 0 var(--s-5);
  color: var(--ink-2);
  max-width: var(--measure);
}

.qa .qa-a p {
  margin-bottom: var(--s-3);
}

.qa .qa-a p:last-child {
  margin-bottom: 0;
}

.qa .qa-a ul,
.qa .qa-a ol {
  padding-inline-start: 1.2em;
  list-style: disc;
  margin-top: var(--s-2);
}

/* ---- CTA block: one per page, at the end, under a 3px blue rule ---- */
.cta-box {
  border-top: 3px solid var(--blue-deep);
  padding-top: var(--s-6);
  display: grid;
  gap: var(--s-5);
  align-items: center;
}

@media (min-width: 900px) {
  .cta-box {
    grid-template-columns: 1fr auto;
  }
}

.cta-box p {
  color: var(--ink-2);
  margin-top: var(--s-3);
  max-width: var(--measure);
  font-size: var(--fs-2);
}

.cta-actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--s-3);
  align-items: center;
}

/* The contact line: the number and the address isolate themselves (.num / .lat);
   the line itself keeps the page direction so an Arabic word next to them stays joined. */
.cta-contact {
  grid-column: 1 / -1;
  display: flex;
  flex-wrap: wrap;
  gap: var(--s-2) var(--s-5);
  font-size: var(--fs-0);
  color: var(--ink-3);
}

.cta-contact a {
  color: var(--ink-2);
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: var(--s-2);
  min-height: 44px;
}

.cta-contact a:hover {
  color: var(--link);
}

.cta-contact .icon {
  width: 18px;
  height: 18px;
}

/* ---- Interactive app demo (DESIGN.md §5, "جرّب تخصيص الثيم بنفسك") ----
   The phone is the hero (sticky at the inline-end on desktop), the controls
   sit in three tabs. Markup: views/site/components/appDemo.js; behaviour:
   public/js/site/app-demo.js. */
.demo [hidden] {
  display: none !important;
}

.demo .sec-head {
  margin-bottom: var(--s-3);
}

.demo-note {
  margin: 0 0 var(--s-6);
  color: var(--ink-3);
  font-size: var(--fs-0);
}

.demo-grid {
  display: grid;
  gap: var(--s-6);
}

.demo-stage-in {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--s-3);
}

@media (min-width: 960px) {
  .demo-grid {
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-areas: 'controls stage';
    align-items: start;
    gap: var(--s-7);
  }

  .demo-stage {
    grid-area: stage;
    align-self: stretch;
  }

  .demo-controls {
    grid-area: controls;
  }

  .demo-stage-in {
    position: sticky;
    top: calc(var(--header-h) + var(--s-4));
  }
}

/* preview language: a two-button segmented control */
.demo-lang {
  display: inline-flex;
  padding: 2px;
  border: 1px solid var(--line-strong);
  border-radius: var(--r-pill);
  background: var(--card);
}

.td-lang-tab {
  min-height: 40px;
  min-width: 96px;
  padding: 0 var(--s-4);
  border: 0;
  border-radius: var(--r-pill);
  background: transparent;
  color: var(--ink-2);
  font: inherit;
  font-size: var(--fs-0);
  font-weight: 600;
  cursor: pointer;
}

.td-lang-tab[aria-pressed='true'] {
  background: var(--ink);
  color: var(--paper);
}

/* the device: a fixed dark bezel (it is a phone in both themes) */
.demo-phone {
  height: 580px;
  aspect-ratio: 9 / 19.5;
  padding: 10px;
  border-radius: 44px;
  background: #16181d;
  box-shadow: var(--shadow-3);
}

@media (min-width: 960px) {
  .demo-phone {
    height: clamp(560px, calc(100vh - var(--header-h) - 150px), 760px);
  }
}

.td-screen {
  width: 100%;
  height: 100%;
  overflow: hidden;
  border-radius: 34px;
  background: #fff;
}

.td-screen iframe {
  display: block;
  width: 100%;
  height: 100%;
  border: 0;
}

.demo-cta {
  width: 100%;
}

/* controls: one card with three text tabs on a rule */
.demo-controls {
  container-type: inline-size;
  min-width: 0;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--r-2);
}

.demo-tabs {
  display: flex;
  overflow-x: auto;
  border-bottom: 1px solid var(--line);
  scrollbar-width: none;
}

.demo-tab {
  flex: 1 0 auto;
  min-height: 56px;
  padding: 0 var(--s-4);
  border: 0;
  border-bottom: 3px solid transparent;
  background: none;
  color: var(--ink-2);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}

.demo-tab:hover {
  color: var(--ink);
}

.demo-tab[aria-selected='true'] {
  color: var(--blue-ink);
  border-bottom-color: var(--blue-deep);
}

.demo-tab:focus-visible {
  outline-offset: -3px;
}

.demo-panel {
  padding: var(--s-5);
}

@media (max-width: 599px) {
  .demo-panel {
    padding: var(--s-4) var(--s-3);
  }
}

.demo-panel:focus-visible {
  outline-offset: -3px;
}

.demo-h {
  margin: 0 0 var(--s-3);
  font-size: var(--fs-1);
  font-weight: 600;
}

.demo-panel > * + .demo-h,
.demo-shots {
  margin-top: var(--s-5);
}

/* Design tab: the app themes as small storefront tiles */
.demo-themes {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(96px, 1fr));
  gap: var(--s-3);
}

.demo-theme {
  display: flex;
  flex-direction: column;
  gap: var(--s-2);
  padding: var(--s-2);
  border: 1.5px solid var(--line);
  border-radius: var(--r-2);
  background: var(--paper);
  color: var(--ink);
  font: inherit;
  font-weight: 600;
  text-align: start;
  cursor: pointer;
  transition: border-color var(--dur) var(--ease);
}

.demo-theme:hover {
  border-color: var(--line-strong);
}

.demo-theme.active {
  border-color: var(--blue-deep);
  background: var(--blue-tint);
  color: var(--blue-ink);
}

.demo-theme-shot {
  display: grid;
  place-items: center;
  aspect-ratio: 4 / 5;
  overflow: hidden;
  border-radius: var(--r-1);
  background: var(--paper-2);
  color: var(--ink-3);
}

.demo-theme-shot img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: top center;
}

.demo-theme-name {
  padding-inline: var(--s-1);
  line-height: 1.4;
}

.td-shots {
  display: flex;
  gap: var(--s-2);
  overflow-x: auto;
  padding-bottom: var(--s-2);
  scroll-snap-type: x proximity;
}

.td-shot {
  flex: none;
  width: 72px;
  height: 128px;
  padding: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--r-1);
  background: var(--paper-2);
  cursor: zoom-in;
  scroll-snap-align: start;
}

.td-shot img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: top center;
}

/* Colours & fonts tab */
.td-color-grid,
.td-font-grid {
  display: grid;
  gap: 0 var(--s-5);
}

.td-font-grid {
  gap: var(--s-4) var(--s-5);
}

@container (min-width: 600px) {
  .td-color-grid,
  .td-font-grid {
    grid-template-columns: 1fr 1fr;
  }
}

.td-color-item {
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr) 6.5rem 44px;
  align-items: center;
  gap: var(--s-2);
  min-height: 56px;
  border-bottom: 1px solid var(--line);
}

.td-color-input {
  width: 44px;
  height: 44px;
  padding: 0;
  border: 1px solid var(--line-strong);
  border-radius: var(--r-1);
  background: none;
  cursor: pointer;
}

.td-color-input::-webkit-color-swatch-wrapper {
  padding: 3px;
}

.td-color-input::-webkit-color-swatch {
  border: 0;
  border-radius: 4px;
}

.td-color-input::-moz-color-swatch {
  border: 0;
  border-radius: 4px;
}

.td-color-label {
  font-size: var(--fs-0);
  color: var(--ink-2);
  line-height: 1.35;
}

.td-color-code {
  width: 100%;
  min-height: 44px;
  padding: 0 var(--s-2);
  border: 1.5px solid var(--line);
  border-radius: var(--r-1);
  background: var(--paper-2);
  color: var(--ink);
  font-family: var(--font-mono);
  font-size: var(--fs-1);
  text-align: start;
}

.td-font-label {
  display: block;
  margin-bottom: var(--s-2);
  font-size: var(--fs-0);
  font-weight: 600;
  color: var(--ink-2);
}

.td-font-select,
.demo-dialog .td-field input:not([type='checkbox'], [type='color'], [type='file']),
.demo-dialog .td-field select,
.demo-dialog .td-field textarea {
  width: 100%;
  min-height: 48px;
  padding: var(--s-2) var(--s-3);
  border: 1.5px solid var(--line);
  border-radius: var(--r-1);
  background: var(--paper-2);
  color: var(--ink);
  font: inherit;
}

.demo-dialog .td-field textarea {
  min-height: 96px;
}

.td-font-preview {
  margin: var(--s-2) 0 0;
  padding: var(--s-3);
  border-radius: var(--r-1);
  background: var(--paper);
  font-size: var(--fs-2);
}

/* shared 44px icon button */
.demo-icon-btn {
  flex: none;
  display: inline-grid;
  place-items: center;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 0;
  border-radius: var(--r-1);
  background: transparent;
  color: var(--ink-2);
  cursor: pointer;
}

.demo-icon-btn:hover {
  background: var(--paper-2);
  color: var(--ink);
}

.demo-icon-btn .icon {
  width: 20px;
  height: 20px;
}

/* Sections tab: 48px rows — handle · icon · name · (settings, remove) · switch */
.demo-secs-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-3);
  margin-bottom: var(--s-3);
}

.demo-secs-head p {
  flex: 1 1 24ch;
  margin: 0;
  color: var(--ink-2);
}

.td-sections-list {
  margin: 0;
  padding: 0;
  list-style: none;
  border-top: 1px solid var(--line);
}

.td-section-item {
  display: flex;
  align-items: center;
  gap: var(--s-1);
  min-height: 48px;
  border-bottom: 1px solid var(--line);
  background: var(--card);
}

.td-sections-list.is-collapsed > .td-section-item:nth-child(n + 7) {
  display: none;
}

.td-section-item.dragging {
  opacity: 0.5;
}

.td-section-item.drag-over {
  box-shadow: inset 0 2px 0 var(--blue-deep);
}

.td-drag-handle {
  flex: none;
  display: grid;
  place-items: center;
  width: 32px;
  height: 44px;
  padding: 0;
  border: 0;
  border-radius: var(--r-1);
  background: none;
  color: var(--ink-3);
  cursor: grab;
}

.td-drag-handle .icon {
  width: 18px;
  height: 18px;
}

.td-sec-icon {
  flex: none;
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  margin-inline-end: var(--s-2);
  border-radius: var(--r-1);
  background: var(--blue-tint);
  color: var(--blue-ink);
}

.td-sec-icon .icon {
  width: 18px;
  height: 18px;
}

.td-sec-name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 500;
}

.td-section-item.is-off .td-sec-name,
.td-section-item.is-off .td-sec-icon {
  color: var(--ink-3);
}

.td-section-item.is-off .td-sec-icon {
  background: var(--paper-2);
}

/* settings / remove: folded away (no width, so the name keeps the room) until
   the row is hovered or anything in it has focus — Tab still reaches them,
   and focusing one unfolds them. */
.td-sec-actions {
  display: flex;
  max-width: 0;
  overflow: hidden;
  opacity: 0;
  transition:
    opacity var(--dur) var(--ease),
    max-width var(--dur) var(--ease);
}

.td-section-item:hover .td-sec-actions,
.td-section-item:focus-within .td-sec-actions {
  max-width: 88px;
  opacity: 1;
}

/* touch: nothing to hover, so the actions stay visible; the handle stays and
   gets a full 44px target (touch reorder runs on pointer events) */
@media (hover: none) {
  .td-sec-actions {
    max-width: none;
    opacity: 1;
  }

  .td-drag-handle {
    width: 44px;
  }
}

/* Touch reorder (pointer events in app-demo.js): the handle owns the gesture,
   so the page does not scroll while a finger drags a row. */
.td-drag-handle {
  touch-action: none;
}

.td-section-item.touch-dragging {
  position: relative;
  z-index: 2;
  background: var(--card);
  box-shadow: var(--shadow-2);
}

.td-toggle {
  position: relative;
  flex: none;
  width: 48px;
  height: 44px;
  padding: 0;
  border: 0;
  background: none;
  cursor: pointer;
}

.td-toggle span {
  position: absolute;
  inset-block: 12px;
  inset-inline: 6px;
  border-radius: var(--r-pill);
  background: var(--ink-3);
  transition: background-color var(--dur) var(--ease);
}

.td-toggle span::after {
  content: '';
  position: absolute;
  top: 2px;
  inset-inline-start: 2px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #fff;
  transition: transform var(--dur) var(--ease);
}

.td-toggle.active span {
  background: var(--blue-deep);
}

.td-toggle.active span::after {
  transform: translateX(16px);
}

[dir='rtl'] .td-toggle.active span::after {
  transform: translateX(-16px);
}

.td-sections-empty {
  margin: 0;
  padding: var(--s-5) 0;
  color: var(--ink-3);
  text-align: center;
}

.demo-more {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--s-1);
  width: 100%;
  min-height: 48px;
  margin-top: var(--s-2);
  border: 0;
  border-radius: var(--r-1);
  background: none;
  color: var(--link);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}

.demo-more:hover {
  background: var(--paper-2);
}

/* dialogs (native <dialog>): add / edit section, edit item */
.demo-dialog {
  width: min(560px, calc(100vw - 2rem));
  max-height: min(85vh, 760px);
  padding: 0;
  border: 1px solid var(--line);
  border-radius: var(--r-2);
  background: var(--card);
  color: var(--ink);
  box-shadow: var(--shadow-3);
}

.demo-dialog[open] {
  display: flex;
  flex-direction: column;
}

.demo-dialog::backdrop {
  background: rgba(11, 22, 48, 0.6);
}

.demo-dialog-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-3);
  padding-block: var(--s-2);
  padding-inline: var(--s-5) var(--s-2);
  border-bottom: 1px solid var(--line);
}

.demo-dialog-head h3 {
  font-size: var(--fs-2);
}

.demo-dialog-body {
  flex: 1;
  overflow: auto;
  padding: var(--s-5);
}

.demo-dialog-foot {
  display: flex;
  justify-content: flex-end;
  gap: var(--s-2);
  padding: var(--s-3) var(--s-5);
  border-top: 1px solid var(--line);
  background: var(--paper);
}

.demo-dialog-lead {
  margin: 0 0 var(--s-4);
  color: var(--ink-2);
}

.td-avail-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: var(--s-2);
}

.td-avail-item {
  display: grid;
  justify-items: start;
  gap: var(--s-1);
  padding: var(--s-3);
  border: 1.5px solid var(--line);
  border-radius: var(--r-2);
  background: var(--paper);
  color: var(--ink);
  font: inherit;
  text-align: start;
  cursor: pointer;
}

.td-avail-item:hover {
  border-color: var(--line-strong);
}

.td-avail-item.selected {
  border-color: var(--blue-deep);
  background: var(--blue-tint);
}

.td-avail-item .icon {
  width: 20px;
  height: 20px;
  color: var(--blue-ink);
}

.td-avail-item .name {
  font-weight: 600;
  line-height: 1.4;
}

.td-avail-item .desc {
  font-size: var(--fs-0);
  color: var(--ink-3);
}

.td-field {
  margin-bottom: var(--s-4);
}

.td-field > label,
.td-field-label {
  display: block;
  margin-bottom: var(--s-2);
  font-size: var(--fs-0);
  font-weight: 600;
  color: var(--ink-2);
}

.td-field-hint {
  margin: var(--s-2) 0 0;
  color: var(--ink-3);
  font-size: var(--fs-0);
}

.td-field-check {
  display: flex;
  align-items: center;
  gap: var(--s-2);
  min-height: 44px;
}

.td-field-check input {
  width: 20px;
  height: 20px;
}

.td-field-check > label {
  margin: 0;
  font-size: var(--fs-1);
  color: var(--ink);
}

.demo-dialog .demo-field-color {
  width: 100%;
  height: 48px;
  padding: 2px;
  border: 1.5px solid var(--line);
  border-radius: var(--r-1);
  background: var(--paper-2);
}

.demo-notice {
  display: flex;
  align-items: center;
  gap: var(--s-2);
  margin: 0;
  padding: var(--s-3);
  border-radius: var(--r-1);
  background: var(--blue-tint);
  color: var(--blue-ink);
  font-size: var(--fs-0);
}

.demo-notice .icon {
  flex: none;
  width: 18px;
  height: 18px;
}

.demo-img-prev {
  display: grid;
  place-items: center;
  height: 120px;
  overflow: hidden;
  border: 1.5px dashed var(--line-strong);
  border-radius: var(--r-2);
  background: var(--paper-2);
}

.demo-img-prev img {
  width: auto;
  height: auto;
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

.demo-img-empty {
  display: grid;
  justify-items: center;
  gap: var(--s-1);
  color: var(--ink-3);
  font-size: var(--fs-0);
}

.demo-img-empty .icon {
  width: 28px;
  height: 28px;
}

.demo-img-row {
  display: flex;
  align-items: center;
  gap: var(--s-2);
  margin-top: var(--s-2);
}

.demo-dialog .demo-img-row input[type='url'] {
  flex: 1;
  min-width: 0;
}

.demo-upload {
  flex: none;
  white-space: nowrap;
}

.demo-upload .icon {
  width: 18px;
  height: 18px;
}

.td-arr-list {
  display: grid;
  gap: var(--s-2);
  margin-bottom: var(--s-2);
}

.td-arr-row {
  display: flex;
  align-items: center;
  gap: var(--s-2);
  padding: var(--s-1) var(--s-2);
  border: 1px solid var(--line);
  border-radius: var(--r-1);
}

.td-arr-thumb {
  flex: none;
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  overflow: hidden;
  border-radius: var(--r-1);
  background: var(--paper-2);
  color: var(--ink-3);
}

.td-arr-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.td-arr-info {
  flex: 1;
  min-width: 0;
  display: grid;
}

.td-arr-title {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.td-arr-sub {
  color: var(--ink-3);
  font-size: var(--fs-0);
}

.td-arr-empty {
  margin: 0;
  padding: var(--s-3);
  border: 1px dashed var(--line);
  border-radius: var(--r-1);
  color: var(--ink-3);
  font-size: var(--fs-0);
  text-align: center;
}

.td-arr-add .icon {
  width: 18px;
  height: 18px;
}

/* screenshot lightbox */
.demo-lightbox {
  width: 100vw;
  height: 100vh;
  max-width: none;
  max-height: none;
  margin: 0;
  padding: var(--s-7) var(--s-4) var(--s-5);
  border: 0;
  background: transparent;
  color: var(--on-navy);
}

.demo-lightbox[open] {
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
  justify-items: center;
  gap: var(--s-3);
}

.demo-lightbox::backdrop {
  background: rgba(11, 22, 48, 0.9);
}

.demo-lb-stage {
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
  justify-items: center;
  gap: var(--s-2);
  min-height: 0;
  margin: 0;
}

.demo-lb-stage img {
  width: auto;
  height: auto;
  max-width: min(92vw, 560px);
  max-height: 100%;
  min-height: 0;
  object-fit: contain;
  border-radius: var(--r-2);
}

.demo-lb-stage figcaption {
  color: var(--on-navy-2);
  font-size: var(--fs-0);
}

.demo-lightbox .demo-icon-btn {
  color: var(--on-navy);
  border: 1px solid rgba(244, 241, 234, 0.35);
  border-radius: var(--r-pill);
}

.demo-lightbox .demo-icon-btn:hover {
  background: rgba(244, 241, 234, 0.12);
  color: var(--on-navy);
}

.demo-lb-close {
  position: absolute;
  top: var(--s-3);
  inset-inline-end: var(--s-3);
}

.demo-lb-nav {
  display: flex;
  gap: var(--s-3);
}
