/* "More" item + sheet (src/nav/more-sheet.js). Phones and tablets only: at
   992px and below the sidebar is the bottom tab bar and its footer is hidden.
   Logical properties keep RTL and LTR correct with one set of rules. */

.nav-more { display: none; }

@media (max-width: 992px) {
  .nav-menu .nav-more { display: flex; }

  /* The bar gains one item. src/setup/styles.css lays the bar out as a grid
     of exactly six columns while the setup item is shown (flex otherwise);
     one column per visible item keeps every count on a single row. */
  #appSidebar:has(#navMoreBtn) .sidebar-top { inline-size: 100%; min-inline-size: 0; }
  #appSidebar:has(#navMoreBtn) .nav-menu {
    display: grid; grid-template-columns: none;
    grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); gap: 0;
  }
  .nav-menu .nav-link { min-inline-size: 0; align-items: center; text-align: center; }
  .nav-menu .nav-link[hidden] { display: none; }
  .nav-menu .nav-link > span:not(.setup-nav-percent) {
    max-inline-size: 100%; line-height: 1.15; white-space: normal; overflow-wrap: anywhere;
    display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
  }
  .nav-menu .nav-more { border: 0; background: transparent; font: inherit; color: inherit; cursor: pointer; }
  .nav-menu .nav-more[aria-expanded="true"] { color: var(--accent-hover); background: var(--accent-light); }
}

/* ---- The sheet ---------------------------------------------------------- */
/* Built like the side drawer: a scrim and a panel, fixed siblings directly
   under body, always present; closed means transparent and off-screen, and
   opening changes only opacity and transform. index.css hides both while
   closed (visibility, no blur): closed overlays that stayed rendered used
   ~300 MB of GPU memory on the owner's dpr-3 phone, and new overlays there
   painted partially until the phone switched apps (2026-09-30).
   `inert` keeps the closed panel out of focus and the accessibility tree. */
.more-sheet-scrim {
  position: fixed; inset: 0; z-index: 1250;
  background: rgba(38, 37, 34, .30);
  backdrop-filter: blur(2px);
  opacity: 0; pointer-events: none;
  transition: opacity .3s ease;
}
.more-sheet-scrim.is-open { opacity: 1; pointer-events: auto; }
.more-sheet {
  position: fixed; inset-inline: 0; inset-block-end: 0; z-index: 1251;
  margin-inline: auto;
  display: flex; flex-direction: column;
  inline-size: 100%; max-inline-size: 560px;
  box-sizing: border-box; padding: 6px 16px calc(16px + var(--safe-bottom, env(safe-area-inset-bottom, 0px)));
  border: 1px solid var(--border-color); border-block-end: 0; border-radius: 20px 20px 0 0;
  background: var(--bg-secondary); color: var(--text-primary); font-family: var(--font-family);
  transform: translateY(calc(100% + 24px));
  transition: transform .32s cubic-bezier(0.2, 0.7, 0.2, 1);
}
.more-sheet.is-open { transform: translateY(0); }
/* The sheet fits a phone in portrait; only a short screen (landscape) scrolls it. */
@media (max-height: 600px) {
  .more-sheet { max-block-size: calc(100% - 24px); overflow-y: auto; overscroll-behavior: contain; }
}

.more-sheet-grip {
  inline-size: 40px; block-size: 4px; border-radius: 999px; margin: 4px auto 6px;
  background: var(--border-color);
}
.more-sheet-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding-block: 4px 10px; }
.more-sheet-head h2 { margin: 0; font-size: 1.15rem; font-weight: 700; color: var(--text-primary); }
.more-sheet-close {
  display: grid; place-items: center; inline-size: 44px; block-size: 44px; padding: 0;
  border: 1px solid var(--border-color); border-radius: 50%;
  background: var(--bg-tertiary); color: var(--text-secondary); cursor: pointer;
}
.more-sheet-close:hover { color: var(--text-primary); border-color: var(--accent-hover); }

.more-sheet-body { display: flex; flex-direction: column; gap: 8px; }

/* Each row: label at the start, the borrowed control at the end. */
.more-row {
  display: flex; flex-wrap: wrap; align-items: center; gap: 10px;
  min-block-size: 56px; padding: 6px 12px; box-sizing: border-box;
  border: 1px solid var(--border-color); border-radius: 14px; background: var(--bg-primary, var(--bg-tertiary));
}
.more-row[hidden] { display: none; }
.more-row-label { flex: 1 1 auto; font-size: 0.9375rem; font-weight: 600; color: var(--text-primary); text-align: start; }
/* The control's wrappers dissolve, so its button sits on the row and its
   popover (accessibility, appearance) opens as a full-width part of the row
   instead of floating off the top of the sheet. */
.more-row-control,
.more-sheet .a11y-wrap,
.more-sheet .appearance-wrap { display: contents; }

.more-sheet .a11y-btn,
.more-sheet .appearance-btn,
.more-sheet #languageToggle {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; flex: none;
  inline-size: auto; min-inline-size: 48px; block-size: 44px; padding-inline: 12px;
  border: 1px solid var(--border-color); border-radius: 10px;
  background: var(--accent-light); color: var(--accent-hover); cursor: pointer;
  font: 600 0.875rem/1 var(--font-family);
}
.more-sheet #languageToggle { direction: ltr; color: var(--text-secondary); }
.more-sheet #languageToggle .language-code { font-family: system-ui, sans-serif; font-size: 0.875rem; }
.more-sheet #languageToggle .language-flag { display: inline; font-size: 1.0625rem; }
.more-sheet .a11y-btn svg, .more-sheet .appearance-btn svg { inline-size: 20px; block-size: 20px; }
.more-sheet [aria-expanded="true"] { border-color: var(--accent-hover); }
.more-sheet button:focus-visible { outline: 2px solid var(--accent-hover); outline-offset: 2px; }

.more-sheet .a11y-pop,
.more-sheet .appearance-panel {
  position: static; order: 2; flex: 1 0 100%;
  inline-size: auto; max-inline-size: none; min-inline-size: 0; max-block-size: none;
  margin: 2px 0 6px; box-shadow: none; overflow: visible;
  inset: auto;
}
.more-sheet .appearance-panel { display: flex; flex-direction: column; gap: 12px; padding: 12px; border: 1px solid var(--border-color); border-radius: 12px; background: var(--bg-secondary); }
.more-sheet .appearance-panel[hidden] { display: none; }
.more-sheet .appearance-panel .cp-menu { position: static; inline-size: 100%; max-inline-size: none; min-inline-size: 0; margin-block-start: 6px; box-shadow: none; }
.more-sheet .appearance-panel .cp-name { display: inline; }


/* Privacy switch: sized like the other row controls; its state shows by
   colour and icon (its aria-label and aria-pressed carry the words). */
.more-row[data-row="privacy"] .pm-toggle {
  flex: none; margin: 0; inline-size: auto; min-inline-size: 48px; block-size: 44px; min-block-size: 44px;
  padding-inline: 12px; border-radius: 10px; justify-content: center;
}
.more-row[data-row="privacy"] .pm-toggle-label {
  position: absolute; inline-size: 1px; block-size: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap;
}

/* Signed-in profile + Sign out, at the top. */
.more-sheet-profile[hidden] { display: none; }
.more-sheet #sidebarProfile {
  display: flex; flex-direction: row; align-items: center; gap: 10px;
  margin: 0; padding: 10px 12px; border: 1px solid var(--border-color); border-radius: 14px;
  background: var(--bg-tertiary);
}
.more-sheet #sidebarProfile .side-user { flex: 1; min-inline-size: 0; display: flex; align-items: center; gap: 10px; }
.more-sheet #sidebarProfile .su-meta { position: static; inline-size: auto; block-size: auto; overflow: hidden; clip-path: none; display: flex; flex-direction: column; min-inline-size: 0; }
.more-sheet #sidebarProfile .su-name, .more-sheet #sidebarProfile .su-role { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.more-sheet #sidebarProfile .logout-btn {
  display: inline-flex; align-items: center; gap: 6px; flex: none;
  inline-size: auto; block-size: 44px; padding-inline: 12px;
}
/* The label is visually hidden in the sidebar; here there is room for it. */
.more-sheet #sidebarProfile .logout-btn span { position: static; inline-size: auto; block-size: auto; margin: 0; overflow: visible; clip-path: none; white-space: nowrap; }

.more-row-link { inline-size: 100%; font: inherit; color: inherit; cursor: pointer; }
.more-row-link:hover { border-color: var(--accent-hover); }
.more-row-chev { flex: none; color: var(--text-soft, var(--text-secondary)); }
[dir="rtl"] .more-row-chev { transform: scaleX(-1); }

.more-sheet-version { margin: 6px 0 0; text-align: center; font: 0.75rem/1.4 system-ui, sans-serif; color: var(--text-soft, var(--text-secondary)); }
