:root {
    --bg: #f7f8fb;
    --card: #ffffff;
    --text: #1b1f2a;
    --muted: #6b7280;
    --primary: #2563eb;
    --primary-dark: #1d4ed8;
    --danger: #dc2626;
    --success: #16a34a;
    --border: #e5e7eb;
    --badge-bg: #eef2ff;
    --badge-text: #3730a3;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ===== Navbar ===== */
.navbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 28px;
    background: #fff;
    border-bottom: 1px solid var(--border);
}
.navbar .brand {
    font-weight: 700;
    font-size: 1.2rem;
    color: var(--text);
}
.navbar .nav-links a {
    margin-right: 18px;
    color: var(--text);
}
.navbar .nav-auth a { margin-left: 12px; }

/* ===== Layout ===== */
.container {
    max-width: 1080px;
    margin: 32px auto;
    padding: 0 24px;
}
.container.narrow { max-width: 540px; }

.page-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 18px;
}

.hero { text-align: center; padding-top: 60px; }
.hero h1 { font-size: 2.6rem; margin-bottom: 8px; }
.hero .lead { color: var(--muted); font-size: 1.15rem; }
.cta { margin: 28px 0 50px; display: flex; gap: 12px; justify-content: center; }

.subjects {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 16px;
    text-align: left;
}
.subject-card {
    background: #fff;
    border: 1px solid var(--border);
    padding: 16px;
    border-radius: 10px;
}

/* ===== Cards / forms ===== */
.card {
    background: var(--card);
    padding: 24px;
    border-radius: 10px;
    border: 1px solid var(--border);
    margin-bottom: 20px;
}
.card label {
    display: block;
    margin-bottom: 14px;
    font-weight: 500;
}
.card label.inline {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: normal;
}
.card input[type=text],
.card input[type=email],
.card input[type=password],
.card input[type=url],
.card input[type=number],
.card input[type=datetime-local],
.card textarea,
.card select {
    display: block;
    width: 100%;
    margin-top: 6px;
    padding: 10px;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 1rem;
    font-family: inherit;
}
.field-error { display: block; color: var(--danger); font-size: 0.85rem; margin-top: 4px; }

/* ===== Buttons ===== */
.btn {
    display: inline-block;
    padding: 8px 16px;
    border: 1px solid var(--border);
    background: #fff;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.95rem;
    color: var(--text);
    text-decoration: none;
}
.btn:hover { background: #f3f4f6; text-decoration: none; }
.btn-primary {
    background: var(--primary);
    color: #fff;
    border-color: var(--primary);
}
.btn-primary:hover { background: var(--primary-dark); }
.btn-danger {
    background: #fff;
    color: var(--danger);
    border-color: var(--danger);
}
.btn-danger:hover { background: #fef2f2; }
.link-btn {
    background: none;
    border: none;
    color: var(--primary);
    cursor: pointer;
    padding: 0;
    font-size: inherit;
    font-family: inherit;
}

/* ===== Alerts ===== */
.alert {
    padding: 10px 14px;
    border-radius: 6px;
    margin-bottom: 16px;
}
.alert-error   { background: #fef2f2; color: #991b1b; border: 1px solid #fecaca; }
.alert-success { background: #f0fdf4; color: #166534; border: 1px solid #bbf7d0; }

/* ===== Badge ===== */
.badge {
    display: inline-block;
    padding: 2px 8px;
    background: var(--badge-bg);
    color: var(--badge-text);
    border-radius: 999px;
    font-size: 0.78rem;
    font-weight: 600;
}
.badge-success { background: #dcfce7; color: #166534; }
.badge-info    { background: #dbeafe; color: #1e40af; }
.badge-muted   { background: #f3f4f6; color: #6b7280; }

.muted { color: var(--muted); }
.empty { color: var(--muted); font-style: italic; margin: 24px 0; }

/* ===== Table ===== */
.table {
    width: 100%;
    border-collapse: collapse;
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 10px;
    overflow: hidden;
}
.table th, .table td {
    padding: 12px 14px;
    text-align: left;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}
.table th { background: #f9fafb; font-size: 0.85rem; text-transform: uppercase; color: var(--muted); }
.table tr:last-child td { border-bottom: none; }

/* ===== Video grid ===== */
.grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 18px;
}
.video-card {
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 10px;
    overflow: hidden;
    color: var(--text);
    text-decoration: none;
    transition: transform 0.12s;
}
.video-card:hover { transform: translateY(-2px); text-decoration: none; }
.video-card .thumb {
    aspect-ratio: 16/9;
    background: #1b1f2a center/cover no-repeat;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 600;
}
.video-card .card-body { padding: 14px; }
.video-card h3 { margin: 6px 0 4px; font-size: 1.05rem; }

/* ===== Video detail ===== */
.video-frame {
    position: relative;
    aspect-ratio: 16/9;
    background: #000;
    margin: 16px 0 24px;
    border-radius: 10px;
    overflow: hidden;
}
.video-frame iframe {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    border: none;
}
.back-link { display: inline-block; margin-bottom: 8px; color: var(--muted); }

/* ===== Stats ===== */
.stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 16px;
    margin-top: 20px;
}
.stat {
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 22px;
    text-align: center;
}
.stat h2 { font-size: 2.2rem; margin: 0; color: var(--primary); }

/* ===== Homework answer block ===== */
.answer {
    background: #f9fafb;
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 10px;
    white-space: pre-wrap;
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: 0.9rem;
}

/* ===== Filter bar ===== */
.filter-bar {
    margin: 16px 0;
    padding: 12px 16px;
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 10px;
}
.filter-bar select {
    padding: 6px 10px;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 0.95rem;
}

/* ===== Footer ===== */
.footer {
    text-align: center;
    padding: 24px;
    color: var(--muted);
    font-size: 0.9rem;
}
