:root {
    --primary-color: #4A3B32; /* Deep Espresso Brown */
    --accent-color: #C07C41; /* Warm Caramel/Gold */
    --bg-color: #fdfbf7; /* Soft creamy beige */
    --surface-color: #ffffff;
    --text-color: #3E322C;
    --border-color: #Dbd3c8;
    --lock-color: #A05252; /* Earthy Red */
    --unlock-color: #5C7A5C; /* Sage Green */
    --font-heading: 'Lora', serif;
    --font-ui: 'Outfit', sans-serif;
}

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

body, html {
    font-family: var(--font-ui);
    background-color: var(--bg-color);
    color: var(--text-color);
    overscroll-behavior-y: none; /* Prevent pull-to-refresh on mobile */
    /* touch-action is controlled dynamically based on lock state */
}

h1, h2, h3, h4 {
    font-family: var(--font-heading);
}

/* Main Header Layout (Fixed Absolute Center System) */
.main-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 25px;
    padding: 20px 0; /* Increased padding */
    min-height: 130px; /* Forces enough height so the title doesn't cut off */
    width: 100%;
    position: relative;
}

.header-left {
    display: flex;
    gap: 12px;
    z-index: 10;
}

.header-center {
    position: absolute;
    left: 50%;
    top: 50%; /* Pin to vertical center */
    transform: translate(-50%, -50%); /* Perfectly center vertically and horizontally */
    text-align: center;
    z-index: 5;
    width: 100%; /* Prevents text squishing */
    pointer-events: none; 
}

.header-right {
    display: flex;
    z-index: 10;
}

.header-input {
    padding: 12px 16px;
    border: 1.5px solid var(--border-color);
    border-radius: 8px;
    font-family: var(--font-ui);
    font-size: 1rem;
    background-color: var(--surface-color);
    color: var(--text-color);
    width: 220px;
    transition: all 0.3s;
    box-shadow: 0 2px 8px rgba(0,0,0,0.02);
}

.header-input-small {
    width: 160px;
}

.header-input:focus {
    outline: none;
    border-color: var(--accent-color);
    box-shadow: 0 0 0 3px rgba(192, 124, 65, 0.1);
}

/* Elegant Main Title - Clean Centering */
.main-title {
    display: block;
    width: 100%;
    text-align: center;
    margin: 0;
    pointer-events: auto;
}

.title-tsm {
    font-family: var(--font-heading), serif;
    font-size: 2.8rem;
    color: var(--primary-color);
    font-weight: 600;
    letter-spacing: 8px;
    margin-right: -8px; /* Mathematically cancels the tracking on the last letter */
    padding: 0;
    text-shadow: 1px 1px 2px rgba(0,0,0,0.05);
    display: block;
}

.title-sinavi {
    font-family: var(--font-ui), sans-serif;
    font-size: 1.1rem;
    color: var(--accent-color); 
    font-weight: 600;
    letter-spacing: 16px;
    margin-right: -16px; /* Mathematically cancels the tracking on the last letter */
    padding: 0;
    text-transform: uppercase;
    margin-top: 2px;
    display: block;
}

/* Mobile Responsiveness for Header */
@media (max-width: 768px) {
    .main-header {
        display: flex;
        flex-direction: column;
        gap: 15px;
        padding: 15px 10px;
        min-height: auto; /* Reset for mobile */
    }
    .header-center {
        position: static;
        transform: none;
        order: -1;
        width: auto;
    }
    .header-left, .header-right {
        width: 100%;
    }
    .header-left {
        flex-direction: column;
    }
    .header-input, .header-input-small {
        width: 100%;
    }
    .btn-submit {
        width: 100%;
        margin-top: 5px;
        padding: 15px;
        font-size: 1.1rem;
    }
    .title-tsm {
        font-size: 2.4rem;
        letter-spacing: 6px;
        margin-right: -6px;
        text-indent: 0;
        transform: none;
    }
    .title-sinavi {
        font-size: 0.95rem;
        letter-spacing: 12px;
        margin-right: -12px;
        text-indent: 0;
        transform: none;
    }
}

/* Local Toolbar (Inside Question Card) */
.local-toolbar {
    background-color: transparent;
    padding: 0 0 15px 0;
    margin-bottom: 10px;
    border-bottom: 1px solid var(--border-color);
}



.btn {
    min-height: 44px; /* Mobile touch target size */
    min-width: 44px;
    padding: 10px 15px;
    border: none;
    border-radius: 12px;
    font-size: 0.95rem;
    font-family: var(--font-ui);
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
}

.btn:active {
    transform: scale(0.96);
}

.btn-lock {
    display: flex;
    align-items: center;
    gap: 5px;
    color: white;
}

.btn-lock.locked {
    background-color: var(--lock-color);
}

.btn-lock.unlocked {
    background-color: var(--unlock-color);
}

.tools-container {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    align-items: center;
    background-color: #f5f1ea;
    padding: 15px;
    border-radius: 12px;
    box-shadow: inset 0 2px 4px rgba(0,0,0,0.02);
}

.tools-container.hidden {
    display: none;
}

.tool-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.tool-group label {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--primary-color);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.tool-select {
    min-height: 44px;
    padding: 8px 12px;
    border-radius: 8px;
    border: 1px solid var(--border-color);
    font-size: 0.95rem;
    font-family: var(--font-ui);
    background-color: white;
    color: var(--text-color);
    transition: border-color 0.3s;
}

.tool-select:focus {
    border-color: var(--accent-color);
    outline: none;
}

.action-buttons {
    flex-direction: row;
    flex-wrap: wrap;
    align-items: flex-end;
}

.tool-btn {
    background-color: var(--surface-color);
    color: var(--primary-color);
    border: 1px solid var(--border-color);
    font-size: 0.9rem;
    padding: 10px 14px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.02);
}

.tool-btn:hover {
    background-color: #fcfcfc;
}

.tool-btn.active {
    background-color: var(--accent-color);
    color: white;
    border-color: var(--accent-color);
    box-shadow: 0 4px 10px rgba(192, 124, 65, 0.3);
}

.eraser {
    color: #A05252;
    border-color: #eed1d1;
}
.eraser.active {
    background-color: #A05252;
    border-color: #A05252;
    color: white;
}

/* Tabs */
.makam-tabs {
    background-color: var(--primary-color);
    overflow-x: auto; /* Horizontally scrollable */
    -webkit-overflow-scrolling: touch;
    position: relative;
    z-index: 900;
}

.makam-tabs ul {
    list-style: none;
    display: flex;
    padding: 0;
    margin: 0;
    min-width: max-content; /* Ensure tabs don't wrap */
}

.makam-tabs li {
    flex: 1;
}

.makam-tabs button {
    width: 100%;
    background: none;
    border: none;
    color: rgba(255, 255, 255, 0.6);
    padding: 16px 24px;
    font-size: 1.05rem;
    font-family: var(--font-heading);
    font-weight: 600;
    cursor: pointer;
    border-bottom: 4px solid transparent;
    transition: all 0.3s;
    min-height: 54px;
    letter-spacing: 0.5px;
}

.makam-tabs button:hover {
    color: rgba(255, 255, 255, 0.8);
}

.makam-tabs button.active {
    color: white;
    border-bottom: 4px solid var(--accent-color);
    background-color: rgba(255, 255, 255, 0.05);
}

/* Content Area */
#app-content {
    padding: 15px;
    max-width: 800px;
    margin: 0 auto;
}

.makam-section {
    display: none;
    animation: fadeIn 0.3s ease;
}

.makam-section.active {
    display: block;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(5px); }
    to { opacity: 1; transform: translateY(0); }
}

.question-card {
    background-color: var(--surface-color);
    border-radius: 16px;
    padding: 24px;
    margin-bottom: 24px;
    box-shadow: 0 4px 20px rgba(74, 59, 50, 0.06);
    border: 1px solid rgba(0,0,0,0.02);
}

.question-card h3 {
    margin-bottom: 16px;
    font-size: 1.25rem;
    color: var(--primary-color);
    line-height: 1.5;
}

/* Inputs */
.input-text, .input-textarea {
    width: 100%;
    min-height: 48px;
    padding: 12px 16px;
    border: 1.5px solid var(--border-color);
    border-radius: 8px;
    font-size: 1rem;
    font-family: inherit;
    background-color: #faf9f7;
    transition: all 0.3s;
    color: var(--text-color);
}

.input-text:focus, .input-textarea:focus {
    outline: none;
    border-color: var(--accent-color);
    background-color: white;
    box-shadow: 0 0 0 3px rgba(192, 124, 65, 0.1);
}

.input-textarea {
    resize: vertical;
    min-height: 80px;
}

/* Canvas Containers */
.canvas-container {
    width: 100%;
    overflow: hidden !important; /* NO MORE SCROLLING */
    touch-action: none;
    border: 1.5px solid var(--border-color);
    border-radius: 12px;
    background-color: #fdfdfc;
}

.canvas-container.unlocked {
    touch-action: none; /* Prevent scroll over canvas when unlocked */
    border-color: var(--unlock-color);
}

canvas {
    display: block;
    width: 100% !important; /* Scale like an image */
    height: auto !important; /* Maintain aspect ratio */
    max-width: 100%;
    cursor: crosshair;
}

.canvas-wide {
    min-width: 0 !important; /* Kill the 800px min-width */
}

/* Header Submit Button */
.btn-submit {
    background-color: var(--lock-color);
    color: white;
    font-size: 1.05rem;
    padding: 12px 24px;
    border-radius: 8px;
    box-shadow: 0 4px 15px rgba(160, 82, 82, 0.3);
    transition: all 0.3s ease;
    font-family: var(--font-heading);
    letter-spacing: 0.5px;
    border: none;
    cursor: pointer;
    font-weight: 600;
}

.btn-submit:hover {
    background-color: #8b4545;
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(160, 82, 82, 0.5);
}

/* Subtle Stopwatch */
.exam-timer {
    font-family: var(--font-ui), sans-serif;
    font-size: 0.85rem;
    font-weight: 400;
    color: #95a5a6; /* Subdued, non-threatening gray */
    margin-top: 8px;
    letter-spacing: 0.5px;
    display: inline-block;
}

