:root {
    --font-sans: Inter, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    --radius-sm: 10px;
    --radius-md: 16px;
    --radius-lg: 24px;
    --shadow-sm: 0 4px 16px rgba(15, 23, 42, 0.08);
    --shadow-md: 0 18px 40px rgba(15, 23, 42, 0.16);
    --transition: 180ms ease;
}

:root,
html[data-theme="dark"] {
    --bg: #0b1120;
    --bg-soft: #111827;
    --panel: rgba(15, 23, 42, 0.92);
    --panel-2: #182235;
    --surface: #111b2e;
    --surface-2: #1d2b45;
    --surface-3: #243552;
    --text: #f8fafc;
    --muted: #94a3b8;
    --border: rgba(148, 163, 184, 0.18);
    --border-strong: rgba(148, 163, 184, 0.28);
    --accent: #3b82f6;
    --accent-strong: #2563eb;
    --accent-soft: rgba(59, 130, 246, 0.16);
    --success-bg: rgba(22, 101, 52, 0.22);
    --success-text: #bbf7d0;
    --warning-bg: rgba(120, 53, 15, 0.24);
    --warning-text: #fed7aa;
    --danger-bg: rgba(153, 27, 27, 0.22);
    --danger-text: #fecaca;
    --body-gradient: radial-gradient(circle at top left, rgba(37, 99, 235, 0.18), transparent 28%), linear-gradient(180deg, #09101d 0%, #0b1120 100%);
}

html[data-theme="light"] {
    --bg: #f3f7fb;
    --bg-soft: #ffffff;
    --panel: rgba(255, 255, 255, 0.94);
    --panel-2: #ffffff;
    --surface: #ffffff;
    --surface-2: #eef4ff;
    --surface-3: #e3ecff;
    --text: #0f172a;
    --muted: #475569;
    --border: rgba(15, 23, 42, 0.12);
    --border-strong: rgba(15, 23, 42, 0.18);
    --accent: #2563eb;
    --accent-strong: #1d4ed8;
    --accent-soft: rgba(37, 99, 235, 0.10);
    --success-bg: rgba(34, 197, 94, 0.12);
    --success-text: #166534;
    --warning-bg: rgba(245, 158, 11, 0.16);
    --warning-text: #92400e;
    --danger-bg: rgba(239, 68, 68, 0.12);
    --danger-text: #991b1b;
    --body-gradient: radial-gradient(circle at top left, rgba(37, 99, 235, 0.12), transparent 24%), linear-gradient(180deg, #f8fbff 0%, #eef5fb 100%);
    --shadow-sm: 0 8px 24px rgba(15, 23, 42, 0.06);
    --shadow-md: 0 24px 48px rgba(15, 23, 42, 0.10);
}

* { box-sizing: border-box; }
html { min-height: 100%; }
body {
    margin: 0;
    min-height: 100vh;
    font-family: var(--font-sans);
    background: var(--body-gradient);
    color: var(--text);
}

a {
    color: inherit;
}

img {
    max-width: 100%;
}

.container {
    width: min(1180px, calc(100% - 32px));
    margin: 0 auto;
}

.topbar {
    position: sticky;
    top: 0;
    z-index: 30;
    backdrop-filter: blur(12px);
    background: color-mix(in srgb, var(--panel) 84%, transparent);
    border-bottom: 1px solid var(--border);
}

.topbar-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-height: 72px;
    gap: 20px;
}

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

.brand-mark {
    width: 42px;
    height: 42px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 14px;
    background: linear-gradient(135deg, var(--accent), var(--accent-strong));
    color: #fff;
    font-weight: 800;
    box-shadow: var(--shadow-sm);
}

.brand-meta {
    display: grid;
    gap: 2px;
}

.brand {
    color: var(--text);
    text-decoration: none;
    font-weight: 700;
    font-size: 1.05rem;
}

.brand-subtitle {
    color: var(--muted);
    font-size: 0.82rem;
}

.nav {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.nav a,
.user-info,
.link-button,
.theme-chip {
    color: var(--muted);
    text-decoration: none;
    font-size: 0.95rem;
}

.nav a,
.theme-chip {
    padding: 10px 14px;
    border-radius: 999px;
    transition: background-color var(--transition), color var(--transition), border-color var(--transition);
    border: 1px solid transparent;
}

.nav a:hover,
.nav a.active,
.theme-chip {
    background: var(--accent-soft);
    color: var(--text);
    border-color: color-mix(in srgb, var(--accent) 24%, transparent);
}

.theme-chip {
    cursor: default;
}

.link-button {
    background: transparent;
    border: 0;
    cursor: pointer;
    padding: 0;
}

.inline-form { display: inline; }
.page-content { padding: 32px 0 56px; }

.hero,
.card,
.card-link,
.form-card,
.metric-card,
.panel-card,
.sidebar-card,
.empty-state {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
}

.hero {
    padding: 40px;
    background: linear-gradient(135deg, color-mix(in srgb, var(--accent) 12%, var(--panel)) 0%, var(--panel) 100%);
}

.hero h1 {
    margin-top: 0;
    margin-bottom: 14px;
    font-size: clamp(2rem, 3.4vw, 3rem);
}

.hero p {
    max-width: 720px;
    color: var(--muted);
    font-size: 1.03rem;
    line-height: 1.7;
}

.hero-actions {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    margin-top: 22px;
}

.card,
.form-card,
.panel-card,
.sidebar-card,
.empty-state {
    padding: 24px;
}

.card-link {
    display: block;
    padding: 24px;
    color: inherit;
    text-decoration: none;
    transition: transform var(--transition), border-color var(--transition), background-color var(--transition);
}

.card-link:hover {
    transform: translateY(-2px);
    border-color: color-mix(in srgb, var(--accent) 30%, var(--border));
    background: color-mix(in srgb, var(--accent-soft) 40%, var(--panel));
}

.page-header {
    margin-bottom: 24px;
}

.page-header h1,
.page-header h2,
.panel-heading h2,
.section-title {
    margin: 0 0 8px;
}

.page-header p,
.panel-heading p,
.muted,
.helper-text,
.empty-state p,
.section-caption {
    color: var(--muted);
    line-height: 1.65;
}

.header-actions,
.stack-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
}

.card-grid,
.metric-grid,
.action-grid {
    display: grid;
    gap: 16px;
}

.card-grid { grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }
.metric-grid { grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }
.action-grid { grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }

.metric-card {
    padding: 20px;
}

.metric-label {
    font-size: 0.86rem;
    color: var(--muted);
    margin-bottom: 8px;
}

.metric-value {
    font-size: 1.8rem;
    font-weight: 700;
}

.button-row,
.form-row,
.inline-actions {
    display: flex;
    gap: 16px;
    flex-wrap: wrap;
}

.form-row > .form-group {
    flex: 1 1 280px;
}

.button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 44px;
    padding: 0 18px;
    border-radius: 12px;
    border: 1px solid transparent;
    text-decoration: none;
    cursor: pointer;
    transition: transform var(--transition), background-color var(--transition), border-color var(--transition);
    font-weight: 600;
}

.button:hover {
    transform: translateY(-1px);
}

.button.primary {
    background: linear-gradient(135deg, var(--accent), var(--accent-strong));
    color: white;
}

.button.primary:hover { filter: brightness(1.03); }

.button.secondary {
    background: transparent;
    color: var(--text);
    border-color: var(--border-strong);
}

.button.secondary:hover {
    background: var(--surface-2);
}

.button.ghost {
    background: var(--accent-soft);
    color: var(--text);
}

.form-group {
    margin-bottom: 18px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    color: var(--muted);
    font-weight: 600;
}

.form-control {
    width: 100%;
    min-height: 46px;
    border-radius: 12px;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text);
    padding: 11px 14px;
    outline: none;
    transition: border-color var(--transition), box-shadow var(--transition), background-color var(--transition);
}

.form-control:focus {
    border-color: color-mix(in srgb, var(--accent) 60%, var(--border));
    box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 18%, transparent);
}

textarea.form-control { min-height: 128px; resize: vertical; }

.validation-summary,
.field-validation {
    color: #fca5a5;
    display: block;
    margin-top: 6px;
}

.alert {
    padding: 14px 16px;
    border-radius: 14px;
    margin-bottom: 20px;
    border: 1px solid transparent;
}

.alert-success {
    background: var(--success-bg);
    color: var(--success-text);
    border-color: color-mix(in srgb, var(--success-text) 18%, transparent);
}

.alert-warning {
    background: var(--warning-bg);
    color: var(--warning-text);
}

.alert-danger {
    background: var(--danger-bg);
    color: var(--danger-text);
}

.badge,
.status-badge {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    min-height: 30px;
    padding: 0 12px;
    border-radius: 999px;
    border: 1px solid var(--border);
    background: var(--surface-2);
    font-size: 0.85rem;
    color: var(--text);
}

.status-badge.draft,
.status-badge.private {
    background: var(--warning-bg);
    color: var(--warning-text);
}

.status-badge.published,
.status-badge.public {
    background: var(--success-bg);
    color: var(--success-text);
}

.status-badge.unlisted {
    background: var(--accent-soft);
    color: var(--text);
}

.table-wrap {
    overflow-x: auto;
}

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

.table th,
.table td {
    padding: 14px 12px;
    border-bottom: 1px solid var(--border);
    text-align: left;
    vertical-align: top;
}

.table th {
    color: var(--muted);
    font-weight: 600;
    font-size: 0.92rem;
}

.table tbody tr:hover {
    background: color-mix(in srgb, var(--surface-2) 46%, transparent);
}

.table-title {
    font-weight: 600;
    margin-bottom: 4px;
}

.table-subtitle {
    color: var(--muted);
    font-size: 0.9rem;
}

.auth-shell {
    min-height: calc(100vh - 180px);
    display: grid;
    place-items: center;
}

.auth-card {
    width: min(520px, 100%);
}

.management-shell {
    display: grid;
    grid-template-columns: 280px minmax(0, 1fr);
    gap: 24px;
}

.management-sidebar {
    position: sticky;
    top: 96px;
    align-self: start;
}

.management-brand {
    display: grid;
    gap: 6px;
    margin-bottom: 18px;
}

.management-nav {
    display: grid;
    gap: 8px;
}

.management-nav a {
    padding: 12px 14px;
    border-radius: 12px;
    text-decoration: none;
    color: var(--muted);
    border: 1px solid transparent;
    transition: background-color var(--transition), border-color var(--transition), color var(--transition);
}

.management-nav a:hover,
.management-nav a.active {
    color: var(--text);
    background: var(--accent-soft);
    border-color: color-mix(in srgb, var(--accent) 22%, transparent);
}

.management-content {
    min-width: 0;
}

.panel-stack {
    display: grid;
    gap: 18px;
}

.empty-state {
    text-align: center;
    padding: 48px 28px;
}

.empty-state h3 {
    margin-bottom: 10px;
}

.course-card-meta,
.inline-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 14px;
}

.kbd {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 30px;
    height: 30px;
    border-radius: 8px;
    border: 1px solid var(--border-strong);
    background: var(--surface);
    color: var(--muted);
    font-size: 0.85rem;
}

.divider {
    height: 1px;
    background: var(--border);
    margin: 18px 0;
}

@media (max-width: 980px) {
    .management-shell {
        grid-template-columns: 1fr;
    }

    .management-sidebar {
        position: static;
    }
}

@media (max-width: 720px) {
    .topbar-inner,
    .header-actions,
    .stack-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .nav {
        width: 100%;
    }

    .nav a,
    .theme-chip {
        width: 100%;
        justify-content: center;
        text-align: center;
    }

    .hero {
        padding: 28px;
    }
}


.panel-stack {
    display: grid;
    gap: 24px;
}

.detail-grid {
    display: grid;
    grid-template-columns: minmax(0, 1.4fr) minmax(320px, 0.8fr);
    gap: 24px;
}

.stack-panel {
    display: grid;
    gap: 24px;
    align-self: start;
}

.content-tree {
    display: grid;
    gap: 18px;
}

.tree-section {
    display: grid;
    gap: 18px;
    padding: 20px;
}

.tree-section-header,
.tree-lesson-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
}

.tree-section-title,
.tree-lesson-title {
    font-weight: 700;
    margin-bottom: 4px;
}

.tree-section-subtitle,
.tree-lesson-subtitle {
    color: var(--muted);
    font-size: 0.93rem;
}

.tree-lessons {
    display: grid;
    gap: 14px;
}

.tree-lesson {
    padding: 16px;
    border: 1px solid var(--border);
    border-radius: 14px;
    background: color-mix(in srgb, var(--surface-2) 65%, transparent);
    display: grid;
    gap: 14px;
}

.mini-form-shell {
    border-top: 1px solid var(--border);
    padding-top: 14px;
    display: grid;
    gap: 12px;
}

.mini-form-title {
    font-weight: 600;
}

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

.media-chip {
    padding: 12px 14px;
    border-radius: 12px;
    border: 1px solid var(--border);
    background: var(--surface);
}

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

.stack-item {
    display: flex;
    gap: 12px;
    align-items: flex-start;
}

.compact-empty-state {
    text-align: left;
}

.checkbox-group {
    display: flex;
    align-items: end;
}

.checkbox-group label {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    min-height: 46px;
    color: var(--text);
}

@media (max-width: 1100px) {
    .detail-grid {
        grid-template-columns: 1fr;
    }
}


.settings-list {
    display: grid;
    gap: 16px;
}

.compact-card {
    padding: 18px;
}

.setting-row {
    display: flex;
    justify-content: space-between;
    gap: 20px;
    align-items: flex-start;
}

.setting-actions {
    display: flex;
    gap: 12px;
    align-items: center;
    min-width: 340px;
}

@media (max-width: 900px) {
    .setting-row,
    .setting-actions {
        flex-direction: column;
        align-items: stretch;
        min-width: 0;
    }
}


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

.course-card h3 {
    margin-top: 12px;
    margin-bottom: 10px;
}

.video-shell {
    border-radius: 18px;
    overflow: hidden;
    border: 1px solid var(--border-color);
    background: var(--surface-elevated);
    aspect-ratio: 16 / 9;
}

.video-shell iframe {
    width: 100%;
    height: 100%;
    border: 0;
}

.spaced-top {
    margin-top: 18px;
}

.compact-tree .tree-section {
    margin-bottom: 12px;
}

.mini-lesson.active-lesson {
    border: 1px solid var(--primary-color);
    box-shadow: 0 0 0 1px color-mix(in srgb, var(--primary-color) 35%, transparent);
}

.button.danger {
    border-color: color-mix(in srgb, var(--danger-color) 30%, var(--border-color));
    color: var(--danger-color);
}


.progress-shell { margin-top: 1rem; }
.progress-bar { width: 100%; height: 10px; border-radius: 999px; background: rgba(255,255,255,.08); overflow: hidden; }
.progress-bar span { display:block; height:100%; border-radius: 999px; background: linear-gradient(90deg, #5b8cff, #7c5cff); }
.muted-note { color: var(--text-muted, #9aa4b2); font-size: .95rem; }
.course-grid { display:grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 1rem; }
.resource-list { display:grid; gap: .75rem; margin-top: 1rem; }
.resource-item { display:flex; align-items:flex-start; justify-content:space-between; gap: 1rem; }
.compact-metric-grid { margin-bottom: 1rem; }

.comment-form-card {
  margin-top: 1rem;
}

.comment-list {
  display: grid;
  gap: 1rem;
  margin-top: 1rem;
}

.comment-card {
  padding: 1rem 1.1rem;
}

.comment-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .75rem;
  margin-bottom: .5rem;
  font-size: .9rem;
  opacity: .85;
}

.comment-content {
  margin: 0;
  white-space: pre-wrap;
  line-height: 1.6;
}

.stack-form {
  display: grid;
  gap: 1rem;
}

.inline-alert {
  margin-top: .75rem;
}

.compact-input {
  min-width: 14rem;
}

.reject-form {
  display: flex;
  gap: .5rem;
  align-items: center;
  flex-wrap: wrap;
}


.preferences-page {
    max-width: 880px;
}

.theme-picker-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 16px;
}

.theme-option {
    display: flex;
    align-items: center;
    gap: 14px;
    cursor: pointer;
    transition: border-color var(--transition), transform var(--transition), background-color var(--transition);
}

.theme-option:hover {
    transform: translateY(-2px);
    border-color: color-mix(in srgb, var(--accent) 24%, var(--border));
}

.theme-option.selected {
    border-color: color-mix(in srgb, var(--accent) 42%, var(--border));
    background: color-mix(in srgb, var(--accent-soft) 36%, var(--panel));
}

.theme-option input[type="radio"] {
    margin: 0;
}

.theme-swatch {
    width: 56px;
    height: 56px;
    border-radius: 16px;
    border: 1px solid var(--border-strong);
    flex: 0 0 auto;
    box-shadow: var(--shadow-sm);
}

.theme-swatch.dark {
    background: linear-gradient(180deg, #0b1120 0%, #182235 100%);
}

.theme-swatch.light {
    background: linear-gradient(180deg, #ffffff 0%, #e7eefb 100%);
}

.block {
    display: block;
}

.comment-history-actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 20px;
}

.wrap {
    flex-wrap: wrap;
}

@media (max-width: 720px) {
    .comment-history-actions {
        flex-direction: column;
        align-items: stretch;
    }
}
