/* Autism-Friendly Design Principles */
:root {
    --primary-color: #4A90E2;
    --secondary-color: #50C878;
    --background: #F5F7FA;
    --card-background: #FFFFFF;
    --text-primary: #2C3E50;
    --text-secondary: #7F8C8D;
    --border-color: #E1E8ED;
    --shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

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

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: var(--background);
    color: var(--text-primary);
    line-height: 1.6;
}

/* Make the app a column flex container so footer can stick to the bottom
   when the page content is short. Each visible <main> will grow to fill
   available space. */
html, body { height: 100%; }
#app { display: flex; flex-direction: column; min-height: 100vh; }
#app > main { flex: 1 1 auto; }

header {
    background-color: var(--card-background);
    padding: 1rem 2rem;
    box-shadow: var(--shadow);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

header h1 {
    color: var(--primary-color);
    font-size: 1.8rem;
}

/* header title with logo */
.title {
    display: flex;
    align-items: center;
    gap: 12px;
}

/* brand link wrapping logo + name should be inline and unstyled */
.brand {
    display: inline-flex;
    align-items: center;
    gap: 12px;
    text-decoration: none;
    color: inherit;
}
.brand h1 { margin: 0; }

.logo {
    width: 40px;
    height: 40px;
    display: inline-block;
}

.user-menu {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.top-menu ul {
    list-style: none;
    display: flex;
    gap: 1rem;
    align-items: center;
}
.top-menu ul li a {
    color: var(--text-primary);
    text-decoration: none;
    padding: 0.2rem 0.4rem;
}
.top-menu ul li a:hover {
    color: var(--primary-color);
}

/* small board selector shown in the header (non-button box) */
.board-selector-top {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.25rem 0.5rem;
    border-radius: 6px;
    border: 1px solid var(--border-color);
    background: linear-gradient(180deg, #fff, #fbfbfb);
    color: var(--text-primary);
    cursor: pointer;
    font-size: 0.95rem;
}
.board-selector-top .label { color: var(--text-secondary); margin-right: 4px; }
.board-selector-top .name { color: var(--text-primary); margin-right: 6px; }
.board-selector-top .caret { color: var(--text-secondary); font-size: 0.85rem; }

/* Focus styles for keyboard accessibility */
.board-selector-top:focus {
    outline: 3px solid #A8D5FF;
    outline-offset: 2px;
}

/* section selector styling (similar to view selector) */
.section-selector-container { position: relative; display: inline-block; margin-left: 12px; }
.section-selector-top {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.25rem 0.5rem;
    border-radius: 6px;
    border: 1px solid var(--border-color);
    background: linear-gradient(180deg, #fff, #fbfbfb);
    color: var(--text-primary);
    cursor: pointer;
    font-size: 0.95rem;
}
.section-selector-top .label { color: var(--text-secondary); margin-right: 4px; }
.section-selector-top .name { color: var(--text-primary); margin-right: 6px; }
.section-selector-top .caret { color: var(--text-secondary); font-size: 0.85rem; }
.section-selector-dropdown {
    position: absolute;
    background: var(--card-background);
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow);
    margin-top: 8px;
    border-radius: 6px;
    z-index: 2000;
}
.section-selector-dropdown ul { list-style:none; padding: 8px; margin:0; }
.section-selector-dropdown ul li { margin: 4px 0; }
.section-selector-dropdown ul li a { color: var(--text-primary); text-decoration:none; }

/* view selector styling (similar compact box) */
.view-selector-container { position: relative; display: inline-block; margin-left: 12px; }
.global-add-column { text-align: center; margin: 1rem 0; }
.global-add-link { display: inline-block; background: var(--primary-color); color: #fff; padding: 0.5rem 0.9rem; border-radius: 6px; text-decoration: none; }
.global-add-link:hover { background:#357ABD; }
.view-selector-top {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.25rem 0.5rem;
    border-radius: 6px;
    border: 1px solid var(--border-color);
    background: linear-gradient(180deg, #fff, #fbfbfb);
    color: var(--text-primary);
    cursor: pointer;
    font-size: 0.95rem;
}
.view-selector-top .label { color: var(--text-secondary); margin-right: 4px; }
.view-selector-top .name { color: var(--text-primary); margin-right: 6px; }
.view-selector-top .caret { color: var(--text-secondary); font-size: 0.85rem; }
.view-selector-dropdown,
.board-selector-dropdown {
    position: absolute;
    background: var(--card-background);
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow);
    margin-top: 8px;
    border-radius: 6px;
    z-index: 2000;
}
.view-selector-dropdown ul, .board-selector-dropdown ul { list-style:none; padding: 8px; margin:0; }
.view-selector-dropdown ul li, .board-selector-dropdown ul li { margin: 4px 0; }
.view-selector-dropdown ul li a, .board-selector-dropdown ul li a { color: var(--text-primary); text-decoration:none; }
.board-selector-container { position: relative; display: inline-block; }
.board-selector-add { padding: 8px; border-top: 1px solid var(--border-color); text-align: center; }
.board-add-link { color: var(--primary-color); text-decoration: none; font-weight: 600; }
.board-add-link:hover { text-decoration: underline; }

/* Planner calendar styles */
.planner-controls { display:flex; align-items:center; gap:12px; padding: 0.5rem 1rem; }
.calendar-nav { display:flex; align-items:center; gap:8px; }
.calendar { padding: 0 1rem 1rem 1rem; }
.calendar-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.calendar-cell { min-height: 90px; background: var(--card-background); border:1px solid var(--border-color); border-radius:6px; padding:6px; position:relative; }
.calendar-cell .date-num { position:absolute; top:6px; right:8px; font-size:0.85rem; color:var(--text-secondary); }
.calendar-weekdays { display:grid; grid-template-columns: repeat(7,1fr); gap:6px; padding:0 1rem; margin-top:8px; }
.weekday { font-size:0.85rem; color:var(--text-secondary); text-align:center; }
.day-task { display:block; background:var(--background); padding:2px 4px; border-radius:4px; margin-top:18px; font-size:0.8rem; max-height:36px; overflow:hidden; }
.undated-box { border-top:1px solid var(--border-color); padding: 1rem; background: #fff9; }

/* highlight today's date number in calendar views */
.calendar-cell .date-num.today,
.calendar-week .date-num.today {
    background: var(--primary-color);
    color: #fff;
    width: 26px;
    height: 26px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    font-size: 0.8rem;
    right: 8px;
    top: 6px;
}

/* day header highlight */
.calendar-day-header.today {
    display: inline-block;
    background: var(--primary-color);
    color: #fff;
    padding: 6px 10px;
    border-radius: 6px;
}

/* Coming up list */
.coming-up { padding: 1rem; }
.coming-item { padding: 0.5rem 0; border-bottom:1px solid var(--border-color); }

/* TimeLines coming soon section */
.timelines-section {
    padding: 2rem;
    text-align: center;
}
.timelines-section .coming-soon {
    max-width: 600px;
    margin: 4rem auto;
    padding: 3rem 2rem;
    background: var(--card-background);
    border-radius: 12px;
    box-shadow: var(--shadow);
}
.timelines-section .coming-soon h2 {
    color: var(--primary-color);
    font-size: 2rem;
    margin-bottom: 1rem;
}
.timelines-section .coming-soon p {
    color: var(--text-secondary);
    font-size: 1.1rem;
}

.top-menu-dropdown {
    display: none;
    padding: 0.4rem;
    border-radius: 6px;
    border: 1px solid var(--border-color);
}

.login-btn-mobile {
    display: none; /* shown only on small screens */
}

button {
    background-color: var(--primary-color);
    color: white;
    border: none;
    padding: 0.6rem 1.2rem;
    border-radius: 6px;
    cursor: pointer;
    font-size: 1rem;
    transition: background-color 0.2s ease;
}

button:hover {
    background-color: #357ABD;
}

button:focus {
    outline: 3px solid #A8D5FF;
    outline-offset: 2px;
}

.auth-container {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 80vh;
}

.auth-form {
    background-color: var(--card-background);
    padding: 2rem;
    border-radius: 8px;
    box-shadow: var(--shadow);
    width: 100%;
    max-width: 400px;
}

.auth-form h2 {
    margin-bottom: 1.5rem;
    text-align: center;
}

.auth-form form {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

input {
    padding: 0.8rem;
    border: 2px solid var(--border-color);
    border-radius: 6px;
    font-size: 1rem;
}

input:focus {
    outline: none;
    border-color: var(--primary-color);
}

.board-container {
    display: flex;
    gap: 1.5rem;
    padding: 2rem;
    overflow-x: auto;
}

/* allow columns to wrap into multiple rows when there's not enough horizontal space */
.board-container {
    display: flex;
    gap: 1.5rem;
    padding: 2rem;
    overflow-x: auto;
    flex-wrap: wrap;
    align-items: flex-start;
}

.column {
    background-color: var(--card-background);
    border-radius: 8px;
    padding: 1rem;
    /* make columns use a fixed width on wide screens but be flexible when wrapping */
    flex: 0 0 300px;
    max-width: 300px;
    box-shadow: var(--shadow);
}

/* mobile: stack columns vertically for narrow viewports */
@media (max-width: 800px) {
    .board-container {
        flex-direction: column;
        padding: 1rem;
    }
    .column {
        flex: 1 1 auto;
        width: 100%;
        max-width: none;
        min-width: 0;
    }
    header {
        padding: 0.75rem 1rem;
    }
    header h1 {
        font-size: 1.2rem;
    }
    /* collapse top menu into a dropdown on small screens */
    .top-menu { display: none; }
    .top-menu-dropdown { display: inline-block; }
    /* ensure login button for guests remains visible on small screens */
    .login-btn-mobile { display: inline-block; }
}

.column-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 2px solid var(--border-color);
}

.column-header h3 {
    font-size: 1.2rem;
}

.column-header h3 {
    cursor: pointer;
}

.task-count {
    background-color: var(--background);
    padding: 0.2rem 0.6rem;
    border-radius: 12px;
    font-size: 0.9rem;
}

.task-list {
    min-height: 100px;
    margin-bottom: 1rem;
}

.task-card {
    background-color: var(--background);
    padding: 1rem;
    margin-bottom: 0.8rem;
    border-radius: 6px;
    border: 2px solid var(--border-color);
    cursor: move;
    transition: transform 0.1s ease;
    position: relative; /* for tooltip positioning */
}

.task-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow);
}

/* task hover tooltip */
.task-tooltip {
    display: none;
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    bottom: calc(100% + 10px);
    min-width: 220px;
    max-width: 320px;
    background: var(--card-background);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    box-shadow: 0 6px 18px rgba(0,0,0,0.12);
    padding: 0.6rem;
    border-radius: 8px;
    z-index: 2000;
    font-size: 0.9rem;
}
.task-tooltip .row { margin-bottom: 0.35rem; }
.task-card:hover .task-tooltip { display: block; }

/* small caret */
.task-tooltip::after {
    content: '';
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    bottom: -6px;
    width: 0; height: 0;
    border-left: 6px solid transparent;
    border-right: 6px solid transparent;
    border-top: 6px solid var(--card-background);
}

/* small info indicator shown on task cards that have extra metadata */
.task-info-indicator {
    position: absolute;
    top: 6px;
    right: 6px;
    padding: 0 2px;
    background: transparent;
    color: #1e88e5;
    font-size: 12px;
    line-height: 1;
    pointer-events: none; /* allow drag interactions */
    display: inline-block;
}

.task-card h4 {
    margin-bottom: 0.5rem;
    font-size: 1rem;
}

.task-card p {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.task-meta {
    margin-top: 0.5rem;
}

.shared-badge {
    background-color: var(--secondary-color);
    color: white;
    padding: 0.2rem 0.6rem;
    border-radius: 4px;
    font-size: 0.8rem;
}

.add-task-btn {
    width: 100%;
    background-color: var(--background);
    color: var(--text-primary);
    border: 2px dashed var(--border-color);
}

.add-task-btn:hover {
    background-color: var(--border-color);
}

/* Mobile-only small move buttons for tasks (visible only on small screens) */
.mobile-move-controls { display: none; position: absolute; left: 8px; top: 8px; gap:6px; }
.mobile-move-controls button { background: transparent; border: 1px solid var(--border-color); padding: 4px 6px; border-radius: 4px; font-size:0.85rem; }

@media (max-width: 800px) {
    .mobile-move-controls { display: inline-flex; }
    /* on mobile, make the card cursor default to avoid implying drag */
    .task-card { cursor: default; }
}

/* Landing page styles for unauthenticated users */
.landing {
    display: grid;
    grid-template-columns: 1fr 420px;
    gap: 2rem;
    align-items: center;
    padding: 3rem;
}
.landing-hero {
    display: flex;
    gap: 1.5rem;
    align-items: center;
}
.landing-image {
    max-width: 320px;
    width: 100%;
    height: auto;
    border-radius: 12px;
    box-shadow: var(--shadow);
}
.landing-text h2 {
    color: var(--primary-color);
    margin-bottom: 0.5rem;
}
.landing-text p {
    color: var(--text-secondary);
    margin-bottom: 1rem;
    max-width: 50ch;
}
.landing-cta {
    background: linear-gradient(90deg, var(--primary-color), #6ab0ff);
    padding: 0.6rem 1rem;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(74,144,226,0.18);
}

@media (max-width: 900px) {
    .landing {
        grid-template-columns: 1fr;
        padding: 1.25rem;
    }
    .landing-hero { flex-direction: column; align-items: flex-start; }
    .auth-container { margin-top: 1.25rem; }
}

/* Footer styles */
.site-footer {
    background: var(--card-background);
    border-top: 1px solid var(--border-color);
    padding: 0.75rem 2rem;
    color: var(--text-secondary);
}
.footer-container {
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}
.footer-left {
    font-size: 0.95rem;
}
.footer-links a {
    color: var(--text-secondary);
    text-decoration: none;
    margin: 0 6px;
}
.footer-links a:hover {
    color: var(--primary-color);
}
.footer-links .sep { color: var(--border-color); margin: 0 6px; }

@media (max-width: 600px) {
    .footer-container { flex-direction: column; align-items: center; text-align: center; }
    .footer-links { margin-top: 6px; }
}

/* simpler landing layout */
.landing-simple {
    padding: 3rem;
    text-align: center;
}
.landing-simple h2 {
    color: var(--primary-color);
    font-size: 2rem;
    margin-bottom: 0.5rem;
}
.landing-lead {
    color: var(--text-secondary);
    max-width: 70ch;
    margin: 0 auto 1.25rem auto;
}
.landing-image-centered {
    max-width: 760px;
    width: 100%;
    height: auto;
    margin: 0 auto;
    border-radius: 12px;
    box-shadow: var(--shadow);
}

/* modal styles */
.modal-overlay {
    position: fixed;
    left: 0; top: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.45);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1200;
    padding: 1rem;
}
.modal-panel {
    background: var(--card-background);
    border-radius: 10px;
    padding: 1.25rem 1.5rem;
    max-width: 420px;
    width: 100%;
    box-shadow: 0 10px 30px rgba(0,0,0,0.15);
    position: relative;
}
.modal-close {
    position: absolute;
    right: 10px; top: 8px;
    background: transparent;
    border: none;
    font-size: 1.25rem;
    cursor: pointer;
}

@media (max-width: 600px) {
    .landing-simple { padding: 1.25rem; }
}

/* Toast notifications (created dynamically by JS) */
#toast-container { z-index: 9999; }
.toast { color: #fff; padding: 10px 14px; border-radius: 8px; box-shadow: 0 6px 18px rgba(0,0,0,0.12); font-size: 0.95rem; min-width: 200px; }
.toast-info { background: #333; }
.toast-error { background: #e53935; }
.toast-warn { background: #F5A623; color: #111; }

/* ===== TIMELINE STYLES ===== */

/* Timeline List View */
.timeline-list-view {
    padding: 2rem;
    max-width: 1200px;
    margin: 0 auto;
}

.timeline-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
}

.timeline-header h2 {
    color: var(--primary-color);
    font-size: 2rem;
}

.add-timeline-btn {
    background: var(--primary-color);
    color: white;
    border: none;
    padding: 0.75rem 1.5rem;
    border-radius: 8px;
    font-size: 1rem;
    cursor: pointer;
    transition: background 0.2s;
}

.add-timeline-btn:hover {
    background: #357ABD;
}

.empty-state {
    text-align: center;
    padding: 4rem 2rem;
    color: var(--text-secondary);
}

.timeline-cards {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 1.5rem;
}

.timeline-card {
    background: var(--card-background);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    padding: 1.5rem;
    cursor: pointer;
    transition: box-shadow 0.2s, transform 0.2s;
}

.timeline-card:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    transform: translateY(-2px);
}

.timeline-card h3 {
    color: var(--text-primary);
    margin-bottom: 0.75rem;
}

.timeline-meta {
    display: flex;
    gap: 1rem;
    color: var(--text-secondary);
    font-size: 0.9rem;
}

/* Timeline Detail View */
.timeline-detail-view {
    padding: 2rem;
    max-width: 1400px;
    margin: 0 auto;
}

.timeline-detail-header {
    display: flex;
    align-items: center;
    gap: 1.5rem;
    margin-bottom: 1.5rem;
}

.back-btn {
    background: var(--border-color);
    border: none;
    padding: 0.5rem 1rem;
    border-radius: 6px;
    cursor: pointer;
    font-size: 1rem;
}

.back-btn:hover {
    background: #d1d8e0;
}

.timeline-detail-header h2 {
    flex: 1;
    color: var(--primary-color);
}

.timeline-actions {
    display: flex;
    gap: 0.75rem;
}

.edit-timeline-btn, .start-timeline-btn, .delete-timeline-btn {
    padding: 0.5rem 1rem;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.95rem;
}

.edit-timeline-btn {
    background: var(--border-color);
}

.start-timeline-btn {
    background: var(--secondary-color);
    color: white;
    font-weight: 600;
}

.delete-timeline-btn {
    background: #e53935;
    color: white;
}

.timeline-info {
    background: var(--card-background);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 1rem;
    margin-bottom: 1.5rem;
}

.timeline-time-info {
    display: flex;
    gap: 2rem;
    color: var(--text-secondary);
}

.timeline-header-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.timeline-header-actions h3 {
    color: var(--text-primary);
}

.timeline-content {
    background: var(--card-background);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    padding: 1.5rem;
    min-height: 500px;
    display: flex;
}

.timeline-flex-container {
    display: flex;
    gap: 2rem;
    flex: 1;
    min-height: 450px;
}

.timeline-events-column {
    background: var(--card-background);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    padding: 1.5rem;
}

.timeline-events-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.add-event-btn {
    background: var(--primary-color);
    color: white;
    border: none;
    padding: 0.5rem 1rem;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.9rem;
}

.empty-events-wrapper {
    text-align: center;
    padding: 2rem;
    color: var(--text-secondary);
}

.empty-events {
    text-align: center;
    padding: 2rem;
    color: var(--text-secondary);
}

.event-list {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 450px;
}

.event-card {
    background: var(--background);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 1rem;
    padding-bottom: 50px; /* extra space for bottom labels */
    margin: 2px 0;
    display: flex;
    flex-direction: column;
    box-sizing: border-box;
    min-height: 100px;
    position: relative;
    /* flex-grow is set inline based on duration */
}

.free-time-card {
    background: #e8f5e9;
    border-color: #a5d6a7;
}

.free-time-card h4 {
    color: #2e7d32;
    font-style: italic;
}

.event-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;
}

.event-header h4 {
    flex: 1;
    color: var(--text-primary);
}

.event-controls {
    display: flex;
    gap: 0.25rem;
    width: 125px;
    justify-content: flex-end;
    flex-shrink: 0;
}

.event-controls button {
    background: #f5f5f5;
    border: 1px solid var(--border-color);
    width: 28px;
    height: 28px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.85rem;
    color: var(--text-primary);
    flex-shrink: 0;
}

.event-controls button:hover {
    background: #e0e0e0;
    color: var(--primary-color);
}

.event-meta {
    position: absolute;
    right: 10px;
    bottom: 8px;
    display: flex;
    gap: 0.75rem;
    font-size: 0.85rem;
    align-items: center;
}

.event-duration {
    color: var(--text-secondary);
}

.event-duration-unknown {
    color: #F5A623;
}

.event-difficulty {
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 0.8rem;
}

.difficulty-easy {
    background: #e8f5e9;
    color: #2e7d32;
}

.difficulty-medium {
    background: #fff3e0;
    color: #ef6c00;
}

.difficulty-hard {
    background: #ffebee;
    color: #c62828;
}

.event-flexible {
    background: #e3f2fd;
    color: #1976d2;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 0.8rem;
}

.event-time-label {
    position: absolute;
    bottom: 8px;
    left: 10px;
    background: rgba(0, 0, 0, 0.75);
    color: white;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 600;
}

/* Timeline Bar */
.timeline-bar {
    width: 120px;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
}

.timeline-scale {
    display: flex;
    flex-direction: column;
    height: 100%;
}

.timeline-segment {
    background: linear-gradient(180deg, #4A90E2 0%, #357ABD 100%);
    border: 1px solid #2d6ba3;
    border-radius: 4px;
    margin: 2px 0;
    position: relative;
    min-height: 80px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-sizing: border-box;
}

.free-time-segment {
    background: linear-gradient(180deg, #81c784 0%, #66bb6a 100%);
    border: 1px solid #4caf50;
}

.timeline-time-label {
    color: white;
    font-size: 0.7rem;
    font-weight: 600;
    text-align: center;
    word-break: break-word;
    padding: 2px;
}

/* Active Timeline View */
.active-timeline-view {
    padding: 2rem;
    max-width: 1400px;
    margin: 0 auto;
}

.active-header {
    display: flex;
    align-items: center;
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.stop-btn {
    background: #e53935;
    color: white;
    border: none;
    padding: 0.5rem 1rem;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 600;
}

.active-header h2 {
    flex: 1;
    color: var(--primary-color);
}

.timeline-clocks {
    display: flex;
    justify-content: center;
    gap: 4rem;
    margin-bottom: 3rem;
}

.clock-container {
    text-align: center;
}

.clock-label {
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin-bottom: 0.5rem;
}

.progress-clock {
    width: 150px;
    height: 150px;
    position: relative;
}

.progress-clock svg {
    width: 100%;
    height: 100%;
    transform: rotate(-90deg);
}

.clock-background {
    fill: none;
    stroke: var(--border-color);
    stroke-width: 8;
}

.clock-progress {
    fill: none;
    stroke: var(--secondary-color);
    stroke-width: 8;
    stroke-linecap: round;
    stroke-dasharray: 283;
    transition: stroke-dashoffset 0.5s ease;
}

.clock-time {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--text-primary);
}

.active-timeline-content {
    display: flex;
    flex-direction: column;
}

.active-events-list {
    display: flex;
    flex-direction: column;
    height: 100%;
}

.active-event-card {
    background: var(--card-background);
    border: 2px solid var(--border-color);
    border-radius: 8px;
    padding: 1rem;
    padding-bottom: 50px; /* Extra space for times and progress bar */
    margin: 2px 0;
    transition: all 0.3s;
    display: flex;
    flex-direction: column;
    box-sizing: border-box;
    min-height: 150px;
    position: relative;
}

.active-event-card.current-event {
    /* Highlight current running event with a warm creamy yellow */
    border-color: #d4b85a;
    background: #f2d87a;
    box-shadow: 0 0 0 3px rgba(212, 184, 90, 0.12);
}

.active-event-card.completed-event {
    opacity: 1;
    background: #e8f5e9; /* pale green */
    border-color: #a5d6a7;
    box-shadow: none;
}

.active-event-card.overdue-event {
    background: #ffebee;
    border-color: #e53935;
}

.active-event-card.late-completed-event {
    background: #fff9c4;
    border-color: #fbc02d;
}

.active-event-card.warning-event {
    background: #ffebee;
    border-color: #e53935;
    opacity: 1;
}

/* If an event is both current and marked overdue, prefer the current-event creamy yellow styling */
.active-event-card.current-event.overdue-event {
    background: #f2d87a;
    border-color: #d4b85a;
    box-shadow: 0 0 0 3px rgba(212, 184, 90, 0.12);
}

/* If a spare-time free event is current, show yellow instead of green */
.active-event-card.current-event.free-time-card {
    background: #f2d87a;
    border-color: #d4b85a;
    box-shadow: 0 0 0 3px rgba(212, 184, 90, 0.12);
}

.active-event-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.active-event-header h4 {
    flex: 1;
    color: var(--text-primary);
}

.check-btn {
    background: var(--secondary-color);
    color: white;
    border: none;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 1.2rem;
    display: flex;
    align-items: center;
    justify-content: center;
}

.overdue-btn {
    background: #e53935;
    color: white;
    border: none;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 1.2rem;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Button indicating the currently running event (arrow icon) */
.current-btn {
    background: #f39c12; /* orange */
    color: #fff;
    border: none;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 1.1rem;
    display: flex;
    align-items: center;
    justify-content: center;
}

.done-btn {
    background: #2e7d32; /* dark green */
    color: #fff;
    border: none;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    cursor: default;
    font-size: 1.1rem;
    display: flex;
    align-items: center;
    justify-content: center;
}

.done-mark {
    color: var(--secondary-color);
    font-size: 1.5rem;
    font-weight: bold;
}

.active-event-meta {
    color: var(--text-secondary);
    font-size: 0.85rem;
    margin-top: 0.5rem;
}

.active-event-times {
    position: absolute;
    bottom: 26px;
    left: 10px;
    background: rgba(0, 0, 0, 0.75);
    color: white;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 600;
    z-index: 5;
}

.event-progress-bar {
    position: absolute;
    bottom: 10px;
    left: 10px;
    right: 10px;
    height: 14px;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 7px;
    overflow: hidden;
    border: 1px solid rgba(0, 0, 0, 0.3);
    margin-top: 6px;
}

.event-progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #4A90E2 0%, #50C878 100%);
    transition: width 0.5s ease;
    border-radius: 7px;
}

.active-timeline-bar {
    position: relative;
}

.timeline-progress-line {
    position: absolute;
    left: 0;
    right: 0;
    height: 3px;
    background: #e53935;
    z-index: 10;
    transition: top 0.5s ease;
    box-shadow: 0 0 8px rgba(229, 57, 53, 0.6);
}

.timeline-progress-line::before {
    content: '◀';
    position: absolute;
    left: -8px;
    top: 50%;
    transform: translateY(-50%);
    color: #e53935;
    font-size: 0.8rem;
}

.active-timeline-scale {
    display: flex;
    flex-direction: column;
    height: 100%;
}

.active-timeline-segment {
    background: linear-gradient(180deg, #4A90E2 0%, #357ABD 100%);
    border: 1px solid #2d6ba3;
    border-radius: 4px;
    margin: 2px 0;
    position: relative;
    min-height: 100px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-sizing: border-box;
}

.active-time-label {
    color: white;
    font-size: 0.7rem;
    font-weight: 600;
    text-align: center;
    word-break: break-word;
    padding: 2px;
}

/* Timeline & Event Modals */
.timeline-form, .event-form {
    padding: 1rem 0;
}

.timeline-form h2, .event-form h2 {
    margin-bottom: 1.5rem;
    color: var(--primary-color);
}

.form-group {
    margin-bottom: 1.25rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    color: var(--text-secondary);
    font-weight: 500;
}

.form-group input[type="text"],
.form-group input[type="number"],
.form-group input[type="datetime-local"],
.form-group select {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    font-size: 1rem;
    font-family: inherit;
}

.form-group small {
    display: block;
    margin-top: 0.25rem;
    color: var(--text-secondary);
    font-size: 0.85rem;
}

.checkbox-group label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
}

.checkbox-group input[type="checkbox"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
}

.form-actions {
    display: flex;
    gap: 1rem;
    justify-content: flex-end;
    margin-top: 1.5rem;
}

.btn-cancel, .btn-save {
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 1rem;
}

.btn-cancel {
    background: var(--border-color);
}

.btn-save {
    background: var(--primary-color);
    color: white;
}

.btn-save:hover {
    background: #357ABD;
}

/* Responsive Timeline Styles */
@media (max-width: 768px) {
    .timeline-content,
    .active-timeline-content {
        grid-template-columns: 1fr;
    }
    
    .timeline-bar,
    .active-timeline-bar {
        display: none;
    }
    
    .timeline-clocks {
        flex-direction: column;
        gap: 2rem;
        align-items: center;
    }
    
    .timeline-cards {
        grid-template-columns: 1fr;
    }
    
    .timeline-detail-header {
        flex-wrap: wrap;
    }
    
    .timeline-time-info {
        flex-direction: column;
        gap: 0.5rem;
    }
}
