:root {
  --bg: #121418;
  --surface: #191c22;
  --surface-2: #21252d;
  --border: #2c313b;
  --text: #e6e1d6;
  --muted: #989389;
  --accent: #c9a25e;
  --accent-hover: #d8b574;
  --green: #34d399;
  --red: #f87171;
  --serif: Georgia, 'Times New Roman', serif;
  --sans: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--sans);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

.hidden { display: none !important; }

.topbar {
  height: 54px;
  padding: 0 24px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 20;
}

.brand-name {
  font-family: var(--serif);
  font-weight: 700;
  font-size: 1.25rem;
  letter-spacing: 0.02em;
  color: var(--accent);
}

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

.progress-pill {
  font-family: var(--mono);
  font-size: 0.78rem;
  color: var(--muted);
  background: var(--bg);
  border: 1px solid var(--border);
  padding: 4px 10px;
  border-radius: 4px;
}

.nav-btn, .btn {
  font-family: inherit;
  font-size: 0.84rem;
  font-weight: 600;
  color: var(--text);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 6px 13px;
  text-decoration: none;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, transform 0.1s ease;
}

.nav-btn:hover, .btn:hover:not(:disabled) {
  background: #292e38;
  border-color: #464d5c;
}

.btn:active:not(:disabled) {
  transform: translateY(1px);
}

.btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.btn-emerald {
  background: var(--accent);
  border-color: var(--accent);
  color: #14120e;
}

.btn-emerald:hover:not(:disabled) {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
}

.btn-danger {
  color: var(--red);
  border-color: rgba(248, 113, 113, 0.35);
}

/* Classic Two-Column Course Layout */
.layout {
  display: grid;
  grid-template-columns: 300px 1fr;
  max-width: 1260px;
  margin: 0 auto;
  min-height: calc(100vh - 54px);
  border-left: 1px solid var(--border);
  border-right: 1px solid var(--border);
  background: var(--surface);
}

.sidebar {
  background: #15181d;
  border-right: 1px solid var(--border);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.course-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.course-tab {
  font-family: inherit;
  font-size: 0.78rem;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 4px;
  background: var(--surface);
  color: var(--muted);
  border: 1px solid var(--border);
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}

.course-tab:hover {
  color: var(--text);
  border-color: #464d5c;
}

.course-tab.active {
  background: rgba(201, 162, 94, 0.14);
  color: var(--accent);
  border-color: var(--accent);
}

.search-box, .form-input, .form-textarea {
  width: 100%;
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 9px 11px;
  font-family: inherit;
  font-size: 0.86rem;
  transition: border-color 0.15s;
}

.search-box:focus, .form-input:focus, .form-textarea:focus {
  outline: none;
  border-color: var(--accent);
}

.lesson-nav {
  display: flex;
  flex-direction: column;
  gap: 14px;
  overflow-y: auto;
}

.topic-group {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.topic-heading {
  font-family: var(--serif);
  font-size: 0.84rem;
  font-weight: 700;
  color: var(--muted);
  border-bottom: 1px solid var(--border);
  padding: 4px 4px;
  margin-bottom: 2px;
}

.lesson-item {
  width: 100%;
  text-align: left;
  background: transparent;
  border: none;
  border-left: 2px solid transparent;
  color: #cbd5e1;
  padding: 7px 10px;
  font-family: inherit;
  font-size: 0.86rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  border-radius: 0 4px 4px 0;
  transition: background 0.14s, color 0.14s;
}

.lesson-item:hover {
  background: var(--surface-2);
  color: #ffffff;
}

.lesson-item.active {
  background: var(--surface-2);
  border-left-color: var(--accent);
  color: var(--accent);
  font-weight: 600;
}

.check-dot {
  font-size: 0.78rem;
  color: var(--green);
  font-weight: 700;
}

/* Main Content Stage */
.content {
  padding: 26px 30px;
  width: 100%;
}

.empty-stage {
  border: 1px solid var(--border);
  background: var(--bg);
  border-radius: 6px;
  padding: 48px 24px;
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.empty-stage h2 { font-family: var(--serif); color: var(--text); }
.empty-stage p { color: var(--muted); }
.empty-stage a { color: var(--accent); }
.empty-note { font-size: 0.85rem; color: var(--muted); padding: 6px; }

.lesson-view {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.video-frame {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  background: #000;
  border: 1px solid var(--border);
  border-radius: 6px;
  overflow: hidden;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.4);
}

.video-frame iframe {
  width: 100%;
  height: 100%;
  border: none;
}

.lesson-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 14px;
  border-bottom: 1px solid var(--border);
  padding-bottom: 14px;
}

.topic-badge {
  display: inline-block;
  font-size: 0.76rem;
  font-weight: 600;
  color: var(--accent);
  margin-bottom: 4px;
}

.lesson-header h1 {
  font-family: var(--serif);
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text);
}

.lesson-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

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

.note-card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.note-card h3 {
  font-family: var(--serif);
  font-size: 0.94rem;
  color: var(--accent);
  border-bottom: 1px solid var(--border);
  padding-bottom: 5px;
}

.note-card pre {
  font-family: var(--mono);
  font-size: 0.84rem;
  line-height: 1.55;
  white-space: pre-wrap;
  color: #e2e8f0;
}

.note-card p {
  font-size: 0.9rem;
  line-height: 1.6;
  white-space: pre-wrap;
  color: #cbd5e1;
}

/* Admin Panel */
.admin-wrap {
  max-width: 820px;
  margin: 26px auto;
  padding: 0 18px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.panel-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 22px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.panel-card h2 {
  font-family: var(--serif);
  font-size: 1.2rem;
  color: var(--accent);
  border-bottom: 1px solid var(--border);
  padding-bottom: 8px;
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.form-field {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.form-field.full { grid-column: 1 / -1; }

.form-field label {
  font-size: 0.78rem;
  color: var(--muted);
  font-weight: 600;
}

.err-text { font-size: 0.85rem; color: var(--red); }
.ok-text { font-size: 0.85rem; color: var(--green); }

.admin-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.admin-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 11px 13px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 4px;
}

.admin-row-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.admin-row-meta {
  font-size: 0.76rem;
  color: var(--muted);
}

.admin-row-actions {
  display: flex;
  gap: 6px;
}

@media (max-width: 820px) {
  .topbar { padding: 0 12px; }
  .layout { grid-template-columns: 1fr; border-left: none; border-right: none; }
  .content { order: -1; padding: 14px; }
  .sidebar {
    border-right: none;
    border-top: 1px solid var(--border);
    max-height: none;
  }
  .lesson-item { min-height: 42px; padding: 9px 10px; }
  .btn, .nav-btn, .course-tab { min-height: 36px; }
  .search-box, .form-input, .form-textarea { font-size: 16px; }
  .lesson-header h1 { font-size: 1.2rem; }
  .form-grid { grid-template-columns: 1fr; }
  .admin-row { flex-direction: column; align-items: flex-start; }
  .admin-row-actions { width: 100%; justify-content: flex-end; }
}
