/*
==============================================================================
 PT EMR Simulator - Accessible & Professional Stylesheet
 - WCAG AA compliant color system
 - Modern typography with improved readability
 - Enhanced accessibility features and focus management
 - Professional micro-interactions
 - Responsive design with mobile-first approach
==============================================================================
*/

/* Font imports for better typography */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');
@import url('https://fonts.googleapis.com/css2?family=Oswald:wght@500;600;700&display=swap');
/* Extracted modules (must appear before any style rules) */
@import url('./buttons.css');
@import url('./sidebar.css');
@import url('./tables.css');

/* ========================================
  1) DESIGN TOKENS (Variables & System)
  ======================================== */

/* UND Brand Colors - Single Source of Truth */
:root {
  /* Official UND Brand Colors */
  --und-gray: #aeaeae;
  --und-green: #009a44;
  --und-orange: #ff671f;
  --und-black: #000000;

  /* UND Green Variants */
  --und-green-light: rgba(0, 154, 68, 0.08);
  --und-green-dark: #007a35;
  --und-orange-light: rgba(255, 103, 31, 0.08);
  --und-orange-dark: #e55a1c;

  /* Neutral Gray Scale (no blue tints) */
  --neutral-50: #fafafa; /* Very light background */
  --neutral-100: #f5f5f5; /* Light background */
  --neutral-200: #eeeeee; /* Panel background (light) */
  --neutral-300: #e0e0e0; /* Border (light) */
  --neutral-400: #bdbdbd; /* Muted text */
  --neutral-500: #9e9e9e; /* Secondary text */
  --neutral-600: #757575; /* Primary text (light theme) */
  --neutral-700: #616161; /* Dark borders */
  --neutral-750: #525252; /* Between 700 and 800 */
  --neutral-800: #424242; /* Panel background (dark) */
  --neutral-850: #383838; /* Medium dark */
  --neutral-900: #2c2c2c; /* Background (dark) */
  --neutral-950: #1a1a1a; /* Very dark */
  /* Honor both light and dark UA color schemes */
  color-scheme: light dark;
}

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

.skip-link {
  position: fixed;
  top: 8px;
  left: 8px;
  z-index: 10000;
  background: var(--und-green);
  color: #fff;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  text-decoration: none;
  transform: translateY(-150%);
}
.skip-link:focus {
  transform: translateY(0);
  outline: 2px solid #fff;
  outline-offset: 2px;
}

/* Respect user reduced motion preference */
@media (prefers-reduced-motion: reduce) {
  * {
    animation: none !important;
    transition: none !important;
    scroll-behavior: auto !important;
  }
}

/* Theme-agnostic chrome tokens (stable across themes) */
:root {
  /* Topbar gradient right stop and background remain dark for brand contrast */
  --chrome-topbar-right: var(--neutral-950); /* very dark semantic topbar right */
  --chrome-topbar-bg: rgba(0, 0, 0, 0.92);
  /* Sidebar gradient stops used for gray chrome */
  --chrome-sidebar-left: var(--neutral-800); /* dark navigation */
  --chrome-sidebar-right: var(--neutral-900); /* semantic dark gray */

  /* Theme-agnostic layout + primitives (same in light/dark) */
  /* Layout tokens */
  --topbar-h: 72px; /* unify top bar height (taller per request) */
  --edu-ribbon-h: 28px; /* bottom ribbon height for readable text */
  --sticky-header-h: 64px; /* unified sticky header height */
  /* Shared header geometry (alias for clarity across left/right headers) */
  --header-h: var(--sticky-header-h);
  --header-b: 2px; /* border thickness for header rows */
  /* Section divider brand stripes */
  --section-stripe-angle: 56deg; /* brand angle */
  --section-stripe-gap-frac: 0.65; /* gap portion per period (65%) */
  --section-stripe-fill-frac: 0.35; /* white slash portion per period (35%) */
  --section-stripe-period: 48px; /* width of one gap+slash tile (adjust to taste) */
  --section-stripe-count: 3; /* number of visible slashes */
  --section-stripe-color: #fff; /* slash color (white on UND green) */
  /* Side-edge slant computed from height and brand angle so edges match 56° */
  --section-parallelogram-slant: 38px; /* ≈ 56px / tan(56°) */
  --sidebar-w: 280px; /* unify sidebar width */
  --section-divider-h: 56px; /* sticky in-content section banner height (taller for prominence) */

  /* Z-index layers */
  --z-topbar: 3000;
  --z-sidebar: 1000;
  --z-case-header: 1001;
  --z-sticky-header: 1000; /* below footer ribbon to avoid overlap */
  --z-footer: 1100;
  --z-modal: 10000;

  /* Spacing, radii, shadows */
  --radius-sm: 6px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --radius-xl: 20px;
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  --shadow-1: 0 2px 8px rgba(0, 0, 0, 0.1);
  --shadow-2: 0 8px 18px rgba(0, 0, 0, 0.25);
  /* Input radius token (used across inputs/buttons) */
  --input-radius: var(--radius-md);
}
/* If trig functions are supported, compute slant from height & angle for exact ratio */
@supports (width: calc(1px * tan(45deg))) {
  :root {
    --section-parallelogram-slant: calc(
      var(--section-divider-h) / tan(var(--section-stripe-angle))
    );
  }
}
/* Dark theme tokens (apply when [data-theme="dark"]) */
:root[data-theme='dark'] {
  /* Semantic Background System */
  --bg: var(--neutral-900); /* Primary background */
  --panel: var(--neutral-800); /* Panel/card backgrounds */
  --surface: var(--neutral-800); /* Surface elements */
  --surface-secondary: var(--neutral-850); /* Secondary surfaces */
  --bg-secondary: var(--neutral-850);
  --bg2: var(--neutral-850);
  /* Darken inline card rows so inputs appear lighter than their container */
  --inline-card-bg: var(--neutral-850);

  /* Text Colors */
  --text: var(--neutral-100); /* Primary text */
  --text-secondary: var(--neutral-300); /* Secondary text */
  --text-muted: var(--neutral-400); /* Muted text using UND gray spectrum */
  --muted: var(--neutral-400);

  /* Interactive Colors */
  --accent: var(--und-green); /* Primary accent */
  --accent2: var(--und-green); /* Secondary accent */
  --primary: var(--und-green); /* Primary action color */

  /* Status Colors */
  --warn: #f6e05e; /* Warning yellow */
  --warning: #f6e05e;
  --danger: #fc8181; /* Error red */
  --success: #68d391; /* Success green */

  /* Borders and Dividers */
  --border: var(--neutral-700); /* Standard borders */
  --border-strong: var(--neutral-600);
  --border-muted: rgba(189, 189, 189, 0.25);

  /* Component-specific */
  --chip-bg: var(--neutral-800);
  --surface-muted: var(--neutral-850);
  --text-subtle: var(--neutral-400);
  --table-stripe: var(--neutral-800);
  --table-head-bg: var(--neutral-800);

  /* Input controls (dark theme) - lighter than background for visual hierarchy */
  --input-bg: var(--neutral-750); /* Lighter than background for better contrast */
  --input-border: var(--neutral-700);
  --input-text: var(--neutral-50); /* UND gray spectrum instead of hard-coded */

  /* Text on light surfaces (for white sidebar cards) */
  --text-on-light: var(--neutral-900); /* UND gray spectrum instead of hard-coded */
  --text-secondary-on-light: var(--neutral-600);

  /* Select controls (dark theme) */
  --select-bg: var(--neutral-850);
  --select-border: var(--neutral-700);
  --select-text: var(--neutral-50); /* UND gray spectrum instead of hard-coded */

  /* Light surface variants */
  --surface-light: var(--neutral-50);
  --surface-light-border: var(--neutral-300);
  --surface-light-hover: var(--neutral-50);

  /* Enhanced tokens with better contrast */
  --primary-light: var(--und-green-light);
  --accent2-light: var(--und-green-light);
  --border-light: rgba(189, 189, 189, 0.6); /* UND neutral-400 with opacity */
  --danger-light: rgba(252, 129, 129, 0.15);
  --primary-dark: var(--und-green-dark);
  --accent2-dark: var(--und-green-dark);
  --accent-dark: var(--und-green-dark); /* Use UND green instead of non-brand color */
  --danger-dark: #e53e3e;
  --bg-hover: rgba(255, 255, 255, 0.05);

  /* Button system */
  --btn-bg: var(--neutral-800);
  --btn-hover: var(--neutral-700);
  --btn-primary: var(--und-green); /* Use UND green instead of blue */

  /* Gradients - Neutral */
  --gradient-start: var(--neutral-900);
  --gradient-mid: var(--neutral-850);
  --gradient-end: var(--neutral-900);

  /* Header gradients for dark theme */
  --header-gradient-left: var(--und-black);
  --header-gradient-right: var(--chrome-topbar-right);

  /* Background gradients - Clean */
  --home-bg-start: var(--bg);
  --home-bg-end: var(--bg);

  /* Chrome elements */
  --topbar-gradient-right: var(--neutral-900);
  --topbar-bg: rgba(0, 0, 0, 0.92);
  --footer-bg: rgba(10, 12, 18, 0.7);
  --inline-card-bg: var(--neutral-800);
  --icon-color: var(--neutral-100); /* UND gray spectrum instead of hard-coded */
  --icon-opacity: 1;

  /* Z-index layers */
  --z-topbar: 3000;
  --z-sidebar: 1000;
  --z-case-header: 1001;
  --z-sticky-header: 1000; /* Below footer ribbon to avoid overlap */
  --z-footer: 1100;
  --z-modal: 10000;

  /* Spacing, radii, shadows */
  --radius-sm: 6px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --radius-xl: 20px;
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  --shadow-1: 0 2px 8px rgba(0, 0, 0, 0.1);
  --shadow-2: 0 8px 18px rgba(0, 0, 0, 0.25);
  /* Input radius token (overridable in contexts like tables) */
  --input-radius: var(--radius-md);
  /* Editor content background (used behind SOAP sections) */
  --editor-bg: var(--neutral-900);
  /* Sticky patient header background (darker in dark theme) */
  --case-header-bg: var(--neutral-950);
}

/* Icon utility for sprite-based SVGs */
.icon {
  width: 1em;
  height: 1em;
  vertical-align: -0.125em;
  fill: currentColor;
}

.btn .icon,
.nav-link .icon {
  margin-right: 0.5rem;
}

/* Hide inline SVG sprite container */
#svg-sprite {
  display: none;
}

/* Light theme - Accessibility-compliant (WCAG AA) */
:root {
  /* Semantic Background System */
  --bg: var(--neutral-50); /* Primary background */
  --panel: var(--neutral-200); /* Panel/card backgrounds (UND gray tint) */
  --surface: var(--neutral-200); /* Surface elements */
  --surface-secondary: var(--neutral-100);
  --bg-secondary: var(--neutral-100);
  --bg2: var(--neutral-100);

  /* Text Colors */
  --text: #1a202c; /* Primary text */
  --text-secondary: var(--neutral-600); /* Secondary text */
  --text-muted: var(--neutral-500); /* Muted text */
  --muted: var(--neutral-600);

  /* Interactive Colors */
  --accent: var(--und-green); /* Primary accent */
  --accent2: var(--und-green); /* Secondary accent */
  --primary: var(--und-green); /* Primary action color */

  /* Status Colors */
  --warn: #d69e2e; /* Warning yellow */
  --warning: #d69e2e;
  --danger: #e53e3e; /* Error red */
  --success: #38a169; /* Success green */

  /* Borders and Dividers */
  --border: var(--neutral-300); /* Standard borders */
  --border-strong: var(--neutral-400);
  --border-muted: rgba(224, 224, 224, 0.35);

  /* Component-specific */
  --chip-bg: var(--neutral-100);
  --surface-muted: var(--neutral-100);
  --text-subtle: var(--neutral-600);
  --table-stripe: var(--neutral-100);
  --table-head-bg: var(--neutral-700); /* Darker for contrast in light mode */
  --editor-bg: var(--neutral-200);
  /* Input controls for light theme */
  --input-bg: var(--neutral-50);
  --input-border: var(--neutral-300);
  --input-text: var(--neutral-900); /* UND gray spectrum instead of hard-coded */

  /* Selects in light theme */
  --select-bg: var(--neutral-50);
  --select-border: var(--neutral-300);
  --select-text: var(--neutral-900); /* UND gray spectrum instead of hard-coded */

  /* Light surface tokens */
  --surface-light: var(--neutral-50);
  --surface-light-border: var(--neutral-300);
  --surface-light-hover: var(--neutral-50);

  /* Button system for light theme */
  --btn-bg: var(--neutral-100);
  --btn-hover: var(--neutral-200);
  --btn-primary: var(--und-green);

  --gradient-start: var(--neutral-50);
  --gradient-mid: var(--neutral-100);
  --gradient-end: var(--neutral-50);

  /* Header gradients for light theme */
  --header-gradient-left: var(--neutral-800);
  --header-gradient-right: var(--neutral-750);

  /* Home (landing) background gradient - light theme */
  --home-bg-start: var(--neutral-50);
  --home-bg-end: var(--neutral-100);
  /* Topbar gradient right stop for light theme */
  --topbar-gradient-right: var(--neutral-800);
  /* Keep a dark top bar in light mode for stronger brand contrast */
  --topbar-bg: var(--neutral-900);
  --footer-bg: var(--neutral-100);
  --inline-card-bg: var(--neutral-200);
  --icon-color: var(--neutral-700); /* Better icon contrast */
  --icon-opacity: 1;
  --bg-hover: rgba(0, 0, 0, 0.04);
  --danger-dark: #c53030;
  --accent-dark: #2f855a;

  /* Enhanced tokens for light theme with better contrast */
  --primary-light: var(--und-green-light);
  --accent2-light: var(--und-green-light);
  --border-light: rgba(224, 224, 224, 0.6); /* UND neutral-300 with opacity */
  --danger-light: rgba(220, 53, 69, 0.1);
  --primary-dark: var(--und-green-dark);
  --accent2-dark: var(--und-green-dark);

  /* Editor content background for light theme (slightly tinted to lift from bg) */
  --editor-bg: color-mix(in srgb, var(--neutral-200) 80%, white);
  /* Sticky patient header background: match subsection header gray gradient */
  --case-header-bg: linear-gradient(
    90deg,
    var(--header-gradient-left) 0%,
    var(--header-gradient-right) 100%
  );
}

/* Modules imported at top; keep this comment as a marker */

/* ========================================
   2) BASE / RESET & TYPOGRAPHY
   ======================================== */
* {
  box-sizing: border-box;
}
html,
body {
  min-height: 100%;
}

/* Enhanced typography for accessibility */
html {
  font-size: 16px; /* Base font size for better accessibility */
  /* Remove deprecated text-size-adjust properties to satisfy linters */
}

body {
  margin: 0;
  font-family:
    'Inter',
    -apple-system,
    BlinkMacSystemFont,
    'Segoe UI',
    'Roboto',
    'Oxygen',
    'Ubuntu',
    'Cantarell',
    'Fira Sans',
    'Droid Sans',
    'Helvetica Neue',
    sans-serif;
  font-size: 1rem; /* 16px base */
  line-height: 1.6; /* Better readability */
  font-weight: 400;
  background: var(--surface);
  color: var(--text);
  min-height: 100vh; /* allow page to grow naturally and scroll */
  /* Improve font rendering */
  font-feature-settings:
    'liga' 1,
    'kern' 1;
  text-rendering: optimizeLegibility;
}

/* Typography hierarchy */
h1,
h2,
h3,
h4,
h5,
h6 {
  font-weight: 600;
  line-height: 1.3;
  margin: 0 0 1rem 0;
  color: var(--text);
}

h1 {
  font-size: clamp(1.875rem, 1.2rem + 2.2vw, 2.25rem);
} /* 30→36 */
h2 {
  font-size: clamp(1.5rem, 1.1rem + 1.4vw, 1.875rem);
} /* 24→30 */
h3 {
  font-size: clamp(1.25rem, 1rem + 1vw, 1.5rem);
} /* 20→24 */
h4 {
  font-size: clamp(1.125rem, 0.95rem + 0.7vw, 1.25rem);
} /* 18→20 */
h5 {
  font-size: clamp(1rem, 0.95rem + 0.4vw, 1.125rem);
} /* 16→18 */
h6 {
  font-size: clamp(0.9375rem, 0.9rem + 0.2vw, 1rem);
} /* 15→16 */

p {
  margin: 0 0 1rem 0;
  line-height: 1.6;
}

/* Focus management for accessibility */
:where(:focus-visible) {
  outline: 2px solid var(--und-green);
  outline-offset: 2px;
}

/* Ensure visible focus on common interactive elements even if components override outline */
:where(button, [role='button'], a[href], input, select, textarea, summary):focus-visible {
  outline: 2px solid var(--und-green);
  outline-offset: 2px;
}

/* Native controls accent color */
html {
  accent-color: var(--und-green);
}

/* Respect Windows High Contrast / forced colors */
@media (forced-colors: active) {
  :root {
    /* Let system manage colors; keep borders visible */
    --border: CanvasText;
  }
  :where(:focus-visible) {
    outline: 2px solid Highlight;
    outline-offset: 2px;
  }
  .btn,
  input,
  select,
  textarea {
    /* Safari doesn't support forced-color-adjust; safe to omit */
    border-color: CanvasText;
  }
}

/* Skip link styles consolidated near the end of file under accessibility section */

/* ========================================
   3) APP CHROME (Topbar, Sidebar, Footer)
   ======================================== */
/* .topbar legacy block removed; using specific header.topbar block defined later */

/* Educational ribbon fixed to the viewport bottom */
.edu-ribbon {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: var(--z-footer);
  height: var(--edu-ribbon-h);
  display: flex;
  align-items: center;
  justify-content: center;
  /* Dark gradient: true black → dark gray to mirror topbar */
  background: linear-gradient(90deg, var(--und-black) 0%, var(--chrome-topbar-right) 100%);
  color: #fff;
  font-size: 0.75rem; /* 12px */
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 0 12px; /* side padding for layout */
  padding-bottom: env(safe-area-inset-bottom);
}
/* Gradient top accent line: darker orange → flame orange */
.edu-ribbon::before {
  content: '';
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--und-orange-dark) 0%, var(--und-orange) 100%);
}
.edu-ribbon span {
  opacity: 0.9;
}
/* Left/Right inline layout */
.edu-ribbon {
  gap: 8px;
}
.edu-ribbon .edu-left {
  margin-right: auto;
}
.edu-ribbon .edu-right {
  margin-left: auto;
  white-space: nowrap;
}
/* Small flame orange text on right */
.edu-ribbon .edu-right {
  color: var(--und-orange);
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: none;
  font-size: 0.6875rem; /* 11px */
}
@media (max-width: 480px) {
  .edu-ribbon {
    height: 24px;
    font-size: 0.6875rem; /* 11px */
  }
  .edu-ribbon .edu-right {
    font-size: 0.625rem; /* 10px */
  }
}

/* Avoid content being hidden behind fixed bottom ribbon */
/* Add a bit of extra breathing room below content so the fixed ribbon never overlaps */
body:has(.edu-ribbon) {
  padding-bottom: calc(var(--edu-ribbon-h) + env(safe-area-inset-bottom) + 16px);
}

/* Ensure primary containers also have clearance above the fixed ribbon */
/* On home and simple pages (#app uses padding), and on editor pages (.main-content-with-sidebar) */
body:has(.edu-ribbon) #app {
  /* Add extra space at the very bottom so last panels/cards aren't obscured */
  padding-bottom: calc(var(--edu-ribbon-h) + env(safe-area-inset-bottom) + 24px);
}
/* Note: Case editor handles bottom clearance locally (inline margins on action bars).
   Avoid adding extra global padding here to prevent unnecessary spacing. */
/* Home-only: ensure the last panels have breathing room above the fixed ribbon */
.home-container {
  padding-bottom: calc(var(--edu-ribbon-h) + env(safe-area-inset-bottom) + 28px);
}

/* Home-only background: subtle gray gradient to improve panel contrast */
#app:has(.home-container) {
  background: linear-gradient(
    180deg,
    var(--home-bg-start, var(--neutral-200)) 0%,
    var(--home-bg-end, var(--neutral-300)) 100%
  );
}

/* Also paint the page background so margins around #app are covered */
body:has(#app .home-container) {
  background: linear-gradient(
    180deg,
    var(--home-bg-start, var(--neutral-200)) 0%,
    var(--home-bg-end, var(--neutral-300)) 100%
  );
}

/* Apply the same UND Gray gradient to Student and Faculty dashboards */
body[data-route='student-cases'],
body[data-route='instructor-cases'] {
  background: linear-gradient(
    180deg,
    var(--home-bg-start, var(--neutral-200)) 0%,
    var(--home-bg-end, var(--neutral-300)) 100%
  );
}

/* Also ensure the main app area uses the gradient for those routes */
body[data-route='student-cases'] #app,
body[data-route='instructor-cases'] #app {
  background: linear-gradient(
    180deg,
    var(--home-bg-start, var(--neutral-200)) 0%,
    var(--home-bg-end, var(--neutral-300)) 100%
  );
}

/* Editor routes: paint the page canvas with the darker editor background */
body[data-route='student-editor'],
body[data-route='instructor-editor'] {
  background: var(--editor-bg);
}
body[data-route='student-editor'] #app,
body[data-route='instructor-editor'] #app {
  background: var(--editor-bg);
}

/* Patient info sticky header: unify geometry with sidebar CASE FILE tab */
#patient-sticky-header {
  height: var(--header-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px; /* match sticky-top-bar horizontal padding */
  line-height: 1; /* kill extra line-height growth */
  box-sizing: border-box;
  border: var(--header-b) solid transparent; /* equal total box */
  border-bottom-color: var(--und-green); /* only show bottom visually */
  transform: translateZ(0); /* sub-pixel snapping */
}

/* Light theme: match subsection header gradient and ensure readable text on dark bg */
html:not([data-theme='dark']) #patient-sticky-header {
  /* Scope text tokens inside the header for correct contrast */
  --text: #ffffff;
  --text-secondary: rgba(255, 255, 255, 0.9);
  color: var(--text);
}

/* Ensure the white Edit button uses dark text inside the gradient header */
html:not([data-theme='dark']) #patient-sticky-header .btn.secondary {
  color: var(--neutral-900);
  background: #ffffff; /* keep white button fill */
  border-color: var(--und-green);
}
html:not([data-theme='dark']) #patient-sticky-header .btn.secondary:hover {
  color: var(--und-green);
}

/* Darker panel containers on Home, Student, Faculty dashboards */
/* Light theme: increase UND Gray mix with white for deeper panels */
html:not([data-theme='dark']) body[data-route='home'],
html:not([data-theme='dark']) body[data-route='student-cases'],
html:not([data-theme='dark']) body[data-route='instructor-cases'] {
  /* Use the same gray as the case editor background for containers */
  --panel: var(--editor-bg);
  --surface: var(--editor-bg);
  /* Slightly darker border for definition on light editor gray */
  --border: color-mix(in srgb, var(--editor-bg) 60%, black);
}

/* Dark theme: increase UND Gray mix with black for deeper panels */
html[data-theme='dark'] body[data-route='home'],
html[data-theme='dark'] body[data-route='student-cases'],
html[data-theme='dark'] body[data-route='instructor-cases'] {
  /* Mirror the editor background for containers in dark theme too */
  --panel: var(--editor-bg);
  --surface: var(--editor-bg);
  /* Slightly lighter border for definition on dark editor background */
  --border: color-mix(in srgb, var(--editor-bg) 46%, white);
}

/* Offset page content for fixed main header */
/* Only add offset when a topbar exists */
body:has(header.topbar) {
  padding-top: var(--topbar-h);
}

/* Top bar navigation styles consolidated under header.topbar at the end of file */

/* Theme toggle switch */
.theme-toggle.switch {
  position: relative;
  width: 56px;
  height: 28px;
  border: none;
  background: transparent;
  padding: 0;
  margin-left: 8px;
  cursor: pointer;
}
.theme-toggle .switch-track {
  position: absolute;
  inset: 0;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.18);
  border: 1px solid rgba(255, 255, 255, 0.25);
  transition:
    background 0.2s ease,
    border-color 0.2s ease;
}
.theme-toggle .switch-thumb {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--bg);
  display: grid;
  place-items: center;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
  transition:
    transform 0.22s ease,
    background 0.2s ease;
}
.theme-toggle .icon {
  font-size: 14px;
  line-height: 1;
}
.theme-toggle .icon.sun {
  display: block;
}
.theme-toggle .icon.moon {
  display: none;
}
/* Tweak sun/moon SVG appearance */
.theme-toggle .switch-thumb .icon {
  width: 14px;
  height: 14px;
}
/* Light theme: sun icon colored, dark theme: moon icon colored */
html:not([data-theme='dark']) .theme-toggle .icon.sun {
  color: var(--und-orange);
}
html[data-theme='dark'] .theme-toggle .icon.moon {
  color: var(--und-orange);
}

.theme-toggle.is-dark .switch-track {
  background: rgba(255, 255, 255, 0.18);
  border-color: rgba(255, 255, 255, 0.25);
}
.theme-toggle.is-dark .switch-thumb {
  transform: translateX(28px);
}
.theme-toggle.is-dark .icon.sun {
  display: none;
}
.theme-toggle.is-dark .icon.moon {
  display: block;
}

.theme-toggle.switch:focus-visible {
  /* use custom track ring */
  outline: none;
}
.theme-toggle.switch:focus-visible {
  /* Use the custom track ring instead of default outline */
  outline: none;
}
/* Remove Firefox inner focus border for buttons */
.theme-toggle.switch::-moz-focus-inner {
  border: 0;
}
.theme-toggle.switch:hover .switch-track {
  filter: brightness(1.08);
}

.theme-toggle:focus-visible {
  /* use custom track ring */
  outline: none;
}
.theme-toggle:focus-visible {
  /* Use the custom track ring instead of default outline */
  outline: none;
}
/* Provide a visible focus affordance on the track when focused */
.theme-toggle:focus-visible .switch-track {
  box-shadow:
    0 0 0 3px color-mix(in srgb, var(--und-green) 30%, transparent),
    0 0 0 1px var(--und-green);
}
.theme-toggle {
  -webkit-tap-highlight-color: transparent;
}

/* Accessible, subtle focus cue: soft ring around the track on keyboard focus */
.theme-toggle:focus-visible .switch-track {
  box-shadow:
    0 0 0 2px rgba(255, 255, 255, 0.18),
    0 0 0 5px rgba(0, 154, 68, 0.45); /* UND green ring */
}

@media (prefers-contrast: more) {
  .theme-toggle:focus-visible .switch-track {
    box-shadow:
      0 0 0 2px rgba(255, 255, 255, 0.28),
      0 0 0 6px rgba(0, 154, 68, 0.75);
  }
}

/* Theme toggle is visible in the top-right of the header */

/* UND-branded mini toggle used in subsection headers */
.und-toggle {
  cursor: pointer;
}
.und-toggle-input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}
.und-toggle-track {
  width: 38px;
  height: 22px;
  border-radius: 999px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  display: inline-flex;
  align-items: center;
  padding: 2px;
  box-sizing: border-box;
  transition:
    background 0.2s ease,
    border-color 0.2s ease;
}
.und-toggle-thumb {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
  background: var(--bg);
  transition: transform 0.2s ease;
}
/* Checked (on) state: UND green */
.und-toggle-input:checked + .und-toggle-track {
  background: var(--und-green);
  border-color: var(--und-green-dark);
}
.und-toggle-input:checked + .und-toggle-track .und-toggle-thumb {
  transform: translateX(16px);
}
/* Focus ring for accessibility */
.und-toggle-input:focus-visible + .und-toggle-track {
  box-shadow: 0 0 0 2px var(--und-green-light);
}
/* Hover brightness */
.und-toggle:hover .und-toggle-track {
  filter: brightness(1.03);
}

/* Toggle label color and state cue */
.subsection-visibility-toggle .toggle-text {
  color: rgba(255, 255, 255, 0.85);
  letter-spacing: 0.03em;
}
.subsection-visibility-toggle .und-toggle-input:not(:checked) ~ .toggle-text {
  color: rgba(255, 255, 255, 0.65);
}
.subsection-visibility-toggle .und-toggle-input:checked ~ .toggle-text {
  color: var(--text);
}

/* Visually hide ON/OFF text (keep accessible) */
.subsection-visibility-toggle .toggle-text {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

/* Sidebar styles extracted to sidebar.css */

/* ========================================
   4) LAYOUT (App container & main content)
   ======================================== */
#app {
  padding: var(--space-4);
  max-width: 1100px;
  width: 100%;
  margin: 0 auto;
  /* Let the document body handle vertical scrolling; avoid constraining height here */
}
/* Expand app when sidebar is present */
#app:has(.chart-navigation) {
  max-width: none;
  margin: 0;
  padding: 0;
  width: 100%;
}

/* Educational Disclaimer Banner - removed (now a slim top ribbon) */

/* Also remove padding when sticky header is present */
#app:has(.sticky-top-bar) {
  max-width: none;
  margin: 0;
  padding: 0;
  width: 100%;
}

/* Sticky top bar + sidebar-aware adjustments */
.sticky-top-bar {
  position: fixed;
  top: var(--topbar-h);
  z-index: var(--z-sticky-header);
  left: 0;
  width: 100%;
  margin-left: var(--sidebar-w);
  width: calc(100% - var(--sidebar-w));
  transition:
    margin-left 0.3s ease,
    width 0.3s ease;
  contain: layout; /* Performance optimization for main content area */

  /* Visual styling - clean professional design with exact height */
  /* Subtle left→right gradient: darker green to UND green */
  background: linear-gradient(90deg, var(--und-green-dark) 0%, var(--und-green) 100%);
  color: #fff;
  height: var(--header-h); /* Fixed height via shared variable */
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px; /* Consistent padding */
  box-sizing: border-box; /* Critical for height calculation */
  line-height: 1; /* avoid extra inline height */
  /* Unify total box height with sidebar tab: transparent full border + bottom color */
  border: var(--header-b) solid transparent;
  border-bottom-color: var(--und-green);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

/* In-content sticky section divider that gently pushes when next section arrives */
.editor-section-divider {
  position: sticky; /* stick just under the top app bar */
  top: calc(var(--topbar-h) + var(--patient-sticky-h, 0px));
  z-index: var(--z-sticky-header);
  height: var(--section-divider-h);
  display: flex;
  align-items: center;
  justify-content: center; /* center the section title */
  /* Use editor canvas background so cutout triangles blend with page in light/dark */
  background: var(--editor-bg);
  color: #fff;
  box-shadow: none; /* avoid rectangular shadow peeking outside slants */
  /* Full bleed within the content container (respects sidebar); cancel horizontal gutters */
  margin-left: calc(-1 * var(--pad-x));
  margin-right: calc(-1 * var(--pad-x));
  padding-left: var(--pad-x);
  padding-right: var(--pad-x);
  /* ensure the pseudo-element stacks behind content */
  isolation: isolate;
  overflow: hidden; /* ensure stripe/SVG crop aligns to parallelogram edges */
}

/* Parallelogram background (keeps text upright) */
.editor-section-divider::before {
  content: '';
  position: absolute;
  inset: 0; /* cover full element */
  background: linear-gradient(90deg, var(--und-green-dark) 0%, var(--und-green) 100%);
  border-bottom: none; /* avoid seam on light canvas */
  z-index: -2; /* sit behind stripes and content */
  /* create left and right slants; tweak the 16px to taste */
  clip-path: polygon(
    var(--section-parallelogram-slant) 0,
    100% 0,
    calc(100% - var(--section-parallelogram-slant)) 100%,
    0 100%
  );
}

/* Three brand slashes at the right edge */
/* Stripes disabled: show a clean green parallelogram only */

/* Home hero: UND green gradient parallelogram banner */
.home-hero {
  position: relative;
  min-height: 92px; /* narrower banner */
  display: flex;
  align-items: center;
  justify-content: center; /* center the title */
  padding: var(--space-4) calc(1.5 * var(--pad-x)); /* slightly less vertical padding; overshoot horizontally */
  color: #fff;
  margin-left: calc(-2.5 * var(--pad-x)); /* bleed further left */
  margin-right: calc(-2.5 * var(--pad-x)); /* bleed further right */
  isolation: isolate;
  overflow: hidden;
}
.home-hero::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, var(--und-green-dark) 0%, var(--und-green) 100%);
  clip-path: polygon(
    var(--section-parallelogram-slant) 0,
    100% 0,
    calc(100% - var(--section-parallelogram-slant)) 100%,
    0 100%
  );
  z-index: -1;
}
.home-hero__title {
  font-size: clamp(22px, 4vw, 32px);
  font-weight: 800;
  letter-spacing: 0.5px;
  margin: 0;
  color: #fff; /* ensure white text regardless of global h1 color */
  text-align: center;
}
.editor-section-divider::after {
  content: none !important;
}
.editor-section-divider h3 {
  margin: 0;
  font-size: 20px;
  letter-spacing: 0.4px;
  text-transform: uppercase;
  color: #fff;
  font-weight: 800;
  line-height: 1;
  width: 100%;
  text-align: center; /* explicit text centering */
}

/* Section wrapper spacing so upcoming dividers are visible early */
.editor-section {
  padding-top: var(--space-2);
  margin-top: var(--space-3);
}

/* Constrain sticky bar content to the same max width as #app on routes without sidebar */
.sticky-top-bar > .bar-inner {
  width: 100%;
  max-width: 1100px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

/* Double gutters for the sticky top info bar on desktop */
@media (min-width: 1024px) {
  .sticky-top-bar {
    padding-left: 40px;
    padding-right: 40px;
  }
}

/* Sticky top bar section title */
.sticky-top-bar .active-section-title {
  margin: 0;
  color: #fff;
  font-size: 18px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* Sticky top bar left and right sections */
.sticky-top-bar .left-section {
  display: flex;
  align-items: center;
}

.sticky-top-bar .right-section {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Save status pill shown in sticky header */
.sticky-top-bar .save-status-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--bg);
  color: var(--text); /* text respects theme */
  border: 1px solid transparent;
  border-radius: 999px;
  padding: 6px 10px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.15);
}
.sticky-top-bar .save-status-pill .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--muted);
}
.sticky-top-bar .save-status-pill .dot.saved {
  background: var(--success);
}
.sticky-top-bar .save-status-pill .dot.saving {
  background: var(--warn);
}
.sticky-top-bar .save-status-pill .dot.error {
  background: var(--danger);
}
.sticky-top-bar .save-status-pill .text {
  font-size: 12px;
  font-weight: 600;
  color: var(--text);
}

/* Override button styling for UND Green header */
.sticky-top-bar .btn.secondary {
  padding: 8px 16px;
  font-size: 14px;
  background: rgba(255, 255, 255, 0.2);
  border: 1px solid rgba(255, 255, 255, 0.3);
  color: #fff;
}

.sticky-top-bar .btn.secondary:hover {
  background: rgba(255, 255, 255, 0.3);
  border-color: rgba(255, 255, 255, 0.5);
  color: #fff;
  transform: translateY(-1px);
}
.main-content-with-sidebar {
  margin-left: var(--sidebar-w);
  width: calc(100% - var(--sidebar-w));
  /* Let content define height; ensure safe space for bottom ribbon via padding */
  padding-bottom: calc(var(--edu-ribbon-h) + 16px);
  margin-top: 0;
  transition:
    margin-left 0.3s ease,
    width 0.3s ease;
  background: var(--editor-bg);
}

/* When sticky header is present and fixed, add top padding to content */
#app:has(.sticky-top-bar) .main-content-with-sidebar {
  padding-top: var(--sticky-header-h);
}
/* Removed legacy .nav-collapsed adjustments */

/* Section container */
.main-container {
  background: var(--surface);
  margin: var(--space-3) 0;
  overflow: visible;
}
.section-content {
  /* horizontal padding token used to align inner content and allow headers to be full-bleed */
  --pad-x: clamp(16px, 3vw, 48px);
  padding: var(--space-5) var(--pad-x);
  margin: 0 auto;
  max-width: 1100px;
}
/* Desktop: responsive, tighter horizontal padding to avoid excessive gutters */
@media (min-width: 1024px) {
  .section-content {
    /* maintain the same pad var to keep alignment consistent */
    padding-left: var(--pad-x);
    padding-right: var(--pad-x);
  }
}

/* Section pager: UND-styled modern buttons */
.section-content .section-pager {
  display: block; /* spacing handled inline; keep block for specificity */
}
.section-content .pager-btn {
  border-radius: 9999px;
  padding: 10px 16px;
  min-height: 40px;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.12);
  font-weight: 700;
}
.section-content .pager-btn.pager-next.btn.primary,
.section-content .pager-btn.pager-prev.btn.primary,
.section-content .pager-btn.pager-home.btn.primary {
  background: linear-gradient(90deg, var(--und-green-dark) 0%, var(--und-green) 100%);
  border-color: var(--und-green-dark);
}
.section-content .pager-btn.pager-next.btn.primary:hover {
  filter: brightness(1.05);
}
/* Remove secondary variant usage for pager; all are primary */

/* Clean pill buttons (no clip-path arrows) */

/* Button system moved to buttons.css to avoid duplication/conflicts */

/* ========================================
   7) PRIMITIVES (Panels, Typography, Chips)
   ======================================== */
.panel {
  background: var(--panel);
  border: 1px solid var(--border-muted);
  border-radius: var(--radius-lg);
  padding: var(--space-4);
  margin: var(--space-3) 0;
  box-shadow: var(--shadow-2);
}

.section-title {
  font-size: 18px;
  margin: 14px 0 var(--space-2);
  color: var(--text);
  font-weight: 600;
}

.subsection-title {
  font-size: 16px;
  margin: 6px 0 var(--space-3);
  /* Add horizontal padding so text doesn't touch the edges */
  padding: var(--space-2) var(--space-4);
  /* Theme-aware gradient using CSS variables */
  background: linear-gradient(
    90deg,
    var(--header-gradient-left) 0%,
    var(--header-gradient-right) 100%
  );
  color: #fff;
  font-weight: 600;
  /* Subtle rounding for a cleaner pill-like header */
  border-radius: var(--radius-sm);
  text-transform: capitalize;
  letter-spacing: 0.3px;
  /* Reinstate UND green underline for emphasis */
  border-bottom: 3px solid var(--und-green);
}

.brand {
  font-weight: 700;
  letter-spacing: 0.3px;
}

/* Tables styles extracted to tables.css */

/* ========================================
   8) ACCESSIBLE INPUT SYSTEM
   ======================================== */
input[type='text'],
input[type='number'],
input[type='email'],
input[type='tel'],
input[type='url'],
input[type='search'],
textarea,
select,
.form-input,
.form-textarea,
.form-select {
  width: 100%;
  padding: 12px var(--space-3);
  background: var(--input-bg);
  color: var(--input-text);
  border: 1px solid var(--input-border);
  border-radius: var(--input-radius);
  transition: all 0.2s ease;
  font-size: 1rem; /* 16px to prevent zoom on mobile */
  line-height: 1.5;
  min-height: 44px; /* Touch target size */
  font-family: inherit;
}

/* Dark theme: align textareas with selects for a darker tone */
html[data-theme='dark'] textarea,
html[data-theme='dark'] .form-textarea {
  background: var(--select-bg);
  color: var(--select-text);
  border-color: var(--select-border);
}
html[data-theme='dark'] textarea::placeholder,
html[data-theme='dark'] .form-textarea::placeholder {
  color: var(--text-secondary);
}
/* Global select dropdown theme: dark in dark theme, light in light theme */
html[data-theme='dark'] select,
html[data-theme='dark'] .form-select {
  background: var(--select-bg);
  border-color: var(--select-border);
  color: var(--select-text);
}

input[type='text']:focus,
input[type='number']:focus,
input[type='email']:focus,
input[type='tel']:focus,
input[type='url']:focus,
input[type='search']:focus,
textarea:focus,
select:focus,
.form-input:focus,
.form-textarea:focus,
.form-select:focus {
  border-color: var(--border-strong);
  box-shadow: 0 0 0 2px var(--accent2-light);
  transform: translateY(-1px);
}

/* Keyboard focus ring for inputs */
input[type='text']:focus-visible,
input[type='number']:focus-visible,
input[type='email']:focus-visible,
input[type='tel']:focus-visible,
input[type='url']:focus-visible,
input[type='search']:focus-visible,
textarea:focus-visible,
select:focus-visible,
.form-input:focus-visible,
.form-textarea:focus-visible,
.form-select:focus-visible {
  outline: 2px solid var(--und-green);
  outline-offset: 2px;
}

/* Invalid state styling */
input:invalid,
textarea:invalid,
select:invalid {
  border-color: var(--danger);
}

input:invalid:focus,
textarea:invalid:focus,
select:invalid:focus {
  box-shadow: 0 0 0 2px var(--danger-light);
}

/* Disabled state */
input:disabled,
textarea:disabled,
select:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  background: var(--bg-secondary);
}

textarea {
  line-height: 1.6;
  /* Remove scrollbars and the resize handle; we auto-expand on input */
  resize: none;
  overflow: hidden;
}
textarea::-webkit-scrollbar {
  display: none;
} /* Chrome/Safari/Edge */
textarea::-webkit-resizer {
  display: none;
}

/* Placeholder color (muted relative to input text) */
input::placeholder,
textarea::placeholder,
.form-input::placeholder,
.form-textarea::placeholder,
.form-input-standard::placeholder {
  color: rgba(26, 32, 44, 0.55); /* fallback: based on --input-text (#1a202c) */
}
/* Dark theme placeholder color */
html[data-theme='dark'] input::placeholder,
html[data-theme='dark'] textarea::placeholder,
html[data-theme='dark'] .form-input::placeholder,
html[data-theme='dark'] .form-textarea::placeholder,
html[data-theme='dark'] .form-input-standard::placeholder {
  color: rgba(249, 250, 251, 0.55); /* near-white at 55% */
}

/* Radio/checkbox accent color in dark theme for native controls */
html[data-theme='dark'] input[type='radio'],
html[data-theme='dark'] input[type='checkbox'] {
  accent-color: var(--und-green);
  background: var(--input-bg);
  border-color: var(--input-border);
}

/* ========================================
   9) ACCESSIBLE NAVIGATION & TABS
   ======================================== */
.topnav {
  display: flex;
  align-items: center;
  gap: 0;
}

.topnav a {
  padding: var(--space-3) var(--space-5);
  color: var(--text-secondary);
  text-decoration: none;
  font-weight: 600;
  font-size: 1rem; /* restore previous readable size */
  transition: all 0.2s ease;
  border-bottom: 2px solid transparent;
  position: relative;
  margin-right: var(--space-2);
  min-height: 44px; /* touch target */
  display: flex;
  align-items: center;
  border-radius: var(--radius-sm);
}

.topnav a:hover {
  color: var(--und-green);
  background: var(--und-green-light);
}

.topnav a:focus-visible {
  outline: 2px solid var(--und-green);
  outline-offset: 2px;
}

.topnav a.active {
  color: var(--und-green);
  font-weight: 600;
  border-bottom-color: var(--und-green);
  background: var(--und-green-light);
}

/* Spacing for feedback button in top nav */
.topnav .feedback-btn {
  margin-left: 8px;
}

.tabs {
  display: flex;
  gap: 0;
  margin: var(--space-5) 0 var(--space-6);
  padding: 0 var(--space-2);
  flex-wrap: wrap;
  border-bottom: 1px solid var(--border);
}

.tab {
  padding: var(--space-3) var(--space-5);
  background: transparent;
  cursor: pointer;
  color: var(--text-secondary);
  font-weight: 500;
  font-size: 0.875rem; /* 14px */
  transition: all 0.2s ease;
  white-space: nowrap;
  border-bottom: 2px solid transparent;
  min-height: 44px; /* Touch target */
  display: flex;
  align-items: center;
  border-radius: var(--radius-sm) var(--radius-sm) 0 0;
  position: relative;
  border: none;
  text-decoration: none;
}

.tab:hover {
  color: var(--und-green);
  background: var(--und-green-light);
}

.tab:focus-visible {
  outline: 2px solid var(--und-green);
  outline-offset: 2px;
}

.tab.active,
.tab[aria-selected='true'] {
  color: var(--und-green);
  font-weight: 600;
  border-bottom-color: var(--und-green);
  background: var(--und-green-light);
}

/* Sidebar navigation styles extracted to sidebar.css */

/* ========================================
   11) ENHANCED FORM SYSTEM
   ======================================== */
.form-field {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  margin-bottom: var(--space-4);
}
.form-field--disabled {
  opacity: 0.6;
  pointer-events: none;
}
.form-field--error {
  --border-color: var(--danger);
}

.form-label {
  width: auto;
  color: var(--muted);
  font-size: 14px;
  font-weight: 500;
  line-height: 1.4;
  margin-bottom: var(--space-1);
}
.form-label--required::after {
  content: ' *';
  color: var(--danger);
}
.form-label--checkbox,
.form-label--radio {
  width: auto;
  display: flex;
  align-items: center;
  gap: var(--space-2);
  cursor: pointer;
  font-weight: normal;
}
.form-label--checkbox:hover,
.form-label--radio:hover {
  color: var(--text);
}

/* Indent form labels within subsections */
.section-anchor {
  --subsection-indent: 32px;
  padding-left: var(--subsection-indent);
  /* Ensure anchored scroll positions are visible below fixed headers */
  scroll-margin-top: calc(
    var(--topbar-h) + var(--patient-sticky-h, 0px) + var(--section-divider-h)
  );
  /* Performance optimization - only render visible sections */
  content-visibility: auto;
  contain-intrinsic-size: 200px; /* Estimated section height */
}

/* Do not indent subsection titles; keep them aligned with the subsection edge */
.section-anchor > .subsection-title {
  margin-left: calc(-1 * var(--subsection-indent));
}

.section-anchor .form-label {
  margin-left: 0;
  color: var(--text);
  font-weight: 600;
  position: relative;
}

.section-anchor .form-label::before {
  content: '///';
  position: absolute;
  left: -20px;
  top: 50%;
  transform: translateY(-50%);
  width: auto;
  height: auto;
  background: transparent;
  color: var(--und-green);
  font-size: 16px;
  font-weight: 900;
  font-family: monospace;
  letter-spacing: -0.3em;
}

/* Indent form input wrappers within subsections to match labels */
.section-anchor .form-input-wrapper {
  margin-left: 0;
}

/* Remove content indent for In-Clinic Treatment Plan, but keep header pulled left to align with others */
#in-clinic-treatment-plan.section-anchor {
  --subsection-indent: 32px; /* base indent token */
  /* Increase left padding for the section contents so they are relatively indented */
  padding-left: calc(var(--subsection-indent) + var(--space-6));
}
/* Header should stay inside the container (no clipping) and not add extra inner indent */

/* Keep header position but remove extra inner left padding on the banner */
#in-clinic-treatment-plan.section-anchor > .subsection-title {
  padding-left: 0;
}

/* Keep the In-Clinic Treatment Plan sub-heading visually indented, but avoid clipping
   from negative margins inside an overflow-hidden parent. */
#in-clinic-treatment-plan.section-anchor > .subsection-title {
  /* Align header like others: negate the full left padding applied to this section */
  margin-left: calc(-1 * (var(--subsection-indent) + var(--space-6)));
  /* Use default inner padding */
  padding-left: var(--space-4);
}

.form-input-wrapper {
  flex: 1;
  position: relative;
}

/* Case editor: darker row backgrounds in dark theme so inputs are lighter than their container */
html[data-theme='dark'] .section-content .section-anchor > .form-field {
  background: transparent; /* blend into parent */
  border: 0;
  border-radius: 0;
  /* Keep spacing consistent with base theme; do not override padding/margins here */
}
/* Grid rows: let them inherit the parent background for a flat look */
html[data-theme='dark'] .section-content .form-row {
  background: transparent;
  border: 0;
  border-radius: 0;
  /* Keep spacing consistent with base theme; do not override padding/margins here */
}
.form-input--small {
  padding: var(--space-1) var(--space-2);
  font-size: 12px;
}
.form-input--large {
  padding: 14px var(--space-4);
  font-size: 16px;
}

.form-hint {
  font-size: 12px;
  color: var(--text-subtle);
  margin-top: var(--space-1);
  line-height: 1.4;
}
.form-error {
  font-size: 12px;
  color: var(--danger);
  margin-top: var(--space-1);
  line-height: 1.4;
  display: flex;
  align-items: center;
  gap: var(--space-1);
}
.form-error::before {
  content: '⚠';
  font-size: 10px;
}

/* Grid helpers */
.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-4);
  margin-bottom: var(--space-4);
}
.form-row .form-field {
  margin-bottom: 0;
}

/* ========================================
   12) PT-SPECIFIC COMPONENTS
   ======================================== */
.pain-scale-container {
  display: flex;
  gap: var(--space-1);
  margin-bottom: var(--space-2);
  flex-wrap: wrap;
}
.pain-scale-btn {
  border: 1px solid var(--border);
  background: var(--neutral-50); /* semantic neutral background */
  color: #0f172a; /* dark text for contrast */
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-sm);
  cursor: pointer;
  min-width: 32px;
  transition: all 0.2s ease;
}
.pain-scale-btn:focus-visible {
  outline: 3px solid var(--und-green);
  outline-offset: 2px;
}
.pain-scale-btn:hover {
  background: var(--neutral-100); /* semantic hover state */
  box-shadow: 0 1px 0 rgba(0, 0, 0, 0.06);
  transform: translateY(-1px);
}
.pain-scale-btn.active {
  background: var(--accent2);
  border-color: var(--accent2);
  color: #fff;
  transform: scale(1.05);
}
/* Dark theme: make pain scale pills dark with light text */
html[data-theme='dark'] .pain-scale-btn {
  background: var(--input-bg);
  color: var(--input-text);
  border-color: var(--input-border);
}
html[data-theme='dark'] .pain-scale-btn:hover {
  background: var(--bg-hover);
  border-color: var(--input-border);
  box-shadow: none;
}
html[data-theme='dark'] .pain-scale-btn.active {
  background: var(--accent2);
  border-color: var(--accent2);
  color: #fff;
}

/* Dark mode: restore black gradients for subsection headers */
html[data-theme='dark'] .subsection-title {
  background: linear-gradient(90deg, var(--und-black) 0%, var(--chrome-topbar-right) 100%);
}
.pain-scale-desc {
  font-size: 12px;
  color: var(--text-secondary);
  margin-top: var(--space-1);
  line-height: 1.4;
}

.pt-field-group {
  background: var(--inline-card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: var(--space-3);
  margin: var(--space-2) 0;
}

/* Context Panel */
.context-panel {
  background: linear-gradient(135deg, var(--panel) 0%, var(--inline-card-bg) 100%);
  border: 1px solid var(--accent2);
  border-radius: var(--radius-md);
  padding: var(--space-4);
  margin: var(--space-4) 0;
}
.context-panel .inline-card {
  background: var(--und-green-light);
  border-left: 3px solid var(--und-green);
  margin: var(--space-2) 0;
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-sm);
  color: var(--text);
}

/* Regional assessment table styles extracted to tables.css */

/* ========================================
   13) SOAP & OBJECTIVE SECTIONS
   ======================================== */
.soap-section,
.subjective-section,
.objective-section,
.assessment-section,
.plan-section,
.billing-section {
  background: transparent; /* Let uniform editor background show through */
  border-radius: var(--radius-lg);
  margin-bottom: var(--space-6);
  overflow: hidden;
}

/* SOAP section header */
.soap-section h3,
.subjective-section h3,
.objective-section h3,
.assessment-section h3,
.plan-section h3,
.billing-section h3 {
  /* Subtle left→right gradient: slightly darker green to UND green */
  background: linear-gradient(90deg, var(--und-green-dark) 0%, var(--und-green) 100%);
  color: white;
  margin: calc(-1 * var(--space-5)) calc(-1 * var(--space-5)) 0 calc(-1 * var(--space-5));
  padding: var(--space-4) var(--space-5);
  font-size: 20px;
  font-weight: 700;
  font-family:
    'Inter',
    -apple-system,
    BlinkMacSystemFont,
    'Segoe UI',
    sans-serif;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 10px;
  text-transform: uppercase;
  letter-spacing: 0.8px;
}

.soap-subsection {
  padding: var(--space-2) var(--space-5) var(--space-5) var(--space-5);
  border-bottom: 1px solid var(--border);
}
.soap-subsection:last-child {
  border-bottom: none;
}

/* Remove top padding from the first subsection to eliminate gap after header */
.soap-section .soap-subsection:first-child,
.subjective-section .soap-subsection:first-child,
.objective-section .soap-subsection:first-child,
.assessment-section .soap-subsection:first-child,
.plan-section .soap-subsection:first-child,
.billing-section .soap-subsection:first-child {
  padding-top: 0;
}

/* Also ensure no margin on first subsection title */
.section-content .subsection-title:first-child,
.subjective-section .subsection-title:first-child,
.section-anchor .subsection-title:first-child {
  margin-top: 12px; /* Small breathing room below header */
}

/* PT Exam sections */
.pt-exam-section {
  background: var(--panel);
  border-left: 4px solid var(--accent2);
  padding: var(--space-4);
  margin: var(--space-3) 0;
  border-radius: var(--radius-sm);
}
.pt-exam-section h5 {
  color: var(--accent2);
  margin: 0 0 var(--space-2);
  font-size: 14px;
  font-weight: 600;
}

/* Editable table styles extracted to tables.css */

/* Table accents extracted to tables.css */

/* ========================================
   16) DRAFTS & FACULTY DASHBOARD
   ======================================== */
.group-header {
  color: var(--muted);
  font-size: 16px;
  font-weight: 600;
  margin: var(--space-6) 0 var(--space-3);
  padding-bottom: var(--space-2);
  border-bottom: 1px solid var(--border-light);
}
.info-banner {
  background: var(--inline-card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: var(--space-4);
  margin-bottom: var(--space-5);
  color: var(--text);
}
.info-banner p {
  margin: 0;
  color: var(--text-subtle);
}

.drafts-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  margin-top: var(--space-4);
}
.draft-card {
  background: var(--inline-card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: var(--space-4);
  transition: all 0.2s ease;
}
.draft-card:hover {
  border-color: var(--accent2);
  transform: translateY(-2px);
  box-shadow: var(--shadow-1);
}
.draft-card.empty-draft {
  opacity: 0.7;
  border-style: dashed;
}
.draft-card.near-complete {
  border-color: var(--accent);
}

.draft-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--space-3);
}
.draft-title {
  margin: 0;
  font-size: 16px;
  color: var(--text);
}
.draft-encounter {
  background: var(--chip-bg);
  color: var(--muted);
  padding: var(--space-1) var(--space-2);
  border-radius: var(--radius-sm);
  font-size: 12px;
  font-weight: 600;
}
.draft-info {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--space-3);
  flex-wrap: wrap;
  gap: var(--space-2);
}
.draft-completion {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}
.completion-bar {
  width: 100px;
  height: 6px;
  background: var(--border);
  border-radius: 3px;
  overflow: hidden;
}
.completion-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 3px;
  transition: width 0.3s ease;
}
.completion-text,
.draft-modified {
  font-size: 12px;
  color: var(--muted);
}
.draft-actions {
  display: flex;
  gap: var(--space-2);
  justify-content: flex-end;
}
.draft-actions .btn {
  font-size: 12px;
  padding: var(--space-1) 10px;
}

/* ========================================
   17) BILLING & DIAGNOSIS CODES
   ======================================== */
.billing-codes-container {
  margin: var(--space-4) 0;
}
.billing-code-row {
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: var(--space-4);
  margin-bottom: var(--space-3);
  background: var(--bg-secondary);
  position: relative;
  transition: border-color 0.2s ease;
}
.billing-code-row.has-description {
  border-left: 3px solid var(--primary);
  cursor: help;
}
.billing-code-row.has-description:hover {
  border-color: var(--primary);
}
.billing-code-fields {
  display: grid;
  grid-template-columns: 3fr 100px 150px 100px;
  gap: var(--space-4);
  align-items: start;
  margin-bottom: var(--space-2);
  background-color: var(--und-green-light);
  border-radius: var(--radius-sm);
  padding: var(--space-2);
}
.billing-code-fields .form-field {
  display: block;
  margin-bottom: 0;
}
.billing-code-fields .form-label {
  margin-bottom: var(--space-1);
  font-weight: 500;
}
.billing-code-fields .form-hint {
  font-size: 11px;
  margin-top: 2px;
  color: var(--text-subtle);
  opacity: 0.8;
}
.code-description {
  display: none;
}
.billing-code-row:hover .code-description {
  display: block;
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  z-index: 10;
  font-size: 13px;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: var(--space-3);
}

/* ========================================
   18) ENHANCED GOAL LINKER MODAL
   ======================================== */
.goal-linker-modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: var(--z-modal);
  -webkit-backdrop-filter: blur(4px); /* Safari/iOS */
  backdrop-filter: blur(4px);
}
.goal-linker-content {
  background: var(--surface);
  border-radius: var(--radius-xl);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
  max-width: 600px;
  width: 90%;
  max-height: 80vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
.goal-linker-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: var(--space-5) var(--space-6);
  border-bottom: 1px solid var(--border);
  background: var(--panel);
}
.goal-linker-header h3 {
  margin: 0;
  color: var(--accent2);
  font-size: 18px;
  font-weight: 600;
}
.close-btn {
  background: none;
  border: none;
  padding: var(--space-2);
  border-radius: var(--radius-sm);
  cursor: pointer;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
}
.close-btn:hover {
  background: var(--border);
  color: var(--text);
  transform: scale(1.1);
}

.goal-selection-list {
  flex: 1;
  overflow-y: auto;
  padding: var(--space-5) var(--space-6);
  max-height: 50vh;
}
.case-details-modal {
  max-width: 560px; /* tighter width for single column */
}
.case-details-body {
  max-height: 60vh; /* allow a bit more scroll in details */
}
.case-details-grid {
  display: grid;
  grid-template-columns: 1fr; /* single column */
  row-gap: 14px;
}
.case-details-grid .case-info-row {
  display: block; /* stack label and value */
}
.case-details-grid .case-info-row .label {
  display: block;
  margin: 0 0 4px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}
.case-details-grid .case-info-row .value {
  display: block;
  color: var(--text);
  font-size: 16px;
  font-weight: 600;
  line-height: 1.4;
}
/* Summary row and module cards in Case Details */
.case-details-summary .label {
  color: var(--text-secondary);
  font-size: 12px;
}
.case-details-summary .value {
  font-size: 14px;
}
.module-card .label {
  color: var(--text-secondary);
  font-size: 12px;
}
.module-card .value {
  font-size: 14px;
}
.case-details-modal .goal-linker-header h3 {
  font-size: 20px;
  color: var(--und-green);
}
.case-details-modal .goal-linker-header {
  background: var(--surface);
}
.case-details-modal .goal-linker-header + .goal-selection-list {
  background: var(--surface);
}
.goal-section-title {
  margin: var(--space-4) 0 var(--space-2);
  color: var(--accent2);
  font-size: 14px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  border-bottom: 1px solid var(--border);
  padding-bottom: var(--space-1);
}
.goal-checkbox-label {
  display: flex;
  align-items: flex-start;
  padding: var(--space-3);
  margin: var(--space-1) 0;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all 0.2s ease;
  border: 1px solid transparent;
}
.goal-checkbox-label:hover {
  background: var(--panel);
  border-color: var(--border);
  transform: translateX(4px);
}
.goal-checkbox-label input[type='checkbox'] {
  margin-right: var(--space-3);
  margin-top: 2px;
  flex-shrink: 0;
}
.goal-text {
  line-height: 1.4;
  color: var(--text);
  font-size: 14px;
}

.goal-linker-actions {
  display: flex;
  gap: var(--space-3);
  justify-content: flex-end;
  padding: var(--space-5) var(--space-6);
  border-top: 1px solid var(--border);
  background: var(--panel);
}

/* Goal chips with enhanced styling */
.goal-chip {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  background: var(--und-green-light);
  color: var(--und-green-dark);
  padding: var(--space-1) var(--space-2);
  border-radius: 12px;
  font-size: 12px;
  font-weight: 500;
  margin: 2px var(--space-1) 2px 0;
  cursor: pointer;
  border: 1px solid var(--und-green);
  transition: all 0.2s ease;
}
.goal-chip:hover {
  background: var(--und-green);
  color: #fff;
  transform: translateY(-1px);
  box-shadow: 0 2px 8px rgba(56, 161, 105, 0.3);
}
.link-goals-btn {
  background: transparent;
  color: var(--und-green);
  border: 1px dashed var(--und-green);
  padding: var(--space-1) var(--space-3);
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 12px;
  font-weight: 500;
  transition: all 0.2s ease;
  margin-top: var(--space-1);
}
.link-goals-btn:hover {
  background: var(--und-green-light);
  border-color: var(--und-green-dark);
  color: var(--und-green-dark);
}

/* ========================================
   19) UTILITIES & HELPERS
   ======================================== */
/* Billing dropdown fixes: avoid clipping and misaligned dropdowns */
.billing-code-fields {
  overflow: visible;
}
select:focus,
.form-select:focus {
  transform: none;
}
.billing-section {
  overflow: visible;
}
.flex-between {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--space-3);
}
.badge {
  display: inline-block;
  padding: 2px var(--space-2);
  border-radius: 12px;
  border: 1px solid var(--border);
  font-size: 12px;
  color: var(--muted);
}
.text-muted {
  color: var(--muted);
  font-style: italic;
}
.hint {
  color: var(--muted);
  font-size: 12px;
  margin-top: var(--space-1);
}
.hr {
  border-top: 1px solid var(--border);
  margin: var(--space-3) 0;
}
.small {
  font-size: 12px;
  color: var(--muted);
}
.inline-card {
  background: var(--inline-card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 10px;
  margin: var(--space-1) 0;
}

/* ========================================
   20) ENHANCED RESPONSIVE DESIGN
   ======================================== */

/* Tablet and desktop adjustments */
@media (max-width: 900px) {
  .hamburger-btn {
    display: inline-flex;
    order: 3;
    margin-left: auto;
  }
  .brand-row {
    order: 1;
  }
  #primaryNav {
    order: 2;
  }
  #primaryNav.topnav a,
  #primaryNav .feedback-btn,
  #primaryNav .theme-toggle,
  .brand-row .feedback-btn {
    display: none !important;
  }
  .und-logo {
    height: 28px;
  }
  .brand-label {
    font-size: 14px;
  }
  .brand-label-suffix {
    display: none;
  }
}

/* Enhanced touch targets handled in buttons.css */

/* Mobile-first responsive design */
@media (max-width: 768px) {
  /* Show header hamburger on mobile */
  .hamburger-btn {
    display: inline-flex;
  }
  /* Scroll lock handled by .mobile-drawer-open in mobile-patch-v2.css */

  /* Slightly smaller footer token for phones */
  :root {
    --edu-ribbon-h: 24px;
  }
  /* Compact topbar and scalable tokens on mobile */
  :root {
    --topbar-h: 60px; /* reduce header height to free vertical space */
  }

  header.topbar {
    padding: 0 12px;
    gap: 8px;
  }

  /* Logo scales down slightly */
  .und-logo {
    height: 24px;
  }

  /* Larger font size for mobile readability */
  html {
    font-size: 16px;
  }

  body {
    line-height: 1.7; /* Better mobile readability */
  }

  /* Mobile drawer behavior handled by mobile-patch-v2.css */

  /* Mobile typography improvements */
  h1 {
    font-size: 1.75rem;
  } /* 28px */
  h2 {
    font-size: 1.5rem;
  } /* 24px */
  h3 {
    font-size: 1.25rem;
  } /* 20px */
  h4 {
    font-size: 1.125rem;
  } /* 18px */

  /* Mobile layout adjustments */
  #app {
    padding: var(--space-3);
  }

  /* Enhanced mobile forms */
  .form-field {
    flex-direction: column;
    align-items: stretch;
    gap: var(--space-2);
  }
  .form-label {
    width: auto;
    font-size: 1rem; /* Larger labels on mobile */
  }
  .form-row {
    grid-template-columns: 1fr;
    gap: var(--space-2);
  }

  /* Mobile input improvements */
  input,
  textarea,
  select {
    font-size: 1rem;
    padding: 14px var(--space-3);
  }

  /* Mobile button enhancements handled in buttons.css */

  /* Mobile navigation improvements: horizontal scroll of primary nav */
  .topnav {
    flex-wrap: nowrap;
    gap: var(--space-1);
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none; /* Firefox */
    max-width: 60vw; /* prevent pushing brand off-screen */
  }
  .topnav::-webkit-scrollbar {
    display: none;
  }
  .topnav a {
    min-height: 40px; /* comfortable but compact */
    padding: 10px 12px;
    font-size: 0.95rem;
    white-space: nowrap;
  }

  .tabs {
    flex-wrap: wrap;
    gap: var(--space-1);
  }

  .tab {
    min-height: 48px;
    padding: var(--space-3) var(--space-4);
  }

  /* Mobile draft cards */
  .draft-header {
    flex-direction: column;
    align-items: flex-start;
    gap: var(--space-2);
  }
  .draft-info {
    flex-direction: column;
    align-items: flex-start;
  }
  .draft-actions {
    width: 100%;
    justify-content: space-between;
    gap: var(--space-2);
  }

  /* Mobile SOAP sections */
  .soap-section h3,
  .subjective-section h3,
  .objective-section h3,
  .assessment-section h3,
  .plan-section h3,
  .billing-section h3 {
    padding: var(--space-3) var(--space-4);
    font-size: 1.125rem; /* 18px */
    font-family: 'Inter', sans-serif;
    color: var(--text);
  }
  .soap-subsection {
    padding: var(--space-2) var(--space-4) var(--space-4) var(--space-4);
  }

  /* Mobile billing adjustments */
  .billing-code-fields {
    grid-template-columns: 1fr;
    gap: var(--space-2);
  }

  /* Mobile table improvements moved to tables.css */

  /* Mobile modal improvements */
  .goal-linker-content {
    width: 95%;
    max-height: 90vh;
    margin: var(--space-2);
  }
  /* On mobile, layout width managed by drawer offsets */
  .main-content-with-sidebar {
    margin-left: 0;
    width: 100%;
  }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
  :root {
    --border: #000;
    --text: #000;
    --bg: #fff;
  }

  html[data-theme='dark'] {
    --border: #fff;
    --text: #fff;
    --bg: #000;
  }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }

  .btn:hover {
    transform: none;
  }

  .tab:hover,
  .topnav a:hover {
    transform: none;
  }
}

/* ========================================
   22) COMPONENT-SPECIFIC CLASSES (from JS)
   ======================================== */

/* Case metadata panel */
.case-metadata-panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: var(--space-5);
  margin-bottom: var(--space-5);
  width: 100%;
  max-width: none;
  box-sizing: border-box;
  box-shadow: var(--shadow-1);
}

.case-metadata-title {
  margin: 0 0 var(--space-4) 0;
  color: var(--text);
  font-size: 1.125rem; /* 18px */
  font-weight: 600;
  line-height: 1.3;
}

.case-metadata-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-5);
  margin-bottom: var(--space-4);
}

/* Unified form styling that extends the existing form system */
.form-label-standard {
  display: block;
  margin-bottom: var(--space-1);
  font-weight: 600;
  color: var(--text);
  font-size: 0.875rem;
  line-height: 1.4;
}

.form-input-standard {
  padding: var(--space-2) var(--space-3);
  border: 1px solid var(--input-border);
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  width: 100%;
  background: var(--input-bg);
  color: var(--input-text);
  font-family: inherit;
  line-height: 1.4;
  min-height: 44px; /* Touch target for accessibility */
  transition:
    border-color 0.2s ease,
    box-shadow 0.2s ease;
}

.form-input-standard:focus {
  border-color: var(--und-green);
  outline: none;
  box-shadow: 0 0 0 2px var(--und-green-light);
}
.form-input-standard:focus-visible {
  outline: 2px solid var(--und-green);
  outline-offset: 2px;
}

.form-input-standard:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  background: var(--bg-secondary);
}

/* Navigation text styles extracted to sidebar.css */

/* Instructor dashboard styles */
.instructor-dashboard {
  padding: var(--space-6);
  max-width: 1200px;
  margin: 0 auto;
}

.instructor-title {
  margin: 0 0 var(--space-6) 0;
  color: var(--text);
  font-size: 1.5rem;
  font-weight: 600;
  line-height: 1.3;
}

.instructor-form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-5);
  margin-bottom: var(--space-4);
}

.instructor-form-field {
  margin-bottom: var(--space-4);
}

.instructor-form-label {
  display: block;
  margin-bottom: var(--space-2);
  font-weight: 500;
  color: var(--text);
  font-size: 0.875rem;
  line-height: 1.4;
}

.instructor-form-input {
  padding: var(--space-3);
  border: 1px solid var(--input-border);
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  width: 100%;
  background: var(--input-bg);
  color: var(--text);
  font-family: inherit;
  line-height: 1.4;
  min-height: 44px; /* Touch target for accessibility */
  transition:
    border-color 0.2s ease,
    box-shadow 0.2s ease;
}

.instructor-form-input:focus {
  border-color: var(--und-green);
  outline: none;
  box-shadow: 0 0 0 2px var(--und-green-light);
}
.instructor-form-input:focus-visible {
  outline: 2px solid var(--und-green);
  outline-offset: 2px;
}

.instructor-form-input:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  background: var(--bg-secondary);
}

/* Error states for form components */
.form-input-standard.error,
.instructor-form-input.error {
  border-color: var(--danger);
  box-shadow: 0 0 0 2px var(--danger-light);
}

.form-label-standard.error,
.instructor-form-label.error {
  color: var(--danger);
}

/* Success states for form components */
.form-input-standard.success,
.instructor-form-input.success {
  border-color: var(--success);
  box-shadow: 0 0 0 2px var(--und-green-light);
}

/* Field validation messages */
.field-error-message {
  color: var(--danger);
  font-size: 0.75rem;
  margin-top: var(--space-1);
  display: flex;
  align-items: center;
  gap: var(--space-1);
}

.field-success-message {
  color: var(--success);
  font-size: 0.75rem;
  margin-top: var(--space-1);
  display: flex;
  align-items: center;
  gap: var(--space-1);
}

/* Required field indicator */
.form-label-standard.required::after,
.instructor-form-label.required::after {
  content: ' *';
  color: var(--danger);
  font-weight: 600;
}

/* Loading states */
.form-input-standard.loading,
.instructor-form-input.loading {
  background-image: linear-gradient(90deg, transparent, var(--primary-light), transparent);
  background-size: 200px 100%;
  background-repeat: no-repeat;
  animation: loading 1.5s infinite;
}

@keyframes loading {
  0% {
    background-position: -200px 0;
  }
  100% {
    background-position: 200px 0;
  }
}

/* Focus within containers for keyboard navigation */
.case-metadata-panel:focus-within,
.instructor-dashboard:focus-within {
  box-shadow:
    var(--shadow-1),
    0 0 0 2px var(--und-green-light);
}

/* Ensure all interactive elements have proper contrast */
.nav-text-primary:hover,
.nav-text-secondary:hover,
.nav-text-meta:hover {
  color: var(--accent2);
}

/* Screen reader only content */
.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;
}

/* Modal (feedback) */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10000;
}
.modal-panel {
  background: var(--bg);
  color: var(--text);
  padding: 24px;
  border-radius: 12px;
  width: 92%;
  max-width: 560px;
  box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1);
}
.modal-title {
  margin: 0 0 8px 0;
}
.modal-subtitle {
  margin: 0 0 12px 0;
  color: var(--text-secondary);
}
.modal-iframe-wrap {
  width: 100%;
  height: 560px;
}
.modal-iframe {
  width: 100%;
  height: 100%;
  border: 1px solid var(--input-border);
  border-radius: 12px;
  background: var(--bg);
}
.modal-label {
  display: block;
  margin-bottom: 6px;
}
.modal-textarea {
  width: 100%;
  box-sizing: border-box;
  border: 1px solid var(--input-border);
  border-radius: 8px;
  padding: 10px;
  font-family: inherit;
  font-size: 14px;
  resize: vertical;
}
.modal-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  margin-top: 12px;
}

/* Mobile responsive adjustments */
@media (max-width: 768px) {
  .case-metadata-grid,
  .instructor-form-grid {
    grid-template-columns: 1fr;
    gap: var(--space-3);
  }

  .instructor-dashboard {
    padding: var(--space-4);
  }

  .case-metadata-panel {
    padding: var(--space-4);
    margin-bottom: var(--space-4);
  }

  /* Ensure touch targets remain accessible on mobile */
  .form-input-standard,
  .instructor-form-input {
    min-height: 48px; /* Larger touch target on mobile */
    font-size: 1rem; /* Prevent zoom on iOS */
  }

  .nav-text-primary,
  .nav-text-secondary,
  .nav-text-meta {
    font-size: 0.875rem; /* Larger text on mobile */
  }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
  :root {
    --border: #000000;
    --text: #000000;
    --text-secondary: #333333;
    --accent2: #007a35; /* UND green dark for HC */
    --success: #008000;
    --danger: #ff0000;
  }

  :root {
    --border: #000000;
    --text: #000000;
    --bg: var(--neutral-50);
    --panel: var(--neutral-100);
  }

  .form-input-standard:focus,
  .instructor-form-input:focus {
    border-width: 3px;
    box-shadow: 0 0 0 3px var(--und-green);
  }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
  .form-input-standard,
  .instructor-form-input,
  .btn {
    transition: none;
  }
}

/* Print styles for forms */
@media print {
  .case-metadata-panel,
  .instructor-dashboard {
    border: 1px solid #000000;
    background: var(--neutral-50);
    color: #000000;
    box-shadow: none;
    break-inside: avoid;
  }

  .case-metadata-grid,
  .instructor-form-grid {
    grid-template-columns: 1fr;
    gap: 1rem;
  }

  .form-input-standard,
  .instructor-form-input {
    border: 1px solid #000000;
    background: var(--neutral-50);
    color: #000000;
  }
}

/* ========================================
   Persistent App Header (always visible)
   ======================================== */
header.topbar {
  position: fixed; /* pinned to viewport */
  top: 0;
  left: 0;
  right: 0;
  z-index: var(--z-topbar); /* above sidebar and feature headers */
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  box-sizing: border-box; /* include padding/border in height */
  height: var(--topbar-h);
  padding: 0 16px; /* no vertical padding so total height == --topbar-h */
  /* Subtle left→right gradient: true black to dark gray (theme-agnostic chrome) */
  background: linear-gradient(90deg, var(--und-black) 0%, var(--chrome-topbar-right) 100%);
  border-bottom: 1px solid var(--border);
  -webkit-backdrop-filter: blur(6px); /* Safari/iOS */
  backdrop-filter: blur(6px);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.06);
}

/* Header hamburger */
.hamburger-btn {
  display: none; /* hidden on desktop; shown on mobile via media query */
  background: transparent;
  border: 0;
  color: #fff;
  height: var(--topbar-h);
  width: 48px;
  align-items: center;
  justify-content: center;
}
.hamburger-btn:focus-visible {
  outline: 2px solid #fff;
  outline-offset: 2px;
}

/* Breadcrumbs (below header) */
.breadcrumbs {
  position: sticky;
  top: var(--topbar-h);
  z-index: var(--z-topbar);
  background: var(--editor-bg);
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  border-bottom: 1px solid var(--border);
}
.breadcrumbs.is-empty {
  display: none;
}
.breadcrumbs a {
  color: var(--text);
  text-decoration: none;
  font-weight: 600;
}
.breadcrumbs a:hover {
  text-decoration: underline;
}
.crumb-sep {
  opacity: 0.5;
}

/* TEMP: hide breadcrumbs to prevent overlap with sidebar */
#breadcrumbs,
.breadcrumbs {
  display: none !important;
}

/* Brand + Feedback inline row */
.brand-row {
  display: inline-flex;
  align-items: center;
  gap: 12px;
}
.brand-row .feedback-btn {
  margin-left: 8px;
}
@media (max-width: 640px) {
  .brand-row {
    gap: 8px;
  }
}

header.topbar .brand {
  font-weight: 700;
  color: #ffffff; /* ensure legibility on dark header */
}

header.topbar .topnav a {
  margin-right: 4px;
  color: rgba(255, 255, 255, 0.9);
  text-decoration: none;
  font-weight: 600;
  border-bottom: 2px solid transparent;
}
/* Ensure the topnav sits on the right and aligns its items (links + toggle) */
header.topbar .topnav {
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  flex-wrap: nowrap;
}
header.topbar .topnav a:hover {
  color: #ffffff;
  background: rgba(255, 255, 255, 0.08);
}
header.topbar .topnav a:focus-visible {
  outline-color: var(--und-green);
}
header.topbar .topnav a.active {
  color: #ffffff;
  border-bottom-color: var(--und-green);
}

/* Ensure buttons/links in header remain legible */
header.topbar .btn,
header.topbar button,
header.topbar a.button {
  color: #ffffff;
}

/* UND logo on right side */
.und-logo-link {
  display: inline-flex;
  align-items: center;
  height: var(--topbar-h);
}
.und-logo-link,
.und-logo-link:hover,
.und-logo-link:focus {
  text-decoration: none;
}
.und-logo {
  height: 32px;
  width: auto;
  display: block;
  filter: none;
}
@media (max-width: 480px) {
  .und-logo {
    height: 26px;
  }
}

/* Brand label to the right of UND logo */
.brand-label {
  /* Restore original brand styling, but smaller font size */
  font-family:
    'Oswald', 'Trade Gothic', 'TradeGothic LT', 'Trade Gothic Next', 'TradeGothicLTStd',
    'TradeGothic LT Std', 'News Gothic', 'Franklin Gothic Medium', 'Arial Narrow', Arial, sans-serif;
  color: #ffffff;
  font-weight: 700;
  letter-spacing: 0.06em;
  margin-left: 10px;
  white-space: nowrap;
  font-size: 18px; /* smaller than previous 24px */
  text-decoration: none;
}
.brand-label .brand-label-suffix {
  margin-left: 4px;
  font-weight: 700;
  color: var(--und-orange); /* flame orange for visibility */
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.35); /* pop against dark header */
  white-space: nowrap;
}
/* Reinstate subtle vertical divider before label */
.brand-label::before {
  content: '';
  display: inline-block;
  width: 1px;
  height: 22px;
  background: rgba(255, 255, 255, 0.6);
  margin-right: 10px;
  vertical-align: middle;
  border-radius: 1px;
}
@media (max-width: 640px) {
  .brand-label {
    display: none;
  }
}

/* Sticky top bar is fully defined earlier; duplicate one-liner removed */

/* Sidebar offsets are defined in the primary sidebar block; redundant override removed */

/* Skip link accessibility (defined near top of file) */

/* Old theme-toggle button styles removed in favor of switch variant */

/* Print styles moved to css/print.css */
