:root {
  --ink: #17202a;
  --muted: #607085;
  --line: #d9e2ec;
  --panel: #ffffff;
  --bg: #f5f7fb;
  --brand: #166c67;
  --brand-strong: #0f4f4b;
  --blue: #3056d3;
  --amber: #c77700;
  --danger: #bd2f2f;
  --shadow: 0 18px 45px rgba(23, 32, 42, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background: var(--bg);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0;
}

a {
  color: inherit;
  text-decoration: none;
}

button,
input,
textarea,
select {
  font: inherit;
}

.app-shell {
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr);
  min-height: 100vh;
}

.auth-shell {
  display: block;
}

.content-column {
  display: flex;
  min-width: 0;
  min-height: 100vh;
  flex-direction: column;
}

.auth-shell .main-panel {
  padding: 0;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 24px 18px;
  background: #102a36;
  color: #f6fbfd;
  display: flex;
  flex-direction: column;
  gap: 26px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-mark {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  background: #35b7a5;
  color: #062b28;
  font-weight: 800;
}

.brand small,
.user-card span,
td small {
  display: block;
  color: #a8bac5;
  font-size: 12px;
  margin-top: 3px;
}

.sidebar nav {
  display: grid;
  gap: 8px;
}

.nav-link {
  padding: 12px 14px;
  color: #d8e4ea;
  border-left: 3px solid transparent;
}

.nav-link.active,
.nav-link:hover {
  background: rgba(255, 255, 255, 0.08);
  border-left-color: #35b7a5;
}

.user-card {
  margin-top: auto;
  padding: 14px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(255, 255, 255, 0.06);
}

.user-card a {
  display: inline-block;
  margin-top: 12px;
  color: #70d9ca;
}

.main-panel {
  flex: 1;
  padding: 34px;
  min-width: 0;
}

.site-footer {
  padding: 14px 24px;
  border-top: 1px solid var(--line);
  background: var(--panel);
  color: var(--muted);
  font-size: 13px;
  line-height: 19px;
  text-align: center;
}

.site-footer a:hover {
  color: var(--brand-strong);
}

.page-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 20px;
  margin-bottom: 24px;
}

.page-header.compact {
  margin-bottom: 16px;
}

.eyebrow {
  display: inline-block;
  color: var(--brand);
  font-weight: 800;
  font-size: 12px;
  letter-spacing: 0;
  margin-bottom: 8px;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  font-size: 34px;
  line-height: 1.15;
  margin-bottom: 10px;
}

h2 {
  font-size: 19px;
  line-height: 1.25;
}

p {
  color: var(--muted);
  line-height: 1.65;
}

.course-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 18px;
}

.category-home-header {
  margin-bottom: 30px;
}

.category-overview-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 18px;
}

.category-overview-card {
  --category-accent: var(--brand);
  display: grid;
  min-height: 210px;
  grid-template-columns: 1fr auto;
  grid-template-rows: auto 1fr;
  gap: 18px;
  padding: 22px;
  border: 1px solid var(--line);
  border-top: 5px solid var(--category-accent);
  background: var(--panel);
  box-shadow: var(--shadow);
  transition: transform 150ms ease, box-shadow 150ms ease;
}

.category-overview-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 22px 48px rgba(23, 32, 42, 0.13);
}

.category-index {
  grid-column: 1 / -1;
  color: var(--category-accent);
  font-size: 13px;
  font-weight: 800;
}

.category-overview-card h2 {
  margin-bottom: 8px;
  font-size: 26px;
}

.category-overview-card p {
  margin-bottom: 0;
}

.category-arrow {
  display: grid;
  width: 42px;
  height: 42px;
  align-self: end;
  place-items: center;
  background: var(--category-accent);
  color: white;
  font-size: 24px;
}

.category-tone-0 { --category-accent: #167a70; }
.category-tone-1 { --category-accent: #315cbd; }
.category-tone-2 { --category-accent: #b66a00; }
.category-tone-3 { --category-accent: #a9435b; }
.category-tone-4 { --category-accent: #4f7b2a; }
.category-tone-5 { --category-accent: #5d6672; }

.course-series-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 18px;
}

.course-series-card {
  display: grid;
  min-height: 190px;
  grid-template-columns: 1fr auto;
  grid-template-rows: auto 1fr auto;
  gap: 12px 18px;
  padding: 22px;
  border: 1px solid var(--line);
  border-left: 5px solid var(--brand);
  background: var(--panel);
  box-shadow: var(--shadow);
  transition: border-color 150ms ease, transform 150ms ease;
}

.course-group-heading th {
  padding: 14px 18px;
  border-top: 3px solid var(--brand);
  background: #edf5f3;
  color: var(--ink);
  text-align: left;
}

.course-group-heading strong {
  margin-right: 12px;
  font-size: 16px;
}

.course-group-heading span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}

.course-series-card:hover {
  border-left-color: var(--blue);
  transform: translateY(-2px);
}

.series-category {
  grid-column: 1 / -1;
  color: var(--brand);
  font-size: 12px;
  font-weight: 800;
}

.course-series-card h2 {
  align-self: center;
  margin: 0;
  font-size: 24px;
}

.series-stats {
  display: flex;
  align-items: flex-end;
  gap: 14px;
  color: var(--muted);
  font-size: 13px;
}

.series-arrow {
  display: grid;
  width: 42px;
  height: 42px;
  grid-column: 2;
  grid-row: 2 / 4;
  align-self: end;
  place-items: center;
  background: var(--brand);
  color: white;
  font-size: 24px;
}

.course-card,
.form-panel,
.table-panel,
.viewer-panel,
.learning-side,
.login-form,
.login-copy,
.error-panel {
  background: var(--panel);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}

.course-card {
  min-height: 292px;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.locked-card {
  opacity: 0.72;
}

.course-topline,
.course-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  color: var(--muted);
  font-size: 13px;
}

.course-topline strong,
.pill {
  color: var(--brand-strong);
  background: #dff5ef;
  padding: 4px 8px;
}

.progress-bar {
  width: 100%;
  height: 9px;
  background: #e9eef5;
  overflow: hidden;
}

.progress-bar i {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, var(--brand), var(--blue));
}

.card-action,
.primary-action,
.secondary-action,
button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  padding: 10px 16px;
  border: 0;
  background: var(--brand);
  color: white;
  cursor: pointer;
  font-weight: 750;
}

.card-action {
  margin-top: auto;
}

.locked-action {
  background: #d4dbe7;
  color: #5c697a;
  cursor: not-allowed;
}

.secondary-action {
  background: #e8eef7;
  color: #203044;
  border: 1px solid var(--line);
}

.secondary-action.full {
  width: 100%;
}

.split-layout {
  display: grid;
  grid-template-columns: minmax(280px, 380px) minmax(0, 1fr);
  gap: 22px;
  align-items: start;
}

.form-panel {
  padding: 20px;
}

label {
  display: grid;
  gap: 7px;
  color: #334155;
  font-weight: 700;
  margin-bottom: 14px;
}

.check-row {
  grid-template-columns: 18px 1fr;
  align-items: center;
  gap: 10px;
  font-weight: 650;
}

.check-row input {
  width: 18px;
  height: 18px;
}

input,
textarea,
select {
  width: 100%;
  border: 1px solid #cbd5e1;
  padding: 11px 12px;
  background: white;
  color: var(--ink);
}

textarea {
  resize: vertical;
}

.table-panel {
  overflow: auto;
}

.table-toolbar {
  display: flex;
  align-items: center;
  min-height: 42px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  font-size: 13px;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 720px;
}

th,
td {
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: middle;
}

th {
  color: #475569;
  background: #f8fafc;
  font-size: 13px;
}

td small {
  color: var(--muted);
}

td form {
  display: inline-flex;
  margin: 2px 6px 2px 0;
}

.course-admin-layout {
  grid-template-columns: minmax(300px, 420px) minmax(0, 1fr);
}

.course-admin-table {
  min-width: 960px;
}

.course-admin-table tbody tr {
  transition: background 120ms ease, opacity 120ms ease;
}

.course-admin-table tbody tr:hover td {
  background: #f8fafc;
}

.course-admin-table tbody tr.dragging {
  opacity: 0.48;
}

.course-admin-table tbody tr.dragging td {
  background: #e8f5f1;
}

.course-order-cell,
.course-actions {
  min-width: 138px;
  white-space: nowrap;
}

.drag-handle {
  width: 34px;
  min-width: 34px;
  min-height: 34px;
  margin-right: 8px;
  padding: 0;
  color: #425466;
  background: #edf2f7;
  border: 1px solid var(--line);
  cursor: grab;
  font-size: 18px;
}

.drag-handle:active {
  cursor: grabbing;
}

.account-actions {
  min-width: 250px;
  white-space: nowrap;
}

@media (max-width: 1500px) {
  .course-admin-layout {
    grid-template-columns: 1fr;
  }

  .course-admin-layout > .form-panel {
    width: min(100%, 680px);
  }
}

.compact-action {
  min-height: 34px;
  padding: 6px 10px;
  font-size: 13px;
}

.danger-action {
  color: var(--danger);
  background: #fff;
  border: 1px solid #e5aaaa;
}

.current-account {
  display: inline-block;
  padding: 7px 10px;
  color: var(--muted);
  font-size: 13px;
}

.text-danger {
  color: var(--danger);
  background: transparent;
  min-height: auto;
  padding: 0;
}

.muted,
.empty-state {
  color: var(--muted);
}

.empty-state {
  background: white;
  border: 1px dashed #b8c4d4;
  padding: 28px;
}

.learning-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(320px, 390px);
  gap: 20px;
  align-items: start;
}

.viewer-column {
  min-width: 0;
  display: grid;
  gap: 16px;
}

.viewer-panel {
  display: grid;
  place-items: center;
  overflow: hidden;
  background: #0c1622;
}

.viewer-video,
.viewer-pdf {
  min-height: 0;
  aspect-ratio: 16 / 9;
}

.viewer-panel video,
.viewer-panel iframe {
  display: block;
  width: 100%;
  height: 100%;
  border: 0;
  object-fit: contain;
}

.viewer-audio,
.viewer-file {
  min-height: 260px;
}

.viewer-panel audio {
  width: calc(100% - 64px);
}

.download-panel {
  text-align: center;
  color: white;
  padding: 36px;
}

.download-panel p {
  color: #b6c4cf;
}

.study-side {
  position: sticky;
  top: 20px;
}

.progress-panel {
  padding: 18px 20px;
  background: white;
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}

.progress-heading,
.progress-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.progress-heading h2 {
  margin-bottom: 0;
}

.progress-heading strong {
  color: var(--brand-strong);
  font-size: 26px;
  font-weight: 850;
}

.progress-track {
  height: 10px;
  margin: 16px 0;
  overflow: hidden;
  background: #e8eef7;
}

.progress-track i {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, var(--brand), var(--blue));
  transition: width 180ms ease;
}

.progress-actions {
  justify-content: flex-start;
  flex-wrap: wrap;
}

.course-details {
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

.course-details summary {
  color: var(--brand-strong);
  cursor: pointer;
  font-weight: 750;
}

.course-details dl {
  grid-template-columns: 90px minmax(0, 1fr);
  margin-top: 14px;
}

dl {
  margin: 0;
  display: grid;
  gap: 8px;
}

dt {
  color: var(--muted);
  font-size: 12px;
}

dd {
  margin: 0 0 8px;
  word-break: break-word;
}

.note-editor,
.notes-panel,
.admin-note {
  background: white;
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}

.note-editor {
  padding: 22px;
}

.form-heading,
.admin-note header,
.filter-form {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
}

.form-heading button {
  min-width: 120px;
}

.note-editor textarea {
  min-height: 360px;
  line-height: 1.7;
}

.note-sharing-option {
  grid-template-columns: 20px minmax(0, 1fr);
  align-items: start;
  gap: 10px;
  padding: 13px 14px;
  border: 1px solid var(--line);
  background: #f8fafc;
}

.note-sharing-option input {
  width: 18px;
  height: 18px;
  margin-top: 2px;
}

.note-sharing-option span {
  display: grid;
  gap: 3px;
}

.note-sharing-option small {
  color: var(--muted);
  font-weight: 500;
  line-height: 1.5;
}

.note-help {
  margin-bottom: 0;
  padding-top: 14px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 13px;
}

.notes-panel {
  margin-top: 20px;
  padding: 22px;
}

.section-heading,
.filter-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.section-heading h2 {
  margin-bottom: 0;
}

.note-count,
.filter-bar > span {
  color: var(--muted);
  font-size: 13px;
  white-space: nowrap;
}

.note-card {
  border-top: 1px solid var(--line);
  padding: 16px 0 0;
  margin-top: 16px;
}

.note-card div,
.admin-note header div {
  display: grid;
  gap: 3px;
}

.note-card span,
.admin-note span,
.admin-note time {
  color: var(--muted);
  font-size: 12px;
}

.note-card p,
.admin-note p {
  color: #263445;
  line-height: 1.7;
  word-break: break-word;
}

.notes-list {
  display: grid;
  gap: 14px;
}

.admin-note {
  padding: 18px;
}

.note-visibility {
  justify-items: end;
  text-align: right;
}

.visibility-pill {
  display: inline-flex;
  width: max-content;
  padding: 5px 8px;
  border: 1px solid var(--line);
  font-weight: 750;
}

.visibility-pill.is-public {
  color: var(--brand-strong);
  background: #e1f5ef;
  border-color: #9fd7c9;
}

.visibility-pill.is-private {
  color: #5c697a;
  background: #f1f5f9;
}

.note-permission-form {
  display: flex;
  justify-content: flex-end;
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

.filter-bar {
  align-items: flex-end;
  margin-bottom: 18px;
  padding: 16px;
  background: white;
  border: 1px solid var(--line);
}

.filter-form {
  align-items: flex-end;
  justify-content: flex-start;
  flex-wrap: wrap;
}

.filter-form label {
  min-width: 220px;
  margin-bottom: 0;
}

.filter-form select {
  min-width: 220px;
}

.login-panel {
  min-height: calc(100vh - 48px);
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(320px, 440px);
  background:
    linear-gradient(120deg, rgba(16, 42, 54, 0.92), rgba(22, 108, 103, 0.86)),
    linear-gradient(45deg, #102a36 25%, #3056d3 100%);
}

.login-copy {
  align-self: stretch;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 8vw;
  color: white;
  background: transparent;
  border: 0;
  box-shadow: none;
}

.login-copy h1 {
  max-width: 680px;
  font-size: 52px;
}

.login-copy p {
  max-width: 560px;
  color: #e6f1f4;
}

.login-copy .eyebrow {
  color: #8bf0de;
}

.demo-box {
  display: grid;
  gap: 7px;
  max-width: 520px;
  margin-top: 18px;
  padding: 16px;
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.18);
}

.login-form {
  align-self: center;
  margin: 28px;
  padding: 28px;
}

.login-form button,
.form-panel button {
  width: 100%;
}

.form-panel button:disabled {
  cursor: wait;
  opacity: 0.72;
}

.upload-status {
  display: grid;
  gap: 8px;
  margin-top: 14px;
  padding: 12px;
  border: 1px solid var(--line);
  background: #f7fafc;
}

.upload-status[hidden] {
  display: none;
}

.upload-status-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  color: var(--muted);
  font-size: 13px;
}

.upload-status-row strong {
  color: var(--brand-strong);
}

.upload-status progress {
  width: 100%;
  height: 10px;
  accent-color: var(--brand);
}

.alert {
  background: #fff4e5;
  color: #7a4600;
  padding: 10px 12px;
  border: 1px solid #ffd69a;
}

.error-panel {
  max-width: 560px;
  padding: 34px;
}

@media (max-width: 980px) {
  .app-shell {
    display: block;
  }

  .sidebar {
    position: static;
    height: auto;
  }

  .sidebar nav {
    grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  }

  .main-panel {
    padding: 22px;
  }

  .page-header,
  .split-layout,
  .learning-layout,
  .login-panel,
  .form-heading,
  .admin-note header,
  .filter-form,
  .filter-bar {
    grid-template-columns: 1fr;
    display: grid;
  }

  .note-visibility {
    justify-items: start;
    text-align: left;
  }

  .login-copy {
    padding: 42px 24px 18px;
  }

  .login-copy h1 {
    font-size: 38px;
  }

  .login-form {
    margin: 18px 24px 42px;
  }

  .viewer-panel {
    min-height: 0;
  }

  .study-side {
    position: static;
  }

  .note-editor textarea {
    min-height: 240px;
  }
}

@media (max-width: 560px) {
  .main-panel {
    padding: 16px;
  }

  h1 {
    font-size: 28px;
  }

  .page-header {
    display: block;
  }

  .course-grid {
    grid-template-columns: 1fr;
  }

  .login-copy h1 {
    font-size: 31px;
  }

  .progress-actions button {
    width: 100%;
  }
}
