  :root { color-scheme: light; }
  html { -webkit-tap-highlight-color: transparent; }
  body { font-family: "Inter", system-ui, sans-serif; background: #fafafa; }
  body::before {
    content:""; position: fixed; inset: 0; z-index: -1; pointer-events: none;
    background:
      radial-gradient(600px 400px at 100% -10%, rgba(16,185,129,.07), transparent 60%),
      radial-gradient(500px 380px at -10% 110%, rgba(14,165,233,.06), transparent 60%);
  }
  .font-display { font-family: "Space Grotesk", "Inter", sans-serif; }
  .tabular-nums { font-variant-numeric: tabular-nums; }
  ::-webkit-scrollbar { width: 10px; height: 10px; }
  ::-webkit-scrollbar-thumb { background: #d4d4d8; border-radius: 8px; border: 2px solid #fafafa; }
  ::-webkit-scrollbar-thumb:hover { background: #a1a1aa; }
  ::-webkit-scrollbar-track { background: transparent; }
  [hidden] { display: none !important; }

  .card { background: #fff; border: 1px solid #e9e9ec; border-radius: 1rem; box-shadow: 0 1px 2px rgba(16,24,40,.03); }
  .btn { display:inline-flex; align-items:center; justify-content:center; gap:.5rem; font-weight:600; font-size:.875rem;
         min-height:44px; padding:0 1rem; border-radius:.8rem; border:1px solid transparent; cursor:pointer;
         transition: all .2s cubic-bezier(.4,0,.2,1); user-select:none; white-space:nowrap; }
  .btn:active { transform: scale(.965); }
  :root{ --brand:#059669; }
  .btn-primary { background:var(--brand,#059669); color:#fff; box-shadow: 0 1px 2px rgba(5,150,105,.25), inset 0 1px 0 rgba(255,255,255,.12); }
  .btn-primary:hover { background:var(--brand,#059669); filter:brightness(.92); }
  .btn-ghost { background:#fff; border-color:#e4e4e7; color:#3f3f46; }
  .btn-ghost:hover { background:#f4f4f5; border-color:#d4d4d8; }
  .btn-danger { background:#e11d48; color:#fff; }
  .btn-danger:hover { background:#be123c; }
  .btn-soft { background:rgba(5,150,105,.09); color:#047857; }
  .btn-soft:hover { background:rgba(5,150,105,.16); }
  .btn[disabled] { opacity:.55; pointer-events:none; }
  .icon-btn { display:inline-flex; align-items:center; justify-content:center; width:44px; height:44px; border-radius:.8rem;
              color:#71717a; cursor:pointer; transition:all .2s; border:1px solid transparent; }
  .icon-btn:hover { background:#f4f4f5; color:#18181b; }
  .icon-btn.danger:hover { background:#fff1f2; color:#e11d48; }
  .field, select.field { width:100%; min-height:44px; border:1px solid #e4e4e7; border-radius:.8rem; padding:0 .8rem;
       font-size:.875rem; background:#fff; color:#18181b; transition: border-color .2s, box-shadow .2s; }
  .field:focus { outline:none; border-color:#10b981; box-shadow:0 0 0 3.5px rgba(16,185,129,.14); }
  .field::placeholder { color:#a1a1aa; }
  select.field { appearance:none; -webkit-appearance:none; padding-right:2.2rem; cursor:pointer;
      background-image:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 256 256'%3E%3Cpath fill='%2371717a' d='M216.49,104.49l-80,80a12,12,0,0,1-17,0l-80-80a12,12,0,0,1,17-17L128,159l71.51-71.52a12,12,0,0,1,17,17Z'/%3E%3C/svg%3E");
      background-repeat:no-repeat; background-position:right .8rem center; }
  .label { display:block; font-size:.72rem; font-weight:700; letter-spacing:.07em; text-transform:uppercase; color:#71717a; margin-bottom:.4rem; }
  .chip { display:inline-flex; align-items:center; gap:.35rem; font-size:.72rem; font-weight:600; padding:.3rem .6rem;
          border-radius:999px; background:#f4f4f5; color:#52525b; border:1px solid #e9e9ec; }
  .badge { display:inline-flex; align-items:center; gap:.3rem; font-size:.68rem; font-weight:800; letter-spacing:.04em; text-transform:uppercase;
           padding:.25rem .55rem; border-radius:999px; }
  .tile { display:flex; align-items:center; justify-content:center; width:44px; height:44px; border-radius:.85rem; flex:none; }

  .seg { display:inline-flex; background:#f4f4f5; border:1px solid #e9e9ec; border-radius:.9rem; padding:.25rem; gap:.15rem; max-width:100%; overflow-x:auto; }
  .seg-btn { display:inline-flex; align-items:center; gap:.4rem; min-height:40px; padding:0 .9rem; border-radius:.65rem;
             font-size:.8rem; font-weight:600; color:#71717a; cursor:pointer; transition:all .2s; white-space:nowrap; }
  .seg-btn:hover { color:#18181b; }
  .seg-btn.active { background:#fff; color:#047857; box-shadow:0 1px 3px rgba(16,24,40,.1); }

  .switch { position:relative; display:inline-block; width:52px; height:32px; border-radius:999px; background:#e4e4e7; transition:background .2s; flex:none; cursor:pointer; }
  .switch::after { content:""; position:absolute; top:3px; left:3px; width:26px; height:26px; border-radius:50%; background:#fff;
                   box-shadow:0 1.5px 4px rgba(0,0,0,.22); transition:transform .2s cubic-bezier(.34,1.4,.64,1); }
  input:checked + .switch { background:#059669; }
  input:checked + .switch::after { transform: translateX(20px); }

  .nav-item { display:flex; align-items:center; gap:.75rem; width:100%; min-height:48px; padding:0 .9rem; border-radius:.85rem;
              font-size:.875rem; font-weight:600; color:#52525b; cursor:pointer; transition:all .2s; }
  .nav-item:hover { background:#f4f4f5; color:#18181b; }
  .nav-item.active { background:linear-gradient(135deg, rgba(5,150,105,.1), rgba(20,184,166,.08)); color:#047857; }
  .nav-item.active i { color:#059669; }
  .tab-item { display:flex; flex-direction:column; align-items:center; justify-content:center; gap:3px; min-height:56px;
              font-size:10px; font-weight:700; color:#a1a1aa; cursor:pointer; transition:color .2s; position:relative; }
  .tab-item i { font-size:1.3rem; transition:transform .2s; }
  .tab-item.active { color:#047857; }
  .tab-item.active i { transform: translateY(-1px); }
  .tab-item.active::before { content:""; position:absolute; top:5px; width:4px; height:4px; border-radius:50%; background:#059669; }

  .ttable { border-collapse: separate; border-spacing: 0; width: 100%; }
  .ttable th, .ttable td { border-bottom:1px solid #eeeef1; border-right:1px solid #eeeef1; }
  .ttable thead th { position:sticky; top:0; z-index:15; background:#fbfbfc; padding:.6rem .5rem; font-size:.7rem; font-weight:800;
                     letter-spacing:.06em; text-transform:uppercase; color:#71717a; }
  .ttable thead th:first-child { z-index:25; position:sticky; left:0; }
  .ttable .rowhead { position:sticky; left:0; z-index:12; background:#fbfbfc; min-width:92px; padding:.5rem; text-align:left;
                     font-size:.72rem; font-weight:800; color:#3f3f46; vertical-align:middle; }
  .ttable .rowhead .bell { display:block; font-size:.62rem; font-weight:600; color:#a1a1aa; font-variant-numeric:tabular-nums; }
  .ttable td.cell { min-width:126px; height:58px; padding:5px 6px; vertical-align:middle; cursor:pointer; background:#fff;
                    transition: background .15s; position:relative; }
  .ttable td.cell:hover { background:#f0fdf7; }
  .ttable td.cell.readonly { cursor:default; }
  .ttable td.cell.readonly:hover { background:#fff; }
  .ttable td.cell.conflict { background:#fff1f2; box-shadow: inset 0 0 0 1.5px #fda4af; }
  .subj-pill { font-size:10px; font-weight:800; letter-spacing:.03em; padding:2px 7px; border-radius:6px; width:max-content; }

  #modal-root:empty { display:none; }
  .modal-backdrop { position:fixed; inset:0; z-index:50; background:rgba(9,9,11,.42); backdrop-filter:blur(6px); -webkit-backdrop-filter:blur(6px);
                    display:flex; align-items:flex-end; justify-content:center; animation: fade-in .2s ease-out; }
  @media (min-width:640px){ .modal-backdrop { align-items:center; padding:2rem; } }
  .modal-panel { width:100%; max-height:88dvh; overflow-y:auto; background:#fff; border-radius:1.4rem 1.4rem 0 0; box-shadow:0 24px 60px -12px rgba(0,0,0,.3);
                 animation: modal-in .3s cubic-bezier(.16,1,.3,1); }
  @media (min-width:640px){ .modal-panel { border-radius:1.25rem; max-width:30rem; } }
  body.modal-open { overflow:hidden; overscroll-behavior:none; }

  /* Dialogs become true native-style screens on phones. This fixes keyboard clipping,
     double scrolling, narrow action rows and fixed-width controls across every window. */
  @media (max-width:639px){
    .modal-backdrop { align-items:stretch; padding:0; }
    .modal-panel {
      width:100%; height:100dvh; max-height:100dvh; border-radius:0;
      overscroll-behavior:contain; -webkit-overflow-scrolling:touch;
      scroll-padding-top:5rem; scroll-padding-bottom:35dvh;
      padding-top:env(safe-area-inset-top); padding-bottom:env(safe-area-inset-bottom);
      animation:modal-mobile-in .24s cubic-bezier(.16,1,.3,1);
    }
    .modal-panel > .p-6, .modal-panel > form.p-6 { padding:1rem; }
    .modal-panel > .p-6 > .flex.items-start:first-child,
    .modal-panel > form.p-6 > .flex.items-start:first-child {
      position:sticky; top:calc(-1 * env(safe-area-inset-top)); z-index:8;
      margin:-1rem -1rem .75rem; padding:.8rem 1rem;
      background:rgba(255,255,255,.94); border-bottom:1px solid #eeeef1;
      backdrop-filter:blur(12px); -webkit-backdrop-filter:blur(12px);
    }
    .modal-panel .field, .modal-panel select.field { min-width:0!important; max-width:100%!important; font-size:16px; }
    .modal-panel [class*="min-w-"] { min-width:0!important; }
    .modal-panel .flex.gap-2\.5 { flex-wrap:wrap; }
    .modal-panel .btn.flex-1 { flex:1 1 8.5rem; min-width:min(8.5rem,100%); }
    .modal-panel .btn { white-space:normal; text-align:center; line-height:1.2; height:auto; padding-top:.65rem; padding-bottom:.65rem; }
    .modal-panel pre, .modal-panel table { max-width:100%; }
    .modal-panel .overflow-x-auto { scrollbar-width:thin; }
    .modal-backdrop.closing .modal-panel { animation:modal-mobile-out .18s ease-in forwards; }
  }
  .modal-backdrop.closing { animation: fade-out .18s ease-in forwards; }
  .modal-backdrop.closing .modal-panel { animation: modal-out .18s ease-in forwards; }
  @keyframes fade-in { from { opacity:0 } } @keyframes fade-out { to { opacity:0 } }
  @keyframes modal-in { from { opacity:0; transform: translateY(30px) scale(.985) } }
  @keyframes modal-out { to { opacity:0; transform: translateY(24px) scale(.985) } }
  @keyframes modal-mobile-in { from { opacity:0; transform:translateY(18px) } }
  @keyframes modal-mobile-out { to { opacity:0; transform:translateY(18px) } }

  #toast-root { position:fixed; top:calc(env(safe-area-inset-top) + 12px); right:12px; left:12px; z-index:70; display:flex;
                flex-direction:column; align-items:flex-end; gap:8px; pointer-events:none; }
  @media (min-width:640px){ #toast-root { left:auto; right:20px; top:20px; } }
  .toast { pointer-events:auto; display:flex; align-items:flex-start; gap:.65rem; width:100%; max-width:22rem; background:#fff;
           border:1px solid #e9e9ec; border-radius:.95rem; padding:.8rem .95rem; box-shadow:0 12px 32px -8px rgba(16,24,40,.18);
           animation: toast-in .3s cubic-bezier(.16,1,.3,1); }
  .toast.leaving { transition:all .22s ease-in; opacity:0; transform: translateX(16px); }
  @keyframes toast-in { from { opacity:0; transform: translateY(-10px) scale(.96) } }

  @keyframes view-in { from { opacity:0; transform: translateY(10px) } }
  .view-in { animation: view-in .34s cubic-bezier(.16,1,.3,1); }
  @keyframes rise { from { opacity:0; transform: translateY(14px) } to { opacity:1; transform:none } }
  .rise { animation: rise .5s cubic-bezier(.16,1,.3,1) both; }
  @keyframes pulse-dot { 0%,100%{ opacity:1 } 50%{ opacity:.35 } }
  .dot-anim { animation: pulse-dot 1s infinite; }
  @keyframes spin { to { transform: rotate(360deg) } }
  .spinner { width:18px; height:18px; border-radius:50%; border:2.5px solid rgba(255,255,255,.35); border-top-color:#fff; animation: spin .7s linear infinite; }
  .spinner.dark { border-color:#d4d4d8; border-top-color:#059669; }
  @keyframes brand-pop { 0%{ transform: scale(.8); opacity:0 } 60%{ transform: scale(1.04) } 100%{ transform:scale(1); opacity:1 } }
  .brand-pop { animation: brand-pop .6s cubic-bezier(.16,1,.3,1) both; }

  .swatch { width:36px; height:36px; border-radius:.65rem; cursor:pointer; border:2px solid transparent; transition:all .18s; position:relative; }
  .swatch:hover { transform:scale(1.08); }
  input:checked + .swatch { border-color:#18181b; box-shadow:0 0 0 3px rgba(24,24,27,.12); }
  input:checked + .swatch::after { content:""; position:absolute; inset:0; margin:auto; width:10px; height:10px; border-radius:50%; background:rgba(255,255,255,.95); }

  .subj-check span.cbox { display:flex; align-items:center; justify-content:center; gap:.4rem; min-height:44px; padding:0 .7rem;
     border:1.5px solid #e4e4e7; border-radius:.75rem; font-size:.78rem; font-weight:600; color:#52525b; cursor:pointer; transition:all .18s; }
  .subj-check input:checked + span.cbox { border-color:#059669; background:rgba(5,150,105,.07); color:#047857; }
  .role-pick span.rbox { display:flex; align-items:center; justify-content:center; gap:.4rem; min-height:44px; padding:0 .6rem;
     border:1.5px solid #e4e4e7; border-radius:.75rem; font-size:.78rem; font-weight:700; color:#52525b; cursor:pointer; transition:all .18s; }
  .role-pick input:checked + span.rbox { border-color:#059669; background:rgba(5,150,105,.07); color:#047857; }

  .logo-img { width:100%; height:100%; object-fit:cover; border-radius:inherit; }

  /* ---- low-cost / small-screen hardening (320px phones are common) ---- */
  html:lang(si), html:lang(ta) { font-size: 15.5px; }
  :lang(si), :lang(ta) { line-height: 1.75; }
  @media (max-width: 380px){
    .btn { padding:0 .7rem; font-size:.8rem; gap:.35rem; }
    .chip { font-size:.68rem; padding:.3rem .5rem; }
    .card { border-radius:.85rem; }
    #view { padding-left:.65rem; padding-right:.65rem; }
    .tab-item { font-size:10px; }
    .tab-item i { font-size:1.15rem; }
    .ttable td.cell { min-width:104px; }
    h2.font-display { font-size:1.15rem !important; }
  }
  /* Header "more" button: must stay obvious on the frosted header, which is why it is a
     solid emerald chip instead of the ghost-grey icon style used elsewhere. */
  #hdr-menu:active { transform:scale(.94); }
  @media (max-width:639px){ #hdr-menu { outline:2px solid rgba(255,255,255,.55); outline-offset:-2px; } }
  /* School name must never be reduced to dots. On phones it wraps to whole words and
     uses adaptive sizing for long names; only a truly single unbreakable word can shrink. */
  #hdr-title { overflow-wrap:anywhere; word-break:break-word; hyphens:auto; }
  #hdr-sub   { overflow-wrap:anywhere; word-break:break-word; }
  @media (max-width:639px){
    #hdr-menu { display:inline-flex; }
    #tabbar-grid { padding-left:max(.2rem,env(safe-area-inset-left)); padding-right:max(.2rem,env(safe-area-inset-right)); }
    .tab-item { min-width:0; overflow:hidden; }
    .tab-item span { display:block; width:100%; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
  }
  /* Phone tab bar: every tab keeps a usable width (72px) and the bar scrolls sideways when a
     principal has many tabs, instead of squeezing the labels into unreadable slivers. */
  #tabbar { overflow-x:auto; overscroll-behavior-x:contain; scrollbar-width:none; -webkit-overflow-scrolling:touch; }
  #tabbar::-webkit-scrollbar { display:none; }
  #tabbar .tab-item { min-width:72px; font-size:10px; }
  #tabbar .tab-item i { font-size:1.25rem; }
  /* Progressive text sizing: very long school names step down in size instead of truncating */
  #hdr-title.t-lg { font-size:15px; line-height:1.2; }
  #hdr-title.t-xl { font-size:13.5px; line-height:1.2; }
  #hdr-title.t-xxl{ font-size:12.5px; line-height:1.18; }
  #hdr-sub.t-sub  { font-size:10px; line-height:1.35; }
  @media (min-width:640px){
    #hdr-title.t-lg  { font-size:17px; }
    #hdr-title.t-xl  { font-size:16px; }
    #hdr-title.t-xxl { font-size:15px; }
    #hdr-sub.t-sub   { font-size:11px; }
  }
  @media (max-width:350px){
    #brand-tile-m { display:none; }
  }
  @media (max-width: 340px){
    .ttable td.cell { min-width:92px; }
    .btn { min-height:42px; }
  }
  /* respect reduced motion + save battery on weak devices */
  @media (prefers-reduced-motion: reduce){
    *, *::before, *::after { animation-duration:.01ms !important; animation-iteration-count:1 !important; transition-duration:.01ms !important; }
  }

  /* Loading is part of the product, not a delay to hide. The splash states what it is
     doing so a slow rural connection reads as "working" instead of "broken". */
  #splash { position:fixed; inset:0; z-index:90; background:#052e2b; display:flex; flex-direction:column; align-items:center; justify-content:center; gap:0;
            transition: opacity .45s cubic-bezier(.4,0,.2,1), visibility .45s; overflow:hidden; }
  #splash::before { content:""; position:absolute; inset:-40%;
    background: radial-gradient(closest-side, rgba(16,185,129,.22), transparent 70%) 30% 25%/60% 60% no-repeat,
                radial-gradient(closest-side, rgba(13,148,136,.18), transparent 70%) 75% 80%/55% 55% no-repeat;
    animation: splash-drift 14s ease-in-out infinite alternate; }
  #splash.gone { opacity:0; visibility:hidden; }
  @keyframes splash-drift { from{ transform:translate3d(-3%,-2%,0) scale(1); } to{ transform:translate3d(4%,3%,0) scale(1.08); } }
  @keyframes splash-sheen { 0%{ transform:translateX(-120%) } 100%{ transform:translateX(220%) } }
  .splash-ring { position:relative; width:96px; height:96px; border-radius:28px; display:flex; align-items:center; justify-content:center;
    background:linear-gradient(135deg,#10b981,#0d9488); box-shadow:0 18px 46px -12px rgba(13,148,136,.65), inset 0 1px 0 rgba(255,255,255,.2); }
  .splash-ring::after { content:""; position:absolute; inset:0; border-radius:28px; overflow:hidden;
    background:linear-gradient(105deg,transparent 38%,rgba(255,255,255,.34) 50%,transparent 62%);
    animation: splash-sheen 2.6s cubic-bezier(.4,0,.2,1) infinite; }
  .splash-bar { width:210px; height:4px; border-radius:999px; background:rgba(255,255,255,.16); overflow:hidden; position:relative; }
  .splash-bar::after { content:""; position:absolute; inset:0; border-radius:999px;
    background:linear-gradient(90deg,#34d399,#5eead4); transform-origin:0 50%; animation: splash-fill 2.2s cubic-bezier(.4,0,.2,1) infinite; }
  @keyframes splash-fill { 0%{ transform:scaleX(.04) } 45%{ transform:scaleX(.62) } 70%{ transform:scaleX(.7) } 100%{ transform:scaleX(1) } }
  .splash-step { animation: splash-step 2.2s ease-in-out infinite; }
  @keyframes splash-step { 0%,100%{ opacity:.45 } 50%{ opacity:1 } }
  @media (prefers-reduced-motion: reduce){
    #splash::before, .splash-ring::after, .splash-bar::after, .splash-step { animation:none !important; }
    .splash-bar::after { transform:scaleX(.55); }
  }

  #print-root { display:none; }
  @media print {
    body { background:#fff !important; }
    body::before { display:none !important; }
    #app, #toast-root, #modal-root, #login-root, #splash { display:none !important; }
    #print-root { display:block !important; }
  }
  .pdoc { font-family:"Inter",sans-serif; color:#000; }
  .pdoc .doc-head { display:flex; justify-content:space-between; align-items:flex-end; gap:1rem; border-bottom:2.5px solid #111; padding-bottom:8px; margin-bottom:12px; }
  .pdoc h1 { font-size:19px; font-weight:800; letter-spacing:-.01em; margin:0; }
  .pdoc .doc-sub { font-size:10px; color:#333; text-align:right; }
  .pdoc table { width:100%; border-collapse:collapse; }
  .pdoc th, .pdoc td { border:1px solid #111; padding:4px 6px; font-size:9.5px; vertical-align:top; }
  .pdoc th { background:#e8e8e8; font-weight:800; text-transform:uppercase; font-size:8.5px; letter-spacing:.05em; text-align:left; }
  .pdoc .cc { font-weight:800; font-size:10px; }
  .pdoc .cs { font-size:8.5px; color:#222; margin-top:1px; }
  .pdoc .legend { margin-top:10px; font-size:8.5px; column-count:3; column-gap:18px; color:#111; }
  .pdoc .dayband td { background:#e8e8e8; font-weight:800; font-size:8.5px; text-transform:uppercase; letter-spacing:.06em; }
  .pdoc .swp { display:inline-block; width:9px; height:9px; border:1px solid #111; margin-right:4px; vertical-align:baseline; }
  .pdoc .doc-logo { width:34px; height:34px; object-fit:cover; border:1px solid #111; border-radius:6px; }
  .pdoc .pb { break-before: page; page-break-before: always; }
  .sheet-preview { background:#fff; box-shadow:0 2px 6px rgba(16,24,40,.08), 0 16px 40px -12px rgba(16,24,40,.14); border:1px solid #e9e9ec;
                   padding:26px; margin:0 auto; max-width:1120px; min-width:min(860px, 100%); }
  .sheet-preview.portrait { max-width:800px; }

/* =====================================================================================
   MOBILE + MISSING-UTILITY REPAIRS  (appended, so nothing above is disturbed)

   app.css is a pre-built Tailwind bundle that was hand-pruned. It was never re-scanned after
   app.js grew, so 57 utility classes used in the rendered markup had no rule at all, and there
   was no horizontal-overflow guard anywhere. Together these are what makes the app "go all over
   the place" on a phone: unstyled blocks size themselves to their content, one wide child pans
   the whole document, and the fixed header and tab bar travel with it.
   ===================================================================================== */

/* ---- 1. The missing safety net ------------------------------------------------------ */
/* Clamped, not hidden: a genuinely wide child can still scroll inside its own container
   (the timetable and the print preview already do), but it can never drag the page sideways. */
html, body { max-width:100%; overflow-x:hidden; }
/* Long unbroken strings (URLs, sheet ids, pasted codes) are the usual culprit. */
#view, #login-root, #modal-root { min-width:0; max-width:100%; }
#view img, #view table, #view pre { max-width:100%; }
#view pre, #view code { overflow-wrap:anywhere; word-break:break-word; white-space:pre-wrap; }

/* ---- 2. Utilities app.js uses that app.css never shipped ----------------------------- */
/* Layout */
.place-items-center   { place-items:center; }
.w-44                { width:11rem; }
.h-44                { height:11rem; }
.h-28                { height:7rem; }
.-top-10              { top:-2.5rem; }
.-right-10           { right:-2.5rem; }
.max-h-\[85vh\]      { max-height:85vh; }
.py-10               { padding-top:2.5rem; padding-bottom:2.5rem; }
.my-4                { margin-top:1rem; margin-bottom:1rem; }
.ml-2                { margin-left:.5rem; }
.pl-2                { padding-left:.5rem; }
.px-2\.5             { padding-left:.625rem; padding-right:.625rem; }
.py-0\.5             { padding-top:.125rem; padding-bottom:.125rem; }
.p-0                 { padding:0; }
/* app.css defines xl:grid-cols-3 but skipped the lg: step, so the Attendance and Find panels
   collapsed to one column across the whole 1024-1279px range.

   These MUST stay inside a media query. Declared at top level they applied the 3-column track
   at EVERY width, while the `lg:col-span-2` that gives the results two thirds of the row only
   activates at 1024px. Below that, the Find results were squeezed into three ~89px columns on a
   320px phone — one word per line. */
@media (min-width:64rem){
  .lg\:grid-cols-3   { grid-template-columns:repeat(3,minmax(0,1fr)); }
}
@media (min-width:96rem){ .2xl\:grid-cols-3 { grid-template-columns:repeat(3,minmax(0,1fr)); } }
.border-2             { border-width:2px; }
.divide-zinc-200 > * + * { border-top-width:1px; border-top-style:solid; border-top-color:#e4e4e7; }
.divide-zinc-200 > :not([hidden]) ~ :not([hidden]) { border-top-width:1px; border-top-style:solid; border-top-color:#e4e4e7; }
/* Landing-page card modifier (rendered once, app.js:6133). The .lp-dark base supplies the
   styling; this keeps the modifier from being a silent no-op. */
.lp-tile-dark { grid-column:auto; }

/* Colour / text that silently fell back to inherited values (unreadable chips, invisible copy) */
.text-indigo-500        { color:#6366f1; }
.text-indigo-700        { color:#4338ca; }
.text-violet-900        { color:#4c1d95; }
.text-violet-700        { color:#6d28d9; }
.text-sky-400           { color:#38bdf8; }
.text-amber-950         { color:#451a03; }
.text-emerald-900       { color:#064e3b; }
/* The admin System check renders raw server messages — long URLs, Firebase error strings and
   command lines. Without these they either run off the card or sit at a 500-weight contrast
   on a tinted background, which is where a failure report stops being readable. */
.text-rose-900          { color:#881337; }
.text-sky-900           { color:#0c4a6e; }
/* A URL or an error string with no spaces has to wrap rather than widen the dialog. */
.break-words            { overflow-wrap:break-word; word-break:break-word; }
.text-emerald-900\/70   { color:rgba(6,78,59,.7); }
.text-fuchsia-500       { color:#d946ef; }
.text-rose-700\/80      { color:rgba(190,18,60,.8); }
.text-zinc-800          { color:#27272a; }
.bg-violet-50           { background-color:#f5f3ff; }
.border-violet-200      { border-color:#ddd6fe; }
.border-indigo-100      { border-color:#e0e7ff; }
.border-indigo-200      { border-color:#c7d2fe; }
.border-emerald-200\/60 { border-color:rgba(167,243,208,.6); }
.bg-amber-300\/90       { background-color:rgba(252,211,77,.9); }
.bg-white\/10           { background-color:rgba(255,255,255,.1); }
.bg-white\/15           { background-color:rgba(255,255,255,.15); }
.bg-white\/60           { background-color:rgba(255,255,255,.6); }
.bg-white\/70           { background-color:rgba(255,255,255,.7); }
.from-white             { --tw-gradient-from:#fff; --tw-gradient-stops:var(--tw-gradient-from),var(--tw-gradient-to,#0000); }
.to-indigo-50\/60       { --tw-gradient-to:rgba(238,242,255,.6); }
.opacity-90             { opacity:.9; }
.font-normal            { font-weight:400; }
/* Decorative blur blob behind the Find hero — was an empty unpositioned div. */
.blur-2xl               { filter:blur(40px); }
/* Search results no longer truncate without this. */
.line-clamp-2           { display:-webkit-box; -webkit-line-clamp:2; -webkit-box-orient:vertical; overflow:hidden; }
.items-baseline        { align-items:baseline; }
.tracking-\[\.14em\]    { letter-spacing:.14em; }
/* sm: variant — must be inside the breakpoint, or it applies at every width. */
@media (min-width:40rem){
  .sm\:text-\[30px\]    { font-size:30px; line-height:2.5rem; }
}
.animate-pulse          { animation:pulse 2s cubic-bezier(.4,0,.6,1) infinite; }
@keyframes pulse { 0%,100%{opacity:1} 50%{opacity:.5} }
/* !important variants, exactly as Tailwind would emit them */
.\!bg-violet-50            { background-color:#f5f3ff !important; }
.\!border-0                { border-width:0 !important; }
.\!border-violet-200       { border-color:#ddd6fe !important; }
.\!border-indigo-200       { border-color:#c7d2fe !important; }
.\!bg-transparent          { background-color:transparent !important; }
.\!mb-1\.5                 { margin-bottom:.375rem !important; }
.\!pl-0                    { padding-left:0 !important; }
.\!px-0                    { padding-left:0 !important; padding-right:0 !important; }
.\!px-4                    { padding-left:1rem !important; padding-right:1rem !important; }
.\!ring-0                  { --tw-ring-shadow:0 0 #0000 !important; box-shadow:var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow) !important; }
.\!shadow-none             { box-shadow:none !important; }

/* Hover states: they never fired on touch, which is why buttons felt dead on a phone. */
@media (hover:hover){
  .hover\:bg-white        { background-color:#fff; }
  .hover\:bg-white\/25    { background-color:rgba(255,255,255,.25); }
  .hover\:bg-zinc-50\/60  { background-color:rgba(250,250,250,.6); }
  .hover\:bg-emerald-50\/30 { background-color:rgba(236,253,245,.3); }
  .hover\:border-emerald-300 { border-color:#6ee7b7; }
  .hover\:text-zinc-800   { color:#27272a; }
}
/* On touch there is no hover, so give a real press state instead. */
@media (hover:none){
  button:active, .btn:active, .chip:active, .tab-item:active, .nav-item:active { opacity:.75; }
  .btn:active, .btn-primary:active { transform:scale(.98); }
}

/* ---- 3. Touch targets -------------------------------------------------------------- */
/* .icon-btn is 44px. Four call sites override it with !w-8 !h-8 (=32px) and `!important`
   beat the base rule, so those buttons were a third under the usable minimum. */
.icon-btn { min-width:44px; min-height:44px; }
.icon-btn.\!w-8  { width:44px !important; height:44px !important; }
.icon-btn.\!w-10 { width:44px !important; height:44px !important; }
@media (hover:none){
  /* The 8 primary timetable actions are min-h-[32px]. !important wins over .chip so the
     whole toolbar becomes tappable without touching the markup. */
  .chip[class*="min-h-[32px]"] { min-height:44px !important; }
  .seg-btn[class*="min-h-[36px]"] { min-height:44px !important; }
}
/* The status pill is now a <button>; it must still be a 44px target on touch. */
.sync-pill { min-height:32px; }
@media (hover:none){ .sync-pill { min-height:40px; } }
/* Below 640px the label is hidden and only the icon remains, so it must not reserve the
   desktop width or the title gets squeezed. */
@media (max-width:639px){
  #sync-pill { width:34px; padding-left:0 !important; padding-right:0 !important; justify-content:center; }
  #sync-pill span { display:none; }
  #sync-pill.sync-alert { animation:sync-pulse 1.6s ease-in-out infinite; }
}
@keyframes sync-pulse { 0%,100%{ box-shadow:0 0 0 0 rgba(244,63,94,.45);} 50%{ box-shadow:0 0 0 6px rgba(244,63,94,0);} }

/* ---- 4. Tab bar fits the screen ---------------------------------------------------- */
/* It was `repeat(N, minmax(72px,1fr))` with a hard min-width of N*72px: 6 tabs = 432px and
   7 tabs (super admin) = 504px on a 360px phone. The bar scrolled, but the scrollbar was
   hidden, so the last tab was simply not there. Distribute instead of overflow. */
#tabbar { overflow-x:hidden; }
#tabbar-grid { width:100%; max-width:100%; grid-template-columns:repeat(var(--tabcount,6),minmax(0,1fr)) !important; min-width:0 !important; }
#tabbar .tab-item { min-width:0; padding-left:.15rem; padding-right:.15rem; font-size:9.5px; }
@media (min-width:400px){ #tabbar .tab-item { font-size:10px; } }

/* ---- 5. Keyboard / viewport jumps -------------------------------------------------- */
/* The on-screen keyboard was resizing the visual viewport but not the layout viewport, so the
   fixed tab bar sat under it and the 100dvh modal and timetable box collapsed and sprang
   back. Ask the browser to resize the layout viewport instead, and keep #view scrollable
   clear of the bar. */
@media (max-width:639px){
  #view { scroll-padding-bottom:calc(72px + env(safe-area-inset-bottom)); padding-bottom:9rem; }
  #tabbar { padding-bottom:env(safe-area-inset-bottom); }
  /* Prefer a stable bar height over one that resizes on every keystroke. */
  .modal-panel { height:100dvh; max-height:100dvh; }
}

/* ---- 6. Timetable box: keyboard-stable --------------------------------------------- */
/* calc(100dvh - 240px) collapsed to roughly 150px while typing. Clamp it, and stop the sticky
   header re-pinning on every keystroke by not letting it track the keyboard at all. */
.timetable-scroll { max-height:min(calc(100dvh - 240px), 60vh); }

/* ---- 7. Find screen polish --------------------------------------------------------- */
/* The hero search field carries !border-0/!ring-0, which do not touch the UA focus ring.
   There was not a single `outline` declaration in either stylesheet, so Chrome painted its
   default 2px black rectangle around the field on every focus — it read as a debug state. */
.find-input:focus, .find-input:focus-visible { outline:none; }
.find-bar:focus-within { box-shadow:0 0 0 3px rgba(255,255,255,.55), 0 10px 26px -8px rgba(2,6,23,.35); }
.find-input::-webkit-search-cancel-button { -webkit-appearance:none; }
.find-input::placeholder { color:#a1a1aa; }
/* Matched terms. Cards were dense enough that the only emphasis was the matched word. */
/* No horizontal padding: a match inside a word ("Math|ematics") must not split it visually. */
.find-hit { background:rgba(16,185,129,.18); color:#047857; border-radius:3px; padding:0; box-shadow:0 0 0 1px rgba(16,185,129,.18); font-weight:700; }
/* 16px on every viewport: below that, iOS Safari zooms the page when the field takes focus,
   and this input is the screen's primary control. */
.\!text-\[16px\]     { font-size:16px !important; }
/* 40 cards measured 5180px tall inside an 844px viewport — six screens of scroll behind a hero
   that already ate 45% of the screen. Cap it and let the list scroll. */
.find-list { max-height:min(58vh, 560px); overflow-y:auto; overscroll-behavior:contain; padding-right:2px; margin-right:-2px; }
.find-card:focus-visible, .find-card:focus { outline:2px solid #059669; outline-offset:2px; }
/* Long sheet cells and OCR text must break rather than stretch the card. */
.find-card { min-width:0; }
.find-card > div { overflow-wrap:anywhere; }
/* Answer text: the instant answer is lines, the smart answer is light Markdown. */
.find-answer p { margin:0 0 .35rem; line-height:1.55; }
.find-answer p:last-child { margin-bottom:0; }
.find-answer ul, .find-answer ol { margin:.25rem 0 .5rem; padding-left:1.15rem; line-height:1.55; }
.find-answer ul { list-style:disc; } .find-answer ol { list-style:decimal; }
.find-answer li { margin:.1rem 0; }
.find-answer code { font-size:12px; background:#f4f4f5; border-radius:4px; padding:0 4px; }
/* Group filter chips above the results. One row that scrolls sideways on a phone rather than
   wrapping into three rows above the first answer. */
.find-kinds { display:flex; gap:6px; overflow-x:auto; scrollbar-width:none; padding:2px 2px 10px; margin:0 -2px; }
.find-kinds::-webkit-scrollbar { display:none; }
.find-kind { flex:none; display:inline-flex; align-items:center; gap:6px; height:32px; padding:0 12px;
  border-radius:999px; border:1px solid #e4e4e7; background:#fff; color:#3f3f46; font-size:12px; font-weight:600;
  transition:background-color .15s, border-color .15s, color .15s; }
.find-kind:hover { border-color:#a7f3d0; background:#f0fdf4; }
.find-kind i { font-size:14px; color:#71717a; }
.find-kind-n { font-size:10px; font-weight:700; min-width:18px; height:18px; padding:0 5px; border-radius:999px;
  display:inline-grid; place-items:center; background:#f4f4f5; color:#52525b; }
.find-kind.is-on { background:#059669; border-color:#059669; color:#fff; }
.find-kind.is-on i { color:#fff; }
.find-kind.is-on .find-kind-n { background:rgba(255,255,255,.22); color:#fff; }
.find-kind:focus-visible, .find-tile:focus-visible { outline:2px solid #059669; outline-offset:2px; }
/* Browse tiles, shown before anything is typed. */
.find-browse { display:grid; grid-template-columns:repeat(auto-fill, minmax(120px, 1fr)); gap:8px; }
.find-tile { display:grid; grid-template-columns:auto 1fr; grid-template-rows:auto auto; column-gap:10px; align-items:center;
  text-align:left; padding:12px; border-radius:14px; border:1px solid #e4e4e7; background:#fafafa;
  transition:border-color .15s, background-color .15s, transform .15s; min-width:0; }
.find-tile:hover { border-color:#6ee7b7; background:#f0fdf4; transform:translateY(-1px); }
.find-tile i { grid-row:1 / span 2; font-size:22px; color:#059669; width:38px; height:38px; border-radius:11px;
  display:grid; place-items:center; background:#d1fae5; }
.find-tile-n { font-size:18px; font-weight:800; line-height:1.1; color:#18181b; }
.find-tile-l { font-size:11px; font-weight:600; color:#71717a; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
/* A sheet row, shown as label / value pairs. */
.find-row { display:grid; grid-template-columns:minmax(90px, 35%) 1fr; gap:0; border:1px solid #e4e4e7; border-radius:12px; overflow:hidden; font-size:13px; }
.find-row dt, .find-row dd { margin:0; padding:8px 12px; border-top:1px solid #f4f4f5; overflow-wrap:anywhere; }
.find-row dt { background:#fafafa; color:#71717a; font-size:11px; font-weight:700; text-transform:uppercase; letter-spacing:.04em; }
.find-row dt:first-of-type, .find-row dt:first-of-type + dd { border-top:0; }
@media (max-width:639px){
  /* One card per ~96px reads sparse on a phone; tighten it so more context is visible. */
  .find-card { padding:.7rem; }
  .find-browse { grid-template-columns:repeat(2, minmax(0, 1fr)); }
  .find-row { grid-template-columns:1fr; }
  .find-row dd { border-top:0; padding-top:0; }
  .find-list { max-height:none; overflow:visible; }   /* on a phone, scrolling the page is natural */
}

/* ---- 8. Unstyled-block guard ------------------------------------------------------- */
/* Anything carrying a data-site slot or a chip row must never be able to push the page wide. */
#view [class*="grid-cols-["], #view [class*="grid-cols-"] { min-width:0; }
#view .chip { max-width:100%; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
#view .card, #view .modal-panel, #view fieldset { min-width:0; }
/* ---- 9. Utilities the prebuilt app.css does not include ---------------------------- */
/* app.css is a fixed Tailwind build, not a live compiler: a utility missing from it silently
   does nothing. tests/prod-manifest.test.js fails the build if a new one appears. */
.text-4xl { font-size:2.25rem; line-height:2.5rem; }
.\!px-5 { padding-left:1.25rem !important; padding-right:1.25rem !important; }
.bg-violet-50\/70 { background-color:rgb(245 243 255 / .7); }
.text-violet-950 { color:#2e1065; }
.py-1\.5 { padding-top:.375rem; padding-bottom:.375rem; }
@media (min-width:640px){ .sm\:w-auto { width:auto; } }

/* ---- Page help ("?" in the header, the phone menu and the sign-in card) ---------------------- */
/* A soft emerald glow on the help button until the person has opened help once, so new staff
   notice it without a nagging banner. Stops for good after the first open; respects reduced motion. */
#hdr-help { color:#047857; }
.help-pulse { position:relative; }
.help-pulse::after { content:""; position:absolute; inset:4px; border-radius:.7rem; box-shadow:0 0 0 0 rgba(16,185,129,.45);
  animation:help-glow 2.4s cubic-bezier(.2,.7,.3,1) infinite; pointer-events:none; }
@keyframes help-glow { 0% { box-shadow:0 0 0 0 rgba(16,185,129,.45); } 70% { box-shadow:0 0 0 10px rgba(16,185,129,0); } 100% { box-shadow:0 0 0 0 rgba(16,185,129,0); } }
@media (prefers-reduced-motion: reduce) { .help-pulse::after { animation:none; box-shadow:0 0 0 2px rgba(16,185,129,.35); } }
.help-body ol, .help-body ul { list-style:none; margin:0; padding:0; }
.w-6 { width:1.5rem; }
.h-6 { height:1.5rem; }

/* Arbitrary grid tracks used by app.js that the prebuilt app.css never contained. Without these
   the Dashboard's "today" rows, Relief's absence rows, the Schools access form and the Marketing
   studio silently collapsed into one stacked column. */
.grid-cols-\[54px_minmax\(0\2c 1fr\)\] { grid-template-columns:54px minmax(0,1fr); }
.grid-cols-\[40px_minmax\(0\2c 1fr\)\] { grid-template-columns:40px minmax(0,1fr); }
@media (min-width:640px){
  .sm\:grid-cols-\[40px_minmax\(0\2c 1fr\)_auto\] { grid-template-columns:40px minmax(0,1fr) auto; }
  .sm\:grid-cols-\[minmax\(0\2c \.9fr\)_minmax\(0\2c 1\.4fr\)\] { grid-template-columns:minmax(0,.9fr) minmax(0,1.4fr); }
}
@media (min-width:1024px){
  .lg\:grid-cols-\[minmax\(0\2c 1\.25fr\)_minmax\(280px\2c \.75fr\)\] { grid-template-columns:minmax(0,1.25fr) minmax(280px,.75fr); }
}

/* Phone header room. #hdr-redo is "hidden sm:inline-flex", but .icon-btn (above, loaded after
   app.css) sets display:inline-flex and silently beat .hidden, so Redo showed on every phone and
   squeezed the page title into a one-word-wide column. Redo is in the ⋮ menu on phones. */
@media (max-width:639px){
  #hdr-redo { display:none !important; }
  #hdr-help, #hdr-undo { width:38px !important; height:38px !important; }
}

/* Dialogs above the public site's floating top bar (.lp-nav is z-index 60), which used to cover
   the title of every dialog opened from the home page — Forgot password, Help signing in.
   Toasts (70) and the splash (90) stay above dialogs. */
.modal-backdrop { z-index:65; }
