/* Light Theme Variables */
:root {
    --bg-base: #ffffff;
    --bg-secondary: #f8fafc;
    --text-primary: #1e293b;
    --text-muted: #64748b;
    --border-color: #e2e8f0;
    --accent-color: #3b82f6;
    
    --radius-md: 8px;
    
    /* Category Stripes */
    --c-bsm: #94a3b8;
    --c-mreq: #10b981;
    --c-msel: #6366f1; /* Indigo */
    --c-cap: #f43f5e;
}

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

body {
    font-family: 'Pretendard', 'Outfit', sans-serif;
    background: var(--bg-base);
    color: var(--text-primary);
    overflow-x: hidden;
}

.app-container {
    display: flex;
    flex-direction: column;
    height: 100vh;
}

/* Header */
.top-header {
    background: rgba(255,255,255,0.95);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--border-color);
    padding: 0.75rem 2rem 0;
    z-index: 100;
    display: flex;
    flex-direction: column;
    gap: 0;
    box-shadow: 0 4px 6px -1px rgba(0,0,0,0.05);
}

.header-row {
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
    padding-bottom: 0.55rem;
}

.logo-title-row {
    display: flex;
    align-items: center;
    gap: 0.2rem;
    flex-wrap: wrap;
}

@media (min-width: 768px) {
    .logo-title-row {
        gap: 0.4rem;
    }
}


.logo-title-row h1 {
    font-size: 1.3rem;
    font-weight: 800;
    color: #0f172a;
}
.logo-meta {
    font-size: 0.78rem;
    color: #334155;
}
.logo-meta strong {
    color: #0f172a;
    font-weight: 700;
}
.logo-specialties {
    display: flex;
    gap: 0.4rem;
    flex-wrap: wrap;
}
.specialty-badge {
    font-size: 0.68rem;
    font-weight: 700;
    padding: 0.15rem 0.5rem;
    border-radius: 10px;
}
.badge-lang     { background: #fef9c3; color: #854d0e; border: 1px solid #fde047; }
.badge-physical { background: #dbeafe; color: #1e40af; border: 1px solid #93c5fd; }
.badge-gov      { background: #fce7f3; color: #9d174d; border: 1px solid #f9a8d4; }
.badge-layer    { background: #f0fdf4; color: #166534; border: 1px solid #86efac; font-family: monospace; }

.controls-wrapper {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    padding: 0.4rem 0 0.5rem;
    min-width: 0;
}

.controls-wrapper.hidden {
    display: none;
}

/* Every filter row: [label | chip-group(scroll)] — single line, no exceptions */
.controls {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-wrap: nowrap;
    min-width: 0;
}

/* Action row: show-new + reset, right-aligned */
.filter-actions {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    justify-content: flex-end;
}

.filter-label {
    font-size: 0.85rem;
    font-weight: 400;
    color: #475569;
    width: 140px;
    flex-shrink: 0;
    white-space: nowrap;
}

/* chip-group: always single-line horizontal scroll within .controls */
.chip-group {
    display: flex;
    flex-wrap: nowrap;
    gap: 0.5rem;
    flex: 1;
    min-width: 0;
    overflow-x: auto;
    scrollbar-width: none;
    -ms-overflow-style: none;
}
.chip-group::-webkit-scrollbar { display: none; }

.filter-chip {
    padding: 0.4rem 0.8rem;
    border-radius: 20px;
    font-size: 0.8rem;
    border: 1px solid var(--border-color);
    background: white;
    cursor: pointer;
    transition: all 0.2s;
    font-weight: 500;
    color: #475569;
    white-space: nowrap;
    flex-shrink: 0;
}

.filter-chip:hover {
    background: #f1f5f9;
    color: #1e293b;
    border-color: #cbd5e1;
}

.filter-chip.active {
    font-weight: 700;
    border-width: 2px;
}

.reset-chip {
    border-color: #fca5a5;
    color: #ef4444;
}
.reset-chip:hover {
    background: #fef2f2;
    border-color: #ef4444;
}

/* MD filter chip — shares color with its parent track */
.md-filter-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.22rem 0.55rem;
    font-size: 0.72rem;
    white-space: nowrap;
}
.md-type-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 16px;
    height: 16px;
    border-radius: 4px;
    font-size: 0.65rem;
    font-weight: 800;
    background: currentColor;
    color: inherit;
    opacity: 0.25;
    flex-shrink: 0;
}
.md-filter-chip .md-type-badge {
    /* context_non_ai: 세로 soft gradient stripe (depth) */
    background-color: var(--md-color, #6366f1);
    background-image: repeating-linear-gradient(
        90deg,
        transparent       0px,
        rgba(255,255,255,0.85) 2.25px,
        transparent       4.5px
    );
    color: #fff;
    -webkit-text-stroke: 2px rgba(0,0,0,0.45);
    paint-order: stroke fill;
    opacity: 0.95;
}
.md-filter-chip .md-type-badge.breadth {
    /* breadth: 가로 soft gradient stripe (width) */
    background-image: repeating-linear-gradient(
        180deg,
        transparent       0px,
        rgba(255,255,255,0.85) 2.25px,
        transparent       4.5px
    );
}
.md-filter-chip.active .md-type-badge {
    opacity: 1;
}

/* Main Navigation Bar */
.main-nav {
    display: flex;
    align-items: center;
    gap: 0;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 0;
    margin-bottom: 0;
}

.main-nav-left {
    display: flex;
    align-items: center;
    flex: 1;
    gap: 0;
}

.main-nav-right {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding-left: 1rem;
    margin-left: auto;
}

/* Collapsed state: hide sub-nav and filter controls */
.top-header.filters-collapsed #main-sub-nav,
.top-header.filters-collapsed .controls-wrapper {
    display: none;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 0;
    padding: 0.45rem 1rem;
    font-size: 0.82rem;
    font-weight: 600;
    color: #64748b;
    cursor: pointer;
    border-bottom: 2px solid transparent;
    transition: color 0.15s, border-color 0.15s;
    white-space: nowrap;
    user-select: none;
    margin-bottom: -1px;
    text-decoration: none;
}

a.nav-sub-btn {
    text-decoration: none;
}

.nav-item:hover {
    color: #0f172a;
}

.nav-item.active {
    color: #0f172a;
    border-bottom-color: #0f172a;
}

.main-sub-nav {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 0.2rem 0.25rem 0;
    border-bottom: 1px solid var(--border-color);
}

.main-sub-nav:empty {
    display: none;
}

.nav-sub-btn {
    padding: 0.3rem 0.7rem;
    font-size: 0.78rem;
    font-weight: 600;
    cursor: pointer;
    border: none;
    border-bottom: 2px solid transparent;
    color: #64748b;
    background: transparent;
    transition: color 0.15s, border-color 0.15s;
    white-space: nowrap;
    margin-bottom: -1px;
}

.nav-sub-btn:hover {
    color: #0f172a;
}

.nav-sub-btn.active {
    color: #0f172a;
    font-weight: 700;
    border-bottom-color: #0f172a;
}

.show-new-toggle {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 0.8rem;
    font-weight: 600;
    color: #475569;
    cursor: pointer;
    white-space: nowrap;
}

.legend {
    display: flex;
    flex-direction: row;
    gap: 1rem;
    font-size: 0.75rem;
    color: var(--text-muted);
    align-items: center;
    position: sticky;
    left: 0;
    margin-bottom: 0.75rem;
    width: fit-content;
}
.legend-item { display: flex; align-items: center; gap: 0.3rem; white-space: nowrap; }
.legend-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.legend-dot-track { width: 8px; height: 8px; border-radius: 3px; flex-shrink: 0; background: var(--accent-color); opacity: 0.7; }

/* Roadmap Container */
.roadmap-wrapper {
    flex: 1;
    overflow: auto;
    padding: 1rem;
    background: var(--bg-secondary);
}

/* Grid Table Structure */
.roadmap-table {
    display: grid;
    /* First col fixed (Sem), then N cols dynamically */
    /* First col fixed (Sem), then N cols dynamically */
    grid-template-columns: 80px repeat(var(--col-count, 1), minmax(110px, 130px));
    
    /* Ensure table takes full width of content so borders don't cut off */
    width: max-content; 
    min-width: 100%; /* At least full screen */
    
    background: white;
    border-radius: var(--radius-md);
    
    /* border: 1px solid var(--border-color); -> Removed general border to handle via cells */
    border-bottom: 1px solid var(--border-color); /* Keep bottom border */
    border-right: 1px solid var(--border-color); /* Keep right border */
    border-left: 1px solid var(--border-color); /* Keep left border */
    /* border-radius: var(--radius-md); -> Removed top radius */
    border-bottom-left-radius: var(--radius-md);
    border-bottom-right-radius: var(--radius-md);
    
    box-shadow: 0 4px 6px -1px rgba(0,0,0,0.02);
    /* No flex-direction needed, grid handles 2D */
}

/* Flatten header/row containers to let children participate in Grid */
.table-header, .table-row {
    display: contents;
}

/* Header Cells */
.col-header {
    /* flex: 1 removed */
    text-align: center;
    padding: 0.6rem;
    font-weight: 700;
    border-right: 1px solid var(--border-color);
    border-bottom: 2px solid var(--border-color); /* Moved from .table-header */
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    cursor: pointer;
    font-size: 0.8rem;
    color: #334155;
    transition: background 0.2s, color 0.2s;
    background: #f8fafc; /* Ensure background since parent is gone */
    
    /* Sticky Header */
    position: sticky;
    top: 0;
    z-index: 50;
    border-top: 1px solid var(--border-color); /* Explicit Top Border */
    
    /* Text Wrap */
    word-break: break-word; /* Ensure long words break */
    overflow-wrap: anywhere;
    hyphens: auto;
}
.col-header:hover { 
    background: #e2e8f0; 
    color: var(--accent-color);
    text-decoration: underline;
}

/* First Column Header (Top Left Corner) */
.col-header:first-of-type {
    border-top-left-radius: 8px;
    border-left: 1px solid var(--border-color); /* Explicit Left */
    z-index: 60; /* Higher priority */
}

/* Last Column Header (Top Right Corner) */
.col-header:last-of-type {
    border-top-right-radius: 8px;
    border-right: 1px solid var(--border-color); /* Explicit Right */
}
.col-header.semester-col { 
    /* flex removed */
    background: #f1f5f9; 
    cursor: default; 
    pointer-events: none; 
    /* Sticky Left Top Corner */
    position: sticky;
    left: 0;
    top: 0;
    z-index: 60; /* Higher than row labels and other headers */
}

.col-color-indicator {
    width: 8px; height: 8px; border-radius: 50%;
    flex-shrink: 0;
}

/* Rows */
/* .table-row is display: contents, so we style children directly for borders */

.row-label {
    /* flex: 0 0 80px removed */
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    color: var(--text-muted);
    background: #f8fafc;
    border-right: 1px solid var(--border-color);
    border-bottom: 1px solid var(--border-color); /* Added */
    border-left: 1px solid var(--border-color); /* Added for Sticky Left alignment */
    
    /* Sticky Left Column */
    position: sticky;
    left: 0;
    z-index: 40;
}

.cell {
    /* flex: 1 removed */
    padding: 0.8rem;
    border-right: 1px solid var(--border-color);
    border-bottom: 1px solid var(--border-color); /* Added */
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    min-height: 60px;
    background: white;
    
    /* Text Wrap */
    word-break: break-word; 
    overflow-wrap: anywhere;
}

/* Track/MD 선택 시 셀 내 카드 2열 가로 배치 (컬럼이 2배 넓어진 상태) */
.cell--2col {
    flex-direction: row;
    flex-wrap: wrap;
    align-content: flex-start;
    gap: 0.4rem;
}
.cell--2col .course-card {
    flex: 0 0 130px;  /* 컬럼이 max-content로 자동 확장되므로 % 대신 px 고정 */
    min-width: 0;
}

/* Course Card */
.course-card {
    padding: 0.5rem;
    background: white;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    font-size: 0.7rem;
    position: relative;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
    overflow: hidden;
    line-height: 1.3;

    min-height: 50px;
    height: auto;
    display: flex;
    flex-direction: column;
    justify-content: space-between;

    /* Text Wrap */
    word-break: keep-all; /* Prefer keeping words together */
    overflow-wrap: break-word;
}

/* Category Stripe */
.course-card::before {
    content: '';
    position: absolute;
    left: 0; top: 0; bottom: 0;
    width: 4px;
    background: #cbd5e1;
}
.course-card[data-cat="BSM"]::before { background: var(--c-bsm); }
.course-card[data-cat="Major_Req"]::before { background: var(--c-mreq); }
.course-card[data-cat="Major_Sel"]::before { background: var(--c-msel); }
.course-card[data-cat="Capstone"]::before { background: var(--c-cap); }

/* --- Status States --- */
/* Suggested / Planned (Dashed) */
.course-card.suggested {
    border-style: dashed;
    border-width: 2px;
    background: #fdfdfd; 
    color: #475569;
}
.course-card.suggested::after {
    content: '';
}

.course-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0,0,0,0.08);
    z-index: 10;
    border-color: #94a3b8;
}

.course-card.highlighted {
    background: #eff6ff;
    border-color: var(--accent-color);
    box-shadow: 0 0 0 1px var(--accent-color);
    font-weight: 600;
    color: #1e293b;
    border-style: solid; /* Override dashed if highlighted? Or keep dashed? Keep dashed if suggested */
}
/* If highlighted AND suggested, maybe keep dashed but blue border? */
.course-card.suggested.highlighted {
    border-style: dashed;
    border-width: 2px;
}

/* Track Badges */
.track-badges {
    display: flex;
    gap: 4px;
    margin-top: 4px;
    flex-wrap: nowrap;
    overflow: hidden;
}

.track-badges.expanded {
    flex-wrap: wrap;
    overflow: visible;
}

.track-badge-more {
    cursor: pointer;
    background: #f1f5f9;
    border-color: #94a3b8;
    color: #475569;
    flex-shrink: 0;
}
.track-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 15px;
    height: 15px;
    border-radius: 50%;
    background: #e2e8f0;
    color: #475569;
    font-size: 0.6rem;
    font-weight: 700;
    border: 1px solid #cbd5e1;
}


.course-card.dimmed {
    opacity: 0.25;
}
.course-card.similar {
    /* bg color set by JS */
    font-weight: 600;
}

/* Modal */
.modal {
    position: fixed; inset: 0;
    background: rgba(0,0,0,0.4);
    display: flex; justify-content: center; align-items: center;
    z-index: 200;
    opacity: 0; pointer-events: none;
    transition: opacity 0.2s;
    backdrop-filter: blur(2px);
}
.modal.visible { opacity: 1; pointer-events: auto; }
.modal-box {
    background: white;
    width: 420px;
    padding: 2rem;
    border-radius: 12px;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1);
    border: 1px solid var(--border-color);
}

/* Scrollbar */
::-webkit-scrollbar {
    height: 10px; width: 10px;
}
::-webkit-scrollbar-track { background: #f1f5f9; }
::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 5px; }
::-webkit-scrollbar-thumb:hover { background: #94a3b8; }

/* View Mode Toggles */
.view-mode-group {
    display: flex;
    align-items: center;
}

.view-btn {
    font-family: inherit;
    transition: all 0.2s;
}

.view-btn:hover {
    background: #f8fafc;
    border-color: #cbd5e1;
    color: #0f172a;
}

.view-btn.active {
    box-shadow: 0 1px 2px rgba(0,0,0,0.05);
}
.view-btn.active:hover {
    background: #1e293b;
    border-color: #1e293b;
    color: white;
}

/* =====================================================
   Track Overview Styles
   ===================================================== */

.roadmap-table.track-overview-mode {
    display: block;
    width: 100%;
    min-width: 0;
    background: transparent;
    border: none;
    box-shadow: none;
    border-radius: 0;
}

.track-overview-wrapper {
    display: flex;
    flex-direction: column;
    gap: 2rem;
    max-width: 1400px;
    margin: 0 auto;
}

.track-overview-header {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.track-overview-title h2 {
    font-size: 1.5rem;
    font-weight: 800;
    color: #0f172a;
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.track-overview-badge {
    font-size: 0.75rem;
    font-weight: 700;
    background: #0f172a;
    color: #fff;
    padding: 0.2rem 0.6rem;
    border-radius: 20px;
    vertical-align: middle;
}

.track-overview-title p {
    font-size: 0.9rem;
    color: #64748b;
    margin-top: 0.25rem;
}

.track-overview-meta {
    display: flex;
    gap: 1.5rem;
    flex-wrap: wrap;
    font-size: 0.8rem;
    color: #94a3b8;
    padding: 0.6rem 1rem;
    background: #f8fafc;
    border-radius: 8px;
    border: 1px solid #e2e8f0;
}

/* Overview Bar: 6 dept cells */
.track-number-bar {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 0.75rem;
}

.track-number-cell {
    border: 2px solid;
    border-radius: 10px;
    overflow: hidden;
    background: #fff;
    transition: transform 0.15s, box-shadow 0.15s;
}

.track-number-cell:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 16px rgba(0,0,0,0.1);
}

.track-number-header {
    padding: 0.6rem 0.75rem;
    color: white;
}

.track-numbers {
    font-size: 0.78rem;
    font-weight: 700;
    line-height: 1.6;
}

.track-number-dept {
    padding: 0.4rem 0.75rem;
    font-size: 0.78rem;
    font-weight: 700;
    color: #1e293b;
    border-bottom: 1px solid #e2e8f0;
}

.track-number-ax {
    padding: 0.4rem 0.75rem 0.5rem;
    font-size: 0.7rem;
    color: #64748b;
    line-height: 1.5;
}

.ax-label {
    display: inline-block;
    font-size: 0.65rem;
    font-weight: 700;
    background: #e2e8f0;
    color: #475569;
    border-radius: 4px;
    padding: 0.1rem 0.35rem;
    margin-right: 0.3rem;
    margin-bottom: 0.2rem;
}

/* Department Section */
.track-dept-section {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    padding: 1.5rem;
    background: #fff;
    border-radius: 12px;
    border: 1px solid #e2e8f0;
    box-shadow: 0 2px 4px rgba(0,0,0,0.03);
}

.track-dept-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.track-dept-badge {
    font-size: 0.7rem;
    font-weight: 700;
    color: #fff;
    padding: 0.25rem 0.6rem;
    border-radius: 20px;
}

.track-dept-name {
    font-size: 1.15rem;
    font-weight: 800;
    color: #0f172a;
}

/* Track Cards Row: 2 cards side by side */
.track-cards-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

.track-card {
    border: 2px solid var(--track-color);
    border-radius: 10px;
    overflow: hidden;
    background: #fff;
    display: flex;
    flex-direction: column;
}

.track-card-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    color: white;
}

.track-card-number {
    font-size: 0.8rem;
    font-weight: 800;
    background: rgba(255,255,255,0.25);
    padding: 0.2rem 0.5rem;
    border-radius: 6px;
    white-space: nowrap;
}

.track-card-name {
    font-size: 1.05rem;
    font-weight: 800;
}

.track-card-desc {
    padding: 0.6rem 1rem;
    font-size: 0.78rem;
    color: #64748b;
    line-height: 1.5;
    border-bottom: 1px dashed #e2e8f0;
}

.track-card-courses {
    padding: 0.75rem 1rem 0.75rem 2rem;
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
    flex: 1;
}

.track-card-courses li {
    font-size: 0.82rem;
    color: #334155;
    line-height: 1.4;
}

.track-card-courses li::marker {
    color: var(--track-color);
}

/* AX Row */
.track-ax-row {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.6rem 0.75rem;
    background: #f8fafc;
    border-radius: 8px;
    border: 1px solid #e2e8f0;
    flex-wrap: wrap;
}

.track-ax-label {
    font-size: 0.75rem;
    font-weight: 700;
    color: #475569;
    white-space: nowrap;
    padding: 0.2rem 0.6rem;
    background: #e2e8f0;
    border-radius: 6px;
}

.track-ax-partners {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.track-ax-chip {
    font-size: 0.78rem;
    color: #334155;
    background: #fff;
    border: 1px solid #cbd5e1;
    padding: 0.2rem 0.65rem;
    border-radius: 20px;
    font-weight: 500;
}

/* ── 4×2 Semester grid ── */
.track-semester-grid {
    display: grid;
    grid-template-columns: 42px 1fr 1fr;
    gap: 4px;
    padding: 0.6rem;
}
.track-semester-col-header {
    font-size: 0.68rem;
    font-weight: 600;
    text-align: center;
    padding: 3px 4px;
    background: #f1f5f9;
    border-radius: 4px;
    color: #64748b;
}
.track-grade-label {
    font-size: 0.68rem;
    font-weight: 600;
    color: #94a3b8;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding-top: 5px;
    white-space: nowrap;
}
.track-semester-cell {
    background: #fafafa;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    padding: 4px;
    min-height: 28px;
    display: flex;
    flex-wrap: wrap;
    gap: 3px;
    align-content: flex-start;
}

/* ── Course chip grid (legacy flat, kept for compatibility) ── */
.track-course-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
    padding: 0.75rem;
    align-content: flex-start;
    flex: 1;
}

.course-chip {
    display: inline-block;
    font-size: 0.75rem;
    font-weight: 500;
    padding: 0.22rem 0.55rem;
    border-radius: 6px;
    border: 1px solid transparent;
    line-height: 1.35;
    cursor: default;
    transition: opacity 0.15s;
}
.course-chip:hover { opacity: 0.8; }

/* 기초/교양 — neutral gray */
.course-chip.cat-bsm {
    background: #f1f5f9;
    color: #475569;
    border-color: #cbd5e1;
}
/* 전공필수 — amber/yellow */
.course-chip.cat-req {
    background: #fef9c3;
    color: #854d0e;
    border-color: #fde047;
}
/* 전공선택 공통 — green */
.course-chip.cat-common {
    background: #dcfce7;
    color: #166534;
    border-color: #86efac;
}
/* 전공선택 트랙별 — dept color (set via JS inline style) */
.course-chip.cat-track {
    /* fallback if JS doesn't run */
    background: #eff6ff;
    color: #1d4ed8;
    border-color: #93c5fd;
}
/* 캡스톤/PBL — coral/rose */
.course-chip.cat-cap {
    background: #fce7f3;
    color: #9d174d;
    border-color: #f9a8d4;
}

/* Category legend inside track overview header */
.track-cat-legend {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    margin-top: 0.5rem;
}
.legend-chip {
    font-size: 0.72rem;
    font-weight: 600;
    padding: 0.2rem 0.6rem;
    border-radius: 6px;
    border: 1px solid transparent;
}
.legend-chip.cat-bsm    { background: #f1f5f9; color: #475569; border-color: #cbd5e1; }
.legend-chip.cat-req    { background: #fef9c3; color: #854d0e; border-color: #fde047; }
.legend-chip.cat-common { background: #dcfce7; color: #166534; border-color: #86efac; }
.legend-chip.cat-track-demo { background: #eff6ff; color: #1d4ed8; border-color: #93c5fd; }
.legend-chip.cat-cap    { background: #fce7f3; color: #9d174d; border-color: #f9a8d4; }

/* Track / Layer filter group pill in header */
.track-filter-chip,
.layer-filter-chip {
    font-size: 0.75rem !important;
    padding: 0.3rem 0.65rem !important;
    border-radius: 16px !important;
    background: transparent !important;
}

/* Responsive: narrower screens */
@media (max-width: 900px) {
    .track-number-bar {
        grid-template-columns: repeat(3, 1fr);
    }
    .track-cards-row {
        grid-template-columns: 1fr;
    }
}

/* ── Faculty View ──────────────────────────────────────────── */
.faculty-wrapper {
    padding: 1.5rem 2rem 3rem;
    max-width: 1400px;
    margin: 0 auto;
}

.faculty-header {
    margin-bottom: 2rem;
}

.faculty-section {
    margin-bottom: 2.5rem;
}

.faculty-section-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 2px solid #f1f5f9;
}

.faculty-dept-badge {
    font-size: 0.7rem;
    font-weight: 700;
    color: #fff;
    padding: 0.2rem 0.55rem;
    border-radius: 4px;
    letter-spacing: 0.03em;
}

.faculty-dept-name {
    font-size: 1rem;
    font-weight: 700;
    margin: 0;
}

.faculty-dept-count {
    font-size: 0.8rem;
    color: #94a3b8;
    font-weight: 600;
    margin-left: auto;
}

.faculty-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 0.85rem;
}

.faculty-card {
    background: #fff;
    border: 1.5px solid #e2e8f0;
    border-radius: 12px;
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
    transition: box-shadow 0.15s, border-color 0.15s;
    border-top: 3px solid var(--fc-color, #64748b);
}

.faculty-card:hover {
    box-shadow: 0 4px 16px rgba(0,0,0,0.08);
    border-color: var(--fc-color, #64748b);
}

.faculty-card-top {
    display: flex;
    align-items: center;
    gap: 0.65rem;
}

.faculty-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    font-weight: 700;
    flex-shrink: 0;
}

.faculty-card-info {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
    min-width: 0;
}

.faculty-name {
    font-size: 0.95rem;
    font-weight: 700;
    color: #0f172a;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    display: flex;
    align-items: center;
    gap: 0.35rem;
    flex-wrap: wrap;
}

.faculty-role-badge {
    font-size: 0.62rem;
    font-weight: 600;
    color: #fff;
    background: #f59e0b;
    padding: 0.1rem 0.4rem;
    border-radius: 4px;
    white-space: nowrap;
}

.faculty-pos {
    font-size: 0.78rem;
    font-weight: 600;
}

.faculty-dept-note {
    font-size: 0.7rem;
    color: #94a3b8;
}

.faculty-major {
    font-size: 0.78rem;
    color: #475569;
    display: flex;
    align-items: center;
    gap: 0.35rem;
}

.faculty-major-label {
    font-size: 0.65rem;
    font-weight: 700;
    background: #f1f5f9;
    color: #64748b;
    padding: 0.1rem 0.4rem;
    border-radius: 4px;
    flex-shrink: 0;
}

.faculty-keywords {
    display: flex;
    flex-wrap: wrap;
    gap: 0.3rem;
}

.faculty-kw {
    font-size: 0.68rem;
    font-weight: 500;
    padding: 0.15rem 0.5rem;
    border-radius: 10px;
    border: 1px solid transparent;
    line-height: 1.4;
}

/* ── Track card PBL strip ───────────────────────────────────── */
.track-pbl-strip {
    margin-top: 0.75rem;
    padding: 0.6rem 0.75rem;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

.pbl-strip-top {
    display: flex;
    align-items: baseline;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.pbl-strip-label {
    font-size: 0.62rem;
    font-weight: 800;
    letter-spacing: 0.08em;
    background: #0f172a;
    color: #fff;
    padding: 0.1rem 0.4rem;
    border-radius: 4px;
    flex-shrink: 0;
}

.pbl-strip-course {
    font-size: 0.75rem;
    font-weight: 600;
    color: #1e293b;
}

.pbl-strip-companies {
    display: flex;
    align-items: center;
    gap: 0.3rem;
    flex-wrap: wrap;
}

.pbl-company-chip {
    font-size: 0.68rem;
    font-weight: 600;
    padding: 0.15rem 0.5rem;
    border-radius: 10px;
    background: var(--fc-color, #64748b);
    color: #fff;
    opacity: 0.85;
    cursor: default;
}
.track-pbl-strip .pbl-company-chip {
    background: #475569;
}

.pbl-x {
    font-size: 0.65rem;
    color: #94a3b8;
    font-weight: 700;
}

/* ── PBL View ────────────────────────────────────────────────── */
.pbl-wrapper {
    padding: 1.5rem 2rem 3rem;
    max-width: 1400px;
    margin: 0 auto;
}

.pbl-header {
    margin-bottom: 2rem;
}

.pbl-dept-section {
    margin-bottom: 2.5rem;
}

.pbl-cards-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
    gap: 1rem;
}

.pbl-card {
    background: #fff;
    border: 1.5px solid #e2e8f0;
    border-radius: 12px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    border-top: 3px solid var(--pbl-color, #64748b);
    transition: box-shadow 0.15s;
}

.pbl-card:hover {
    box-shadow: 0 4px 16px rgba(0,0,0,0.08);
}

.pbl-card-header {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.55rem 0.9rem;
    color: #fff;
}

.pbl-track-num {
    font-size: 0.75rem;
    font-weight: 800;
    background: rgba(255,255,255,0.25);
    padding: 0.1rem 0.45rem;
    border-radius: 5px;
}

.pbl-track-name {
    font-size: 0.85rem;
    font-weight: 700;
}

.pbl-card-body {
    padding: 0.85rem 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.55rem;
    flex: 1;
}

.pbl-course-name {
    font-size: 0.88rem;
    font-weight: 700;
    color: #0f172a;
    line-height: 1.35;
}

.pbl-companies {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    flex-wrap: wrap;
}

.pbl-card-company {
    font-size: 0.72rem;
    font-weight: 600;
    padding: 0.2rem 0.6rem;
    border-radius: 12px;
    background: #f1f5f9;
    color: #475569;
    border: 1px solid #e2e8f0;
    cursor: default;
    transition: background 0.1s;
}

.pbl-card-company.pbl-company-highlight {
    background: #fef3c7;
    color: #92400e;
    border-color: #fde68a;
}

.pbl-worv-badge {
    font-size: 0.6rem;
    font-weight: 800;
    letter-spacing: 0.06em;
    background: #f59e0b;
    color: #fff;
    padding: 0.05rem 0.3rem;
    border-radius: 3px;
    vertical-align: middle;
}

.pbl-objective {
    font-size: 0.78rem;
    color: #334155;
    line-height: 1.55;
    margin: 0;
}

.pbl-details {
    margin-top: 0.2rem;
}

.pbl-details summary {
    font-size: 0.72rem;
    font-weight: 600;
    color: var(--pbl-color, #64748b);
    cursor: pointer;
    user-select: none;
    list-style: none;
    display: flex;
    align-items: center;
    gap: 0.3rem;
}

.pbl-details summary::-webkit-details-marker { display: none; }
.pbl-details summary::before {
    content: '▶';
    font-size: 0.55rem;
    transition: transform 0.15s;
}
.pbl-details[open] summary::before { transform: rotate(90deg); }

.pbl-content {
    font-size: 0.75rem;
    color: #475569;
    line-height: 1.6;
    margin: 0.5rem 0 0;
    padding-top: 0.4rem;
    border-top: 1px solid #f1f5f9;
}

/* ═══════════════════════════════════════════════════
   FUSION MD VIEW — legend bar above the main grid
   ═══════════════════════════════════════════════════ */

/* Legend bar (sticky above the grid) */
.fusion-legend-bar {
    padding: 0.75rem 1.5rem 0.6rem;
    background: #f8fafc;
    border-bottom: 2px solid #e2e8f0;
    position: sticky;
    top: 0;
    z-index: 10;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

/* MD chip row — clickable, inside fusion legend bar */
.fusion-md-legend {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    font-size: 0.82rem;
}
.fusion-md-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.3rem 0.75rem 0.3rem 0.5rem;
    border-radius: 20px;
    border: 1.5px solid color-mix(in srgb, var(--md-chip-color, #6366f1) 40%, transparent);
    background: color-mix(in srgb, var(--md-chip-color, #6366f1) 8%, #fff);
    color: var(--text-primary);
    font-size: 0.82rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s;
}
.fusion-md-chip:hover {
    border-color: var(--md-chip-color, #6366f1);
    background: color-mix(in srgb, var(--md-chip-color, #6366f1) 15%, #fff);
}
.fusion-md-chip.active {
    background: var(--md-chip-color, #6366f1);
    border-color: var(--md-chip-color, #6366f1);
    color: #fff;
}
.fusion-md-chip.active small { color: rgba(255,255,255,0.8); }
.fusion-md-chip-title { font-weight: 700; }
.fusion-md-chip small {
    font-weight: 400;
    color: var(--text-muted);
    margin-left: 0.1rem;
}
.fusion-md-legend-dot {
    width: 9px;
    height: 9px;
    border-radius: 50%;
    flex-shrink: 0;
}

/* Fusion major selector tabs */
.fusion-tab-bar {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
}
.fusion-tab {
    padding: 0.45rem 1rem;
    border-radius: 20px;
    border: 1.5px solid #e2e8f0;
    background: #fff;
    color: #64748b;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s;
}
.fusion-tab:hover { border-color: #6366f1; color: #6366f1; }
.fusion-tab.active {
    background: #6366f1;
    border-color: #6366f1;
    color: #fff;
}

/* ── Main 2-dept semester grid ── */
.fg2-grid {
    display: grid;
    grid-template-columns: 72px 1fr 1.4fr;
    grid-template-rows: auto repeat(8, minmax(64px, auto));
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    overflow: hidden;
    margin-bottom: 1.5rem;
    background: var(--bg-base);
}

/* Header row */
.fg2-head {
    padding: 0.75rem 1rem;
    font-size: 0.82rem;
    font-weight: 600;
    background: var(--bg-secondary);
    border-bottom: 2px solid #e2e8f0;
    display: flex;
    align-items: center;
    gap: 0.4rem;
}
.fg2-head-sem {
    color: var(--text-muted);
    justify-content: center;
    border-right: 1px solid #e2e8f0;
}
.fg2-head-dept {
    border-right: 1px solid #e2e8f0;
}
.fg2-head-dept small { font-weight: 400; color: var(--text-muted); }

/* Semester label cells */
.fg2-sem {
    position: relative;
    z-index: 3;
    padding: 0.25rem;
    text-align: center;
    font-size: 0.72rem;
    font-weight: 700;
    color: var(--text-muted);
    border-right: 1px solid #e2e8f0;
    border-bottom: 1px solid #f1f5f9;
    background: var(--bg-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Course cells */
.fg2-cell {
    position: relative;
    z-index: 2;
    padding: 8px;
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    align-content: flex-start;
    border-right: 1px solid #e2e8f0;
    border-bottom: 1px solid #f1f5f9;
    background: transparent;
    min-height: 64px;
}

/* Course chips */
.fg2-chip {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 7px 3px 5px;
    border-radius: 5px;
    background: #fff;
    border: 1px solid #e2e8f0;
    border-left-width: 3px;
    font-size: 0.75rem;
    line-height: 1.3;
    box-shadow: 0 1px 2px rgba(0,0,0,0.05);
}
.fg2-bridge-chip {
    border-style: dashed;
    border-left-style: solid;
}
.fg2-layer {
    padding: 1px 5px;
    border-radius: 3px;
    color: #fff;
    font-size: 0.65rem;
    font-weight: 700;
    letter-spacing: 0.02em;
    flex-shrink: 0;
}
.fg2-cat {
    padding: 1px 5px;
    border-radius: 3px;
    color: #fff;
    font-size: 0.65rem;
    font-weight: 600;
    flex-shrink: 0;
}
.fg2-name {
    color: var(--text-primary);
    font-size: 0.76rem;
}
.fg2-bridge-tag {
    padding: 1px 4px;
    border-radius: 3px;
    background: #fef3c7;
    color: #92400e;
    font-size: 0.62rem;
    font-weight: 700;
    flex-shrink: 0;
}

/* MD overlay boxes — sit behind course cells (z-index: 1 < cell z-index: 2) */
.fg2-overlay {
    position: relative;
    z-index: 1;
    border-radius: 6px;
    border-left: 3px solid var(--ov-color, #6366f1);
    background: color-mix(in srgb, var(--ov-color, #6366f1) 9%, transparent);
    pointer-events: none;
    display: flex;
    align-items: flex-start;
    padding: 6px 4px;
}
.fg2-ov-context {
    border-top: 1px dashed color-mix(in srgb, var(--ov-color, #6366f1) 35%, transparent);
    border-bottom: 1px dashed color-mix(in srgb, var(--ov-color, #6366f1) 35%, transparent);
    border-right: 1px dashed color-mix(in srgb, var(--ov-color, #6366f1) 35%, transparent);
}
.fg2-ov-breadth {
    border-top: 1px dashed color-mix(in srgb, var(--ov-color, #f59e0b) 35%, transparent);
    border-bottom: 1px dashed color-mix(in srgb, var(--ov-color, #f59e0b) 35%, transparent);
    border-right: 1px dashed color-mix(in srgb, var(--ov-color, #f59e0b) 35%, transparent);
}
.fg2-ov-label {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 8px;
    border-radius: 4px;
    color: #fff;
    font-size: 0.7rem;
    font-weight: 700;
    white-space: nowrap;
    flex-shrink: 0;
}
.fg2-ov-label em {
    font-style: normal;
    font-weight: 400;
    opacity: 0.85;
}

/* Summary bar */
.fusion-summary {
    padding: 0.85rem 1.25rem;
    background: #f0fdf4;
    border: 1.5px solid #bbf7d0;
    border-radius: 10px;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-wrap: wrap;
    font-size: 0.88rem;
    color: #166534;
}
.fusion-sum-item { color: #15803d; }
.fusion-sum-plus, .fusion-sum-eq { font-weight: 700; color: #166534; }
.fusion-sum-eq { font-size: 1.1rem; }
.fusion-sum-total { font-size: 1rem; color: #14532d; }

@media (max-width: 900px) {
    .fg2-grid { grid-template-columns: 48px 1fr 1fr; }
    .fusion-wrapper { padding: 1rem; }
}

/* ══════════════════════════════════════════════════════════════
   MOBILE RESPONSIVE — shared across all pages using curriculum.css
   ══════════════════════════════════════════════════════════════ */

/* Tablet: ≤ 900px */
@media (max-width: 900px) {
    .top-header {
        padding: 0.5rem 1rem 0;
    }
    .header-row {
        padding-bottom: 0.35rem;
    }
    .logo-title-row h1 {
        font-size: 1.05rem;
    }
    .logo-meta {
        font-size: 0.68rem;
        line-height: 1.4;
    }
    .main-nav-left {
        overflow-x: auto;
        scrollbar-width: none;
        -ms-overflow-style: none;
    }
    .main-nav-left::-webkit-scrollbar { display: none; }
    .nav-item {
        padding: 0.4rem 0.7rem;
        font-size: 0.75rem;
    }
    .main-sub-nav {
        overflow-x: auto;
        scrollbar-width: none;
        -ms-overflow-style: none;
    }
    .main-sub-nav::-webkit-scrollbar { display: none; }
    .nav-sub-btn {
        font-size: 0.72rem;
        padding: 0.25rem 0.55rem;
    }
    .filter-label {
        width: auto;
        font-size: 0.75rem;
    }
    .filter-chip {
        font-size: 0.72rem;
        padding: 0.3rem 0.6rem;
    }
    .faculty-wrapper {
        padding: 1rem;
    }
    .faculty-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* Mobile: ≤ 480px */
@media (max-width: 480px) {
    .top-header {
        padding: 0.4rem 0.75rem 0;
    }
    .logo-title-row h1 {
        font-size: 0.9rem;
    }
    .logo-meta {
        display: none;
    }
    .logo-specialties {
        display: none;
    }
    .nav-item {
        padding: 0.35rem 0.5rem;
        font-size: 0.7rem;
    }
    .nav-sub-btn {
        font-size: 0.68rem;
        padding: 0.2rem 0.45rem;
    }
    .controls-wrapper {
        padding: 0.25rem 0 0.35rem;
    }
    .filter-label {
        display: none;
    }
    .controls {
        gap: 0.4rem;
    }
    .filter-chip {
        font-size: 0.68rem;
        padding: 0.25rem 0.5rem;
    }
    .faculty-grid {
        grid-template-columns: 1fr;
    }
    .pbl-cards-grid {
        grid-template-columns: 1fr;
    }
}
