:root {
    /* Colors - Bright Theme */
    --bg-color-start: #f0f9ff;
    /* Sky 50 */
    --bg-color-end: #e0f2fe;
    /* Sky 100 */
    --text-primary: #1e293b;
    /* Slate 800 */
    --text-secondary: #64748b;
    /* Slate 500 */
    --accent-color: #0ea5e9;
    /* Sky 500 */

    --accent-glow: #0284c7;
    /* Sky 600 - Darker for visibility on light bg */

    --glass-bg: rgba(255, 255, 255, 0.65);
    /* More opaque white for light mode */
    --glass-border: rgba(255, 255, 255, 0.8);
    --glass-highlight: rgba(255, 255, 255, 0.9);

    --success-color: #10b981;
    /* Emerald 500 */

    --completed-card-bg: rgba(16, 185, 129, 0.15);

    --completed-ot-bg: rgba(6, 182, 212, 0.15);
    /* KB: Cyan tint */
    --completed-ot-border: rgba(6, 182, 212, 0.4);

    --completed-nt-bg: rgba(245, 158, 11, 0.15);
    /* KB: Amber tint */
    --completed-nt-border: rgba(245, 158, 11, 0.4);

    /* Spacing & Layout */
    --app-max-width: 600px;
    --header-height: 60px;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    -webkit-tap-highlight-color: transparent;
}

body {
    font-family: 'Zen Kaku Gothic New', sans-serif;
    color: var(--text-primary);
    background: linear-gradient(135deg, var(--bg-color-start) 0%, var(--bg-color-end) 100%);
    background-attachment: fixed;
    min-height: 100vh;
    overflow-x: hidden;
}

.app-container {
    max-width: var(--app-max-width);
    margin: 0 auto;
    padding: 20px;
    padding-bottom: 80px;
    /* Space for bottom interaction */
}

/* Glassmorphism Utilities */
.glass-panel {
    background: var(--glass-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--glass-border);
    border-radius: 16px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

/* Header */
.main-header {
    padding: 20px;
    margin-bottom: 24px;
    text-align: center;
    position: relative;
}

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

.header-top h1 {
    font-size: 1.2rem;
    font-weight: 700;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    background: linear-gradient(to right, #1e293b, #475569);
    /* Slate 800 to Slate 600 */
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.icon-btn {
    background: transparent;
    border: none;
    color: var(--text-primary);
    cursor: pointer;
    padding: 8px;
    border-radius: 50%;
    transition: background 0.2s;
}

.icon-btn:hover {
    background: var(--glass-border);
}

/* Tree Visualization */
/* Tree Visual */
.tree-container {
    height: 180px;
    display: flex;
    justify-content: center;
    align-items: center;
    margin-bottom: 20px;
    position: relative;
}

.tree-image {
    max-height: 100%;
    max-width: 100%;
    object-fit: contain;
    transition: all 0.5s ease;
    filter: drop-shadow(0 0 15px rgba(255, 255, 255, 0.3));
}

.progress-info {
    width: 100%;
    max-width: 200px;
    margin-top: 16px;
    display: flex;
    align-items: center;
    gap: 12px;
}

.progress-bar-bg {
    flex: 1;
    height: 6px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 10px;
    overflow: hidden;
}

.progress-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--accent-color), var(--success-color));
    border-radius: 10px;
    box-shadow: 0 0 10px var(--accent-color);
    transition: width 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

#total-percentage {
    font-size: 0.9rem;
    font-weight: 700;
    color: var(--accent-glow);
}

/* Motivation Section */
.motivation-section {
    padding: 16px;
    margin-bottom: 24px;
}

.section-header h2 {
    font-size: 0.9rem;
    color: var(--text-secondary);
    margin-bottom: 12px;
}

.calendar-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(12px, 1fr));
    gap: 4px;
    height: 80px;
    /* Limit height roughly */
    overflow: hidden;
    /* Or optimize for mobile scrolling */
}

/* Book List & Tabs */
.tabs {
    display: flex;
    gap: 12px;
    margin-bottom: 16px;
}

.tab-btn {
    flex: 1;
    padding: 12px;
    background: transparent;
    border: none;
    color: var(--text-secondary);
    font-weight: 700;
    border-bottom: 2px solid transparent;
    cursor: pointer;
    transition: all 0.3s;
}

.tab-btn.active {
    color: var(--text-primary);
    border-bottom-color: var(--accent-color);
}

.book-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 12px;
}

.book-card {
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    border-radius: 12px;
    padding: 12px;
    cursor: pointer;
    position: relative;
    overflow: hidden;
    transition: transform 0.2s, background 0.3s;
}

.book-card:active {
    transform: scale(0.98);
}

.book-card.completed-ot {
    background: var(--completed-ot-bg);
    border-color: var(--completed-ot-border);
    box-shadow: 0 0 15px rgba(6, 182, 212, 0.1);
}

.book-card.completed-nt {
    background: var(--completed-nt-bg);
    border-color: var(--completed-nt-border);
    box-shadow: 0 0 15px rgba(245, 158, 11, 0.1);
}

.book-name {
    font-size: 0.95rem;
    font-weight: 700;
    margin-bottom: 4px;
    z-index: 1;
    position: relative;
}

.book-progress {
    font-size: 0.8rem;
    color: var(--text-secondary);
    z-index: 1;
    position: relative;
}

.book-stamp {
    position: absolute;
    top: -5px;
    right: -5px;
    font-size: 3rem;
    opacity: 0.3;
    pointer-events: none;
    transform: rotate(-15deg);
    filter: drop-shadow(0 0 5px gold);
}

/* Modal */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    z-index: 100;
    display: flex;
    align-items: flex-end;
    /* Sheet style on mobile */
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s;
}

.modal.open {
    opacity: 1;
    pointer-events: auto;
}

.modal-content {
    width: 100%;
    max-width: var(--app-max-width);
    margin: 0 auto;
    height: 85vh;
    border-radius: 20px 20px 0 0;
    background: rgba(30, 41, 59, 0.95);
    display: flex;
    flex-direction: column;
    transform: translateY(100%);
    transition: transform 0.3s cubic-bezier(0.2, 0.8, 0.2, 1);
}

.modal.open .modal-content {
    transform: translateY(0);
}

/* Center Modal (Confirmation) */
.modal.center-modal {
    align-items: center;
    justify-content: center;
}

.modal-content-center {
    width: 90%;
    max-width: 320px;
    background: rgba(30, 41, 59, 0.98);
    border-radius: 16px;
    padding: 24px;
    transform: scale(0.9);
    transition: transform 0.2s;
    text-align: center;
    border: 1px solid var(--glass-border);
}

.modal.open .modal-content-center {
    transform: scale(1);
}

.modal-content-center h3 {
    margin-bottom: 12px;
    font-size: 1.1rem;
}

.modal-content-center p {
    color: var(--text-secondary);
    margin-bottom: 24px;
    font-size: 0.95rem;
}

.modal-actions {
    display: flex;
    gap: 12px;
}

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

.modal-header h2 {
    font-size: 1.2rem;
    flex: 1;
    text-align: center;
}

.close-modal-btn {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 1.5rem;
    cursor: pointer;
    padding: 0 10px;
}

.chapter-grid-container {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(60px, 1fr));
    gap: 12px;
    align-content: start;
}

/* Chapter Items */
.chapter-item {
    aspect-ratio: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    border-radius: 12px;
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s;
    user-select: none;
}

.chapter-item:active {
    transform: scale(0.9);
}

.chapter-item.read {
    background: linear-gradient(135deg, var(--accent-color), #3b82f6);
    border-color: transparent;
    color: #fff;
    box-shadow: 0 0 15px rgba(6, 182, 212, 0.4);
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
}

.chapter-item.read:active {
    box-shadow: 0 0 5px rgba(6, 182, 212, 0.6);
}

/* Settings */
.settings-body {
    padding: 20px;
}

.setting-item {
    margin-bottom: 24px;
}

.setting-item h3 {
    font-size: 1rem;
    margin-bottom: 8px;
}

.setting-item p {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-bottom: 12px;
}

.primary-btn,
.secondary-btn,
.danger-btn {
    width: 100%;
    padding: 12px;
    border-radius: 8px;
    font-weight: 700;
    cursor: pointer;
    border: none;
    margin-bottom: 8px;
}

.primary-btn {
    background: var(--accent-color);
    color: #fff;
}

.secondary-btn {
    background: var(--glass-highlight);
    color: var(--text-primary);
}

.danger-btn {
    background: rgba(239, 68, 68, 0.2);
    color: #ef4444;
}

textarea {
    width: 100%;
    height: 100px;
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid var(--glass-border);
    border-radius: 8px;
    padding: 10px;
    color: var(--text-primary);
    font-family: monospace;
    margin-bottom: 8px;
}

/* Canvas */
#confetti-canvas {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 200;
}

@keyframes float {

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

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