/* ============================================
   DAILY ENGINE v10 — Dark Mode PWA Styles
   Task Library + Custom Time Blocks
   ============================================ */

/* --- Reset & Base --- */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --bg-primary: #0a0a0f;
    --bg-secondary: #14141f;
    --bg-card: #1a1a2e;
    --bg-card-hover: #22223a;
    --bg-input: #12121e;
    --text-primary: #e8e8f0;
    --text-secondary: #8888a8;
    --text-muted: #55556a;
    --accent-morning: #f59e0b;
    --accent-workday: #3b82f6;
    --accent-evening: #8b5cf6;
    --accent-free: #10b981;
    --accent-danger: #ef4444;
    --accent-todo: #ec4899;
    --accent-cyan: #06b6d4;
    --accent-lime: #84cc16;
    --border: #2a2a3e;
    --border-light: #33334a;
    --check-green: #22c55e;
    --radius: 12px;
    --radius-sm: 8px;
    --radius-pill: 50px;
    --shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
    --transition: 0.2s ease;
    --safe-top: env(safe-area-inset-top, 0px);
    --safe-bottom: env(safe-area-inset-bottom, 0px);
}

html {
    font-size: 16px;
    -webkit-text-size-adjust: 100%;
    scroll-behavior: smooth;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'Segoe UI', Roboto, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    min-height: 100dvh;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
}

/* --- Header / Nav --- */
#app-header {
    position: sticky;
    top: 0;
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: calc(var(--safe-top) + 12px) 20px 12px;
    background: var(--bg-primary);
    border-bottom: 1px solid var(--border);
}

.header-left {
    display: flex;
    align-items: center;
    gap: 10px;
}

.app-logo { font-size: 1.4rem; }

#app-header h1 {
    font-size: 1.25rem;
    font-weight: 700;
    letter-spacing: -0.02em;
}

.header-right {
    display: flex;
    gap: 4px;
}

.nav-btn {
    background: transparent;
    border: none;
    color: var(--text-muted);
    padding: 8px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
}

.nav-btn:hover { background: var(--bg-card); color: var(--text-primary); }
.nav-btn.active { color: var(--text-primary); background: var(--bg-card); }

/* --- Views --- */
#app-main {
    padding: 0 16px 100px;
    max-width: 500px;
    margin: 0 auto;
}

.view { display: none; }
.view.active { display: block; animation: fadeIn 0.25s ease; }
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ===== TODAY VIEW ===== */
.today-header { padding: 20px 0 12px; }
.today-header h2 {
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 12px;
    letter-spacing: -0.02em;
}

/* --- Day Navigation --- */
.day-nav-row {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    margin-bottom: 10px;
}

.day-nav-btn {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: 1.5px solid var(--border);
    background: var(--bg-secondary);
    color: var(--text-primary);
    font-size: 1.2rem;
    font-weight: 700;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition);
    font-family: inherit;
    line-height: 1;
}
.day-nav-btn:hover {
    background: var(--bg-card-hover);
    border-color: var(--border-light);
}
.day-nav-btn:active {
    transform: scale(0.92);
}

.day-nav-today-pill {
    padding: 6px 18px;
    border-radius: var(--radius-pill);
    border: 1.5px solid var(--border);
    background: var(--bg-secondary);
    color: var(--text-secondary);
    font-size: 0.82rem;
    font-weight: 700;
    cursor: pointer;
    transition: all var(--transition);
    font-family: inherit;
}
.day-nav-today-pill:hover {
    border-color: var(--border-light);
    color: var(--text-primary);
}
.day-nav-today-pill.active {
    background: var(--accent-workday);
    border-color: var(--accent-workday);
    color: #fff;
    cursor: default;
}

/* --- Pill Row --- */
.pill-row {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    position: sticky;
    top: var(--header-height, 60px); /* measured by JS, fallback 60px */
    z-index: 20;
    background: var(--bg-primary);
    padding: 8px 0 10px;
}

.pill {
    padding: 6px 16px;
    border-radius: var(--radius-pill);
    font-size: 0.82rem;
    font-weight: 600;
    cursor: pointer;
    border: 1.5px solid var(--border);
    background: var(--bg-secondary);
    color: var(--text-secondary);
    transition: all 0.3s cubic-bezier(0.22, 1, 0.36, 1);
    white-space: nowrap;
    user-select: none;
    -webkit-user-select: none;
}

.pill:hover { border-color: var(--border-light); color: var(--text-primary); }

/* Dynamic pill color via CSS variable */
.pill.active {
    background: var(--pill-color, var(--accent-workday));
    border-color: var(--pill-color, var(--accent-workday));
    color: #fff;
    filter: drop-shadow(0 0 8px var(--pill-color, var(--accent-workday)));
    transform: scale(1.05);
}

.pill.current-indicator { position: relative; }
.pill.current-indicator::after {
    content: '';
    position: absolute;
    top: -3px;
    right: -3px;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--check-green);
    border: 2px solid var(--bg-primary);
}

/* --- Checklist --- */
.checklist-container {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 8px 0;
}

/* --- Block Sections (continuous list) --- */
.block-section {
    margin-bottom: 8px;
    scroll-margin-top: calc(var(--header-height, 60px) + 56px); /* header + pills + breathing room */
}

/* Entrance animation for sections */
.block-section-enter {
    animation: sectionSlideIn 0.45s cubic-bezier(0.22, 1, 0.36, 1) both;
}

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

/* Entrance animation for individual task items */
.task-item-enter {
    animation: taskSlideIn 0.35s cubic-bezier(0.22, 1, 0.36, 1) both;
}

@keyframes taskSlideIn {
    from {
        opacity: 0;
        transform: translateY(12px) scale(0.97);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.block-section-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 14px;
    border-left: 4px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg-primary);
    margin-bottom: 6px;
    position: sticky;
    top: calc(var(--header-height, 60px) + 46px); /* header (measured) + pill row (~46px) */
    z-index: 10;
    transition: box-shadow 0.3s ease, background 0.3s ease;
}

/* Active (NOW) block header — glowing accent */
.block-section-header.block-section-active {
    background: rgba(20, 20, 31, 0.95);
    box-shadow:
        0 0 0 1px rgba(34, 197, 94, 0.2),
        0 2px 12px rgba(34, 197, 94, 0.15),
        0 0 24px rgba(34, 197, 94, 0.08);
}

.block-section-name {
    font-weight: 700;
    font-size: 0.88rem;
    flex: 1;
}

.block-section-now {
    font-size: 0.65rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--check-green);
    background: rgba(34, 197, 94, 0.12);
    padding: 2px 8px;
    border-radius: var(--radius-pill);
    animation: nowPulse 2s ease-in-out infinite;
}

@keyframes nowPulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.3); }
    50% { box-shadow: 0 0 0 6px rgba(34, 197, 94, 0); }
}

.block-section-count {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-muted);
}

.block-section-empty {
    padding: 10px 16px;
    color: var(--text-muted);
    font-size: 0.82rem;
    font-style: italic;
}

.checklist-item {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 14px 16px;
    background: var(--bg-card);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    border-left: 3px solid var(--accent-workday);
    cursor: pointer;
    transition: all var(--transition);
    user-select: none;
    -webkit-user-select: none;
}

.checklist-item:hover { background: var(--bg-card-hover); }
.checklist-item:active { transform: scale(0.98); }
.checklist-item.checked { opacity: 0.5; }
.checklist-item.checked .task-text { text-decoration: line-through; color: var(--text-muted); }

.custom-checkbox {
    width: 24px;
    height: 24px;
    min-width: 24px;
    border-radius: 50%;
    border: 2px solid var(--border-light);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition);
}

.checklist-item.checked .custom-checkbox {
    background: var(--check-green);
    border-color: var(--check-green);
}

.custom-checkbox svg { opacity: 0; transition: opacity var(--transition); }
.checklist-item.checked .custom-checkbox svg { opacity: 1; }

.task-text {
    font-size: 0.95rem;
    font-weight: 500;
    line-height: 1.3;
    transition: all var(--transition);
    flex: 1;
}

.task-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}

.task-meta {
    font-size: 0.75rem;
    color: var(--text-muted);
    font-weight: 500;
}

.task-recur-badge {
    font-size: 0.8rem;
    margin-right: 4px;
}

.task-override-badge {
    font-size: 0.7rem;
    font-weight: 600;
    margin-left: 6px;
    opacity: 0.75;
    white-space: nowrap;
}

.checklist-item.time-overridden {
    border-left-width: 4px;
    border-left-style: dashed;
}

/* Inline delete */
.btn-inline-delete {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 6px;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0.3;
    transition: all var(--transition);
    flex-shrink: 0;
}
.btn-inline-delete:hover, .btn-inline-delete:active {
    opacity: 1; color: var(--accent-danger); background: rgba(239, 68, 68, 0.1);
}

/* --- Quick Add --- */
.quick-add-container { padding: 8px 0 16px; }

.btn-quick-add {
    width: 100%;
    padding: 14px;
    border: 2px dashed var(--border);
    border-radius: var(--radius);
    background: transparent;
    color: var(--text-secondary);
    font-size: 0.92rem;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition);
    font-family: inherit;
}
.btn-quick-add:hover, .btn-quick-add:active {
    border-color: var(--accent-free); color: var(--accent-free); background: rgba(16, 185, 129, 0.05);
}

.quick-add-input-row { display: flex; gap: 8px; }

.quick-add-input {
    flex: 1;
    padding: 12px 14px;
    background: var(--bg-card);
    border: 1.5px solid var(--border-light);
    border-radius: var(--radius);
    color: var(--text-primary);
    font-size: 0.92rem;
    font-family: inherit;
    outline: none;
    transition: border-color var(--transition);
}
.quick-add-input:focus { border-color: var(--accent-free); }
.quick-add-input::placeholder { color: var(--text-muted); }

.btn-quick-add-confirm {
    padding: 12px 20px;
    background: var(--accent-free);
    color: #000;
    border: none;
    border-radius: var(--radius);
    font-size: 0.88rem;
    font-weight: 700;
    cursor: pointer;
    font-family: inherit;
    transition: all var(--transition);
    white-space: nowrap;
}
.btn-quick-add-confirm:hover { background: #34d399; }

.hidden { display: none !important; }

/* --- Progress Bar --- */
.progress-bar-container {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 12px 20px calc(var(--safe-bottom) + 12px);
    background: rgba(10, 10, 15, 0.9);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-top: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 12px;
    z-index: 90;
}

.progress-bar {
    flex: 1;
    height: 8px;
    background: var(--bg-card);
    border-radius: 4px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--check-green), #4ade80);
    border-radius: 4px;
    transition: width 0.4s ease;
    width: 0%;
}

.progress-label {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-secondary);
    min-width: 50px;
    text-align: right;
}

/* Empty State */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-muted);
}
.empty-state .empty-icon { font-size: 3rem; margin-bottom: 16px; }
.empty-state p { font-size: 0.95rem; line-height: 1.5; }

/* ===== STREAK BADGE ===== */
.streak-badge {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 0 10px;
    font-size: 0.88rem;
    color: var(--text-secondary);
}
.streak-fire { font-size: 1.1rem; }
.streak-count { font-weight: 700; color: var(--accent-morning); }
.streak-best { font-size: 0.78rem; color: var(--text-muted); }
.streak-dimmed { color: var(--text-muted); font-size: 0.82rem; }

/* ===== TO-DO SECTION ===== */
.todo-section {
    margin-top: 20px;
    padding-top: 16px;
    border-top: 1px dashed var(--border);
}
.todo-header h3 {
    font-size: 1rem;
    font-weight: 700;
    margin-bottom: 10px;
}
.todo-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.todo-item {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 14px 16px;
    background: var(--bg-card);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    border-left: 3px solid var(--accent-todo);
    cursor: pointer;
    transition: all var(--transition);
    user-select: none;
    -webkit-user-select: none;
}
.todo-item:hover { background: var(--bg-card-hover); }
.todo-item:active { transform: scale(0.98); }
.todo-item.checked { opacity: 0.5; }
.todo-item.checked .task-text { text-decoration: line-through; color: var(--text-muted); }
.todo-item .todo-checkbox { border-color: var(--accent-todo); }
.todo-item.checked .todo-checkbox { background: var(--accent-todo); border-color: var(--accent-todo); }

.btn-quick-add-todo { border-color: var(--accent-todo); color: var(--accent-todo); }
.btn-quick-add-todo:hover, .btn-quick-add-todo:active {
    border-color: var(--accent-todo) !important; color: var(--accent-todo) !important;
    background: rgba(236, 72, 153, 0.05) !important;
}
.btn-todo-confirm { background: var(--accent-todo) !important; color: #fff !important; }
.btn-todo-confirm:hover { background: #db2777 !important; }

/* ═══════════════════════════════════════════
   SCHEDULED PANEL — Overdue + Upcoming
   ═══════════════════════════════════════════ */
.scheduled-section {
    margin-top: 20px;
    padding-top: 16px;
    border-top: 1px dashed var(--border);
}

.scheduled-header h3 {
    font-size: 1rem;
    font-weight: 700;
    margin-bottom: 12px;
}

.scheduled-subsection {
    margin-bottom: 14px;
}

.scheduled-sublabel {
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    padding: 4px 0 8px;
}

.overdue-label {
    color: var(--accent-danger);
}

.upcoming-label {
    color: var(--accent-workday);
}

.scheduled-item {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 12px 14px;
    background: var(--bg-card);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    border-left: 3px solid var(--accent-danger);
    margin-bottom: 6px;
    flex-wrap: wrap;
}

.scheduled-item.upcoming-item {
    border-left-color: var(--accent-workday);
}

.scheduled-item-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}

.scheduled-task-text {
    font-size: 0.92rem;
    font-weight: 500;
    line-height: 1.3;
}

.scheduled-meta {
    font-size: 0.75rem;
    font-weight: 500;
}

.overdue-meta {
    color: var(--accent-danger);
}

.upcoming-meta {
    color: var(--text-muted);
}

.scheduled-actions {
    display: flex;
    gap: 6px;
    flex-shrink: 0;
    flex-wrap: wrap;
}

.sched-btn {
    padding: 5px 10px;
    border-radius: var(--radius-pill);
    font-size: 0.72rem;
    font-weight: 700;
    cursor: pointer;
    border: 1.5px solid var(--border);
    background: var(--bg-secondary);
    color: var(--text-secondary);
    font-family: inherit;
    transition: all var(--transition);
    white-space: nowrap;
}

.sched-btn:hover {
    border-color: var(--border-light);
    color: var(--text-primary);
    background: var(--bg-card-hover);
}

.sched-do-today {
    border-color: var(--check-green);
    color: var(--check-green);
}
.sched-do-today:hover {
    background: var(--check-green);
    color: #000;
}

.sched-skip {
    border-color: var(--text-muted);
    color: var(--text-muted);
}
.sched-skip:hover {
    border-color: var(--text-secondary);
    color: var(--text-primary);
}

.sched-reschedule {
    border-color: var(--accent-workday);
    color: var(--accent-workday);
}
.sched-reschedule:hover {
    background: var(--accent-workday);
    color: #fff;
}

.sched-reschedule-upcoming {
    border-color: var(--border);
    font-size: 0.85rem;
    padding: 4px 8px;
}
.sched-reschedule-upcoming:hover {
    border-color: var(--accent-workday);
    background: rgba(59, 130, 246, 0.1);
}

/* --- Reschedule Modal --- */
.reschedule-dialog {
    max-width: 340px;
    text-align: center;
}

.reschedule-title {
    font-size: 1.1rem;
    font-weight: 700;
    margin-bottom: 4px;
}

.reschedule-subtitle {
    font-size: 0.88rem;
    color: var(--text-secondary);
    margin-bottom: 16px;
    line-height: 1.4;
}

.reschedule-dates {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    justify-content: center;
    margin-bottom: 16px;
    max-height: 200px;
    overflow-y: auto;
}

.reschedule-date-btn {
    padding: 8px 14px;
    border-radius: var(--radius-sm);
    border: 1.5px solid var(--border);
    background: var(--bg-secondary);
    color: var(--text-secondary);
    font-size: 0.82rem;
    font-weight: 600;
    cursor: pointer;
    font-family: inherit;
    transition: all var(--transition);
}

.reschedule-date-btn:hover {
    border-color: var(--accent-workday);
    color: var(--accent-workday);
    background: rgba(59, 130, 246, 0.1);
}

.reschedule-date-btn:first-child {
    border-color: var(--check-green);
    color: var(--check-green);
}

.reschedule-date-btn:first-child:hover {
    background: var(--check-green);
    color: #000;
}

/* ═══════════════════════════════════════════
   EDIT VIEW — v10 Redesign
   ═══════════════════════════════════════════ */
.edit-header { padding: 20px 0 8px; }
.edit-header h2 {
    font-size: 1.5rem;
    font-weight: 700;
    letter-spacing: -0.02em;
}
.edit-subtitle {
    color: var(--text-secondary);
    font-size: 0.85rem;
    margin-top: 4px;
}

/* --- Edit Tabs --- */
.edit-tabs {
    display: flex;
    gap: 4px;
    padding: 12px 0;
    border-bottom: 1px solid var(--border);
    margin-bottom: 16px;
}

.edit-tab {
    flex: 1;
    padding: 10px 14px;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg-secondary);
    color: var(--text-secondary);
    font-size: 0.88rem;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition);
    font-family: inherit;
    text-align: center;
}

.edit-tab:hover { border-color: var(--border-light); color: var(--text-primary); }
.edit-tab.active {
    background: var(--accent-workday);
    border-color: var(--accent-workday);
    color: #fff;
}

.edit-section-intro {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-bottom: 16px;
    line-height: 1.5;
}

/* --- Block Cards --- */
.block-card {
    background: var(--bg-card);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    border-left: 4px solid var(--accent-workday);
    padding: 16px;
    margin-bottom: 12px;
}

.block-card-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 12px;
}

.block-name-input {
    flex: 1;
    padding: 8px 10px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 0.95rem;
    font-weight: 600;
    font-family: inherit;
    outline: none;
    transition: border-color var(--transition);
}
.block-name-input:focus { border-color: var(--accent-workday); }

.block-color-select {
    padding: 8px 8px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 0.82rem;
    font-family: inherit;
    outline: none;
    cursor: pointer;
}
.block-color-select:focus { border-color: var(--accent-workday); }

.btn-delete-block {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 6px;
    border-radius: 4px;
    display: flex;
    transition: all var(--transition);
}
.btn-delete-block:hover { color: var(--accent-danger); background: rgba(239, 68, 68, 0.1); }

/* --- Day Groups --- */
.block-groups {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.day-group {
    padding: 10px 12px;
    background: var(--bg-secondary);
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
}

.day-toggles {
    display: flex;
    gap: 4px;
    margin-bottom: 8px;
    flex-wrap: wrap;
}

.day-toggle {
    width: 36px;
    height: 30px;
    border-radius: 6px;
    border: 1.5px solid var(--border);
    background: var(--bg-primary);
    color: var(--text-muted);
    font-size: 0.72rem;
    font-weight: 700;
    cursor: pointer;
    transition: all var(--transition);
    font-family: inherit;
    padding: 0;
}
.day-toggle:hover { border-color: var(--border-light); color: var(--text-secondary); }
.day-toggle.active {
    background: var(--accent-workday);
    border-color: var(--accent-workday);
    color: #fff;
}

.day-toggle.small {
    width: 32px;
    height: 26px;
    font-size: 0.68rem;
}

.group-time-row {
    display: flex;
    align-items: center;
    gap: 8px;
}

.time-sep {
    color: var(--text-muted);
    font-size: 0.85rem;
}

.time-input {
    background: var(--bg-input);
    border: 1px solid var(--border);
    color: var(--text-primary);
    padding: 6px 10px;
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    font-family: inherit;
    outline: none;
    width: 100px;
}
.time-input:focus { border-color: var(--accent-workday); }

.btn-remove-group {
    background: none;
    border: 1px solid var(--border);
    color: var(--text-muted);
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 0.75rem;
    transition: all var(--transition);
    margin-left: auto;
}
.btn-remove-group:hover { color: var(--accent-danger); border-color: var(--accent-danger); }

.btn-add-day-group {
    background: none;
    border: 1.5px dashed var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    font-size: 0.78rem;
    font-weight: 600;
    padding: 8px 12px;
    cursor: pointer;
    transition: all var(--transition);
    font-family: inherit;
    width: 100%;
    text-align: center;
    margin-top: 4px;
}
.btn-add-day-group:hover { border-color: var(--accent-workday); color: var(--accent-workday); }

.btn-add-block {
    width: 100%;
    padding: 14px;
    border: 2px dashed var(--border);
    border-radius: var(--radius);
    background: transparent;
    color: var(--text-secondary);
    font-size: 0.92rem;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition);
    font-family: inherit;
    margin-top: 4px;
}
.btn-add-block:hover {
    border-color: var(--accent-workday);
    color: var(--accent-workday);
    background: rgba(59, 130, 246, 0.05);
}

/* --- Task Filter Row --- */
.task-filter-row {
    display: flex;
    gap: 6px;
    align-items: center;
    flex-wrap: wrap;
    margin-bottom: 12px;
}

.filter-label {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-right: 2px;
}

.filter-pill {
    padding: 4px 12px;
    font-size: 0.75rem;
}

/* --- Edit Task List --- */
.edit-task-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 4px 0;
}

.edit-task-item {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 12px;
    background: var(--bg-card);
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    border-left: 3px solid var(--accent-workday);
}

.edit-task-item .drag-handle {
    color: var(--text-muted);
    cursor: grab;
    font-size: 1.1rem;
    padding: 0 2px;
    user-select: none;
    -webkit-user-select: none;
    margin-top: 3px;
}

.edit-task-fields {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 6px;
    min-width: 0;
}

.edit-task-row-main {
    display: flex;
    align-items: center;
    gap: 8px;
}

.edit-task-name {
    flex: 1;
    background: transparent;
    border: none;
    color: var(--text-primary);
    font-size: 0.92rem;
    font-weight: 500;
    outline: none;
    font-family: inherit;
}
.edit-task-name::placeholder { color: var(--text-muted); }

.btn-delete-task {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 4px;
    border-radius: 4px;
    display: flex;
    transition: all var(--transition);
}
.btn-delete-task:hover { color: var(--accent-danger); background: rgba(239, 68, 68, 0.1); }

/* Block assignment dropdown */
.edit-task-row-assign { display: flex; gap: 6px; }

.task-block-select {
    width: 100%;
    padding: 6px 10px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text-secondary);
    font-size: 0.78rem;
    font-family: inherit;
    outline: none;
    cursor: pointer;
    transition: border-color var(--transition);
}
.task-block-select:focus { border-color: var(--accent-workday); color: var(--text-primary); }

/* Day toggles row */
.edit-task-row-days {
    display: flex;
    gap: 3px;
    flex-wrap: wrap;
}

/* Time & duration */
.edit-task-row-meta { display: flex; gap: 6px; }

.edit-task-time,
.edit-task-duration {
    flex: 1;
    padding: 5px 8px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text-secondary);
    font-size: 0.75rem;
    font-family: inherit;
    outline: none;
    transition: border-color var(--transition);
}
.edit-task-time:focus, .edit-task-duration:focus {
    border-color: var(--accent-workday); color: var(--text-primary);
}
.edit-task-time::placeholder, .edit-task-duration::placeholder {
    color: var(--text-muted); font-size: 0.72rem;
}

/* Recurrence */
.edit-task-row-recur {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.recur-toggle-label {
    display: flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    font-size: 0.78rem;
    color: var(--text-muted);
    user-select: none;
    -webkit-user-select: none;
}
.recur-toggle-label input[type="checkbox"] {
    width: 16px; height: 16px;
    accent-color: var(--accent-workday);
    cursor: pointer;
}
.recur-toggle-label span { font-weight: 600; }

.recur-fields {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
    font-size: 0.75rem;
    color: var(--text-secondary);
}
.recur-fields span { color: var(--text-muted); }

.recur-every {
    width: 48px;
    padding: 4px 6px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text-primary);
    font-size: 0.78rem;
    font-family: inherit;
    outline: none;
    text-align: center;
}
.recur-every:focus { border-color: var(--accent-workday); }

.recur-unit {
    padding: 4px 8px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text-primary);
    font-size: 0.78rem;
    font-family: inherit;
    outline: none;
    cursor: pointer;
}
.recur-unit:focus { border-color: var(--accent-workday); }

.recur-start {
    padding: 4px 8px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text-primary);
    font-size: 0.75rem;
    font-family: inherit;
    outline: none;
}
.recur-start:focus { border-color: var(--accent-workday); }

/* Add task button */
.btn-add-task {
    width: 100%;
    padding: 12px;
    border: 2px dashed var(--border);
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--text-secondary);
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition);
    font-family: inherit;
    margin-top: 8px;
}
.btn-add-task:hover {
    border-color: var(--border-light); color: var(--text-primary); background: var(--bg-card);
}

/* --- Archive --- */
.archive-section {
    margin-top: 16px;
    padding-bottom: 8px;
}

.archive-toggle {
    display: flex;
    align-items: center;
    gap: 8px;
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 0.82rem;
    font-weight: 600;
    cursor: pointer;
    padding: 8px 4px;
    font-family: inherit;
    transition: color var(--transition);
}
.archive-toggle:hover { color: var(--text-secondary); }
.archive-toggle-icon { font-size: 0.65rem; }

.archive-list {
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 8px 0;
}

.archive-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 10px 14px;
    background: var(--bg-secondary);
    border-radius: var(--radius-sm);
    border: 1px dashed var(--border);
}

.archive-task-text {
    font-size: 0.88rem;
    color: var(--text-muted);
    flex: 1;
}

.btn-restore {
    background: none;
    border: 1px solid var(--accent-free);
    color: var(--accent-free);
    padding: 5px 12px;
    border-radius: var(--radius-pill);
    font-size: 0.75rem;
    font-weight: 600;
    cursor: pointer;
    font-family: inherit;
    transition: all var(--transition);
    white-space: nowrap;
}
.btn-restore:hover { background: var(--accent-free); color: #000; }

/* --- Backup Section --- */
.backup-section {
    margin-top: 28px;
    padding: 20px 16px;
    background: var(--bg-card);
    border-radius: var(--radius);
    border: 1px solid var(--border);
}
.backup-section h3 {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 6px;
}
.backup-subtitle {
    font-size: 0.82rem;
    color: var(--text-secondary);
    margin-bottom: 16px;
    line-height: 1.4;
}
.backup-buttons { display: flex; gap: 10px; }

.btn-backup {
    flex: 1;
    padding: 12px;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg-secondary);
    color: var(--text-primary);
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    font-family: inherit;
    transition: all var(--transition);
}
.btn-backup:hover { background: var(--bg-card-hover); border-color: var(--border-light); }

.btn-export { border-color: var(--accent-workday); color: var(--accent-workday); }
.btn-import { border-color: var(--accent-morning); color: var(--accent-morning); }
.btn-clipboard { border-color: var(--accent-evening); color: var(--accent-evening); }
.btn-link { border-color: var(--accent-free); color: var(--accent-free); }
.btn-recovery { border-color: var(--accent-morning); color: var(--accent-morning); }
.btn-cloud { border-color: var(--accent-workday); color: var(--accent-workday); }

/* ===== CONFIRM DIALOG ===== */
.confirm-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 24px;
    opacity: 0;
    transition: opacity 0.2s ease;
}
.confirm-overlay.visible { opacity: 1; }

.confirm-dialog {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 24px;
    max-width: 320px;
    width: 100%;
    box-shadow: var(--shadow);
    transform: scale(0.95);
    transition: transform 0.2s ease;
}
.confirm-overlay.visible .confirm-dialog { transform: scale(1); }

.confirm-message {
    font-size: 0.95rem;
    line-height: 1.5;
    color: var(--text-primary);
    margin-bottom: 20px;
    text-align: center;
}

.confirm-buttons { display: flex; gap: 10px; }

.confirm-btn {
    flex: 1;
    padding: 11px;
    border-radius: var(--radius-sm);
    font-size: 0.88rem;
    font-weight: 600;
    cursor: pointer;
    font-family: inherit;
    border: none;
    transition: all var(--transition);
}
.confirm-cancel {
    background: var(--bg-secondary); color: var(--text-secondary); border: 1px solid var(--border);
}
.confirm-cancel:hover { background: var(--bg-card-hover); color: var(--text-primary); }
.confirm-yes { background: var(--accent-danger); color: #fff; }
.confirm-yes:hover { background: #dc2626; }

/* ===== TOAST ===== */
.toast {
    position: fixed;
    bottom: 80px;
    left: 50%;
    transform: translateX(-50%) translateY(20px);
    background: var(--bg-card);
    color: var(--text-primary);
    padding: 12px 24px;
    border-radius: var(--radius-pill);
    font-size: 0.88rem;
    font-weight: 600;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.5);
    border: 1px solid var(--border-light);
    z-index: 2000;
    opacity: 0;
    transition: all 0.3s ease;
    pointer-events: none;
    white-space: nowrap;
}
.toast.visible { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ===== CLOUD SYNC INDICATOR ===== */
.sync-indicator {
    font-size: 0.65rem;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: var(--radius-pill);
    white-space: nowrap;
    transition: all 0.3s ease;
}
.sync-indicator.synced { color: var(--check-green); background: rgba(34, 197, 94, 0.1); }
.sync-indicator.syncing { color: var(--accent-workday); background: rgba(59, 130, 246, 0.1); }
.sync-indicator.error { color: var(--accent-morning); background: rgba(245, 158, 11, 0.1); }

/* ===== RECOVERY MODAL ===== */
.recovery-dialog { max-width: 360px; text-align: center; }
.recovery-title { font-size: 1.15rem; font-weight: 700; margin-bottom: 8px; }
.recovery-subtitle { font-size: 0.85rem; color: var(--text-secondary); line-height: 1.5; margin-bottom: 16px; }
.recovery-code-display {
    font-family: 'SF Mono', 'Menlo', 'Consolas', monospace;
    font-size: 1.2rem;
    font-weight: 800;
    letter-spacing: 0.08em;
    color: var(--accent-morning);
    background: var(--bg-secondary);
    border: 2px solid var(--accent-morning);
    border-radius: var(--radius-sm);
    padding: 14px 16px;
    margin-bottom: 12px;
    user-select: all;
    -webkit-user-select: all;
    word-break: break-all;
}
.recovery-hint { font-size: 0.78rem; color: var(--text-muted); margin-bottom: 16px; }
.recovery-done-btn { background: var(--check-green) !important; color: #000 !important; }
.recovery-done-btn:hover { background: #16a34a !important; }
.recovery-code-input {
    width: 100%;
    padding: 12px 14px;
    background: var(--bg-secondary);
    border: 1.5px solid var(--border-light);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-family: 'SF Mono', 'Menlo', 'Consolas', monospace;
    font-size: 1rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-align: center;
    outline: none;
    transition: border-color var(--transition);
    margin-bottom: 8px;
}
.recovery-code-input:focus { border-color: var(--accent-workday); }
.recovery-code-input::placeholder { color: var(--text-muted); font-weight: 500; letter-spacing: 0.02em; }
.recovery-error { font-size: 0.82rem; color: var(--accent-danger); margin-bottom: 12px; min-height: 1.2em; }

/* ===== CALENDAR VIEW ===== */
.stats-header { padding: 20px 0 12px; }
.stats-header h2 { font-size: 1.5rem; font-weight: 700; letter-spacing: -0.02em; }
.stats-content { display: flex; flex-direction: column; gap: 12px; }

.stat-card {
    background: var(--bg-card);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    padding: 20px;
}
.stat-card h3 {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    margin-bottom: 8px;
}
.stat-card .stat-value { font-size: 2rem; font-weight: 800; letter-spacing: -0.03em; }
.stat-card .stat-sub { font-size: 0.82rem; color: var(--text-secondary); margin-top: 4px; }
.stat-card .stat-value.green { color: var(--check-green); }
.stat-card .stat-value.blue { color: var(--accent-workday); }
.stat-card .stat-value.purple { color: var(--accent-evening); }
.stat-card .stat-value.orange { color: var(--accent-morning); }

.cal-card {
    background: var(--bg-card);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    padding: 16px;
}
.cal-nav { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.cal-month-label { font-size: 1rem; font-weight: 700; }
.cal-nav-btn {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    color: var(--text-primary);
    width: 36px; height: 36px;
    border-radius: 50%;
    font-size: 1.2rem;
    font-weight: 700;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition);
}
.cal-nav-btn:hover { background: var(--bg-card-hover); border-color: var(--border-light); }

.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.cal-header-cell {
    text-align: center; font-size: 0.7rem; font-weight: 700;
    color: var(--text-muted); padding: 4px 0 8px; text-transform: uppercase;
}
.cal-cell {
    aspect-ratio: 1;
    display: flex; align-items: center; justify-content: center;
    font-size: 0.82rem; font-weight: 600;
    border-radius: var(--radius-sm);
    cursor: pointer; transition: all var(--transition);
    color: var(--text-secondary);
    background: var(--bg-secondary);
    border: 1.5px solid transparent;
}
.cal-cell.empty { background: transparent; cursor: default; }
.cal-cell.cal-future { opacity: 0.3; cursor: default; }
.cal-cell.cal-today { border-color: var(--text-primary); color: var(--text-primary); font-weight: 800; }
.cal-cell.cal-selected { border-color: var(--accent-workday); box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.3); }
.cal-cell.cal-perfect { background: var(--check-green); color: #000; font-weight: 800; }
.cal-cell.cal-good { background: rgba(34, 197, 94, 0.35); color: var(--check-green); font-weight: 700; }
.cal-cell.cal-partial { background: rgba(245, 158, 11, 0.25); color: var(--accent-morning); font-weight: 700; }
.cal-cell.cal-none { background: rgba(239, 68, 68, 0.15); color: var(--accent-danger); }
.cal-cell:active:not(.empty):not(.cal-future) { transform: scale(0.9); }

.cal-legend { display: flex; justify-content: center; gap: 12px; margin-top: 12px; flex-wrap: wrap; }
.cal-leg { display: flex; align-items: center; gap: 4px; font-size: 0.7rem; color: var(--text-muted); }
.cal-leg-dot { width: 10px; height: 10px; border-radius: 3px; }
.cal-leg-dot.cal-perfect { background: var(--check-green); }
.cal-leg-dot.cal-good { background: rgba(34, 197, 94, 0.35); }
.cal-leg-dot.cal-partial { background: rgba(245, 158, 11, 0.25); }
.cal-leg-dot.cal-none { background: rgba(239, 68, 68, 0.15); }

.cal-detail-card {
    background: var(--bg-card);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    padding: 20px;
    margin-top: 12px;
    animation: fadeIn 0.25s ease;
}
.cal-detail-card > h3 { font-size: 1rem; font-weight: 700; margin-bottom: 14px; }
.cal-detail-block { margin-bottom: 12px; }
.cal-detail-block h4 {
    font-size: 0.8rem; font-weight: 600; color: var(--text-muted);
    text-transform: uppercase; letter-spacing: 0.04em; margin-bottom: 6px;
}
.cal-detail-list { list-style: none; padding: 0; }
.cal-detail-list li { font-size: 0.88rem; padding: 4px 0; color: var(--text-secondary); line-height: 1.4; }
.cal-detail-list li.done { color: var(--text-muted); }
.cal-detail-list li.missed { color: var(--text-secondary); }
.cal-detail-summary {
    margin-top: 12px; padding-top: 10px; border-top: 1px solid var(--border);
    font-size: 0.85rem; font-weight: 600; color: var(--text-secondary); text-align: center;
}

.task-streak-badge {
    font-size: 0.75rem; color: var(--accent-morning); font-weight: 700; margin-left: 6px;
}

/* ===== Scrollbar / Tap ===== */
::-webkit-scrollbar { width: 0; }
* { -webkit-tap-highlight-color: transparent; }

/* ===== MEASUREMENT MODAL ===== */
.measurement-dialog {
    text-align: center;
}
.measurement-title {
    font-size: 1.1rem;
    font-weight: 700;
    margin-bottom: 4px;
}
.measurement-subtitle {
    color: var(--text-secondary);
    font-size: 0.85rem;
    margin-bottom: 16px;
}
.measurement-input-row {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin-bottom: 16px;
}
.measurement-input {
    background: var(--bg-input);
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 1.5rem;
    font-weight: 700;
    padding: 10px 14px;
    width: 120px;
    text-align: center;
    font-family: inherit;
    transition: border-color var(--transition);
}
.measurement-input:focus {
    outline: none;
    border-color: var(--accent-workday);
}
.measurement-unit {
    color: var(--text-secondary);
    font-size: 1rem;
    font-weight: 600;
}

/* ===== EDIT: MEASUREMENT CONFIG ===== */
.edit-task-row-measure {
    margin-top: 6px;
}
.measure-toggle-label {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.82rem;
    color: var(--text-secondary);
    cursor: pointer;
}
.measure-toggle-label input[type="checkbox"] {
    accent-color: var(--accent-workday);
}
.measure-fields {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 6px;
    font-size: 0.8rem;
    color: var(--text-secondary);
    flex-wrap: wrap;
}
.measure-fields.hidden { display: none; }
.measure-unit-input, .measure-goal-input {
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    padding: 4px 8px;
    font-size: 0.82rem;
    font-family: inherit;
    width: 90px;
}
.measure-goal-input { width: 70px; }

/* ===== TODAY: MEASUREMENT BADGES ===== */
.task-measure-badge {
    font-size: 0.8rem;
    margin-right: 4px;
}
.task-measure-value {
    display: block;
    font-size: 0.72rem;
    color: var(--accent-workday);
    font-weight: 600;
    margin-top: 2px;
}

/* ===== TRACK VIEW ===== */
.track-header { padding: 20px 0 8px; }
.track-header h2 {
    font-size: 1.5rem;
    font-weight: 700;
    letter-spacing: -0.02em;
}
.track-subtitle {
    color: var(--text-secondary);
    font-size: 0.85rem;
    margin-top: 4px;
}
.track-content { padding-bottom: 20px; }

.track-card {
    background: var(--bg-card);
    border-radius: var(--radius);
    border-left: 4px solid var(--border);
    padding: 16px;
    margin-bottom: 16px;
    box-shadow: var(--shadow);
}

.track-card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 12px;
}
.track-task-name {
    font-weight: 700;
    font-size: 1rem;
}
.track-task-unit {
    color: var(--text-muted);
    font-size: 0.8rem;
    margin-left: 6px;
}
.track-latest {
    text-align: right;
}
.track-latest-value {
    font-size: 1.4rem;
    font-weight: 800;
    color: var(--accent-workday);
}
.track-latest-unit {
    color: var(--text-secondary);
    font-size: 0.8rem;
}
.track-no-data {
    color: var(--text-muted);
    font-size: 0.8rem;
}

.track-range-row {
    display: flex;
    gap: 6px;
    margin-bottom: 12px;
}
.track-range-btn {
    flex: 1;
    padding: 6px 0;
    border-radius: var(--radius-pill);
    border: 1.5px solid var(--border);
    background: var(--bg-secondary);
    color: var(--text-secondary);
    font-size: 0.78rem;
    font-weight: 700;
    font-family: inherit;
    cursor: pointer;
    transition: all var(--transition);
}
.track-range-btn:hover {
    border-color: var(--border-light);
    color: var(--text-primary);
}
.track-range-btn.active {
    background: var(--accent-workday);
    border-color: var(--accent-workday);
    color: #fff;
}

.track-chart-row {
    display: flex;
    align-items: center;
    gap: 4px;
}
.track-nav-btn {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    border: 1.5px solid var(--border);
    background: var(--bg-secondary);
    color: var(--text-primary);
    font-size: 1rem;
    font-weight: 700;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition);
    flex-shrink: 0;
    font-family: inherit;
}
.track-nav-btn:hover { background: var(--bg-card-hover); }
.track-nav-btn:disabled { opacity: 0.3; cursor: default; }
.track-canvas-wrap {
    flex: 1;
    min-width: 0;
}
.track-canvas {
    width: 100%;
    height: 220px;
    display: block;
}

.track-data-count {
    text-align: center;
    color: var(--text-muted);
    font-size: 0.75rem;
    margin-top: 10px;
}

/* ===== Responsive ===== */
@media (min-width: 600px) {
    #app-main { padding: 0 24px 100px; }
}
