:root {
  --radius-xs: 4px;
  --radius-sm: 6px;
  --radius-md: 8px;
  --radius-lg: 10px;
  --radius-pill: 999px;
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  --space-8: 32px;
  --space-10: 40px;
  --space-12: 48px;
  --space-16: 64px;
  --space-20: 80px;
  --space-24: 96px;
  --container-sm: 760px;
  --container-md: 1120px;
  --container-lg: 1360px;
  --container-xl: 1800px;
  --font-sans: Inter, "Segoe UI", Arial, sans-serif;
  --font-display: "Cormorant Garamond", Georgia, serif;
  --font-editorial: "Schibsted Grotesk", Inter, "Segoe UI", Arial, sans-serif;
  --text-xs: 12px;
  --text-sm: 13px;
  --text-md: 14px;
  --text-base: 16px;
  --text-lg: 18px;
  --text-xl: 22px;
  --text-2xl: 28px;
  --text-3xl: 40px;
  --text-4xl: 56px;
  --text-5xl: 72px;
  --leading-tight: 1.1;
  --leading-heading: 1.2;
  --leading-body: 1.55;
  --weight-regular: 400;
  --weight-medium: 550;
  --weight-semibold: 650;
  --weight-bold: 750;
  --control-sm: 34px;
  --control-md: 40px;
  --control-lg: 48px;
  --motion-fast: 120ms;
  --motion-base: 180ms;
  --motion-slow: 320ms;
  --ease-standard: cubic-bezier(0.2, 0, 0, 1);
  --ease-emphasized: cubic-bezier(0.16, 1, 0.3, 1);
}

:root,
[data-theme="light"] {
  --ui-page: #F3F5F7;
  --ui-surface: #FFFFFF;
  --ui-surface-muted: #F8FAFB;
  --ui-surface-hover: #F4F8F7;
  --ui-text: #172126;
  --ui-text-secondary: #4D5A61;
  --ui-text-muted: #65727A;
  --ui-border: #DFE4E8;
  --ui-border-strong: #CBD3D9;
  --ui-action: #176B5B;
  --ui-action-hover: #115548;
  --ui-action-soft: #E6F3EF;
  --ui-on-action: #FFFFFF;
  --ui-success: #176B5B;
  --ui-success-soft: #E6F3EF;
  --ui-info: #275D9F;
  --ui-info-soft: #EAF1FA;
  --ui-warning: #9A6113;
  --ui-warning-soft: #FFF4DC;
  --ui-danger: #B83A46;
  --ui-danger-hover: #972C37;
  --ui-danger-soft: #FBEAEC;
  --ui-focus: rgb(23 107 91 / 14%);
  --ui-shadow: rgb(20 33 40 / 8%);
  --shadow-sm: 0 1px 2px rgb(20 33 40 / 6%);
  --shadow-md: 0 12px 30px var(--ui-shadow);
}

* { box-sizing: border-box; }
html { background: var(--ui-page); color: var(--ui-text); font-family: var(--font-sans); }
body { background: var(--ui-page); color: var(--ui-text); font-size: var(--text-base); line-height: var(--leading-body); margin: 0; min-width: 320px; }
button, input { font: inherit; }
a { color: inherit; }
a:focus-visible, button:focus-visible, input:focus-visible { box-shadow: 0 0 0 3px var(--ui-focus); outline: 0; }
.login-page { display: grid; min-height: 100vh; padding: var(--space-6); place-items: center; }
.login-card { background: var(--ui-surface); border: 1px solid var(--ui-border); border-radius: var(--radius-md); box-shadow: var(--shadow-sm); padding: var(--space-10); width: min(100%, 460px); }
.mark, .logo span { background: var(--ui-surface-muted); border: 1px solid var(--ui-border); border-radius: var(--radius-sm); color: var(--ui-text); display: grid; font-weight: var(--weight-bold); place-items: center; }
.mark { height: var(--control-lg); margin-bottom: var(--space-8); width: var(--control-lg); }
.eyebrow { color: var(--ui-text-muted); font-size: var(--text-xs); font-weight: var(--weight-semibold); letter-spacing: .06em; line-height: var(--leading-heading); margin: 0 0 var(--space-2); text-transform: uppercase; }
h1 { color: var(--ui-text); font-size: clamp(var(--text-3xl), 5vw, var(--text-4xl)); font-weight: var(--weight-semibold); letter-spacing: -0.02em; line-height: var(--leading-tight); margin: 0; }
h2 { color: var(--ui-text); font-size: var(--text-xl); font-weight: var(--weight-semibold); letter-spacing: -0.01em; line-height: var(--leading-heading); margin: 0; }
.lead, .hero > p:not(.eyebrow) { color: var(--ui-text-secondary); line-height: var(--leading-body); margin: var(--space-4) 0 0; }
.login-form { display: grid; gap: var(--space-4); margin-top: var(--space-8); }
label { color: var(--ui-text-secondary); display: grid; font-size: var(--text-sm); font-weight: var(--weight-semibold); gap: var(--space-2); line-height: var(--leading-heading); }
input { background: var(--ui-surface); border: 1px solid var(--ui-border-strong); border-radius: 7px; color: var(--ui-text); min-height: var(--control-md); padding: 0 var(--space-3); }
input::placeholder { color: var(--ui-text-muted); }
input:focus { border-color: var(--ui-action); }
button { align-items: center; background: var(--ui-action); border: 1px solid transparent; border-radius: 7px; color: var(--ui-on-action); cursor: pointer; display: inline-flex; font-weight: var(--weight-semibold); gap: var(--space-2); justify-content: center; min-height: var(--control-md); padding: 0 14px; text-decoration: none; transition: background-color var(--motion-base) var(--ease-standard), border-color var(--motion-base) var(--ease-standard), box-shadow var(--motion-base) var(--ease-standard), transform var(--motion-fast) var(--ease-standard); }
button:hover { background: var(--ui-action-hover); }
button:active { transform: translateY(1px); }
.form-error { background: var(--ui-danger-soft); border: 1px solid var(--ui-danger-soft); border-left: var(--space-1) solid var(--ui-danger); border-radius: var(--radius-sm); color: var(--ui-danger); font-size: var(--text-sm); line-height: var(--leading-body); margin: var(--space-5) 0 0; padding: var(--space-3); }
.header { align-items: center; background: var(--ui-surface); border-bottom: 1px solid var(--ui-border); box-shadow: var(--shadow-sm); display: flex; justify-content: space-between; min-height: var(--space-16); padding: 0 max(var(--space-6), calc((100vw - var(--container-md)) / 2)); }
.logo { align-items: center; color: var(--ui-text); display: inline-flex; font-size: var(--text-base); font-weight: var(--weight-semibold); gap: var(--space-2); text-decoration: none; }
.logo span { height: var(--text-2xl); width: var(--text-2xl); }
.logout { color: var(--ui-text-secondary); font-size: var(--text-md); font-weight: var(--weight-semibold); text-decoration: none; }
.logout:hover, .logout:focus-visible { color: var(--ui-action); text-decoration: underline; }
.portal { margin: 0 auto; max-width: var(--container-md); padding: var(--space-20) var(--space-6); }
.hero { max-width: var(--container-sm); padding: 0 0 var(--space-12); }
.hero h1 { font-size: clamp(var(--text-3xl), 5vw, var(--text-4xl)); }
.section-grid { display: grid; gap: var(--space-5); grid-template-columns: repeat(3, minmax(0, 1fr)); }
.section-card { background: var(--ui-surface); border: 1px solid var(--ui-border); border-radius: var(--radius-md); box-shadow: var(--shadow-sm); color: var(--ui-text); display: grid; min-height: 190px; padding: var(--space-6); text-decoration: none; transition: background-color var(--motion-base) var(--ease-standard), border-color var(--motion-base) var(--ease-standard), transform var(--motion-fast) var(--ease-standard); }
.section-card:hover { background: var(--ui-surface-hover); border-color: var(--ui-border-strong); }
.section-card:active { transform: translateY(1px); }
.section-card span { align-self: start; background: var(--ui-surface-muted); border: 1px solid var(--ui-border); border-radius: var(--radius-pill); color: var(--ui-text-secondary); font-size: var(--text-xs); font-weight: var(--weight-semibold); justify-self: start; line-height: var(--leading-heading); padding: var(--space-1) var(--space-2); }
.section-card h2 { align-self: end; font-size: var(--text-xl); margin-top: var(--space-10); }
.section-card p { color: var(--ui-text-secondary); font-size: var(--text-md); line-height: var(--leading-body); margin: var(--space-3) 0 0; }
.backline { margin: calc(var(--space-6) * -1) 0 var(--space-6); }
.backline a { color: var(--ui-action); font-size: var(--text-sm); font-weight: var(--weight-semibold); text-decoration: none; }
.backline a:hover { text-decoration: underline; }
.section-head { background: var(--ui-surface); border: 1px solid var(--ui-border); border-radius: var(--radius-md); box-shadow: var(--shadow-sm); margin-bottom: var(--space-6); padding: var(--space-6); }
.section-head p:not(.eyebrow) { color: var(--ui-text-secondary); margin: var(--space-3) 0 0; max-width: var(--container-sm); }
.courses { display: grid; gap: var(--space-5); }
.viewer { background: var(--ui-surface); border: 1px solid var(--ui-border); border-radius: var(--radius-md); box-shadow: var(--shadow-sm); margin: 0 0 var(--space-6); overflow: hidden; padding: var(--space-6); }
.viewer-heading { align-items: flex-start; border-bottom: 1px solid var(--ui-border); display: flex; gap: var(--space-4); justify-content: space-between; margin: calc(var(--space-6) * -1) calc(var(--space-6) * -1) var(--space-6); min-height: var(--space-16); padding: var(--space-5) var(--space-6); }
.viewer h2 { font-size: var(--text-xl); }
.viewer video, .viewer iframe { background: var(--ui-text); border: 0; border-radius: var(--radius-md); display: block; height: min(67vh, 720px); width: 100%; }
.viewer video { height: auto; max-height: 620px; }
.viewer-download { align-items: center; background: var(--ui-surface); border: 1px solid var(--ui-border-strong); border-radius: 7px; color: var(--ui-text); display: inline-flex; font-size: var(--text-sm); font-weight: var(--weight-semibold); justify-content: center; min-height: var(--control-sm); padding: 0 11px; text-decoration: none; white-space: nowrap; }
.viewer-download:hover { background: var(--ui-surface-muted); }
.document-viewer { background: var(--ui-surface-muted); border: 1px solid var(--ui-border); border-radius: var(--radius-md); color: var(--ui-text-secondary); font-family: var(--font-display); font-size: var(--text-base); line-height: var(--leading-body); max-height: min(67vh, 720px); overflow: auto; padding: var(--space-8); }
.document-viewer p { color: var(--ui-text-secondary); margin: 0 0 var(--space-4); }
.document-viewer img { border-radius: var(--radius-md); display: block; height: auto; margin: var(--space-6) auto; max-width: 100%; }
.course, .empty { background: var(--ui-surface); border: 1px solid var(--ui-border); border-radius: var(--radius-md); box-shadow: var(--shadow-sm); overflow: hidden; }
.course-heading { align-items: center; border-bottom: 1px solid var(--ui-border); display: flex; gap: var(--space-4); justify-content: space-between; min-height: var(--space-16); padding: var(--space-5) var(--space-6); }
.course-heading > span { background: var(--ui-surface-muted); border: 1px solid var(--ui-border); border-radius: var(--radius-pill); color: var(--ui-text-secondary); font-size: var(--text-xs); font-weight: var(--weight-semibold); line-height: var(--leading-heading); padding: var(--space-1) var(--space-2); white-space: nowrap; }
.file-list { display: grid; }
.file { align-items: center; color: var(--ui-text); display: grid; gap: var(--space-3); grid-template-columns: var(--control-lg) minmax(0, 1fr) auto; min-height: var(--control-lg); padding: var(--space-3) var(--space-6); text-decoration: none; transition: background-color var(--motion-base) var(--ease-standard), border-color var(--motion-base) var(--ease-standard); }
.file:hover { background: var(--ui-surface-hover); }
.file + .file { border-top: 1px solid var(--ui-border); }
.file-type { background: var(--ui-surface-muted); border: 1px solid var(--ui-border); border-radius: var(--radius-sm); color: var(--ui-text-secondary); font-size: var(--text-xs); font-weight: var(--weight-bold); line-height: var(--leading-heading); padding: var(--space-2) var(--space-1); text-align: center; }
.file-name { color: var(--ui-text); font-size: var(--text-md); font-weight: var(--weight-semibold); line-height: var(--leading-heading); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-name small { color: var(--ui-text-muted); display: block; font-size: var(--text-xs); font-weight: var(--weight-regular); line-height: var(--leading-heading); margin-top: var(--space-1); overflow: hidden; text-overflow: ellipsis; }
.file-size { color: var(--ui-text-muted); font-size: var(--text-xs); white-space: nowrap; }
.empty { padding: var(--space-8); }
code { color: var(--ui-action); }

@media (max-width: 920px) { .section-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

@media (max-width: 620px) {
  .login-page { padding: var(--space-4); }
  .login-card { padding: var(--space-8) var(--space-6); }
  .portal { padding: var(--space-8) var(--space-4); }
  .header { min-height: 56px; padding: 0 var(--space-4); }
  .hero { padding-bottom: var(--space-8); }
  .course-heading, .file { padding-left: var(--space-4); padding-right: var(--space-4); }
  .file { grid-template-columns: var(--control-md) minmax(0, 1fr); }
  .file-size { display: none; }
  .viewer { padding: var(--space-4); }
  .viewer-heading { flex-direction: column; margin: calc(var(--space-4) * -1) calc(var(--space-4) * -1) var(--space-4); padding: var(--space-4); }
  .viewer iframe { height: 62vh; }
  .document-viewer { padding: var(--space-5); }
  .section-grid { grid-template-columns: 1fr; }
  .section-card { min-height: 160px; }
}

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