:root {
    --bg-dark: #0f1117;
    --bg-card: rgba(30, 32, 45, 0.7);
    --text-primary: #ffffff;
    --text-secondary: rgba(255, 255, 255, 0.7);
    --accent: #4cc9f0;
    --accent-hover: #4895ef;
    --success: #4ade80;
    --error: #f72585;
    --glass-border: rgba(255, 255, 255, 0.1);
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    --sidebar-width: 320px;
    font-size: 18px;
    /* Base font size increased */
}

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

hr {
    border: none;
    height: 2px;
    background: linear-gradient(90deg, transparent, var(--accent), transparent);
    margin: 2rem 0;
    width: 100%;
    opacity: 0.8;
}

.clause-text-mini hr {
    margin: 1.2rem 0;
    height: 1.5px;
    background: linear-gradient(90deg, transparent, var(--accent), transparent);
    opacity: 0.6;
}

/* GitHub Sync Styles */
.github-sync-section {
    border: 1px solid rgba(76, 201, 240, 0.3) !important;
}

.github-connect-status {
    padding: 0.5rem 1rem;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 8px;
    margin-bottom: 1.5rem;
    font-size: 0.85rem;
    display: inline-block;
}

.github-connect-status.synced {
    color: var(--success);
    background: rgba(74, 222, 128, 0.1);
}

.github-settings-form {
    display: grid;
    gap: 1.2rem;
    text-align: left;
    margin-bottom: 1.5rem;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.form-group label {
    font-size: 0.85rem;
    color: var(--accent);
    font-weight: 600;
}

.form-group input {
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--glass-border);
    color: var(--text-primary);
    padding: 0.6rem 1rem;
    border-radius: 8px;
    font-family: inherit;
    font-size: 0.9rem;
}

.form-group input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 2px rgba(76, 201, 240, 0.2);
}

.form-group small {
    font-size: 0.75rem;
    opacity: 0.6;
}

.form-group small a {
    color: var(--accent);
    text-decoration: underline;
}

.github-sync-actions {
    display: flex;
    gap: 1rem;
    justify-content: flex-start;
}

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--bg-dark);
    color: var(--text-primary);
    overflow-x: hidden;
    line-height: 1.6;
}

.app-container {
    display: flex;
    min-height: 100vh;
    position: relative;
    width: 100%;
}

h1,
h2,
.quiz-title {
    font-family: 'Outfit', sans-serif;
}

.edit-badge {
    position: fixed;
    top: 10px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--error);
    color: white;
    padding: 0.2rem 1rem;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: bold;
    z-index: 2000;
    box-shadow: 0 4px 15px rgba(255, 71, 87, 0.4);
    display: none;
    pointer-events: none;
}

.edit-mode .edit-badge {
    display: block;
}

/* Dashboard Section */
.sidebar-dashboard {
    padding: 1rem;
    margin: 0.5rem;
    background: rgba(255, 255, 255, 0.03);
    border-radius: 12px;
    border: 1px solid var(--glass-border);
}

/* Home Dashboard Styles */
.home-dashboard {
    max-width: 1400px;
    margin: 2rem auto;
    padding: 2.5rem;
    background: var(--bg-card);
    backdrop-filter: blur(12px);
    border: 1px solid var(--glass-border);
    border-radius: 24px;
    text-align: center;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.3);
}

.welcome-banner {
    margin-bottom: 2.5rem;
}

.welcome-title {
    font-size: 2.2rem;
    background: linear-gradient(135deg, #fff 0%, var(--accent) 100%);
    background-clip: text;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    margin-bottom: 0.5rem;
}

.main-mountain-display {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
    margin-bottom: 3rem;
}

.main-stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1.5rem;
    width: 100%;
}


.main-stat-card.due-active {
    box-shadow: 0 0 20px rgba(247, 37, 133, 0.3);
    border-color: rgba(247, 37, 133, 0.5);
}

.main-stat-card.due-active .card-value {
    color: #f72585;
}

.ripple-card {
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
}

.ripple-card:hover {
    transform: translateY(-5px);
    background: rgba(255, 255, 255, 0.05);
}

.card-actions {
    margin-top: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.mini-btn {
    border: none;
    padding: 0.4rem 0.8rem;
    border-radius: 6px;
    font-size: 0.75rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    width: 100%;
}

.mini-btn.srs-clause {
    background: rgba(76, 201, 240, 0.2);
    color: #4cc9f0;
    border: 1px solid rgba(76, 201, 240, 0.3);
}

.mini-btn.srs-page {
    background: rgba(114, 9, 183, 0.2);
    color: #b5179e;
    border: 1px solid rgba(114, 9, 183, 0.3);
}

.mini-btn:hover {
    filter: brightness(1.2);
    transform: scale(1.02);
}

.due-questions-container {
    margin-top: 2rem;
    padding: 1.5rem;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 16px;
    border: 1px solid var(--glass-border);
    text-align: left;
    animation: fadeIn 0.3s ease-out;
}

.due-questions-container h3 {
    margin-bottom: 1rem;
    font-size: 1rem;
    color: var(--accent);
}

.due-table-wrapper {
    max-height: 300px;
    overflow-y: auto;
}

.due-table-wrapper table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
}

.due-table-wrapper th {
    text-align: left;
    padding: 0.75rem;
    border-bottom: 1px solid var(--glass-border);
    position: sticky;
    top: 0;
    background: #1e293b;
}

.due-table-wrapper td {
    padding: 0.75rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.due-table-wrapper tr:hover {
    background: rgba(255, 255, 255, 0.02);
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.main-stat-card {
    background: rgba(0, 0, 0, 0.3);
    padding: 1.5rem;
    border-radius: 16px;
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.card-label {
    display: block;
    font-size: 0.9rem;
    color: var(--accent);
    margin-bottom: 0.5rem;
}

.card-value {
    font-family: 'Outfit', sans-serif;
    font-size: 2rem;
    font-weight: 700;
    color: white;
}

.card-filter-section {
    margin: 0.5rem 0;
    padding: 0.5rem;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 10px;
    border: 1px solid var(--glass-border);
}

.card-mastery-select {
    width: 100%;
    background: transparent;
    border: none;
    color: var(--accent);
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    outline: none;
    text-align: center;
}

.card-mastery-select option {
    background: #1a1c27;
    color: white;
}

.main-daily-row {
    background: rgba(255, 255, 255, 0.03);
    padding: 2rem;
    border-radius: 20px;
    text-align: left;
}

/* Nightly Review Theme - Cozy Lounge */
.nightly-review-mode {
    --bg-dark: #120a06; /* Deep mahogany */
    --bg-card: rgba(45, 25, 15, 0.85);
    --accent: #ffb703; /* Amber/Gold */
    --accent-hover: #fb8500;
    --text-primary: #f8f1e5;
    --text-secondary: rgba(248, 241, 229, 0.7);
    --glass-border: rgba(255, 183, 3, 0.2);
    background-image: radial-gradient(circle at center, #2d190f 0%, #0c0604 100%) !important;
}

.nightly-review-mode::before {
    content: '';
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background-image: 
        radial-gradient(white, rgba(255,255,255,.2) 2px, transparent 40px),
        radial-gradient(white, rgba(255,255,255,.15) 1px, transparent 30px),
        radial-gradient(white, rgba(255,255,255,.1) 2px, transparent 40px);
    background-size: 550px 550px, 350px 350px, 250px 250px;
    background-position: 0 0, 40px 60px, 130px 270px;
    opacity: 0.15;
    pointer-events: none;
    z-index: -1;
}

.nightly-review-mode .home-dashboard,
.nightly-review-mode .quiz-wrapper,
.nightly-review-mode .quiz-container {
    border-color: rgba(255, 183, 3, 0.3) !important;
    box-shadow: 0 25px 80px rgba(0, 0, 0, 0.7), 0 0 30px rgba(255, 183, 3, 0.15) !important;
    background: rgba(30, 15, 10, 0.8) !important;
}

.nightly-review-mode .welcome-title,
.nightly-review-mode .quiz-title {
    background: linear-gradient(135deg, #f8f1e5 0%, #ffb703 100%);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    text-shadow: 0 0 20px rgba(255, 183, 3, 0.3);
}

.nightly-review-mode .clause-blank {
    border-bottom: 2px solid #ffb703 !important;
}

.nightly-review-mode .clause-blank.filled {
    color: #ffb703 !important;
}

.nightly-review-mode .badge {
    box-shadow: 0 0 10px rgba(255, 183, 3, 0.2);
}

.main-stat-card.nightly-card {
    background: linear-gradient(135deg, rgba(255, 183, 3, 0.15) 0%, rgba(0, 0, 0, 0.4) 100%);
    border: 1px solid rgba(255, 183, 3, 0.3);
    transition: all 0.3s ease;
}

.main-stat-card.nightly-card:hover {
    border-color: rgba(255, 183, 3, 0.6);
    box-shadow: 0 0 25px rgba(255, 183, 3, 0.2);
}

.nightly-btn {
    background: linear-gradient(135deg, #ffb703, #fb8500) !important;
    color: #120a06 !important;
    border: none !important;
    box-shadow: 0 4px 15px rgba(255, 183, 3, 0.4) !important;
    font-weight: 800 !important;
    letter-spacing: 0.5px;
}

.nightly-btn:hover {
    transform: scale(1.05) !important;
    filter: brightness(1.1) !important;
    box-shadow: 0 6px 20px rgba(255, 183, 3, 0.6) !important;
}

.nightly-review-mode .mini-btn {
    opacity: 0.9;
}

.nightly-review-mode .mini-btn:hover {
    opacity: 1;
}

.nightly-review-mode .sidebar {
    background: #0c0604 !important;
    border-right-color: rgba(255, 183, 3, 0.2) !important;
}

.nightly-review-mode .tab-btn.active {
    background: #ffb703 !important;
    color: #120a06 !important;
}

.large-bar {
    height: 16px;
    margin: 1.5rem 0;
}

.daily-tip {
    font-size: 0.85rem;
    color: var(--text-secondary);
    text-align: center;
    margin-top: 1rem;
    font-style: italic;
}

/* Mountain Progress Specifics */
.mountain-marker {
    font-size: 5px;
    fill: rgba(255, 255, 255, 0.4);
}

.climb-stats {
    display: flex;
    justify-content: space-between;
    margin-top: 0.5rem;
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.stat-value {
    color: var(--accent);
    font-weight: bold;
}

.daily-progress-section {
    padding-top: 0.5rem;
    border-top: 1px solid rgba(255, 255, 255, 0.05);
}

.daily-header {
    display: flex;
    justify-content: space-between;
    margin-bottom: 0.4rem;
    font-size: 0.8rem;
}

.daily-label {
    color: var(--text-secondary);
}

.daily-value {
    color: var(--text-primary);
    font-weight: 600;
}

.daily-bar-container {
    height: 6px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 3px;
    overflow: hidden;
}

.daily-bar-fill {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, #4cc9f0, #4361ee);
    border-radius: 3px;
    transition: width 0.6s ease-out;
    box-shadow: 0 0 10px rgba(67, 97, 238, 0.4);
}

/* Projection Section */
.projection-section {
    margin: 3rem auto 2rem auto;
    padding: 2.5rem;
    background: rgba(30, 32, 45, 0.8);
    border-radius: 24px;
    border: 1.5px solid rgba(76, 201, 240, 0.4);
    box-shadow: 0 15px 40px rgba(0, 0, 0, 0.3);
    text-align: left;
    width: 100%;
    max-width: 900px;
    box-sizing: border-box;
    display: block;
}

.projection-section .chart-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

.projection-section h3 {
    font-size: 1.1rem;
    color: var(--accent);
    margin: 0;
}

.chart-legend {
    font-size: 0.75rem;
    color: var(--text-secondary);
    font-style: italic;
}

.projection-chart-container {
    height: 300px;
    position: relative;
    width: 100%;
    scrollbar-width: thin;
    scrollbar-color: rgba(76, 201, 240, 0.4) transparent;
}

.projection-chart-container::-webkit-scrollbar {
    height: 8px;
}

.projection-chart-container::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.05);
    border-radius: 4px;
}

.projection-chart-container::-webkit-scrollbar-thumb {
    background: rgba(76, 201, 240, 0.4);
    border-radius: 4px;
}

.projection-chart-container::-webkit-scrollbar-thumb:hover {
    background: var(--accent);
}

/* SRS Config Display */
.srs-config-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 2rem;
    margin-top: 1.5rem;
}

.srs-config-card h4 {
    font-size: 0.9rem;
    color: var(--text-secondary);
    margin-bottom: 1rem;
    padding-left: 0.5rem;
    border-left: 3px solid var(--accent);
}

.srs-intervals-display {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.interval-chip {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--glass-border);
    padding: 0.4rem 0.8rem;
    border-radius: 8px;
    font-size: 0.8rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    min-width: 60px;
}

.interval-chip .lv-label {
    font-size: 0.65rem;
    color: var(--accent);
    margin-bottom: 2px;
}

.interval-chip .days-label {
    font-weight: bold;
    color: var(--text-primary);
}

.srs-logic-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 0.8rem;
}

.srs-logic-list li {
    font-size: 0.85rem;
    display: flex;
    align-items: center;
    gap: 1rem;
}

.logic-tag {
    padding: 0.2rem 0.6rem;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: bold;
    min-width: 70px;
    text-align: center;
}

.logic-tag.success { background: rgba(74, 222, 128, 0.2); color: #4ade80; }
.logic-tag.danger { background: rgba(247, 37, 133, 0.2); color: #f72585; }
.logic-tag.info { background: rgba(76, 201, 240, 0.2); color: #4cc9f0; }

/* Override Button */
.override-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--success);
    color: var(--bg-dark);
    border: 1px solid var(--success);
    padding: 2px 8px;
    border-radius: 4px;
    margin-left: 8px;
    cursor: pointer;
    font-size: 0.75rem;
    font-weight: 800;
    transition: var(--transition);
    vertical-align: middle;
    box-shadow: 0 0 10px rgba(74, 222, 128, 0.3);
}

.override-btn:hover {
    filter: brightness(1.2);
    transform: scale(1.05);
}

.override-btn:active {
    transform: scale(0.95);
}

@media (max-width: 768px) {
    .projection-chart-container {
        height: 250px;
    }

    .projection-section {
        padding: 1rem;
    }
}


/* Sidebar */
.sidebar-resizer {
    width: 6px;
    cursor: col-resize;
    background-color: transparent;
    transition: background-color 0.2s;
    z-index: 1000;
    flex-shrink: 0;
}

.sidebar-resizer:hover, .sidebar-resizer.is-resizing {
    background-color: var(--accent);
}

.sidebar {
    width: var(--sidebar-width, 320px);
    height: 100vh;
    position: sticky;
    top: 0;
    background: #1a1c27;
    border-right: 1px solid var(--glass-border);
    display: flex;
    flex-direction: column;
    transition: width 0.1s, transform 0.3s;
    z-index: 1000;
    flex-shrink: 0;
    overflow-y: hidden; /* Inner content will scroll */
}

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

.header-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
}



#quiz-sidebar-content {
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, 0.2) transparent;
}

#quiz-sidebar-content::-webkit-scrollbar {
    width: 6px;
}

#quiz-sidebar-content::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.02);
}

#quiz-sidebar-content::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 10px;
}

#quiz-sidebar-content::-webkit-scrollbar-thumb:hover {
    background: var(--accent);
}

.sidebar-footer {
    padding: 1rem;
    border-top: 1px solid var(--glass-border);
    background: rgba(15, 17, 23, 0.6);
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
    margin-top: auto;
}

.sidebar-footer-btn {
    width: 100%;
    padding: 0.8rem 1rem;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--glass-border);
    border-radius: 12px;
    color: var(--text-secondary);
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.sidebar-footer-btn:hover {
    background: rgba(67, 97, 238, 0.15);
    border-color: var(--accent);
    color: var(--text-primary);
    transform: translateY(-1px);
}

.sidebar-footer-btn:active {
    transform: translateY(0);
}

/* Sidebar Tabs */
.sidebar-tabs {
    display: flex;
    gap: 0.75rem;
    padding: 1rem;
    background: rgba(15, 17, 23, 0.3);
    border-bottom: 1px solid var(--glass-border);
}

.tab-btn {
    flex: 1;
    background: none;
    border: none;
    color: var(--text-secondary);
    padding: 0.75rem 0.5rem;
    cursor: pointer;
    font-size: 1rem;
    font-weight: 600;
    border-radius: 10px;
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
}

#home-btn.tab-btn {
    flex: 0.6;
    font-size: 1.2rem;
}

.tab-btn.active {
    background: var(--accent);
    color: var(--bg-dark);
}

.tab-btn:hover:not(.active) {
    background: rgba(255, 255, 255, 0.05);
}

.toc-nav li {
    margin-bottom: 0.25rem;
    position: relative;
    cursor: default;
    display: block;
    width: 100%;
}

.edit-mode .toc-nav .item-container {
    cursor: grab;
}

.edit-mode .toc-nav .item-container:active {
    cursor: grabbing;
}

.toc-nav li.dragging {
    opacity: 0.5;
}

.toc-nav li.drag-over-top > .item-container {
    position: relative;
    box-shadow: inset 0 4px 0 var(--error);
}
.toc-nav li.drag-over-top > .item-container::before {
    content: '↑ 同階層の上へ';
    position: absolute;
    top: -20px;
    left: 0;
    font-size: 0.75rem;
    color: var(--error);
    font-weight: bold;
    pointer-events: none;
    background: var(--bg-dark);
    padding: 2px 6px;
    border-radius: 4px;
    border: 1px solid var(--error);
    z-index: 100;
}

.toc-nav li.drag-over-bottom > .item-container {
    position: relative;
    box-shadow: inset 0 -4px 0 var(--error);
}
.toc-nav li.drag-over-bottom > .item-container::after {
    content: '↓ 同階層の下へ';
    position: absolute;
    bottom: -20px;
    left: 0;
    font-size: 0.75rem;
    color: var(--error);
    font-weight: bold;
    pointer-events: none;
    background: var(--bg-dark);
    padding: 2px 6px;
    border-radius: 4px;
    border: 1px solid var(--error);
    z-index: 100;
}

.toc-nav li a {
    flex: 1;
}

.reorder-btns {
    display: none;
    gap: 2px;
    flex-wrap: wrap;
    transition: opacity 0.2s;
    background: rgba(255, 255, 255, 0.03);
    padding: 4px;
    border-radius: 6px;
    border: 1px solid var(--glass-border);
    margin-top: 4px;
    width: 100%;
    justify-content: flex-start;
}

.edit-mode .reorder-btns {
    display: none; /* Hide even in edit mode, use context menu */
}

.item-container:hover .reorder-btns {
    display: none; /* Hide on hover too */
}

.reorder-btn {
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid var(--glass-border);
    color: var(--text-secondary);
    cursor: pointer;
    padding: 2px 5px;
    border-radius: 4px;
    font-size: 0.7rem;
    transition: var(--transition);
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
}

.reorder-btn:hover {
    opacity: 1;
    color: var(--accent);
}

.delete-folder-btn:hover {
    color: var(--error) !important;
}

.toc-nav ul {
    list-style: none;
}

.toc-nav ul ul {
    margin-left: 0.75rem;
    padding-left: 0.25rem;
    border-left: 1px solid var(--glass-border);
}

.toc-nav li {
    margin-bottom: 0.25rem;
    position: relative;
}

.toc-nav li .item-container {
    display: flex !important;
    align-items: center;
    gap: 0.5rem;
    border-radius: 8px;
    padding: 0.4rem 0.6rem;
    transition: var(--transition);
    width: 100%;
    min-height: 36px;
    box-sizing: border-box;
    flex-wrap: wrap;
}

.edit-mode .toc-nav li .item-container {
    flex-direction: row;
    /* Keep initially row but let it wrap */
    align-items: center;
}

.toc-nav li.active>.item-container {
    background: rgba(76, 201, 240, 0.1);
    box-shadow: inset 0 0 0 1px var(--accent);
}

.folder-toggle {
    cursor: pointer;
    font-size: 0.7rem;
    width: 18px;
    height: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-secondary);
    transition: var(--transition);
}

.folder-toggle:hover {
    color: var(--accent);
}

.folder-item {
    font-weight: 700 !important;
    color: var(--accent) !important;
}

.folder-icon {
    font-size: 0.9rem;
    margin-right: 0.2rem;
}

.toc-pool-checkbox {
    cursor: pointer;
    width: 14px;
    height: 14px;
    margin: 0;
    accent-color: var(--accent);
    opacity: 0.6;
    transition: var(--transition);
    flex-shrink: 0;
}

.toc-pool-checkbox:hover {
    opacity: 1;
}

.toc-pool-checkbox:checked {
    opacity: 1;
}

.drag-over-folder > .item-container {
    background: rgba(255, 60, 60, 0.2) !important;
    outline: 2px dashed var(--error) !important;
    outline-offset: -2px;
    position: relative;
}
.drag-over-folder > .item-container::before {
    content: '📁 このフォルダの中へ';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 0.85rem;
    color: #fff;
    background: var(--error);
    padding: 4px 10px;
    border-radius: 4px;
    font-weight: bold;
    pointer-events: none;
    z-index: 100;
}

.toc-nav a {
    color: var(--text-secondary);
    text-decoration: none;
    flex: 1;
    min-width: 0;
    font-weight: 500;
    font-size: 0.85rem;
    line-height: normal;
    display: block;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.edit-mode .item-container {
    padding-right: 0.6rem;
}

.toc-nav a:hover,
.toc-nav .active>.item-container a {
    color: var(--accent);
}

.sidebar-actions {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-top: 1.5rem;
}

.add-btn {
    text-align: left;
    padding-left: 1rem;
    font-size: 0.8rem;
}

/* Main Content */
.main-content {
    flex-grow: 1;
    padding: 1.5rem 2rem;
    /* Reduced padding to maximize content width */
    transition: var(--transition);
    min-width: 0;
    /* Ensures flex child doesn't overflow */
}

.content-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
    padding: 1rem 0;
    border-bottom: 1px solid var(--glass-border);
    position: sticky;
    top: 0;
    background: var(--bg-dark);
    z-index: 1000;
    backdrop-filter: blur(10px);
}

.edit-mode .quiz-title {
    cursor: text;
    border-bottom: 1px dotted var(--text-secondary);
}

.header-left,
.header-right {
    display: flex;
    align-items: center;
    gap: 1.5rem;
}

.edit-controls {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding-right: 1.5rem;
    border-right: 1px solid var(--glass-border);
}

.edit-label {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-secondary);
}

/* Switch UI */
.switch {
    position: relative;
    display: inline-block;
    width: 44px;
    height: 24px;
}

.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: var(--bg-card);
    transition: .4s;
    border: 1px solid var(--glass-border);
}

.slider:before {
    position: absolute;
    content: "";
    height: 16px;
    width: 16px;
    left: 4px;
    bottom: 3px;
    background-color: var(--text-secondary);
    transition: .4s;
}

input:checked+.slider {
    background-color: rgba(76, 201, 240, 0.2);
    border-color: var(--accent);
}

input:checked+.slider:before {
    transform: translateX(20px);
    background-color: var(--accent);
}

.slider.round {
    border-radius: 34px;
}

.slider.round:before {
    border-radius: 50%;
}

/* Small Switch */
.switch-small {
    position: relative;
    display: inline-block;
    width: 36px;
    height: 20px;
}
.switch-small input {
    opacity: 0;
    width: 0;
    height: 0;
}
.switch-small .slider:before {
    height: 14px;
    width: 14px;
    left: 3px;
    bottom: 2px;
}
.switch-small input:checked+.slider:before {
    transform: translateX(16px);
}

.menu-toggle {
    display: none;
    background: none;
    border: none;
    color: var(--text-primary);
    font-size: 1.5rem;
    cursor: pointer;
}

/* Buttons */
.secondary-btn,
.primary-btn,
.danger-btn {
    padding: 0.6rem 1.2rem;
    border-radius: 10px;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    font-size: 0.9rem;
    border: none;
    font-family: inherit;
}

.primary-btn {
    background: var(--accent);
    color: var(--bg-dark);
}

.secondary-btn {
    background: var(--bg-card);
    color: var(--text-primary);
    border: 1px solid var(--glass-border);
}

.secondary-btn:hover {
    background: rgba(255, 255, 255, 0.1);
}

.danger-btn {
    background: rgba(247, 37, 133, 0.1);
    color: var(--error);
    border: 1px solid rgba(247, 37, 133, 0.3);
}

.danger-btn:hover {
    background: var(--error);
    color: white;
}

.add-btn {
    width: 100%;
    margin-top: 1.5rem;
}

.table-controls {
    margin-top: 1.5rem;
    display: flex;
    gap: 1rem;
}

/* Visibility toggles */
.hidden-quiz {
    display: none;
}

.edit-mode .hidden-quiz {
    display: flex;
}

.study-only {
    display: flex;
}

.edit-mode .study-only {
    display: none !important;
}

.quiz-section {
    padding-bottom: 40vh;
}

/* Quiz Controls */
/* .quiz-controls moved to bottom for sticky implementation */

.edit-mode .quiz-controls {
    display: none;
}

/* Choice States for Batch Mode */
.choice-cell.selected {
    background: rgba(76, 201, 240, 0.15) !important;
    border: 1px solid var(--accent) !important;
}

/* Visibility and State Utility */
.hidden {
    display: none !important;
}

.view {
    animation: fadeIn 0.4s ease forwards;
    width: 100%;
}

.view.hidden {
    display: none;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1.5rem;
    margin-bottom: 3rem;
}

.stats-card {
    background: var(--bg-card);
    border: 1px solid var(--glass-border);
    padding: 1.5rem;
    border-radius: 20px;
    text-align: center;
}

.stats-card h3 {
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin-bottom: 1rem;
}

.big-number {
    font-size: 2.5rem;
    font-family: 'Outfit', sans-serif;
    font-weight: 700;
    color: var(--accent);
}

.history-section h3 {
    margin-bottom: 1.5rem;
}

.chart-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
    gap: 1rem;
}

.chart-controls {
    display: flex;
    background: rgba(255, 255, 255, 0.05);
    padding: 4px;
    border-radius: 12px;
    border: 1px solid var(--glass-border);
}

.chart-tab {
    background: none;
    border: none;
    color: var(--text-secondary);
    padding: 0.5rem 1rem;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: 600;
    transition: var(--transition);
}

.chart-tab.active {
    background: var(--accent);
    color: var(--bg-dark);
    box-shadow: 0 4px 15px rgba(76, 201, 240, 0.3);
}

.chart-container {
    background: rgba(255, 255, 255, 0.02);
    padding: 1rem;
    border-radius: 16px;
    border: 1px solid var(--glass-border);
}

.auto-gen-controls {
    display: flex;
    gap: 1rem;
    margin-top: 1rem;
    flex-wrap: wrap;
}

.data-mgmt-status {
    padding: 0.5rem;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid var(--glass-border);
    transition: var(--transition);
}

.alert-banner {
    background: rgba(247, 37, 133, 0.1);
    border: 1px solid var(--error);
    color: var(--text-primary);
    padding: 1rem;
    border-radius: 12px;
    font-size: 0.85rem;
    line-height: 1.5;
}

#history-table th,
#history-table td {
    width: auto;
}

/* Search Bar */
.search-section {
    margin-bottom: 2rem;
    animation: fadeIn 0.5s ease forwards;
}

.search-container {
    background: var(--bg-card);
    border: 1px solid var(--glass-border);
    border-radius: 12px;
    padding: 0.75rem 1.25rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    max-width: 400px;
    transition: var(--transition);
}

.search-container:focus-within {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(76, 201, 240, 0.1);
}

.search-icon {
    opacity: 0.5;
    font-size: 0.9rem;
}

#search-input {
    background: none;
    border: none;
    color: var(--text-primary);
    font-size: 0.95rem;
    width: 100%;
    outline: none;
}

#search-input::placeholder {
    color: var(--text-secondary);
}

/* Table Design */
.table-wrapper {
    width: 100%;
    box-sizing: border-box;
    background: var(--bg-card);
    border-radius: 20px;
    border: 1px solid var(--glass-border);
    padding: 1.5rem;
    padding-bottom: 30vh;
    /* Add large bottom padding for keyword bank visibility */
    backdrop-filter: blur(10px);
    overflow-x: auto;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
    /* Custom Scrollbar for X */
    scrollbar-width: thin;
    scrollbar-color: var(--accent) rgba(255, 255, 255, 0.05);
}

.understanding-map-container {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    padding: 1.5rem;
    background: var(--bg-card);
    border: 1px solid var(--glass-border);
    border-radius: 20px;
    min-height: 100px;
}

.map-cell {
    width: 24px;
    height: 24px;
    border-radius: 4px;
    cursor: pointer;
    transition: var(--transition);
    position: relative;
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.map-cell:hover {
    transform: scale(1.2);
    z-index: 10;
    box-shadow: 0 0 10px rgba(76, 201, 240, 0.5);
}

.map-cell[data-tooltip]::before {
    content: attr(data-tooltip);
    position: absolute;
    bottom: 140%;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.95);
    color: white;
    padding: 0.6rem 0.8rem;
    border-radius: 8px;
    font-size: 0.75rem;
    white-space: pre;
    opacity: 0;
    pointer-events: none;
    transition: var(--transition);
    z-index: 2000;
    border: 1px solid var(--glass-border);
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.4);
    min-width: 150px;
}

.map-cell:hover::before {
    opacity: 1;
}

.table-wrapper::-webkit-scrollbar {
    height: 8px;
}

.table-wrapper::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.05);
    border-radius: 10px;
}

.table-wrapper::-webkit-scrollbar-thumb {
    background: var(--glass-border);
    border-radius: 10px;
    transition: var(--transition);
}

.table-wrapper::-webkit-scrollbar-thumb:hover {
    background: var(--accent);
}

table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0 10px;
    margin-bottom: 20vh;
    /* Extra spacing so the last row can clear the keyword bank */
}

th {
    text-align: left;
    padding: 1rem;
    color: var(--text-secondary);
    font-weight: 600;
    text-transform: uppercase;
    font-size: 0.8rem;
    letter-spacing: 0.1em;
    cursor: pointer;
    transition: var(--transition);
    /* user-select: none removed to allow editing titles */
    position: relative;
    /* Remove sticky to avoid overlap issues */
    top: 0;
    background: var(--bg-card);
    z-index: 20;
}

th:hover {
    color: var(--accent);
}

th::after {
    content: '竊・;
    position: absolute;
    right: 0.5rem;
    opacity: 0.3;
    pointer-events: none;
}

th.sort-asc::after {
    content: '竊・;
    opacity: 1;
    color: var(--accent);
}

th.sort-desc::after {
    content: '竊・;
    opacity: 1;
    color: var(--accent);
}

td {
    padding: 1rem;
    background: rgba(255, 255, 255, 0.03);
    border-top: 1px solid var(--glass-border);
    border-bottom: 1px solid var(--glass-border);
    transition: var(--transition);
    white-space: pre-wrap;
    /* Support \n and manual line breaks */
    line-height: 1.6;
    vertical-align: top;
}

td:first-child,
th:first-child {
    position: relative;
    /* Remove sticky left to avoid complexity until layout stable */
    left: 0;
    z-index: 10;
    background: var(--bg-card);
    border-left: 1px solid var(--glass-border);
}

.question-cell {
    min-width: 250px;
}

.choice-cell {
    min-width: 120px;
}

td:first-child {
    border-top-left-radius: 12px;
    border-bottom-left-radius: 12px;
    font-weight: 600;
}

.pool-cell, .select-cell {
    width: 60px;
    text-align: center;
}

td:last-child {
    border-right: 1px solid var(--glass-border);
    border-top-right-radius: 12px;
    border-bottom-right-radius: 12px;
}

.choice-cell {
    cursor: pointer;
    text-align: center;
    font-weight: 500;
}

.choice-cell:hover {
    background: rgba(76, 201, 240, 0.1);
    color: var(--accent);
}

.choice-cell.correct {
    background: rgba(74, 222, 128, 0.2) !important;
    color: var(--success);
    border-color: var(--success);
    font-weight: 700;
}

/* 鬮｢鬥ｴ・・ｸｺ蛹ｻ笳・ｭ弱ｑ・ｿ・ｽE雎｢・ｾ隰・ｹ昶・髯ｦ・ｨ驕会ｽｺ */
.row-wrong {
    background: rgba(247, 37, 133, 0.08) !important;
    animation: shake 0.5s cubic-bezier(.36, .07, .19, .97) both;
    border-left: 4px solid var(--error) !important;
}

.row-wrong td {
    border-top: 1px solid rgba(247, 37, 133, 0.3) !important;
    border-bottom: 1px solid rgba(247, 37, 133, 0.3) !important;
}

@keyframes shake {

    10%,
    90% {
        transform: translate3d(-1px, 0, 0);
    }

    20%,
    80% {
        transform: translate3d(2px, 0, 0);
    }

    30%,
    50%,
    70% {
        transform: translate3d(-4px, 0, 0);
    }

    40%,
    60% {
        transform: translate3d(4px, 0, 0);
    }
}

.choice-cell.wrong {
    background: var(--error) !important;
    color: white !important;
    border-color: var(--error);
    text-decoration: line-through;
    opacity: 0.8;
}

/* Edit Mode states */
.hidden-quiz {
    display: none;
}

.edit-mode .hidden-quiz {
    display: block;
}

.edit-mode .hidden-quiz.inline {
    display: inline-block;
}

.edit-mode #add-page-btn {
    display: block;
    margin-top: 1rem;
}

.edit-mode #add-row-btn {
    display: block;
}

[contenteditable="true"] {
    outline: none;
    padding: 2px 4px;
    border-radius: 4px;
    transition: var(--transition);
    border-bottom: 2px dashed transparent;
}

.edit-mode [contenteditable="true"] {
    border-bottom-color: var(--accent);
    background: rgba(76, 201, 240, 0.05);
}

.edit-mode [contenteditable="true"]:hover {
    background: rgba(76, 201, 240, 0.1);
}

[contenteditable="true"]:focus {
    background: rgba(255, 255, 255, 0.05) !important;
    box-shadow: 0 0 0 2px var(--accent);
}

.edit-mode #quiz-title {
    cursor: text;
    border-bottom: 2px dashed var(--accent);
    padding: 2px 8px;
    border-radius: 4px;
}

.edit-mode #quiz-title:hover {
    background: rgba(76, 201, 240, 0.1);
}

.column-controls {
    display: none;
    justify-content: center;
    margin-bottom: 1rem;
    gap: 1rem;
}

.edit-mode .column-controls {
    display: flex;
}

.edit-mode .choice-cell {
    border: 1px dashed rgba(255, 255, 255, 0.1);
}

.edit-mode .choice-cell:hover {
    border-color: var(--accent);
    background: rgba(76, 201, 240, 0.05);
}

.edit-mode .choice-cell.multi-selected,
.choice-cell.selected.multi-select {
    background: rgba(76, 201, 240, 0.25) !important;
    border: 1px solid var(--accent) !important;
    color: var(--accent);
}

.choice-cell.correct.multi-select {
    background: rgba(67, 170, 139, 0.3) !important;
    border-color: var(--success) !important;
}

.choice-cell.wrong.multi-select {
    background: rgba(247, 37, 133, 0.3) !important;
    border-color: var(--error) !important;
}

/* Row/Column Deletion and Sorting */
.row-edit-controls {
    display: none;
    gap: 0.5rem;
    align-items: center;
    margin-bottom: 0.8rem;
    padding: 0.4rem;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 8px;
    width: fit-content;
}

.edit-mode .row-edit-controls {
    display: flex;
}

.delete-row-btn,
.delete-col-btn,
.move-row-btn {
    color: var(--text-secondary);
    cursor: pointer;
    transition: var(--transition);
}

.delete-row-btn {
    font-size: 1.2rem;
}

.move-row-btn {
    font-size: 1rem;
    background: var(--bg-card);
    padding: 0.2rem 0.5rem;
    border-radius: 4px;
    border: 1px solid var(--glass-border);
    line-height: 1;
}

.delete-row-btn:hover {
    color: var(--error);
}

.move-row-btn:hover {
    color: var(--accent);
    background: rgba(255, 255, 255, 0.1);
    border-color: var(--accent);
}

.delete-col-btn {
    position: absolute;
    top: 0.2rem;
    /* Move slightly down to avoid floating too high */
    right: 0.4rem;
    font-size: 0.9rem;
    opacity: 0.6;
    z-index: 5;
}

.col-label-edit {
    display: inline-block;
    min-width: 2rem;
    padding: 2px 5px;
    border-radius: 4px;
    transition: var(--transition);
}

.edit-mode .col-label-edit {
    border: 1px dashed var(--accent);
    background: rgba(76, 201, 240, 0.05);
}

.col-label-edit:focus {
    outline: none;
    background: rgba(76, 201, 240, 0.15);
    border-style: solid;
    box-shadow: 0 0 0 2px rgba(76, 201, 240, 0.2);
}

.question-cell {
    text-align: left;
    min-width: 300px;
    font-weight: 500;
    vertical-align: top;
}

.question-cell>* {
    display: block;
    margin-bottom: 0.5rem;
}

.page-tag {
    font-size: 0.95rem;
    background: var(--accent);
    color: white;
    padding: 6px 14px;
    border-radius: 8px;
    width: fit-content;
    font-weight: 700;
    margin-bottom: 0.6rem;
    box-shadow: 0 4px 10px rgba(76, 201, 240, 0.3);
    display: inline-flex;
    align-items: center;
}

.edit-mode .question-cell {
    cursor: text;
    border-bottom: 1px dotted var(--text-secondary);
}

/* Memo Styles */
.memo-input {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-top: 0.5rem;
    padding: 0.5rem;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 8px;
    border: 1px dashed var(--glass-border);
    min-height: 1.5rem;
}

.memo-input:empty:before {
    content: attr(placeholder);
    color: rgba(255, 255, 255, 0.2);
    pointer-events: none;
}

.memo-input:hover {
    background: rgba(255, 255, 255, 0.08);
    border-color: var(--accent);
}

.memo-display {
    margin-top: 0.75rem;
    padding: 0.75rem 1rem;
    background: rgba(76, 201, 240, 0.1);
    border-left: 4px solid var(--accent);
    border-radius: 4px 8px 8px 4px;
    font-size: 0.85rem;
    color: var(--text-primary);
    line-height: 1.5;
    animation: fadeIn 0.3s ease-out;
}

.memo-display strong {
    color: var(--accent);
    margin-right: 0.5rem;
}

/* Animations */
@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

tr {
    animation: fadeInRow 0.5s ease forwards;
}

@keyframes fadeInRow {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

/* Responsive */
/* Mini Clause Styles for Table */
.table-clause-wrapper {
    width: 100%;
    box-sizing: border-box;
    margin: 10px 0;
    padding: 1.5rem;
    /* Slightly more padding for the larger scale */
    background: rgba(255, 255, 255, 0.03);
    border-radius: 12px;
    border: 1px solid var(--glass-border);
    text-align: left;
}

.clause-badge {
    display: inline-block;
    padding: 8px 20px;
    background: var(--accent);
    color: #0a0e1a;
    border-radius: 8px;
    font-size: 1.4rem;
    font-weight: 800;
    margin-bottom: 12px;
    box-shadow: 0 4px 14px rgba(76, 201, 240, 0.4);
    letter-spacing: 0.03em;
}

.clause-text-mini {
    line-height: 2.5;
    font-size: 1.4rem;
    /* Larger font in tables */
    color: var(--text-primary);
    white-space: pre-wrap;
}

.clause-text-mini .clause-blank {
    min-width: 60px;
    height: 24px;
    font-size: 0.9rem;
}

@media (max-width: 1024px) {
    .sidebar {
        transform: translateX(-100%);
    }

    .sidebar.open {
        transform: translateX(0);
    }

    .main-content {
        margin-left: 0;
        width: 100%;
    }

    .menu-toggle {
        display: block;
    }
}

/* Clause Quiz Styles */
.clause-container {
    max-width: 2000px;
    /* Allow much wider display */
    margin: 1.5rem auto;
    width: calc(100% - 1rem);
    /* Avoid sticking to edges */
    background: var(--bg-card);
    border: 1px solid var(--glass-border);
    border-radius: 24px;
    padding: 2rem;
    /* Reduced padding to give more room for content */
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
    backdrop-filter: blur(10px);
}

.clause-text {
    font-size: 1.5rem;
    /* Larger font */
    line-height: 2.5;
    color: var(--text-primary);
    text-align: justify;
    margin-bottom: 3.5rem;
    white-space: pre-wrap;
}

.clause-blank {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 140px;
    /* Wider blanks */
    height: 48px;
    /* Taller blanks */
    margin: 0 6px;
    padding: 0 15px;
    background: rgba(255, 255, 255, 0.05);
    border-bottom: 4px solid var(--accent);
    border-radius: 8px 8px 0 0;
    cursor: pointer;
    transition: var(--transition);
    vertical-align: middle;
    font-weight: 700;
    color: var(--accent);
    font-size: 1.4rem;
    /* Adjusted to match larger cards */
    position: relative;
    overflow: visible !important;
}

.clause-blank.drag-over {
    background: rgba(76, 201, 240, 0.2);
    border-bottom-color: var(--accent-hover);
    transform: translateY(-2px);
}

.clause-blank.filled {
    background: rgba(76, 201, 240, 0.1);
}

.clause-blank.correct {
    background: rgba(74, 222, 128, 0.1);
    border-bottom-color: var(--success);
    color: var(--success);
}

.clause-blank.wrong {
    background: rgba(247, 37, 133, 0.1);
    border-bottom-color: var(--error);
    color: var(--error);
}

.clause-blank.auto-filled {
    border-bottom: 2px dotted var(--accent) !important;
    color: var(--accent) !important;
    cursor: default;
}

.clause-input-blank.auto-filled {
    border: 1px dotted var(--accent) !important;
    color: var(--accent) !important;
    background: rgba(76, 201, 240, 0.05) !important;
}

.choice-cell.auto-filled {
    border: 1px dotted var(--accent) !important;
    color: var(--accent) !important;
    background: rgba(76, 201, 240, 0.05) !important;
    font-style: italic;
}

.reveal-correct {
    font-size: 0.85rem;
    color: var(--success);
    margin-left: 4px;
    font-weight: 400;
    opacity: 0.8;
}

.keyword-bank {
    display: flex;
    flex-wrap: wrap;
    gap: 0.6rem;
    padding: 1.2rem;
    background: rgba(26, 28, 39, 0.9);
    /* Slightly transparent background */
    backdrop-filter: blur(15px);
    border-radius: 16px;
    border: 2px solid var(--accent);
    /* Thicker border */
    justify-content: center;
    position: fixed;
    bottom: 5rem;
    left: calc(var(--sidebar-width) + 2rem);
    right: 2rem;
    z-index: 2000;
    box-shadow: 0 -10px 40px rgba(0, 0, 0, 0.8);
    max-height: 25vh;
    overflow-y: auto;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    opacity: 0;
    pointer-events: none;
    transform: translateY(20px);
}

.sidebar-hidden .keyword-bank {
    left: 2rem;
}

.keyword-bank.minimized {
    max-height: 48px;
    min-height: 48px;
    overflow: hidden;
    padding: 0.5rem 1rem;
    bottom: 4.5rem;
}

.keyword-bank-header {
    display: none;
    /* Initially hidden, will show if children exist via JS or CSS */
    width: 100%;
    justify-content: space-between;
    align-items: center;
    padding-bottom: 0.5rem;
    margin-bottom: 0.5rem;
    border-bottom: 1px solid var(--glass-border);
}

.active-bank .keyword-bank-header {
    display: flex;
}

.bank-toggle-btn {
    background: var(--accent);
    color: var(--bg-dark);
    border: none;
    border-radius: 6px;
    padding: 2px 10px;
    font-size: 0.8rem;
    font-weight: bold;
    cursor: pointer;
    transition: var(--transition);
}

.bank-toggle-btn:hover {
    filter: brightness(1.1);
}

.bank-title {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--accent);
}

.keyword-bank.active-bank {
    opacity: 1;
    pointer-events: auto;
    transform: translateY(0);
}

.keyword-bank.hidden {
    display: none !important;
}

/* For mobile/small screens when sidebar is hidden/toggleable */
@media (max-width: 1024px) {
    .keyword-bank {
        left: 1rem;
        right: 1rem;
    }
}

/* Special Training: If inside table-clause-wrapper, make it slightly different or ensure visibility */
.table-clause-wrapper .keyword-bank {
    width: 100%;
    box-sizing: border-box;
}

/* Single page view fallback */
#clause-display .keyword-bank {
    opacity: 1 !important;
    pointer-events: auto !important;
    position: relative;
    /* Not sticky on single page usually */
    margin-bottom: 2rem;
}

.quiz-controls {
    position: sticky;
    bottom: 0.5rem;
    z-index: 501;
    background: rgba(15, 17, 23, 0.8);
    backdrop-filter: blur(8px);
    padding: 0.8rem;
    border-radius: 12px;
    margin-top: 1rem;
    border-top: 1px solid var(--glass-border);
    display: flex;
    justify-content: center;
    gap: 1.5rem;
    flex-wrap: wrap;
    box-shadow: 0 -5px 20px rgba(0, 0, 0, 0.4);
}

.keyword-card {
    background: var(--bg-dark);
    border: 1px solid var(--accent);
    /* More visible border */
    padding: 0.8rem 1.5rem;
    border-radius: 12px;
    color: var(--text-primary);
    font-weight: 700;
    font-size: 1.3rem;
    /* Significantly larger text */
    cursor: grab;
    transition: var(--transition);
    user-select: none;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.2);
}

.keyword-card:hover {
    border-color: var(--accent);
    transform: translateY(-2px);
    box-shadow: 0 6px 15px rgba(76, 201, 240, 0.2);
}

.keyword-card.dragging {
    opacity: 0.5;
    cursor: grabbing;
}

.keyword-card.selected {
    background: var(--accent) !important;
    color: var(--bg-dark) !important;
    border-color: #fff !important;
    transform: translateY(-3px);
    box-shadow: 0 5px 15px rgba(76, 201, 240, 0.4);
}

.keyword-card.used {
    background: rgba(255, 255, 255, 0.05) !important;
    color: var(--text-secondary) !important;
    opacity: 0.5;
    cursor: default;
    pointer-events: none;
    border-style: dashed;
}

.keyword-count-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--accent);
    color: var(--bg-dark);
    font-size: 0.9rem;
    min-width: 1.5rem;
    height: 1.5rem;
    border-radius: 50%;
    margin-left: 0.5rem;
    font-weight: 800;
}

.clause-display.hidden {
    display: none;
}

/* Clause Table Styles */
.clause-text table {
    width: 100%;
    border-collapse: collapse;
    margin: 1.5rem 0;
    background: rgba(255, 255, 255, 0.02);
    border-radius: 12px;
    overflow: hidden;
    border: 1px solid var(--glass-border);
}

.clause-text th,
.clause-text td {
    padding: 1rem;
    border: 1px solid var(--glass-border);
    text-align: left;
    background: transparent;
    position: static;
    /* Reset sticky if inherited */
}

.clause-text th {
    background: rgba(76, 201, 240, 0.1);
    color: var(--accent);
    font-weight: 700;
}

.clause-text tr:hover td {
    background: rgba(255, 255, 255, 0.03);
}

.clause-text .clause-blank {
    min-width: 100px;
    height: 36px;
    font-size: 1.1rem;
}

.clause-editor-btns {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.clause-editor-btns button {
    font-size: 0.8rem;
    padding: 0.4rem 0.8rem;
}

.pool-batch-actions {
    display: flex;
    gap: 0.5rem;
    padding: 1rem 0.8rem;
    background: rgba(255, 255, 255, 0.03);
    border-bottom: 1px solid var(--glass-border);
    justify-content: space-between;
}

.batch-action-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.3rem;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--glass-border);
    color: var(--text-secondary);
    padding: 0.5rem 0.6rem;
    border-radius: 10px;
    font-size: 0.75rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    flex: 1;
    white-space: nowrap;
}

.batch-action-btn:hover {
    background: rgba(76, 201, 240, 0.1);
    border-color: var(--accent);
    color: var(--text-primary);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.batch-action-btn.select-all {
    color: var(--accent);
}

.batch-action-btn.clear-all {
    color: var(--text-secondary);
    opacity: 0.8;
}

.batch-action-btn.clear-all:hover {
    color: #fca5a5;
    /* Light red for clear action */
    border-color: rgba(247, 37, 133, 0.4);
    background: rgba(247, 37, 133, 0.05);
}

#collapse-all-btn:hover, #expand-all-btn:hover {
    color: #ffd166; /* Gold for folder actions */
    border-color: rgba(255, 209, 102, 0.4);
    background: rgba(255, 209, 102, 0.05);
}

.sidebar-quick-actions {
    padding: 0.5rem 0.8rem 1rem 0.8rem;
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
    border-bottom: 1px solid var(--glass-border);
}

.sidebar-gen-btn {
    padding: 0.7rem;
    border-radius: 10px;
    font-size: 0.9rem;
    font-weight: 700;
    cursor: pointer;
    border: none;
    transition: var(--transition);
    text-align: center;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.3);
}

.sidebar-gen-btn.srs-clause {
    background: var(--success);
    color: var(--bg-dark);
}

.sidebar-gen-btn.srs-page {
    background: #2ec4b6;
    color: var(--bg-dark);
}

.sidebar-gen-btn:hover {
    opacity: 0.9;
    transform: translateY(-2px);
    box-shadow: 0 6px 15px rgba(0, 0, 0, 0.4);
}

.sidebar-gen-btn:active {
    transform: translateY(0);
}

/* Modal Styles */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 3000;
    backdrop-filter: blur(5px);
}

.modal-content {
    background: #1a1c27;
    width: 90%;
    max-width: 800px;
    border-radius: 20px;
    border: 1px solid var(--glass-border);
    overflow: hidden;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.6);
}

.modal-header {
    padding: 1.5rem;
    border-bottom: 1px solid var(--glass-border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.close-btn {
    cursor: pointer;
    font-size: 1.5rem;
    color: var(--text-secondary);
}

.modal-body {
    padding: 1.5rem;
}

.srs-chart-container {
    height: 400px;
    margin-bottom: 1.5rem;
}

.srs-info-text {
    font-size: 0.9rem;
    color: var(--text-secondary);
    line-height: 1.8;
}

.history-icon-btn {
    cursor: pointer;
    margin-left: 0.5rem;
    opacity: 0.6;
    transition: var(--transition);
    font-size: 1.1rem;
    display: inline-block;
}

.history-icon-btn:hover {
    opacity: 1;
    color: var(--accent);
    transform: scale(1.2);
}

.question-link {
    cursor: pointer;
    transition: var(--transition);
    border-bottom: 1px dashed transparent;
}

.question-link:hover {
    color: var(--accent);
    border-bottom-color: var(--accent);
}

.srs-badge {
    padding: 0.2rem 0.6rem;
    border-radius: 6px;
    font-size: 0.75rem;
    font-weight: 700;
    display: inline-block;
    border: 1px solid rgba(255, 255, 255, 0.1);
    cursor: pointer;
    transition: var(--transition);
}

.srs-badge:hover {
    filter: brightness(1.2);
    transform: translateY(-1px);
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.3);
}

.srs-badge.due {
    border-color: var(--error);
    background: rgba(247, 37, 133, 0.1);
    color: var(--error);
}

.srs-badge.level-1,
.srs-badge.level-2 {
    color: #ff9f1c;
}

.srs-badge.level-3,
.srs-badge.level-4 {
    color: #ffbf69;
}

.srs-badge.level-5,
.srs-badge.level-6 {
    color: #cbf3f0;
}

.srs-badge.level-7,
.srs-badge.level-8 {
    color: #2ec4b6;
}

.srs-badge.level-9,
.srs-badge.level-10 {
    color: var(--success);
}

/* Clause Numerical Input */
.clause-input-blank {
    background: var(--bg-card);
    border: 1px dashed var(--accent);
    color: var(--text-main);
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 1rem;
    font-family: inherit;
    width: 80px;
    height: 1.8rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    vertical-align: middle;
    margin: 0 4px;
    transition: all 0.2s;
}

.clause-input-blank:focus {
    outline: none;
    border-style: solid;
    box-shadow: 0 0 0 2px rgba(64, 150, 255, 0.3);
}

.clause-input-blank.mini {
    width: 60px;
    font-size: 0.9rem;
    height: 1.5rem;
}

.clause-input-blank.correct {
    background: rgba(40, 167, 69, 0.2);
    border: 1px solid #28a745;
    color: #28a745;
}

.clause-input-blank.wrong {
    background: rgba(220, 53, 69, 0.2);
    border: 1px solid #dc3545;
    color: #f82b41;
}

.clause-input-blank:disabled {
    opacity: 1;
    cursor: default;
}

.clause-input-wrapper {
    position: relative;
    display: inline-flex;
    vertical-align: middle;
    margin: 0 4px;
    overflow: visible !important;
}

/* Mastery Status Board */
.mastery-board {
    margin: 1.5rem auto;
    width: calc(100% - 1rem);
    max-width: 2000px;
    background: rgba(30, 32, 45, 0.4);
    border: 1px solid var(--glass-border);
    border-radius: 20px;
    padding: 1.5rem;
    backdrop-filter: blur(10px);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
}

.mastery-board.hidden {
    display: none;
}

.mastery-board .board-title {
    font-size: 1rem;
    font-weight: 700;
    color: var(--accent);
    margin-bottom: 1.2rem;
    display: flex;
    align-items: center;
    gap: 10px;
}

.mastery-list {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
}

.mastery-card {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--glass-border);
    padding: 0.6rem 1.2rem;
    border-radius: 12px;
    display: flex;
    align-items: center;
    gap: 10px;
    transition: var(--transition);
}

.mastery-card:hover {
    background: rgba(255, 255, 255, 0.1);
    transform: translateY(-2px);
}

.mastery-card.mastered {
    border-color: var(--success);
    background: rgba(74, 222, 128, 0.1);
}

.mastery-card.new-item {
    border-style: dashed;
    opacity: 0.8;
}

.mastery-card .kw-index {
    font-size: 0.75rem;
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-secondary);
    width: 18px;
    height: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    font-family: monospace;
}

.mastery-card .kw-text {
    font-size: 0.95rem;
    color: var(--text-primary);
}

.mastery-card .streak-val {
    font-weight: 900;
    color: #ff4d6d;
    background: rgba(255, 77, 109, 0.1);
    padding: 2px 8px;
    border-radius: 6px;
    font-size: 0.85rem;
    min-width: 35px;
    text-align: center;
}

.mastery-card.new-item .streak-val {
    color: var(--text-secondary);
    background: rgba(255, 255, 255, 0.05);
}

.mastery-card.mastered .streak-val {
    color: var(--success);
    background: rgba(74, 222, 128, 0.1);
}

@keyframes badgePop {
    from {
        transform: scale(0);
        opacity: 0;
    }

    to {
        transform: scale(1);
        opacity: 1;
    }
}

.table-clause-wrapper .streak-badge {
    top: -10px;
    right: -10px;
    min-width: 18px;
    height: 18px;
    font-size: 0.7rem;
}

/* Removed redundant .page-tag */

.source-label {
    opacity: 0.6;
    margin-right: 0.3rem;
}

.choice-cell.filled {
    color: var(--accent);
    font-weight: 600;
}

/* Clause Review Headers and Dividers */
.clause-review-header {
    background: rgba(76, 201, 240, 0.1);
    color: var(--accent);
    padding: 0.6rem 1.2rem;
    border-radius: 12px;
    margin-bottom: 1.5rem;
    border-left: 5px solid var(--accent);
    font-weight: 700;
    font-family: 'Outfit', sans-serif;
    font-size: 1.1rem;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
}

.clause-divider {
    border: none;
    border-bottom: 2px dashed var(--glass-border);
    margin: 2.5rem 0;
    opacity: 0.5;
}

/* Sidebar Quick Actions */
.sidebar-quick-actions {
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    border-bottom: 1px solid var(--glass-border);
}

.sidebar-gen-btn {
    width: 100%;
    padding: 0.7rem 0.8rem;
    border-radius: 10px;
    border: none;
    font-size: 0.9rem;
    font-weight: 700;
    cursor: pointer;
    transition: var(--transition);
    text-align: center;
    font-family: 'Outfit', sans-serif;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.sidebar-gen-btn.sync-btn {
    background: var(--accent);
    color: var(--bg-dark);
}

.sidebar-gen-btn.srs-clause {
    background: var(--success);
    color: var(--bg-dark);
}

.sidebar-gen-btn.srs-page {
    background: #2ec4b6;
    color: var(--bg-dark);
}

.sidebar-gen-btn:hover {
    transform: translateY(-2px);
    filter: brightness(1.1);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.sidebar-gen-btn:active {
    transform: translateY(0);
}

/* iPad & Mobile Responsiveness */
@media (max-width: 1024px) {
    :root {
        --sidebar-width: 100%;
        font-size: 16px;
    }

    .sidebar {
        position: fixed;
        left: -100%;
        top: 0;
        height: 100%;
        z-index: 2000;
        transition: var(--transition);
        box-shadow: 10px 0 30px rgba(0, 0, 0, 0.5);
        background-color: var(--bg-dark);
        /* Ensure background is solid when overlapping */
    }

    .sidebar.open {
        left: 0;
    }

    .main-content {
        padding: 1.5rem;
        width: 100%;
        margin-left: 0 !important;
    }

    .header-right {
        flex-direction: column;
        align-items: flex-end;
        gap: 0.5rem;
    }

    .edit-controls {
        flex-wrap: wrap;
        justify-content: flex-end;
        gap: 0.5rem;
    }

    .home-dashboard {
        padding: 1.5rem;
        margin: 1rem auto;
    }

    .welcome-title {
        font-size: 1.8rem;
    }

    /* Table Responsiveness */
    .table-wrapper {
        padding: 1rem;
        border-radius: 12px;
    }

    table {
        font-size: 0.9rem;
    }

    th,
    td {
        padding: 0.8rem 0.5rem;
    }

    .question-cell {
        min-width: 180px;
    }

    .choice-cell {
        min-width: 80px;
    }

    /* Column Controls at top */
    .column-controls {
        flex-wrap: wrap;
        gap: 0.5rem;
    }

    .secondary-btn {
        padding: 0.6rem 0.8rem;
        font-size: 0.85rem;
    }

    /* GitHub Settings */
    .github-sync-actions {
        flex-direction: column;
    }

    .github-sync-actions button {
        width: 100%;
    }
}

/* Specific small mobile tweaks */
@media (max-width: 480px) {
    .main-content {
        padding: 1rem;
    }

    .welcome-title {
        font-size: 1.5rem;
    }
}

/* Touch Device Optimizations */
@media (hover: none) {

    .sidebar-gen-btn,
    .primary-btn,
    .secondary-btn {
        padding: 0.8rem 1rem;
        /* Slightly larger targets for touch */
    }

    .toc-nav a {
        padding: 0.8rem 1rem;
    }
}

/* Global Sidebar Toggle Styles */
.menu-toggle-global {
    position: fixed;
    top: 1.5rem;
    left: 1.5rem;
    z-index: 1500;
    background: var(--bg-card);
    border: 1px solid var(--glass-border);
    color: var(--accent);
    width: 45px;
    height: 45px;
    border-radius: 12px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    backdrop-filter: blur(10px);
    transition: var(--transition);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
}

.menu-toggle-global:hover {
    background: var(--accent);
    color: var(--bg-dark);
    transform: scale(1.05);
}

.sidebar-close-btn {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid var(--glass-border);
    color: var(--text-secondary);
    width: 35px;
    height: 35px;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    transition: var(--transition);
    line-height: 1;
}

.sidebar-close-btn:hover {
    background: var(--error);
    color: white;
    transform: rotate(90deg);
}

/* Adjust main content when toggle exists */
.main-content {
    padding-top: 4.5rem !important;
    /* Make room for the floating toggle */
}

/* Sidebar collapsed state for desktop */
.sidebar-hidden .sidebar {
    margin-left: calc(var(--sidebar-width, 320px) * -1);
}

.sidebar-hidden .main-content {
    margin-left: 0 !important;
}

@media (min-width: 1025px) {
    body:not(.sidebar-hidden) .menu-toggle-global {
        display: none !important;
    }
}

@media (max-width: 1024px) {
    .menu-toggle-global {
        top: 1rem;
        left: 1rem;
        width: 40px;
        height: 40px;
        font-size: 1.2rem;
    }
}

.clause-history-btn {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.6rem 1.2rem;
    background: rgba(76, 201, 240, 0.08);
    border: 1px solid rgba(76, 201, 240, 0.4);
    border-radius: 12px;
    color: #4cc9f0;
    font-size: 0.95rem;
    font-weight: 700;
    font-family: 'Outfit', sans-serif;
    cursor: pointer;
    transition: all 0.3s ease;
    margin-bottom: 2rem;
    width: fit-content;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.clause-history-btn:hover {
    background: rgba(76, 201, 240, 0.15);
    border-color: #4cc9f0;
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(76, 201, 240, 0.3);
}

#peek-answers-btn.active {
    background: rgba(181, 101, 241, 0.2) !important;
    border-color: #b565f1 !important;
    color: #b565f1 !important;
    box-shadow: 0 0 15px rgba(181, 101, 241, 0.3);
    transform: translateY(-2px);
}

/* Peek Revelation Logic */
.peek-answer {
    display: none;
    font-size: 0.75rem;
    color: #b565f1;
    margin-left: 0.4rem;
    font-weight: 600;
    vertical-align: middle;
}

body.answers-revealed .peek-answer {
    display: inline !important;
    color: #f72585 !important;
    /* Bright pink for max visibility */
    background: rgba(255, 255, 255, 0.1);
    padding: 0 4px;
    border-radius: 4px;
}

body.answers-revealed .clause-blank,
body.answers-revealed .clause-input-blank {
        border-color: #f72585 !important;
    box-shadow: 0 0 12px rgba(247, 37, 133, 0.3);
}

/* Streak Badges directly on blanks */
.clause-blank[data-streak],
.clause-input-wrapper[data-streak] {
    position: relative !important;
    overflow: visible !important;
}

.clause-blank.clause-blank[data-streak]::after,
.clause-input-wrapper[data-streak]::after {
    content: none !important; /* Hide the old static fire icon */
}

/* Ensure streak-badge elements are correctly positioned and clickable */
.streak-badge {
    position: absolute;
    top: -24px;
    right: -10px;
    font-weight: 800;
    color: #ffd700; /* Gold/Fire color */
    background: rgba(0, 0, 0, 0.95);
    padding: 2px 6px;
    border-radius: 6px;
    border: 1px solid rgba(255, 215, 0, 0.4);
    white-space: nowrap;
    z-index: 2000;
    pointer-events: auto !important; /* MUST BE AUTO TO CLICK */
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.6);
    line-height: 1;
    cursor: pointer;
    font-size: 0.75rem;
    transition: transform 0.2s ease;
}

.streak-badge:hover {
    transform: scale(1.2);
    background: #ffd700;
    color: #000;
}

@keyframes badgeFloat {

    0%,
    100% {
        transform: translateY(0);
    }

    50% {
        transform: translateY(-2px);
    }
}

.clause-input-wrapper {
    display: inline-block;
    position: relative;
    vertical-align: middle;
}

/* Context Menu */
.context-menu {
    position: fixed;
    z-index: 5000;
    background: rgba(20, 22, 30, 0.98);
    backdrop-filter: blur(15px);
    border: 1px solid var(--glass-border);
    border-radius: 12px;
    padding: 0.5rem;
    min-width: 200px;
    box-shadow: 0 15px 35px rgba(0, 0, 0, 0.6);
    animation: menu-pop 0.1s ease-out;
}

@keyframes menu-pop {
    from { opacity: 0; transform: scale(0.95); }
    to { opacity: 1; transform: scale(1); }
}

.context-menu-item {
    padding: 0.7rem 1rem;
    font-size: 0.9rem;
    color: var(--text-primary);
    cursor: pointer;
    border-radius: 8px;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 0.8rem;
    font-weight: 500;
}

.context-menu-item:hover {
    background: rgba(67, 97, 238, 0.25);
    color: var(--accent);
}

.context-menu-item.danger:hover {
    background: rgba(247, 37, 133, 0.15);
    color: #fca5a5;
}

.context-menu hr {
    border: none;
    border-top: 1px solid var(--glass-border);
    margin: 0.4rem 0.5rem;
}

.quiz-table {
    border-collapse: collapse !important;
    border-spacing: 0 !important;
    margin-top: 1rem;
    margin-bottom: 1.5rem;
    width: 100%;
}

.quiz-table td, .quiz-table th {
    border: 1px solid var(--glass-border) !important;
    padding: 0.8rem 1rem !important;
    background: rgba(255, 255, 255, 0.02) !important;
    vertical-align: middle !important;
    white-space: pre-wrap !important;
}

.quiz-table th {
    background: rgba(67, 97, 238, 0.15) !important;
    color: var(--accent) !important;
    font-weight: 600;
    text-transform: none;
    letter-spacing: normal;
}

.folder-due-badge {
    background: var(--error);
    color: white;
    padding: 1px 6px;
    border-radius: 8px;
    font-size: 0.7rem;
    font-weight: bold;
    margin-left: auto;
    flex-shrink: 0;
    box-shadow: 0 2px 5px rgba(247, 37, 133, 0.3);
    z-index: 5;
}

.stagnant-scroll-wrapper {
    max-height: 500px !important;
    overflow-y: auto !important;
    padding-top: 0 !important;
    padding-bottom: 1.5rem !important;
}

.stagnant-scroll-wrapper thead th {
    position: sticky !important;
    top: 0 !important;
    background: #1e202d !important;
    z-index: 20 !important;
    border-bottom: 2px solid var(--accent) !important;
}

.sort-icon {
    margin-left: 0.3rem;
    font-size: 0.7rem;
    vertical-align: middle;
    display: inline-block;
    transition: transform 0.2s;
    opacity: 0.8;
}

th[onclick] {
    user-select: none;
}

th[onclick]:hover {
    background: rgba(255, 255, 255, 0.05) !important;
}

/* Stagnant Questions Filter Bar Styles */
.stagnant-filter-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 1.5rem;
    padding: 1.5rem;
    margin-bottom: 1.5rem;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--glass-border);
    border-radius: 16px;
    backdrop-filter: blur(8px);
}

.filter-group {
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
    min-width: 220px;
    flex: 1;
}

.filter-group label {
    font-size: 0.85rem;
    color: var(--accent);
    font-weight: 600;
}

.range-inputs {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

.filter-val {
    font-size: 0.8rem;
    color: var(--text-secondary);
    text-align: right;
    font-variant-numeric: tabular-nums;
}

/* Premium Range Sliders */
.range-inputs input[type="range"] {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    height: 6px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 3px;
    outline: none;
    margin: 5px 0;
}

.range-inputs input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 16px;
    height: 16px;
    background: var(--accent);
    border: 2px solid white;
    border-radius: 50%;
    cursor: pointer;
    box-shadow: 0 0 10px rgba(76, 201, 240, 0.5);
    transition: transform 0.1s ease-in-out;
}

.range-inputs input[type="range"]::-webkit-slider-thumb:hover {
    transform: scale(1.2);
}

.range-inputs input[type="range"]::-moz-range-thumb {
    width: 16px;
    height: 16px;
    background: var(--accent);
    border: 2px solid white;
    border-radius: 50%;
    cursor: pointer;
    box-shadow: 0 0 10px rgba(76, 201, 240, 0.5);
}

.next-btn-highlight {
    animation: next-btn-glow 2s infinite;
    box-shadow: 0 0 15px var(--accent) !important;
}

@keyframes next-btn-glow {
    0% { transform: scale(1); box-shadow: 0 0 5px var(--accent); }
    50% { transform: scale(1.05); box-shadow: 0 0 20px var(--accent); }
    100% { transform: scale(1); box-shadow: 0 0 5px var(--accent); }
}

/* Whiteboard Styles */
#whiteboard-overlay {
    position: fixed;
    inset: 0;
    z-index: 9999;
    background: rgba(0, 0, 0, 0.6);
    display: flex;
    flex-direction: column;
}

#whiteboard-overlay.hidden {
    display: none;
}

.wb-toolbar {
    height: 50px;
    background: var(--bg-dark);
    border-bottom: 1px solid var(--glass-border);
    display: flex;
    align-items: center;
    padding: 0 1rem;
    gap: 0.8rem;
}

.wb-tool {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: 2px solid transparent;
    cursor: pointer;
    transition: var(--transition);
}

.wb-tool.active {
    border-color: var(--success);
    transform: scale(1.1);
    box-shadow: 0 0 10px rgba(255, 255, 255, 0.2);
}

.wb-tool-icon {
    background: transparent;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    border-radius: 8px;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
}

.wb-tool-icon:hover, .wb-tool-icon.active {
    background: rgba(255, 255, 255, 0.1);
}

.wb-divider {
    width: 1px;
    height: 30px;
    background: var(--glass-border);
    margin: 0 0.5rem;
}

#wb-canvas {
    flex: 1;
    width: 100%;
    touch-action: none;
    cursor: crosshair;
}

/* e-Gov API Preview Styles */
@keyframes pulse {
    0% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.5; transform: scale(0.95); }
    100% { opacity: 1; transform: scale(1); }
}

.egov-link, .external-link {
    color: var(--accent);
    text-decoration: underline;
    text-underline-offset: 3px;
    cursor: pointer;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    gap: 0.2rem;
}
.egov-link:hover, .external-link:hover {
    color: #fff;
    text-shadow: 0 0 8px var(--accent);
}

.egov-paragraph {
    margin-bottom: 1rem;
    padding-left: 1rem;
    text-indent: -1rem;
}
.egov-item {
    margin-bottom: 0.5rem;
    padding-left: 2rem;
    text-indent: -1rem;
}
.egov-caption {
    font-weight: bold;
    color: var(--accent);
    margin-bottom: 0.5rem;
    display: block;
}
.egov-title {
    font-weight: bold;
    font-size: 1.1rem;
    margin-bottom: 1rem;
    border-bottom: 1px solid var(--glass-border);
    padding-bottom: 0.5rem;
}


/* OK / NG Badges for rows */
.row-correct .question-cell::before {
    content: "OK!";
    display: inline-block;
    background: var(--success);
    color: var(--bg-dark);
    font-weight: bold;
    padding: 2px 6px;
    border-radius: 4px;
    margin-right: 8px;
    font-size: 0.85rem;
    vertical-align: middle;
}

.row-wrong .question-cell::before {
    content: "NG!";
    display: inline-block;
    background: var(--error);
    color: white;
    font-weight: bold;
    padding: 2px 6px;
    border-radius: 4px;
    margin-right: 8px;
    font-size: 0.85rem;
    vertical-align: middle;
}


