:root {
    --bg: #f3f4f6;
    --sidebar-bg: #ffffff;
    --primary: #2563eb;
    --primary-soft: #e0edff;
    --border-subtle: #e5e7eb;
    --text-muted: #6b7280;
    --chip-bg: #f9fafb;
    --chip-hover-bg: #eef2ff;
    --chip-active-bg: #2563eb;
    --chip-active-text: #ffffff;
}

*,
*::before,
*::after {
    box-sizing: border-box;
}

html,
body {
    margin: 0;
    padding: 0;
    height: 100%;
    font-family: system-ui, -apple-system, BlinkMacSystemFont,
    "SF Pro Text", "Segoe UI", sans-serif;
    background: var(--bg);
    color: #111827;
}

body {
    -webkit-font-smoothing: antialiased;
}

.app-shell {
    display: flex;
    height: 100vh;
}

/* SIDEBAR */

.sidebar {
    width: 270px;
    background: var(--sidebar-bg);
    border-right: 1px solid var(--border-subtle);
    display: flex;
    flex-direction: column;
}

.sidebar-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 14px 18px;
    border-bottom: 1px solid var(--border-subtle);
}

.sidebar-header-logo {
    height: 32px;
    width: 32px;
    border-radius: 12px;
    background: var(--primary);
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
}

.logo-dot {
    height: 16px;
    width: 16px;
    border-radius: 999px;
    background: #eff6ff;
    box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.4);
}

.sidebar-header-text {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.sidebar-title {
    font-weight: 600;
    font-size: 16px;
}

.sidebar-subtitle {
    font-size: 11px;
    color: var(--text-muted);
}

.sidebar-section {
    padding: 14px 16px 0;
}

.sidebar-caption {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    font-weight: 600;
    color: var(--text-muted);
}

/* BUTTONS */

.btn-primary {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    border-radius: 999px;
    border: none;
    padding: 8px 14px;
    background: var(--primary);
    color: #ffffff;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    box-shadow: 0 12px 22px rgba(37, 99, 235, 0.25);
    transition: background 0.12s ease, transform 0.08s ease,
    box-shadow 0.12s ease;
}

.btn-primary:hover {
    background: #1d4ed8;
    transform: translateY(-1px);
    box-shadow: 0 16px 30px rgba(37, 99, 235, 0.35);
}

.btn-primary:active {
    transform: translateY(0);
    box-shadow: 0 8px 16px rgba(37, 99, 235, 0.35);
}

.btn-ghost {
    border-radius: 999px;
    padding: 8px 12px;
    border: 1px solid var(--border-subtle);
    background: #f9fafb;
    color: var(--text-muted);
    font-size: 13px;
    cursor: pointer;
}

.btn-ghost:hover {
    background: #e5e7eb;
}

/* GRADES */

.grade-list {
    margin-top: 8px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.grade-btn {
    width: 100%;
    border-radius: 8px;
    border: none;
    padding: 6px 11px;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    background: transparent;
    color: #020617;
    cursor: pointer;
    transition: background 0.1s ease, color 0.1s ease;
}

.grade-btn i {
    font-size: 16px;
    color: var(--text-muted);
}

.grade-btn:hover {
    background: #f3f4ff;
}

.grade-btn.is-active {
    background: var(--primary-soft);
    color: #1e40af;
    font-weight: 500;
}

.grade-btn.is-active i {
    color: #1e40af;
}

/* TREE */

.tree-panel {
    padding: 10px 8px 14px;
}

.topic-group {
    border-radius: 12px;
    padding: 4px 4px 4px 6px;
    margin-bottom: 2px;
}

.topic-header {
    width: 100%;
    border-radius: 10px;
    border: none;
    padding: 6px 8px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: transparent;
    cursor: pointer;
    font-size: 13px;
    color: #020617;
    text-align: left;
}

.topic-main {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.topic-header i {
    font-size: 16px;
    color: var(--text-muted);
}

.topic-header .chevron {
    transition: transform 0.12s ease;
}

.topic-group.is-collapsed .chevron {
    transform: rotate(-90deg);
}

.topic-header:hover {
    background: #f3f4ff;
}

.topic-body {
    margin-top: 4px;
    padding-left: 16px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.topic-body.is-hidden {
    display: none;
}

.subtopic-btn {
    border-radius: 8px;
    border: none;
    padding: 2px 5px;
    font-size: 12px;
    background: #f9fafb;
    color: var(--text-muted);
    cursor: pointer;
    text-align: left;
}

.subtopic-btn:hover {
    background: #e5e7eb;
    color: #111827;
}

/* SEARCH */

.search-box {
    margin-top: 4px;
    display: flex;
    align-items: center;
    gap: 6px;
    border-radius: 999px;
    border: 1px solid var(--border-subtle);
    padding: 4px 8px;
    background: #f9fafb;
}

.search-box i {
    font-size: 14px;
    color: var(--text-muted);
}

.search-box input {
    border: none;
    background: transparent;
    outline: none;
    font-size: 13px;
    flex: 1;
}

.search-results {
    margin-top: 6px;
    max-height: 160px;
    overflow-y: auto;
    font-size: 12px;
}

.search-results div {
    border-radius: 10px;
    padding: 5px 8px;
    background: #ffffff;
    border: 1px solid var(--border-subtle);
    margin-bottom: 4px;
    cursor: pointer;
}

.search-results div:hover {
    background: #f3f4ff;
}

/* MAIN */

.main {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.main-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 22px;
    border-bottom: 1px solid var(--border-subtle);
    background: #ffffff;
}

.mode-switch {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.mode-label {
    font-size: 11px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    font-weight: 600;
}

.mode-buttons {
    display: inline-flex;
    gap: 6px;
    padding: 2px;
    border-radius: 999px;
    background: #eef2ff;
}

.mode-toggle {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    border-radius: 999px;
    border: 1px solid transparent;
    padding: 4px 10px;
    font-size: 12px;
    background: transparent;
    color: var(--text-muted);
    cursor: pointer;
}

.mode-toggle i {
    font-size: 14px;
}

.mode-toggle.is-active {
    background: #ffffff;
    border-color: #c4d3ff;
    color: #1e3a8a;
    box-shadow: 0 6px 18px rgba(129, 140, 248, 0.35);
}

.path-indicator {
    text-align: right;
}

.path-label {
    font-size: 11px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    font-weight: 600;
}

.path-value {
    font-size: 13px;
    font-weight: 500;
}

.content-scroll {
    flex: 1;
    overflow-y: auto;
    padding: 18px 22px 20px;
}

/* CARDS */

.card {
    background: #ffffff;
    border-radius: 18px;
    border: 1px solid var(--border-subtle);
    padding: 14px 16px;
    box-shadow: 0 18px 30px rgba(15, 23, 42, 0.04);
}

.card-title {
    font-size: 14px;
    font-weight: 600;
}

.card-help {
    font-size: 11px;
    color: var(--text-muted);
}

/* TASK CHIPS */

.task-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.file-item {
    border: 1px solid var(--border-subtle);
    background: var(--chip-bg);
    border-radius: 8px;
    padding: 6px 13px;
    font-size: 13px;
    cursor: pointer;
    white-space: nowrap;
    transition: background 0.1s ease, color 0.1s ease, border-color 0.1s ease;
}

.file-item:hover {
    background: var(--chip-hover-bg);
}

.file-item.active {
    background: var(--chip-active-bg);
    border-color: var(--chip-active-bg);
    color: var(--chip-active-text);
}

/* FORMS */

.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
    gap: 12px;
}

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

.field-label {
    font-size: 12px;
    font-weight: 500;
    color: var(--text-muted);
    margin-bottom: 4px;
}

.field-input {
    border-radius: 12px;
    border: 1px solid var(--border-subtle);
    padding: 8px 10px;
    font-size: 13px;
    background: #f9fafb;
}

.field-input:focus {
    outline: none;
    border-color: var(--primary);
    background: #ffffff;
    box-shadow: 0 0 0 1px rgba(37, 99, 235, 0.08);
}

.form-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
}

/* JSON EDITOR */

.json-editor {
    flex: 1;
    width: 100%;
    border-radius: 16px;
    border: 1px solid var(--border-subtle);
    padding: 10px 12px;
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas,
    "Liberation Mono", "Courier New", monospace;
    font-size: 12px;
    line-height: 1.4;
    background: #020617;
    color: #e5e7eb;
    resize: none;
    min-height: 260px;
}

#uploadResult {
    margin-top: 6px;
    background: #020617;
    color: #e5e7eb;
    border-radius: 12px;
    padding: 8px 10px;
    max-height: 150px;
    overflow: auto;
    font-size: 11px;
}

/* EMPTY STATES */

.empty-tree,
.empty-tasks {
    font-size: 12px;
    color: var(--text-muted);
    padding: 4px 6px;
}

/* UTILITIES */

.is-hidden {
    display: none !important;
}

/* Simple custom scrollbar */
::-webkit-scrollbar {
    width: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: #cbd5f5;
    border-radius: 999px;
}
/* META / CONTENT / RESPONSE SECTIONS */

.meta-sections {
    display: grid;
    grid-template-columns: minmax(220px, 2fr) minmax(260px, 3fr) minmax(260px, 3fr);
    gap: 12px;
    margin-top: 4px;
}

.section-card {
    background: #f9fafb;
    border-radius: 14px;
    border: 1px solid var(--border-subtle);
    padding: 10px 12px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.section-card-title {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

.section-card-body {
    display: flex;
    flex-direction: column;
    gap: 8px;
    overflow-y: auto;
}

.section-textarea {
    border-radius: 10px;
    border: 1px solid var(--border-subtle);
    padding: 6px 8px;
    font-size: 12px;
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas,
    "Liberation Mono", "Courier New", monospace;
    min-height: 120px;
    resize: vertical;
    background: #ffffff;
}

.section-textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 1px rgba(37, 99, 235, 0.08);
}
/* Висота списку класів — 40% */
.grade-list {
    flex: 0 0 40%;
    overflow-y: auto;
    padding-right: 4px;
}

/* Висота блоку підтем — 60% */
.tree-panel {
    flex: 0 0 60%;
    overflow-y: auto;
    padding-right: 4px;
}
.sidebar-section.flex-1 {
    display: flex;
    flex-direction: column;
}
