/* Academy OS — base styles.
   Scope: shell (sidebar + main) and page heading only. Cards, tables and
   other components land with the screens that need them. */

:root {
  --bg: #f7f7f5;
  --surface: #ffffff;
  --border: #e7e7e5;
  --border-soft: #edede9;

  --text: #1a1a1a;
  --text-secondary: #4a4a47;
  --text-muted: #8e8e8b;
  --icon: #9c9c99;

  /* Primary button green. Was a bright mint (#00bc7f / #34ab82, from the
     first mockups); since 17 Nov 2026 (Karla) the Academy OS green-teal
     of the frame and the logo's "OS" (#4C6760), a little livelier so
     buttons don't look grey: -strong is the button itself (5.2:1 with
     white text), the plain one its clearly darker hover. */
  --accent-green: #2f5c54;
  --accent-green-strong: #3d766b;
  /* Pills, initials and soft highlights (e.g. "Sent to printer"). Was a
     mint (#cbfaee); since 17 Nov 2026 (Karla) a deeper, clearer version of
     the button green on a fresh tint of it — the first pale tint read grey,
     "tone in tone" (5:1 for small text). */
  --avatar-bg: #d5eee7;
  --avatar-text: #1f6b5c;
  /* The "OS" in the "Academy OS" wordmark — sampled from the real
     theacademyos.co.uk marketing site's own sage-green "OS", same
     source as the dark theme below. A deeper shade here than the
     dark-theme value, since this one has to read on a WHITE sidebar
     background instead of near-black — the brand mark stays sage in
     both themes, just tuned per-theme for contrast. */
  --brand-sage: #5f7d59;

  /* The frame round the app (Karla, 17 Nov 2026 — the student portal's
     "card over a colour" look): Academy OS's deep green-teal #4C6760,
     the same green as the "OS" in the logo (static/img/brand, recoloured
     the same day; the dark logo uses the lighter #8AB3A8). */
  --frame: #4c6760;
  --frame-gap: 14px;
  --frame-radius: 18px;
  --os-sage: #4c6760;
  --os-sage-text: #4c6760;

  --danger: #9b2c21;
  --danger-bg: #fdf3f2;
  --danger-border: #f1d7d4;

  /* README "Colour Scheme" table — status indicators and standout figures. */
  --accent-fawn: #c9a96e; /* Soft Fawn — standout figures, e.g. Course Revenue */
  --status-positive: #3d9a6e; /* Shamrock — Attended, Settled */
  --status-negative: #c0443a; /* Tomato Jam — Absent */
  --status-pending: #c07a2a; /* Bronze — Pending, Outstanding */
  /* Named so the three call sites that used to hardcode this exact
     hex (role-pill/staff-avatar "Sales" backgrounds) can read it as a
     token instead — see this file's own dark-theme block for why
     that matters once a second theme exists. */
  --status-pending-bg: #fdf0dc;

  /* Role-indicator colour (Settings — Roles & Permissions). Indigo has
     no other use in the palette yet, so it's scoped to just this. */
  --accent-indigo: #6366f1;
  --accent-indigo-bg: #eef0fd;

  --font-sans: 'DM Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  /* Reserved for numeric / tabular data. */
  --font-mono: 'DM Mono', ui-monospace, 'SF Mono', Menlo, monospace;

  --sidebar-w: 223px;
  --sidebar-w-collapsed: 72px;
}

/* Dark theme (Settings > General > Appearance) — an explicit opt-in
   toggle, not tied to prefers-color-scheme: this app has one fixed
   default look for everyone today, so switching based on OS setting
   alone would silently change production's appearance for anyone
   with a dark OS theme who never asked for it. Colour reference:
   theacademyos.co.uk's own marketing site (near-black ground, warm
   off-white text, muted sage-green accent) — sampled by eye, not a
   generated palette, so every token here traces back to that real
   brand asset rather than an invented dark-mode default. Every token
   from the light block above is redefined here; component CSS reads
   only these custom properties, never a literal, so redefining the
   tokens alone re-themes the whole app with no per-page changes. */
:root[data-theme="dark"] {
  --bg: #14150f;
  --surface: #1c1e16;
  --border: #34362a;
  --border-soft: #262920;

  --text: #f1efe6;
  --text-secondary: #c7cbb9;
  --text-muted: #8d9482;
  --icon: #8d9482;

  --accent-green: #4a887c;
  --accent-green-strong: #3d766b;
  --avatar-bg: #1d3a33;
  --avatar-text: #8fcfbf;
  --brand-sage: #8fad87;

  --frame: #2b3b37;
  --os-sage: #8ab3a8;
  --os-sage-text: #8ab3a8;

  --danger: #e2897e;
  --danger-bg: #2e1b18;
  --danger-border: #4a2a25;

  --accent-fawn: #d9b87a;
  --status-positive: #8fad87;
  --status-negative: #e2897e;
  --status-pending: #d9a863;
  --status-pending-bg: #332a18;

  --accent-indigo: #a5a8f5;
  --accent-indigo-bg: #23243d;
}

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}

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

/* Shell ------------------------------------------------------------------ */

.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  display: flex;
  flex-direction: column;
  width: var(--sidebar-w);
  /* 100vh on mobile Safari is the viewport's LARGEST possible height
     (toolbar hidden) — while the address bar is actually showing,
     that overstates the real visible height, so a fixed box this
     tall pushes whatever's pinned to the bottom (.user/log out below)
     underneath the toolbar, unreachable. 100dvh tracks the real,
     currently-visible height as the toolbar shows/hides; kept as a
     second declaration (not a replacement) so browsers without dvh
     support still get the 100vh fallback above. */
  height: 100vh;
  height: 100dvh;
  /* Belt-and-braces alongside the dvh fix above: if the nav ever grows
     taller than the viewport on a short/small device, this lets it
     scroll internally rather than clipping the pinned-bottom .user
     row unreachably. */
  overflow-y: auto;
  /* Real values only once the viewport meta tag below declares
     viewport-fit=cover — otherwise these always compute to 0, which
     is a harmless no-op, not an error. Keeps the logout button clear
     of the home indicator on a notched phone, same as the top inset
     keeps the brand row clear of the status bar/notch. */
  padding-top: env(safe-area-inset-top, 0px);
  padding-bottom: env(safe-area-inset-bottom, 0px);
  background: var(--surface);
  border-right: 1px solid var(--border);
}

.main {
  margin-left: var(--sidebar-w);
  padding: 30px 40px 64px;
}

.main__inner {
  max-width: 960px;
  margin: 0 auto;
}

/* Opt-in for pages whose content (e.g. a wide data table) shouldn't be
   capped at the standard reading-width column — see main_inner_class
   block in base.html. */
.main__inner--wide {
  max-width: none;
}

/* A middle ground between the 960px reading column and --wide's
   unbounded width — for a page like the Overview dashboard, whose
   card/panel grids should stay proportionate rather than stretching
   to fill an ultra-wide viewport, but still want more room than the
   960px column gives a wide table. Neither existing modifier fit, so
   this is a new one rather than reusing --wide. */
.main__inner--contained {
  max-width: 1280px;
}

/* Page messages (django.contrib.messages) ---------------------------------
   Sits above .main__inner rather than inside it, so it renders at a
   consistent width regardless of which main_inner_class modifier a
   given page opts into. */
.page-messages {
  max-width: 960px;
  margin: 0 auto 20px;
  padding: 0;
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.page-message {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 16px;
  border-radius: 8px;
  font-size: 14px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
}

.page-message__text {
  flex: 1;
  min-width: 0;
}

/* Top-right of the toast, standard convention — currentColor picks
   up whichever variant's own text colour below, so it never needs
   its own per-variant overrides. */
.page-message__close {
  flex: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  padding: 0;
  border: none;
  border-radius: 4px;
  background: transparent;
  color: inherit;
  opacity: 0.6;
  cursor: pointer;
}

.page-message__close:hover {
  opacity: 1;
  background: rgb(0 0 0 / 8%);
}

.page-message__close-icon {
  width: 13px;
  height: 13px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2.2;
}

.page-message--error {
  background: var(--danger-bg);
  border-color: var(--danger-border);
  color: var(--danger);
}

.page-message--success {
  background: var(--avatar-bg);
  border-color: var(--status-positive);
  color: var(--status-positive);
}

.page-message--info {
  color: var(--text-secondary);
}

/* Brand ------------------------------------------------------------------ */

.brand {
  display: flex;
  gap: 9px;
  align-items: center;
  padding: 15px 20px;
  border-bottom: 1px solid var(--border-soft);
}

.brand__mark {
  display: grid;
  flex: none;
  place-items: center;
  width: 24px;
  height: 24px;
  background: var(--text);
  border-radius: 7px;
  color: var(--surface);
  font-size: 11px;
  font-weight: 600;
}

.brand__text {
  display: flex;
  flex-direction: column;
  line-height: 1.3;
}

.brand__name {
  font-size: 14px;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.brand__name-os {
  color: var(--brand-sage);
}

.brand__sub {
  color: var(--text-muted);
  font-size: 12px;
}

/* The Academy OS logo image (templates/_academyos_logo.html), light and
   dark versions swapped with the theme. It replaces the "Academy OS"
   text and the letter square wherever the brand is shown in full; the
   collapsed sidebar is too narrow for it and shows the square instead
   (see .sidebar-collapsed below). */
.brand-logo {
  display: block;
  width: auto;
  height: 20px;
}

.brand-logo--dark,
:root[data-theme="dark"] .brand-logo--light {
  display: none;
}

:root[data-theme="dark"] .brand-logo--dark {
  display: block;
}

.brand .brand__mark,
.auth__brand .brand__mark {
  display: none;
}

.brand__text {
  gap: 4px;
}

/* Sidebar collapse (desktop only, >=1024px) ------------------------------- */

.sidebar-collapse-toggle {
  display: none;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 10px 20px;
  background: none;
  border: 0;
  border-bottom: 1px solid var(--border-soft);
  color: var(--text-secondary);
  font-family: inherit;
  font-size: 13px;
  text-align: left;
  cursor: pointer;
}

.sidebar-collapse-toggle:hover {
  background: var(--bg);
  color: var(--text);
}

.sidebar-collapse-toggle__icon {
  flex: none;
  width: 16px;
  height: 16px;
  fill: none;
  stroke: var(--icon);
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.6;
  transition: transform 0.15s ease;
}

@media (min-width: 1024px) {
  .sidebar-collapse-toggle {
    display: flex;
  }
}

/* Nav -------------------------------------------------------------------- */

.nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 9px 8px;
}

/* Settings, pinned to the bottom of the sidebar regardless of how many
   permission-gated items render in the main .nav above it — see
   templates/base.html. Only this element gets the auto margin (not
   .user below it too) so the two sit flush together at the very
   bottom, with all the leftover space pushed above Settings instead
   of split into two gaps. */
.nav--bottom {
  margin-top: auto;
}

.nav__item {
  display: flex;
  gap: 10px;
  align-items: center;
  height: 36px;
  padding: 0 12px;
  border-radius: 10px;
  color: var(--text-secondary);
  font-size: 14px;
  text-decoration: none;
}

.nav__item:hover {
  background: var(--bg);
}

/* Selected item: the portal's style (Karla, 17 Nov 2026) — a sage tint,
   bold label, sage icon (below). */
.nav__item.is-active {
  background: color-mix(in srgb, var(--os-sage) 16%, var(--surface));
  color: var(--text);
  font-weight: 600;
}

.nav__icon {
  flex: none;
  width: 16px;
  height: 16px;
  fill: none;
  stroke: var(--icon);
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.6;
}

.nav__item.is-active .nav__icon {
  stroke: var(--os-sage-text);
}

.nav__badge {
  display: grid;
  place-items: center;
  min-width: 17px;
  height: 17px;
  margin-left: auto;
  padding: 0 5px;
  background: var(--accent-green);
  border-radius: 999px;
  color: var(--surface);
  font-size: 10px;
  font-weight: 500;
}

/* .nav__item is written for an <a> — a <button> needs these resets
   (no default border/background, full width, inherited font) before
   it looks the same. The Feedback trigger is the only <button> using
   this class today. */
button.nav__item {
  width: 100%;
  background: none;
  border: 0;
  font: inherit;
  text-align: left;
  cursor: pointer;
}

/* Feedback dialog ---------------------------------------------------------
   Native <dialog>, triggered by the sidebar's Feedback button (see
   templates/base.html) — no modal library anywhere in this app, and
   <dialog> gives show/close/backdrop/focus-trap behaviour for free.
   Sends straight to core:submit_feedback; see that view's own
   docstring for the destination and why nothing's stored in-app. */

.feedback-dialog {
  width: min(420px, calc(100vw - 32px));
  padding: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  color: var(--text);
}

.feedback-dialog::backdrop {
  background: rgba(0, 0, 0, 0.45);
}

.feedback-dialog__form {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 20px;
}

.feedback-dialog__header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.feedback-dialog__title {
  margin: 0;
  color: var(--text);
  font-size: 16px;
  font-weight: 600;
}

.feedback-dialog__close {
  flex: none;
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  background: none;
  border: 0;
  border-radius: 8px;
  color: var(--text-muted);
  cursor: pointer;
}

.feedback-dialog__close:hover {
  background: var(--bg);
  color: var(--text);
}

.feedback-dialog__close svg {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2;
}

.feedback-dialog__hint {
  margin: 0;
  color: var(--text-secondary);
  font-size: 13px;
}

.feedback-dialog__textarea {
  padding: 10px 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text);
  font-family: inherit;
  font-size: 14px;
  resize: vertical;
}

.feedback-dialog__actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.feedback-dialog__cancel {
  padding: 8px 14px;
  background: none;
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text-secondary);
  font-family: inherit;
  font-size: 13px;
  cursor: pointer;
}

.feedback-dialog__cancel:hover {
  background: var(--bg);
}

.feedback-dialog__submit {
  padding: 8px 16px;
  background: var(--accent-green-strong);
  border: 0;
  border-radius: 8px;
  color: #fff;
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
}

.feedback-dialog__submit:hover {
  background: var(--accent-green);
}

/* User ------------------------------------------------------------------- */

.user {
  display: flex;
  gap: 12px;
  align-items: center;
  margin-top: auto;
  /* Tighter on the right than the left so the email still fits beside the
     logout button. */
  padding: 16px 12px 16px 20px;
  border-top: 1px solid var(--border-soft);
}

/* auto margins split the sidebar's leftover space evenly between every
   element that has one — without this override, both .user's own
   auto margin above and .nav--bottom's above IT would each claim
   half, opening a visible gap between Settings and the user row
   instead of sitting flush together at the very bottom. Only matters
   when .nav--bottom actually renders (Owner/superuser); for everyone
   else .user's own margin-top: auto above still pins it to the bottom
   exactly as before. */
.nav--bottom + .user {
  margin-top: 0;
}

.user__avatar {
  display: grid;
  flex: none;
  place-items: center;
  width: 24px;
  height: 24px;
  background: var(--avatar-bg);
  border-radius: 999px;
  color: var(--avatar-text);
  font-size: 10px;
  font-weight: 600;
}

.user__text {
  display: flex;
  flex: 1;
  flex-direction: column;
  min-width: 0;
  line-height: 1.35;
}

.user__logout {
  flex: none;
  margin: 0 0 0 -2px;
}

.user__logout-btn {
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  padding: 0;
  background: none;
  border: 0;
  border-radius: 8px;
  color: inherit;
  cursor: pointer;
}

.user__logout-btn svg {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: var(--icon);
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.6;
}

.user__logout-btn:hover {
  background: var(--bg);
}

.user__logout-btn:hover svg {
  stroke: var(--text);
}

.user__name {
  overflow: hidden;
  font-size: 12px;
  font-weight: 500;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.user__email {
  overflow: hidden;
  color: var(--text-muted);
  font-size: 10px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Sidebar collapsed state (desktop only, >=1024px) ------------------------
   Toggled via .sidebar-collapsed on .app — see sidebar-collapse-toggle in
   this file's "Sidebar collapse" section and sidebar.js. Scoped to
   min-width: 1024px so the preference is inert on the mobile/tablet
   drawer, which always shows the full sidebar with labels regardless. */
@media (min-width: 1024px) {
  .sidebar-collapsed .sidebar {
    width: var(--sidebar-w-collapsed);
  }

  .sidebar-collapsed .main {
    margin-left: var(--sidebar-w-collapsed);
  }

  .sidebar-collapsed .brand {
    justify-content: center;
    padding-left: 0;
    padding-right: 0;
  }

  .sidebar-collapsed .brand .brand__mark {
    display: grid;
  }

  .sidebar-collapsed .brand__text,
  .sidebar-collapsed .sidebar-collapse-toggle__label,
  .sidebar-collapsed .nav__label,
  .sidebar-collapsed .nav__badge,
  .sidebar-collapsed .user__text {
    display: none;
  }

  .sidebar-collapsed .sidebar-collapse-toggle {
    justify-content: center;
    padding-left: 0;
    padding-right: 0;
  }

  .sidebar-collapsed .sidebar-collapse-toggle__icon {
    transform: rotate(180deg);
  }

  .sidebar-collapsed .nav__item {
    justify-content: center;
    padding-left: 0;
    padding-right: 0;
  }

  .sidebar-collapsed .user {
    justify-content: center;
    gap: 6px;
    padding-left: 6px;
    padding-right: 6px;
  }

  .sidebar-collapsed .user__logout {
    margin-left: 0;
  }
}

/* Page heading ----------------------------------------------------------- */

.page-date {
  margin: 0;
  color: var(--text-muted);
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.page-title {
  margin: 2px 0 0;
  font-size: 25px;
  font-weight: 400;
  letter-spacing: -0.015em;
}

.page-subtitle {
  margin: 6px 0 0;
  color: var(--text-secondary);
  font-size: 14px;
}

.page-heading-row {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 24px;
}

/* A second page-heading-row further down the same page (e.g. a
   distinct section below the page's own top heading) needs its own
   top margin to separate it from whatever precedes it — the base
   rule above has none, since it's normally the very first element on
   a page, right under the top nav. */
.page-heading-row--section {
  margin-top: 32px;
}

/* Mobile nav --------------------------------------------------------------
   Below the desktop breakpoint (tablet and phone both) the sidebar
   becomes a toggleable drawer instead of a permanently-visible column.
   Base rules below are inert at any width (hidden/inactive by default)
   so desktop is unaffected; the @media block is where they actually
   take effect. */

.mobile-topbar {
  display: none;
}

.sidebar-toggle {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  padding: 0;
  background: none;
  border: 0;
  border-radius: 8px;
  color: inherit;
  cursor: pointer;
}

.sidebar-toggle:hover {
  background: var(--bg);
}

.sidebar-toggle__icon {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: var(--text);
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.8;
}

.sidebar-backdrop {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: none;
  background: rgb(0 0 0 / 40%);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}

@media (max-width: 1023.98px) {
  .mobile-topbar {
    position: sticky;
    /* Not a bare 0 — now that the viewport meta tag declares
       viewport-fit=cover (see templates/base.html), page content can
       render under the status bar/notch at scroll position 0, and a
       sticky-top bar would sit right under it without this. */
    top: env(safe-area-inset-top, 0px);
    z-index: 30;
    display: flex;
    align-items: center;
    gap: 10px;
    /* min-height, not height — the inset is ADDED padding (so the
       56px of actual bar content keeps its own size), not budget the
       56px has to shrink to fit inside (box-sizing: border-box would
       otherwise squeeze the toggle button/brand into less room on a
       notched phone). */
    min-height: 56px;
    padding: env(safe-area-inset-top, 0px) 12px 0;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
  }

  .mobile-topbar__brand {
    display: flex;
    align-items: center;
  }

  .mobile-topbar__brand .brand-logo {
    height: 18px;
  }

  .sidebar {
    z-index: 50;
    transform: translateX(-100%);
    transition: transform 0.25s ease;
  }

  .sidebar.is-open {
    box-shadow: 4px 0 24px rgb(0 0 0 / 12%);
    transform: translateX(0);
  }

  .sidebar-backdrop {
    display: block;
  }

  .sidebar-backdrop.is-open {
    opacity: 1;
    pointer-events: auto;
  }

  body.sidebar-open {
    overflow: hidden;
  }

  .main {
    margin-left: 0;
    padding: 20px 16px 48px;
  }
}

/* M4 US-SP-08: a student's lessons done (bookings/_lesson_count.html) on My
   Courses, the Courses page and the student record. */
.lesson-count { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--text-secondary); white-space: nowrap; }
.lesson-count--muted { color: var(--text-muted); }
.lesson-count__bar { position: relative; width: 52px; height: 6px; border-radius: 999px; background: var(--border); overflow: hidden; }
.lesson-count__fill { position: absolute; inset: 0 auto 0 0; border-radius: 999px; background: var(--accent-green-strong); }

/* The frame (Karla, 17 Nov 2026) ----------------------------------------
   The student portal's look for the staff app: the white sidebar and the
   page sit together as ONE rounded card on a pale sage (--frame). On
   desktop, like the portal, the card stays put and the page scrolls
   INSIDE it (.main is the scroll box) — scrolling the window instead let
   the card's top edge slide up past the frame (Karla, 17 Nov). Checked:
   the only script reading the window's scroll (the Settings tooltips,
   roles_settings.js) still places itself right (the window never scrolls
   now) and hides on any scroll (capture listener). Phones keep the window
   scroll and sticky top bar. The page keeps its off-white --bg, so the
   white cards on it keep their contrast. Only the logged-in shell (.app)
   gets it — login and other pages using this file are unchanged. Last in
   the file so it wins over the shell, collapsed and mobile rules above. */
/* Edge to edge, square at the window's own edges — only the card is
   rounded (rounded outer corners were tried and dropped, Karla 17 Nov:
   they left white slivers against the browser's own corners). */
body:has(> .app) {
  background: var(--frame);
}

.app {
  min-height: 100vh;
  min-height: 100dvh;
  background: var(--frame);
}

@media (min-width: 1024px) {
  .sidebar {
    top: var(--frame-gap);
    left: var(--frame-gap);
    height: calc(100vh - 2 * var(--frame-gap));
    height: calc(100dvh - 2 * var(--frame-gap));
    border: 1px solid var(--border);
    border-radius: var(--frame-radius) 0 0 var(--frame-radius);
  }

  .main {
    position: fixed;
    top: var(--frame-gap);
    right: var(--frame-gap);
    bottom: var(--frame-gap);
    left: calc(var(--sidebar-w) + var(--frame-gap));
    margin: 0;
    overflow-y: auto;
    overscroll-behavior: contain;
    background: var(--bg);
    border: 1px solid var(--border);
    border-left: 0;
    border-radius: 0 var(--frame-radius) var(--frame-radius) 0;
  }

  .sidebar-collapsed .main {
    margin-left: 0;
    left: calc(var(--sidebar-w-collapsed) + var(--frame-gap));
  }
}

/* Printing a page (Cmd+P) prints the whole page, not just what fits in
   the fixed card on screen. */
@media print {
  .app,
  body:has(> .app) {
    background: none;
  }

  .main {
    position: static;
    overflow: visible;
    margin: 0;
    border: 0;
  }
}

/* Phones and tablets: the sidebar is a drawer and the top bar stays as it
   is; the page card sits 8px in from the edges (the portal's own gap) and
   always reaches the bottom, however short the page (Karla, 17 Nov): .app
   is a column, the card takes the height left under the top bar. The
   drawer and its backdrop are fixed and the Feedback dialog opens on top,
   so the column doesn't move them. */
@media (max-width: 1023.98px) {
  .app {
    display: flex;
    flex-direction: column;
  }

  .main {
    flex: 1 0 auto;
    margin: 8px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 14px;
  }
}
