/* ═══════════════════════════════════════════════════════════
     Scratch 
     Font: system-ui / SF Pro 
     ═══════════════════════════════════════════════════════════ */

  @font-face {
    font-family: opendy;
    src: url(https://cdn.8ball.space/OpenDyslexic/OpenDyslexic-Regular.woff2);
  }

  :root {
    /* - Surfaces - */
    --bg: #0c1218;
    --bg-card: #141c24;
    /* - Borders - */
    --border: #2d3a46;
    /* - Typography - */
    --text: #f0f5fa;
    --text-muted: rgba(240,245,250,0.55);
    /* - Brand - */
    --accent: #79b8ff;
    --accent-text: #0e1016;
    /* - Links - */
    --link: #79b8ff;
    /* - Semantic - */
    --danger: #f85149;
    --copy-flash: #1c2a38;
    /* - Navigation - */
    --suite-bottom-nav-height: 56px;
    --suite-bottom-nav-offset: calc(var(--suite-bottom-nav-height) + env(safe-area-inset-bottom, 0px) + 0.5rem);
    /* - Radius scale (Apple HIG) - */
    --r-xs: 6px;
    --r-sm: 8px;
    --r-md: 12px;
    --r-lg: 16px;
    --r-xl: 20px;
    --r-pill: 999px;
  }


  /* - Reset - */
  *, *::before, *::after { box-sizing: border-box; }

  html, body {
    -webkit-text-size-adjust: 100%;
    overflow-x: hidden;
  }

  /* - Base - */
  body {
    font-family: system-ui, -apple-system, BlinkMacSystemFont, "SF Pro Text", "Helvetica Neue", Helvetica, Arial, sans-serif;
    margin: 0;
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
    letter-spacing: -0.012em;
    font-size: 1rem;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
  }

  /* - Layout - */
  .container {
    max-width: 1180px;
    margin: 0 auto;
    padding: 1.25rem 1rem;
    width: 100%;
  }

  /* - Typography - */
  h1, h2, h3, h4, h5, h6 {
    font-weight: 700;
    letter-spacing: -0.025em;
    line-height: 1.15;
    margin: 0 0 0.5rem;
  }

  h1 { font-size: clamp(1.7rem, 5vw, 2.5rem); font-weight: 800; }
  h2 { font-size: clamp(1.2rem, 3vw, 1.65rem); }
  h3 { font-size: clamp(1rem, 2.4vw, 1.2rem); }
  p  { margin: 0.4rem 0; }

  a {
    color: var(--link);
    text-decoration: none;
    font-weight: 500;
  }
  a:hover { text-decoration: underline; }

  /* - Focus - */
  input:focus, button:focus, select:focus, a:focus, textarea:focus {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
  }

  /* ══════════════════════════════════════════════════════════
     BUTTON SYSTEM  -  Apple Filled / Tinted / Plain
     ══════════════════════════════════════════════════════════ */
  .button-link,
  button,
  .btn-primary,
  .btn-secondary,
  .upload,
  .delete,
  .disable {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.45rem;
    font: inherit;
    font-weight: 600;
    font-size: 0.93rem;
    letter-spacing: -0.01em;
    padding: 0.6rem 1.1rem;
    border-radius: var(--r-pill);
    border: none;
    min-height: 44px;
    cursor: pointer;
    white-space: nowrap;
    text-decoration: none;
    transition: opacity 0.15s ease, background 0.15s ease, color 0.15s ease;
    vertical-align: middle;
    -webkit-tap-highlight-color: transparent;
    word-break: keep-all;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  /* Filled primary */
  .button-link,
  .btn-primary,
  .upload,
  .delete {
    background: var(--accent);
    color: var(--accent-text, #fff);
  }
  .button-link:hover, .btn-primary:hover, .upload:hover, .delete:hover {
    opacity: 0.84;
    text-decoration: none;
  }

  /* Tinted secondary */
  button,
  .btn-secondary {
    background: color-mix(in srgb, var(--accent) 15%, var(--bg-card) 85%);
    color: var(--accent);
  }
  button:hover,
  .btn-secondary:hover {
    background: color-mix(in srgb, var(--accent) 24%, var(--bg-card) 76%);
    text-decoration: none;
  }

  /* Muted / destructive tint for .disable */
  .disable {
    background: color-mix(in srgb, var(--bg-card) 80%, var(--bg) 20%);
    color: var(--text-muted);
    border: 1px solid var(--border);
  }

  /* Inline content helper */
  .button-link p,
  .delete p,
  .upload p,
  .disable p,
  button p {
    display: inline;
    margin: 0;
  }

  /* ══════════════════════════════════════════════════════════
     FORM
     ══════════════════════════════════════════════════════════ */
  form {
    display: grid;
    gap: 0.8rem;
  }
  form button { width: auto; }

  /* - Inputs - */
  input, textarea {
    font: inherit;
    padding: 0.65rem 0.9rem;
    border-radius: var(--r-md);
    border: 1px solid var(--border);
    background: var(--bg-card);
    color: var(--text);
    min-height: 44px;
    font-size: 0.93rem;
    width: 100%;
    transition: border-color 0.15s, background 0.15s;
    letter-spacing: -0.01em;
  }
  input:focus, textarea:focus {
    border-color: var(--accent);
    outline: none;
    background: color-mix(in srgb, var(--bg-card) 90%, var(--accent) 10%);
  }

  /* - Select - */
  /* color-scheme on :root ensures the native dropdown list matches the theme.
     --select-arrow is a full url() token overridden to dark arrow on light themes. */
  select {
    font: inherit;
    padding: 0.55rem 2.2rem 0.55rem 0.85rem;
    border-radius: var(--r-md);
    border: 1px solid var(--border);
    background-color: var(--bg-card);
    color: var(--text);
    appearance: none;
    cursor: pointer;
    min-height: 44px;
    font-size: 0.93rem;
    transition: border-color 0.15s, background-color 0.15s;
    background-image: var(--select-arrow);
    background-repeat: no-repeat;
    background-position: right 0.65rem center;
    background-size: 1.1rem;
  }
  select:hover { border-color: var(--accent); }
  select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent) 30%, transparent); }
  option { background: var(--bg-card); color: var(--text); }

  /* - Sort form - */
  .sort-form {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 1rem;
  }
  .sort-form label {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    font-weight: 600;
    font-size: 0.88rem;
    color: var(--text-muted);
  }
  /* Hide the always-on sort button on desktop - onchange auto-submits there */
  .sort-apply-btn { display: none; }

  /* ══════════════════════════════════════════════════════════
     CARD  -  Apple Grouped Section surface
     ══════════════════════════════════════════════════════════ */
  .card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    padding: 1rem 1.1rem;
    margin: 0;
    overflow-x: auto;
    overflow-y: visible;
    outline: none;
  }
  .card:focus {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
  }
  .card a:not(.button-link):not(.btn-primary):not(.btn-secondary) {
    color: var(--accent);
    text-decoration: none;
    font-weight: 600;
  }
  .card a:not(.button-link):not(.btn-primary):not(.btn-secondary):hover {
    text-decoration: underline;
  }
  .card p, .card li { margin: 0.4rem 0; }

  /* - Row - */
  .row {
    display: flex;
    gap: 0.65rem;
    flex-wrap: wrap;
    align-items: center;
  }

  /* ══════════════════════════════════════════════════════════
     TABLES  -  Inset-grouped iOS style
     ══════════════════════════════════════════════════════════ */
  table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0 0.35rem;
  }
  td, th {
    padding: 0.65rem 0.75rem;
    text-align: left;
    vertical-align: middle;
    word-break: break-word;
    overflow-wrap: break-word;
    background: var(--bg-card);
    border: none;
  }
  tr td:first-child, tr th:first-child {
    border-top-left-radius: var(--r-md);
    border-bottom-left-radius: var(--r-md);
  }
  tr td:last-child, tr th:last-child {
    border-top-right-radius: var(--r-md);
    border-bottom-right-radius: var(--r-md);
  }
  td.col-actions, th.col-actions {
    white-space: nowrap;
    width: 1%;
  }
  #imagesTable img {
    height: 50px;
    width: 80px;
    object-fit: cover;
    border-radius: var(--r-sm);
    display: block;
  }
  th {
    font-weight: 700;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-muted);
  }

  /* ══════════════════════════════════════════════════════════
     UTILITIES
     ══════════════════════════════════════════════════════════ */
  .muted  { color: var(--text-muted); }
  .danger { color: var(--danger); }

  .copy-link {
    color: var(--accent);
    cursor: pointer;
    text-decoration: none;
    font-weight: 600;
  }
  .copy-link:hover { text-decoration: underline; }

  .link-icon { display: none; font-size: 1.1rem; }

  .col-link .link-text {
    display: inline-block;
    max-width: 100%;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .col-link .link-text,
  .copy-link .link-text {
    color: var(--text);
    text-decoration: underline;
    text-decoration-color: color-mix(in srgb, var(--accent) 45%, transparent);
    text-underline-offset: 2px;
    font-weight: 600;
  }

  /* - Responsive hide/show - */
  @media (max-width: 1000px) {
    .link-text { display: none; }
    .hide { display: none; }
    .link-icon { display: inline; }
    .container { max-width: 100%; }
    .upload-box { max-width: 100%; }
    .row { gap: 0.5rem; }
  }

  /* ══════════════════════════════════════════════════════════
     DROPDOWN  -  iOS action-sheet inspired
     ══════════════════════════════════════════════════════════ */
  .dropdown {
    position: relative;
    display: inline-block;
  }
  /* Remove native <details>/<summary> disclosure marker */
  details.dropdown > summary { list-style: none; }
  details.dropdown > summary::-webkit-details-marker { display: none; }
  .dropdown-toggle {
    min-width: 44px;
    justify-content: center;
  }
  .dropdown-menu {
    position: absolute;
    right: 0;
    top: calc(100% + 8px);
    min-width: 200px;
    background: color-mix(in srgb, var(--bg-card) 96%, var(--bg) 4%);
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    box-shadow: 0 12px 36px rgba(0,0,0,0.28), 0 2px 6px rgba(0,0,0,0.12);
    padding: 0.4rem;
    z-index: 1002;
    display: none;
    backdrop-filter: blur(20px) saturate(1.3);
    -webkit-backdrop-filter: blur(20px) saturate(1.3);
  }
  /* JS-managed open state */
  .dropdown.open .dropdown-menu { display: block; }
  /* Native <details> open state (no-JS fallback) */
  details.dropdown[open] .dropdown-menu { display: block; }
  .dropdown-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    width: 100%;
    padding: 0.55rem 0.8rem;
    background: transparent;
    border: 0;
    border-radius: var(--r-sm);
    color: var(--text);
    text-align: left;
    text-decoration: none;
    cursor: pointer;
    white-space: nowrap;
    font-size: 0.93rem;
    font-weight: 500;
    min-height: 44px;
    transition: background 0.12s ease, color 0.12s ease;
  }
  .dropdown-item:hover {
    background: color-mix(in srgb, var(--accent) 14%, var(--bg-card) 86%);
    color: var(--accent);
  }
  .dropdown-item:hover i { color: var(--accent); }
  body[data-theme="light"] .dropdown-item:hover {
    background: color-mix(in srgb, var(--accent) 14%, var(--bg-card) 86%);
    color: var(--accent);
  }
  body[data-theme="light"] .dropdown-item:hover i { color: var(--accent); }

  /* ══════════════════════════════════════════════════════════
     SIDE MENU (base, non-enhanced)  -  iOS Settings style
     ══════════════════════════════════════════════════════════ */
  .side-menu:not([data-enhanced]) {
    position: fixed;
    top: 0;
    right: -340px;
    width: 320px;
    height: 100vh;
    background: color-mix(in srgb, var(--bg-card) 96%, transparent);
    backdrop-filter: blur(24px) saturate(1.3);
    -webkit-backdrop-filter: blur(24px) saturate(1.3);
    border-left: 1px solid var(--border);
    box-shadow: none;
    padding: 1.25rem 1rem;
    transition: right 0.28s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    z-index: 1001;
    overflow-y: auto;
  }
  .side-menu:not([data-enhanced]).open { right: 0; }

  .side-menu:not([data-enhanced]) .side-menu-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    margin-bottom: 1.25rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--border);
  }
  .side-menu:not([data-enhanced]) .side-menu-header h2 {
    margin: 0;
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--text);
    letter-spacing: -0.02em;
  }
  .side-menu:not([data-enhanced]) .close-menu-btn {
    background: color-mix(in srgb, var(--bg) 70%, transparent);
    border: none;
    color: var(--text-muted);
    width: 30px;
    height: 30px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background 0.15s ease;
    font-size: 0.85rem;
  }
  .side-menu:not([data-enhanced]) .close-menu-btn:hover {
    background: color-mix(in srgb, var(--border) 60%, transparent);
    color: var(--text);
  }
  .side-menu:not([data-enhanced]) .menu-section { margin-bottom: 1.5rem; }
  .side-menu:not([data-enhanced]) .menu-section-heading {
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.07em;
    margin: 0 0 0.35rem 0.5rem;
    color: var(--text-muted);
  }
  /* Grouped list container */
  .side-menu:not([data-enhanced]) .menu-list {
    list-style: none;
    padding: 0;
    margin: 0;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    overflow: hidden;
  }
  .side-menu:not([data-enhanced]) .menu-item { margin: 0; }
  .side-menu:not([data-enhanced]) .menu-item + .menu-item {
    border-top: 1px solid color-mix(in srgb, var(--border) 60%, transparent);
  }
  .side-menu:not([data-enhanced]) .menu-link {
    display: flex;
    align-items: center;
    gap: 0.7rem;
    padding: 0.72rem 1rem;
    background: transparent;
    border: none;
    border-radius: 0;
    color: var(--text);
    text-decoration: none;
    font-weight: 500;
    font-size: 0.93rem;
    transition: background 0.12s ease, color 0.12s ease;
  }
  .side-menu:not([data-enhanced]) .menu-link:hover {
    background: color-mix(in srgb, var(--accent) 10%, transparent);
    color: var(--accent);
  }
  .side-menu:not([data-enhanced]) .menu-link i {
    width: 1.2rem;
    text-align: center;
    color: var(--accent);
    font-size: 0.9rem;
  }

  @media (max-width: 768px) {
    .side-menu:not([data-enhanced]) { width: 88%; right: -88%; }
  }

  /* ══════════════════════════════════════════════════════════
     NOTICES & ALERTS
     ══════════════════════════════════════════════════════════ */
  .notice {
    background: rgba(219,168,43,0.12);
    border: 1px solid rgba(219,168,43,0.3);
    color: #dba82b;
    padding: 0.85rem 1rem;
    margin-bottom: 1rem;
    border-radius: var(--r-md);
    font-size: 0.93rem;
    font-weight: 500;
  }
  .note {
    margin-top: 1.25rem;
    font-size: 0.84rem;
    color: var(--text-muted);
  }

  /* - Keep filled controls legible across theme accents - */
  .btn-primary,
  .btn-primary *,
  .file-select-btn,
  .file-select-btn *,
  .gallery-badge,
  .gallery-badge *,
  .skip-link,
  .skip-link *,
  .upload,
  .upload *,
  .delete,
  .delete * {
    color: var(--accent-text, #ffffff) !important;
  }

  /* ══════════════════════════════════════════════════════════
     MENU TOGGLE
     ══════════════════════════════════════════════════════════ */
  .menu-toggle {
    position: relative;
    z-index: 3;
    display: inline-flex;
    align-items: center;
    gap: 0.38rem;
    background: color-mix(in srgb, var(--bg-card) 88%, var(--bg) 12%);
    border: 1px solid var(--border);
    color: var(--text);
    padding: 0.45rem 0.75rem;
    border-radius: var(--r-md);
    font-weight: 600;
    font-size: 0.83rem;
    cursor: pointer;
    transition: border-color 0.15s, background 0.15s, color 0.15s;
    min-height: 36px;
  }
  .menu-toggle:hover {
    border-color: var(--accent);
    background: color-mix(in srgb, var(--accent) 10%, var(--bg-card) 90%);
    color: var(--accent);
  }

  /* ══════════════════════════════════════════════════════════
     HERO  -  Apple Large Title section
     ══════════════════════════════════════════════════════════ */
  .hero {
    padding: 2rem 1.5rem;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--r-xl);
  }
  .hero-title {
    font-size: clamp(1.7rem, 5vw, 2.6rem);
    font-weight: 800;
    letter-spacing: -0.03em;
    line-height: 1.1;
    margin: 0 0 0.5rem;
  }
  .hero-subtitle {
    font-size: 1.02rem;
    font-weight: 400;
    color: var(--text-muted);
    margin: 0 0 1.5rem;
    line-height: 1.55;
  }
  .cta-group {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
  }
  .btn-primary {
    background: var(--accent);
    color: var(--accent-text, #fff);
    border: none;
    font-weight: 700;
  }
  .btn-primary:hover { opacity: 0.84; }
  .btn-secondary {
    background: color-mix(in srgb, var(--accent) 13%, var(--bg-card) 87%);
    color: var(--accent);
    border: none;
    font-weight: 600;
  }
  .btn-secondary:hover {
    background: color-mix(in srgb, var(--accent) 22%, var(--bg-card) 78%);
  }

  /* ══════════════════════════════════════════════════════════
     FOOTER
     ══════════════════════════════════════════════════════════ */
  footer {
    margin-top: 3rem;
    padding-top: 1.25rem;
    padding-bottom: calc(var(--suite-bottom-nav-offset) + 0.5rem);
    border-top: 1px solid var(--border);
  }
  footer p {
    margin: 1rem 0;
    color: var(--text-muted);
    font-size: 0.85rem;
    line-height: 1.65;
  }

  /* - Skip to main content (a11y) - */
  .skip-link {
    position: absolute;
    top: -40px;
    left: 0;
    background: var(--accent);
    color: white;
    padding: 0;
    text-decoration: none;
    z-index: 10000;
  }
  .skip-link:focus { top: 0; }

  /* - Screen-reader only - */
  .sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0,0,0,0);
    white-space: nowrap;
    border-width: 0;
  }

  /* ══════════════════════════════════════════════════════════
     ZOOM LEVELS
     ══════════════════════════════════════════════════════════ */
  body[data-zoom-level="0"] { zoom: 1.0;  }
  body[data-zoom-level="1"] { zoom: 1.25; }
  body[data-zoom-level="2"] { zoom: 1.5;  }
  body[data-zoom-level="3"] { zoom: 1.75; }
  body[data-zoom-level="4"] { zoom: 2.0;  }

  /* ══════════════════════════════════════════════════════════
     FONT SIZE: LARGE (accessibility)
     ══════════════════════════════════════════════════════════ */
  body[data-font-size="large"] { font-size: 1.25rem; line-height: 1.75; }
  body[data-font-size="large"] h1 { font-size: 2.5rem; font-weight: 800; }
  body[data-font-size="large"] h2 { font-size: 2rem;   font-weight: 700; }
  body[data-font-size="large"] h3 { font-size: 1.5rem; font-weight: 700; }
  body[data-font-size="large"] p,
  body[data-font-size="large"] li,
  body[data-font-size="large"] td,
  body[data-font-size="large"] th,
  body[data-font-size="large"] label,
  body[data-font-size="large"] button,
  body[data-font-size="large"] input,
  body[data-font-size="large"] select,
  body[data-font-size="large"] .button-link {
    font-size: 1.25rem;
    font-weight: 600;
  }
  body[data-font-size="large"] .muted { font-weight: 600; color: var(--text); }
  body[data-font-size="large"] button,
  body[data-font-size="large"] .button-link,
  body[data-font-size="large"] input,
  body[data-font-size="large"] select {
    padding: 0.85rem 1.25rem;
    min-height: 52px;
  }
  body[data-font-size="large"] td,
  body[data-font-size="large"] th  { padding: 0.9rem 0.85rem; }
  body[data-font-size="large"] .card { padding: 1.75rem 2rem; }
  body[data-font-size="large"] a { font-weight: 700; text-decoration-thickness: 2px; }
  body[data-font-size="large"] code { font-size: 1.15rem; padding: 0.3rem 0.6rem; }
  body[data-font-size="large"] .dropdown-item {
    font-size: 1.25rem;
    font-weight: 600;
    padding: 0.7rem 1rem;
  }

  /* ══════════════════════════════════════════════════════════
     ACCESS CONTROL PAGE
     ══════════════════════════════════════════════════════════ */
  .access-control-container {
    max-width: 1100px;
    margin: 2rem auto;
    padding: 0 1rem;
  }
  .access-control-header { margin-bottom: 1.5rem; }
  .access-control-header h1 { font-size: 2rem; margin-bottom: 0.5rem; color: var(--text); }
  .access-control-header p  { color: var(--text-muted); line-height: 1.6; }

  .alert {
    padding: 0.85rem 1rem;
    border-radius: var(--r-md);
    margin-bottom: 1.25rem;
    font-size: 0.93rem;
    font-weight: 500;
  }
  .alert-success { background: rgba(46,160,67,0.12);   border: 1px solid rgba(46,160,67,0.3);   color: #3fb950; }
  .alert-error   { background: rgba(248,81,73,0.12);   border: 1px solid rgba(248,81,73,0.3);   color: #f85149; }
  .alert-warning { background: rgba(219,168,43,0.12);  border: 1px solid rgba(219,168,43,0.3);  color: #dba82b; }

  /* - Info box (collapsible) - */
  .info-box {
    background: color-mix(in srgb, var(--accent) 10%, transparent);
    border: 1px solid color-mix(in srgb, var(--accent) 35%, transparent);
    border-radius: var(--r-md);
    padding: 0.85rem 1rem;
    margin-bottom: 1.25rem;
  }
  .acl-info-details { margin-bottom: 1.25rem; }
  .acl-info-details summary { list-style: none; cursor: pointer; user-select: none; }
  .acl-info-details summary::-webkit-details-marker { display: none; }
  .acl-info-details[open] .acl-chevron { transform: rotate(180deg); }
  .acl-chevron { transition: transform 0.2s; margin-left: auto; flex-shrink: 0; }
  .info-box-title {
    font-weight: 700;
    color: var(--accent);
    font-size: 0.93rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin: 0;
  }
  .info-box-content { color: var(--text-muted); line-height: 1.55; font-size: 0.91rem; padding-top: 0.5rem; }

  /* - Filter bar - */
  .acl-filter-bar {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 1rem;
  }
  .acl-filter-wrap {
    position: relative;
    flex: 1;
    max-width: 340px;
  }
  .acl-filter-icon {
    position: absolute;
    left: 0.75rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    font-size: 0.9rem;
    pointer-events: none;
  }
  .acl-filter-input {
    padding-left: 2.1rem !important;
    width: 100%;
    min-height: 38px;
    font-size: 0.9rem;
  }
  .acl-filter-count {
    font-size: 0.83rem;
    color: var(--text-muted);
    white-space: nowrap;
  }

  /* - Card grid - */
  .profiles-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.85rem;
    margin-bottom: 0.5rem;
  }
  @media (max-width: 900px) { .profiles-grid { grid-template-columns: repeat(2, 1fr); } }
  @media (max-width: 560px) { .profiles-grid { grid-template-columns: 1fr; } }

  /* - Profile card - */
  .profile-card {
    display: block;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-left: 3px solid var(--border);
    border-radius: var(--r-md);
    cursor: pointer;
    transition: border-color 0.15s, box-shadow 0.15s;
    user-select: none;
    outline: none;
  }
  .profile-card:hover,
  .profile-card:focus-visible {
    border-color: var(--accent);
    border-left-color: var(--accent);
    box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent) 25%, transparent);
  }
  .profile-card.is-enabled {
    border-left-color: #3fb950;
  }
  .profile-card.allow-all {
    border-color: rgba(219,168,43,0.45);
    border-left-color: rgba(219,168,43,0.7);
    background: color-mix(in srgb, rgba(219,168,43,0.07), var(--bg-card));
  }
  .profile-card.allow-all.is-enabled {
    border-left-color: #dba82b;
  }
  .profile-card-inner {
    padding: 0.9rem;
    display: flex;
    flex-direction: column;
    gap: 0.65rem;
  }
  .profile-card-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
  }

  /* Logo / fallback icon */
  .profile-logo {
    width: 36px;
    height: 36px;
    object-fit: contain;
    border-radius: var(--r-sm);
    flex-shrink: 0;
  }
  .profile-logo-fallback {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: color-mix(in srgb, var(--accent) 12%, transparent);
    border-radius: var(--r-sm);
    flex-shrink: 0;
    color: var(--accent);
    font-size: 1.2rem;
  }
  .profile-card.allow-all .profile-logo-fallback { color: #dba82b; background: rgba(219,168,43,0.12); }

  /* Toggle switch */
  .profile-card-toggle { flex-shrink: 0; }
  .toggle-track {
    display: inline-flex;
    align-items: center;
    width: 40px;
    height: 22px;
    background: var(--border);
    border-radius: var(--r-pill);
    padding: 2px;
    transition: background 0.2s;
    position: relative;
  }
  .toggle-thumb {
    width: 18px;
    height: 18px;
    background: #fff;
    border-radius: 50%;
    transition: transform 0.2s;
    box-shadow: 0 1px 3px rgba(0,0,0,0.35);
    flex-shrink: 0;
  }
  .profile-checkbox:checked ~ .profile-card-inner .toggle-track,
  .profile-card.is-enabled .toggle-track {
    background: #3fb950;
  }
  .profile-card.allow-all.is-enabled .toggle-track { background: #dba82b; }
  .profile-checkbox:checked ~ .profile-card-inner .toggle-thumb,
  .profile-card.is-enabled .toggle-thumb {
    transform: translateX(18px);
  }

  .visually-hidden {
    position: absolute;
    width: 1px; height: 1px;
    margin: -1px; padding: 0;
    overflow: hidden;
    clip: rect(0,0,0,0);
    white-space: nowrap;
    border: 0;
  }

  /* Card body text */
  .profile-card-body { display: flex; flex-direction: column; gap: 0.3rem; }
  .profile-card-name { font-size: 0.97rem; font-weight: 700; color: var(--text); line-height: 1.3; }
  .profile-card-desc {
    color: var(--text-muted);
    font-size: 0.84rem;
    line-height: 1.45;
    margin: 0;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
  }
  .warning-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.15rem 0.5rem;
    background: rgba(219,168,43,0.18);
    border-radius: var(--r-pill);
    font-size: 0.75rem;
    color: #dba82b;
    font-weight: 700;
    width: fit-content;
  }

  /* No results message */
  .acl-no-results {
    text-align: center;
    color: var(--text-muted);
    font-size: 0.93rem;
    padding: 2rem 0;
  }

  @media (max-width: 560px) {
    .access-control-container { margin: 1rem auto; }
  }

  /* ══════════════════════════════════════════════════════════
     APP MODE (WebView / mobile app)
     ══════════════════════════════════════════════════════════ */
  body.app-mode { padding-bottom: env(safe-area-inset-bottom, 0px); }
  body.app-mode .container {
    max-width: 100%;
    margin: 0;
    padding: calc(env(safe-area-inset-top, 0px) + 0.6rem) 0.75rem 0;
  }
  body.app-mode button,
  body.app-mode .button-link,
  body.app-mode .btn-primary,
  body.app-mode .btn-secondary,
  body.app-mode .primary,
  body.app-mode .ghost,
  body.app-mode a.button-link { min-height: 48px; min-width: 48px; padding: 0.75rem 1.25rem; }
  body.app-mode input,
  body.app-mode select,
  body.app-mode textarea { font-size: 1rem; min-height: 48px; padding: 0.75rem 0.9rem; }
  body.app-mode .card { padding: 1rem; margin: 0.5rem 0; border-radius: var(--r-lg); }

  @media (hover: none) {
    body.app-mode .button-link:hover,
    body.app-mode .btn-primary:hover,
    body.app-mode .btn-secondary:hover { filter: none; transform: none; }
    body.app-mode .button-link:active,
    body.app-mode .btn-primary:active,
    body.app-mode .btn-secondary:active { opacity: 0.7; }
  }
  body.app-mode .desktop-only { display: none !important; }
  .mobile-only { display: none; }
  body.app-mode .mobile-only { display: revert; }

  /* ══════════════════════════════════════════════════════════
     RESPONSIVE  -  768px (tablet/mobile)
     ══════════════════════════════════════════════════════════ */
  @media (max-width: 768px) {
    .container { margin: 0.75rem auto; padding: 0 0.75rem; }
    .upload-box { max-width: 100%; }

    /* Stacked card table on mobile */
    table, thead, tbody, th, td, tr { display: block; }
    thead tr { position: absolute; top: -9999px; left: -9999px; }
    tr {
      border: 1px solid var(--border);
      border-radius: var(--r-md);
      margin-bottom: 0.85rem;
      overflow: visible;
      position: relative;
    }
    /* Round the top corners of the first cell and bottom corners of the last
       cell so the card shape is preserved without overflow:hidden (which would
       clip the absolutely-positioned actions dropdown). */
    td:first-child {
      border-radius: var(--r-md) var(--r-md) 0 0;
    }
    td:last-child {
      border-radius: 0 0 var(--r-md) var(--r-md);
    }
    td {
      border: none;
      border-bottom: 1px solid var(--border);
      position: relative;
      padding-left: 50%;
      min-height: 2.5rem;
      display: flex;
      align-items: center;
      justify-content: flex-end;
      text-align: right;
      border-radius: 0;
      background: var(--bg-card);
    }
    td[data-label="Thumbnail"] { justify-content: center; padding: 10px 0; }
    td[data-label="Thumbnail"] img { width: 100%; height: 50px; object-fit: cover; }
    td[data-label="Name"] { justify-content: center; text-align: center; padding-left: 15px; }
    td:before {
      position: absolute;
      left: 15px;
      width: 45%;
      padding-right: 10px;
      white-space: nowrap;
      text-align: left;
      font-weight: 700;
      font-size: 0.78rem;
      color: var(--text-muted);
      content: attr(data-label);
    }
    td:last-child { border-bottom: 0; }
    td[data-label="Thumbnail"]:before { content: ""; }
    td[data-label="Name"]:before { content: ""; }
    td[data-label="Actions"]:before { content: ""; }
    td[data-label="Actions"] .row { justify-content: flex-end; gap: 0.75rem; flex-wrap: wrap; }
    td[data-label="Actions"] form { display: flex; align-items: center; }
    td[data-label="Actions"] .mobile-copy { display: inline-flex; }
    td[data-label="Actions"] .dropdown { display: inline-block; }

    .link-text { display: none; }
    .link-icon  { display: inline; }
    .hide       { display: none; }

    .hero-title    { font-size: 1.75rem; }
    .hero-subtitle { font-size: 0.97rem; }

    button, .button-link, .btn-primary, .btn-secondary, .primary, .ghost {
      padding: 0.7rem 1.1rem;
      font-size: 1rem;
      min-height: 44px;
      min-width: 44px;
    }
    input, select, textarea { font-size: 1rem; min-height: 44px; padding: 0.75rem 0.9rem; }

    .row { flex-direction: column; align-items: stretch; gap: 0.65rem; }
    .row > button,
    .row > a.btn-primary,
    .row > a.btn-secondary { width: 100%; }

    .card { padding: 0.9rem 1rem; margin: 0.6rem 0; }

    .dropdown-menu {
      position: absolute;
      right: 0;
      left: auto;
      width: auto;
      min-width: auto;
      top: calc(100% + 6px);
    }

    .hero { padding: 1.5rem 1rem; margin-bottom: 0.85rem; }
    .cta-group { flex-direction: column; width: 100%; }
    .cta-group .btn-primary,
    .cta-group .btn-secondary { width: 100%; }

    .sort-form { flex-direction: column; align-items: flex-start; }
    .sort-form label  { width: 100%; }
    .sort-form select { width: 100%; }
    /* Show the apply button on mobile where onchange may be unreliable */
    .sort-apply-btn { display: inline-flex; }
  }

  /* - Extra small (480px) - */
  @media (max-width: 480px) {
    .container  { padding: 0 0.6rem; }
    h1, .hero-title { font-size: 1.5rem; }
    h2 { font-size: 1.2rem; }
    h3 { font-size: 1.05rem; }
    .hero { padding: 1.25rem 0.85rem; }
    .hero-title    { font-size: 1.5rem; margin-bottom: 0.6rem; }
    .hero-subtitle { font-size: 0.9rem;  margin-bottom: 0.85rem; }
    .card   { padding: 0.75rem 0.85rem; margin: 0.5rem 0; }
    button, input, select { font-size: 1rem; }
    .menu-toggle { padding: 0.4rem 0.6rem; }
  }

  /* ══════════════════════════════════════════════════════════
     SUITE SHELL  -  Apple Navigation Bar
     ══════════════════════════════════════════════════════════ */
  .suite-shell-nav {
    position: sticky;
    top: 0;
    z-index: 1100;
    border-bottom: 1px solid color-mix(in srgb, var(--border) 70%, transparent);
    background: color-mix(in srgb, var(--bg-card) 86%, transparent);
    backdrop-filter: blur(20px) saturate(1.4);
    -webkit-backdrop-filter: blur(20px) saturate(1.4);
  }
  .suite-shell-nav-inner {
    max-width: 1180px;
    margin: 0 auto;
    padding: 0 1rem;
    height: 52px;
    display: flex;
    align-items: center;
    gap: 0.75rem;
  }

  /* Brand */
  .suite-shell-brand {
    text-decoration: none;
    display: inline-flex;
    flex-direction: column;
    line-height: 1.05;
    min-width: max-content;
  }
  .suite-shell-brand-title {
    font-weight: 900;
    letter-spacing: -0.04em;
    color: var(--text);
    font-size: 1.05rem;
  }
  .suite-shell-brand-title span { color: var(--accent); }
  .suite-shell-brand-sub {
    color: var(--text-muted);
    font-size: 0.67rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.09em;
  }
  .suite-brand-upload-word,
  .suite-brand-front-word {
    color: inherit;
    transition: color 0.18s ease, text-shadow 0.18s ease;
  }
  body.brand-upload-active .suite-brand-upload-word {
    color: #4ea8ff;
    text-shadow: 0 0 0.45rem rgba(78, 168, 255, 0.34);
  }
  body.brand-front-active .suite-brand-front-word {
    color: #ff9b3d;
    text-shadow: 0 0 0.45rem rgba(255, 155, 61, 0.34);
  }

  /* Text-logo only mode used on pages that hide suite navigation */
  .suite-text-logo-wrap {
    max-width: 1180px;
    margin: 0 auto;
    padding: 0.85rem 1rem 0.25rem;
  }
  .suite-shell-brand.suite-shell-brand-logo-only .suite-brand-upload-word {
    color: #4ea8ff;
    text-shadow: 0 0 0.45rem rgba(78, 168, 255, 0.34);
  }
  .suite-shell-brand.suite-shell-brand-logo-only .suite-brand-front-word {
    color: #ff9b3d;
    text-shadow: 0 0 0.45rem rgba(255, 155, 61, 0.34);
  }

  /* Nav links - plain text, no border, Apple style */
  .suite-shell-links {
    display: flex;
    align-items: center;
    gap: 0.2rem;
    margin-left: 0.65rem;
  }
  .suite-shell-link {
    border: none;
    background: transparent;
    color: color-mix(in srgb, var(--text) 70%, transparent);
    text-decoration: none;
    font-weight: 600;
    font-size: 0.86rem;
    letter-spacing: -0.01em;
    border-radius: var(--r-sm);
    padding: 0.38rem 0.65rem;
    transition: color 0.15s ease, background 0.15s ease;
  }
  .suite-shell-link:hover {
    color: var(--text);
    background: color-mix(in srgb, var(--border) 45%, transparent);
    text-decoration: none;
  }
  .suite-shell-link.active {
    color: var(--accent);
    background: color-mix(in srgb, var(--accent) 12%, transparent);
    text-decoration: none;
  }
  .suite-shell-link.nav-disabled { opacity: 0.32; pointer-events: none; }

  .suite-shell-actions {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 0.4rem;
  }

  /* Main content clears the bottom tab bar */
  main#main-content { padding-bottom: var(--suite-bottom-nav-offset); }
  main#main-content > .container {
    display: grid;
    gap: 0.85rem;
    padding-top: 1.25rem;
    padding-bottom: 1.25rem;
  }

  /* - Bottom Tab Bar  -  iOS Tab Bar - */
  .suite-view-toggle {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 1600;
    display: flex;
    align-items: stretch;
    height: calc(var(--suite-bottom-nav-height) + env(safe-area-inset-bottom, 0px));
    padding-bottom: env(safe-area-inset-bottom, 0px);
    border-top: 1px solid color-mix(in srgb, var(--border) 65%, transparent);
    background: color-mix(in srgb, var(--bg-card) 86%, transparent);
    backdrop-filter: blur(20px) saturate(1.4);
    -webkit-backdrop-filter: blur(20px) saturate(1.4);
  }

  /* Each tab: icon stacked above label */
  .suite-view-chip {
    flex: 1 1 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.2rem;
    font-weight: 600;
    font-size: 0.68rem;
    letter-spacing: 0;
    color: color-mix(in srgb, var(--text) 50%, transparent);
    background: transparent;
    border: none;
    text-decoration: none;
    transition: color 0.15s ease;
    padding: 0 0.5rem;
    min-height: var(--suite-bottom-nav-height);
    -webkit-tap-highlight-color: transparent;
  }
  .suite-view-chip + .suite-view-chip {
    border-left: 1px solid color-mix(in srgb, var(--border) 45%, transparent);
  }
  .suite-view-chip i { font-size: 1.3rem; display: block; }
  .suite-view-chip:hover { color: var(--text); text-decoration: none; }
  .suite-view-chip.active { color: var(--accent); text-decoration: none; }

  /* - Suite shell responsive - */
  @media (max-width: 900px) {
    .suite-shell-nav-inner {
      flex-wrap: wrap;
      height: auto;
      padding-top: 0.55rem;
      padding-bottom: 0.55rem;
      row-gap: 0.45rem;
    }
    .suite-shell-links { order: 3; margin-left: 0; width: 100%; flex-wrap: wrap; }
    .suite-shell-actions { margin-left: auto; }
    .container { padding-left: 0.75rem; padding-right: 0.75rem; }
    .card  { padding: 0.9rem; border-radius: var(--r-md); }
    .hero  { padding: 1.25rem 1rem; }
    .row   { gap: 0.55rem; }
  }

  @media (max-width: 600px) {
    .suite-shell-link    { font-size: 0.78rem; padding: 0.35rem 0.55rem; }
    .suite-shell-brand-sub { display: none; }
    main#main-content > .container { gap: 0.7rem; }
    .button-link, button, .btn-primary, .btn-secondary, .primary, .ghost, .upload, .delete, .disable {
      width: 100%;
      justify-content: center;
    }
    .field-label-actions {
      display: inline-flex;
      flex-wrap: wrap;
      gap: 0.4rem;
      justify-content: flex-end;
    }
    .field-label-actions > button,
    .field-label-actions > .button-link,
    .field-label-actions > .primary,
    .field-label-actions > .ghost {
      width: auto;
      flex: 0 0 auto;
    }
    .suite-shell-links   { gap: 0.2rem; }
    .suite-view-chip     { font-size: 0.64rem; }
  }

  /* ══════════════════════════════════════════════════════════
    warmth, rhythm, personality
     ══════════════════════════════════════════════════════════ */
  :root {
    --human-card-top: color-mix(in srgb, var(--bg-card) 90%, var(--accent) 10%);
    --human-card-bottom: color-mix(in srgb, var(--bg-card) 95%, var(--bg) 5%);
  }

  body {
    background: var(--bg);
  }

  .suite-shell-nav {
    border-bottom: 1px solid color-mix(in srgb, var(--border) 72%, transparent);
    background: color-mix(in srgb, var(--bg-card) 84%, transparent);
    backdrop-filter: blur(14px) saturate(1.1);
    -webkit-backdrop-filter: blur(14px) saturate(1.1);
  }

  .card,
  .hero,
  .dropdown-menu {
    background: var(--bg-card);
    border-color: color-mix(in srgb, var(--border) 80%, var(--accent) 20%);
  }

  .hero-title,
  h1,
  h2 {
    letter-spacing: -0.03em;
  }

  .button-link,
  button,
  .btn-primary,
  .btn-secondary,
  .primary,
  .ghost,
  .upload,
  .delete,
  .disable,
  .suite-shell-link {
    transition:
      background 0.18s ease,
      color 0.18s ease,
      border-color 0.18s ease,
      transform 0.18s ease;
  }

  .button-link:hover,
  button:hover,
  .btn-primary:hover,
  .btn-secondary:hover,
  .primary:hover,
  .ghost:hover,
  .upload:hover,
  .delete:hover,
  .suite-shell-link:hover {
    transform: translateY(-1px);
  }

  .suite-shell-link.active {
    box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--accent) 40%, transparent);
  }

  footer {
    border-top-color: color-mix(in srgb, var(--border) 74%, var(--accent) 26%);
  }

  footer p {
    color: color-mix(in srgb, var(--text-muted) 86%, var(--text) 14%);
  }

  @keyframes bi-spin {
    from { transform: rotate(0deg); }
    to   { transform: rotate(360deg); }
  }
  .bi-spin {
    display: inline-block;
    animation: bi-spin 1s linear infinite;
  }

  /* ══════════════════════════════════════════════════════════
     BUTTON VARIANTS  -  shared by ScratchUpload & ScratchFront
     ══════════════════════════════════════════════════════════ */

  /* .primary — filled accent action (alias of .btn-primary) */
  .primary,
  button.primary,
  a.primary {
    background: var(--accent);
    color: var(--accent-text, #fff);
    border: none;
  }
  .primary:hover,
  button.primary:hover,
  a.primary:hover { opacity: 0.84; text-decoration: none; }

  /* .ghost — outlined / subtle secondary action */
  .ghost,
  button.ghost,
  a.ghost {
    background: color-mix(in srgb, var(--bg-card) 80%, var(--bg) 20%);
    color: var(--text);
    border: 1px solid var(--border);
  }
  .ghost:hover,
  button.ghost:hover,
  a.ghost:hover {
    background: color-mix(in srgb, var(--accent) 10%, var(--bg-card) 90%);
    border-color: color-mix(in srgb, var(--accent) 45%, var(--border));
    text-decoration: none;
  }

  /* .danger — destructive action (tinted outline variant) */
  button.danger,
  .btn-danger {
    background: color-mix(in srgb, var(--danger) 15%, var(--bg-card) 85%);
    color: var(--danger);
    border: 1px solid color-mix(in srgb, var(--danger) 30%, transparent);
  }
  button.danger:hover,
  .btn-danger:hover {
    background: color-mix(in srgb, var(--danger) 25%, var(--bg-card) 75%);
  }
  /* Filled destructive variant */
  button.danger.filled,
  .btn-danger.filled {
    background: var(--danger);
    color: #fff;
    border-color: var(--danger);
  }

  /* ══════════════════════════════════════════════════════════
     BADGES  -  shared pill labels
     ══════════════════════════════════════════════════════════ */
  .badge {
    display: inline-flex;
    align-items: center;
    gap: 0.2rem;
    padding: 0.2rem 0.55rem;
    border-radius: var(--r-pill);
    font-size: 0.75rem;
    font-weight: 700;
    line-height: 1.4;
    border: 1px solid transparent;
  }
  .badge.warning { background: rgba(240,160,48,0.2);  color: #f0a030; border-color: rgba(240,160,48,0.4); }
  .badge.danger  { background: rgba(231,81,90,0.15);  color: var(--danger, #e7515a); border-color: rgba(231,81,90,0.35); }
  .badge.muted   { background: rgba(255,255,255,0.06); color: var(--text-muted); border-color: var(--border); }
  .badge.info    { background: color-mix(in srgb, var(--accent) 20%, transparent); color: var(--accent); border-color: color-mix(in srgb, var(--accent) 38%, var(--border)); }
  .badge.subtle  { background: rgba(255,255,255,0.04); color: var(--text-muted); border-color: var(--border); font-weight: 600; }

  /* ══════════════════════════════════════════════════════════
     ADDITIONAL UTILITIES  -  shared helpers
     ══════════════════════════════════════════════════════════ */
  .small      { font-size: 0.9rem; }
  .error-text { color: #ff7b7b; }

  /* Empty-state placeholder */
  .empty {
    padding: 1rem;
    text-align: center;
    color: var(--text-muted);
    background: rgba(255,255,255,0.02);
    border: 1px dashed var(--border);
    border-radius: 0.75rem;
  }

  /* ══════════════════════════════════════════════════════════
     FORM HELPERS  -  field group & label layout
     ══════════════════════════════════════════════════════════ */
  .field {
    display: grid;
    gap: 0.35rem;
  }
  .field-label-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    flex-wrap: wrap;
  }
  .field-label-row button {
    padding: 0.45rem 0.7rem;
    font-size: 0.95rem;
    line-height: 1.2;
  }

  /* ══════════════════════════════════════════════════════════
     CARD HELPERS  -  header / toolbar layout
     ══════════════════════════════════════════════════════════ */
  .card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    flex-wrap: wrap;
    gap: 0.75rem;
  }
  .card-header h3 { margin: 0; }
  .card-header .muted { margin: 0.25rem 0 0; }
  .card-toolbar {
    display: flex;
    align-items: center;
    flex: 1;
    justify-content: flex-end;
    gap: 0.5rem;
    flex-wrap: wrap;
  }

  /* ══════════════════════════════════════════════════════════
     DIALOG  -  native <dialog> base
     ══════════════════════════════════════════════════════════ */
  dialog {
    border: 1px solid var(--border);
    background: var(--bg-card);
    color: var(--text);
    border-radius: var(--r-xl);
    padding: 0;
    max-width: min(960px, 96vw);
    box-shadow: 0 40px 70px rgba(0,0,0,0.45);
  }
  dialog::backdrop { background: rgba(0,0,0,0.55); }
  dialog h3 { margin-top: 0; margin-bottom: 0.35rem; }

  .dialog-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 0.5rem;
    margin-bottom: 0.35rem;
    padding: 1.25rem 1.35rem 0.5rem;
  }
  .dialog-header button { min-width: 44px; }

  /* ══════════════════════════════════════════════════════════
     TOGGLE SWITCH  -  iOS-style checkbox toggle
     ══════════════════════════════════════════════════════════ */
  label.toggle {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    font-weight: 700;
    cursor: pointer;
  }
  label.toggle input { accent-color: var(--accent); }

  label.toggle-label {
    display: inline-flex;
    align-items: center;
    gap: 0.55rem;
    min-height: 2rem;
    padding: 0.25rem 0.45rem 0.25rem 0.25rem;
    border-radius: var(--r-pill);
    border: 1px solid color-mix(in srgb, var(--accent) 18%, var(--border));
    background: color-mix(in srgb, var(--accent) 7%, var(--bg-card));
    box-shadow: inset 0 1px 0 rgba(255,255,255,0.06), 0 6px 14px rgba(0,0,0,0.18);
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
    transition: border-color 0.16s ease, background 0.16s ease, box-shadow 0.16s ease, transform 0.16s ease;
  }
  label.toggle-label input[type="checkbox"] {
    appearance: none;
    -webkit-appearance: none;
    position: relative;
    width: 2.15rem;
    height: 1.35rem;
    margin: 0;
    border-radius: var(--r-pill);
    border: 1px solid color-mix(in srgb, var(--accent) 30%, var(--border));
    background: color-mix(in srgb, var(--text-muted) 22%, var(--bg));
    box-shadow: inset 0 1px 3px rgba(0,0,0,0.4);
    transition: background 0.16s ease, border-color 0.16s ease, box-shadow 0.16s ease;
    cursor: pointer;
    min-height: 0;
  }
  label.toggle-label input[type="checkbox"]::before {
    content: "";
    position: absolute;
    top: 50%;
    left: 0.16rem;
    width: 0.9rem;
    height: 0.9rem;
    border-radius: 50%;
    background: #ffffff;
    transform: translate(0, -50%);
    box-shadow: 0 2px 8px rgba(0,0,0,0.35);
    transition: transform 0.16s ease;
  }
  label.toggle-label input[type="checkbox"]:checked {
    background: color-mix(in srgb, var(--accent) 70%, var(--bg));
    border-color: var(--accent);
    box-shadow: inset 0 1px 3px color-mix(in srgb, var(--accent) 40%, rgba(0,0,0,0.22)), 0 0 0 1px color-mix(in srgb, var(--accent) 32%, transparent);
  }
  label.toggle-label input[type="checkbox"]:checked::before {
    transform: translate(0.78rem, -50%);
  }
  label.toggle-label:has(input[type="checkbox"]:checked) {
    border-color: color-mix(in srgb, var(--accent) 58%, var(--border));
    background: color-mix(in srgb, var(--accent) 16%, var(--bg-card));
    box-shadow: inset 0 1px 0 rgba(255,255,255,0.08), 0 10px 20px rgba(0,0,0,0.22);
  }
  label.toggle-label:hover { border-color: color-mix(in srgb, var(--accent) 45%, var(--border)); transform: translateY(-1px); }
  label.toggle-label:focus-within { outline: 2px solid color-mix(in srgb, var(--accent) 78%, transparent); outline-offset: 2px; }

/* ══════════════════════════════════════════════════════════
   INSTALLED PWA SAFE AREAS (iOS status bar / notch)
   In standalone display mode the web view runs under the status bar
   (viewport-fit=cover + apple black-translucent status bar), so the sticky top
   nav gets its first row clipped. Pad the top of the nav by the safe-area inset
   so it sits below the status bar; the nav's own background then fills the
   inset area. env() insets are 0 in a normal browser tab, so these rules do
   nothing outside an installed PWA. The .pwa-standalone class is a fallback for
   iOS versions that don't match the display-mode media query. */
@media (display-mode: standalone) {
  .suite-shell-nav { padding-top: env(safe-area-inset-top, 0px); }
  .suite-text-logo-wrap { padding-top: calc(env(safe-area-inset-top, 0px) + 0.85rem); }
}
body.pwa-standalone .suite-shell-nav { padding-top: env(safe-area-inset-top, 0px); }
body.pwa-standalone .suite-text-logo-wrap { padding-top: calc(env(safe-area-inset-top, 0px) + 0.85rem); }


