/*
 * V0.5.8 — UX / Design-System Hardening
 *
 * Scope:
 * - Student Registry
 * - registration-link sharing
 * - Datastar hot search
 * - RTL/LTR boundaries
 * - responsive navigation
 *
 * This layer intentionally sits above app.css + v0_5.css.
 */

:root {
  --ux-space-1: .35rem;
  --ux-space-2: .55rem;
  --ux-space-3: .8rem;
  --ux-space-4: 1rem;
  --ux-space-5: 1.25rem;
  --ux-space-6: 1.5rem;
  --ux-control-height: 44px;
  --ux-content-wide: 1040px;
}


/* -------------------------------------------------------
   Shared page rhythm
------------------------------------------------------- */

.students-page {
  width: min(100%, var(--ux-content-wide));
  margin-inline: auto;
  display: grid;
  gap: var(--ux-space-4);
}

.students-page > * {
  min-width: 0;
}

.registry-stats {
  margin: 0;
}


/* -------------------------------------------------------
   Registration share component
------------------------------------------------------- */

.registry-share-card {
  display: grid;
  gap: var(--ux-space-4);
  padding: 1.05rem 1.1rem;
}

.registry-share-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--ux-space-4);
}

.registry-share-copy {
  min-width: 0;
}

.registry-card-title {
  margin: 0;
  font-size: 1rem;
  line-height: 1.5;
}

.registry-card-copy {
  margin: .18rem 0 0;
  max-width: 58rem;
  color: var(--muted);
  font-size: .82rem;
  line-height: 1.7;
}

.registry-share-field {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: var(--ux-space-2);
  min-width: 0;
  padding: .42rem;
  border: 1px solid var(--border);
  border-radius: .86rem;
  background:
    color-mix(
      in srgb,
      var(--background) 76%,
      var(--surface)
    );
}

.registry-share-url {
  box-sizing: border-box;
  width: 100%;
  min-width: 0;
  min-height: var(--ux-control-height);
  border: 0;
  outline: 0;
  border-radius: .62rem;
  padding: .55rem .7rem;
  background: transparent;
  color: var(--foreground);
  font-family:
    ui-monospace,
    SFMono-Regular,
    Menlo,
    Consolas,
    monospace;
  font-size: .78rem;
  direction: ltr;
  text-align: left;
}

.registry-share-url:focus {
  background: var(--surface);
  box-shadow:
    0 0 0 2px
    color-mix(
      in srgb,
      var(--primary) 16%,
      transparent
    );
}

.registry-share-field > .btn {
  min-height: var(--ux-control-height);
  white-space: nowrap;
}

.registry-share-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--ux-space-4);
  padding-top: .75rem;
  border-top: 1px solid
    color-mix(
      in srgb,
      var(--border) 75%,
      transparent
    );
}

.registry-rotate-note {
  margin: 0;
  max-width: 42rem;
  color: var(--muted);
  font-size: .76rem;
  line-height: 1.65;
}

.registry-rotate-form {
  flex: 0 0 auto;
  margin: 0;
}

.registry-rotate-button {
  white-space: nowrap;
}


/* -------------------------------------------------------
   Search
------------------------------------------------------- */

.registry-search-card {
  padding: 1rem 1.05rem;
}

.registry-search-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: end;
  gap: var(--ux-space-3);
}

.registry-search-field {
  display: grid;
  gap: .35rem;
  min-width: 0;
}

.registry-search-input {
  width: 100%;
  min-width: 0;
}

.registry-search-hint {
  margin: 0;
  color: var(--muted);
  font-size: .73rem;
}

.registry-search-actions {
  display: flex;
  align-items: center;
  gap: var(--ux-space-2);
}

.registry-search-submit,
.registry-search-clear {
  min-height: 44px;
}


/* -------------------------------------------------------
   Search results
------------------------------------------------------- */

.students-results-shell {
  display: grid;
  gap: .65rem;
  min-width: 0;
}

.registry-results-head {
  min-height: 1.65rem;
  display: flex;
  align-items: center;
  gap: .45rem;
  padding-inline: .15rem;
  color: var(--muted);
  font-size: .76rem;
}

.registry-results-count {
  font-weight: 700;
}

.registry-query-label {
  overflow: hidden;
  max-width: 24rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.student-registry-list {
  display: grid;
  gap: .68rem;
}

.student-registry-row {
  min-width: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 1rem;
  padding: 1rem 1.05rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow-xs);
  transition:
    border-color .16s ease,
    box-shadow .16s ease,
    transform .16s ease;
}

.student-registry-row:hover {
  border-color:
    color-mix(
      in srgb,
      var(--primary) 24%,
      var(--border)
    );
  box-shadow: var(--shadow-sm);
  transform: translateY(-1px);
}

.student-row-main {
  min-width: 0;
  display: grid;
  grid-template-columns:
    minmax(13rem, 1.5fr)
    minmax(7rem, .75fr)
    minmax(7rem, .75fr)
    minmax(7rem, .75fr);
  align-items: center;
  gap: .7rem 1rem;
}

.student-row-heading {
  min-width: 0;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: .42rem .55rem;
}

.student-row-name {
  min-width: 0;
  overflow-wrap: anywhere;
  font-size: .96rem;
  line-height: 1.6;
}

.student-code-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 4.2rem;
  min-height: 1.7rem;
  padding-inline: .48rem;
  border-radius: .56rem;
  background:
    color-mix(
      in srgb,
      var(--primary) 8%,
      var(--surface)
    );
  border: 1px solid
    color-mix(
      in srgb,
      var(--primary) 18%,
      var(--border)
    );
  color: var(--primary-strong);
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  letter-spacing: .045em;
}

.student-meta-item {
  min-width: 0;
  display: grid;
  gap: .13rem;
}

.student-meta-label {
  color: var(--muted);
  font-size: .68rem;
}

.student-meta-item strong {
  min-width: 0;
  overflow-wrap: anywhere;
  font-size: .8rem;
  font-weight: 650;
}

.student-row-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
}

.student-edit-btn {
  white-space: nowrap;
}


/* -------------------------------------------------------
   Empty state
------------------------------------------------------- */

.registry-empty {
  min-height: 170px;
  display: grid;
  place-items: center;
  align-content: center;
  gap: .35rem;
  padding: 1.4rem;
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  background:
    color-mix(
      in srgb,
      var(--surface) 75%,
      transparent
    );
  text-align: center;
}

.registry-empty-icon {
  width: 2rem;
  height: 2rem;
  display: grid;
  place-items: center;
  color: var(--primary);
}

.registry-empty-title {
  margin: 0;
  font-size: .98rem;
}

.registry-empty-copy {
  margin: 0;
  color: var(--muted);
  font-size: .78rem;
}


/* -------------------------------------------------------
   Public Student Registry polish
------------------------------------------------------- */

.student-code {
  text-align: center;
  font-variant-numeric: tabular-nums;
  letter-spacing: .12em;
  font-weight: 750;
}

.done-screen .big-score {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 8rem;
  margin: .45rem 0 .5rem;
  padding: .55rem .9rem;
  border-radius: .85rem;
  background: var(--primary-soft);
  color: var(--primary-strong);
  font-size: clamp(1.8rem, 7vw, 2.5rem);
  font-variant-numeric: tabular-nums;
  letter-spacing: .1em;
}


/* -------------------------------------------------------
   Responsive shell audit

   V0.5.8 mobile nav now contains 5 primary destinations.
   The old V0.5 layer used three fixed columns.
------------------------------------------------------- */

@media (max-width: 1100px) {
  .student-row-main {
    grid-template-columns:
      minmax(13rem, 1.4fr)
      repeat(3, minmax(6.5rem, .7fr));
  }
}

@media (max-width: 900px) {
  .mobile-bottom {
    grid-template-columns:
      repeat(5, minmax(0, 1fr));
  }

  .bottom-link {
    padding-inline: .18rem;
    font-size: .66rem;
  }

  .student-row-main {
    grid-template-columns:
      minmax(0, 1fr)
      minmax(7rem, .7fr);
  }

  .student-row-heading {
    grid-column: 1 / -1;
  }
}

@media (max-width: 680px) {
  .students-page {
    gap: .72rem;
  }

  .registry-share-head {
    align-items: stretch;
    flex-direction: column;
  }

  .registry-share-head > .badge {
    width: fit-content;
  }

  .registry-share-field {
    grid-template-columns: 1fr;
  }

  .registry-share-field > .btn {
    width: 100%;
  }

  .registry-share-footer {
    align-items: stretch;
    flex-direction: column;
  }

  .registry-rotate-form,
  .registry-rotate-form .btn {
    width: 100%;
  }

  .registry-search-form {
    grid-template-columns: 1fr;
  }

  .registry-search-actions {
    width: 100%;
  }

  .registry-search-actions .btn {
    flex: 1 1 auto;
  }

  .student-registry-row {
    grid-template-columns: 1fr;
    align-items: stretch;
  }

  .student-row-main {
    grid-template-columns:
      repeat(2, minmax(0, 1fr));
  }

  .student-row-heading {
    grid-column: 1 / -1;
  }

  .student-row-actions {
    justify-content: stretch;
  }

  .student-row-actions .btn {
    width: 100%;
  }
}

@media (max-width: 430px) {
  .registry-share-card,
  .registry-search-card,
  .student-registry-row {
    padding: .82rem;
  }

  .student-row-main {
    grid-template-columns: 1fr;
  }

  .student-row-heading {
    grid-column: auto;
  }

  .bottom-link {
    gap: .12rem;
    font-size: .61rem;
  }

  .bottom-link .ui-icon {
    width: 1rem;
    height: 1rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  .student-registry-row {
    transition: none;
  }

  .student-registry-row:hover {
    transform: none;
  }
}


/* =======================================================
   V0.5.8 FINAL DESIGN-SYSTEM HARDENING

   Keep this layer token-driven:
   - no new raw palette values
   - explicit bidi isolation
   - small missing semantic contracts
   - no replacement of established V0.5 identity tokens
======================================================= */


/* Mixed Arabic / Latin content */

.student-row-name {
  min-width: 0;
  unicode-bidi: plaintext;
  text-align: start;
}

.registry-query-label {
  max-inline-size: min(24rem, 60vw);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  unicode-bidi: isolate;
}

.student-meta-item strong[dir="auto"] {
  unicode-bidi: plaintext;
  text-align: start;
}

.registry-share-url {
  unicode-bidi: plaintext;
}


/* Semantic class contracts surfaced by the audit */

.badge-warning {
  color: var(--warning);
  background:
    color-mix(
      in srgb,
      var(--warning) 10%,
      var(--surface)
    );
  border-color:
    color-mix(
      in srgb,
      var(--warning) 24%,
      var(--border)
    );
}

.nav-label {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}

.flash-copy {
  min-width: 0;
  overflow-wrap: anywhere;
}

.password-toggle-label {
  min-width: 0;
}


/* Shared interactive geometry */

.registry-search-input,
.registry-share-url {
  min-block-size: var(--ux-control-height);
}

.registry-search-submit,
.registry-search-clear,
.registry-share-field > .btn {
  min-block-size: var(--ux-control-height);
}


/* Keep rows stable with long mixed-language values */

.student-registry-row {
  contain: layout style;
}

.student-row-heading,
.student-meta-item,
.student-row-actions {
  min-width: 0;
}


/* Narrow-screen bidi and overflow safety */

@media (max-width: 430px) {
  .registry-query-label {
    max-inline-size: 70vw;
  }

  .registry-share-url {
    font-size: .72rem;
  }

  .student-code-pill {
    letter-spacing: .035em;
  }
}


/* =======================================================
   V0.5.8 DATA REGISTRY SCALE CONTRACT

   Desktop: semantic data table.
   Mobile: dense directory rows.
   Server: 25 records per page.
======================================================= */

.registry-command-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  min-width: 0;
  padding: .72rem .82rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}

.registry-summary-bar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: .2rem .9rem;
  min-width: 0;
}

.registry-summary-item {
  display: inline-flex;
  align-items: baseline;
  gap: .28rem;
  white-space: nowrap;
}

.registry-summary-value {
  color: var(--foreground);
  font-size: .98rem;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

.registry-summary-label {
  color: var(--muted);
  font-size: .74rem;
}

.registry-link-tools {
  display: flex;
  align-items: center;
  gap: .5rem;
  flex: 0 0 auto;
}

.registry-link-details {
  position: relative;
}

.registry-link-summary {
  min-height: var(--ux-control-height);
  display: inline-flex;
  align-items: center;
  padding: .48rem .72rem;
  border: 1px solid var(--border);
  border-radius: .7rem;
  background: var(--surface);
  color: var(--foreground);
  font-size: .76rem;
  font-weight: 700;
  cursor: pointer;
  list-style: none;
}

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

.registry-link-management {
  width: min(34rem, 82vw);
  display: grid;
  gap: .7rem;
  margin-top: .5rem;
  padding: .8rem;
  border: 1px solid var(--border);
  border-radius: .8rem;
  background: var(--surface);
  box-shadow: var(--shadow-md);
}

.registry-search-form {
  grid-template-columns:
    minmax(15rem, 1.8fr)
    minmax(17rem, 1.25fr)
    auto;
  align-items: end;
}

.registry-filter-grid {
  display: grid;
  grid-template-columns:
    repeat(2, minmax(0, 1fr));
  gap: .6rem;
}

.registry-filter-field {
  display: grid;
  gap: .35rem;
  min-width: 0;
}

.registry-filter-select {
  width: 100%;
  min-width: 0;
  min-height: var(--ux-control-height);
}

.registry-table-wrap {
  min-width: 0;
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow-xs);
}

.registry-table {
  width: 100%;
  min-width: 760px;
  border-collapse: collapse;
  table-layout: fixed;
}

.registry-table th {
  padding: .68rem .72rem;
  border-bottom: 1px solid var(--border);
  background: var(--surface-soft);
  color: var(--muted);
  font-size: .7rem;
  font-weight: 750;
  text-align: start;
  white-space: nowrap;
}

.registry-table td {
  padding: .7rem .72rem;
  border-bottom: 1px solid
    color-mix(
      in srgb,
      var(--border) 72%,
      transparent
    );
  /* Top, not middle: keeps every column's first line on the same
     baseline regardless of row height. */
  vertical-align: top;
  font-size: .78rem;
}

.registry-table td.registry-col-select,
.registry-table td.registry-col-status {
  padding-block-start: .95rem;
}

.registry-table-row:last-child td {
  border-bottom: 0;
}

.registry-table-row:hover td {
  background:
    color-mix(
      in srgb,
      var(--primary) 3%,
      var(--surface)
    );
}

.registry-col-code {
  width: 6.4rem;
}

.registry-col-student {
  width: 29%;
}

.registry-col-grade {
  width: 15%;
}

.registry-col-governorate {
  width: 14%;
}

.registry-col-status {
  width: 7rem;
}

.registry-col-actions {
  width: 5.8rem;
  text-align: end;
}

.registry-col-select {
  width: 2.4rem;
}

.registry-row-select {
  width: 1.05rem;
  height: 1.05rem;
  accent-color: var(--primary);
}

.registry-bulk-bar {
  display: flex;
  align-items: center;
  gap: .7rem;
  flex-wrap: wrap;
  padding: .6rem .1rem;
}

.registry-bulk-bar .field-hint {
  margin: 0;
}

/* Name and phone sit on one line -- two display:block spans used to stack
   them into a two-line cell no matter what vertical-align the row used. */
.registry-student-line {
  display: flex;
  align-items: baseline;
  gap: .4rem;
  min-width: 0;
}

.registry-table-name {
  flex: 1 1 auto;
  min-width: 2.4rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--foreground);
  font-size: .83rem;
  line-height: 1.45;
  unicode-bidi: plaintext;
}

.registry-table-reference {
  flex: 0 0 auto;
  color: var(--muted);
  font-size: .68rem;
  white-space: nowrap;
  unicode-bidi: plaintext;
}

.registry-edit-link {
  white-space: nowrap;
}

.registry-mobile-list {
  display: none;
}

.registry-pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: .55rem;
  padding-block: .35rem;
}

.registry-page-link {
  min-width: 4.8rem;
  min-height: 2.2rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: .38rem .62rem;
  border: 1px solid var(--border);
  border-radius: .62rem;
  background: var(--surface);
  color: var(--foreground);
  font-size: .74rem;
  font-weight: 700;
  text-decoration: none;
}

.registry-page-link:hover {
  border-color:
    color-mix(
      in srgb,
      var(--primary) 30%,
      var(--border)
    );
}

.registry-page-link.is-disabled {
  opacity: .45;
  cursor: default;
}

.registry-page-current {
  min-width: 6.4rem;
  color: var(--muted);
  font-size: .73rem;
  text-align: center;
}

@media (max-width: 980px) {
  .registry-search-form {
    grid-template-columns:
      minmax(0, 1fr)
      minmax(16rem, .9fr);
  }

  .registry-search-actions {
    grid-column: 1 / -1;
    justify-content: flex-end;
  }
}

@media (max-width: 680px) {
  .students-page {
    gap: .65rem;
  }

  .registry-command-bar {
    align-items: stretch;
    flex-direction: column;
    padding: .68rem;
  }

  .registry-summary-bar {
    justify-content: space-between;
    gap: .35rem;
    padding-inline: .1rem;
  }

  .registry-link-tools {
    width: 100%;
    display: grid;
    grid-template-columns: 1fr auto;
  }

  .registry-link-tools > .btn {
    width: 100%;
  }

  .registry-link-management {
    width: calc(100vw - 3rem);
    max-width: 100%;
  }

  .registry-search-card {
    padding: .72rem;
  }

  .registry-search-form {
    grid-template-columns: 1fr;
    gap: .65rem;
  }

  .registry-filter-grid {
    grid-template-columns:
      repeat(2, minmax(0, 1fr));
  }

  .registry-search-actions {
    grid-column: auto;
  }

  .registry-table-wrap {
    display: none;
  }

  .registry-mobile-list {
    display: block;
    border-block: 1px solid var(--border);
    background: var(--surface);
  }

  .registry-mobile-row {
    position: relative;
    display: grid;
    gap: .42rem;
    padding: .8rem .15rem;
    border-bottom: 1px solid var(--border);
  }

  .registry-mobile-row:last-child {
    border-bottom: 0;
  }

  .registry-mobile-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: .6rem;
  }

  .registry-mobile-head > .registry-row-select {
    margin-top: .2rem;
    flex-shrink: 0;
  }

  .registry-mobile-identity {
    min-width: 0;
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: .35rem .48rem;
  }

  .registry-mobile-name {
    min-width: 0;
    max-width: 100%;
    overflow-wrap: anywhere;
    font-size: .86rem;
    line-height: 1.45;
    unicode-bidi: plaintext;
  }

  .registry-mobile-meta {
    min-width: 0;
    display: flex;
    flex-wrap: wrap;
    gap: .28rem .45rem;
    color: var(--muted);
    font-size: .7rem;
  }

  .registry-mobile-meta > span:not(:last-child)::after {
    content: "·";
    margin-inline-start: .45rem;
    color: var(--muted-2);
  }

  .registry-mobile-edit {
    justify-self: end;
    color: var(--primary);
    font-size: .72rem;
    font-weight: 750;
    text-decoration: none;
  }

  .registry-pagination {
    justify-content: space-between;
    gap: .35rem;
  }

  .registry-page-link {
    min-width: 4.2rem;
  }
}

@media (max-width: 430px) {
  .registry-filter-grid {
    grid-template-columns: 1fr;
  }

  .registry-summary-label {
    font-size: .68rem;
  }

  .registry-summary-value {
    font-size: .9rem;
  }

  .registry-link-tools {
    grid-template-columns: 1fr;
  }

  .registry-link-summary {
    width: 100%;
    justify-content: center;
  }
}


/* =======================================================
   V0.5.8 MOBILE COMMAND SURFACE

   Mobile admin priorities:
   1. context is already supplied by the mobile topbar
   2. registry summary stays compact
   3. search/filter opens only when needed
   4. records occupy the primary viewport
======================================================= */

.registry-mobile-search-bar {
  display: none;
}

.registry-mobile-search-dialog {
  width: min(
    calc(100% - 1rem),
    34rem
  );
  max-width: none;
  max-height: min(
    82dvh,
    44rem
  );
  margin: auto auto .5rem;
  padding: 0;
  border: 1px solid var(--border);
  border-radius:
    1.1rem
    1.1rem
    .9rem
    .9rem;
  background: var(--surface);
  color: var(--foreground);
  box-shadow: var(--shadow-md);
  overflow: hidden;
}

.registry-mobile-search-dialog::backdrop {
  background:
    color-mix(
      in srgb,
      var(--foreground) 28%,
      transparent
    );
  backdrop-filter: blur(2px);
}

.registry-mobile-dialog-shell {
  display: grid;
  gap: .9rem;
  max-height: min(
    82dvh,
    44rem
  );
  padding: 1rem;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.registry-mobile-dialog-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: .8rem;
  padding-bottom: .75rem;
  border-bottom: 1px solid var(--border);
}

.registry-mobile-dialog-title {
  margin: 0;
  font-size: 1.05rem;
  line-height: 1.5;
}

.registry-mobile-dialog-copy {
  margin: .12rem 0 0;
  color: var(--muted);
  font-size: .75rem;
  line-height: 1.6;
}

.registry-mobile-dialog-field {
  display: grid;
  gap: .35rem;
  min-width: 0;
}

.registry-mobile-dialog-input,
.registry-mobile-dialog-select {
  width: 100%;
  min-width: 0;
  min-height: var(--ux-control-height);
}

.registry-mobile-dialog-filters {
  display: grid;
  grid-template-columns:
    repeat(2, minmax(0, 1fr));
  gap: .65rem;
}

.registry-mobile-dialog-actions {
  display: grid;
  grid-template-columns:
    repeat(2, minmax(0, 1fr));
  gap: .55rem;
  padding-top: .75rem;
  border-top: 1px solid var(--border);
}

.registry-mobile-dialog-done:only-child {
  grid-column: 1 / -1;
}

.registry-mobile-filter-count {
  min-width: 1.4rem;
  height: 1.4rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-inline-start: .35rem;
  border-radius: 999px;
  background: var(--primary);
  color: var(--primary-foreground);
  font-size: .68rem;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

.registry-mobile-search-state {
  color: var(--muted);
  font-size: .7rem;
  white-space: nowrap;
}


/* -------------------------------------------------------
   Mobile registry hierarchy
------------------------------------------------------- */

@media (max-width: 680px) {

  /*
   * The mobile topbar already contains:
   * منصة الاختبارات / الطلاب
   *
   * Repeating a second hero/title/subtitle wastes the
   * highest-value viewport space.
   */
  .students-page > .page-header {
    display: none;
  }

  .students-page {
    gap: .55rem;
    padding-top: .55rem;
  }

  .registry-command-bar {
    gap: .55rem;
    padding: .6rem .65rem;
  }

  .registry-summary-bar {
    width: 100%;
    justify-content: space-between;
  }

  .registry-summary-item {
    gap: .2rem;
  }

  .registry-link-tools {
    width: 100%;
    grid-template-columns:
      repeat(2, minmax(0, 1fr));
    gap: .45rem;
  }

  .registry-link-tools > .btn,
  .registry-link-summary {
    width: 100%;
    min-height: 2.55rem;
    justify-content: center;
  }

  /*
   * Desktop keeps its full inline search/filter form.
   * Mobile replaces it with one command surface.
   */
  .registry-search-card {
    display: none;
  }

  .registry-mobile-search-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: .6rem;
    padding: .5rem .6rem;
    border: 1px solid var(--border);
    border-radius: .82rem;
    background: var(--surface);
    box-shadow: var(--shadow-xs);
  }

  .registry-mobile-search-trigger {
    min-height: 2.55rem;
    flex: 1 1 auto;
    justify-content: center;
  }

  .registry-results-head {
    min-height: 1.35rem;
    padding-block: .05rem;
  }

  .registry-mobile-list {
    margin-top: 0;
  }
}


/*
 * Native dialog becomes a bottom sheet only on narrow
 * application layouts.
 */
@media (max-width: 680px) {
  .registry-mobile-search-dialog {
    position: fixed;
    inset:
      auto
      .5rem
      .5rem
      .5rem;
    width: auto;
    margin: 0;
  }
}


@media (max-width: 430px) {

  /*
   * Keep the two primary registration-link commands
   * side-by-side even on phone widths.
   */
  .registry-link-tools {
    grid-template-columns:
      repeat(2, minmax(0, 1fr));
  }

  .registry-mobile-dialog-filters {
    grid-template-columns: 1fr;
  }

  .registry-mobile-dialog-actions {
    grid-template-columns: 1fr;
  }

  .registry-mobile-dialog-done,
  .registry-mobile-dialog-reset {
    grid-column: auto;
  }

  .registry-mobile-search-state {
    display: none;
  }
}


/* =======================================================
   V0.5.8 PREMIUM DATETIME PICKER

   Local wall-time UI only.
   Canonical form value remains YYYY-MM-DDTHH:MM.
======================================================= */

.premium-datetime-picker {
  min-width: 0;
}

.premium-datetime-summary {
  display: grid;
  grid-template-columns:
    minmax(0, 1.45fr)
    minmax(7.5rem, .55fr);
  gap: .55rem;
}

.premium-datetime-segment {
  min-width: 0;
  min-height: 4rem;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: center;
  gap: .2rem;
  padding: .65rem .75rem;
  border: 1px solid var(--border);
  border-radius: .82rem;
  background: var(--surface);
  color: var(--foreground);
  text-align: start;
  cursor: pointer;
}

.premium-datetime-segment:hover {
  border-color:
    color-mix(
      in srgb,
      var(--primary) 32%,
      var(--border)
    );
  background:
    color-mix(
      in srgb,
      var(--primary) 2.5%,
      var(--surface)
    );
}

.premium-datetime-segment:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

.premium-datetime-segment-label {
  color: var(--muted);
  font-size: .68rem;
  font-weight: 700;
}

.premium-datetime-segment-value {
  max-width: 100%;
  overflow-wrap: anywhere;
  font-size: .8rem;
  line-height: 1.45;
}

.premium-datetime-time-value {
  font-variant-numeric: tabular-nums;
  letter-spacing: .02em;
}

.premium-datetime-dialog {
  width: min(
    42rem,
    calc(100% - 2rem)
  );
  max-width: none;
  max-height: min(
    88dvh,
    48rem
  );
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 1rem;
  background: var(--surface);
  color: var(--foreground);
  box-shadow: var(--shadow-md);
  overflow: hidden;
}

.premium-datetime-dialog::backdrop {
  background:
    color-mix(
      in srgb,
      var(--foreground) 30%,
      transparent
    );
  backdrop-filter: blur(2px);
}

.premium-datetime-dialog-shell {
  display: grid;
  gap: .9rem;
  max-height: min(
    88dvh,
    48rem
  );
  padding: 1rem;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.premium-datetime-dialog-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: .8rem;
  padding-bottom: .75rem;
  border-bottom: 1px solid var(--border);
}

.premium-datetime-dialog-title {
  margin: 0;
  font-size: 1.05rem;
  line-height: 1.5;
}

.premium-datetime-dialog-copy {
  margin: .12rem 0 0;
  color: var(--muted);
  font-size: .75rem;
  line-height: 1.6;
}

.premium-datetime-tabs {
  display: grid;
  grid-template-columns:
    repeat(2, minmax(0, 1fr));
  gap: .35rem;
  padding: .28rem;
  border: 1px solid var(--border);
  border-radius: .78rem;
  background: var(--surface-soft);
}

.premium-datetime-tab {
  min-height: 2.55rem;
  border: 0;
  border-radius: .6rem;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: .76rem;
  font-weight: 750;
  cursor: pointer;
}

.premium-datetime-tab.is-active {
  background: var(--surface);
  color: var(--foreground);
  box-shadow: var(--shadow-xs);
}

.premium-datetime-panel {
  min-width: 0;
}

.premium-calendar-head {
  display: grid;
  grid-template-columns:
    2.7rem minmax(0, 1fr) 2.7rem;
  align-items: center;
  gap: .45rem;
  margin-bottom: .65rem;
}

.premium-calendar-nav {
  width: 2.7rem;
  height: 2.7rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border);
  border-radius: .68rem;
  background: var(--surface);
  color: var(--foreground);
  font-size: 1.15rem;
  cursor: pointer;
}

.premium-calendar-month {
  min-width: 0;
  text-align: center;
  font-size: .88rem;
  line-height: 1.5;
}

.premium-calendar-weekdays,
.premium-calendar-grid {
  display: grid;
  grid-template-columns:
    repeat(7, minmax(0, 1fr));
  gap: .28rem;
}

.premium-calendar-weekdays {
  margin-bottom: .32rem;
}

.premium-calendar-weekday {
  padding-block: .3rem;
  color: var(--muted);
  font-size: .64rem;
  font-weight: 750;
  text-align: center;
}

.premium-calendar-day {
  min-width: 0;
  min-height: 2.75rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid transparent;
  border-radius: .7rem;
  background: transparent;
  color: var(--foreground);
  font: inherit;
  font-size: .76rem;
  font-variant-numeric: tabular-nums;
  cursor: pointer;
}

.premium-calendar-day:hover {
  border-color: var(--border);
  background: var(--surface-soft);
}

.premium-calendar-day.is-selected {
  border-color: var(--primary);
  background: var(--primary);
  color: var(--primary-foreground);
  font-weight: 800;
}

.premium-calendar-day.is-empty {
  pointer-events: none;
}

.premium-time-preview {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: .75rem;
  margin-bottom: .8rem;
  padding: .7rem .78rem;
  border: 1px solid var(--border);
  border-radius: .78rem;
  background: var(--surface-soft);
}

.premium-time-preview-label {
  color: var(--muted);
  font-size: .72rem;
}

.premium-time-preview-value {
  font-size: 1.3rem;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  letter-spacing: .04em;
}

.premium-time-grid {
  display: grid;
  grid-template-columns:
    minmax(0, 1.45fr)
    minmax(0, .8fr);
  gap: .9rem;
}

.premium-time-section {
  display: grid;
  gap: .45rem;
  min-width: 0;
}

.premium-time-section-label {
  color: var(--muted);
  font-size: .7rem;
  font-weight: 750;
}

.premium-time-options {
  display: grid;
  gap: .32rem;
  direction: ltr;
}

.premium-time-hours {
  grid-template-columns:
    repeat(6, minmax(0, 1fr));
}

.premium-time-minutes {
  grid-template-columns:
    repeat(4, minmax(0, 1fr));
}

.premium-time-option {
  min-width: 0;
  min-height: 2.45rem;
  border: 1px solid var(--border);
  border-radius: .62rem;
  background: var(--surface);
  color: var(--foreground);
  font: inherit;
  font-size: .72rem;
  font-variant-numeric: tabular-nums;
  cursor: pointer;
}

.premium-time-option:hover {
  border-color:
    color-mix(
      in srgb,
      var(--primary) 32%,
      var(--border)
    );
}

.premium-time-option.is-selected {
  border-color: var(--primary);
  background:
    color-mix(
      in srgb,
      var(--primary) 11%,
      var(--surface)
    );
  color: var(--primary-strong);
  font-weight: 800;
}

.premium-time-manual-field {
  display: grid;
  gap: .38rem;
  margin-top: .9rem;
  padding-top: .8rem;
  border-top: 1px solid var(--border);
}

.premium-time-manual {
  max-width: 9rem;
  font-variant-numeric: tabular-nums;
  letter-spacing: .04em;
  text-align: center;
}

.premium-time-manual[aria-invalid="true"] {
  border-color: var(--danger);
}

.premium-datetime-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: .5rem;
  padding-top: .75rem;
  border-top: 1px solid var(--border);
}

@media (max-width: 680px) {
  .premium-datetime-summary {
    grid-template-columns:
      minmax(0, 1.35fr)
      minmax(6.7rem, .65fr);
  }

  .premium-datetime-dialog {
    position: fixed;
    inset:
      auto
      .5rem
      .5rem
      .5rem;
    width: auto;
    max-height: 88dvh;
    margin: 0;
    border-radius:
      1.05rem
      1.05rem
      .85rem
      .85rem;
  }

  .premium-datetime-dialog-shell {
    max-height: 88dvh;
    padding: .85rem;
  }

  .premium-calendar-day {
    min-height: 2.6rem;
  }

  .premium-time-grid {
    grid-template-columns: 1fr;
  }

  .premium-time-hours {
    grid-template-columns:
      repeat(6, minmax(0, 1fr));
  }

  .premium-time-minutes {
    grid-template-columns:
      repeat(7, minmax(0, 1fr));
  }
}

@media (max-width: 430px) {
  .premium-datetime-summary {
    grid-template-columns:
      repeat(2, minmax(0, 1fr));
  }

  .premium-datetime-segment {
    min-height: 3.7rem;
    padding: .58rem .62rem;
  }

  .premium-time-hours {
    grid-template-columns:
      repeat(4, minmax(0, 1fr));
  }

  .premium-time-minutes {
    grid-template-columns:
      repeat(4, minmax(0, 1fr));
  }

  .premium-datetime-actions {
    display: grid;
    grid-template-columns:
      repeat(2, minmax(0, 1fr));
  }

  .premium-datetime-actions > .btn {
    width: 100%;
  }
}


/* =======================================================
   V0.5.8 MOBILE APP SHELL

   Section pages:
     shell owns page identity.

   Context pages:
     entity/document/quiz identity remains visible,
     but as a compact contextual surface.

   Mobile is not a compressed desktop layout.
======================================================= */

@media (max-width: 900px) {

  /*
   * Highest-value viewport space starts immediately
   * beneath the fixed application bar.
   */
  .teacher-main {
    padding:
      calc(var(--topbar-height) + .55rem)
      .65rem
      calc(var(--bottom-nav-height) + 1rem);
  }


  /* -----------------------------------------------------
     Mobile application bar
  ----------------------------------------------------- */

  .mobile-topbar {
    gap: .55rem;
  }

  .mobile-title {
    line-height: 1.12;
  }

  .mobile-brand {
    color: var(--muted);
    font-size: .64rem;
    font-weight: 700;
  }

  .mobile-screen-title {
    margin-top: .08rem;
    color: var(--foreground);
    font-size: .84rem;
    font-weight: 800;
  }


  /* -----------------------------------------------------
     Canonical page-header behavior
  ----------------------------------------------------- */

  .page-header-section.no-actions {
    display: none;
  }

  .page-header-section.has-actions {
    margin: 0 0 .55rem;
    padding: 0;
  }

  .page-header-section.has-actions
  .page-heading-copy {
    display: none;
  }

  .page-header-section.has-actions
  > .header-actions {
    width: 100%;
  }

  .page-header-section.has-actions
  > .header-actions
  > .btn:only-child {
    width: 100%;
    min-height: 2.65rem;
    justify-content: center;
  }


  /*
   * Entity/detail pages keep identity,
   * but no second desktop hero.
   */
  .page-header-context {
    display: grid;
    gap: .52rem;
    margin: 0 0 .7rem;
    padding: .15rem 0 .62rem;
    border-bottom: 1px solid var(--border);
  }

  .page-header-context
  .page-heading-copy {
    min-width: 0;
  }

  .page-header-context
  .page-eyebrow {
    display: none;
  }

  .page-header-context
  .page-title {
    margin: 0;
    font-size: 1.05rem;
    line-height: 1.4;
    letter-spacing: 0;
    overflow-wrap: anywhere;
  }

  .page-header-context
  .page-subtitle {
    margin: .12rem 0 0;
    max-width: none;
    color: var(--muted);
    font-size: .72rem;
    line-height: 1.55;
    overflow-wrap: anywhere;
  }

  .page-header-context
  > .header-actions {
    width: 100%;
    display: flex;
    flex-wrap: nowrap;
    gap: .42rem;
    overflow-x: auto;
    overscroll-behavior-inline: contain;
    scrollbar-width: none;
    padding-bottom: .08rem;
  }

  .page-header-context
  > .header-actions::-webkit-scrollbar {
    display: none;
  }

  .page-header-context
  > .header-actions
  > * {
    flex: 0 0 auto;
  }

  .page-header-context
  .header-actions
  .btn {
    white-space: nowrap;
  }


  /* -----------------------------------------------------
     Dashboard becomes an app home surface,
     not another hero card.
  ----------------------------------------------------- */

  .dashboard-hero {
    min-height: 0;
    margin: 0 0 .45rem;
    padding: .18rem 0 .55rem;
    align-items: flex-start;
    border: 0;
    border-radius: 0;
    background: transparent;
    box-shadow: none;
  }

  .dashboard-hero::before {
    display: none;
  }

  .dashboard-kicker {
    display: none;
  }

  .dashboard-title {
    font-size: 1.14rem;
    line-height: 1.4;
    letter-spacing: 0;
  }

  .dashboard-subtitle {
    margin-top: .16rem;
    max-width: none;
    font-size: .72rem;
    line-height: 1.55;
  }

  /*
   * Create Quiz already exists in the mobile topbar.
   */
  .dashboard-hero-action {
    display: none;
  }


  /* -----------------------------------------------------
     Dense mobile metrics
  ----------------------------------------------------- */

  .stats-grid {
    grid-template-columns:
      repeat(2, minmax(0, 1fr));
    gap: .45rem;
  }

  .stat-card {
    min-height: 0;
    padding: .62rem .68rem;
    border-radius: .78rem;
    box-shadow: none;
  }

  .stat-head {
    gap: .45rem;
  }

  .stat-icon-wrap {
    width: 2rem;
    height: 2rem;
    flex-basis: 2rem;
  }

  .stat-value {
    font-size: 1.22rem;
  }

  .stat-label {
    font-size: .68rem;
  }

  .stat-subtitle {
    display: none;
  }


  /* -----------------------------------------------------
     Section rhythm
  ----------------------------------------------------- */

  .section-heading {
    align-items: end;
    gap: .5rem;
    margin: .72rem 0 .42rem;
  }

  .section-heading h2 {
    font-size: .92rem;
  }

  .section-heading p {
    margin-top: .08rem;
    font-size: .68rem;
  }

  .block-heading {
    margin: .85rem 0 .48rem;
  }

  .block-title {
    font-size: .96rem;
  }


  /* -----------------------------------------------------
     Mobile data/list surface

     A list is one visual object. Its rows do not each
     need an independent floating card.
  ----------------------------------------------------- */

  .quiz-list {
    gap: 0;
    overflow: hidden;
    border: 1px solid var(--border);
    border-radius: .9rem;
    background: var(--surface);
    box-shadow: var(--shadow-xs);
  }

  .quiz-list > .card {
    border: 0;
    border-bottom: 1px solid var(--border);
    border-radius: 0;
    background: transparent;
    box-shadow: none;
  }

  .quiz-list > .card:last-child {
    border-bottom: 0;
  }

  .quiz-row-card,
  .result-overview-card {
    padding: .76rem .78rem;
    gap: .58rem;
  }

  .quiz-row-card::before {
    display: none;
  }

  .quiz-row-card:hover {
    border-color: transparent;
    box-shadow: none;
    transform: none;
  }

  .quiz-title {
    font-size: .88rem;
    line-height: 1.55;
  }

  .mini-metrics,
  .row-meta {
    gap: .3rem;
  }

  .quiz-card-actions {
    gap: .4rem;
  }


  /* -----------------------------------------------------
     Information and form surfaces
  ----------------------------------------------------- */

  .source-policy-card {
    margin-bottom: .55rem;
    padding: .62rem .72rem;
    border-radius: .78rem;
    box-shadow: none;
  }

  .source-policy-card
  .section-title {
    font-size: .78rem;
  }

  .source-policy-card p {
    margin: .16rem 0 0;
    font-size: .7rem;
    line-height: 1.55;
  }

  .form-card,
  .narrow-card {
    padding: .82rem;
    border-radius: .88rem;
    box-shadow: none;
  }

  .form-actions {
    gap: .45rem;
  }


  /* -----------------------------------------------------
     Mobile bottom navigation remains the stable
     five-destination primary navigation.
  ----------------------------------------------------- */

  .mobile-bottom {
    grid-template-columns:
      repeat(5, minmax(0, 1fr));
  }

  .bottom-link {
    padding-inline: .12rem;
    font-size: .63rem;
  }
}


@media (max-width: 430px) {

  .teacher-main {
    padding-inline: .52rem;
  }

  .page-header-context
  .page-title {
    font-size: 1rem;
  }

  .stats-grid {
    gap: .38rem;
  }

  .stat-card {
    padding: .56rem .58rem;
  }

  .quiz-row-card,
  .result-overview-card {
    padding: .7rem .68rem;
  }

  .form-card,
  .narrow-card {
    padding: .72rem;
  }
}


/* =======================================================
   V0.5.8 COMPACT PREMIUM TIME SURFACE

   Desktop keeps the full structured picker.

   Mobile uses horizontally scrollable, snap-aligned
   hour/minute rails so time selection does not turn
   into a tall keypad.
======================================================= */

@media (max-width: 680px) {

  .premium-datetime-time-panel {
    min-width: 0;
  }

  .premium-time-preview {
    margin-bottom: .62rem;
    padding: .62rem .7rem;
  }

  .premium-time-preview-label {
    font-size: .68rem;
  }

  .premium-time-preview-value {
    font-size: 1.42rem;
  }

  .premium-time-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: .7rem;
  }

  .premium-time-section {
    min-width: 0;
    gap: .38rem;
  }

  .premium-time-section-label {
    font-size: .68rem;
  }

  /*
   * Horizontal selector rails.
   *
   * Direction stays LTR because time is a technical
   * numeric value even inside the RTL application.
   */
  .premium-time-options,
  .premium-time-hours,
  .premium-time-minutes {
    display: flex;
    grid-template-columns: none;
    min-width: 0;
    gap: .36rem;
    padding:
      .08rem
      .08rem
      .34rem;
    overflow-x: auto;
    overflow-y: hidden;
    overscroll-behavior-inline: contain;
    scroll-snap-type: x proximity;
    scrollbar-width: none;
    direction: ltr;
  }

  .premium-time-options::-webkit-scrollbar,
  .premium-time-hours::-webkit-scrollbar,
  .premium-time-minutes::-webkit-scrollbar {
    display: none;
  }

  .premium-time-option {
    flex:
      0
      0
      3.25rem;
    min-width: 3.25rem;
    min-height: 2.7rem;
    padding-inline: .4rem;
    scroll-snap-align: center;
    border-radius: .68rem;
    font-size: .75rem;
  }

  .premium-time-option.is-selected {
    box-shadow:
      inset
      0
      0
      0
      1px
      color-mix(
        in srgb,
        var(--primary) 20%,
        transparent
      );
  }

  .premium-time-manual-field {
    margin-top: .68rem;
    padding-top: .68rem;
  }

  .premium-time-manual {
    max-width: none;
    width: 100%;
    min-height: 3rem;
    font-size: 1rem;
    font-weight: 750;
  }

  .premium-time-manual-field
  .field-hint {
    margin-top: .1rem;
    font-size: .65rem;
    line-height: 1.5;
  }

  .premium-datetime-actions {
    margin-top: .05rem;
    padding-top: .68rem;
  }
}


@media (max-width: 430px) {

  .premium-datetime-dialog-copy {
    display: none;
  }

  .premium-datetime-dialog-head {
    align-items: center;
    padding-bottom: .58rem;
  }

  .premium-datetime-tabs {
    margin-top: -.05rem;
  }

  .premium-time-preview {
    margin-bottom: .48rem;
  }

  .premium-time-option {
    flex-basis: 3.15rem;
    min-width: 3.15rem;
  }
}


/* =======================================================
   V0.5.8 DELEGATED INTERACTION SURFACES
======================================================= */

.clipboard-probe {
  position: fixed;
  inset: auto auto 0 0;
  width: 1px;
  height: 1px;
  padding: 0;
  border: 0;
  opacity: 0;
  pointer-events: none;
}


/* Quiz contextual commands */

.quiz-context-actions {
  display: flex;
  align-items: center;
  gap: .45rem;
  min-width: 0;
}

.quiz-context-actions
.inline-form {
  margin: 0;
}

.quiz-context-more {
  display: none;
}


/* Secondary quiz action dialog */

.quiz-action-dialog,
.app-confirm-dialog {
  width: min(
    28rem,
    calc(100% - 2rem)
  );
  max-width: none;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 1rem;
  background: var(--surface);
  color: var(--foreground);
  box-shadow: var(--shadow-md);
  overflow: hidden;
}

.quiz-action-dialog::backdrop,
.app-confirm-dialog::backdrop {
  background:
    color-mix(
      in srgb,
      var(--foreground) 30%,
      transparent
    );
  backdrop-filter: blur(2px);
}

.quiz-action-sheet,
.app-confirm-shell {
  display: grid;
  gap: .85rem;
  padding: 1rem;
}

.quiz-action-sheet-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: .75rem;
  padding-bottom: .7rem;
  border-bottom: 1px solid var(--border);
}

.quiz-action-sheet-title,
.app-confirm-title {
  margin: 0;
  font-size: 1rem;
  line-height: 1.5;
}

.quiz-action-sheet-copy,
.app-confirm-copy {
  margin: .12rem 0 0;
  color: var(--muted);
  font-size: .72rem;
  line-height: 1.55;
}

.quiz-action-sheet-form,
.quiz-action-sheet-button {
  width: 100%;
}

.app-confirm-actions {
  display: grid;
  grid-template-columns:
    repeat(2, minmax(0, 1fr));
  gap: .5rem;
}

.app-confirm-actions > .btn {
  width: 100%;
}


@media (max-width: 900px) {

  /*
   * Context actions must fit the viewport.
   * No horizontal command scrolling.
   */
  .page-header-context
  > .header-actions {
    overflow: visible;
  }

  .quiz-context-actions {
    width: 100%;
    display: grid;
    grid-template-columns:
      repeat(2, minmax(0, 1fr));
    gap: .42rem;
  }

  .quiz-context-open,
  .quiz-context-results,
  .quiz-context-more {
    width: 100%;
    min-width: 0;
    justify-content: center;
  }

  .quiz-context-more {
    display: inline-flex;
    grid-column: 1 / -1;
  }

  .quiz-context-duplicate-desktop {
    display: none;
  }

  .quiz-action-dialog,
  .app-confirm-dialog {
    position: fixed;
    inset:
      auto
      .5rem
      .5rem
      .5rem;
    width: auto;
    margin: 0;
    border-radius:
      1.05rem
      1.05rem
      .85rem
      .85rem;
  }

  .quiz-action-sheet,
  .app-confirm-shell {
    padding: .85rem;
  }
}


@media (max-width: 430px) {

  .quiz-context-actions {
    gap: .38rem;
  }

  .quiz-context-actions
  .btn {
    min-height: 2.65rem;
    padding-inline: .55rem;
    font-size: .71rem;
  }
}


/* =======================================================
   V0.5.8 LIVE SOURCE PROCESSING

   Source background work uses a short-lived authenticated
   Datastar SSE stream. The page shell and source preview
   remain stable while status/review surfaces morph.
======================================================= */

.source-live-controller {
  display: none;
}

#source-live-summary {
  transition:
    border-color 140ms ease,
    box-shadow 140ms ease;
}

#source-live-summary[aria-busy="true"] {
  border-color:
    color-mix(
      in srgb,
      var(--primary) 18%,
      var(--border)
    );
}

#source-live-summary
.badge-info:first-child {
  white-space: nowrap;
}
