:root {
  color-scheme: light;
  --ink: #172033;
  --muted: #68738a;
  --faint: #919bad;
  --canvas: #f3f5f8;
  --surface: #ffffff;
  --soft: #e9edf4;
  --line: #dfe4ec;
  --blue: #2554e8;
  --cyan: #1aa9c7;
  --navy: #10172a;
  --danger: #b4233c;
  --shadow: 0 18px 48px rgba(20, 32, 57, .09);
  --radius: 24px;
  --font: 'Manrope', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --display: 'Unbounded', var(--font);
}

[data-theme="dark"] {
  color-scheme: dark;
  --ink: #f4f7fb;
  --muted: #a6b0c3;
  --faint: #737f95;
  --canvas: #0b1020;
  --surface: #151d31;
  --soft: #202a42;
  --line: #29344e;
  --blue: #7593ff;
  --cyan: #46c9dd;
  --navy: #080d19;
  --shadow: 0 22px 60px rgba(0, 0, 0, .3);
}

*, *::before, *::after { box-sizing: border-box; }
html { min-width: 280px; scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }
body { margin: 0; min-height: 100vh; overflow-x: hidden; color: var(--ink); background: var(--canvas); font-family: var(--font); line-height: 1.55; }
button, select, input, textarea { color: inherit; font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
button { border: 0; }
a { color: inherit; text-decoration: none; }
img, svg { display: block; max-width: 100%; }

.ambient { position: fixed; z-index: -1; inset: 0; overflow: hidden; pointer-events: none; }
.ambient::before, .ambient::after { content: ''; position: absolute; border-radius: 50%; }
.ambient::before { width: min(62vw, 900px); aspect-ratio: 1; top: -40vw; right: -22vw; background: radial-gradient(circle, rgba(37, 84, 232, .12), transparent 68%); }
.ambient::after { width: min(42vw, 580px); aspect-ratio: 1; bottom: -25vw; left: 5vw; background: radial-gradient(circle, rgba(26, 169, 199, .09), transparent 70%); }

.app-sidebar { position: fixed; z-index: 70; inset: 0 auto 0 0; display: flex; width: 286px; min-height: 100dvh; flex-direction: column; padding: 30px 22px 22px; border-right: 1px solid var(--line); background: color-mix(in srgb, var(--surface) 96%, var(--canvas)); }
.sidebar-brand { display: flex; align-items: center; justify-content: space-between; min-height: 46px; }
.app-brand { display: flex; align-items: center; gap: 11px; min-width: 0; }
.app-brand__mark { display: grid; width: 42px; height: 42px; flex: 0 0 auto; place-items: center; border-radius: 14px; color: #fff; background: linear-gradient(145deg, var(--blue), var(--cyan)); font-family: var(--display); font-size: 17px; box-shadow: 0 9px 24px rgba(37, 84, 232, .24); }
.app-brand > span:last-child { display: grid; line-height: 1.1; }
.app-brand b { font-family: var(--display); font-size: 16px; letter-spacing: -.035em; }
.app-brand small { margin-top: 5px; color: var(--muted); font-size: 10px; }
.sidebar-close { display: none !important; }
.sidebar-copy { margin: 36px 4px 24px; padding: 0 0 25px; border-bottom: 1px solid var(--line); }
.sidebar-copy p, .sidebar-nav__group > p { margin: 0 0 9px; color: var(--faint); font-size: 9px; font-weight: 800; letter-spacing: .15em; }
.sidebar-copy strong { display: block; max-width: 205px; font-family: var(--display); font-size: 16px; line-height: 1.45; }
.sidebar-nav { display: grid; gap: 22px; }
.sidebar-nav__group { display: grid; gap: 4px; }
.sidebar-nav__group > p { margin: 0 12px 6px; }
.sidebar-nav button { display: grid; grid-template-columns: 28px minmax(0, 1fr); align-items: center; gap: 9px; width: 100%; min-height: 45px; padding: 9px 12px; border-radius: 13px; color: var(--muted); background: transparent; text-align: left; cursor: pointer; font-size: 13px; font-weight: 750; transition: color .18s, background .18s, transform .18s; }
.sidebar-nav button:hover { color: var(--ink); background: var(--soft); transform: translateX(2px); }
.sidebar-nav button.is-active { color: var(--ink); background: var(--soft); }
.sidebar-nav .nav-index { color: var(--faint); font-size: 9px; letter-spacing: .08em; }
.sidebar-nav button.is-active .nav-index { color: var(--blue); }
.sidebar-footer { display: grid; gap: 13px; margin-top: auto; padding-top: 22px; }
.sidebar-admin { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 15px; border-radius: 14px; color: #fff; background: var(--navy); font-size: 12px; font-weight: 800; }
.sidebar-footer small { color: var(--faint); font-size: 9px; line-height: 1.5; }

.app-workspace { min-width: 0; min-height: 100dvh; margin-left: 286px; }
.app-header { position: sticky; z-index: 50; top: 0; display: grid; grid-template-columns: minmax(0, 1fr) 44px; align-items: center; min-height: 74px; padding: 10px max(24px, calc((100vw - 286px - 1120px) / 2)); border-bottom: 1px solid color-mix(in srgb, var(--line) 78%, transparent); background: color-mix(in srgb, var(--canvas) 88%, transparent); backdrop-filter: blur(18px); -webkit-backdrop-filter: blur(18px); }
.icon-button { display: grid; width: 42px; height: 42px; place-items: center; padding: 0; border: 1px solid var(--line); border-radius: 14px; color: var(--ink); background: var(--surface); cursor: pointer; transition: transform .2s, border-color .2s, background .2s; }
.icon-button:hover { border-color: var(--blue); transform: translateY(-1px); }
.menu-toggle { display: none; gap: 4px; align-content: center; }
.menu-toggle span { width: 18px; height: 2px; border-radius: 2px; background: currentColor; }
.header-context { display: grid; line-height: 1.15; }
.header-context > span { font-size: 13px; font-weight: 800; }
.header-context small { display: flex; align-items: center; gap: 7px; margin-top: 5px; color: var(--faint); font-size: 9px; font-weight: 700; }
.header-context i { width: 6px; height: 6px; border-radius: 50%; background: #22a768; box-shadow: 0 0 0 4px rgba(34, 167, 104, .1); }
.theme-toggle { justify-self: end; }
.theme-icon { font-size: 21px; line-height: 1; }
.drawer-backdrop { position: fixed; z-index: 60; inset: 0; width: 100%; height: 100%; padding: 0; opacity: 0; visibility: hidden; background: rgba(6, 12, 26, .58); cursor: pointer; transition: opacity .25s, visibility .25s; }
.drawer-backdrop.is-open { opacity: 1; visibility: visible; }
.menu-open { overflow: hidden; }

.app-shell { width: min(100% - 48px, 1120px); margin: 0 auto; padding: clamp(40px, 6vw, 72px) 0 34px; }
.view-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 30px; margin-bottom: 30px; }
.kicker { margin: 0; color: var(--blue); font-size: 9px; font-weight: 800; letter-spacing: .17em; }
.view-heading h1 { margin: 9px 0 0; font-family: var(--display); font-size: clamp(36px, 5.5vw, 62px); line-height: 1.03; letter-spacing: -.055em; }
.view-description { max-width: 580px; margin: 13px 0 0; color: var(--muted); font-size: 14px; }
.view-number { color: color-mix(in srgb, var(--line) 78%, transparent); font-family: var(--display); font-size: clamp(58px, 8vw, 92px); font-weight: 700; line-height: .8; user-select: none; }

.group-bar { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 10px; margin-bottom: 16px; padding: 9px; border: 1px solid var(--line); border-radius: 18px; background: var(--surface); box-shadow: 0 7px 25px rgba(22, 32, 54, .04); }
.group-bar label { display: grid; min-width: 0; }
.group-bar label span { padding: 2px 12px 3px; color: var(--muted); font-size: 9px; font-weight: 800; letter-spacing: .09em; text-transform: uppercase; }
.group-bar select { width: 100%; min-width: 0; padding: 5px 38px 7px 12px; border: 0; outline: 0; background: transparent; font-weight: 800; cursor: pointer; }
.group-bar select option { color: #172033; background: #fff; }
.refresh-button { display: flex; align-items: center; gap: 9px; min-height: 52px; padding: 0 20px; border-radius: 13px; color: #fff; background: var(--navy); cursor: pointer; font-size: 12px; }
.refresh-button span { font-size: 19px; transition: transform .35s; }
.refresh-button:active span { transform: rotate(180deg); }

.content-card { min-height: 360px; overflow: hidden; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow); }
.content-card__body { padding: clamp(22px, 4vw, 36px); }
.feed { display: grid; gap: 12px; }
.feed-item { position: relative; padding: clamp(18px, 3vw, 25px); overflow: hidden; border: 1px solid var(--line); border-radius: 17px; background: color-mix(in srgb, var(--surface) 76%, var(--soft)); }
.feed-item::before { content: ''; position: absolute; inset: 0 auto 0 0; width: 3px; background: linear-gradient(var(--blue), var(--cyan)); opacity: .55; }
.feed-item h3 { margin: 0 0 8px; font-size: clamp(15px, 2vw, 18px); line-height: 1.4; }
.feed-item p { margin: 0; color: var(--muted); overflow-wrap: anywhere; }
.feed-item time { display: block; margin-top: 13px; color: var(--faint); font-size: 10px; font-weight: 700; }
.feed-image { display: block; margin-top: 17px; overflow: hidden; border-radius: 13px; background: var(--soft); }
.feed-image img { width: 100%; max-height: 720px; object-fit: contain; }
.week-label { display: inline-flex; align-items: center; min-height: 34px; margin-bottom: 16px; padding: 7px 12px; border-radius: 99px; color: var(--blue); background: color-mix(in srgb, var(--blue) 10%, var(--surface)); font-size: 11px; font-weight: 800; }
.material-overview { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; margin-bottom: 12px; }
.material-stat { padding: 18px; border: 1px solid var(--line); border-radius: 16px; background: var(--soft); }
.material-stat b { display: block; font-family: var(--display); font-size: 24px; }
.material-stat span { display: block; margin-top: 5px; color: var(--muted); font-size: 11px; font-weight: 700; }
.empty-state, .error-state, .loading { display: grid; min-height: 260px; place-content: center; justify-items: center; padding: 30px; color: var(--faint); text-align: center; }
.empty-state span { display: grid; width: 46px; height: 46px; place-items: center; border-radius: 15px; background: var(--soft); font-family: var(--display); font-size: 24px; }
.empty-state p, .error-state p { max-width: 390px; margin: 11px 0 0; }
.error-state b { color: var(--danger); }
.loading { gap: 14px; font-size: 11px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; }
.loading i { width: 30px; height: 30px; border: 3px solid var(--soft); border-top-color: var(--blue); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.app-footer { display: flex; justify-content: space-between; gap: 20px; margin-top: 28px; padding: 22px 0 0; border-top: 1px solid var(--line); color: var(--faint); font-size: 10px; font-weight: 700; }
.mobile-nav { display: none; }

/* Admin panel */
body:not(.student-app) { padding-bottom: 50px; }
body:not(.student-app) > header { position: sticky; z-index: 40; top: 0; display: flex; align-items: center; justify-content: space-between; gap: 16px; min-height: 72px; padding: 12px max(20px, calc((100vw - 1100px) / 2)); border-bottom: 1px solid var(--line); background: color-mix(in srgb, var(--canvas) 90%, transparent); backdrop-filter: blur(16px); }
.brand { display: flex; align-items: center; gap: 10px; font-family: var(--display); font-size: clamp(14px, 3vw, 18px); }
.brand span { padding: 4px 8px; border-radius: 99px; color: var(--blue); background: var(--soft); font-family: var(--font); font-size: 9px; letter-spacing: .08em; }
body:not(.student-app) main { width: min(100% - 32px, 1100px); margin: 0 auto; padding-top: 40px; }
body:not(.student-app) h1 { margin: 8px 0 26px !important; font-family: var(--display) !important; font-size: clamp(32px, 6vw, 56px); letter-spacing: -.05em; }
body:not(.student-app) .eyebrow { color: var(--blue); font-size: 10px; font-weight: 800; letter-spacing: .16em; }
.grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.card { min-width: 0; padding: clamp(20px, 4vw, 30px); border: 1px solid var(--line); border-radius: 20px; background: var(--surface); box-shadow: 0 10px 30px rgba(20, 32, 57, .05); }
.card h2 { margin: 0 0 20px; font-family: var(--display); font-size: clamp(18px, 4vw, 24px); letter-spacing: -.03em; }
.wide { grid-column: 1 / -1; }
form { margin: 0; }
input, textarea, body:not(.student-app) select { width: 100% !important; min-width: 0; padding: 12px 14px !important; border: 1px solid var(--line); border-radius: 12px; outline: 0; background: var(--canvas); }
input:focus, textarea:focus, body:not(.student-app) select:focus { border-color: var(--blue); box-shadow: 0 0 0 3px color-mix(in srgb, var(--blue) 15%, transparent); }
textarea { min-height: 110px; resize: vertical; }
body:not(.student-app) button { padding: 11px 17px; border-radius: 11px; color: #fff; background: var(--navy); cursor: pointer; font-weight: 800; }
body:not(.student-app) .item { padding: 16px 0; overflow-wrap: anywhere; border-top: 1px solid var(--line); }
body:not(.student-app) .item:first-child { border-top: 0; }
body:not(.student-app) .item img { border-radius: 12px; }
.login-card { max-width: 440px; margin: 10vh auto 0; }
.login-card h2 { margin-bottom: 8px; }
.form-error { min-height: 24px; margin: 8px 0; color: var(--danger); font-size: 13px; }
.notice { margin: 0 0 20px; padding: 13px 16px; border: 1px solid color-mix(in srgb, var(--cyan) 35%, var(--line)); border-radius: 13px; color: var(--ink); background: color-mix(in srgb, var(--cyan) 9%, var(--surface)); font-weight: 700; }
.admin-grid { grid-template-columns: minmax(240px, .7fr) minmax(0, 1.6fr); align-items: start; }
.card-label { margin: 0 0 8px; color: var(--blue); font-size: 9px; font-weight: 800; letter-spacing: .15em; }
.form-stack { display: grid; gap: 14px; }
.form-stack label { display: grid; gap: 6px; min-width: 0; color: var(--muted); font-size: 11px; font-weight: 800; }
.form-row { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.file-field { padding: 13px; border: 1px dashed var(--line); border-radius: 13px; background: var(--canvas); }
.file-field input { padding: 6px !important; background: transparent; }
.publish-card > .message { margin: -10px 0 20px; color: var(--muted); font-size: 13px; }
.publications-card { margin-top: 16px; }
.archive-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 9px; margin: 4px 0 8px; padding: 12px 0 18px; border-bottom: 1px solid var(--line); }
.archive-filters { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 9px; margin: 16px 0 0; }
.publication-preview { margin-top: 16px; padding: 18px; border: 1px solid var(--blue); border-radius: 14px; background: color-mix(in srgb, var(--blue) 6%, var(--surface)); }
.publication-preview b { display: block; font-size: 16px; }
.publication-preview p { margin: 8px 0 0; color: var(--muted); white-space: pre-wrap; }
.publication-preview img { max-width: 100%; max-height: 280px; margin-top: 13px; border-radius: 11px; object-fit: contain; }
.form-actions { display: flex; flex-wrap: wrap; gap: 9px; }
body:not(.student-app) .secondary-button { color: var(--ink); background: var(--soft); }
.archive-actions label { display: flex; align-items: center; gap: 7px; margin-right: auto; color: var(--muted); font-size: 11px; font-weight: 800; }
.archive-actions input, .archive-select input { width: 17px !important; height: 17px; margin: 0; accent-color: var(--blue); }
.archive-actions button { font-size: 11px; }
.section-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; margin-bottom: 10px; }
.section-heading h2 { margin-bottom: 0; }
.section-heading > span { padding: 5px 10px; border-radius: 99px; color: var(--muted); background: var(--soft); font-size: 10px; font-weight: 800; white-space: nowrap; }
.admin-feed { display: grid; }
.admin-item { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: start; gap: 15px; padding: 22px 0; border-top: 1px solid var(--line); }
.archive-select { padding-top: 4px; }
.admin-item__content { min-width: 0; }
.admin-item__meta { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; color: var(--faint); font-size: 10px; font-weight: 700; }
.admin-item__meta b { padding: 3px 8px; border-radius: 99px; color: var(--blue); background: var(--soft); }
.admin-item h3 { margin: 13px 0 6px; overflow-wrap: anywhere; }
.admin-item p { margin: 8px 0 0; color: var(--muted); overflow-wrap: anywhere; }
.admin-item img { width: min(100%, 360px); max-height: 300px; margin-top: 14px; object-fit: contain; background: var(--soft); }
body:not(.student-app) .danger-button { color: var(--danger); background: color-mix(in srgb, var(--danger) 10%, var(--surface)); }

@media (max-width: 940px) {
  .app-sidebar { width: min(334px, 88vw); padding-top: max(22px, env(safe-area-inset-top)); padding-bottom: max(24px, env(safe-area-inset-bottom)); box-shadow: 28px 0 70px rgba(7, 14, 30, .28); transform: translateX(-105%); visibility: hidden; transition: transform .25s ease, visibility .25s; }
  .app-sidebar.is-open { transform: translateX(0); visibility: visible; }
  .sidebar-close { display: grid !important; }
  .sidebar-nav__primary { display: none; }
  .sidebar-copy { margin-top: 28px; }
  .app-workspace { margin-left: 0; }
  .app-header { grid-template-columns: 42px minmax(0, 1fr) 42px; gap: 13px; min-height: 68px; padding: max(9px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) 9px max(16px, env(safe-area-inset-left)); }
  .menu-toggle { display: grid; }
  .header-context { min-width: 0; }
  .header-context > span, .header-context small span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .app-shell { width: min(100% - 32px, 760px); padding: 34px 0 calc(104px + env(safe-area-inset-bottom)); }
  .mobile-nav { position: fixed; z-index: 55; right: max(10px, env(safe-area-inset-right)); bottom: max(10px, env(safe-area-inset-bottom)); left: max(10px, env(safe-area-inset-left)); display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 3px; padding: 6px; border: 1px solid color-mix(in srgb, var(--line) 75%, transparent); border-radius: 19px; background: color-mix(in srgb, var(--surface) 92%, transparent); box-shadow: 0 16px 45px rgba(9, 18, 38, .18); backdrop-filter: blur(18px); -webkit-backdrop-filter: blur(18px); }
  .mobile-nav button { display: grid; min-width: 0; min-height: 54px; place-content: center; justify-items: center; gap: 3px; padding: 5px 2px; border-radius: 13px; color: var(--muted); background: transparent; cursor: pointer; }
  .mobile-nav button span { font-size: 9px; font-weight: 800; letter-spacing: .05em; }
  .mobile-nav button b { max-width: 100%; overflow: hidden; font-size: clamp(8px, 2.4vw, 10px); text-overflow: ellipsis; white-space: nowrap; }
.mobile-nav button.is-active { color: #fff; background: linear-gradient(135deg, var(--blue), #4777ff); box-shadow: 0 7px 17px rgba(37, 84, 232, .22); }
.mobile-nav button.has-new { position: relative; }
.mobile-nav button.has-new::after { content: ''; position: absolute; top: 8px; right: calc(50% - 18px); width: 7px; height: 7px; border: 2px solid var(--surface); border-radius: 50%; background: #f15b54; }
  .mobile-nav #mobile-more.is-active { color: var(--blue); background: var(--soft); box-shadow: none; }
}

@media (max-width: 720px) {
  .icon-button { width: 40px; height: 40px; border-radius: 13px; }
  .app-shell { width: calc(100% - 24px); padding-top: 27px; }
  .view-heading { align-items: flex-start; margin-bottom: 22px; }
  .view-heading h1 { font-size: clamp(31px, 10vw, 44px); }
  .view-description { margin-top: 9px; font-size: 12px; }
  .view-number { margin-top: 8px; font-size: 46px; }
  .group-bar { grid-template-columns: minmax(0, 1fr) 50px; gap: 6px; margin-bottom: 12px; padding: 6px; border-radius: 16px; }
  .group-bar label span { padding-top: 4px; }
  .refresh-button { width: 50px; min-height: 50px; justify-content: center; padding: 0; border-radius: 11px; }
  .refresh-button b { display: none; }
  .content-card { min-height: 330px; border-radius: 19px; }
  .content-card__body { padding: 14px; }
  .feed-item { padding: 17px; border-radius: 14px; }
  .material-overview { grid-template-columns: 1fr; gap: 7px; }
  .material-stat { display: flex; align-items: center; justify-content: space-between; padding: 13px 15px; }
  .material-stat b { font-size: 19px; }
  .material-stat span { margin: 0; }
  .empty-state, .error-state, .loading { min-height: 260px; padding: 24px 14px; }
  .app-footer { display: none; }
  .grid { grid-template-columns: 1fr; }
  .wide { grid-column: auto; }
  .admin-grid, .form-row { grid-template-columns: 1fr; }
  .admin-item { grid-template-columns: auto minmax(0, 1fr); align-items: start; }
  .admin-item form { grid-column: 1 / -1; }
  .admin-item .danger-button { width: 100%; }
  .archive-actions { align-items: stretch; }
  .archive-filters { grid-template-columns: 1fr; }
  .archive-actions label { width: 100%; }
  .archive-actions button { flex: 1 1 145px; }
  body:not(.student-app) main { width: calc(100% - 24px); padding-top: 28px; }
  .brand span { display: none; }
}

@media (max-width: 370px) {
  .view-number { display: none; }
  .header-context small { display: none; }
  .mobile-nav { right: 6px; bottom: max(6px, env(safe-area-inset-bottom)); left: 6px; }
  .mobile-nav button b { font-size: 8px; }
}

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