/* ------------------------------------------------------------------
   Theme tokens
   ------------------------------------------------------------------ */
:root {
  --bg: #ffffff;
  --side: #f5f6f8;
  --text: #1b1f24;
  --text-2: #3a4049;
  --muted: #6b7280;
  --line: #e3e5e9;
  --accent: #1d4e89;
  --accent-soft: #eaf1f9;
  --warn: #a14d00;
  --warn-soft: #fdf3e7;
  --side-w: 290px;
  --content-w: 1280px; /* caps line length only on very wide screens */
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #121417;
    --side: #181b1f;
    --text: #e8eaed;
    --text-2: #c4c8ce;
    --muted: #8b919a;
    --line: #2a2e34;
    --accent: #7cb2f0;
    --accent-soft: #1a2635;
    --warn: #f0a24a;
    --warn-soft: #2b2216;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #121417;
  --side: #181b1f;
  --text: #e8eaed;
  --text-2: #c4c8ce;
  --muted: #8b919a;
  --line: #2a2e34;
  --accent: #7cb2f0;
  --accent-soft: #1a2635;
  --warn: #f0a24a;
  --warn-soft: #2b2216;
  color-scheme: dark;
}

/* ------------------------------------------------------------------
   Base
   ------------------------------------------------------------------ */
*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: 70px; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text-2);
  font: 400 17.5px/1.7 "Source Sans 3", system-ui, -apple-system, sans-serif;
  -webkit-font-smoothing: antialiased;
}
h1, h2 { font-family: "Source Serif 4", Georgia, serif; font-weight: 600; color: var(--text); line-height: 1.25; letter-spacing: -.01em; }
h1 { font-size: 2.1rem; margin: 0 0 .5rem; }
h2 { font-size: 1.4rem; margin: 3rem 0 1rem; padding-bottom: .4rem; border-bottom: 1px solid var(--line); }
h2 a { color: inherit; }
h2 a:hover { color: var(--accent); text-decoration: none; }
h3 { font-size: 1.05rem; font-weight: 600; color: var(--text); margin: 1.4rem 0 .5rem; }
a { color: var(--accent); text-decoration: none; text-underline-offset: 3px; }
a:hover { text-decoration: underline; }
strong, b { font-weight: 600; color: var(--text); }
img { max-width: 100%; height: auto; }
code { font: .84em "JetBrains Mono", ui-monospace, monospace; background: var(--side); border: 1px solid var(--line); border-radius: 4px; padding: .1em .35em; }
pre { background: var(--side); border: 1px solid var(--line); border-radius: 6px; padding: 1rem 1.2rem; overflow-x: auto; }
pre code { background: none; border: 0; padding: 0; }
.muted { color: var(--muted); }

.page-header { margin-bottom: 1.8rem; }
.lead { color: var(--muted); font-size: 1.08rem; margin: 0; }

/* ------------------------------------------------------------------
   Layout: fixed sidebar + content
   ------------------------------------------------------------------ */
.layout { display: grid; grid-template-columns: var(--side-w) 1fr; min-height: 100vh; }
.sidebar { background: var(--side); border-right: 1px solid var(--line); }
.sidebar-inner { position: sticky; top: 0; max-height: 100vh; overflow-y: auto; padding: 3rem 2rem 2rem; }
.content { min-width: 0; display: flex; flex-direction: column; }
.main { flex: 1; width: 100%; max-width: var(--content-w); margin: 0 auto; padding: 3.5rem clamp(2rem, 5vw, 5rem) 4rem; }
.site-footer { width: 100%; max-width: var(--content-w); margin: 0 auto; padding: 1.5rem clamp(2rem, 5vw, 5rem) 2rem; font-size: .85rem; color: var(--muted); }

/* identity */
.identity { display: flex; flex-direction: column; gap: 1.1rem; }
.avatar { display: block; width: 150px; height: 150px; object-fit: cover; object-position: 50% 30%; border-radius: 50%; }
.name { display: block; font-family: "Source Serif 4", Georgia, serif; font-weight: 600; font-size: 1.45rem; line-height: 1.2; color: var(--text); }
.name:hover { text-decoration: none; color: var(--accent); }
.role { margin: .4rem 0 0; font-size: .92rem; line-height: 1.5; color: var(--muted); }
.nav-toggle { display: none; }

/* navigation */
.side-nav ul { list-style: none; margin: 2rem 0 0; padding: 0; border-top: 1px solid var(--line); }
.side-nav li { border-bottom: 1px solid var(--line); }
.side-nav a { display: block; padding: .6rem 0 .6rem .9rem; color: var(--text-2); font-weight: 600; border-left: 3px solid transparent; margin-left: -.9rem; }
.side-nav a:hover { color: var(--accent); text-decoration: none; }
.side-nav a.active { color: var(--accent); border-left-color: var(--accent); }

/* contact */
.contact { list-style: none; margin: 1.8rem 0 0; padding: 0; font-size: .92rem; }
.contact li { display: flex; gap: .6rem; align-items: baseline; padding: .15rem 0; overflow-wrap: anywhere; }
.contact i { width: 1rem; color: var(--muted); }
.socials { display: flex; gap: 1rem; margin-top: 1rem; font-size: 1.2rem; }
.socials a { color: var(--muted); }
.socials a:hover { color: var(--accent); text-decoration: none; }
.theme-toggle {
  display: inline-flex; gap: .5rem; align-items: center; margin-top: 1.8rem; padding: 0;
  background: none; border: 0; color: var(--muted); font: inherit; font-size: .85rem; cursor: pointer;
}
.theme-toggle:hover { color: var(--text); }
.icon-light { display: none; }
:root[data-theme="dark"] .icon-dark { display: none; }
:root[data-theme="dark"] .icon-light { display: inline; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .icon-dark { display: none; }
  :root:not([data-theme="light"]) .icon-light { display: inline; }
}

/* mobile: sidebar becomes a compact header */
@media (max-width: 860px) {
  .layout { grid-template-columns: 1fr; }
  .sidebar { border-right: 0; border-bottom: 1px solid var(--line); }
  .sidebar-inner { position: static; max-height: none; padding: 1rem 20px; }
  .identity { flex-direction: row; align-items: center; gap: .9rem; }
  .avatar { width: 52px; height: 52px; }
  .name { font-size: 1.15rem; }
  .role { display: none; }
  .nav-toggle {
    display: block; margin-left: auto; background: none; border: 1px solid var(--line); border-radius: 6px;
    color: var(--text); font-size: 1.05rem; padding: .4rem .65rem; cursor: pointer;
  }
  .sidebar-collapse { display: none; padding-bottom: .5rem; }
  .sidebar-collapse.open { display: block; }
  .side-nav ul { margin-top: 1rem; }
  .main { padding: 2rem 20px 3rem; }
  .site-footer { padding: 1.5rem 20px; }
}

/* ------------------------------------------------------------------
   Home
   ------------------------------------------------------------------ */
.topics { list-style: none; display: flex; flex-wrap: wrap; gap: .3rem .5rem; margin: .3rem 0 0; padding: 0; color: var(--muted); font-size: .95rem; }
.topics li + li::before { content: "·"; margin-right: .5rem; }

/* company (sidebar + home) */
.company-logo { flex: none; object-fit: contain; }
:root[data-theme="dark"] .company-logo { filter: invert(1); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .company-logo { filter: invert(1); } }
.company-link {
  display: flex; gap: .7rem; align-items: center; margin-top: .6rem; padding: .7rem .8rem;
  border: 1px solid var(--line); border-radius: 8px; background: var(--bg);
  font-size: .82rem; line-height: 1.35; color: var(--muted);
}
.contact + .company-link { margin-top: 1.4rem; }
.company-link strong { color: var(--text); font-weight: 600; }
.company-link:hover { border-color: var(--accent); text-decoration: none; }
.company-link .company-logo { width: 32px; height: 32px; }
.company-list { display: grid; gap: 1.8rem; }
.company-card { display: flex; gap: 1.5rem; align-items: flex-start; color: var(--text-2); }
.company-card:hover { text-decoration: none; }
.company-card .company-logo { width: 72px; height: 72px; margin-top: .2rem; }
.company-card > span { display: flex; flex-direction: column; gap: .3rem; }
.company-role { color: var(--muted); }
.company-role strong { font-size: 1.05rem; }
.company-url { color: var(--accent); font-weight: 600; font-size: .95rem; }
.company-url i { font-size: .75em; margin-left: .2rem; }
.company-card:hover .company-url { text-decoration: underline; }
@media (max-width: 520px) { .company-card { flex-direction: column; gap: .8rem; } }

/* ------------------------------------------------------------------
   Course list (home + teaching)
   ------------------------------------------------------------------ */
.course-list { list-style: none; margin: 0; padding: 0; }
.course-list li { border-bottom: 1px solid var(--line); }
.course-list li:first-child { border-top: 1px solid var(--line); }
h2 + .course-list li:first-child { border-top: 0; }
.course-row {
  position: relative; display: flex; flex-direction: column; gap: .15rem;
  padding: 1rem 2.5rem 1rem 0; color: var(--text-2);
}
.course-row:hover { text-decoration: none; }
.course-title { font-weight: 600; font-size: 1.08rem; color: var(--text); }
.course-row:hover .course-title { color: var(--accent); }
.course-meta { font-size: .92rem; color: var(--muted); }
.course-summary { font-size: .95rem; margin-top: .2rem; }
.course-arrow { position: absolute; right: .3rem; top: 50%; transform: translateY(-50%); color: var(--muted); transition: transform .15s, color .15s; }
.course-row:hover .course-arrow { color: var(--accent); transform: translate(4px, -50%); }
.lang { font-size: .7rem; font-weight: 700; letter-spacing: .05em; color: var(--muted); border: 1px solid var(--line); border-radius: 4px; padding: 0 .3rem; vertical-align: 2px; }
.course-list.compact .course-row { padding-top: .7rem; padding-bottom: .7rem; }

/* ------------------------------------------------------------------
   Publications
   ------------------------------------------------------------------ */
.pubs { list-style: none; padding: 0; margin: 0; }
.pub { display: grid; grid-template-columns: 3.2rem 1fr; gap: 1rem; padding: .9rem 0; border-bottom: 1px solid var(--line); }
.pub:last-child { border-bottom: 0; }
.pub-year { color: var(--muted); font-weight: 600; }
.pub-title { font-weight: 600; color: var(--text); line-height: 1.45; }
.pub-title a { color: var(--text); }
.pub-title a:hover { color: var(--accent); }
.pub-authors { font-size: .93rem; margin-top: .2rem; }
.pub-authors em { font-style: normal; font-weight: 600; color: var(--text); }
.pub-journal { font-size: .88rem; color: var(--muted); font-style: italic; }
.pub-journal .muted { font-style: normal; }
.year-heading + .pubs .pub-year { display: none; }
.year-heading + .pubs .pub { grid-template-columns: 1fr; }
@media (max-width: 520px) { .pub { grid-template-columns: 1fr; gap: .1rem; } }

/* ------------------------------------------------------------------
   Course page
   ------------------------------------------------------------------ */
.back-link { display: inline-flex; align-items: center; gap: .4rem; font-size: .9rem; color: var(--muted); margin-bottom: 1.4rem; }
.back-link:hover { color: var(--accent); text-decoration: none; }
.card-top { display: flex; flex-wrap: wrap; gap: .4rem; margin-bottom: .7rem; }
.pill { font-size: .8rem; font-weight: 600; color: var(--accent); background: var(--accent-soft); border-radius: 4px; padding: .1rem .5rem; }
.pill-muted { color: var(--muted); background: var(--side); }

.facts { display: grid; grid-template-columns: max-content 1fr; margin: 0; border-top: 1px solid var(--line); }
.facts > div { display: contents; }
.facts dt, .facts dd { padding: .5rem 0; border-bottom: 1px solid var(--line); }
.facts dt { padding-right: 2.5rem; color: var(--muted); }
.facts dd { margin: 0; color: var(--text); }
@media (max-width: 520px) {
  .facts { grid-template-columns: 1fr; }
  .facts dt { border-bottom: 0; padding-bottom: 0; }
  .facts dd { padding-top: 0; }
}

.quick-links { display: flex; flex-wrap: wrap; gap: .5rem; margin: 1.3rem 0 0; }
.btn {
  display: inline-flex; align-items: center; gap: .45rem; padding: .35rem .85rem; font-size: .92rem; font-weight: 600;
  border: 1px solid var(--line); border-radius: 6px; color: var(--text);
}
.btn i { color: var(--accent); }
.btn:hover { border-color: var(--accent); color: var(--accent); text-decoration: none; }

.section-nav {
  position: sticky; top: 0; z-index: 5;
  display: flex; gap: 1.4rem; overflow-x: auto; scrollbar-width: none;
  margin: 2rem 0 0; padding: .8rem 0 0; background: var(--bg); border-bottom: 1px solid var(--line);
}
.section-nav::-webkit-scrollbar { display: none; }
.section-nav a { flex: none; color: var(--muted); padding-bottom: .6rem; font-size: .93rem; font-weight: 600; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.section-nav a:hover { color: var(--text); text-decoration: none; }
.section-nav a.current { color: var(--accent); border-bottom-color: var(--accent); }

.announcements { list-style: none; padding: 0; margin: 0; }
.announcements li { display: grid; grid-template-columns: 6.5rem 1fr; gap: 1rem; padding: .7rem 0 .7rem .9rem; border-left: 3px solid var(--line); }
.announcements li + li { margin-top: .5rem; }
.announcements li.important { border-left-color: var(--warn); background: var(--warn-soft); }
.announcements time { color: var(--muted); font-size: .9rem; font-weight: 600; }
.announcements li.important time { color: var(--warn); }
@media (max-width: 520px) { .announcements li { grid-template-columns: 1fr; gap: .1rem; } }

.table-wrap { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; font-size: .95rem; }
th, td { text-align: left; padding: .55rem .7rem; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-weight: 600; font-size: .85rem; color: var(--muted); border-bottom-width: 2px; }
th:first-child, td:first-child { padding-left: .4rem; }

.schedule .num { color: var(--muted); width: 2.2rem; font-variant-numeric: tabular-nums; }
.schedule .date { white-space: nowrap; width: 7.5rem; font-weight: 600; color: var(--text); font-variant-numeric: tabular-nums; }
.schedule .files { width: 11rem; }
.files .mat-link { white-space: nowrap; }
.schedule tr.past td { color: var(--muted); }
.schedule tr.past .date { font-weight: 400; }
.schedule tr.next td { background: var(--accent-soft); }
.next-badge { display: none; margin-left: .5rem; font-size: .7rem; text-transform: uppercase; letter-spacing: .05em; font-weight: 700; color: var(--accent); }
.schedule tr.next .next-badge { display: inline; }
.tag { display: inline-block; font-size: .72rem; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; padding: 0 .4rem; border-radius: 3px; margin-right: .35rem; vertical-align: 1px; }
.tag-test { background: var(--warn-soft); color: var(--warn); }
.tag-deadline, .tag-project { background: var(--accent-soft); color: var(--accent); }
.tag-presentation { background: var(--accent); color: var(--bg); }

.mat-link { display: inline-flex; align-items: baseline; gap: .45rem; }
.mat-link i { width: 1rem; text-align: center; }
.mat-nolink { color: var(--text-2); }
.mat-nolink i { color: var(--muted); }
.files .mat-link { display: flex; }
.files .mat-link + .mat-link { margin-top: .2rem; }
.materials { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 0 2.5rem; }
.mat-group h3 { margin-top: .3rem; }
.mat-group ul { list-style: none; padding: 0; margin: 0 0 1rem; }
.mat-group li { padding: .3rem 0; }

.updated { font-size: .85rem; margin-top: 3rem; }

@media print {
  .sidebar, .section-nav, .quick-links, .back-link { display: none; }
  .layout { display: block; }
  body { font-size: 11pt; }
}

/* ------------------------------------------------------------------
   Password-protected content
   ------------------------------------------------------------------ */
.lock-box {
  margin: 2.2rem 0 0; padding: 1.4rem 1.5rem; max-width: 36rem;
  border: 1px solid var(--line); border-left: 3px solid var(--accent); border-radius: 6px; background: var(--side);
}
.lock-box[hidden] { display: none; }
.lock-title { margin: 0; font-weight: 600; color: var(--text); }
.lock-title i { color: var(--accent); margin-right: .35rem; }
.lock-help { margin: .3rem 0 1rem; font-size: .95rem; color: var(--muted); }
.lock-row { display: flex; gap: .5rem; flex-wrap: wrap; }
.lock-row input {
  flex: 1 1 14rem; min-width: 0; padding: .45rem .7rem; font: inherit; color: var(--text);
  background: var(--bg); border: 1px solid var(--line); border-radius: 6px;
}
.lock-row input:focus { outline: 2px solid var(--accent); outline-offset: 1px; border-color: var(--accent); }
.lock-row .btn { cursor: pointer; background: var(--bg); font: inherit; font-weight: 600; }
.lock-row .btn:disabled { opacity: .6; cursor: progress; }
.lock-remember { display: inline-flex; gap: .4rem; align-items: center; margin-top: .7rem; font-size: .9rem; color: var(--muted); cursor: pointer; }
.lock-error { margin: .6rem 0 0; color: var(--warn); font-weight: 600; font-size: .92rem; }
.dev-note { margin: 2rem 0 0; padding: .5rem .8rem; font-size: .88rem; color: var(--warn); background: var(--warn-soft); border-radius: 6px; }
.dev-note i { margin-right: .3rem; }
