:root {
    --brand: #7C1623;
    --brand-dark: #5E0F1B;
    --brand-hover: #9C1F30;
    --brand-soft: #FBF1F3;
    --brand-border: #E8CBD4;
    --ink: #1A1D23;
    --text-2: #5B6270;
    --text-3: #8A909E;
    --border: #E7E9EE;
    --border-soft: #F0F1F4;
    --card: #FFFFFF;
    --bg: #F6F7F9;
    --soft: #FAFBFC;
    --success: #1E8449;
    --success-soft: #EAF7EF;
    --warning: #B45309;
    --warning-soft: #FFF4E2;
    --danger: #C0392B;
    --danger-soft: #FDECEC;
    --info: #2D6CDF;
    --info-soft: #EAF2FF;
    --cyan: #0E7490;
    --cyan-soft: #E0F5F7;
    --purple: #6F54D9;
    --purple-soft: #F1EEFF;
    --radius: 14px;
    --radius-sm: 9px;
    --shadow: 0 4px 16px rgba(16, 24, 40, .06);
    --sidebar-w: 232px;
    --ease: cubic-bezier(.2, .8, .2, 1);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-font-smoothing: antialiased; }
body {
    margin: 0;
    background: var(--bg);
    color: var(--ink);
    font: 13.5px/1.45 "Segoe UI", Inter, system-ui, -apple-system, sans-serif;
}
a { color: inherit; text-decoration: none; }
button, input, textarea, select { font: inherit; }
a, button, summary, input, textarea, select, .card, .tag, .topic-node, .tree-nav a, .tree-nav .tree-item, .course-row, .choice-row, .filter-option, .question-help-btn, .question-help-tip, .question-hint-panel, .question-field, .bug-report-fab, .bug-report-fab span, .help-actions, .help-actions button {
    transition:
        background-color .2s var(--ease),
        border-color .2s var(--ease),
        color .2s var(--ease),
        box-shadow .2s var(--ease),
        opacity .2s var(--ease),
        transform .2s var(--ease);
}
button:focus-visible, a:focus-visible, input:focus-visible, textarea:focus-visible, select:focus-visible {
    outline: 2px solid var(--brand);
    outline-offset: 2px;
}

.sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: var(--sidebar-w);
    padding: 18px 14px;
    background: var(--card);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.logo-box { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.logo-mark {
    width: 34px;
    height: 34px;
    border-radius: 10px;
    display: grid;
    place-items: center;
    background: var(--brand);
    color: white;
    font-weight: 800;
}
.logo-box strong { display: block; font-size: 14px; }
.logo-box span { color: var(--brand); font-size: 11.5px; font-weight: 700; }
.sec {
    margin: 16px 8px 5px;
    color: var(--text-3);
    font-size: 10.5px;
    font-weight: 700;
    letter-spacing: .08em;
    text-transform: uppercase;
}
.nav {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 9px 10px;
    border-radius: 10px;
    color: var(--text-2);
    font-weight: 600;
}
.nav:hover { background: var(--soft); color: var(--brand); transform: translateX(2px); }
.nav.active { background: var(--brand-soft); color: var(--brand); }
.nav.active::before {
    content: "";
    position: absolute;
    left: -6px;
    width: 3px;
    height: 18px;
    border-radius: 99px;
    background: var(--brand);
}
.ai-tag {
    padding: 2px 6px;
    border-radius: 99px;
    background: var(--purple-soft);
    color: var(--purple);
    font-size: 10px;
    font-weight: 700;
}
.user-menu {
    position: relative;
    margin-top: auto;
}
.user-menu summary { list-style: none; cursor: pointer; }
.user-menu summary::-webkit-details-marker { display: none; }
.user-box {
    padding: 12px;
    border: 1px solid var(--border-soft);
    border-radius: var(--radius);
    display: flex;
    gap: 10px;
    align-items: center;
}
.user-box:hover {
    border-color: var(--brand-border);
    box-shadow: 0 8px 22px rgba(124, 22, 35, .08);
}
.user-actions {
    display: grid;
    gap: 8px;
    position: absolute;
    left: 0;
    right: 0;
    bottom: calc(100% + 8px);
    padding: 10px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: white;
    box-shadow: 0 14px 36px rgba(16, 24, 40, .14);
    opacity: 0;
    pointer-events: none;
    transform: translateY(8px) scale(.98);
    transform-origin: bottom center;
}
.user-menu[open] .user-actions {
    opacity: 1;
    pointer-events: auto;
    transform: translateY(0) scale(1);
    animation: menu-rise .18s var(--ease);
}
.user-actions .btn { justify-content: center; width: 100%; }
.avatar {
    width: 30px;
    height: 30px;
    border-radius: 99px;
    background: var(--brand);
    color: white;
    display: grid;
    place-items: center;
    font-weight: 800;
}
.user-box strong, .user-box span { display: block; }
.user-box span { color: var(--text-3); font-size: 11px; }

.main { margin-left: var(--sidebar-w); padding: 20px 26px 42px; max-width: 1480px; }
.topbar {
    display: flex;
    justify-content: space-between;
    gap: 18px;
    align-items: center;
    margin-bottom: 18px;
}
.crumb { color: var(--text-3); font-size: 11px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; }
.breadcrumb {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    align-items: center;
}
.breadcrumb a { color: var(--brand); }
.breadcrumb a::after {
    content: "/";
    color: var(--text-3);
    margin-left: 6px;
}
.breadcrumb span { color: var(--text-3); }
.page-tools {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-bottom: 14px;
}
h1 { margin: 2px 0 0; font-size: 19px; letter-spacing: -.01em; }
h2 { margin: 6px 0 8px; font-size: 26px; line-height: 1.12; letter-spacing: -.02em; max-width: 24ch; }
h3 { margin: 0 0 10px; font-size: 13.5px; font-weight: 700; }
p { color: var(--text-2); margin: 0 0 12px; max-width: 72ch; }
.topbar.compact { justify-content: flex-start; }
.top-actions { display: flex; align-items: center; gap: 10px; }
.search {
    min-width: 210px;
    padding: 8px 10px;
    border: 1px solid var(--border);
    border-radius: 10px;
    color: var(--text-3);
    background: var(--card);
}
.kbd { float: right; border: 1px solid var(--border); border-radius: 6px; padding: 0 5px; font-size: 11px; }

.btn {
    border: 1px solid transparent;
    border-radius: 10px;
    padding: 8.5px 15px;
    font-size: 12.5px;
    font-weight: 600;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 7px;
}
.btn:hover { transform: translateY(-1px); box-shadow: 0 8px 18px rgba(16, 24, 40, .08); }
.btn:active { transform: translateY(0); box-shadow: none; }
.btn:disabled {
    cursor: not-allowed;
    opacity: .58;
    box-shadow: none;
    transform: none;
}
.btn-primary { background: var(--brand); color: white; }
.btn-primary:hover { background: var(--brand-hover); }
.btn-ghost { background: white; color: var(--brand); border-color: var(--brand-border); }
.btn-plain { background: white; color: var(--text-2); border-color: var(--border); }
.icon-btn {
    width: 32px;
    height: 32px;
    border-radius: 10px;
    border: 1px solid var(--border);
    background: white;
    color: var(--text-2);
    cursor: pointer;
    font-size: 18px;
    line-height: 1;
}
.icon-btn:hover { border-color: var(--brand-border); color: var(--brand); transform: translateY(-1px); }

.card {
    background: var(--card);
    border: 1px solid var(--border-soft);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 16px;
}
.card:hover { box-shadow: 0 8px 24px rgba(16, 24, 40, .08); }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 10px; flex-wrap: wrap; }
.head-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.more { color: var(--brand); font-weight: 700; font-size: 12px; }
.insight {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
    padding: 22px;
    margin-bottom: 16px;
    background: var(--card);
    border: 1px solid var(--border-soft);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}
.eyebrow { color: var(--brand); font-size: 11px; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; }
.kpi-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 14px; margin-bottom: 16px; }
.kpi span { color: var(--text-2); font-size: 11.5px; }
.kpi strong { display: block; color: var(--brand); font-size: 28px; line-height: 1.1; letter-spacing: -.02em; margin-top: 5px; }
.kpi small { color: var(--text-3); }
.two-col { display: grid; grid-template-columns: minmax(0, 2fr) minmax(280px, 1.1fr); gap: 16px; margin-bottom: 16px; align-items: start; }
.profile-grid { grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); }
.admin-split { grid-template-columns: minmax(0, 1.5fr) minmax(320px, .9fr); }
.module-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 16px; }
.module-card { display: flex; flex-direction: column; min-height: 210px; }
.module-card .btn { margin-top: auto; justify-content: center; }
.course-card { display: flex; flex-direction: column; min-height: 260px; }
.course-card.available {
    background: white;
    border-color: var(--border-soft);
}
.course-card.done {
    background: var(--success-soft);
    border-color: #BFE8CD;
}
.course-card.retry {
    background: var(--warning-soft);
    border-color: #F8D9A8;
}
.course-card.locked {
    background: #F1F3F6;
    border-color: #DDE1E8;
    color: var(--text-3);
}
.course-card.locked:hover {
    box-shadow: var(--shadow);
}
.coming-card {
    filter: grayscale(.25);
}
.course-card .btn { margin-top: auto; justify-content: center; }
.course-layout { grid-template-columns: minmax(0, 2fr) minmax(260px, .8fr); }
.course-road { max-width: none; }
.topic-path {
    display: grid;
    gap: 14px;
    margin-top: 18px;
}
.topic-node {
    position: relative;
    display: grid;
    grid-template-columns: 42px 1fr;
    align-items: center;
    gap: 12px;
    padding: 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: white;
}
.topic-node:hover { border-color: var(--brand-border); transform: translateY(-1px); }
.topic-node::before {
    content: "";
    position: absolute;
    left: 34px;
    top: -14px;
    width: 2px;
    height: 14px;
    background: var(--border);
}
.topic-node:first-child::before { display: none; }
.topic-node span {
    width: 42px;
    height: 42px;
    border-radius: 99px;
    display: grid;
    place-items: center;
    background: var(--brand-soft);
    color: var(--brand);
    font-weight: 800;
}
.topic-node.available {
    background: white;
    border-color: var(--border);
}
.topic-node.done {
    background: var(--success-soft);
    border-color: #BFE8CD;
}
.topic-node.retry,
.topic-node.pending {
    background: var(--warning-soft);
    border-color: #F8D9A8;
}
.topic-node.locked {
    background: #F1F3F6;
    border-color: #DDE1E8;
    color: var(--text-3);
    cursor: not-allowed;
}
.topic-node.locked:hover {
    border-color: #DDE1E8;
    transform: none;
}
.topic-node.done span { background: #DDF2E5; color: var(--success); }
.topic-node.retry span,
.topic-node.pending span { background: #FFE9C2; color: var(--warning); }
.topic-node.locked span { background: #E4E7EC; color: var(--text-3); }
.topic-node strong { display: block; }
.topic-node small { color: var(--text-3); }
.module-num {
    width: 32px;
    height: 32px;
    border-radius: 9px;
    display: grid;
    place-items: center;
    background: var(--brand-soft);
    color: var(--brand);
    font-weight: 800;
    margin-bottom: 12px;
}
.video-placeholder {
    min-height: 260px;
    border: 1px dashed var(--brand-border);
    border-radius: var(--radius);
    background: var(--brand-soft);
    color: var(--brand);
    display: grid;
    place-items: center;
    font-weight: 700;
    margin-bottom: 18px;
}
.video-player-card {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: white;
    overflow: hidden;
    margin-bottom: 18px;
    box-shadow: 0 8px 22px rgba(16, 24, 40, .05);
}
.video-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding: 12px;
    border-bottom: 1px solid var(--border-soft);
    background: var(--soft);
}
.video-tab {
    width: auto;
    border: 1px solid var(--border);
    border-radius: 999px;
    padding: 8px 13px;
    background: white;
    color: var(--text-2);
    font-weight: 800;
    cursor: pointer;
}
.video-tab:hover:not(:disabled) {
    border-color: var(--brand-border);
    color: var(--brand);
    transform: translateY(-1px);
}
.video-tab.active {
    border-color: var(--brand);
    background: var(--brand-soft);
    color: var(--brand);
}
.video-tab:disabled {
    cursor: not-allowed;
    opacity: .48;
}
.video-stage {
    background: #000;
}
.video-frame {
    aspect-ratio: 16 / 9;
    background: var(--soft);
}
.video-frame iframe {
    width: 100%;
    height: 100%;
    border: 0;
    display: block;
    background: #000;
}
.video-rights-list {
    min-height: 0;
}
.video-rights {
    margin: -6px 0 16px;
    padding: 0;
    color: var(--text-3);
    font-size: 12px;
    font-style: italic;
}
.video-rights a {
    color: var(--brand);
    font-weight: 800;
    font-style: italic;
}
.video-rights[hidden] { display: none; }
.video-pane .video-placeholder {
    min-height: 260px;
    margin-bottom: 0;
    border: 0;
    border-radius: 0;
}
.lesson-body {
    color: var(--text-2);
    margin: 0 0 16px;
    max-width: 84ch;
}
.lesson-body p {
    margin: 0 0 14px;
    max-width: none;
}
.lesson-body strong {
    color: var(--ink);
    font-weight: 800;
}
.lesson-body em {
    color: var(--ink);
}
.lesson-body ul,
.lesson-body ol {
    margin: 0 0 16px 20px;
    padding: 0;
    color: var(--ink);
}
.lesson-body li {
    margin: 5px 0;
    padding-left: 3px;
}
.lesson-body hr {
    border: 0;
    border-top: 1px solid var(--border);
    margin: 20px 0;
}
.task-box {
    border-left: 3px solid var(--brand);
    padding: 12px 14px;
    background: var(--soft);
    border-radius: 0 10px 10px 0;
    margin: 16px 0;
}
.timeline { display: grid; gap: 12px; border-left: 1px solid var(--border); padding-left: 14px; margin-bottom: 18px; }
.timeline a, .timeline span { position: relative; color: var(--text-2); font-weight: 600; }
.timeline a:hover { color: var(--brand); transform: translateX(2px); }
.timeline a::before, .timeline span::before {
    content: "";
    position: absolute;
    left: -19px;
    top: 5px;
    width: 8px;
    height: 8px;
    border-radius: 99px;
    background: var(--border);
}
.timeline .hot::before { background: var(--brand); }
.timeline .hot { color: var(--brand); }
.timeline .done-state {
    color: var(--success);
    background: var(--success-soft);
    width: fit-content;
    padding: 4px 8px;
    border-radius: 99px;
}
.timeline .pending-state {
    color: var(--warning);
    background: var(--warning-soft);
    width: fit-content;
    padding: 4px 8px;
    border-radius: 99px;
}
.timeline .done-state::before { background: var(--success); }
.timeline .pending-state::before { background: var(--warning); }
.tree-title { margin-top: 16px; }
.tree-nav { display: grid; gap: 8px; }
.tree-nav a,
.tree-nav .tree-item {
    display: grid;
    grid-template-columns: 26px 1fr;
    gap: 8px;
    align-items: center;
    padding: 9px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: white;
    color: var(--text-2);
}
.tree-nav a:hover { border-color: var(--brand-border); color: var(--brand); }
.tree-nav .tree-root {
    display: block;
    font-weight: 800;
    color: var(--brand);
    background: var(--brand-soft);
    border-color: var(--brand-border);
}
.tree-nav a span,
.tree-nav .tree-item span {
    width: 26px;
    height: 26px;
    border-radius: 99px;
    display: grid;
    place-items: center;
    font-size: 11px;
    font-weight: 800;
}
.tree-nav a strong,
.tree-nav .tree-item strong { font-size: 12.5px; }
.tree-nav a.available {
    background: white;
    border-color: var(--border);
}
.tree-nav a.done,
.tree-nav .tree-item.done {
    background: var(--success-soft);
    border-color: #BFE8CD;
}
.tree-nav a.done span,
.tree-nav .tree-item.done span {
    background: #DDF2E5;
    color: var(--success);
}
.tree-nav a.retry,
.tree-nav .tree-item.retry,
.tree-nav a.pending {
    background: var(--warning-soft);
    border-color: #F8D9A8;
}
.tree-nav a.retry span,
.tree-nav .tree-item.retry span,
.tree-nav a.pending span {
    background: #FFE9C2;
    color: var(--warning);
}
.tree-nav .tree-item.locked {
    background: #F1F3F6;
    border-color: #DDE1E8;
    color: var(--text-3);
    cursor: not-allowed;
}
.tree-nav .tree-item.locked span {
    background: #E4E7EC;
    color: var(--text-3);
}
.tree-nav a.active {
    outline: 2px solid var(--brand-border);
    color: var(--brand);
}

.bar { height: 8px; background: var(--border-soft); border-radius: 99px; overflow: hidden; margin: 8px 0 14px; }
.bar span { display: block; height: 100%; background: var(--brand); border-radius: inherit; }
.bar.sm { height: 6px; min-width: 110px; margin: 0 0 4px; }
.kv { display: grid; grid-template-columns: 130px 1fr; gap: 9px 12px; }
.kv span { color: var(--text-3); }
.kv strong { font-weight: 600; }
.tag {
    display: inline-flex;
    width: fit-content;
    border: 0;
    border-radius: 99px;
    padding: 3px 8px;
    font-size: 11px;
    font-weight: 700;
}
button.tag { cursor: pointer; }
button.tag:hover { filter: brightness(.97); }
.t-reg { background: var(--cyan-soft); color: var(--cyan); }
.t-work { background: var(--warning-soft); color: var(--warning); }
.t-done { background: var(--success-soft); color: var(--success); }
.t-ai { background: var(--purple-soft); color: var(--purple); }
.t-muted { background: #E4E7EC; color: var(--text-2); }
.ai-box {
    background: linear-gradient(135deg, #FBF8FF, #F4EFFF);
    border-color: #E4DBFA;
}
.ai-box.inline { padding: 12px; border-radius: var(--radius); border: 1px solid #E4DBFA; }

.daily-question {
    display: grid;
    gap: 14px;
}
.profile-hero {
    display: grid;
    grid-template-columns: minmax(220px, .8fr) minmax(0, 1.4fr);
    gap: 18px;
    align-items: start;
    margin-bottom: 16px;
}
.profile-main {
    display: flex;
    align-items: center;
    gap: 14px;
}
.profile-avatar {
    width: 64px;
    height: 64px;
    border-radius: 22px;
    display: grid;
    place-items: center;
    background: var(--brand);
    color: white;
    font-size: 28px;
    font-weight: 900;
}
.profile-main h2 {
    margin: 4px 0 3px;
}
.profile-main p {
    margin: 0;
    color: var(--text-2);
}
.profile-inline-form {
    display: grid;
    gap: 12px;
}
.profile-fields {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
}
.profile-fields label:nth-child(4) {
    grid-column: 1 / -1;
}
.profile-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
}
.profile-save-actions[hidden],
.tab-panel[hidden] {
    display: none;
}
.profile-hero {
    grid-template-columns: minmax(340px, .95fr) minmax(340px, 1.05fr);
    align-items: stretch;
}
.profile-info-card,
.profile-stats-card {
    min-height: 330px;
}
.profile-inline-form {
    min-height: 100%;
    align-content: start;
}
.profile-name-input {
    max-width: 360px;
    font-size: 28px;
    line-height: 1.15;
    font-weight: 900;
    padding: 6px 8px;
}
.profile-inline-form:not(.is-editing) .profile-edit-control {
    display: none;
}
.profile-inline-form.is-editing [data-profile-view] {
    display: none;
}
.profile-inline-form.is-editing .profile-edit-control {
    display: block;
}
.profile-info-list {
    display: grid;
    gap: 10px;
    margin: 14px 0 0;
}
.profile-info-list div {
    display: grid;
    grid-template-columns: 110px minmax(0, 1fr);
    gap: 10px;
    align-items: start;
}
.profile-info-list dt {
    color: var(--text-3);
    font-weight: 800;
}
.profile-info-list dd {
    margin: 0;
    color: var(--ink);
    font-weight: 700;
    overflow-wrap: anywhere;
}
.profile-info-list textarea {
    min-height: 86px;
}
.profile-actions {
    margin-top: auto;
}
.profile-stats-card {
    display: flex;
    flex-direction: column;
}
.profile-stats-scroll {
    display: grid;
    gap: 8px;
    max-height: 238px;
    overflow-y: auto;
    padding-right: 4px;
}
.profile-stat-row {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    align-items: center;
    padding: 10px 12px;
    border: 1px solid var(--border-soft);
    border-radius: 10px;
    background: var(--soft);
}
.profile-stat-row span {
    color: var(--text-2);
    font-weight: 700;
}
.profile-stat-row strong {
    color: var(--brand);
    font-size: 18px;
}
.daily-launch {
    display: grid;
    justify-items: center;
    margin: 8px 0 16px;
}
.daily-game-button {
    width: min(520px, 100%);
    border: 1px solid #F8D9A8;
    border-radius: 999px;
    padding: 14px 22px;
    background: linear-gradient(135deg, #FFF7E8, #FFE9C2);
    color: var(--warning);
    box-shadow: 0 10px 26px rgba(180, 83, 9, .12);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}
.daily-game-button:hover {
    transform: translateY(-2px);
    box-shadow: 0 14px 30px rgba(180, 83, 9, .16);
}
.daily-game-button span {
    font-size: 15px;
    font-weight: 900;
}
.daily-game-button strong {
    font-size: 12px;
}
.daily-modal-card {
    border-color: #F8D9A8;
    background: linear-gradient(180deg, #FFFDF7, white);
}
.daily-question-text {
    font-size: 18px;
    font-weight: 900;
    color: var(--ink);
}
.game-choice {
    background: white;
    border-color: #F8D9A8;
}
.game-choice:hover {
    background: #FFF7E8;
}
.achievement-center {
    max-width: 720px;
    margin: 0 auto 16px;
    border-radius: 24px;
    text-align: center;
}
.achievement-center .card-head {
    justify-content: center;
}
.achievement-strip.centered {
    justify-content: center;
}
.achievement-medal {
    width: 58px;
    height: 58px;
    border-radius: 999px;
    display: grid;
    place-items: center;
    font-weight: 900;
    border: 2px solid var(--border);
    background: white;
    color: var(--text-2);
    box-shadow: 0 8px 20px rgba(16, 24, 40, .08);
}
.achievement-medal.earned {
    border-color: #BFE8CD;
    background: radial-gradient(circle at 30% 25%, white, var(--success-soft));
    color: var(--success);
}
.achievement-medal.locked {
    background: #E4E7EC;
    color: var(--text-3);
    filter: grayscale(1);
}
.notification-card,
.latest-ideas-card {
    max-width: 920px;
    margin: 0 auto 16px;
}
.tab-controls {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}
.tab-button {
    width: auto;
    border: 1px solid var(--border);
    border-radius: 999px;
    padding: 7px 12px;
    background: white;
    color: var(--text-2);
    font-weight: 800;
    cursor: pointer;
}
.tab-button.active {
    border-color: var(--brand);
    background: var(--brand-soft);
    color: var(--brand);
}
.center-actions {
    display: flex;
    justify-content: center;
    margin-top: 12px;
}
.choice-list {
    display: grid;
    gap: 8px;
}
.achievement-strip {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}
.achievement-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
    gap: 16px;
}
.achievement-card {
    display: grid;
    gap: 10px;
    align-content: start;
}
.achievement-card.locked {
    background: #F1F3F6;
    color: var(--text-3);
}
.achievement-badge {
    width: 46px;
    height: 46px;
    border-radius: 14px;
    display: grid;
    place-items: center;
    border: 1px solid var(--border);
    background: white;
    color: var(--text-2);
    font-weight: 900;
    box-shadow: 0 4px 12px rgba(16, 24, 40, .05);
}
.achievement-badge.earned {
    background: var(--success-soft);
    border-color: #BFE8CD;
    color: var(--success);
}
.achievement-badge.locked {
    background: #E4E7EC;
    color: var(--text-3);
    filter: grayscale(1);
}
.activity-list {
    display: grid;
    gap: 10px;
}
.activity-item {
    display: grid;
    gap: 3px;
    padding: 10px 0;
    border-bottom: 1px solid var(--border-soft);
}
.activity-item:last-child { border-bottom: 0; }
.activity-item span,
.muted-text,
.news-card small {
    color: var(--text-3);
}
.activity-item small {
    color: var(--text-3);
    font-size: 11px;
}
.news-list {
    display: grid;
    gap: 14px;
}
.news-card p {
    color: var(--text-2);
    max-width: 86ch;
}
.event-empty {
    min-height: 260px;
    display: grid;
    align-content: center;
    gap: 8px;
}
.highlight-row {
    background: var(--brand-soft);
}

table.data { width: 100%; border-collapse: collapse; }
.table-scroll { width: 100%; overflow-x: auto; }
.data th {
    background: var(--soft);
    color: var(--text-3);
    font-size: 10.5px;
    text-transform: uppercase;
    letter-spacing: .06em;
    text-align: left;
    padding: 9px;
    border-bottom: 1px solid var(--border);
}
.data td { padding: 10px 9px; border-bottom: 1px solid var(--border-soft); vertical-align: top; }
.data tr:hover td { background: #FAFAFB; }
.clickable-row { cursor: pointer; }
.clickable-row:hover td { background: var(--brand-soft); }
.th-filter {
    border: 0;
    background: transparent;
    color: inherit;
    font: inherit;
    font-weight: 800;
    letter-spacing: inherit;
    text-transform: inherit;
    padding: 0;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}
.sort-mark {
    display: inline-block;
    min-width: 10px;
    color: var(--brand);
}
.id { color: var(--brand); font-weight: 800; white-space: nowrap; }
.sub { color: var(--text-3); font-size: 11px; margin-top: 2px; }

label { display: grid; gap: 6px; color: var(--text-2); font-weight: 700; }
.checkbox-line {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--text-2);
    font-weight: 700;
}
.checkbox-line input { width: auto; }
input, textarea, select {
    width: 100%;
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 9px 10px;
    background: white;
    color: var(--ink);
}
input:hover, textarea:hover, select:hover { border-color: var(--brand-border); }
input:focus, textarea:focus, select:focus {
    border-color: var(--brand);
    box-shadow: 0 0 0 3px rgba(124, 22, 35, .09);
    outline: 0;
}
label.has-error input,
label.has-error textarea,
label.has-error select {
    border-color: var(--danger);
    background: var(--danger-soft);
}
.field-error {
    color: var(--danger);
    font-size: 12px;
    font-weight: 700;
    line-height: 1.35;
}
textarea { min-height: 98px; resize: vertical; }
.tall-textarea { min-height: 320px; }
.form-stack { display: grid; gap: 14px; }
.form-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.autosave-status {
    color: var(--text-3);
    font-size: 12px;
    font-weight: 700;
}
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form-grid button { width: fit-content; }
.question-card { display: grid; gap: 10px; }
.result-card { margin-bottom: 16px; }
.inline-result {
    margin: 16px 0;
    padding: 14px;
    border-radius: var(--radius);
    background: var(--soft);
}
.inline-result strong {
    display: block;
    margin: 8px 0 4px;
    color: var(--brand);
    font-size: 24px;
}
.exam-result-list {
    display: grid;
    gap: 12px;
}
.exam-result-card {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: white;
    padding: 14px;
}
.exam-question {
    color: var(--ink);
    font-weight: 700;
}
.answer-review {
    display: grid;
    grid-template-columns: 150px 1fr;
    gap: 8px 12px;
    padding: 12px;
    border-radius: 12px;
    background: var(--soft);
}
.answer-review span {
    color: var(--text-3);
    font-size: 11px;
    font-weight: 800;
    text-transform: uppercase;
}
.answer-review strong {
    font-weight: 600;
    white-space: pre-wrap;
}
.alert {
    border-radius: var(--radius);
    padding: 12px 14px;
    margin-bottom: 14px;
    font-weight: 700;
}
.alert.danger { background: var(--danger-soft); color: var(--danger); border: 1px solid #F4C7C2; }
.inline-form { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 10px; align-items: end; }
.admin-form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
    gap: 12px;
    align-items: end;
}
.admin-form-grid .btn { width: fit-content; align-self: end; }
.user-create-form { grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }
.row-form { display: flex; gap: 8px; align-items: center; }
.action-list { display: grid; gap: 10px; }
.action-list .btn { justify-content: center; }
.link { color: var(--brand); font-weight: 700; }
.detail-hero {
    display: flex;
    justify-content: space-between;
    gap: 20px;
    align-items: center;
    margin-bottom: 16px;
}
.detail-kpis {
    display: grid;
    grid-template-columns: repeat(3, minmax(100px, 1fr));
    gap: 10px;
    min-width: min(420px, 100%);
}
.detail-kpis div {
    padding: 12px;
    border: 1px solid var(--border-soft);
    border-radius: 12px;
    background: var(--soft);
}
.detail-kpis strong { display: block; color: var(--brand); font-size: 22px; }
.detail-kpis span { color: var(--text-3); font-size: 11px; }
.course-accordion { display: grid; gap: 12px; }
.course-list { display: grid; gap: 10px; }
.course-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: white;
}
.course-row:hover { background: var(--brand-soft); border-color: var(--brand-border); transform: translateY(-1px); }
.course-row strong, .course-row span { display: block; }
.course-row span { color: var(--text-2); margin-top: 3px; }
.course-row small { color: var(--brand); font-weight: 800; white-space: nowrap; }
.course-detail {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    background: white;
}
.course-detail[open] { box-shadow: 0 8px 22px rgba(16, 24, 40, .06); }
.course-detail summary {
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    gap: 12px;
    padding: 13px 14px;
    background: var(--soft);
    font-weight: 700;
}
.course-detail summary:hover { color: var(--brand); }
.course-detail summary span { color: var(--brand); }
.topic-inline-form {
    display: grid;
    gap: 12px;
}
.topic-inline-grid {
    align-items: start;
}
.topic-inline-grid [data-topic-view] {
    overflow-wrap: anywhere;
}
.topic-inline-grid .topic-edit-control {
    display: none;
}
.topic-inline-form.is-editing [data-topic-view] {
    display: none;
}
.topic-inline-form.is-editing .topic-edit-control {
    display: block;
}
.topic-inline-actions {
    padding-top: 4px;
}
.topic-inline-actions[hidden] {
    display: none;
}
.admin-topic-questions {
    margin-top: 28px;
}
.admin-question-list {
    display: grid;
    gap: 12px;
}
.admin-question-detail {
    border: 1px solid var(--border);
    border-radius: 12px;
    background: white;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(16, 24, 40, .04);
}
.admin-question-detail[open] {
    border-color: var(--brand-border);
    box-shadow: 0 8px 22px rgba(16, 24, 40, .06);
}
.admin-question-detail summary {
    cursor: pointer;
    display: grid;
    grid-template-columns: 34px auto minmax(0, 1fr) auto;
    align-items: center;
    gap: 14px;
    padding: 13px 16px;
    background: white;
}
.admin-question-detail summary:hover {
    background: var(--brand-soft);
}
.admin-question-detail summary strong,
.admin-question-detail summary small,
.question-main {
    min-width: 0;
}
.question-index {
    width: 34px;
    height: 34px;
    border-radius: 10px;
    display: grid;
    place-items: center;
    background: var(--soft);
    color: var(--brand);
    font-weight: 800;
}
.question-main {
    display: grid;
    gap: 3px;
}
.question-main strong {
    color: var(--ink);
    line-height: 1.25;
}
.admin-question-detail summary small {
    color: var(--text-3);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.question-edit-hint {
    color: var(--brand);
    font-size: 11px;
    font-weight: 800;
    opacity: 0;
    transform: translateX(-4px);
}
.admin-question-detail summary:hover .question-edit-hint,
.admin-question-detail[open] .question-edit-hint {
    opacity: 1;
    transform: translateX(0);
}
.admin-question-detail[open] summary {
    background: var(--brand-soft);
}
.admin-question-edit {
    padding: 16px;
    border-top: 1px solid var(--border-soft);
    background: var(--soft);
}
.compact-table th, .compact-table td { padding: 8px 10px; }
.kv.wide { grid-template-columns: 110px 1fr; }
.kv.wide strong { font-weight: 500; white-space: pre-wrap; }
hr { border: 0; border-top: 1px solid var(--border-soft); margin: 16px 0; }
.narrow-card { max-width: 760px; }
.empty-state {
    padding: 18px;
    border: 1px dashed var(--border);
    border-radius: var(--radius);
    color: var(--text-3);
    background: var(--soft);
}
.modal-form-stack {
    display: grid;
    grid-template-columns: 1fr;
    gap: 12px;
}
.question-field {
    position: relative;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px 14px 14px;
    display: grid;
    gap: 10px;
}
.question-field:hover,
.question-field:focus-within {
    border-color: var(--brand-border);
    box-shadow: 0 8px 24px rgba(16, 24, 40, .06);
}
.question-help-btn {
    position: absolute;
    top: 10px;
    right: 12px;
    width: 28px;
    height: 28px;
    border: 1px solid var(--brand-border);
    border-radius: 50%;
    background: white;
    color: var(--brand);
    cursor: pointer;
    display: inline-grid;
    place-items: center;
    font-weight: 900;
    opacity: 0;
    transform: translateY(-4px) scale(.96);
    box-shadow: var(--shadow);
    z-index: 2;
}
.question-field:hover .question-help-btn,
.question-field:focus-within .question-help-btn,
.question-help-btn:focus-visible {
    opacity: 1;
    transform: translateY(0) scale(1);
}
.question-help-btn:hover {
    background: var(--brand);
    color: white;
    border-color: var(--brand);
}
.question-help-btn:disabled {
    cursor: wait;
    opacity: .75;
}
.question-help-tip {
    position: absolute;
    right: 0;
    bottom: calc(100% + 8px);
    width: max-content;
    max-width: 220px;
    padding: 8px 10px;
    border-radius: 10px;
    background: var(--ink);
    color: white;
    font-size: 12px;
    font-weight: 700;
    line-height: 1.3;
    pointer-events: none;
    opacity: 0;
    transform: translateY(4px);
    box-shadow: var(--shadow);
}
.question-help-tip::after {
    content: "";
    position: absolute;
    right: 10px;
    top: 100%;
    border: 6px solid transparent;
    border-top-color: var(--ink);
}
.question-help-btn:hover .question-help-tip,
.question-help-btn:focus-visible .question-help-tip {
    opacity: 1;
    transform: translateY(0);
}
.question-hint-panel {
    border: 1px solid var(--brand-border);
    border-radius: 12px;
    padding: 12px 14px;
    background: var(--brand-soft);
    color: var(--ink);
    font-weight: 600;
    line-height: 1.5;
    white-space: pre-wrap;
    animation: hintIn .18s var(--ease);
}
.question-hint-panel[hidden] { display: none; }
.question-hint-panel.is-loading {
    color: var(--text-2);
}
.question-hint-panel.is-error {
    border-color: #F4C7C2;
    background: var(--danger-soft);
    color: var(--danger);
}
@keyframes hintIn {
    from { opacity: 0; transform: translateY(-4px); }
    to { opacity: 1; transform: translateY(0); }
}
.case-field {
    background: var(--soft);
}
.matching-field {
    background: linear-gradient(180deg, white, var(--soft));
}
.case-field p {
    color: var(--ink);
    font-weight: 600;
    max-width: none;
}
.question-field legend {
    padding: 0 6px;
    font-weight: 800;
    color: var(--ink);
}
.choice-row {
    display: flex;
    grid-template-columns: auto 1fr;
    align-items: center;
    gap: 9px;
    padding: 8px 10px;
    border: 1px solid var(--border-soft);
    border-radius: 10px;
    background: white;
    color: var(--ink);
    font-weight: 500;
}
.choice-row:hover {
    border-color: var(--brand-border);
    background: var(--brand-soft);
}
.choice-row:has(input:checked) {
    border-color: var(--brand-border);
    background: var(--brand-soft);
    color: var(--brand);
}
.choice-row input { width: auto; }
.modal {
    width: min(760px, calc(100vw - 32px));
    border: 0;
    border-radius: var(--radius);
    padding: 0;
    box-shadow: 0 18px 60px rgba(16, 24, 40, .22);
    opacity: 0;
    transform: translateY(14px) scale(.98);
}
.modal[open] {
    opacity: 1;
    transform: translateY(0) scale(1);
    animation: modal-in .22s var(--ease);
}
.modal::backdrop {
    background: rgba(21, 23, 28, .38);
    animation: fade-in .2s var(--ease);
}
.modal-card {
    padding: 18px;
    background: white;
    border-radius: var(--radius);
}
.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    margin-top: 16px;
}
.help-widget {
    position: fixed;
    right: 26px;
    bottom: 26px;
    z-index: 60;
}
.bug-report-fab {
    position: relative;
    width: 52px;
    height: 52px;
    border: 1px solid var(--brand-border);
    border-radius: 50%;
    background: white;
    color: var(--brand);
    cursor: pointer;
    display: grid;
    place-items: center;
    font-size: 21px;
    font-weight: 900;
    box-shadow: 0 12px 34px rgba(16, 24, 40, .16);
}
.help-fab {
    z-index: 2;
}
.bug-report-fab:hover {
    background: var(--brand);
    border-color: var(--brand);
    color: white;
    transform: translateY(-2px);
}
.help-actions {
    position: absolute;
    right: 0;
    bottom: calc(100% + 10px);
    width: 230px;
    padding: 8px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: white;
    display: grid;
    gap: 7px;
    box-shadow: 0 14px 36px rgba(16, 24, 40, .16);
    opacity: 0;
    pointer-events: none;
    transform: translateY(8px) scale(.98);
    transform-origin: bottom right;
}
.help-actions::after {
    content: "";
    position: absolute;
    right: 18px;
    top: 100%;
    border: 6px solid transparent;
    border-top-color: white;
}
.help-widget:hover .help-actions,
.help-widget:focus-within .help-actions {
    opacity: 1;
    pointer-events: auto;
    transform: translateY(0) scale(1);
}
.help-actions button {
    width: 100%;
    padding: 9px 10px;
    border: 1px solid var(--border-soft);
    border-radius: 10px;
    background: var(--soft);
    color: var(--ink);
    cursor: pointer;
    text-align: left;
    font-weight: 700;
}
.help-actions button:hover {
    border-color: var(--brand-border);
    background: var(--brand-soft);
    color: var(--brand);
}
.bug-report-modal {
    width: min(680px, calc(100vw - 32px));
}
.bug-report-form label {
    display: grid;
    gap: 6px;
    color: var(--text-2);
    font-weight: 700;
}
.bug-report-form textarea {
    resize: vertical;
}
.bug-report-status {
    min-height: 18px;
    color: var(--text-3);
    font-weight: 700;
}
.bug-report-status.is-success { color: var(--success); }
.bug-report-status.is-error { color: var(--danger); }
.bug-report-status.is-loading { color: var(--text-2); }
.bug-report-list {
    display: grid;
    gap: 10px;
}
.bug-report-row {
    padding: 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--soft);
}
.bug-report-row strong {
    display: block;
    margin: 8px 0;
    white-space: pre-wrap;
}
.bug-report-meta {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
    color: var(--text-3);
    font-size: 12px;
    font-weight: 700;
}
.bug-report-row .sub {
    display: inline-block;
    max-width: 100%;
    word-break: break-word;
}
.onboarding-backdrop,
.onboarding-spotlight,
.onboarding-popover {
    display: none;
}
.onboarding-active {
    overflow: hidden;
}
[data-onboarding-root].is-active .onboarding-backdrop,
[data-onboarding-root].is-active .onboarding-spotlight,
[data-onboarding-root].is-active .onboarding-popover {
    display: block;
}
.onboarding-backdrop {
    position: fixed;
    inset: 0;
    z-index: 80;
    background: rgba(16, 24, 40, .54);
    animation: fade-in .18s var(--ease);
}
.onboarding-spotlight {
    position: fixed;
    z-index: 81;
    border: 2px solid white;
    border-radius: 14px;
    box-shadow:
        0 0 0 9999px rgba(16, 24, 40, .54),
        0 14px 40px rgba(255, 255, 255, .16);
    pointer-events: none;
    transition:
        left .22s var(--ease),
        top .22s var(--ease),
        width .22s var(--ease),
        height .22s var(--ease);
}
.onboarding-popover {
    position: fixed;
    z-index: 82;
    padding: 16px;
    border: 1px solid var(--brand-border);
    border-radius: var(--radius);
    background: white;
    box-shadow: 0 20px 60px rgba(16, 24, 40, .24);
    animation: popover-in .18s var(--ease);
}
.onboarding-popover h3 {
    margin: 4px 0 8px;
    font-size: 17px;
}
.onboarding-popover p {
    max-width: none;
}
.onboarding-step {
    display: inline-flex;
    padding: 3px 8px;
    border-radius: 99px;
    background: var(--brand-soft);
    color: var(--brand);
    font-size: 11px;
    font-weight: 800;
}
.onboarding-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    margin-top: 14px;
}
.filter-popover {
    position: fixed;
    z-index: 30;
    width: 292px;
    max-height: 380px;
    padding: 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: white;
    box-shadow: 0 12px 36px rgba(16, 24, 40, .16);
    animation: popover-in .18s var(--ease);
}
.filter-search { margin-bottom: 10px; }
.filter-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    margin-bottom: 10px;
}
.filter-actions button {
    border: 1px solid var(--border);
    border-radius: 9px;
    background: var(--soft);
    color: var(--text-2);
    padding: 7px 8px;
    cursor: pointer;
    font-weight: 700;
}
.filter-actions button:hover {
    border-color: var(--brand-border);
    color: var(--brand);
    transform: translateY(-1px);
}
.filter-options {
    max-height: 190px;
    overflow-y: auto;
    overflow-x: hidden;
    display: grid;
    gap: 0;
}
.filter-option {
    display: grid;
    grid-template-columns: 18px minmax(0, 1fr);
    align-items: center;
    gap: 8px;
    height: 38px;
    min-height: 38px;
    padding: 0 6px;
    border-radius: 8px;
    color: var(--ink);
    font-weight: 500;
    overflow: hidden;
    white-space: nowrap;
}
.filter-option input {
    width: 16px;
    height: 16px;
    margin: 0;
}
.filter-option span {
    display: block;
    min-width: max-content;
    overflow: visible;
    white-space: nowrap;
}
.filter-option:hover { background: var(--soft); }

.login-page {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 24px;
}
.login-card {
    width: min(420px, 100%);
    background: white;
    border: 1px solid var(--border-soft);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 24px;
}
.bitrix-card {
    width: min(560px, 100%);
}
.login-card h1 { margin: 18px 0 8px; font-size: 24px; }
.hint { color: var(--text-3); font-size: 12px; margin-top: 14px; }

@media (max-width: 880px) {
    .sidebar {
        position: static;
        width: auto;
        min-height: auto;
        border-right: 0;
        border-bottom: 1px solid var(--border);
    }
    .main { margin-left: 0; padding: 18px; }
    .topbar, .insight { align-items: flex-start; flex-direction: column; }
    .kpi-grid, .module-grid, .two-col, .form-grid, .admin-split, .detail-kpis, .profile-hero, .profile-fields { grid-template-columns: 1fr; }
    .profile-fields label:nth-child(4) { grid-column: auto; }
    .profile-actions { justify-content: flex-start; }
    .profile-info-list div { grid-template-columns: 1fr; gap: 3px; }
    .daily-game-button { border-radius: var(--radius); align-items: flex-start; flex-direction: column; }
    .detail-hero { flex-direction: column; align-items: stretch; }
    .inline-form { grid-template-columns: 1fr; }
    .search { min-width: 0; width: 100%; }
    .answer-review, .admin-question-detail summary { grid-template-columns: 1fr; }
    .user-actions {
        position: static;
        margin-top: 8px;
        opacity: 1;
        pointer-events: auto;
        transform: none;
        box-shadow: none;
    }
}

@keyframes menu-rise {
    from { opacity: 0; transform: translateY(8px) scale(.98); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes modal-in {
    from { opacity: 0; transform: translateY(14px) scale(.98); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes popover-in {
    from { opacity: 0; transform: translateY(-6px) scale(.98); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes fade-in {
    from { opacity: 0; }
    to { opacity: 1; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: .01ms !important;
        animation-iteration-count: 1 !important;
        scroll-behavior: auto !important;
        transition-duration: .01ms !important;
    }
}
