:root {
  color-scheme: light;
  --ink: #17201f;
  --muted: #61706d;
  --soft: #f4f7f5;
  --surface: #ffffff;
  --line: #d9e2de;
  --field: #ffffff;
  --body-bg:
    radial-gradient(circle at top left, rgba(15, 118, 110, 0.11), transparent 34rem),
    linear-gradient(180deg, #fbfcfb 0%, #eef4f0 100%);
  --teal: #0f766e;
  --teal-ink: #064e49;
  --amber: #d97706;
  --rose: #be3455;
  --blue: #2563eb;
  --shadow: 0 18px 40px rgba(23, 32, 31, 0.08);
  --radius: 8px;
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --ink: #e8f1ee;
  --muted: #9db0aa;
  --soft: #111b1a;
  --surface: #17211f;
  --line: #2b3a36;
  --field: #101817;
  --body-bg:
    radial-gradient(circle at top left, rgba(20, 184, 166, 0.16), transparent 34rem),
    linear-gradient(180deg, #07100f 0%, #101716 100%);
  --teal: #2dd4bf;
  --teal-ink: #99f6e4;
  --amber: #f59e0b;
  --rose: #fb7185;
  --blue: #60a5fa;
  --shadow: 0 18px 40px rgba(0, 0, 0, 0.24);
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  background: var(--body-bg);
  font-family: "Segoe UI", Tahoma, Arial, sans-serif;
}

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

button {
  border: 0;
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.screen {
  min-height: 100vh;
}

.gate {
  display: grid;
  grid-template-columns: minmax(0, 0.92fr) minmax(320px, 0.72fr);
  gap: clamp(24px, 5vw, 72px);
  align-items: center;
  width: min(1180px, calc(100% - 32px));
  min-height: 100vh;
  margin: 0 auto;
  padding: 32px 0;
}

.gate-copy {
  display: grid;
  gap: 24px;
}

.brand-row {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--teal-ink);
  font-weight: 700;
}

.brand-mark {
  width: 38px;
  height: 38px;
  border: 1px solid rgba(15, 118, 110, 0.25);
  border-radius: var(--radius);
  background: var(--soft);
  object-fit: cover;
}

.gate h1 {
  max-width: 760px;
  margin: 0;
  font-size: clamp(2.4rem, 7vw, 5.3rem);
  line-height: 0.95;
  letter-spacing: 0;
}

.lead {
  max-width: 720px;
  margin: 0;
  color: var(--muted);
  font-size: clamp(1rem, 2vw, 1.2rem);
  line-height: 1.65;
}

.visual-panel {
  min-height: 250px;
  border: 1px solid rgba(23, 32, 31, 0.1);
  border-radius: var(--radius);
  background:
    linear-gradient(135deg, rgba(15, 118, 110, 0.9), rgba(37, 99, 235, 0.78)),
    url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAPUlEQVR4nGNgYGD4z8DAwMiABnDnzp0MYgEGxnwGJgYGBqZ4GJgYGBgkGRiGgTRw8V8TMDAwMHIgBgDNpQgS81e2WAAAAABJRU5ErkJggg==");
  background-size: cover, 16px 16px;
  box-shadow: var(--shadow);
  overflow: hidden;
  position: relative;
}

.visual-panel::before,
.visual-panel::after {
  content: "";
  position: absolute;
  border: 1px solid rgba(255, 255, 255, 0.55);
}

.visual-panel::before {
  inset: 28px 34px auto auto;
  width: 160px;
  height: 104px;
  background: rgba(255, 255, 255, 0.12);
}

.visual-panel::after {
  left: 32px;
  right: 32px;
  bottom: 30px;
  height: 84px;
  background:
    linear-gradient(90deg, rgba(255, 255, 255, 0.16) 0 18%, transparent 18% 25%, rgba(255, 255, 255, 0.22) 25% 51%, transparent 51% 59%, rgba(255, 255, 255, 0.18) 59% 100%);
}

.visual-metric {
  position: absolute;
  left: 28px;
  top: 28px;
  width: min(310px, calc(100% - 56px));
  color: #fff;
}

.visual-metric b {
  display: block;
  font-size: 2rem;
}

.visual-metric span {
  display: block;
  max-width: 220px;
  margin-top: 8px;
  color: rgba(255, 255, 255, 0.78);
  line-height: 1.45;
}

.gate-card,
.panel,
.note-card,
.lecture-card,
.admin-row {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.gate-card {
  padding: 22px;
}

.gate-card h2,
.panel h2,
.panel h3 {
  margin: 0;
  letter-spacing: 0;
}

.tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--soft);
}

.tab {
  min-height: 38px;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  font-weight: 700;
}

.tab.active {
  background: var(--surface);
  color: var(--teal-ink);
  box-shadow: 0 1px 0 rgba(23, 32, 31, 0.08);
}

.form-stack {
  display: grid;
  gap: 14px;
  margin-top: 18px;
}

.field {
  display: grid;
  gap: 7px;
}

.field span,
.tiny-label {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

.input,
.select,
.textarea {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--field);
  color: var(--ink);
  padding: 10px 11px;
  outline: none;
}

.textarea {
  min-height: 120px;
  resize: vertical;
  line-height: 1.55;
}

.input:focus,
.select:focus,
.textarea:focus {
  border-color: rgba(15, 118, 110, 0.62);
  box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.12);
}

.button {
  display: inline-flex;
  min-height: 42px;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border-radius: var(--radius);
  background: var(--teal);
  color: #fff;
  padding: 0 14px;
  font-weight: 800;
}

.button.secondary {
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
}

.button.warning {
  background: var(--rose);
}

.hint,
.error {
  margin: 0;
  font-size: 0.88rem;
  line-height: 1.45;
}

.hint {
  color: var(--muted);
}

.error {
  color: var(--rose);
  font-weight: 700;
}

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

.sidebar {
  position: sticky;
  top: 0;
  display: flex;
  height: 100vh;
  flex-direction: column;
  gap: 18px;
  border-right: 1px solid var(--line);
  background: color-mix(in srgb, var(--surface) 86%, transparent);
  padding: 20px;
  backdrop-filter: blur(16px);
}

.nav-stack {
  display: grid;
  gap: 4px;
  padding-bottom: 14px;
  border-bottom: 1px solid color-mix(in srgb, var(--line) 76%, transparent);
}

.sidebar-nav-area {
  display: grid;
  flex: 1;
  min-height: 0;
  align-content: start;
  gap: 16px;
  overflow-y: auto;
  padding-right: 2px;
}

.nav-btn {
  display: flex;
  min-height: 42px;
  align-items: center;
  justify-content: flex-start;
  gap: 10px;
  border-radius: var(--radius);
  background: transparent;
  color: var(--muted);
  padding: 0 11px;
  text-align: left;
  font-weight: 750;
}

.nav-btn > span:not(.nav-icon):not(.nav-count) {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.nav-btn + .nav-btn {
  border-top: 1px solid color-mix(in srgb, var(--line) 66%, transparent);
}

.nav-btn.active {
  background: color-mix(in srgb, var(--teal) 14%, var(--surface));
  color: var(--teal-ink);
}

.nav-icon {
  display: inline-grid;
  width: 24px;
  height: 24px;
  flex: 0 0 24px;
  place-items: center;
  border-radius: 8px;
  background: color-mix(in srgb, var(--teal) 10%, transparent);
  color: currentColor;
}

.nav-icon svg {
  width: 17px;
  height: 17px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.9;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.nav-count {
  margin-left: auto;
  border-radius: 999px;
  background: color-mix(in srgb, var(--teal) 14%, transparent);
  color: var(--teal-ink);
  padding: 3px 8px;
  font-size: 0.78rem;
}

.sidebar-footer {
  display: grid;
  gap: 10px;
  margin-top: 0;
}

.course-nav {
  display: grid;
  gap: 10px;
  padding-top: 2px;
}

.course-nav-section {
  display: grid;
  gap: 7px;
}

.course-nav-section + .course-nav-section {
  padding-top: 10px;
  border-top: 1px solid color-mix(in srgb, var(--line) 76%, transparent);
}

.course-nav-head {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto auto;
  gap: 8px;
  align-items: center;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--ink);
  padding: 0 10px;
  text-align: left;
  font-weight: 850;
}

.course-nav-head.active,
.course-nav-head:hover {
  border-color: color-mix(in srgb, var(--teal) 48%, var(--line));
  background: color-mix(in srgb, var(--teal) 12%, var(--surface));
  color: var(--teal-ink);
}

.course-count {
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 800;
  white-space: nowrap;
}

.course-chevron {
  display: inline-grid;
  width: 24px;
  height: 24px;
  place-items: center;
  border-radius: 999px;
  background: var(--soft);
  color: var(--teal-ink);
  font-weight: 900;
}

.course-lecture-list {
  display: grid;
  gap: 5px;
  padding-left: 10px;
}

.course-lecture-link {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
  min-height: 36px;
  border-left: 2px solid var(--line);
  border-radius: 0 var(--radius) var(--radius) 0;
  background: transparent;
  color: var(--muted);
  padding: 7px 8px 7px 10px;
  text-align: left;
  font-size: 0.86rem;
  font-weight: 720;
}

.course-lecture-link span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.course-lecture-link small {
  display: inline-grid;
  min-width: 22px;
  height: 22px;
  place-items: center;
  border-radius: 999px;
  background: var(--soft);
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 900;
}

.course-lecture-link:hover,
.course-lecture-link.active {
  border-left-color: var(--teal);
  background: color-mix(in srgb, var(--teal) 12%, var(--surface));
  color: var(--teal-ink);
}

.course-lecture-link.active small {
  background: color-mix(in srgb, var(--teal) 20%, var(--surface));
  color: var(--teal-ink);
}

.alias-chip {
  display: grid;
  gap: 3px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--soft);
  padding: 11px;
}

.alias-chip strong {
  word-break: break-word;
}

.theme-card {
  display: grid;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--soft);
  padding: 11px;
}

.theme-options {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
}

.theme-option {
  min-height: 32px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: capitalize;
}

.theme-option.active {
  border-color: color-mix(in srgb, var(--teal) 42%, var(--line));
  background: color-mix(in srgb, var(--teal) 18%, var(--surface));
  color: var(--teal-ink);
}

.main {
  min-width: 0;
  padding: 22px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

.title-row {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 10px;
}

.icon-button {
  display: inline-grid;
  width: 38px;
  min-width: 38px;
  height: 38px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--ink);
  font-size: 1.1rem;
  font-weight: 900;
}

.icon-button:hover,
.theme-option:hover {
  border-color: color-mix(in srgb, var(--teal) 45%, var(--line));
}

.topbar h1 {
  margin: 0;
  font-size: clamp(1.6rem, 3vw, 2.4rem);
  line-height: 1.1;
}

.top-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

.dashboard-grid {
  display: grid;
  grid-template-columns: minmax(0, 0.92fr) minmax(320px, 0.56fr);
  gap: 18px;
  align-items: start;
}

.board-feed-layout {
  display: grid;
  gap: 18px;
}

.lecture-page {
  display: grid;
  gap: 18px;
}

.lecture-hero {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  border: 1px solid rgba(15, 118, 110, 0.2);
  border-radius: var(--radius);
  background:
    linear-gradient(135deg, color-mix(in srgb, var(--surface) 94%, transparent), color-mix(in srgb, var(--soft) 92%, transparent)),
    linear-gradient(90deg, rgba(15, 118, 110, 0.14), rgba(37, 99, 235, 0.1));
  box-shadow: var(--shadow);
  padding: clamp(16px, 3vw, 26px);
}

.lecture-title-block {
  display: grid;
  gap: 10px;
  min-width: 0;
}

.lecture-title-block h1 {
  max-width: 920px;
  margin: 0;
  font-size: clamp(1.7rem, 4vw, 3.1rem);
  line-height: 1.05;
}

.plus-button {
  flex: 0 0 auto;
  width: 58px;
  min-width: 58px;
  height: 58px;
  border-radius: 50%;
  padding: 0;
  font-size: 2.1rem;
  line-height: 1;
}

.lecture-tools {
  grid-template-columns: minmax(0, 1fr);
}

.panel {
  padding: 18px;
}

.panel-header {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.panel-title {
  display: grid;
  gap: 5px;
}

.panel-title p {
  margin: 0;
  color: var(--muted);
  line-height: 1.45;
}

.stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 18px;
}

.stat {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  padding: 12px;
}

.stat b {
  display: block;
  font-size: 1.55rem;
}

.stat span {
  color: var(--muted);
  font-size: 0.85rem;
}

.progress-track {
  overflow: hidden;
  height: 10px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--line) 72%, var(--surface));
}

.progress-fill {
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--teal), var(--amber));
}

.course-switch {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 12px;
}

.pill {
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--muted);
  padding: 0 12px;
  font-weight: 800;
}

.pill.active {
  border-color: color-mix(in srgb, var(--teal) 36%, var(--line));
  background: color-mix(in srgb, var(--teal) 16%, var(--surface));
  color: var(--teal-ink);
}

.lecture-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 10px;
}

.lecture-card {
  box-shadow: none;
  padding: 12px;
  text-align: left;
}

.lecture-card.active {
  border-color: color-mix(in srgb, var(--teal) 58%, var(--line));
  background: color-mix(in srgb, var(--teal) 10%, var(--surface));
}

.lecture-card b {
  display: block;
  margin-bottom: 6px;
  line-height: 1.25;
}

.lecture-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.tag {
  display: inline-flex;
  min-height: 24px;
  align-items: center;
  border-radius: 999px;
  background: color-mix(in srgb, var(--line) 55%, var(--surface));
  color: var(--muted);
  padding: 0 8px;
  font-size: 0.78rem;
  font-weight: 800;
}

.tag.hot {
  background: color-mix(in srgb, var(--amber) 20%, var(--surface));
  color: var(--amber);
}

.tag.done {
  background: color-mix(in srgb, var(--teal) 18%, var(--surface));
  color: var(--teal-ink);
}

.note-form {
  display: grid;
  gap: 12px;
}

.form-actions,
.note-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.form-actions {
  align-items: center;
}

.note-actions {
  justify-content: flex-end;
  margin-top: 12px;
}

.two-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.file-zone {
  border: 1px dashed color-mix(in srgb, var(--line) 70%, var(--muted));
  border-radius: var(--radius);
  background: color-mix(in srgb, var(--soft) 72%, var(--surface));
  padding: 12px;
}

.file-zone input {
  width: 100%;
}

.preview-img,
.note-img {
  display: block;
  max-width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  object-fit: cover;
}

.preview-img {
  max-height: 220px;
  margin-top: 10px;
}

.feed {
  display: grid;
  gap: 10px;
}

.feed-tools {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(160px, 220px);
  gap: 10px;
  margin-bottom: 12px;
}

.note-card {
  box-shadow: none;
  padding: 14px;
}

.note-head {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}

.note-title {
  display: grid;
  gap: 4px;
}

.note-title b {
  line-height: 1.25;
}

.note-meta {
  color: var(--muted);
  font-size: 0.84rem;
}

.note-body {
  margin: 0 0 10px;
  white-space: pre-wrap;
  line-height: 1.62;
}

.bidi,
[dir="auto"] {
  unicode-bidi: plaintext;
}

.empty {
  border: 1px dashed color-mix(in srgb, var(--line) 70%, var(--muted));
  border-radius: var(--radius);
  background: color-mix(in srgb, var(--soft) 72%, var(--surface));
  padding: 18px;
  color: var(--muted);
  text-align: center;
}

.admin-grid {
  display: grid;
  grid-template-columns: minmax(300px, 0.58fr) minmax(0, 1fr);
  gap: 18px;
  align-items: start;
}

.admin-list {
  display: grid;
  gap: 10px;
}

.admin-row {
  box-shadow: none;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  padding: 12px;
}

.admin-row code {
  word-break: break-all;
}

.row-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  justify-content: flex-end;
}

.mini-button {
  min-height: 32px;
  border-radius: 6px;
  background: color-mix(in srgb, var(--line) 55%, var(--surface));
  color: var(--ink);
  padding: 0 10px;
  font-weight: 800;
}

.mini-button.danger {
  background: color-mix(in srgb, var(--rose) 18%, var(--surface));
  color: var(--rose);
}

.mini-button.ok {
  background: color-mix(in srgb, var(--teal) 18%, var(--surface));
  color: var(--teal-ink);
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 20;
  max-width: min(420px, calc(100vw - 36px));
  border: 1px solid rgba(15, 118, 110, 0.28);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
  color: var(--teal-ink);
  padding: 12px 14px;
  font-weight: 800;
}

@media (max-width: 980px) {
  .gate,
  .dashboard-grid,
  .admin-grid {
    grid-template-columns: 1fr;
  }

  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    height: auto;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .sidebar-nav-area {
    max-height: 390px;
  }

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

  .sidebar-footer {
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
  }
}

@media (max-width: 680px) {
  .gate {
    width: min(100% - 22px, 1180px);
  }

  .main {
    padding: 14px;
  }

  .topbar,
  .panel-header,
  .note-head,
  .admin-row,
  .lecture-hero {
    display: grid;
  }

  .plus-button {
    width: 52px;
    min-width: 52px;
    height: 52px;
  }

  .stats,
  .two-col,
  .feed-tools {
    grid-template-columns: 1fr;
  }

  .nav-stack,
  .sidebar-footer {
    grid-template-columns: 1fr;
  }

  .course-lecture-link span {
    white-space: normal;
  }

  .gate-card,
  .panel {
    padding: 14px;
  }
}
