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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: linear-gradient(135deg, #2563eb 0%, #1e40af 100%);
    color: #333;
    line-height: 1.6;
    min-height: 100vh;
}

/* Auth Modal */
#authModal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.modal-content {
    background: white;
    padding: 40px;
    border-radius: 16px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
    max-width: 400px;
    text-align: center;
}

.modal-content h2 {
    margin-bottom: 15px;
    color: #333;
}

.modal-content p {
    color: #666;
    margin-bottom: 25px;
}

#authEmail,
#authPassword {
    width: 100%;
    padding: 12px;
    margin-bottom: 15px;
    border: 1px solid #ddd;
    border-radius: 8px;
    font-size: 14px;
    box-sizing: border-box;
}

#authEmail:focus,
#authPassword:focus {
    outline: none;
    border-color: #2563eb;
    box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.15);
}

#signInBtn,
#signUpBtn {
    width: 100%;
    margin-bottom: 10px;
}

#signUpBtn {
    margin-bottom: 20px;
}

#backBtn {
    width: 100%;
}

#offlineBtn {
    width: 100%;
    margin-bottom: 12px;
}

.auth-divider {
    display: flex;
    align-items: center;
    text-align: center;
    color: #bbb;
    font-size: 12px;
    margin: 16px 0 12px;
}

.auth-divider::before,
.auth-divider::after {
    content: "";
    flex: 1;
    border-bottom: 1px solid #eee;
}

.auth-divider::before { margin-right: 10px; }
.auth-divider::after { margin-left: 10px; }

.auth-note {
    font-size: 12px;
    color: #999;
}

.container {
    max-width: 600px;
    margin: 0 auto;
    padding: 20px;
}

header {
    background: white;
    padding: 20px;
    border-radius: 12px;
    margin-bottom: 20px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 20px;
}

.header-left {
    flex: 1;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 20px;
}

header h1 {
    font-size: 24px;
    color: #2563eb;
    margin: 0;
}

.daily-total {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 18px;
    font-weight: 600;
    white-space: nowrap;
}

.daily-total .label {
    color: #999;
}

.daily-total .time {
    color: #2563eb;
}

.auth-status {
    display: flex;
    align-items: center;
    gap: 10px;
}

.user-email {
    font-size: 14px;
    color: #999;
}

main {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

section {
    background: white;
    padding: 20px;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

section h2 {
    margin-bottom: 15px;
    color: #333;
    font-size: 18px;
}

.section-hint {
    margin-top: -8px;
    margin-bottom: 15px;
    font-size: 13px;
    color: #999;
}

/* Timeline Section */
.timeline {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    padding: 4px 0 8px;
}

.timeline-axis {
    flex: 0 0 auto;
    width: 46px;
}

.timeline-axis-header {
    height: 28px;
}

.timeline-axis-track {
    position: relative;
}

.timeline-hour-label {
    position: absolute;
    left: 0;
    font-size: 11px;
    color: #999;
    font-weight: 600;
    transform: translateY(-6px);
}

.timeline-columns {
    display: flex;
    gap: 8px;
    flex: 1;
    min-width: 0;
}

.timeline-column {
    flex: 1 1 0;
    min-width: 70px;
}

.timeline-column-header {
    height: 28px;
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    font-weight: 600;
    color: #444;
    overflow: hidden;
}

.timeline-column-name {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Gridline spacing (44px) must match PX_PER_HOUR in app.js renderTimeline() */
.timeline-column-track {
    position: relative;
    border-left: 1px solid #eee;
    border-radius: 4px;
    background: repeating-linear-gradient(
        to bottom,
        #f1f1f1 0,
        #f1f1f1 1px,
        transparent 1px,
        transparent 44px
    );
}

.timeline-block {
    position: absolute;
    left: 2px;
    right: 2px;
    padding: 2px 5px;
    border-radius: 5px;
    font-size: 10px;
    font-weight: 600;
    color: white;
    cursor: pointer;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
    transition: transform 0.15s, box-shadow 0.15s;
}

.timeline-block:hover {
    transform: scale(1.02);
    box-shadow: 0 3px 8px rgba(0, 0, 0, 0.28);
    z-index: 2;
}

.timeline-block.selected {
    filter: brightness(1.5);
    box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.95), inset 0 0 0 4px rgba(0, 0, 0, 0.3);
    z-index: 3;
}

.timeline-block--past {
    opacity: 0.7;
}

/* Timeline section header with mode tabs */
.timeline-section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
    flex-wrap: wrap;
    gap: 8px;
}

.timeline-section-header h2 {
    margin-bottom: 0;
}

.timeline-mode-tabs {
    display: flex;
    gap: 4px;
}

.timeline-mode-btn {
    padding: 5px 12px;
    font-size: 12px;
    font-weight: 600;
    border-radius: 6px;
    background: #f0f0f0;
    color: #666;
    border: none;
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
}

.timeline-mode-btn:hover {
    background: #e0e0e0;
    transform: none;
}

.timeline-mode-btn.active {
    background: #2563eb;
    color: white;
}

.timeline-mode-btn.active:hover {
    background: #1d4ed8;
    transform: none;
}

.timeline-hint {
    font-size: 12px;
    color: #bbb;
    margin-top: -2px;
    margin-bottom: 8px;
    transition: color 0.2s;
}

.timeline-hint.active {
    color: #2563eb;
    font-weight: 600;
}

.timeline-legend {
    display: flex;
    gap: 16px;
    margin-bottom: 8px;
    font-size: 12px;
    color: #666;
    font-weight: 600;
}

.legend-today::before,
.legend-compare::before {
    content: '';
    display: inline-block;
    width: 10px;
    height: 10px;
    border-radius: 2px;
    margin-right: 6px;
    vertical-align: middle;
}

.legend-today::before {
    background: rgba(37, 99, 235, 0.25);
    border: 1px solid #2563eb;
}

.legend-compare::before {
    background: rgba(37, 99, 235, 0.08);
    border: 1px dashed #999;
}

.timeline-group-divider {
    width: 1px;
    background: #d0d0d0;
    flex-shrink: 0;
    margin: 28px 6px 0;
}

.timeline-group-empty {
    min-width: 80px;
    display: flex;
    justify-content: center;
    padding-top: 24px;
    font-size: 12px;
    color: #ccc;
    font-style: italic;
}

.timeline-empty {
    padding: 40px 20px;
    text-align: center;
    color: #ccc;
    font-size: 14px;
}

/* Buttons */
button {
    padding: 10px 20px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    transition: all 0.2s;
}

button:hover {
    transform: translateY(-2px);
}

button:active {
    transform: translateY(0);
}

.btn-primary {
    background: #2563eb;
    color: white;
}

.btn-primary:hover {
    background: #1d4ed8;
}

.btn-secondary {
    background: #f0f0f0;
    color: #333;
}

.btn-secondary:hover {
    background: #e0e0e0;
}

.btn-danger {
    background: #ef5350;
    color: white;
    padding: 8px 12px;
    font-size: 12px;
}

.btn-danger:hover {
    background: #e53935;
}

/* Active Session */
.session-area {
    padding: 14px;
    background: #f7f9ff;
    border-radius: 8px;
    text-align: center;
    min-height: 88px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 4px;
}

.no-session {
    color: #999;
    font-size: 14px;
}

.session-category {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 16px;
    font-weight: 600;
    color: #333;
}

.session-category-name {
    font-size: 16px;
}

.session-status {
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    padding: 2px 10px;
    border-radius: 12px;
}

.session-status.session-work {
    background: #dbeafe;
    color: #1d4ed8;
}

.session-status.session-break {
    background: #dcfce7;
    color: #15803d;
}

.session-display {
    font-size: 34px;
    font-weight: 700;
    margin: 4px 0 10px;
    font-family: 'Courier New', monospace;
}

/* Categories */
.category-input {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;
    margin-bottom: 15px;
}

.category-input input[type="text"] {
    flex: 1;
    min-width: 160px;
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 8px;
    font-size: 14px;
}

.category-input input[type="text"]:focus {
    outline: none;
    border-color: #2563eb;
    box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.15);
}

.color-palette {
    display: flex;
    gap: 6px;
}

.swatch {
    width: 24px;
    height: 24px;
    padding: 0;
    border-radius: 50%;
    border: 2px solid transparent;
    cursor: pointer;
    transition: transform 0.15s, border-color 0.15s;
}

.swatch:hover {
    transform: scale(1.15);
}

.swatch.selected {
    border-color: #333;
    box-shadow: 0 0 0 2px white, 0 0 0 4px #33333355;
}

.category-list {
    list-style: none;
}

.category-empty {
    padding: 20px;
    text-align: center;
    color: #bbb;
    font-size: 14px;
}

.category-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px;
    border-left: 4px solid #ddd;
    margin-bottom: 10px;
    cursor: pointer;
    border-radius: 4px;
    transition: all 0.2s;
}

.category-item:hover {
    background: #f5f8ff;
}

.category-item.active {
    background: #eef4ff;
    font-weight: 600;
}

.category-item-left {
    display: flex;
    align-items: center;
    gap: 10px;
    flex: 1;
    flex-wrap: wrap;
}

.category-dot {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    flex-shrink: 0;
    display: inline-block;
}

.category-name {
    font-weight: 600;
}

.category-time {
    font-size: 12px;
    color: #999;
}

.category-item-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.category-running {
    font-size: 12px;
    font-weight: 700;
    color: #2563eb;
    white-space: nowrap;
}

/* Settings */
.settings-details {
    margin-top: 15px;
    border-top: 1px solid #ddd;
    padding-top: 15px;
}

.settings-details summary {
    cursor: pointer;
    color: #2563eb;
    font-weight: 600;
    font-size: 14px;
}

.settings-details summary:hover {
    text-decoration: underline;
}

.settings {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-top: 10px;
}

.settings label {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 14px;
}

.settings input {
    padding: 6px 10px;
    border: 1px solid #ddd;
    border-radius: 4px;
    width: 60px;
    text-align: center;
}

.settings input:focus {
    outline: none;
    border-color: #2563eb;
}

.settings select {
    padding: 6px 10px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 14px;
    background: white;
}

.settings select:focus {
    outline: none;
    border-color: #2563eb;
}

#testAlarmBtn {
    align-self: flex-start;
    margin-top: 4px;
}

/* Visual alarm overlay (Screen Flash option) */
.flash-overlay {
    position: fixed;
    inset: 0;
    background: #2563eb;
    opacity: 0;
    pointer-events: none;
    z-index: 2000;
}

.flash-overlay.flashing {
    animation: flashTwice 0.7s ease;
}

@keyframes flashTwice {
    0%   { opacity: 0; }
    20%  { opacity: 0.9; }
    40%  { opacity: 0; }
    60%  { opacity: 0.9; }
    100% { opacity: 0; }
}

/* Mobile responsive */
@media (max-width: 600px) {
    .container {
        padding: 12px;
    }

    header {
        padding: 15px;
        flex-direction: column;
        gap: 12px;
        text-align: center;
    }

    .header-left,
    .header-right {
        width: 100%;
    }

    .header-right {
        flex-direction: column;
    }

    header h1 {
        font-size: 20px;
    }

    .modal-content {
        margin: 20px;
        max-width: calc(100% - 40px);
    }

    section {
        padding: 15px;
    }

    section h2 {
        font-size: 16px;
    }

    .session-display {
        font-size: 30px;
    }

    .category-input {
        flex-direction: column;
        align-items: stretch;
    }

    .color-palette {
        justify-content: center;
    }

    .category-input button {
        width: 100%;
    }

    button {
        padding: 12px 16px;
        font-size: 16px;
    }
}

/* Generic modal overlay (shared by the edit-block modal; #authModal has its own) */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

/* Timeline hint + Edit button row */
.timeline-actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    flex-wrap: wrap;
}

.timeline-edit-btn {
    padding: 5px 12px;
    font-size: 12px;
    font-weight: 600;
    flex-shrink: 0;
}

/* Live (in-progress) block: a soft pulse so you can see it's still running */
.timeline-block--live {
    box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.9), 0 1px 3px rgba(0, 0, 0, 0.2);
    animation: livePulse 1.6s ease-in-out infinite;
}

@keyframes livePulse {
    0%, 100% { filter: brightness(1); }
    50% { filter: brightness(1.35); }
}

/* Edit-block modal */
.edit-field {
    display: block;
    text-align: left;
    font-size: 13px;
    color: #444;
    margin-bottom: 14px;
}

.edit-field input {
    display: block;
    width: 100%;
    margin-top: 6px;
    padding: 12px;
    border: 1px solid #ddd;
    border-radius: 8px;
    font-size: 14px;
    box-sizing: border-box;
}

.edit-field input:focus {
    outline: none;
    border-color: #2563eb;
    box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.15);
}

.edit-modal-actions {
    display: flex;
    gap: 10px;
    margin-top: 8px;
}

.edit-modal-actions button {
    flex: 1;
}
