:root {
    --primary-font: 'Lato', sans-serif;
    --heading-font: 'Montserrat', sans-serif;
    --bls-animation-duration: 4s;
    --transition-speed: 0.3s;
    --bls-color: #27ab83;
}

[data-theme="light"] {
    --background-color: #f0f4f8;
    --card-background: #ffffff;
    --text-color: #334e68;
    --heading-color: #0d1f2d;
    --primary-color: #27ab83;
    --primary-hover: #229571;
    --secondary-color: #8c5e58;
    --accent-color: #f2b705;
    --border-color: #dbe2ea;
    --shadow-color: rgba(13, 31, 45, 0.1);
    --feather-svg: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='%238c5e58'%3E%3Cpath d='M20.316 3.69c-.933-1.03-3.69-1.33-5.32-.3-1.63 1.03-2.23 2.89-2.23 2.89s-2.31-3.23-4.94-3.53c-2.63-.3-5.18 1.43-5.18 4.29 0 2.86 2.47 5.16 5.37 5.16.2 0 .4-.02.6-.05 2.18-.33 3.9-2.03 3.9-2.03s2.15 3.02 5.02 3.52c2.87.5 4.7-1.39 4.7-3.79s-2.13-4.14-5.33-6.16z'/%3E%3C/svg%3E");
    --bls-color: #27ab83;
}

[data-theme="dark"] {
    --background-color: #102a43;
    --card-background: #1f3b55;
    --text-color: #bcccdc;
    --heading-color: #f0f4f8;
    --primary-color: #2dd4bf;
    --primary-hover: #27bca8;
    --secondary-color: #f7b3a0;
    --accent-color: #f2b705;
    --border-color: #334e68;
    --shadow-color: rgba(0, 0, 0, 0.2);
    --feather-svg: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='%23f7b3a0'%3E%3Cpath d='M20.316 3.69c-.933-1.03-3.69-1.33-5.32-.3-1.63 1.03-2.23 2.89-2.23 2.89s-2.31-3.23-4.94-3.53c-2.63-.3-5.18 1.43-5.18 4.29 0 2.86 2.47 5.16 5.37 5.16.2 0 .4-.02.6-.05 2.18-.33 3.9-2.03 3.9-2.03s2.15 3.02 5.02 3.52c2.87.5 4.7-1.39 4.7-3.79s-2.13-4.14-5.33-6.16z'/%3E%3C/svg%3E");
    --bls-color: #2dd4bf;
}

*,
*::before,
*::after {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: var(--primary-font);
    background-color: var(--background-color);
    color: var(--text-color);
    line-height: 1.7;
    transition: background-color var(--transition-speed), color var(--transition-speed);
}

header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 2rem 5%;
    background-color: var(--card-background);
    border-bottom: 1px solid var(--border-color);
    transition: background-color var(--transition-speed), border-color var(--transition-speed);
}
.header-content { text-align: left; }
h1 {
    font-family: var(--heading-font);
    color: var(--heading-color);
    font-size: 2rem;
    margin: 0;
}
.subtitle {
    font-size: 1.1rem;
    color: var(--text-color);
    margin: 0.25rem 0 0;
}

main {
    max-width: 800px;
    margin: 0 auto;
    padding: 1rem;
}

h2 {
    font-family: var(--heading-font);
    color: var(--heading-color);
    border-bottom: 2px solid var(--primary-color);
    padding-bottom: 0.5rem;
    margin: 0 0 1.5rem 0;
    display: flex;
    align-items: center;
    gap: 0.75rem;
}
.step-icon { font-size: 1.5rem; }

/* Theme switcher and Generic Toggle */
.theme-switcher { display: flex; align-items: center; gap: 0.5rem; }
.theme-label { font-size: 0.9rem; font-weight: bold; }
.toggle-switch {
    background-color: var(--border-color);
    border: none;
    width: 50px;
    height: 26px;
    border-radius: 13px;
    cursor: pointer;
    position: relative;
    transition: background-color var(--transition-speed);
    flex-shrink: 0; /* Prevents shrinking in flex containers */
}
.toggle-thumb {
    position: absolute;
    top: 3px;
    left: 4px;
    width: 20px;
    height: 20px;
    background-color: white;
    border-radius: 50%;
    transition: transform var(--transition-speed) ease;
}
.toggle-switch[aria-checked="true"] { background-color: var(--primary-color); }
.toggle-switch[aria-checked="true"] .toggle-thumb { transform: translateX(23px); }

/* Progress Stepper */
.progress-stepper {
    display: flex;
    justify-content: space-between;
    margin: 2rem 0;
    position: relative;
}
.progress-stepper::before {
    content: '';
    position: absolute;
    top: 15px;
    left: 10%;
    right: 10%;
    height: 2px;
    background-color: var(--border-color);
    z-index: -1;
}
.step { text-align: center; }
.step-number {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background-color: var(--border-color);
    color: var(--text-color);
    display: inline-flex;
    justify-content: center;
    align-items: center;
    font-weight: bold;
    transition: all var(--transition-speed);
    border: 2px solid var(--border-color);
}
.step-label { font-size: 0.85rem; margin-top: 0.5rem; font-weight: bold; }
.step.active .step-number {
    background-color: var(--card-background);
    border-color: var(--primary-color);
    color: var(--primary-color);
}
.step.complete .step-number {
    background-color: var(--primary-color);
    border-color: var(--primary-color);
    color: var(--card-background);
}

/* Tool Styles */
#emdr-tool {
    background-color: var(--card-background);
    border-radius: 12px;
    padding: 2rem;
    margin-bottom: 2rem;
    box-shadow: 0 8px 24px var(--shadow-color);
    border: 1px solid var(--border-color);
    transition: all var(--transition-speed);
}
.step-container { animation: fadeIn 0.5s ease-in-out; }
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}
.hidden { display: none; }

/* Explanation box for steps */
.step-explanation {
    margin: 1.5rem 0;
    padding: 1rem 1.5rem;
    background-color: var(--background-color);
    border-left: 4px solid var(--accent-color);
    border-radius: 8px;
}
.step-explanation p { margin: 0.5rem 0; }
.step-explanation p:first-child { margin-top: 0; }
.step-explanation p:last-child { margin-bottom: 0; }


/* Form Elements */
.form-group { margin-bottom: 1.5rem; }
.form-group label { display: block; font-weight: 700; margin-bottom: 0.5rem; }
.form-group input[type="text"], .form-group textarea {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    font-family: var(--primary-font);
    font-size: 1rem;
    background-color: var(--background-color);
    color: var(--text-color);
    transition: all var(--transition-speed);
}
.form-group input[type="text"]:focus, .form-group textarea:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary-color) 20%, transparent);
}

/* Sliders */
.slider-container { display: flex; align-items: center; gap: 1rem; }
.slider-container input[type="range"] {
    flex-grow: 1;
    -webkit-appearance: none;
    appearance: none;
    height: 8px;
    background: var(--border-color);
    border-radius: 5px;
    outline: none;
}
.slider-container input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none; appearance: none;
    width: 20px; height: 20px;
    background: var(--primary-color);
    border-radius: 50%; cursor: pointer;
}
.slider-container input[type="range"]::-moz-range-thumb {
    width: 20px; height: 20px;
    background: var(--primary-color);
    border-radius: 50%; cursor: pointer;
}
.slider-label { color: var(--text-color); }
.slider-value { font-weight: bold; color: var(--primary-color); min-width: 20px; text-align: center; }

/* Buttons */
.button-primary, .button-secondary, .button-resource {
    display: inline-block; padding: 0.8rem 1.6rem;
    font-family: var(--heading-font); font-size: 1rem;
    border: 2px solid transparent; border-radius: 8px;
    cursor: pointer; text-align: center; text-decoration: none;
    transition: all 0.2s ease-in-out;
}
.button-primary { color: white; background-color: var(--primary-color); }
.button-primary:hover { background-color: var(--primary-hover); transform: translateY(-2px); }
.button-primary:active { transform: translateY(0); }
.button-secondary { color: var(--primary-color); background-color: transparent; border-color: var(--primary-color); }
.button-secondary:hover { background-color: color-mix(in srgb, var(--primary-color) 10%, transparent); transform: translateY(-2px); }
.button-resource {
    color: var(--heading-color);
    background-color: transparent;
    border-color: var(--accent-color);
}
.button-resource:hover {
    background-color: color-mix(in srgb, var(--accent-color) 20%, transparent);
    color: var(--heading-color);
    transform: translateY(-2px);
}

/* Disclaimer */
.disclaimer.warning {
    color: var(--secondary-color);
    margin: 1.5rem 0; padding: 1rem;
    background-color: color-mix(in srgb, var(--secondary-color) 15%, transparent);
    border: 1px solid color-mix(in srgb, var(--secondary-color) 30%, transparent);
    border-left: 5px solid var(--secondary-color);
    border-radius: 8px;
}

/* Developer Info Block */
.developer-info {
    margin: 2rem 0;
    padding: 1rem 1.5rem;
    background-color: var(--background-color);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    text-align: center;
}
.developer-info h3 {
    margin: 0 0 0.5rem 0;
    font-family: var(--heading-font);
    color: var(--heading-color);
}
.developer-info p {
    margin: 0.25rem 0;
    font-size: 1rem;
}
.developer-info a {
    color: var(--primary-color);
    text-decoration: none;
    font-weight: bold;
}
.developer-info a:hover {
    text-decoration: underline;
}


/* Simulation and Controls */
.focus-box {
    background: var(--background-color);
    border-left: 4px solid var(--primary-color);
    padding: 1rem 1.5rem; margin: 1.5rem 0; border-radius: 8px;
}
.focus-box p { margin: 0.5rem 0; }

.simulation-container {
    width: 100%; height: 80px;
    background-color: var(--background-color);
    border-radius: 8px; margin: 1.5rem 0;
    position: relative; overflow: hidden;
    border: 1px solid var(--border-color);
}
.bls-visual {
    position: absolute; top: 50%;
    transform: translateY(-50%);
    left: 20px;
}
.bls-visual.animate.bls-orb { animation: moveAndPulse var(--bls-animation-duration) ease-in-out infinite alternate; }
.bls-visual.animate.bls-feather { animation: moveAndFloat var(--bls-animation-duration) ease-in-out infinite alternate; }
.bls-visual.animate.bls-dot { animation: moveSimple var(--bls-animation-duration) linear infinite alternate; }
.bls-visual.animate.bls-tactile::before { animation: showLeft var(--bls-animation-duration) ease-in-out infinite alternate; }
.bls-visual.animate.bls-tactile::after { animation: showRight var(--bls-animation-duration) ease-in-out infinite alternate; }

/* Animation Styles */
.bls-orb {
    width: 30px; height: 30px;
    background: var(--bls-color);
    border-radius: 50%;
    box-shadow: 0 0 15px var(--bls-color), 0 0 25px var(--bls-color);
}
.bls-feather {
    width: 40px; height: 40px;
    background-color: var(--bls-color);
    -webkit-mask-image: var(--feather-svg);
    mask-image: var(--feather-svg);
}
.bls-dot {
    width: 25px; height: 25px;
    background: var(--bls-color);
    border-radius: 50%;
}
.bls-tactile {
    width: 100%;
    height: 100%;
    left: 0;
    top: 0;
    transform: none;
    
    /* Flexbox layout */
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 20px;

    /* Text styles */
    font-family: var(--heading-font);
    font-size: 1.5rem;
    font-weight: bold;
    color: var(--bls-color);
}

.bls-tactile::before, .bls-tactile::after {
    /* Reset from any potential cascaded styles */
    position: static;
    transform: none;
    top: auto;

    /* Set content and initial state */
    opacity: 0;
}

.bls-tactile::before { content: 'Tap Left'; }
.bls-tactile::after { content: 'Tap Right'; }


/* Keyframes */
@keyframes moveAndPulse {
    from { left: 20px; transform: translateY(-50%) scale(0.8); }
    50% { transform: translateY(-50%) scale(1.2); }
    to { left: calc(100% - 50px); transform: translateY(-50%) scale(0.8); }
}
@keyframes moveAndFloat {
    from { left: 20px; transform: translateY(-50%) rotate(-10deg); }
    50% { transform: translateY(-60%) rotate(0deg); }
    to { left: calc(100% - 60px); transform: translateY(-50%) rotate(10deg); }
}
@keyframes moveSimple {
    from { left: 20px; }
    to { left: calc(100% - 45px); }
}
@keyframes showLeft {
    0%, 45% { opacity: 1; }
    55%, 100% { opacity: 0; }
}
@keyframes showRight {
    0%, 45% { opacity: 0; }
    55%, 100% { opacity: 1; }
}

/* Controls */
.controls-container {
    display: flex; flex-wrap: wrap;
    gap: 1.5rem; justify-content: space-between; align-items: flex-end;
    margin-top: 1.5rem; padding-top: 1.5rem;
    border-top: 1px solid var(--border-color);
}
.control-group { display: flex; flex-direction: column; gap: 0.5rem; }
.control-group label { font-weight: bold; font-size: 0.9rem; }
.button-group { display: flex; }
.style-btn {
    padding: 0.5rem 1rem; border: 1px solid var(--border-color);
    background-color: var(--card-background); color: var(--text-color);
    cursor: pointer; transition: all var(--transition-speed);
}
.style-btn:first-child { border-radius: 8px 0 0 8px; }
.style-btn:last-child { border-radius: 0 8px 8px 0; }
.style-btn.active {
    background-color: var(--primary-color);
    color: white; border-color: var(--primary-color);
}
.control-group input[type="color"] {
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    width: 50px; height: 30px;
    border: 1px solid var(--border-color);
    border-radius: 4px; cursor: pointer;
    padding: 2px;
    background-color: var(--card-background);
}
.control-group input[type="color"]::-webkit-color-swatch-wrapper { padding: 0; }
.control-group input[type="color"]::-webkit-color-swatch { border: none; border-radius: 2px; }
.control-group input[type="color"]::-moz-color-swatch { border: none; border-radius: 2px; }

.session-actions {
    margin-top: 1.5rem; padding-top: 1.5rem;
    border-top: 1px solid var(--border-color);
}
.session-actions p { margin-top: 0; }
.action-buttons-container {
    display: flex;
    gap: 1rem;
    margin-top: 1rem;
    flex-wrap: wrap;
}
#rerate-container {
    margin-top: 1rem; padding: 1.5rem;
    background-color: var(--background-color); border-radius: 8px;
}
#rerate-container .note {
    font-size: 0.9rem; color: var(--text-color);
    text-align: center; margin-top: 1rem;
}
.body-scan-section {
    margin-top: 1.5rem;
}


/* Info Section */
.info-section { margin-top: 3rem; }
.info-title { text-align: center; margin-bottom: 2rem; }
section {
    background-color: var(--card-background);
    border-radius: 12px; padding: 2rem; margin-bottom: 2rem;
    box-shadow: 0 8px 24px var(--shadow-color); border: 1px solid var(--border-color);
}

/* Accordion */
.accordion-item { border-bottom: 1px solid var(--border-color); }
.accordion-item:last-child { border-bottom: none; }
.accordion-header {
    width: 100%; background-color: transparent; border: none;
    padding: 1.5rem 1rem; text-align: left;
    font-family: var(--heading-font); font-size: 1.1rem;
    font-weight: 600; color: var(--heading-color); cursor: pointer;
    display: flex; justify-content: space-between; align-items: center;
    transition: background-color 0.2s;
}
.accordion-header:hover { background-color: var(--background-color); }
.accordion-header .icon {
    width: 1.5em; height: 1.5em; transition: transform 0.3s ease-in-out;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='currentColor'%3E%3Cpath d='M12 13.172l4.95-4.95 1.414 1.414L12 16 5.636 9.636 7.05 8.222z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: center;
    opacity: 0.7;
}
.accordion-header[aria-expanded="true"] .icon { transform: rotate(180deg); }
.accordion-content {
    max-height: 0; overflow: hidden;
    transition: max-height 0.3s ease-in-out;
}
.accordion-content p { padding: 0 1rem 1.5rem; margin: 0; }

/* Modal & Calm Place */
.modal-overlay {
    position: fixed;
    inset: 0;
    background-color: rgba(0, 0, 0, 0.6);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    opacity: 1;
    transition: opacity 0.3s ease-in-out;
}
.modal-overlay.hidden {
    opacity: 0;
    pointer-events: none;
}
.modal-content {
    background-color: var(--card-background);
    padding: 2rem;
    border-radius: 12px;
    width: 90%;
    max-width: 650px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 10px 30px var(--shadow-color);
    transform: scale(1);
    transition: transform 0.3s ease-in-out;
}
.modal-overlay.hidden .modal-content {
    transform: scale(0.95);
}
.modal-title { margin-top: 0; }
.modal-instruction { margin-bottom: 1.5rem; }
.modal-description { font-style: italic; }
.modal-content .prompt { margin-top: 1rem; font-size: 0.9rem; }
.modal-content button.button-primary { width: 100%; margin-top: 1rem; }

.calm-animation-container {
    display: flex;
    justify-content: center;
    align-items: center;
    height: 120px;
    margin: 1rem 0;
}
.calm-animation {
    width: 90px;
    height: 90px;
    background-color: var(--primary-color);
    border-radius: 12px;
    animation: box-breathing 16s linear infinite;
    position: relative;
}
.calm-animation::before {
    content: 'Breathe In';
    position: absolute;
    inset: 0;
    display: flex;
    justify-content: center;
    align-items: center;
    color: white;
    font-family: var(--heading-font);
    font-size: 1.1rem;
    font-weight: bold;
    text-align: center;
    animation: box-breathing-text 16s linear infinite;
}

@keyframes box-breathing {
    0%, 100% { transform: scale(0.7); } /* Start Inhale / End Hold */
    25%      { transform: scale(1); }   /* End Inhale, Start Hold */
    50%      { transform: scale(1); }   /* End Hold, Start Exhale */
    75%      { transform: scale(0.7); } /* End Exhale, Start Hold */
}

@keyframes box-breathing-text {
    0%   { content: 'Breathe In'; }
    25%  { content: 'Hold'; }
    50%  { content: 'Breathe Out'; }
    75%  { content: 'Hold'; }
    100% { content: 'Breathe In'; }
}


/* Modal Accordion */
.modal-accordion {
    border: 1px solid var(--border-color);
    border-radius: 8px;
    margin-bottom: 1.5rem;
    overflow: hidden;
}
.modal-accordion-item { border-bottom: 1px solid var(--border-color); }
.modal-accordion-item:last-child { border-bottom: none; }
.modal-accordion-header {
    width: 100%;
    background-color: transparent;
    border: none;
    padding: 1rem 1.5rem;
    text-align: left;
    font-family: var(--heading-font);
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--heading-color);
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: background-color 0.2s;
}
.modal-accordion-header:hover { background-color: var(--background-color); }
.modal-accordion-header .icon {
    width: 1.5em; height: 1.5em;
    transition: transform 0.3s ease-in-out;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='currentColor'%3E%3Cpath d='M12 13.172l4.95-4.95 1.414 1.414L12 16 5.636 9.636 7.05 8.222z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: center;
    opacity: 0.7;
}
.modal-accordion-header[aria-expanded="true"] .icon { transform: rotate(180deg); }

.modal-accordion-content {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.35s ease-in-out;
    background-color: var(--background-color);
}
.modal-accordion-content > * {
    padding: 0 1.5rem 1.5rem;
}
.modal-accordion-content > *:first-child {
    padding-top: 1rem;
}
.modal-accordion-content ul, .modal-accordion-content ol { padding-left: 2rem; margin: 0; }
.modal-accordion-content li { margin-bottom: 0.5rem; }


/* Footer */
footer {
    text-align: center;
    padding: 2rem;
    margin-top: 2rem;
    font-size: 0.9rem;
    color: var(--text-color);
    border-top: 1px solid var(--border-color);
}

/* Responsiveness */
@media (max-width: 768px) {
    h1 { font-size: 1.5rem; }
    .subtitle { font-size: 1rem; }
    header { padding: 1.5rem 5%; }
    .progress-stepper { margin: 1.5rem 0; }
    #emdr-tool, section { padding: 1.5rem; }
    .controls-container { flex-direction: column; align-items: stretch; }
    .controls-container .button-primary { margin-top: 1rem; width: 100%;}
}

@media (max-width: 480px) {
    header { flex-direction: column; gap: 1rem; text-align: center; }
    .step-label { display: none; }
    .progress-stepper::before { left: 5%; right: 5%; }
}