:root {
    --bg: #111116;
    --surface: #1c1c24;
    --surface2: #26262f;
    --border: #32323d;
    --text: #e8e6ef;
    --text2: #9590a8;
    --accent: #6c5ce7;
    --accent-hover: #7c6ef7;
    --accent-soft: rgba(108, 92, 231, 0.12);
    --green: #00b894;
    --orange: #fdcb6e;
    --red: #e17055;
    --radius: 12px;
    --radius-lg: 16px;
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.2);
    --shadow-md: 0 4px 12px rgba(0,0,0,0.25);
    --shadow-lg: 0 8px 24px rgba(0,0,0,0.35);
    --transition: 0.2s ease;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
}

/* Layout */
.app { max-width: 800px; margin: 0 auto; padding: 16px; }

header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 0;
    border-bottom: 1px solid var(--border);
    margin-bottom: 24px;
}

header h1 { font-size: 20px; font-weight: 700; }
header h1 span { color: var(--accent); }

.header-right { display: flex; align-items: center; gap: 12px; }
.user-tag { color: var(--text2); font-size: 14px; }

/* Buttons */
.btn {
    padding: 10px 20px;
    border: none;
    border-radius: var(--radius);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition);
}

.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); }
.btn-secondary { background: var(--surface2); color: var(--text); border: 1px solid var(--border); }
.btn-secondary:hover { background: var(--border); }
.btn-danger { background: var(--red); color: #fff; }
.btn-danger:hover { opacity: 0.85; }
.btn-small { padding: 6px 14px; font-size: 12px; }
.btn-google {
    background: #fff;
    color: #333;
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 15px;
    padding: 12px 24px;
    border: 1px solid #ddd;
    border-radius: var(--radius);
    cursor: pointer;
    margin: 0 auto;
}
.btn-google:hover { background: #f5f5f5; }
.btn-google svg { width: 20px; height: 20px; }

/* Cards */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 18px;
    margin-bottom: 12px;
    cursor: pointer;
    transition: border-color var(--transition), box-shadow var(--transition);
    box-shadow: var(--shadow-sm);
}
.card:hover { border-color: var(--accent); box-shadow: var(--shadow-md); }
.card-header { display: flex; justify-content: space-between; align-items: center; }
.card-header.collapsible-header { margin-bottom: 0; }
.card-title { font-weight: 600; font-size: 16px; }
.card-meta { color: var(--text2); font-size: 13px; }

/* Sections */
.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}
.section-header h2 { font-size: 18px; }

/* Auth screen */
.auth-screen {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 80vh;
    text-align: center;
    gap: 24px;
}
.auth-screen h1 { font-size: 32px; }
.auth-screen h1 span { color: var(--accent); }
.auth-screen p { color: var(--text2); max-width: 400px; line-height: 1.5; }

/* Modal / Dialog */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
}
.modal {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 28px;
    width: 90%;
    max-width: 420px;
    box-shadow: var(--shadow-lg);
}
.modal h3 { margin-bottom: 16px; }
.modal input {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface2);
    color: var(--text);
    font-size: 14px;
    margin-bottom: 16px;
    outline: none;
}
.modal input:focus { border-color: var(--accent); }
.modal-actions { display: flex; gap: 8px; justify-content: flex-end; }

/* Help grid */
.help-grid { display: flex; flex-direction: column; gap: 16px; }
.help-item { display: flex; gap: 14px; align-items: flex-start; }
.help-item-icon { font-size: 22px; flex-shrink: 0; width: 32px; text-align: center; }
.help-item h4 { font-size: 14px; font-weight: 600; margin-bottom: 4px; }
.help-item p { font-size: 13px; color: var(--text2); line-height: 1.5; }
.help-item a { color: var(--accent); text-decoration: none; }
.help-item a:hover { text-decoration: underline; }

/* Group detail */
.detail-back {
    color: var(--text2);
    font-size: 13px;
    cursor: pointer;
    margin-bottom: 16px;
    display: inline-block;
}
.detail-back:hover { color: var(--text); }

.invite-box {
    background: var(--surface2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 12px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
}
.invite-code { font-family: monospace; font-size: 18px; letter-spacing: 2px; font-weight: 700; }

/* Member list */
.member-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 0;
    border-bottom: 1px solid var(--border);
}
.member-row:last-child { border-bottom: none; }
.member-name { font-weight: 500; }
.member-name .leader-badge {
    background: var(--accent);
    color: #fff;
    font-size: 10px;
    padding: 2px 6px;
    border-radius: 4px;
    margin-left: 6px;
}
.member-sync { color: var(--text2); font-size: 12px; }

/* Progress view */
.progress-section { margin-top: 24px; }
.progress-section h3 { margin-bottom: 12px; }

.assignment-row {
    display: flex;
    align-items: center;
    padding: 8px 12px;
    background: var(--surface2);
    border-radius: 6px;
    margin-bottom: 6px;
    font-size: 14px;
    gap: 8px;
}
.assignment-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.assignment-due { color: var(--text2); font-size: 12px; white-space: nowrap; flex-shrink: 0; }

.status { font-size: 12px; font-weight: 600; padding: 3px 8px; border-radius: 4px; white-space: nowrap; flex-shrink: 0; }
.status-submitted { background: rgba(0,184,148,0.15); color: var(--green); }
.status-graded { background: rgba(0,184,148,0.15); color: var(--green); }
.status-late { background: rgba(253,203,110,0.15); color: var(--orange); }
.status-missing { background: rgba(225,112,85,0.15); color: var(--red); }
.status-overdue { background: rgba(200,50,50,0.2); color: #e05555; }
.status-unsubmitted { background: rgba(145,150,168,0.1); color: var(--text2); }
.status-no_submission { background: rgba(145,150,168,0.1); color: var(--text2); }

/* Visibility */
.vis-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 0;
    border-bottom: 1px solid var(--border);
}
.vis-row:last-child { border-bottom: none; }

/* Toggle switch */
.toggle { position: relative; width: 44px; height: 24px; }
.toggle input { opacity: 0; width: 0; height: 0; }
.toggle .slider {
    position: absolute;
    inset: 0;
    background: var(--surface2);
    border-radius: 24px;
    cursor: pointer;
    transition: background 0.2s;
}
.toggle .slider::before {
    content: '';
    position: absolute;
    width: 18px;
    height: 18px;
    left: 3px;
    top: 3px;
    background: var(--text2);
    border-radius: 50%;
    transition: transform 0.2s, background 0.2s;
}
.toggle input:checked + .slider { background: var(--accent); }
.toggle input:checked + .slider::before { transform: translateX(20px); background: #fff; }

/* Pending prompt */
.pending-banner {
    background: var(--surface2);
    border: 1px solid var(--accent);
    border-radius: var(--radius);
    padding: 14px 16px;
    margin-bottom: 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.pending-banner span { font-size: 14px; }

/* Progress header bar */
.progress-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 12px;
    margin-bottom: 16px;
}
.progress-controls {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-shrink: 0;
}

/* Leader toggle inline */
.leader-toggle-label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: var(--text2);
    white-space: nowrap;
}

/* View toggle */
.view-toggle { display: flex; gap: 0; }
.view-toggle button {
    padding: 8px 16px;
    background: var(--surface2);
    border: 1px solid var(--border);
    color: var(--text2);
    font-size: 13px;
    cursor: pointer;
    white-space: nowrap;
}
.view-toggle button:first-child { border-radius: var(--radius) 0 0 var(--radius); }
.view-toggle button:last-child { border-radius: 0 var(--radius) var(--radius) 0; }
.view-toggle button.active { background: var(--accent); color: #fff; border-color: var(--accent); }

/* Empty state */
.empty {
    text-align: center;
    padding: 40px;
    color: var(--text2);
}

/* Loading */
.loading { text-align: center; padding: 40px; color: var(--text2); }

/* Animations */
@keyframes fadeUp {
    from { opacity: 0; transform: translateY(6px); }
    to   { opacity: 1; transform: translateY(0); }
}
.fade-in { animation: fadeUp 0.18s ease both; }

/* Hidden */
.hidden { display: none !important; }

/* Tab bar */
.tabs {
    display: flex;
    gap: 0;
    border-bottom: 1px solid var(--border);
    margin-bottom: 20px;
}
.tab {
    padding: 10px 20px;
    color: var(--text2);
    font-size: 14px;
    cursor: pointer;
    border-bottom: 2px solid transparent;
    transition: color 0.15s, border-color 0.15s;
}
.tab:hover { color: var(--text); }
.tab.active { color: var(--accent); border-bottom-color: var(--accent); }

/* Collapsible sections */
.collapsible-header { cursor: pointer; user-select: none; }
.collapsible-header .chevron {
    display: inline-block;
    font-size: 10px;
    transition: transform 0.2s;
}
.collapsible-header.collapsed .chevron { transform: rotate(-90deg); }
.collapsible-content {
    overflow: hidden;
    padding-top: 10px;
    max-height: 4000px;
    transition: max-height 0.28s ease, padding-top 0.2s ease, opacity 0.2s ease;
    opacity: 1;
}
.collapsible-content.collapsed { max-height: 0; padding-top: 0; opacity: 0; }

/* Summary counts in collapsed headers */
.summary-counts { display: inline-flex; gap: 6px; margin: 0 8px; }
.summary-counts .status { font-size: 11px; padding: 1px 6px; }

/* Dashboard */
.dashboard { margin-bottom: 20px; }
.dashboard-section { background: var(--surface); border-radius: var(--radius); padding: 12px 16px; margin-bottom: 8px; }
.dashboard-header { display: flex; justify-content: space-between; align-items: center; cursor: pointer; user-select: none; }
.dashboard-title { font-weight: 600; font-size: 14px; }

/* Verification UI */
.verify-actions { display: inline-flex; gap: 4px; align-items: center; margin-left: 8px; }
.verify-select { padding: 2px 6px; font-size: 12px; border-radius: 4px; border: 1px solid var(--border); background: var(--surface2); color: var(--text); }
.verify-badge { display: inline-flex; gap: 6px; align-items: center; font-size: 12px; margin-left: 8px; padding: 2px 8px; border-radius: 4px; }
.verify-pending { background: rgba(255, 170, 0, 0.15); color: #ffaa00; }
.verify-confirmed { background: rgba(0, 200, 100, 0.15); color: #00c864; }
.verify-input { width: 80px; padding: 2px 6px; font-size: 12px; border-radius: 4px; border: 1px solid var(--border); background: var(--surface2); color: var(--text); }

/* Course cards (merged courses + visibility) */
.course-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    margin-bottom: 10px;
    box-shadow: var(--shadow-sm);
    overflow: hidden;
}

.course-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    padding: 14px 16px;
    transition: background var(--transition);
}
.course-card-header.collapsible-header:hover { background: var(--surface2); }

.course-card-info { flex: 1; min-width: 0; }
.course-card-name {
    font-weight: 600;
    font-size: 14px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.course-card-meta { color: var(--text2); font-size: 12px; margin-top: 3px; }

.course-card-controls {
    display: flex;
    align-items: center;
    flex-shrink: 0;
    gap: 6px;
}

.course-card-groups {
    border-top: 1px solid var(--border);
    background: var(--surface2);
    padding: 4px 16px;
}

.vis-group-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 0;
    border-bottom: 1px solid var(--border);
}
.vis-group-row:last-child { border-bottom: none; }
.vis-group-name { font-weight: 500; font-size: 13px; }

/* Course tree in progress */
.course-block { margin-bottom: 16px; }
.course-label {
    font-size: 13px;
    font-weight: 600;
    color: var(--accent);
    margin-bottom: 6px;
    padding-left: 4px;
}

/* Onboarding checklist */
.onboarding-panel {
    background: var(--surface);
    border: 1px solid var(--accent);
    border-radius: var(--radius-lg);
    padding: 20px;
    margin-bottom: 20px;
    box-shadow: 0 0 0 1px var(--accent-soft), var(--shadow-md);
}

.onboarding-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 12px;
}
.onboarding-header h3 { font-size: 16px; font-weight: 600; flex: 1; }
.onboarding-meta { color: var(--text2); font-size: 13px; }

.btn-icon {
    background: none;
    border: none;
    color: var(--text2);
    font-size: 20px;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 4px;
    line-height: 1;
    transition: color var(--transition);
}
.btn-icon:hover { color: var(--text); }

.onboarding-progress {
    height: 4px;
    background: var(--surface2);
    border-radius: 2px;
    margin-bottom: 16px;
    overflow: hidden;
}
.onboarding-progress-bar {
    height: 100%;
    background: var(--accent);
    border-radius: 2px;
    transition: width 0.4s ease;
}

.onboarding-steps { display: flex; flex-direction: column; gap: 4px; }

.onboarding-step {
    display: flex;
    gap: 12px;
    align-items: flex-start;
    padding: 8px 0;
}

.onboarding-step-indicator {
    flex-shrink: 0;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.onboarding-step-indicator .circle {
    width: 12px;
    height: 12px;
    border: 2px solid var(--border);
    border-radius: 50%;
}

.onboarding-step.active .onboarding-step-indicator .circle {
    border-color: var(--accent);
    background: var(--accent-soft);
}

.onboarding-step-indicator .check {
    color: var(--green);
    font-size: 16px;
    font-weight: 700;
}

.onboarding-step-title {
    font-size: 14px;
    font-weight: 500;
    color: var(--text);
    padding-top: 2px;
}

.onboarding-step.done .onboarding-step-title {
    color: var(--text2);
    text-decoration: line-through;
}

.onboarding-step-help {
    margin-top: 6px;
    font-size: 13px;
    color: var(--text2);
    line-height: 1.5;
}
.onboarding-step-help a { color: var(--accent); text-decoration: none; }
.onboarding-step-help a:hover { text-decoration: underline; }

/* Toast notifications */
#toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 200;
    display: flex;
    flex-direction: column;
    gap: 8px;
    pointer-events: none;
}

.toast {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 18px;
    border-radius: var(--radius);
    background: var(--surface);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-lg);
    color: var(--text);
    font-size: 14px;
    pointer-events: auto;
    transform: translateX(120%);
    opacity: 0;
    transition: transform 0.3s ease, opacity 0.3s ease;
    max-width: 380px;
}

.toast-visible { transform: translateX(0); opacity: 1; }

.toast-icon { font-size: 16px; flex-shrink: 0; }
.toast-success { border-left: 3px solid var(--green); }
.toast-success .toast-icon { color: var(--green); }
.toast-error { border-left: 3px solid var(--red); }
.toast-error .toast-icon { color: var(--red); }
.toast-info { border-left: 3px solid var(--accent); }
.toast-info .toast-icon { color: var(--accent); }

/* ── Mobile Responsive ──────────────────────────────────────────── */

@media (max-width: 640px) {
    .app { padding: 12px; }

    header {
        flex-direction: column;
        gap: 12px;
        align-items: flex-start;
        padding: 12px 0;
    }

    .header-right {
        width: 100%;
        justify-content: flex-start;
        flex-wrap: wrap;
        gap: 8px;
    }

    .user-tag { width: 100%; font-size: 13px; }

    .tabs { overflow-x: auto; -webkit-overflow-scrolling: touch; }
    .tab { padding: 10px 16px; font-size: 13px; white-space: nowrap; }

    .section-header {
        flex-direction: column;
        gap: 8px;
        align-items: flex-start;
    }

    .card { padding: 14px; }
    .card-title { font-size: 15px; }

    .invite-box {
        flex-direction: column;
        gap: 8px;
        align-items: flex-start;
    }
    .invite-code { font-size: 16px; }

    .progress-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .progress-controls {
        width: 100%;
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }

    .view-toggle { width: 100%; }
    .view-toggle button {
        flex: 1;
        text-align: center;
        padding: 8px 12px;
    }

    .assignment-row { flex-wrap: wrap; gap: 4px; }
    .assignment-name { width: 100%; white-space: normal; }
    .assignment-due { font-size: 11px; }

    .modal {
        width: 95%;
        padding: 20px;
        max-height: 90vh;
        overflow-y: auto;
    }

    .member-row {
        flex-direction: column;
        gap: 4px;
        align-items: flex-start;
    }

    .verify-actions {
        display: flex;
        flex-wrap: wrap;
        gap: 4px;
        margin-left: 0;
        margin-top: 4px;
    }
    .verify-badge {
        margin-left: 0;
        margin-top: 4px;
        flex-wrap: wrap;
    }

    #toast-container {
        top: auto;
        bottom: 20px;
        right: 12px;
        left: 12px;
    }
    .toast { max-width: none; }

    .onboarding-panel { padding: 16px; }
    .course-card-header { flex-wrap: wrap; }
}

@media (max-width: 380px) {
    .app { padding: 8px; }
    header h1 { font-size: 18px; }
    .auth-screen h1 { font-size: 26px; }
    .btn-small { padding: 6px 10px; font-size: 11px; }
}
