:root {
  --bg: #f4f7fb;
  --panel: #ffffff;
  --line: #d7dfeb;
  --text: #1e293b;
  --muted: #64748b;
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --danger: #dc2626;
  --success: #16a34a;
  --shadow: 0 18px 40px rgba(15, 23, 42, 0.08);
  --radius: 18px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; font-family: Inter, Arial, sans-serif; background: var(--bg); color: var(--text); }
a { color: inherit; text-decoration: none; }
img { max-width: 100%; display: block; }
button, input, textarea, select { font: inherit; }

.container { width: min(1180px, calc(100% - 32px)); margin: 0 auto; }
.page-section { padding: 32px 0 56px; }
.topbar { background: #0f172a; color: #fff; position: sticky; top: 0; z-index: 10; box-shadow: 0 8px 24px rgba(15, 23, 42, 0.28); }
.topbar-inner { display: flex; align-items: center; justify-content: space-between; gap: 24px; padding: 18px 0; }
.brand { font-size: 1.25rem; font-weight: 800; color: #fff; }
.subtitle { color: rgba(255,255,255,0.72); font-size: .95rem; margin-top: 4px; }
.topbar-nav { display: flex; gap: 12px; flex-wrap: wrap; }
.topbar-nav a { color: #fff; opacity: .92; padding: 10px 14px; border-radius: 999px; background: rgba(255,255,255,0.08); }
.hero-card, .admin-form, .auth-card, .viewer-card, .accordion-card, .card, .stat-card, .empty-state { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.hero-card { padding: 28px; display: flex; align-items: center; justify-content: space-between; gap: 24px; margin-bottom: 28px; }
.hero-card.slim { display: block; }
.eyebrow { display: inline-flex; font-size: .82rem; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; color: var(--primary); margin-bottom: 8px; }
h1, h2, h3 { margin: 0 0 10px; line-height: 1.15; }
p { margin: 0; line-height: 1.6; color: var(--muted); }
.section-header { display: flex; justify-content: space-between; gap: 20px; align-items: end; margin-bottom: 18px; }
.card-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 18px; }
.card-body, .card-footer, .accordion-header, .accordion-body, .stat-card, .empty-state { padding: 22px; }
.course-card .card-footer { border-top: 1px solid var(--line); }
.spaced, .meta-line, .actions-cell, .field-row, .form-actions, .viewer-controls, .audio-box { display: flex; gap: 12px; align-items: center; }
.spaced { justify-content: space-between; }
.meta-line { color: var(--muted); flex-wrap: wrap; }
.button { border: none; cursor: pointer; padding: 12px 18px; border-radius: 12px; font-weight: 700; display: inline-flex; align-items: center; justify-content: center; gap: 8px; }
.button.small { padding: 8px 12px; font-size: .92rem; }
.button.full { width: 100%; }
.button-primary { background: var(--primary); color: #fff; }
.button-primary:hover { background: var(--primary-dark); }
.button-secondary { background: #e8eefb; color: var(--text); }
.button-danger { background: #fee2e2; color: var(--danger); }
.pill { display: inline-flex; align-items: center; font-size: .78rem; padding: 6px 10px; background: #dbeafe; color: #1d4ed8; border-radius: 999px; font-weight: 700; margin-bottom: 12px; }
.accordion-list, .admin-section { display: grid; gap: 18px; }
.lesson-list { display: grid; gap: 12px; }
.lesson-item { border: 1px solid var(--line); border-radius: 16px; padding: 16px; display: flex; justify-content: space-between; gap: 16px; align-items: center; }
.viewer-card { padding: 20px; display: grid; gap: 18px; }
.viewer-frame { background: #eef2f7; border-radius: 18px; min-height: 320px; display: flex; align-items: center; justify-content: center; padding: 12px; }
.viewer-frame img { max-height: 70vh; width: auto; border-radius: 10px; box-shadow: 0 12px 24px rgba(0,0,0,.08); }
.viewer-controls { justify-content: space-between; flex-wrap: wrap; }
.viewer-status { display: grid; gap: 4px; text-align: center; }
.slide-content-box { border: 1px solid var(--line); border-radius: 16px; padding: 20px; background: #fcfdff; }
.slide-text { margin-top: 12px; line-height: 1.8; font-size: 1.02rem; }
.audio-box { margin-top: 18px; flex-wrap: wrap; }
.audio-box audio { width: min(100%, 460px); }
.thumb-track { display: grid; grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); gap: 12px; }
.thumb-button { border: 2px solid transparent; background: #fff; border-radius: 14px; padding: 8px; cursor: pointer; display: grid; gap: 8px; }
.thumb-button.is-active { border-color: var(--primary); box-shadow: 0 10px 24px rgba(37, 99, 235, .18); }
.thumb-button img { width: 100%; aspect-ratio: 16/9; object-fit: cover; border-radius: 8px; }
.breadcrumb { display: flex; gap: 8px; color: var(--muted); margin-bottom: 18px; flex-wrap: wrap; }
.flash { padding: 14px 18px; border-radius: 14px; margin-bottom: 18px; border: 1px solid transparent; }
.flash-success { background: #dcfce7; border-color: #86efac; color: #166534; }
.flash-error { background: #fee2e2; border-color: #fca5a5; color: #991b1b; }
.auth-wrapper { display: flex; justify-content: center; }
.auth-card { width: min(100%, 460px); padding: 28px; display: grid; gap: 16px; }
.auth-card.wide, .admin-form { width: min(100%, 860px); }
.form-page .admin-form { padding: 28px; display: grid; gap: 18px; }
.field { display: grid; gap: 8px; }
.field span { font-weight: 700; }
.field input, .field textarea, .field select { padding: 13px 14px; border: 1px solid var(--line); border-radius: 12px; background: #fff; }
.checkbox-field { display: flex; align-items: center; gap: 10px; padding-top: 28px; }
.checkbox-field input { width: 18px; height: 18px; }
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 16px; margin-bottom: 24px; }
.stat-card { text-align: center; }
.stat-card span { color: var(--muted); display: block; margin-bottom: 10px; }
.stat-card strong { font-size: 2rem; }
.table-wrap { overflow: auto; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.admin-table { width: 100%; border-collapse: collapse; min-width: 760px; }
.admin-table th, .admin-table td { padding: 16px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
.admin-table th { background: #f8fafc; font-size: .92rem; color: var(--muted); }
.actions-cell { flex-wrap: wrap; }
.media-preview img { max-width: 320px; border-radius: 12px; border: 1px solid var(--line); }
.audio-preview audio { width: min(100%, 420px); }
.muted { color: var(--muted); }
.empty-state { padding: 28px; text-align: center; }

@media (max-width: 780px) {
  .hero-card, .section-header, .topbar-inner, .viewer-controls, .field-row, .form-actions, .lesson-item { flex-direction: column; align-items: stretch; }
  .topbar-nav { width: 100%; }
  .topbar-nav a { text-align: center; flex: 1 1 auto; }
  .container { width: min(100% - 20px, 1180px); }
}
