/* Keep gestures inside the active surface. Desktop/browser menu zoom stays available. */
html { overscroll-behavior:none; }
html.nova-scroll-locked { overflow:hidden; }
/* Mobile pages must not inherit the desktop phone frame's 760px minimum
   or outer vertical gutters. Content and navigation still set their own space. */
@media (max-width:699px) {
  html body { min-height:100dvh; padding-block:0; }
  html body .phone { min-height:100dvh; }
  /* Employee selection has no bottom tab bar. Keep long lists scrollable. */
  html body #screen-whoami { padding-bottom:calc(24px + env(safe-area-inset-bottom,0px)) !important; }
}
/* Welcome pages fill the visible browser area, not the taller layout viewport.
   Their artwork already positions controls below the top safe area. Keep natural
   overflow for short screens, enlarged text and long company descriptions. */
@media (max-width:999px) {
  html body:has(#screen-nova-home.active, #screen-roleselect.active),
  .phone:has(#screen-nova-home.active, #screen-roleselect.active) { min-height:100dvh; }
  html body :is(#screen-nova-home, #screen-roleselect) {
    min-height:100dvh;
    padding:0 !important;
  }
  :is(#screen-nova-home, #screen-roleselect) :is(.nova-card, .rs-card) {
    padding-bottom:max(22px,env(safe-area-inset-bottom,0px));
  }
}
.sheet-overlay, .sheet, dialog:modal, .lightbox { overscroll-behavior:none; }
/* Feature dialogs have ID-based rules; their boundary behavior is shared. */
dialog:modal { overscroll-behavior:none !important; }
.sheet, dialog:modal { min-width:0; overflow-x:hidden; overflow-wrap:anywhere; }
.sheet :is(input,select,textarea), dialog:modal :is(input,select,textarea) { min-width:0; max-width:100%; }
.lightbox { touch-action:pan-x pan-y pinch-zoom; }

@media (hover:none) and (pointer:coarse) {
  /* Pinch belongs to the media viewer, not the whole application. */
  body, .lightbox { touch-action:pan-x pan-y; }
  input, select, textarea { font-size:16px !important; }
}
.nova-zoom-image { touch-action:none; transform-origin:center; user-select:none; -webkit-user-select:none; }
.nr-viewer-content { position:relative; }
.nova-media-tools { position:absolute; z-index:2; bottom:60px; left:50%; transform:translateX(-50%); display:flex; gap:6px; }
.nr-viewer-content .nova-media-tools { bottom:12px; }
.nova-media-tools button { min-width:44px; min-height:44px; padding:8px 12px; border:1px solid #ffffff66; border-radius:12px; background:#16232ee8; color:white; font:600 16px Inter, sans-serif; cursor:pointer; touch-action:manipulation; }
.lightbox { overflow:hidden; }
.lightbox-close, .lightbox-nav, .lightbox-counter { z-index:3; }

/* Keep the close/save controls reachable in long forms on tablet and desktop too. */
@media (min-width:700px) {
  #sheet-entry .sheet { scroll-padding-block:110px; }
  .nova-entry-header { position:sticky; top:-28px; z-index:3; margin:-28px -28px 16px; padding:28px 72px 16px 28px; background:var(--surface); border-bottom:1px solid var(--border); }
  .nova-entry-header .sheet-title { margin:0; }
  .nova-entry-footer { position:sticky; bottom:-28px; z-index:2; margin:16px -28px -28px; padding:18px 28px 28px; background:var(--surface); border-top:1px solid var(--border); }
  .nova-entry-footer .submit-btn { margin:0; }
}

@media (max-width:699px), (hover:none) and (pointer:coarse) and (max-width:1099px) and (max-height:550px) {
  html { overflow-x:clip; }
  html body { padding-inline:env(safe-area-inset-left,0px) env(safe-area-inset-right,0px); }
  html body .screen { animation:none; padding-top:calc(22px + env(safe-area-inset-top,0px)) !important; }
  html body :is(.admin-tabs,.employee-tabs) {
    position:fixed !important; top:auto !important; left:50% !important; right:auto; transform:translateX(-50%) !important;
    bottom:calc(18px + env(safe-area-inset-bottom,0px)) !important;
    max-width:calc(100% - 24px - env(safe-area-inset-left,0px) - env(safe-area-inset-right,0px));
  }
  html body :is(#screen-admin,#screen-emp-home,#screen-detail) { padding-bottom:calc(144px + env(safe-area-inset-bottom,0px)) !important; }
  html.nova-keyboard-open :is(.admin-tabs,.employee-tabs) { visibility:hidden; pointer-events:none; }
  .demo-wrap, .phone, .screen, .admin-panel, .employee-panel { min-width:0; max-width:100%; }
  .sheet-overlay { top:var(--nova-viewport-top,0px); height:var(--nova-viewport-height,100dvh); bottom:auto; }
  .sheet-overlay > .sheet { max-height:min(88dvh,100%); }
  .sheet-overlay > .sheet.long-form { max-height:100%; }
  .sheet .field, .sheet .field-row > *, dialog:modal form > * { min-width:0; }
  /* Avoid focus auto-zoom on iOS while retaining the user's pinch zoom. */
  .sheet :is(input,select,textarea), dialog:modal :is(input,select,textarea) { font-size:16px; }
  html.nova-keyboard-open dialog:modal {
    top:calc(var(--nova-viewport-top,0px) + 12px); bottom:auto; margin-block:0;
    max-height:calc(var(--nova-viewport-height,100dvh) - 24px) !important;
  }
  html body #sheet-entry { align-items:flex-end; padding:calc(12px + env(safe-area-inset-top,0px)) 0 calc(12px + env(safe-area-inset-bottom,0px)); }
  html body #sheet-entry .sheet.long-form { height:100%; max-height:100%; padding-bottom:0; border-radius:22px; animation:none; scroll-padding-block:24px 110px; }
  .nova-entry-footer { position:sticky; bottom:0; z-index:2; margin:16px -18px 0; padding:16px 18px 20px; background:var(--surface); border-top:1px solid var(--border); }
  .nova-entry-footer .submit-btn { margin:0; }
  .nova-entry-header { position:sticky; top:-20px; z-index:3; margin:-20px -18px 16px; padding:20px 64px 12px 18px; background:var(--surface); border-bottom:1px solid var(--border); }
  .nova-entry-header .sheet-title { margin:0; }
  .nova-entry-header .sheet-handle { margin-left:calc(50% + 5px); }
}


/* Entry form: the approved uncluttered layout, scoped to this sheet. */
#sheet-entry .entry-duration-row { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:12px; }
#sheet-entry .entry-duration-row:has(> [hidden]) { grid-template-columns:minmax(0,1fr); }
#sheet-entry .entry-duration-row .field { min-width:0; }
#sheet-entry .entry-duration-row label { min-height:32px; line-height:1.4; font-size:12px; margin-bottom:7px; }
#sheet-entry .entry-optional { font-size:11px; font-weight:400; color:var(--ink-dim); margin-left:4px; }
#sheet-entry #f-date { display:block; box-sizing:border-box; appearance:none; -webkit-appearance:none; min-width:0; min-inline-size:0; width:100%; max-width:100%; padding-inline:10px; }
#sheet-entry #f-date::-webkit-date-and-time-value { text-align:left; min-width:0; }
#sheet-entry #material-alert-module { font-size:12px; }
@media(max-width:350px) {
  #sheet-entry .entry-duration-row { gap:8px; }
  #sheet-entry .entry-duration-row label { font-size:11px; }
}
