body, html {
    margin: 0;
    padding: 0;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    height: 100%;
    background-color: #f5f5f5;
}

.container {
    display: flex;
    flex-direction: column;
    max-width: 600px;
    margin: 0 auto;
    height: 100vh;
    background-color: white;
    box-shadow: 0 0 10px rgba(0,0,0,0.1);
    position: relative;
}

.content {
    flex: 1;
    padding: 80px 20px 20px 20px;
    overflow-y: auto;
    overflow-x: hidden;
}

.tab {
    display: none;
}

.tab.active {
    display: block;
}

.date-navigator {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0;
    background-color: #f0f0f0;
    padding: 10px;
    border-radius: 0 0 5px 5px;
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    z-index: 20;
    box-sizing: border-box;
    min-height: 60px; /* Ensure consistent height even when buttons are hidden */
}

.left-nav, .center-nav, .right-nav {
    display: flex;
    align-items: center;
    gap: 10px;
}

.nav-btn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: none;
    background-color: #ddd;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    color: #333;
    padding: 0;
    box-sizing: border-box;
}

.nav-btn svg {
    width: 30px;
    height: 30px;
}

.nav-btn.mantra-btn svg {
    width: 34px;
    height: 34px;
}

.nav-btn:hover {
    background-color: #bbb;
}

.nav-btn.confirm {
    background-color: #42f5b6 !important;
    color: #333 !important;
}

.nav-btn.confirm:hover {
    background-color: #4ffecc !important;
}

.nav-btn.cancel {
    background-color: #f44336;
    color: white;
}

.nav-btn.cancel:hover {
    background-color: #d32f2f;
}

#selected-date {
    font-weight: bold;
    font-size: 16px;
}

h1 {
    color: #333;
    text-align: center;
    margin-bottom: 20px;
}

form {
    margin-bottom: 20px;
}

.question {
    margin-bottom: 15px;
    position: relative;
}

.question label {
    display: inline-block;
    margin-right: 10px;
}

.question .value-display {
    font-weight: bold;
    color: #333;
    position: absolute;
    right: 0;
    top: 0;
}

.choice-options {
    width: 100%;
    margin-top: 10px;
}

.choice-options .choice-option {
    display: inline-block;
    padding: 5px 10px;
    border: 1px solid #ddd;
    border-radius: 4px;
    margin-right: 5px;
    margin-bottom: 5px;
    cursor: pointer;
}

.choice-options .choice-option.selected {
    background-color: #42f5b6;
    color: #333;
    border-color: #4CAF50;
}

.closest-answer {
    text-align: center;
    width: 100%;
    font-style: italic;
    color: #666;
    margin-top: 5px;
}

input[type="checkbox"] {
    margin-right: 10px;
}

label {
    display: block;
    margin-bottom: 5px;
    font-weight: bold;
}

input[type="range"] {
    width: 100%;
    margin-bottom: 5px;
}

input[type="text"] {
    width: calc(100% - 22px); /* Account for borders and padding */
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 16px;
    box-sizing: border-box;
}

button {
    background-color: #42f5b6;
    color: #333;
    padding: 10px 15px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 16px;
    margin-right: 10px;
}

button:hover {
    background-color: #4ffecc;
}

ul {
    list-style-type: none;
    padding: 0;
}

li {
    background-color: #f9f9f9;
    margin-bottom: 5px;
    padding: 10px;
    border-radius: 4px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.tab-switcher {
    display: flex;
    background-color: #fff;
    border-top: 1px solid #ddd;
}

.settings-mode {
    height: 100vh;
    background-color: #f5f5f5;
}

.settings-nav {
    display: flex;
    background-color: #fff;
    border-top: 1px solid #ddd;
    justify-content: center;
    padding: 15px;
}

/* Mantra popup */
.mantra-popup {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.7);
    z-index: 1000;
    overflow: auto;
}

.mantra-popup-content {
    background-color: white;
    margin: 5% auto;
    padding: 20px;
    border-radius: 8px;
    width: 80%;
    max-width: 600px;
    position: relative;
}

.mantra-popup-close {
    position: absolute;
    top: 10px;
    right: 20px;
    font-size: 30px;
    font-weight: bold;
    cursor: pointer;
    color: #aaa;
}

.mantra-popup-close:hover {
    color: #000;
}

/* Mantra content styling */
#mantra-content {
    line-height: 1.4;
}

#mantra-content ul, #mantra-content ol {
    padding-left: 20px;
    margin: 0;
}

#mantra-content li {
    margin-bottom: 5px;
}

/* Read mantra button */
.read-mantra-btn {
    width: 100%;
    height: 64px;
    background-color: #ff9800;
    color: #333;
    padding: 15px;
    border: none;
    font-size: 16px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-sizing: border-box;
}

.read-mantra-btn:hover {
    background-color: #e68900;
}

.read-mantra-btn.read {
    background-color: #42f5b6;
    color: #333;
}

.read-mantra-btn.read:hover {
    background-color: #4ffecc;
}

.tab-button {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    flex: 1;
    padding: 10px 5px;
    background-color: #eee;
    border: none;
    border-radius: 10px;
    margin: 5px;
    cursor: pointer;
    font-size: 12px;
    color: #666;
    transition: all 0.3s ease;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
}

.tab-button.active {
    background-color: #42f5b6;
    color: #333;
    box-shadow: 0 4px 12px rgba(66, 245, 182, 0.3);
}

.tab-button:hover:not(.active) {
    background-color: #f5f5f5;
}

.tab-button svg {
    width: 24px;
    height: 24px;
    margin-bottom: 4px;
}

/* Mobile specific styles */
@media (max-width: 768px) {
    .container {
        max-width: 100%;
        box-shadow: none;
        padding-bottom: 60px; /* make room for fixed tab-switcher */
    }

    .content {
        padding: 70px 15px 15px 15px;
    }

    .tab-switcher {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        width: 100%;
        padding-bottom: env(safe-area-inset-bottom);
        z-index: 10;
    }

    .toast {
        bottom: 80px; /* Position above the fixed tab-switcher */
    }
}

@media (min-width: 769px) {
    .container {
        height: 80vh;
        margin-top: 20px;
    }
}

/* Auth overlay */
.auth-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.7);
    z-index: 1000;
}

.auth-modal {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background-color: white;
    padding: 30px;
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
    min-width: 300px;
    text-align: center;
}

.auth-modal h2 {
    margin-top: 0;
}

.auth-modal form {
    display: flex;
    flex-direction: column;
    margin-bottom: 20px;
}

.auth-modal input {
    padding: 10px;
    margin-bottom: 15px;
    border: 1px solid #ddd;
    border-radius: 4px;
}

.auth-modal button {
    padding: 10px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
}

#auth-submit {
    background-color: #42f5b6;
    color: #333;
    margin-bottom: 10px;
}

#auth-submit:hover {
    background-color: #4ffecc;
}

#auth-toggle {
    background: none;
    border: none;
    color: #007bff;
    text-decoration: underline;
    cursor: pointer;
}

.auth-close {
    position: absolute;
    top: 10px;
    right: 15px;
    font-size: 24px;
    background: none;
    border: none;
    cursor: pointer;
    color: #aaa;
}

.auth-close:hover {
    color: #000;
}

/* Toast notification */
.toast {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    background-color: rgba(0, 0, 0, 0.8);
    color: white;
    padding: 12px 16px;
    border-radius: 25px;
    font-size: 14px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    z-index: 1001;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.toast.show {
    opacity: 1;
    visibility: visible;
}

/* Invalid input highlighting */
.invalid {
    border: 2px solid red !important;
    background-color: #ffe6e6;
}

/* TODO List Styling */
.todo-container {
    position: relative;
    min-height: 200px;
}

.todo-items {
    /* Container for todo items */
}

.todo-item {
    position: relative;
    display: flex;
    align-items: center;
    padding: 0;
    margin-bottom: 10px;
    background-color: #fafafa;
    border-radius: 12px;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
    transition: transform 0.2s ease;
    cursor: pointer;
    min-height: 56px;
    z-index: 1;
}

/* Goal-linked todo items - distinct border color */
.todo-item.goal-todo-item {
    border: 2px solid #9c27b0; /* Purple border to distinguish goal-linked todos */
    box-shadow: 0 2px 8px rgba(156, 39, 176, 0.2);
}

.todo-item.goal-todo-item:hover {
    box-shadow: 0 4px 12px rgba(156, 39, 176, 0.3);
}

.todo-item:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.15);
}

.todo-item.dragging {
    cursor: grabbing;
    z-index: 100;
}

/* Background fill that shows progress */
.todo-fill {
    position: absolute;
    top: 0;
    left: 0;
    height: 100%;
    background: linear-gradient(to right, #42f5b6, #4ffecc);
    border-radius: 12px 0 0 12px;
    transition: width 0.1s ease;
    z-index: 0;
    overflow: hidden;
}

.todo-fill[style*="100%"] {
    border-radius: 12px;
}

/* Content layer above the fill */
.todo-content {
    position: relative;
    z-index: 1;
    display: flex;
    align-items: center;
    width: 100%;
    padding: 15px 20px;
    box-sizing: border-box;
}

.task-text {
    flex: 1;
    font-size: 16px;
    line-height: 1.4;
    user-select: none;
    padding: 4px 8px;
    border-radius: 4px;
    transition: background-color 0.2s ease, box-shadow 0.2s ease;
    overflow-wrap: break-word;
    word-break: break-word;
    min-width: 0;
}

.task-text.complete {
    text-decoration: line-through;
    color: #888;
}

.task-text.editing {
    background-color: white;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    border: 1px solid #ddd;
    user-select: text;
    cursor: text;
}

.task-text.editing:focus {
    outline: none;
    border-color: #42f5b6;
    box-shadow: 0 0 0 2px rgba(66, 245, 182, 0.3);
}

.delete-btn {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    border: none;
    background-color: #f44336;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    margin-left: 10px;
    transition: all 0.3s ease;
    padding: 0;
    position: relative;
    z-index: 2;
    flex-shrink: 0;
}

.delete-btn:hover {
    background-color: #d32f2f;
    transform: scale(1.1);
}

/* Weight input wrapper */
.weight-input-wrapper {
    position: relative;
    display: inline-block;
}

/* Global fixed weight tooltip - renders above everything */
.weight-tooltip-global {
    position: fixed;
    transform: translateX(-50%);
    background-color: rgba(0, 0, 0, 0.8);
    color: white;
    padding: 8px 12px;
    border-radius: 20px;
    white-space: nowrap;
    font-size: 12px;
    font-weight: bold;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
    pointer-events: none;
    z-index: 20000;
    text-align: center;
}

.weight-tooltip-global.visible {
    opacity: 1;
    visibility: visible;
}

.weight-tooltip-global::after {
    content: '';
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    border: 6px solid transparent;
    border-bottom-color: rgba(0, 0, 0, 0.8);
}

/* Todo weight input styling */
.todo-weight-input {
    width: 50px;
    height: 32px;
    border: 2px solid #42f5b6;
    border-radius: 8px;
    background-color: white;
    color: #333;
    font-size: 14px;
    font-weight: 600;
    text-align: center;
    margin-left: 0;
    padding: 0 4px;
    outline: none;
    transition: all 0.2s ease;
    flex-shrink: 0;
    -moz-appearance: textfield;
}

.todo-weight-input::-webkit-outer-spin-button,
.todo-weight-input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.todo-weight-input:focus {
    border-color: #2ecc71;
    box-shadow: 0 0 0 3px rgba(66, 245, 182, 0.3);
}

.todo-weight-input:hover {
    border-color: #2ecc71;
}

/* Progress tooltip - appears below the colored section during drag */
.progress-tooltip {
    position: absolute;
    top: calc(100% + 5px);
    transform: translateX(-50%);
    background-color: rgba(0, 0, 0, 0.8);
    color: white;
    padding: 6px 10px;
    border-radius: 15px;
    white-space: nowrap;
    font-size: 12px;
    font-weight: bold;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.15s ease, visibility 0.15s ease;
    pointer-events: none;
    z-index: 1000; /* Still within the todo-item's stacking context */
    text-align: center;
}

.progress-tooltip.visible {
    opacity: 1;
    visibility: visible;
}

.progress-tooltip::after {
    content: '';
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    border: 5px solid transparent;
    border-bottom-color: rgba(0, 0, 0, 0.8);
}

.add-btn {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    border: none;
    background-color: #42f5b6;
    color: #333;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    margin-left: 15px;
    transition: all 0.3s ease;
    padding: 0;
}

.add-btn:hover {
    background-color: #4ffecc;
    transform: scale(1.1);
}

.done-items {
    margin-top: 20px;
}

.done-items .todo-item {
    opacity: 0.8;
}

.add-item {
    display: flex;
    align-items: center;
    padding: 15px 20px;
    margin-bottom: 10px;
    background-color: transparent;
    border-radius: 12px;
    box-shadow: none;
    transition: none;
    min-height: 56px;
    box-sizing: border-box;
}

.add-item:hover {
    transform: none;
    box-shadow: none;
}

.moving {
    opacity: 0.7;
    transform: scale(0.95);
    transition: all 0.3s ease;
}

/* Stats sections styling */
.stats-sections {
    display: flex;
    flex-direction: column;
    gap: 20px;
    margin-top: 20px;
}

.stats-section {
    background-color: #fafafa;
    border-radius: 12px;
    padding: 15px;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
}

.stats-section h3 {
    margin-top: 0;
    margin-bottom: 15px;
    color: #333;
    font-size: 18px;
}

.badges-container {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.badge-container {
    position: relative;
    display: inline-block;
}

.badge {
    max-width: 60px;
    max-height: 60px;
    box-shadow: none;
    transition: transform 0.2s ease;
}

.badge:hover {
    transform: scale(1.1);
}

.badge-tooltip {
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    background-color: rgba(0, 0, 0, 0.8);
    color: white;
    padding: 8px 12px;
    border-radius: 20px;
    white-space: nowrap;
    font-size: 14px;
    font-weight: bold;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
    pointer-events: none;
    z-index: 100;
    margin-top: 5px;
    text-align: center;
}

.badge-tooltip::after {
    content: '';
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    border: 6px solid transparent;
    border-bottom-color: rgba(0, 0, 0, 0.8);
}

.badge-container:hover .badge-tooltip {
    opacity: 1;
    visibility: visible;
}

.goals-container {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.goal-item {
    background: linear-gradient(to bottom, #fff 0%, #f0f0f0 100%);
    padding: 20px;
    border: 1px solid #555;
    border-radius: 12px;
    box-shadow: 0 6px 12px rgba(0, 0, 0, 0.3), inset 0 1px 0 rgba(255, 255, 255, 0.8);
    transition: all 0.2s ease;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.new-goal-item {
    background: #f9f9f9;
    opacity: 0.5;
    padding: 10px;
    border: 1px solid #999;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    height: 50px;
}

.goal-item:hover {
    background: linear-gradient(to bottom, #f8f8f8 0%, #e8e8e8 100%);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.3), inset 0 1px 0 rgba(255, 255, 255, 0.8);
    transform: translateY(-2px);
}

.goal-badge {
    background: transparent;
    opacity: 0.8;
    box-shadow: none;
}

.goal-badge.incomplete {
    filter: grayscale(100%) opacity(0.5);
}

.goal-item.completed {
    opacity: 0.6;
}

.goal-item.claimable {
    opacity: 1;
}

.goal-title {
    font-size: 16px;
    font-weight: bold;
    color: #333;
}

.goal-description {
    font-size: 14px;
    color: #777;
    line-height: 1.3;
}

.progress-bar {
    width: calc(100% - 10px);
    height: 8px;
    background-color: #e0e0e0;
    border-radius: 4px;
    overflow: hidden;
    align-self: center;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(to right, #42f5b6, #4ffecc);
    border-radius: 4px;
    width: 70%; /* Dummy progress */
    transition: width 0.4s ease;
}

.goal-edit-btn {
    position: absolute;
    top: 10px;
    right: 10px;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    border: 1px solid #555;
    background-color: #ddd;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    padding: 0;
}

.goal-edit-btn:hover {
    background-color: #f5f5f5;
    border-color: #bbb;
    transform: scale(1.1);
}

.goal-item {
    position: relative; /* Add this to allow absolute positioning of edit button */
}

.goal-item.claimable {
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background: #42f5b6;
    gap: 20px;
    cursor: pointer;
}

.claim-badge {
    cursor: pointer;
    transition: transform 0.2s ease;
}

.claim-badge:hover {
    transform: scale(1.1);
}

.claim-text {
    cursor: pointer;
    font-size: 24px;
    font-weight: bold;
    color: #666;
}

.claim-text:hover {
    color: #555;
}

.claim-subtext {
    cursor: pointer;
    font-size: 14px;
    color: #888;
    margin-top: 5px;
}

.claim-subtext:hover {
    color: #777;
}

.flying-badge {
    box-shadow: 0 0 20px rgba(66, 245, 182, 0.8);
    transform-origin: center;
}

/* Badge claim animation - now handled via JS */

.goal-type-toggle {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 20px;
    background-color: #f0f0f0;
    border: 2px solid #ddd;
    border-radius: 20px;
    width: 200px;
    height: 34px;
    overflow: hidden;
    transition: border-color 0.4s ease;
}

.goal-type-toggle.has-selection {
    border-color: #000;
}

.toggle-option {
    position: relative;
    z-index: 2;
    flex: 1;
    text-align: center;
    font-size: 12px;
    font-weight: bold;
    color: #666;
    padding: 10px 4px;
    transition: color 0.4s ease, background-color 0.4s ease;
    cursor: pointer;
    border-radius: 15px;
}

.toggle-option.selected {
    color: #000;
    background: linear-gradient(135deg, #42f5b6, #4ffecc);
    box-shadow: 0 2px 10px rgba(66, 245, 182, 0.4);
}

/* Hide the slider background since we use selected class now */
.toggle-slider-bg {
    display: none;
}

input[type="checkbox"] {
    display: none;
}

/* Exception for survey binary question checkboxes */
input[type="checkbox"][id^="q-"] {
    display: inline-block !important;
    width: 18px !important;
    height: 18px !important;
    cursor: pointer;
}

/* Exception for sequential checkbox in goal edit popup */
#edit-goal-sequential {
    display: inline-block !important;
    width: 18px !important;
    height: 18px !important;
    cursor: pointer;
}



/* Stats chart styling */
.chart-container {
    position: relative;
    height: 300px;
    width: 100%;
    max-width: 600px;
    margin: 0 auto;
}

#stats-chart {
    width: 100% !important;
    height: 100% !important;
}

/* Goal target fields */
#goal-target-fields #sum-fields,
#goal-target-fields #streak-fields {
    display: none;
    margin-top: 10px;
}

#goal-target-fields .field-row {
    display: flex;
    align-items: center;
    gap: 15px;
    margin-bottom: 8px;
}

#goal-target-fields label {
    flex-shrink: 0;
    font-weight: bold;
    color: #333;
    white-space: nowrap;
    font-size: 14px;
}

#goal-target-fields input[type="number"] {
    flex: 1;
    padding: 8px 12px;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 14px;
    box-sizing: border-box;
    min-width: 0;
    background-color: #fafafa;
}

#goal-target-fields input[type="number"]:focus {
    outline: none;
    border-color: #42f5b6;
    box-shadow: 0 0 0 2px rgba(66, 245, 182, 0.2);
}
