/* mobile_nav.css – Mobile-only UI: header, bottom nav, employee sheet, more drawer */

/* ── Chrome heights (incl. device safe areas) ──────────────────────────────
   The header is 52 px and the bottom nav 56 px of content. With
   viewport-fit=cover (multi_view_index.html), env(safe-area-inset-*) is the
   notch / status-bar strip at the top and the iPhone home-indicator strip at
   the bottom; both are 0 on devices without them. Every offset that has to
   clear the header or nav uses these variables instead of 52px / 56px. */
:root {
  --m-header-h: calc(52px + env(safe-area-inset-top, 0px));
  --m-nav-h: calc(56px + env(safe-area-inset-bottom, 0px));
}

/* ── Mobile Header ─────────────────────────────────────────────────────────── */

#mobile-header {
  display: none;
  background-color: #0D882C;
  color: white;
  height: var(--m-header-h);
  box-sizing: border-box;
  padding: env(safe-area-inset-top, 0px)
           max(12px, env(safe-area-inset-right, 0px))
           0
           max(12px, env(safe-area-inset-left, 0px));
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-shrink: 0;
  position: sticky;
  top: 0;
  z-index: 800;
}

#mobile-header-title {
  font-size: 16px;
  font-weight: bold;
  white-space: nowrap;
}

/* App-user identity container. Positioned on the right via margin-left: auto,
   forming a visual identity cluster with the hamburger (name ☰). The container
   itself holds two spans with different typography:
     #mobile-header-user-prefix — "Emp# N:" secondary (matches ball-cluster name)
     #mobile-header-user-name   — the user's name, PRIMARY emphasis
   Only the user's own name gets prominent styling; the prefix is informational
   context. Dropped the card_no from the label to fit common names on narrow
   screens without truncation. */
#mobile-header-status {
  margin-left: auto;
  display: flex;
  align-items: baseline;
  gap: 5px;
  overflow: hidden;
  white-space: nowrap;
  min-width: 0;
  flex-shrink: 1;
  /* No fixed max-width — let the flex container share space with the
     ball-cluster via the flex-shrink defaults. */
}

#mobile-header-user-prefix {
  font-size: 13px;
  font-weight: 500;
  color: rgba(255, 255, 255, 0.88);
  white-space: nowrap;
  flex-shrink: 0; /* prefix is short; don't truncate it */
}

#mobile-header-user-prefix:empty {
  display: none; /* hide the gap when prefix is empty (pre-login fallback) */
}

#mobile-header-user-name {
  font-size: 15px;
  font-weight: 700;
  color: white;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
  flex-shrink: 1; /* truncate the name if anything must truncate */
}

#mobile-header-menu-btn {
  background: none;
  border: none;
  color: white;
  cursor: pointer;
  padding: 6px;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ── Bottom Navigation Bar ─────────────────────────────────────────────────── */

#mobile-bottom-nav {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: var(--m-nav-h);
  box-sizing: border-box;
  /* Tabs keep their 56 px; the padding fills the home-indicator strip. */
  padding: 0 env(safe-area-inset-right, 0px)
           env(safe-area-inset-bottom, 0px)
           env(safe-area-inset-left, 0px);
  background: #0D882C;
  border-top: 1px solid rgba(0,0,0,0.2);
  z-index: 900;
  flex-direction: row;
}

.mobile-nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
  color: rgba(255, 255, 255, 0.7);
  font-size: 10px;
  gap: 3px;
  cursor: pointer;
  padding: 6px 2px;
  position: relative;
  transition: background-color 0.15s ease;
  -webkit-tap-highlight-color: transparent;
}

.mobile-nav-item svg {
  width: 20px;
  height: 20px;
  stroke: currentColor;
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex-shrink: 0;
}

.mobile-nav-item.active {
  color: white;
  background-color: rgba(0, 0, 0, 0.18);
}

.mobile-nav-item:active {
  background-color: rgba(0, 0, 0, 0.25);
}

/* ── Color-ball status button ──────────────────────────────────────────────── */

#mobile-header-color-btn {
  display: none; /* shown by JS when a colored employee exists */
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px 6px;
  flex-shrink: 0;
  -webkit-tap-highlight-color: transparent;
  -webkit-appearance: none;
  appearance: none;
}

#mobile-header-color-btn:active {
  opacity: 0.7;
}

#mobile-header-color-ball {
  font-size: 20px;
  line-height: 1;
}

/* Ball-cluster name — transient context (who the ball is associated with, or
   who the supervisor is currently viewing). Secondary typography: lighter and
   smaller than the app-user name (#mobile-header-status) so the persistent
   identity dominates when both are present. Managed (show/hide, text) by
   mobile_nav.js :: updateMobileHeaderCluster(). */
#mobile-header-selected-name {
  /* display: none by default via inline style; JS flips to inline-block */
  font-size: 13px;
  font-weight: 500;
  color: rgba(255, 255, 255, 0.88);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 30%;
  flex-shrink: 1;
  min-width: 0;
}

/* Badge for pending-review indicator */
.mobile-nav-badge {
  position: absolute;
  top: 5px;
  right: calc(50% - 16px);
  background: #fd7e14;
  color: white;
  border-radius: 8px;
  font-size: 9px;
  padding: 1px 5px;
  font-weight: bold;
  line-height: 1.4;
  min-width: 14px;
  text-align: center;
}

/* ── Shared Overlay ────────────────────────────────────────────────────────── */

.mobile-sheet-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  z-index: 1000;
}

.mobile-sheet-overlay.open {
  display: block;
}

/* ── Employee Bottom Sheet ─────────────────────────────────────────────────── */

#mobile-emp-sheet {
  position: fixed;
  bottom: var(--m-nav-h);
  left: 0;
  right: 0;
  height: 62vh;
  background: white;
  border-radius: 14px 14px 0 0;
  z-index: 1001;
  display: flex;
  flex-direction: column;
  transform: translateY(calc(100% + var(--m-nav-h)));
  transition: transform 0.3s cubic-bezier(0.32, 0.72, 0, 1);
  box-shadow: 0 -4px 24px rgba(0, 0, 0, 0.18);
}

#mobile-emp-sheet.open {
  transform: translateY(0);
}

#mobile-emp-sheet-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px 10px;
  border-bottom: 1px solid #dee2e6;
  font-weight: bold;
  font-size: 15px;
  flex-shrink: 0;
}

#mobile-emp-sheet-handle {
  width: 36px;
  height: 4px;
  background: #dee2e6;
  border-radius: 2px;
  margin: 10px auto 0;
  flex-shrink: 0;
}

#mobile-emp-sheet-close {
  background: none;
  border: none;
  font-size: 22px;
  cursor: pointer;
  color: #666;
  padding: 0 4px;
  line-height: 1;
  display: flex;
  align-items: center;
}

#mobile-emp-sheet-body {
  flex: 1;
  overflow: hidden;
  position: relative;
}

/* Employee list inside the sheet */
#mobile-emp-sheet-body #employee-list,
#mobile-emp-sheet-body #month-days-list {
  display: block !important;
  position: absolute;
  inset: 0;
  width: 100% !important;
  height: 100% !important;
  min-width: unset;
  border: none;
  border-right: none;
  padding: 0;
  box-sizing: border-box;
}

/* ── More Drawer ───────────────────────────────────────────────────────────── */

#mobile-more-drawer {
  position: fixed;
  bottom: var(--m-nav-h);
  left: 0;
  right: 0;
  background: white;
  border-radius: 14px 14px 0 0;
  z-index: 1001;
  padding-bottom: 8px;
  transform: translateY(calc(100% + var(--m-nav-h)));
  transition: transform 0.3s cubic-bezier(0.32, 0.72, 0, 1);
  box-shadow: 0 -4px 24px rgba(0, 0, 0, 0.18);
}

#mobile-more-drawer.open {
  transform: translateY(0);
}

#mobile-more-handle {
  width: 36px;
  height: 4px;
  background: #dee2e6;
  border-radius: 2px;
  margin: 10px auto 12px;
}

.mobile-more-item {
  display: flex;
  align-items: center;
  width: 100%;
  padding: 14px 20px;
  border: none;
  border-bottom: 1px solid #f3f3f3;
  background: none;
  font-size: 15px;
  text-align: left;
  cursor: pointer;
  color: #212529;
  gap: 14px;
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

.mobile-more-item:last-child {
  border-bottom: none;
}

.mobile-more-item:active {
  background: #f5f5f5;
}

.mobile-more-item svg {
  width: 20px;
  height: 20px;
  stroke: #0D882C;
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex-shrink: 0;
}

.mobile-more-item.item-danger svg {
  stroke: #dc3545;
}

.mobile-more-item.item-danger {
  color: #dc3545;
}

/* ── Month-Days-List Bottom Sheet ──────────────────────────────────────────── */

#mobile-days-sheet {
  position: fixed;
  bottom: var(--m-nav-h);
  left: 0;
  right: 0;
  height: 62vh;
  background: white;
  border-radius: 14px 14px 0 0;
  z-index: 1001;
  display: flex;
  flex-direction: column;
  transform: translateY(calc(100% + var(--m-nav-h)));
  transition: transform 0.3s cubic-bezier(0.32, 0.72, 0, 1);
  box-shadow: 0 -4px 24px rgba(0, 0, 0, 0.18);
}

#mobile-days-sheet.open {
  transform: translateY(0);
}

#mobile-days-sheet-handle {
  width: 36px;
  height: 4px;
  background: #dee2e6;
  border-radius: 2px;
  margin: 10px auto 0;
  flex-shrink: 0;
}

#mobile-days-sheet-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px;
  border-bottom: 1px solid #dee2e6;
  font-weight: bold;
  font-size: 15px;
  flex-shrink: 0;
}

#mobile-days-sheet-close {
  background: none;
  border: none;
  font-size: 22px;
  cursor: pointer;
  color: #666;
  padding: 0 4px;
  line-height: 1;
  display: flex;
  align-items: center;
}

#mobile-days-sheet-body {
  flex: 1;
  overflow: hidden;
  position: relative;
}

#mobile-days-sheet-body #month-days-list {
  display: flex !important;
  flex-direction: column;
  position: absolute;
  inset: 0;
  width: 100% !important;
  height: 100% !important;
  min-width: unset;
  border: none;
  padding: 0;
  box-sizing: border-box;
}

/* ── Mobile Header Context Buttons ────────────────────────────────────────── */

#mobile-header-emp-btn {
  display: none; /* shown by JS when relevant view is active */
  align-items: center;
  gap: 4px;
  background: rgba(255,255,255,0.15);
  border: none;
  border-radius: 6px;
  color: white;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  padding: 4px 8px;
  white-space: nowrap;
  flex-shrink: 0;
  -webkit-appearance: none;
  appearance: none;
  -webkit-tap-highlight-color: transparent;
}

#mobile-header-emp-btn:active {
  background: rgba(255,255,255,0.28);
}

#mobile-header-emp-btn svg {
  width: 16px;
  height: 16px;
  stroke: currentColor;
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex-shrink: 0;
}

/* ── Daily-header calendar button (mobile only) ───────────────────────────── */

/* Hidden on desktop — the left day-list pane serves the same purpose */
#daily-header-cal-btn {
  display: none;
}

h3.daily-header-title-row {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 0;
}

.daily-header .daily-summary-stats {
  margin-top: 8px;
  margin-left: 0;
}

/* ── Media Query Activation ────────────────────────────────────────────────── */

@media (max-width: 768px) {
  #mobile-header {
    display: flex;
  }

  #mobile-bottom-nav {
    display: flex;
  }

  /* Hide the desktop top bar entirely */
  #top-bar {
    display: none !important;
  }

  /* Reserve space for the fixed bottom nav INSIDE the viewport height.
     body is `height: 100vh` + flex column (main.css / multi_view_main.css);
     with the default content-box the padding was added on top, so body
     was 100vh + 56px tall: the page scrolled by 56px and the last ~50px
     of every view sat under the nav. border-box keeps the padding inside.
     100dvh (with 100vh fallback) tracks the visible viewport while the
     mobile URL bar is showing. */
  body {
    box-sizing: border-box;
    height: 100vh;
    height: 100dvh;
    padding-bottom: var(--m-nav-h);
  }

  /* Hide sidebars from main layout — shown via bottom sheets instead */
  #employee-list,
  #month-days-list {
    display: none !important;
  }

  /* Month picker must clear the days sheet (z-index 1001) so it appears on
     top while the sheet stays open. After the user confirms a month,
     populateDaysList() refreshes the list and the picker closes — the sheet
     is still visible and the user can pick a day without a second tap. */
  .month-picker-overlay {
    z-index: 1002;
  }

  /* Calendar icon dropped — the "dd" portion of the date string
     (#daily-date-day-num) is the new trigger for the days sheet. */
  #daily-header-cal-btn {
    display: none;
  }

  /* Touch screens have no :hover affordance — instead of the gray circle,
     replace the thin angle quote (‹ ›) with a chunky filled triangle so the
     prev/next month buttons read as prominent tap targets. */
  .month-nav-btn,
  #days-list-prev-month,
  #days-list-next-month {
    background: transparent;
    font-size: 0;       /* hide the original ‹ › text */
  }

  #request-prev-month::before,
  #monthly-prev-month::before,
  #days-list-prev-month::before {
    content: '\25C0';   /* ◀ black left-pointing triangle */
    font-size: 14px;
    color: #2563eb;
    line-height: 1;
  }

  #request-next-month::before,
  #monthly-next-month::before,
  #days-list-next-month::before {
    content: '\25B6';   /* ▶ black right-pointing triangle */
    font-size: 14px;
    color: #2563eb;
    line-height: 1;
  }

  /* Touch-sized hit areas for the month (◀ ▶) and day (< >) step buttons.
     Desktop draws them as 24px circles; on a phone that's half the usual
     44px minimum and easy to miss. The button box grows to 40px, and the
     negative vertical margin keeps the yellow info strips the same height
     as before (the extra area overlaps the strip's padding). */
  .month-nav-btn,
  #days-list-prev-month,
  #days-list-next-month,
  .daily-day-step-btn {
    width: 40px;
    height: 40px;
    margin-top: -8px;
    margin-bottom: -8px;
  }

  /* The Daily strip packs four of these on one line next to the
     "當日統計 / Daily Statistics" label; at 40px wide they pushed the label
     onto its own row. Keep the 40px height but only 32px of width there,
     with -2px side margins so each takes ~28px of line space. */
  .daily-header #days-list-prev-month,
  .daily-header #days-list-next-month,
  .daily-header .daily-day-step-btn {
    width: 32px;
    margin-left: -2px;
    margin-right: -2px;
  }

  /* iOS Safari zooms the whole page when a focused field's text is under
     16px, and the page stays zoomed after the field loses focus. 16px on
     every text-entry control on phones stops that. (A maximum-scale=1
     viewport would also stop it but blocks pinch-zoom on Android.) */
  input[type="text"], input[type="search"], input[type="email"],
  input[type="password"], input[type="number"], input[type="tel"],
  input[type="date"], input[type="time"], input[type="month"],
  input[type="datetime-local"], input:not([type]),
  select, textarea {
    /* !important: per-overlay class rules (e.g. .category-dropdown 13px)
       outrank these element selectors; this is a floor, not a style. */
    font-size: 16px !important;
  }

  /* ── Request View ── */
  #attendance-info {
    flex-shrink: 0;
    white-space: nowrap;
    overflow-x: auto;
  }

  /* Profile summary blocks keep the desktop 2-row × 4-column table shape.
     The wrapper scrolls horizontally on narrow phones instead of flattening
     the two table rows into left/right blocks. */
  #request_review_profile,
  #monthly-summary-profile {
    flex-shrink: 0;
    display: block;
    margin: 0 0 4px 0;
    padding: 0;
    width: 100%;
    max-width: 100%;
    overflow-x: auto;
    border: none;
  }

  #request_review_profile > table,
  #monthly-summary-profile > table {
    display: table;
    width: max-content;
    min-width: 100%;
    table-layout: auto;
  }

  #request_review_profile table > tbody,
  #monthly-summary-profile table > tbody {
    display: table-row-group;
  }

  #request_review_profile tbody > tr,
  #monthly-summary-profile tbody > tr {
    display: table-row;
  }

  #request_review_profile td,
  #monthly-summary-profile td {
    display: table-cell;
    white-space: nowrap;
    padding: 3px 6px;
    border: none;
    border-radius: 0;
    background: transparent;
    font-size: 13px;       /* match Daily stat-card text */
  }

  /* ── Monthly View ── */
  #monthly-attendance-info {
    flex-shrink: 0;
    white-space: nowrap;
    overflow-x: auto;
  }

  /* Attendance table: keep header cells on one line.
     CJK headers (e.g. "加班開始") would otherwise break between each character
     because there is no space — shrinking columns to 1-char wide. English
     headers ("Overtime Begin") only break at the space, so the same rule
     keeps both languages consistent and horizontally scrollable. */
  #attendance-table th,
  #attendance-table td {
    white-space: nowrap;
  }

  /* (Removed 2026-11-08: a 56px padding-bottom on #daily-view used to keep
     the bottom-stacked header / summary / controls clear of the nav. The
     body border-box + 100dvh fix above now ends every view exactly at the
     nav's top edge, so the padding would leave an empty 56px band.) */

  /* ── Daily View: reorder children ──
     The stats table grows to fill all remaining vertical space at the
     top; the header, summary, and controls each reserve their natural
     content height at the bottom, stacked in that order top-to-bottom.
     daily-summary-stats is now a sibling of daily-header (was nested
     inside it before the desktop refactor), so it needs its own order. */
  .daily-stats {
    order: 1;
    flex: 1 1 0;         /* grow to fill, shrink if needed, basis 0 */
    min-height: 0;
    overflow-y: auto;
  }

  .daily-header {
    order: 2;
    flex: 0 0 auto;      /* never grow/shrink — fixed content height */
    overflow-x: auto;
    /* The sticky #mobile-header (52 px, z-index: 800) overlays the
       viewport top. When company_daily_stats.js calls scrollIntoView on
       daily-header to bring the "Daily Statistics — <date>" strip into
       view, scroll-margin-top tells the browser to leave 52 px of
       clearance above the element so the h3 text isn't hidden behind
       the green app header. */
    scroll-margin-top: var(--m-header-h);
  }

  #daily-summary-stats {
    order: 3;
    flex: 0 0 auto;      /* reserve content height at bottom */
    overflow-x: auto;
  }

  #daily-controls {
    order: 4;
    flex: 0 0 auto;      /* reserve content height at bottom */
  }

  /* Tighten the gaps between the three bottom-stacked sections so the
     stat-cards, controls, and yellow strip don't waste vertical space
     above the data table. */
  #daily-view .view-info-band {
    margin-bottom: 4px;
  }

  #daily-view #daily-summary-stats {
    margin-top: 0;
    margin-bottom: 4px;
  }

  #daily-view #daily-controls {
    margin-top: 0;
    margin-bottom: 0;
  }

  /* Single-row case (regular employee viewing only their own data, or
     the "no data" placeholder): drop the mobile order overrides so the
     visual layout matches document order (and matches the desktop
     proven-good layout):
       1. daily-header strip at top (yellow band with the "Daily
          Statistics" h3 — daily-summary-stats is hidden by JS for the
          single-row case)
       2. daily-controls (hidden by JS for ≤ 15 rows)
       3. daily-stats fills the rest with the sticky <thead> visible at
          top of its scroll area and the lone row right under it.
     Class `.daily-view-single-row` is added by company_daily_stats.js
     in loadDailyStatsData() based on reportData.length === 1.
     Supervisors / HR with multi-row tables don't get the class and
     keep the standard mobile reorder (daily-stats at top, scrolling). */
  #daily-view.daily-view-single-row .daily-header {
    order: 0;
  }

  #daily-view.daily-view-single-row #daily-summary-stats {
    order: 0;
  }

  #daily-view.daily-view-single-row #daily-controls {
    order: 0;
  }

  #daily-view.daily-view-single-row .daily-stats {
    order: 0;
  }

  /* Daily filter/search row: keep all controls on a single line with
     horizontal scroll instead of wrapping the input to a second row. */
  #daily-controls .daily-controls-advanced {
    flex-wrap: nowrap;
    overflow-x: auto;
  }

  #daily-controls .daily-controls-advanced > * {
    flex-shrink: 0;
  }

  #daily-controls .daily-controls-advanced input[type="text"] {
    flex-grow: 0;
    width: 160px;
    min-width: 160px;
  }
}

/* ── 請假加班紀錄 Attendance Ledger overlay (request_record_export.css / .js) ──
   Keep the table as the main content on phones: full-height window, filters
   collapsed into a tappable summary line, one-line chips. */
@media (max-width: 768px) {
    /* Full-height window so the table gets every pixel the chrome doesn't use */
    .rre-window { left: 8px; right: 8px; top: 8px; width: auto; transform: none;
                  height: calc(100vh - 16px); height: calc(100dvh - 16px); max-height: none; }
    .rre-head { cursor: default; padding: 8px 12px; }

    /* Filters collapse to one tappable summary line */
    .rre-controls { display: none; padding: 10px 12px; gap: 10px 16px; }
    .rre-window.filters-open .rre-controls { display: flex; }
    .rre-summary {
        display: flex; align-items: center; justify-content: space-between; gap: 8px; flex: none;
        width: 100%; text-align: left; font: inherit; font-size: 12.5px; color: var(--rre-ink-2);
        background: var(--rre-surface); border: 0; border-bottom: 1px solid var(--rre-grid);
        padding: 8px 12px; cursor: pointer;
    }
    /* Open/close control for the filters: a clear, thumb-sized round button */
    .rre-caret {
        flex: none; display: inline-flex; align-items: center; justify-content: center;
        width: 30px; height: 30px; border-radius: 50%;
        background: var(--rre-accent-soft); color: var(--rre-accent);
        font-size: 20px; font-weight: 700; line-height: 1;
        transition: transform .15s;
    }
    .rre-window.filters-open .rre-caret { transform: rotate(180deg); }

    /* Outcome chips: one compact line, scrolls sideways instead of wrapping */
    .rre-tally { flex-wrap: nowrap; overflow-x: auto; gap: 6px; padding: 6px 10px; }
    .rre-chip { display: flex; align-items: baseline; gap: 6px; min-width: 0; padding: 3px 8px; white-space: nowrap; flex: none; }
    .rre-chip b { font-size: 12.5px; }

    .rre-sheet { min-height: 120px; }
    .rre-foot { padding: 8px 12px; }
    .rre-foot .rre-note { display: none; }
}
@media (max-width: 768px) and (prefers-reduced-motion: reduce) { .rre-caret { transition: none; } }

/* ── Picker sheet (js/mobile_pickers.js) ─────────────────────────────────────
   On phones every "choose a value" control opens this one sheet: <select>
   and the time quick-pick as a list, <input type=month> and the strip
   MonthPicker as a month grid, <input type=date> as the app's calendar.
   It opens over the request overlays (z-index 10000–10001) but under notify
   toasts (100000), and covers the bottom nav, so it pads the
   home-indicator strip itself. */
.mss-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  z-index: 50000;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.2s ease, visibility 0s linear 0.2s;
}
.mss-backdrop.open {
  opacity: 1;
  visibility: visible;
  transition: opacity 0.2s ease;
}
.mss-sheet {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  max-height: 75vh;
  max-height: 75dvh;
  background: #fff;
  border-radius: 14px 14px 0 0;
  box-shadow: 0 -4px 24px rgba(0, 0, 0, 0.18);
  z-index: 50001;
  display: flex;
  flex-direction: column;
  padding-bottom: env(safe-area-inset-bottom, 0px);
  transform: translateY(105%);
  visibility: hidden;
  transition: transform 0.3s cubic-bezier(0.32, 0.72, 0, 1), visibility 0s linear 0.3s;
}
.mss-sheet:focus { outline: none; }   /* focused only to hold focus inside the sheet */
.mss-sheet.open {
  transform: translateY(0);
  visibility: visible;
  transition: transform 0.3s cubic-bezier(0.32, 0.72, 0, 1);
}
.mss-handle {
  width: 36px;
  height: 4px;
  background: #dee2e6;
  border-radius: 2px;
  margin: 10px auto 0;
  flex-shrink: 0;
}
.mss-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 8px 8px 16px;
  border-bottom: 1px solid #dee2e6;
  flex-shrink: 0;
  min-height: 28px;
}
.mss-title {
  flex: 1;
  margin: 0;
  font-size: 15px;
  font-weight: bold;
  color: #212529;
}
.mss-close {
  margin-left: auto;
  width: 40px;
  height: 40px;
  background: none;
  border: none;
  border-radius: 50%;
  font-size: 24px;
  line-height: 1;
  color: #666;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.mss-close:active { background: rgba(0, 0, 0, 0.08); }
.mss-body {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}

/* List mode */
.mss-list { list-style: none; margin: 0; padding: 4px 0 8px; }
.mss-opt {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 48px;
  padding: 0 16px;
  font-size: 16px;
  color: #212529;
  border-bottom: 1px solid #f1f3f5;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.mss-opt:active { background: #e8f5ec; }
.mss-opt:focus-visible { outline: 2px solid #0D882C; outline-offset: -2px; }
.mss-opt.mss-indent { padding-left: 28px; }
.mss-text { flex: 1; min-width: 0; font-variant-numeric: tabular-nums; }
.mss-hint { font-size: 13px; color: #6c757d; font-variant-numeric: tabular-nums; }
.mss-check { width: 20px; flex-shrink: 0; text-align: center; }
.mss-opt[aria-selected="true"] { color: #0D882C; font-weight: 600; background: #f1f8f3; }
.mss-opt[aria-selected="true"] .mss-check::before { content: '\2713'; font-size: 18px; font-weight: 700; }
.mss-opt.mss-muted:not([aria-selected="true"]) { background: #f8f9fa; color: #868e96; }  /* e.g. outside office hours */
.mss-opt[aria-disabled="true"] { color: #adb5bd; cursor: default; }
.mss-group { padding: 12px 16px 4px; font-size: 12px; font-weight: 600; color: #6c757d; letter-spacing: 0.04em; }

/* Month mode */
.mss-year {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 24px;
  padding: 10px 16px 4px;
}
.mss-year-label { font-size: 17px; font-weight: 700; min-width: 4ch; text-align: center; font-variant-numeric: tabular-nums; }
.mss-nav {
  width: 44px;
  height: 44px;
  border: none;
  border-radius: 50%;
  background: transparent;
  color: #2563eb;            /* same blue as the strips' ◀ ▶ */
  font-size: 16px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.mss-nav:active { background: rgba(0, 0, 0, 0.08); }
.mss-months {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  padding: 8px 16px 16px;
}
.mss-month {
  min-height: 48px;
  border: 1px solid #dee2e6;
  border-radius: 8px;
  background: #fff;
  color: #212529;
  font: inherit;
  font-size: 16px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.mss-month:active { background: #e8f5ec; }
.mss-month.mss-now { border-color: #0D882C; }
.mss-month[aria-selected="true"] { background: #0D882C; border-color: #0D882C; color: #fff; font-weight: 600; }

/* Date mode — the app's CalendarDatePicker, sized up to fill the sheet */
.mss-calendar { display: flex; justify-content: center; padding: 8px 12px 16px; }
.mss-calendar .cdp-calendar { width: 100%; max-width: 360px; border: none; box-shadow: none; }
.mss-calendar .cdp-day { width: auto; height: 44px; font-size: 15px; }
.mss-calendar .cdp-nav-btn { width: 44px; height: 44px; }

html.mss-open, html.mss-open body { overflow: hidden; }
@media (prefers-reduced-motion: reduce) {
  .mss-backdrop, .mss-sheet, .mss-backdrop.open, .mss-sheet.open { transition: none; }
}
