/* --- Base Variables & Reset --- */
:root {
    /* Learning Folk family look: cream paper, deep green, brick, gold */
    --primary-color: #2F7D5B;
    --primary-hover: #256448;
    --primary-light: #E5F4E4;
    --success-color: #2F7D5B;
    --success-hover: #256448;
    --danger-color: #B3402F;
    --danger-hover: #93301F;
    --purple-color: #9C3D2F;
    --purple-light: #F9ECE7;
    --amber-color: #B7860F;
    --amber-light: #F9EEDA;
    --bg-color: #F6F1E7;
    --card-bg: #ffffff;
    --text-main: #2B2B2B;
    --text-muted: #6B6B6B;
    --border-color: #DDD5C7;
    --border-focus: #8FC3A6;
    --radius: 10px;
    --radius-sm: 6px;
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.1), 0 1px 2px rgba(0, 0, 0, 0.06);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
}

* {
    box-sizing: border-box;
}

body {
    font-family: "Atkinson Hyperlegible", "Trebuchet MS", "Segoe UI", system-ui, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-main);
    margin: 0;
    padding: 20px;
    line-height: 1.5;
}

.container {
    max-width: 1340px;
    margin: 0 auto;
}

/* --- Controls & Card Styles --- */
.controls {
    background-color: var(--card-bg);
    padding: 24px;
    border-radius: var(--radius);
    box-shadow: var(--shadow-md);
    margin-bottom: 25px;
    border: 1px solid var(--border-color);
}

.app-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 18px;
    flex-wrap: wrap;
    gap: 14px;
}

.header-branding h2 {
    margin: 0;
    font-size: 1.45rem;
    font-weight: 800;
    color: var(--text-main);
    letter-spacing: -0.3px;
}

.header-tagline {
    font-size: 0.85rem;
    color: var(--text-muted);
    font-weight: 500;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

/* --- View Mode Switcher --- */
.view-mode-toggle {
    display: inline-flex;
    background-color: #e5e7eb;
    padding: 3px;
    border-radius: 8px;
    gap: 2px;
}

.btn-mode {
    padding: 6px 14px;
    background: transparent;
    border: none;
    border-radius: 6px;
    font-size: 0.85rem;
    font-weight: 700;
    color: #4b5563;
    cursor: pointer;
    transition: all 0.15s ease;
}

.btn-mode:hover {
    color: var(--text-main);
}

.btn-mode.active {
    background-color: #ffffff;
    color: var(--primary-color);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12);
}

.backup-actions {
    display: flex;
    gap: 8px;
    align-items: center;
    flex-wrap: wrap;
}

.offline-badge {
    display: inline-flex;
    align-items: center;
    padding: 5px 11px;
    background-color: #ecfdf5;
    border: 1px solid #a7f3d0;
    color: #065f46;
    border-radius: 20px;
    font-size: 0.775rem;
    font-weight: 700;
    letter-spacing: 0.2px;
}

.offline-badge.offline-active {
    background-color: #fef3c7;
    border-color: #fde68a;
    color: #92400e;
}

.toast-notification {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 9999;
    background: #1e293b;
    color: #ffffff;
    padding: 12px 20px;
    border-radius: 8px;
    box-shadow: var(--shadow-lg);
    font-size: 0.9rem;
    font-weight: 600;
    display: none;
    align-items: center;
    gap: 10px;
    max-width: 90vw;
}

.btn-secondary-sm {
    padding: 6px 12px;
    background-color: #f9fafb;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    font-size: 0.8rem;
    font-weight: 600;
    color: #4b5563;
    cursor: pointer;
    transition: background-color 0.15s, border-color 0.15s;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.btn-secondary-sm:hover {
    background-color: #e5e7eb;
    border-color: #9ca3af;
}

.btn-file-label {
    cursor: pointer;
}

.divider {
    margin: 18px 0;
    border: 0;
    border-top: 1px solid var(--border-color);
}

/* --- Combined Family Member Selection & Assignment Section --- */
.family-member-section {
    margin-bottom: 18px;
    background-color: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: var(--radius);
    padding: 14px 16px;
}

.family-label-group {
    display: flex;
    align-items: baseline;
    gap: 10px;
    flex-wrap: wrap;
}

.family-hint {
    font-size: 0.78rem;
    color: var(--text-muted);
    font-weight: 500;
}

.family-actions {
    display: flex;
    gap: 8px;
    align-items: center;
    flex-wrap: wrap;
}

.family-chips-container {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
    margin-top: 10px;
}

.family-chip {
    display: inline-flex;
    align-items: center;
    background-color: #ffffff;
    border: 1.5px solid #cbd5e1;
    border-radius: 24px;
    padding: 4px 12px 4px 10px;
    cursor: pointer;
    transition: all 0.15s ease;
    user-select: none;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
    gap: 8px;
}

.family-chip:hover {
    border-color: var(--primary-color);
    background-color: #f0f7ff;
}

.family-chip.active-viewing {
    border-color: var(--primary-color);
    background-color: #E5F4E4;
    box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.2);
}

.family-chip-checkbox {
    width: 17px;
    height: 17px;
    cursor: pointer;
    accent-color: var(--primary-color);
    margin: 0;
}

.family-chip-label {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
}

.family-chip-name {
    font-size: 0.88rem;
    font-weight: 600;
    color: #374151;
}

.family-chip.active-viewing .family-chip-name {
    color: var(--primary-color);
    font-weight: 700;
}

.viewing-badge {
    font-size: 0.68rem;
    font-weight: 700;
    color: #ffffff;
    background-color: var(--primary-color);
    padding: 2px 7px;
    border-radius: 12px;
    letter-spacing: 0.3px;
    text-transform: uppercase;
    display: inline-block;
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 4px;
    flex-wrap: wrap;
    gap: 8px;
}

.section-label {
    font-weight: 700;
    font-size: 0.875rem;
    color: #374151;
}

.btn-link {
    background: none;
    border: none;
    color: var(--primary-color);
    font-size: 0.825rem;
    font-weight: 600;
    cursor: pointer;
    padding: 0;
}

.btn-link:hover {
    text-decoration: underline;
}

.btn-link.text-danger {
    color: var(--danger-color);
}

.child-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
}

.child-tab {
    padding: 8px 18px;
    background-color: #f3f4f6;
    border: 1px solid #d1d5db;
    border-radius: 20px;
    font-size: 0.9rem;
    font-weight: 600;
    color: #4b5563;
    cursor: pointer;
    transition: all 0.15s ease;
}

.child-tab:hover {
    background-color: #e5e7eb;
    border-color: #9ca3af;
}

.child-tab.active {
    background-color: var(--primary-color);
    color: #ffffff;
    border-color: var(--primary-color);
    box-shadow: 0 2px 4px rgba(37, 99, 235, 0.25);
}

/* --- Week Navigation Section --- */
.week-navigation-section {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 14px;
}

.week-nav-controls {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.week-picker-wrapper input[type="date"] {
    padding: 7px 10px;
    font-size: 0.875rem;
    width: auto;
    font-weight: 500;
}

.btn-nav {
    padding: 7px 14px;
    background-color: #ffffff;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    font-size: 0.85rem;
    font-weight: 600;
    color: #374151;
    cursor: pointer;
    transition: all 0.15s;
}

.btn-nav:hover {
    background-color: #f3f4f6;
    border-color: #9ca3af;
}

.btn-nav-outline {
    padding: 7px 12px;
    background-color: var(--primary-light);
    border: 1px solid var(--border-focus);
    border-radius: 6px;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--primary-color);
    cursor: pointer;
    transition: all 0.15s;
}

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

.week-tools {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.btn-tool {
    padding: 7px 12px;
    background-color: #ffffff;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    font-size: 0.8rem;
    font-weight: 600;
    color: #374151;
    cursor: pointer;
    transition: all 0.15s;
}

.btn-tool:hover {
    background-color: #f3f4f6;
    border-color: #9ca3af;
}

.btn-tool-danger {
    color: var(--danger-color);
    border-color: #fca5a5;
    background-color: #fff5f5;
}

.btn-tool-danger:hover {
    background-color: #fee2e2;
    border-color: var(--danger-color);
}

/* --- Task Creation Form Layout --- */
.form-row-task-name {
    margin-bottom: 14px;
}

.form-group {
    display: flex;
    flex-direction: column;
}

.form-group.flex-full {
    width: 100%;
}

.form-group.flex-2 {
    grid-column: span 2;
}

/* --- Days and Time Row (Time of Day is to the right of Select Days) --- */
.days-and-time-row {
    display: flex;
    align-items: stretch;
    gap: 16px;
    margin-bottom: 14px;
}

.days-and-time-row .day-selection-section {
    flex: 3 1 440px;
    margin-top: 0;
    margin-bottom: 0;
    padding: 14px 16px;
    background-color: #f9fafb;
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
}

.days-and-time-row .time-selection-section {
    flex: 1 1 210px;
    min-width: 190px;
    background-color: #f9fafb;
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    padding: 14px 16px;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
}

.days-and-time-row .time-selection-section .time-group {
    height: 100%;
    justify-content: flex-start;
}

.days-and-time-row .time-selection-section select {
    margin-top: 4px;
}

/* Row with Priority Checkbox and + Add Task button to its right */
.priority-and-add-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    background-color: #ffffff;
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    padding: 10px 16px;
    margin-bottom: 16px;
    flex-wrap: wrap;
}

.priority-and-add-row .btn-primary {
    white-space: nowrap;
    padding: 10px 24px;
}

label {
    margin-bottom: 6px;
    font-weight: 600;
    font-size: 0.875rem;
    color: #374151;
}

input[type="text"],
select {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    background-color: #fff;
    font-size: 0.95rem;
    color: var(--text-main);
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

input[type="text"]:focus,
input[type="date"]:focus,
select:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

.checkbox-label {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    font-weight: 600;
    font-size: 0.9rem;
    padding: 8px 0;
    user-select: none;
}

.checkbox-label input[type="checkbox"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
    accent-color: var(--primary-color);
}

/* --- Early Reader Icon Selection Section --- */
.icon-selection-section {
    margin-top: 16px;
    padding: 14px 16px;
    background-color: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: var(--radius);
}

.icon-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
    flex-wrap: wrap;
    gap: 8px;
}

.icon-hint {
    display: block;
    font-size: 0.78rem;
    font-weight: normal;
    color: var(--text-muted);
    margin-top: 2px;
}

.auto-badge {
    display: inline-block;
    padding: 3px 8px;
    background-color: #ecfdf5;
    border: 1px solid #a7f3d0;
    color: #047857;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 600;
    transition: opacity 0.2s;
}

.icon-picker-bar {
    display: flex;
    align-items: center;
    gap: 14px;
    flex-wrap: wrap;
}

/* Centered Active Icon Preview Box */
.selected-icon-preview {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 78px;
    min-width: 78px;
    height: 72px;
    padding: 6px 4px;
    background: #ffffff;
    border: 2px solid var(--primary-color);
    border-radius: 12px;
    box-shadow: var(--shadow);
    flex-shrink: 0;
    text-align: center;
}

#previewEmoji {
    font-size: 1.85rem;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    text-align: center;
    margin: 0 auto;
}

.preview-label {
    font-size: 0.68rem;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    margin-top: 4px;
    text-align: center;
    letter-spacing: 0.3px;
    width: 100%;
    white-space: nowrap;
    display: block;
}

.quick-icons {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    align-items: center;
    flex: 1;
}

.icon-chip {
    width: 38px;
    height: 38px;
    font-size: 1.35rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background-color: #ffffff;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.15s ease;
    padding: 0;
    user-select: none;
}

.icon-chip[data-icon=""] {
    width: auto;
    padding: 0 10px;
    font-size: 0.8rem;
    font-weight: 600;
    color: #64748b;
}

.icon-chip:hover {
    background-color: #e2e8f0;
    transform: scale(1.08);
}

.icon-chip.active {
    border-color: var(--primary-color);
    background-color: #E5F4E4;
    box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.4);
    transform: scale(1.1);
}

.icon-chip-more {
    padding: 7px 12px;
    background-color: #ffffff;
    border: 1px dashed #94a3b8;
    border-radius: 8px;
    font-size: 0.8rem;
    font-weight: 600;
    color: #475569;
    cursor: pointer;
    transition: all 0.15s ease;
}

.icon-chip-more:hover {
    background-color: #f1f5f9;
    border-color: var(--primary-color);
    color: var(--primary-color);
}

/* --- Multi-Child Assignment Section --- */
.child-assign-section {
    margin-top: 16px;
    padding: 14px 16px;
    background-color: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: var(--radius);
}

.assign-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
    flex-wrap: wrap;
    gap: 8px;
}

.child-assign-presets {
    display: flex;
    gap: 6px;
}

.child-assign-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.child-assign-chip {
    cursor: pointer;
    user-select: none;
}

.child-assign-chip input[type="checkbox"] {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.child-assign-chip span {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 7px 16px;
    background-color: #ffffff;
    border: 1px solid #cbd5e1;
    border-radius: 20px;
    font-size: 0.875rem;
    font-weight: 600;
    color: #475569;
    transition: all 0.15s ease-in-out;
}

.child-assign-chip input[type="checkbox"]:checked + span {
    background-color: #10b981;
    color: #ffffff;
    border-color: #059669;
    box-shadow: 0 2px 4px rgba(16, 185, 129, 0.25);
}

.child-assign-chip:hover span {
    border-color: #10b981;
}

/* --- Recurring / Multi-Day Selection Chips --- */
.day-selection-section {
    margin-top: 16px;
    padding: 14px 16px;
    background-color: #f9fafb;
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
}

.day-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 12px;
}

.day-chip {
    cursor: pointer;
    user-select: none;
}

.day-chip input[type="checkbox"] {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.day-chip span {
    display: inline-block;
    padding: 8px 16px;
    background-color: #ffffff;
    border: 1px solid #d1d5db;
    border-radius: 20px;
    font-size: 0.875rem;
    font-weight: 600;
    color: #4b5563;
    transition: all 0.15s ease-in-out;
}

.day-chip input[type="checkbox"]:checked + span {
    background-color: var(--primary-color);
    color: #ffffff;
    border-color: var(--primary-color);
    box-shadow: 0 2px 4px rgba(37, 99, 235, 0.25);
}

.day-chip:hover span {
    border-color: var(--primary-color);
}

.day-presets {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
}

.preset-label {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-muted);
    margin-right: 4px;
}

.btn-preset {
    padding: 5px 12px;
    background-color: #ffffff;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    font-size: 0.775rem;
    font-weight: 600;
    color: #4b5563;
    cursor: pointer;
    transition: background-color 0.15s, border-color 0.15s;
}

.btn-preset:hover {
    background-color: #e5e7eb;
    border-color: #9ca3af;
}

/* --- Buttons --- */
button {
    font-family: inherit;
}

.form-actions {
    display: flex;
    gap: 12px;
    margin-top: 18px;
    align-items: center;
}

.btn-primary {
    padding: 10px 24px;
    background-color: var(--primary-color);
    color: #ffffff;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.95rem;
    font-weight: 700;
    transition: background-color 0.15s;
}

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

.print-action-bar {
    text-align: center;
    margin: 25px 0 10px 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

.print-button-group {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
}

.btn-print {
    padding: 12px 30px;
    background-color: var(--success-color);
    color: #ffffff;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 1.05rem;
    font-weight: 700;
    box-shadow: var(--shadow-md);
    transition: background-color 0.15s, transform 0.05s;
}

.btn-print:hover {
    background-color: var(--success-hover);
}

.btn-print:active {
    transform: translateY(1px);
}

.print-hint {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.last-printed-hint {
    font-size: 0.825rem;
    font-weight: 600;
    color: #059669;
    min-height: 1.2rem;
}

/* --- Schedule Top Bar (Directly Above Schedule) --- */
.schedule-top-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--card-bg);
    padding: 12px 18px;
    border-radius: var(--radius);
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow);
    margin-bottom: 16px;
    flex-wrap: wrap;
    gap: 12px;
}

.schedule-top-left {
    display: flex;
    align-items: center;
    gap: 16px;
    flex-wrap: wrap;
}

/* Requirement 6: Date Format Mode (Show Dates vs General Reusable Schedule) */
.calendar-date-mode-toggle {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    background-color: #f3f4f6;
    padding: 5px 12px;
    border-radius: 8px;
    border: 1px solid #e5e7eb;
}

.mode-label {
    font-size: 0.8rem;
    font-weight: 700;
    color: #4b5563;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.date-mode-radio {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    cursor: pointer;
    font-size: 0.825rem;
    font-weight: 600;
    color: #374151;
    user-select: none;
}

.date-mode-radio input[type="radio"] {
    cursor: pointer;
    accent-color: var(--primary-color);
}

/* Requirement 7: Print status banner */
.print-status-banner {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background-color: #ecfdf5;
    border: 1px solid #a7f3d0;
    color: #065f46;
    padding: 6px 14px;
    border-radius: 20px;
    font-size: 0.825rem;
    font-weight: 600;
}

.print-status-icon {
    font-size: 1rem;
}

/* --- VIEW 1: Schedule Display Area (Weekly Grid) --- */
#printableArea {
    background-color: var(--card-bg);
    padding: 24px;
    border-radius: var(--radius);
    box-shadow: var(--shadow-md);
    border: 1px solid var(--border-color);
}

#scheduleHeader {
    text-align: center;
    margin-bottom: 20px;
    padding-bottom: 12px;
    border-bottom: 2px solid var(--border-color);
}

#scheduleHeader h1 {
    margin: 0 0 6px 0;
    font-size: 1.85rem;
    font-weight: 800;
    color: var(--text-main);
}

#scheduleHeader h2 {
    margin: 0;
    font-size: 1.15rem;
    font-weight: 500;
    color: var(--text-muted);
}

.schedule-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 10px;
}

.day-column {
    background-color: #fafafa;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 10px 7px;
    display: flex;
    flex-direction: column;
    min-height: 300px;
    min-width: 0;
}

.day-column-header {
    text-align: center;
    margin: 0 0 10px 0;
    padding-bottom: 8px;
    border-bottom: 2px solid #e5e7eb;
}

.day-column-header h3 {
    margin: 0;
    padding: 0;
    font-size: 0.95rem;
    font-weight: 800;
    color: #111827;
    border: none;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.day-numerical-date {
    display: inline-block;
    margin-top: 3px;
    font-size: 0.775rem;
    font-weight: 700;
    color: var(--primary-color);
    background-color: var(--primary-light);
    border: 1px solid #C9DCCB;
    padding: 1px 7px;
    border-radius: 10px;
}

.time-block {
    margin-bottom: 12px;
}

.time-block h4 {
    margin: 0 0 6px 2px;
    color: #4b5563;
    font-size: 0.8rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    display: flex;
    align-items: center;
    gap: 4px;
}

.time-block ul {
    list-style: none;
    margin: 0;
    padding: 0;
}

.time-block li {
    background-color: #ffffff;
    padding: 5px 6px;
    border-radius: 6px;
    margin-bottom: 5px;
    border: 1px solid #e5e7eb;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.825rem;
    transition: background-color 0.15s, border-color 0.15s;
    position: relative;
    min-width: 0;
}

.time-block li:hover {
    background-color: #f9fafb;
    border-color: #cbd5e1;
}

.time-block li.completed {
    background-color: #f8fafc;
    border-color: #e2e8f0;
}

.time-block li.completed .task-name {
    text-decoration: line-through;
    color: #9ca3af;
}

.time-block li.completed .task-icon {
    opacity: 0.5;
    filter: grayscale(0.5);
}

.task-checkbox {
    cursor: pointer;
    min-width: 15px;
    width: 15px;
    height: 15px;
    accent-color: var(--primary-color);
    flex-shrink: 0;
    margin: 0;
}

.task-icon {
    font-size: 1.15rem;
    line-height: 1;
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    text-align: center;
}

/* Smooth unfragmented task text wrapping */
.task-name {
    flex: 1 1 auto;
    min-width: 0;
    overflow-wrap: break-word;
    word-break: normal;
    hyphens: auto;
    font-size: 0.825rem;
    line-height: 1.35;
    color: var(--text-main);
}

.task-must-do-badge {
    color: #d97706;
    font-size: 0.8rem;
    margin-left: 2px;
}

/* Overlay action buttons on hover so they never steal layout width from text */
.task-item-actions {
    position: absolute;
    right: 3px;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(255, 255, 255, 0.96);
    border: 1px solid #d1d5db;
    border-radius: 4px;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.15);
    display: none;
    align-items: center;
    gap: 2px;
    padding: 1px 3px;
    z-index: 5;
}

.time-block li:hover .task-item-actions {
    display: flex;
}

.task-btn-action {
    background: transparent;
    border: none;
    color: #64748b;
    cursor: pointer;
    padding: 2px 4px;
    font-size: 0.75rem;
    border-radius: 3px;
    transition: color 0.15s, background-color 0.15s;
    line-height: 1;
}

.task-btn-action:hover {
    color: var(--primary-color);
    background-color: #E5F4E4;
}

.delete-task-btn:hover {
    color: var(--danger-color) !important;
    background-color: #fee2e2 !important;
}

.day-empty-hint {
    color: #9ca3af;
    font-size: 0.75rem;
    text-align: center;
    font-style: italic;
    margin-top: auto;
    margin-bottom: auto;
    padding: 20px 0;
}

/* --- VIEW 2: Early Reader Picture Routine Board --- */
#earlyReaderView {
    background-color: var(--card-bg);
    padding: 24px;
    border-radius: var(--radius);
    box-shadow: var(--shadow-md);
    border: 1px solid var(--border-color);
}

.reader-board-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 16px;
    margin-bottom: 24px;
    padding-bottom: 16px;
    border-bottom: 2px solid var(--border-color);
}

.reader-header-info h1 {
    margin: 0 0 4px 0;
    font-size: 2rem;
    font-weight: 800;
    color: var(--text-main);
}

.reader-subhead {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 1.05rem;
    color: var(--text-muted);
}

.early-reader-badge {
    background-color: #F9ECE7;
    color: #9C3D2F;
    border: 1px solid #fbcfe8;
    padding: 2px 10px;
    border-radius: 12px;
    font-size: 0.8rem;
    font-weight: 700;
}

.reader-day-selector {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

.reader-day-btn {
    padding: 8px 14px;
    background-color: #f3f4f6;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    font-size: 0.9rem;
    font-weight: 700;
    color: #4b5563;
    cursor: pointer;
    transition: all 0.15s ease;
}

.reader-day-btn:hover {
    background-color: #e5e7eb;
}

.reader-day-btn.active {
    background-color: var(--purple-color);
    color: #ffffff;
    border-color: var(--purple-color);
    box-shadow: 0 2px 6px rgba(124, 58, 237, 0.3);
}

.reader-routine-container {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 20px;
}

.reader-block-card {
    background-color: #ffffff;
    border: 2px solid var(--border-color);
    border-radius: 14px;
    padding: 16px;
    box-shadow: var(--shadow);
    display: flex;
    flex-direction: column;
}

.reader-block-card.time-Morning {
    border-top: 6px solid #f59e0b;
}

.reader-block-card.time-Lunch {
    border-top: 6px solid #10b981;
}

.reader-block-card.time-Afternoon {
    border-top: 6px solid #3F8F69;
}

.reader-block-card.time-Nighttime {
    border-top: 6px solid #6366f1;
}

.reader-block-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 14px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border-color);
}

.reader-block-header h3 {
    margin: 0;
    font-size: 1.2rem;
    font-weight: 800;
    display: flex;
    align-items: center;
    gap: 8px;
}

.reader-block-count {
    font-size: 0.8rem;
    font-weight: 700;
    background: #f1f5f9;
    padding: 2px 8px;
    border-radius: 10px;
    color: #64748b;
}

.reader-task-cards {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.reader-card-item {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 12px 14px;
    background-color: #f8fafc;
    border: 2px solid #e2e8f0;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.2s ease;
    user-select: none;
}

.reader-card-item:hover {
    border-color: var(--primary-color);
    background-color: #E5F4E4;
    transform: translateY(-2px);
    box-shadow: var(--shadow);
}

.reader-card-item.completed {
    background-color: #f0fdf4;
    border-color: #86efac;
    opacity: 0.85;
}

.reader-card-item.completed .reader-task-title {
    text-decoration: line-through;
    color: #15803d;
}

.reader-card-icon {
    font-size: 2.2rem;
    line-height: 1;
    width: 52px;
    height: 52px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #ffffff;
    border-radius: 12px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
    flex-shrink: 0;
}

.reader-card-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.reader-task-title {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--text-main);
    line-height: 1.3;
    overflow-wrap: break-word;
}

.reader-task-tag {
    font-size: 0.75rem;
    color: #d97706;
    font-weight: 700;
    margin-top: 2px;
}

.reader-card-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

.btn-speak {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    border: 1px solid #cbd5e1;
    background: #ffffff;
    font-size: 1.1rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s ease;
}

.btn-speak:hover {
    background: #f1f5f9;
    transform: scale(1.1);
}

.reader-big-check {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    border: 2px solid #94a3b8;
    background: #ffffff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    font-weight: 900;
    color: transparent;
    transition: all 0.15s ease;
    flex-shrink: 0;
}

.reader-card-item.completed .reader-big-check {
    background-color: var(--success-color);
    border-color: var(--success-color);
    color: #ffffff;
}

.reader-empty-msg {
    text-align: center;
    color: #94a3b8;
    padding: 24px 0;
    font-size: 0.95rem;
    font-style: italic;
}

/* --- Modals --- */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 16px;
}

.modal-card {
    background: #ffffff;
    border-radius: 14px;
    width: 100%;
    max-width: 620px;
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--border-color);
    max-height: 85vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.modal-card-sm {
    max-width: 480px;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-color);
}

.modal-header h3 {
    margin: 0;
    font-size: 1.15rem;
    font-weight: 700;
}

.modal-close-btn {
    background: none;
    border: none;
    font-size: 1.2rem;
    color: #64748b;
    cursor: pointer;
    padding: 4px;
    border-radius: 4px;
}

.modal-close-btn:hover {
    color: #0f172a;
    background: #f1f5f9;
}

.modal-body {
    padding: 20px;
    overflow-y: auto;
}

.icon-category-group {
    margin-bottom: 18px;
}

.icon-category-title {
    font-size: 0.85rem;
    font-weight: 700;
    color: #475569;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 8px;
}

.icon-category-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.modal-icon-btn {
    width: 44px;
    height: 44px;
    font-size: 1.5rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: #f8fafc;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.15s ease;
}

.modal-icon-btn:hover {
    background: #e2e8f0;
    transform: scale(1.12);
}

.modal-actions {
    display: flex;
    gap: 10px;
    margin-top: 20px;
    justify-content: flex-end;
}

.delete-modal-actions {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-top: 18px;
}

.delete-modal-actions button {
    width: 100%;
    padding: 10px;
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    border: 0;
}

/* --- Responsive Styles for Mobile Screens --- */
@media screen and (max-width: 900px) {
    .schedule-grid {
        grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
        gap: 12px;
    }

    .form-group.flex-2 {
        grid-column: span 1;
    }

    .day-column {
        min-height: auto;
    }

    .week-navigation-section {
        flex-direction: column;
        align-items: stretch;
    }

    .week-nav-controls, .week-tools {
        justify-content: space-between;
    }

    .schedule-top-bar {
        flex-direction: column;
        align-items: stretch;
        gap: 12px;
    }

    .schedule-top-left {
        justify-content: space-between;
    }
}

@media screen and (max-width: 640px) {
    body {
        padding: 10px;
    }

    .controls {
        padding: 16px 14px;
        margin-bottom: 16px;
    }

    .app-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
    }

    .header-actions {
        width: 100%;
        justify-content: space-between;
    }

    .days-and-time-row {
        flex-direction: column;
        gap: 12px;
    }

    .days-and-time-row .day-selection-section,
    .days-and-time-row .time-selection-section {
        width: 100%;
        flex: 1 1 auto;
    }

    .priority-and-add-row {
        width: 100%;
        justify-content: space-between;
    }

    .schedule-top-left {
        flex-direction: column;
        align-items: stretch;
        gap: 10px;
    }

    .view-mode-toggle {
        display: flex;
        width: 100%;
    }

    .view-mode-toggle .btn-mode {
        flex: 1;
        text-align: center;
        padding: 8px 10px;
    }

    .calendar-date-mode-toggle {
        justify-content: space-between;
        width: 100%;
    }

    .day-chips {
        justify-content: flex-start;
    }

    .day-chip span {
        padding: 7px 12px;
        font-size: 0.8rem;
    }

    #printableArea {
        padding: 16px 12px;
    }

    .schedule-grid {
        grid-template-columns: 1fr;
        gap: 10px;
    }

    .toast-notification {
        top: 10px;
        right: 10px;
        left: 10px;
        max-width: none;
    }
}

@media screen and (max-width: 480px) {
    .priority-and-add-row {
        flex-direction: column;
        align-items: stretch;
        gap: 12px;
    }

    .priority-and-add-row .btn-primary {
        width: 100%;
        padding: 12px;
        font-size: 1rem;
    }

    .day-presets {
        gap: 5px;
    }

    .btn-preset {
        padding: 5px 8px;
        font-size: 0.72rem;
    }

    .family-actions {
        width: 100%;
        justify-content: flex-start;
    }
}

/* --- Dedicated Print Stylesheet --- */
@media print {
    @page {
        size: letter landscape;
        margin: 0.3in;
    }

    body {
        background-color: #ffffff;
        padding: 0;
        margin: 0;
        color: #000000;
    }

    .no-print,
    .controls,
    #printBtn,
    .print-action-bar,
    .task-item-actions,
    .modal-overlay {
        display: none !important;
    }

    .container,
    #printableArea,
    #earlyReaderView {
        max-width: 100%;
        margin: 0;
        padding: 0;
        box-shadow: none;
        border: none;
        background: transparent !important;
    }

    /* Print Weekly Grid View */
    #scheduleHeader {
        margin-bottom: 10px;
        padding-bottom: 6px;
        border-bottom: 2px solid #000;
    }

    #scheduleHeader h1 {
        font-size: 1.6rem;
    }

    #scheduleHeader h2 {
        font-size: 1rem;
        color: #333;
    }

    .schedule-grid {
        display: grid !important;
        grid-template-columns: repeat(7, 1fr) !important;
        gap: 6px !important;
    }

    .day-column {
        background-color: #ffffff !important;
        border: 1px solid #777777 !important;
        padding: 6px 4px !important;
        page-break-inside: avoid;
        min-height: 490px;
    }

    .day-column h3 {
        font-size: 0.85rem;
        padding-bottom: 4px;
        margin-bottom: 6px;
        border-bottom: 1px solid #777;
    }

    .time-block h4 {
        font-size: 0.75rem;
        color: #111;
        margin-bottom: 4px;
    }

    .time-block li {
        background-color: #ffffff !important;
        box-shadow: none !important;
        border: 1px solid #bbbbbb !important;
        padding: 4px 5px !important;
        margin-bottom: 4px !important;
        font-size: 0.78rem !important;
    }

    .task-icon {
        font-size: 1.15rem !important;
    }

    .task-checkbox {
        border: 1px solid #000;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }

    /* Print Early Reader View */
    .reader-routine-container {
        display: grid !important;
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 12px !important;
    }

    .reader-block-card {
        border: 1px solid #666 !important;
        padding: 10px !important;
        page-break-inside: avoid;
    }

    .reader-card-icon {
        font-size: 1.8rem !important;
        width: 42px !important;
        height: 42px !important;
    }

    .btn-speak {
        display: none !important;
    }
}

/* --- Learning Folk Week --- */
.btn-tool-lf { border-color: #2F7D5B; color: #2F7D5B; font-weight: 700; }
.btn-tool-lf:hover { background: #E5F4E4; }
.lf-intro { margin: 0 0 1rem; color: #4b5563; }
.lf-fieldset { border: 1px solid #e5e7eb; border-radius: 12px; padding: 0.75rem 1rem; margin: 0 0 1rem; }
.lf-fieldset legend { font-weight: 700; padding: 0 0.35rem; }
.lf-members { display: flex; flex-wrap: wrap; gap: 0.5rem 1.25rem; }
.lf-check { display: inline-flex; align-items: center; gap: 0.35rem; font-weight: 600; cursor: pointer; }
.lf-stages { display: grid; gap: 0.4rem; }
.lf-stage { display: flex; gap: 0.6rem; align-items: flex-start; padding: 0.5rem 0.6rem; border-radius: 10px; cursor: pointer; }
.lf-stage:hover { background: #f3f4f6; }
.lf-stage input { margin-top: 0.3rem; }
.lf-stage span { display: flex; flex-direction: column; }
.lf-stage small { color: #6b7280; }
.lf-help { margin: 0.5rem 0 0; font-size: 0.85rem; color: #6b7280; }
.lf-preview { background: #F6F1E7; border-radius: 12px; padding: 0.75rem 1rem; margin-bottom: 1rem; }
.lf-preview-head { font-weight: 700; color: #2F7D5B; margin-bottom: 0.35rem; }
.lf-preview ul { margin: 0; padding-left: 1.1rem; }
.lf-preview li { margin: 0.15rem 0; font-size: 0.92rem; }
.task-open-link { margin-left: 0.4rem; font-size: 0.75rem; color: #2F7D5B; text-decoration: none; white-space: nowrap; }
.reader-open-link { display: inline-block; margin-top: 0.25rem; font-size: 0.9rem; font-weight: 700; color: #2F7D5B; text-decoration: none; }
.task-open-link:hover, .reader-open-link:hover { text-decoration: underline; }

/* --- Learning Folk headings and brand --- */
h1, .header-branding h2 { font-family: Georgia, "Times New Roman", serif; font-weight: 400; }
.lf-family-tag { display: inline-block; margin-left: 0.5rem; font-size: 0.75rem; font-family: "Atkinson Hyperlegible", "Trebuchet MS", sans-serif; color: var(--primary-color); background: var(--primary-light); border-radius: 999px; padding: 2px 10px; vertical-align: 4px; text-decoration: none; }

/* --- Reading stage: words the child can sound out --- */
.stage-select-wrap { display: inline-flex; align-items: center; gap: 0.35rem; font-size: 0.9rem; color: var(--text-muted); white-space: nowrap; }
.stage-select-wrap select { font: inherit; width: auto; max-width: 14rem; padding: 2px 6px; border-radius: 6px; border: 1px solid var(--border-color); background: #fff; }
.reader-legend { margin: 0.25rem 0 0; font-size: 0.95rem; color: var(--text-muted); }
.reader-legend .rw-ok { font-weight: 700; color: var(--text-main); }
.rw-ok { color: var(--text-main); font-weight: 700; }
.rw-hard { color: #8A8478; font-weight: 400; border-bottom: 2px dotted #C9C2B6; cursor: pointer; background: none; border-top: none; border-left: none; border-right: none; padding: 0; font: inherit; }
.rw-hard:hover, .rw-hard:focus-visible { color: var(--text-main); outline: none; border-bottom-color: var(--primary-color); }
.reader-card-sub { font-size: 0.8rem; color: var(--text-muted); margin-top: 2px; }
.reader-check { font-size: 0.85rem; margin-top: 6px; color: var(--text-muted); }
.reader-check b { color: var(--danger-color); }
.reader-check.ok { color: var(--primary-color); }
@media print { .rw-hard { color: #555; border-bottom: none; } }
