:root {
    --bg-color: #ededed;
    --text-primary: #1c1c1c;
    --text-secondary: #272727;
    --accent-blue: #234fff;
    --pill-bg: linear-gradient(145deg, #d3d3d3, #e5e5e5);
    --pill-shadow: 6px 6px 15px rgba(0, 0, 0, 0.4),
        -3px -3px 8px rgba(255, 255, 255, 0.8),
        inset 0 0 5px rgba(0, 0, 0, 0.1);
    --font-hand: 'Kalam', cursive, sans-serif;
    --check-color: #1a42e1;
    --ripple: rgba(0, 0, 0, 0.2);
}

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

/* Consolidated drawing canvas styles below in the tools section */

body {
    font-family: var(--font-hand);
    color: var(--text-primary);
    background-color: var(--bg-color);
    margin: 0;
    background-image: url('bg-texture.jpg');
    background-size: 100vw auto;
    /* Uniformly spread without stretching vertically */
    background-repeat: repeat;
    /* Allows scrolling naturally */
    line-height: 1.4;
    overflow-x: hidden;
    /* Android specifics */
    -webkit-tap-highlight-color: transparent;
    user-select: none;
    -webkit-user-select: none;
    -webkit-touch-callout: none;
}

.android-container {
    max-width: 600px;
    margin: 0 auto;
    padding: 24px 16px;
}

/* Make text appear as if it is written directly on the paper */
.syllabus,
.subtitle {
    mix-blend-mode: multiply;
    opacity: 0.85;
    /* Ink absorption simulation */
}

/* Header & Title Banner */
.main-header {
    text-align: center;
    margin-bottom: 30px;
}

.pill-container {
    display: flex;
    justify-content: center;
    margin-bottom: 20px;
}

.brand-pill {
    background: transparent;
    padding: 12px 20px;
    display: inline-flex;
    align-items: center;
    gap: 15px;
    mix-blend-mode: multiply;
}

/* Progress Bar Sketch */
.progress-section {
    margin: 20px auto 30px;
    width: 85%;
    max-width: 400px;
    mix-blend-mode: multiply;
}

.progress-container {
    width: 100%;
    height: 16px;
    /* Increased slightly to handle organic curves */
    border: 2px solid #333;
    border-radius: 12px 25px 8px 18px / 15px 5px 22px 10px;
    /* Jagged asymmetric organic curves */
    background: transparent;
    position: relative;
    overflow: hidden;
    margin-bottom: 8px;
    transform: rotate(-0.5deg);
    /* Off axis */
    box-shadow: 1px 1.5px 0 rgba(0, 0, 0, 0.1);
    /* Fake sketchy thickness */
}

.progress-bar {
    height: 100%;
    background-color: var(--accent-blue);
    width: 0%;
    transition: width 0.5s ease-out;
    border-right: 2px solid #333;
    /* Sketch border end */
    border-radius: 8px 15px 5px 20px / 10px 15px 10px 5px;
    opacity: 0.8;
}

.progress-text {
    font-size: 1.1rem;
    color: #1b1b1b;
    font-weight: 700;
    text-align: right;
    letter-spacing: 0.5px;
}

.brand-pill h1 {
    font-size: 1.8rem;
    color: #1b1b1b;
    font-weight: 700;
    letter-spacing: 0.5px;
    mix-blend-mode: multiply;
    opacity: 0.9;
    text-shadow: 1px 1px 1px rgba(255, 255, 255, 0.4);
}

.subtitle {
    color: var(--accent-blue);
    font-size: 1.2rem;
    font-weight: 600;
    line-height: 1.3;
    max-width: 90%;
    margin: 0 auto;
    text-shadow: 0.5px 0.5px 0 rgba(255, 255, 255, 0.8);
}

/* Syllabus List */
.syllabus {
    display: flex;
    flex-direction: column;
    gap: 28px;
}

.category-section {
    padding-left: 5px;
}

.category-title {
    font-size: 1.6rem;
    font-weight: 700;
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    letter-spacing: 0.5px;
}

.lesson-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding-left: 20px;
}

.lesson-item {
    position: relative;
    border-radius: 8px;
    overflow: hidden;
}

/* Link behavior */
.lesson-link {
    display: flex;
    align-items: flex-start;
    text-decoration: none;
    color: var(--text-primary);
    padding: 8px 12px;
    border-radius: 6px;
    transition: background-color 0.2s ease;
    gap: 12px;
}

.lesson-link:hover,
.lesson-link:focus,
.lesson-link:active {
    background-color: rgba(0, 0, 0, 0.04);
}

.lesson-text {
    flex: 1;
    font-size: 1.3rem;
    font-weight: 600;
    margin-top: -2px;
}

/* Completed Text Style */
.completed-text,
.completed-text .lesson-text {
    opacity: 0.85;
    /* Effectively reduces opacity by approx 10-15% */
}


/* Subpages Styles */
.subpage {
    /* Transparent to show paper texture */
    background-color: transparent;
}

.subpage-header {
    background: transparent;
    padding: 16px 20px;
    display: flex;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 10;
    mix-blend-mode: multiply;
}

.back-btn {
    text-decoration: none;
    color: var(--text-primary);
    font-size: 1.3rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 6px;
    margin-right: 15px;
}

.subpage-header h1 {
    font-size: 1.3rem;
    font-weight: 600;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    opacity: 0.8;
}

.content-container {
    max-width: 600px;
    margin: 10px auto;
    padding: 24px 16px;
    background: transparent;
    border: none;
    box-shadow: none;
    mix-blend-mode: multiply;
    opacity: 0.85;
    /* Ink absorption simulation */
}

.page-title {
    font-size: 2rem;
    margin-bottom: 20px;
    color: var(--text-primary);
    border-bottom: 2px dashed rgba(0, 0, 0, 0.1);
    padding-bottom: 15px;
}

.content-placeholder {
    font-size: 1.4rem;
    margin-bottom: 40px;
}

.content-placeholder p {
    margin-bottom: 15px;
}

.bottom-nav {
    display: flex;
    justify-content: space-between;
    margin-top: 40px;
    gap: 15px;
}

.nav-btn {
    flex: 1;
    text-align: center;
    padding: 12px;
    color: var(--text-primary);
    font-family: inherit;
    font-size: 1.4rem;
    font-weight: 700;
    text-decoration: none;
    background: transparent;
    border: 2px solid #333;
    border-radius: 255px 15px 225px 15px / 15px 225px 15px 255px;
    /* Sketchy border trick */
    mix-blend-mode: multiply;
    opacity: 0.85;
    transition: all 0.2s ease;
}

.nav-btn:hover,
.nav-btn:active {
    background-color: rgba(0, 0, 0, 0.05);
}

.nav-btn.next-btn {
    border-width: 2.5px;
}

.toggle-btn {
    background-image:
        url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='40' height='40'%3E%3Ccircle cx='7' cy='14' r='0.5' fill='%23ffffff' opacity='0.6'/%3E%3Ccircle cx='28' cy='5' r='0.4' fill='%23ffffff' opacity='0.4'/%3E%3Ccircle cx='18' cy='32' r='0.6' fill='%23ffffff' opacity='0.3'/%3E%3Ccircle cx='35' cy='22' r='0.4' fill='%23ffffff' opacity='0.5'/%3E%3Ccircle cx='2' cy='37' r='0.5' fill='%23ffffff' opacity='0.4'/%3E%3Ccircle cx='22' cy='18' r='0.3' fill='%23ffffff' opacity='0.7'/%3E%3C/svg%3E"),
        linear-gradient(to right, var(--accent-blue) 50%, #222 50%);
    background-size: 40px 40px, 200% 100%;
    background-position: 0 0, 100% 0;
    /* Align right to show #222 black sketch */
    background-color: #222;
    /* Fallback */
    color: #fff;
    border-color: #222;
    border-radius: 255px 15px 225px 15px / 15px 225px 15px 255px;
    /* Sketchy, irregular border */
    transition: background-position 0.6s ease-in-out, color 0.4s ease, border-color 0.4s ease, opacity 0.1s ease;
}

.toggle-btn.btn-completed {
    background-position: 0 0, 0 0;
    /* Align left to show blue */
    border-color: var(--accent-blue);
    color: #1b1b1b;
}

.toggle-btn:active {
    opacity: 1 !important;
}

/* Global Ripple Effect classes */
.ripple {
    position: relative;
    overflow: hidden;
}

.ripple-animate {
    position: absolute;
    border-radius: 50%;
    transform: scale(0);
    animation: rippleEffect 0.6s linear;
    background-color: var(--ripple);
    pointer-events: none;
}

@keyframes rippleEffect {
    to {
        transform: scale(4);
        opacity: 0;
    }
}

/* Drawing tools */
body {
    cursor: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' width='24' height='24' fill='none' stroke='%23666' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M16.5 3.5a2.121 2.121 0 0 1 3 3L7 19l-4 1 1-4L16.5 3.5z'/%3E%3C/svg%3E") 2 22, auto;
}

#persistent-canvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    /* height is set by JS to match document scroll height */
    z-index: 9998;
    pointer-events: none;
}

#temp-canvas {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 9999;
    pointer-events: none; /* JS toggles to 'auto' for drawing */
    touch-action: auto;   /* JS toggles to 'none' for drawing */
}

.drawing-tools {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 10000;
    display: flex;
    flex-direction: column-reverse;
    /* Opens upwards */
    align-items: flex-end;
    gap: 10px;
}

.tool-btn {
    width: 50px;
    height: 50px;
    border-radius: 45% 55% 45% 55% / 55% 45% 50% 50%;
    /* Sketchy Hand Drawn Circle */
    background: transparent;
    border: 3px solid #333;
    /* Thicker for sketch look */
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 2px 2px 0 rgba(0, 0, 0, 0.1);
    mix-blend-mode: multiply;
}

.tool-menu {
    display: none;
    flex-direction: column;
    background: #ededed;
    border: 2px solid #333;
    overflow: hidden;
    box-shadow: 2px 4px 10px rgba(0, 0, 0, 0.1);
    border-radius: 255px 15px 225px 15px / 15px 225px 15px 255px;
    /* Extremely irregular sketch box */
}

.tool-menu.open {
    display: flex;
}

.mode-btn {
    padding: 10px 15px;
    border: none;
    background: transparent;
    font-family: inherit;
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-primary);
    cursor: pointer;
    text-align: left;
    border-bottom: 2px dotted #555;
    mix-blend-mode: multiply;
    display: flex;
    align-items: center;
    gap: 8px;
    /* Space between icon and text */
}

.mode-btn:last-child {
    border-bottom: none;
}

.mode-btn.active {
    background: rgba(35, 79, 255, 0.1);
    color: var(--accent-blue);
}