/* All Hands - Main Stylesheet v1.20 */

:root {
    --bg-primary: #F7E8DC;
    --text-primary: #2E2C2C;
    --accent-red: #E48E63;
    --accent-blue: #89A2B6;
    --accent-blue-light: #BBCFEC;
    --accent-yellow: #E7CB5A;
    --accent-pink: #F5C9C6;
    --white: #FFFFFF;
    --gray-light: #E5E5E5;
    --gray-medium: #9CA3AF;
    --text-8: rgba(46, 44, 44, 0.04);
    --text-16: rgba(46, 44, 44, 0.16);
}

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

body {
    font-family: 'Figtree', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.5;
}

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

/* ==========================================
   HEADER
   ========================================== */

.header {
    text-align: left;
    padding: 16px 0 16px 0;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    border-bottom: 1px solid rgba(46, 44, 44, 0.12);
    margin-bottom: 24px;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 12px;
    height: 48px;
}

.app-title {
    display: none;
}

.app-icon {
    height: 100%;
    width: auto;
    flex-shrink: 0;
}

.settings-btn {
    width: 48px !important;
    height: 48px !important;
    min-height: 48px !important;
    background: var(--text-8);
    border: none;
    padding: 0 !important;
    cursor: pointer;
    color: var(--text-primary);
    transition: all 0.2s;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.settings-btn:hover {
    background: var(--text-16);
}

.settings-btn svg {
    width: 24px;
    height: 24px;
}

/* ==========================================
   AUTH SCREEN
   ========================================== */

.auth-screen {
    background: transparent;
    border-radius: 0;
    padding: 0;
    box-shadow: none;
    margin: 0;
    height: 100vh;
    height: 100dvh;
    display: block;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    overflow: hidden;
}

.auth-screen::before {
    content: '';
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 60%;
    max-height: 60%;
    background-image: url('allhands-splash-background.png');
    background-size: 100% 100%;
    background-position: bottom center;
    background-repeat: no-repeat;
    z-index: 0;
}

.auth-logo-container {
    width: 64%;
    max-width: 450px;
    margin: 60px auto 0;
    position: relative;
    z-index: 1;
}

.auth-logo {
    width: 100%;
    height: auto;
    display: block;
}

.auth-spacer {
    display: none;
}

.auth-buttons-container {
    width: 100%;
    max-width: 600px;
    padding: 0 20px;
    padding-bottom: max(24px, env(safe-area-inset-bottom, 0px) + 12px);
    position: fixed;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    z-index: 1;
}

.auth-screen h2 {
    display: none;
}

.auth-toggle {
    text-align: center;
    margin-top: 16px;
    font-size: 15px;
    color: var(--text-primary);
    font-weight: 400;
}

.auth-toggle a {
    color: var(--text-primary);
    text-decoration: underline;
    cursor: pointer;
    font-weight: 600;
    margin-left: 4px;
}

.auth-toggle a:hover {
    opacity: 0.7;
}

.auth-toggle-separator {
    color: var(--text-primary);
}

.google-signin-btn {
    width: 100%;
    min-height: 72px;
    padding: 20px;
    background: white;
    color: var(--text-primary);
    border: none;
    border-radius: 999px;
    font-size: 18px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    transition: opacity 0.2s;
    margin-bottom: 16px;
}

.google-signin-btn:hover {
    opacity: 0.9;
}

.email-signin-btn {
    width: 100%;
    min-height: 72px;
    padding: 20px;
    background: var(--text-primary);
    color: white;
    border: none;
    border-radius: 999px;
    font-size: 18px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: opacity 0.2s;
    margin-bottom: 24px;
}

.email-signin-btn:hover {
    opacity: 0.9;
}

.google-icon {
    width: 24px;
    height: 24px;
}

/* ==========================================
   FORMS
   ========================================== */

.form-group {
    margin-bottom: 20px;
}

.form-group-with-add {
    display: flex;
    gap: 8px;
    align-items: flex-end;
}

.form-group-with-add select {
    flex: 1;
}

label {
    display: block;
    font-size: 14px;
    font-weight: 500;
    margin-bottom: 8px;
    color: var(--text-primary);
}

input, select, textarea {
    width: 100%;
    padding: 18px 16px;
    min-height: 64px;
    height: 64px;
    border: 1px solid var(--text-16);
    border-radius: 8px;
    font-size: 16px;
    font-family: inherit;
    background: transparent;
    color: var(--text-primary);
    max-width: 100%;
    box-sizing: border-box;
}

select {
    height: 64px !important;
    min-height: 64px !important;
    line-height: normal;
}

input::placeholder, textarea::placeholder {
    color: var(--text-primary);
    opacity: 0.64;
}

input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--accent-blue);
}

input[type="datetime-local"] {
    padding: 18px 48px 18px 16px;
    min-height: 64px;
    max-height: 64px;
    height: 64px;
    text-align: left !important;
    width: 100%;
    -webkit-appearance: none;
    appearance: none;
}

input[type="datetime-local"]::-webkit-calendar-picker-indicator {
    opacity: 0;
    cursor: pointer;
    position: absolute;
    right: 0;
    width: 48px;
    height: 100%;
}

/* Yes/No Button Groups */
.yes-no-group {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

.yes-no-button {
    min-height: 64px;
    height: 64px;
    border: 1px solid var(--text-16);
    border-radius: 8px;
    background: transparent;
    color: var(--text-primary);
    font-size: 16px;
    font-weight: 500;
    font-family: inherit;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: flex-start;
    padding: 0 24px;
    gap: 16px;
    transition: all 0.2s;
}

.yes-no-button:hover {
    border-color: var(--accent-blue);
}

.yes-no-button .radio-circle {
    width: 12px;
    height: 12px;
    border: 2px solid var(--text-16);
    border-radius: 50%;
    flex-shrink: 0;
    position: relative;
    transition: all 0.2s;
}

.yes-no-button.selected {
    border-color: var(--text-primary);
}

.yes-no-button.selected .radio-circle {
    border-color: var(--text-primary);
    background: var(--text-primary);
}

input[type="datetime-local"]::-webkit-datetime-edit {
    text-align: left !important;
    padding-left: 0;
}

input[type="datetime-local"]::-webkit-datetime-edit-fields-wrapper {
    text-align: left !important;
}

.datetime-wrapper {
    position: relative;
    width: 100%;
}

.datetime-icon {
    position: absolute;
    right: 16px;
    top: 50%;
    transform: translateY(-50%);
    pointer-events: none;
    color: var(--text-primary);
}

textarea {
    height: auto;
    min-height: 120px;
    resize: vertical;
}

/* ==========================================
   BUTTONS
   ========================================== */

button {
    width: 100%;
    padding: 28px 20px;
    min-height: 96px;
    background: var(--text-primary);
    color: var(--white);
    border: none;
    border-radius: 999px;
    font-size: 16px;
    font-weight: 500;
    cursor: pointer;
    transition: opacity 0.2s;
}

button:hover {
    opacity: 0.9;
}

button:disabled {
    background: var(--gray-medium);
    cursor: not-allowed;
    opacity: 0.6;
}

.secondary-btn {
    background: transparent;
    color: var(--text-primary);
    border: 1px solid var(--text-16);
}

.secondary-btn:hover {
    background: var(--text-8);
}

.add-custom-btn-small {
    width: 64px;
    height: 64px;
    min-height: 64px;
    padding: 0;
    background: var(--text-8);
    color: var(--text-primary);
    border: none;
    border-radius: 8px;
    font-size: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    cursor: pointer;
}

.add-custom-btn-small:hover {
    background: var(--text-16);
}

.back-button {
    display: flex;
    align-items: center;
    gap: 8px;
    background: transparent;
    border: none;
    padding: 16px 0 24px 0;
    margin-bottom: 0;
    cursor: pointer;
    color: var(--text-primary);
    font-size: 15px;
    font-weight: 500;
    min-height: auto;
    width: auto;
}

.back-button:hover {
    opacity: 0.7;
}

/* ==========================================
   MAIN APP
   ========================================== */

.main-app {
    display: none;
    padding: 0 20px 20px 20px;
}

/* Make the main app header full-bleed to match the insights header */
#mainApp > .header {
    margin-left: -20px;
    margin-right: -20px;
    padding-left: 20px;
    padding-right: 20px;
}

#mainApp {
    padding-bottom: calc(160px + env(safe-area-inset-bottom, 0px));
}

/* ==========================================
   STATS CARD
   ========================================== */

.stats-card {
    background: var(--text-8);
    border-radius: 12px 12px 0 0;
    padding: 48px;
    margin-top: 12px;
    margin-bottom: 0;
    box-shadow: none;
}

.stats-cta {
    background: var(--text-8);
    border-radius: 0 0 12px 12px;
    padding: 24px;
    margin-bottom: 16px;
    box-shadow: none;
    border-top: 1px solid rgba(46, 44, 44, 0.08);
    border-left: none;
    border-right: none;
    border-bottom: none;
    display: flex;
    align-items: center;
    justify-content: space-between;
    cursor: pointer;
    transition: opacity 0.2s;
    width: 100%;
    text-align: left;
    min-height: auto;
}

.stats-cta:hover {
    opacity: 0.7;
}

.stats-grid {
    display: flex;
    justify-content: space-between;
    gap: 24px;
}

.stat-item {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-direction: column;
}

.stat-number {
    font-size: 80px;
    font-weight: 600;
    color: var(--text-primary);
    line-height: 1;
}

.stat-label {
    font-size: 14px;
    color: rgba(46, 44, 44, 0.48);
    text-align: center;
    line-height: 1.4;
    white-space: nowrap;
}

.insights-cta {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 0;
    background: transparent !important;
    min-height: auto !important;
    cursor: pointer;
    transition: opacity 0.2s;
    border-radius: 0 !important;
    justify-content: space-between;
    border: none;
}

.insights-cta:hover {
    opacity: 0.7;
}

.insights-cta-left {
    display: flex;
    align-items: center;
    gap: 8px;
}

.insights-cta-dot {
    width: 8px;
    height: 8px;
    background: var(--accent-red);
    border-radius: 50%;
    flex-shrink: 0;
}

.insights-cta-text {
    font-size: 15px;
    font-weight: 500;
    color: var(--text-primary);
}

.insights-cta-arrow {
    color: var(--text-primary);
    width: 20px;
    height: 20px;
}

/* ==========================================
   NAVIGATION BUTTONS
   ========================================== */

.nav-buttons {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-bottom: 24px;
}

.nav-button {
    padding: 24px;
    min-height: 96px;
    border-radius: 12px;
    font-size: 15px;
    font-weight: 500;
    color: var(--text-primary);
    cursor: pointer;
    transition: all 0.2s;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    line-height: 1.2;
}

.nav-button-text {
    display: inline;
}

.nav-button.active {
    background: var(--accent-blue-light);
    color: var(--text-primary);
}

.nav-button:not(.active) {
    background: transparent;
    color: var(--text-primary);
    border: 1px solid var(--text-16);
}

.nav-button:not(.active):hover {
    opacity: 0.8;
}

.nav-button-dot {
    display: none;
}

.nav-button-icon {
    display: none;
    width: 12px;
    height: 12px;
    background: var(--accent-red);
    border-radius: 50%;
    flex-shrink: 0;
}

/* ==========================================
   CARDS & INCIDENTS
   ========================================== */

.card {
    background: transparent;
    border-radius: 12px;
    padding: 0;
    margin-bottom: 20px;
    box-shadow: none;
}

.card h3 {
    font-size: 20px;
    font-weight: 600;
    margin-bottom: 20px;
    color: var(--text-primary);
}

.incident-item {
    background: var(--text-8);
    border-radius: 12px;
    margin-bottom: 12px;
    box-shadow: none;
    overflow: hidden;
}

.incident-item:hover {
    box-shadow: none;
}

.incident-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px;
    border-bottom: 1px solid rgba(46, 44, 44, 0.12);
}

.incident-content {
    padding: 20px;
}

.incident-time-with-dot {
    display: flex;
    align-items: center;
    gap: 8px;
}

.incident-time-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}

.incident-time {
    font-size: 15px;
    color: var(--text-primary);
    font-weight: 500;
}

.incident-notes {
    font-size: 14px;
    color: var(--text-primary);
    line-height: 1.6;
    margin-bottom: 4px;
}

.incident-details {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 12px;
}

.incident-tag {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 6px 12px;
    border-radius: 4px;
    font-size: 13px;
    font-weight: 500;
    background: transparent;
    border: 1px solid rgba(46, 44, 44, 0.12);
    color: var(--text-primary);
}

/* Event Type Badge */
.event-type-badge {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 6px 12px;
    border-radius: 4px;
    font-size: 13px;
    font-weight: 500;
    border: 1px solid rgba(46, 44, 44, 0.12);
    color: var(--text-primary);
    white-space: nowrap;
}

.badge-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}

/* Event Dots for Calendar */
.event-dots {
    position: absolute;
    bottom: 4px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 2px;
}

.event-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    display: inline-block;
}

.empty-state {
    text-align: center;
    padding: 40px 20px;
    color: var(--gray-medium);
}

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

.incident-edit-btn, .incident-delete-btn {
    padding: 0;
    width: 24px;
    height: 24px;
    min-height: 24px;
    background: transparent;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-primary);
}

.incident-edit-btn:hover, .incident-delete-btn:hover {
    opacity: 0.7;
}

/* ==========================================
   MESSAGES
   ========================================== */

.error-message {
    background: #fee2e2;
    color: #991b1b;
    padding: 12px;
    border-radius: 8px;
    margin-bottom: 16px;
    font-size: 14px;
}

.success-message {
    background: linear-gradient(135deg, rgba(245, 201, 198, 0.3) 0%, rgba(137, 162, 182, 0.2) 100%);
    color: var(--text-primary);
    padding: 16px 20px;
    border-radius: 8px;
    margin-top: 16px;
    margin-bottom: 0;
    font-size: 15px;
    font-weight: 500;
    text-align: center;
    border: 1px solid rgba(137, 162, 182, 0.3);
}

/* ==========================================
   CALENDAR
   ========================================== */

.calendar-view {
    /* Controlled by hidden class */
}

.calendar-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.calendar-nav-btn {
    width: auto;
    min-height: 48px;
    padding: 0;
    background: transparent;
    color: var(--text-primary);
    border: none;
    border-radius: 8px;
}

.calendar-nav-btn:hover {
    background: var(--bg-primary);
}

.calendar-month {
    font-weight: 500;
    font-size: 16px;
}

.calendar-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 8px;
    position: relative;
    margin-left: -20px;
    margin-right: -20px;
    margin-bottom: -20px;
    padding-left: 20px;
    padding-right: 20px;
    padding-bottom: 20px;
}

#calendarMode {
    position: relative;
}

.calendar-day {
    aspect-ratio: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 400;
    position: relative;
    cursor: pointer;
    transition: all 0.2s;
    background: transparent;
}

.calendar-day:hover {
    background: rgba(46, 44, 44, 0.04);
}

.calendar-day.has-incident {
    font-weight: 400;
}

.calendar-day.today {
    background: var(--white);
    font-weight: 600;
}

.calendar-day.selected {
    background: transparent;
    border: 1px solid rgba(46, 44, 44, 0.08);
}

/* Keep today white even when selected */
.calendar-day.today.selected {
    background: var(--white);
}

.day-header {
    font-weight: 600;
    font-size: 14px;
    color: var(--gray-medium);
    cursor: default;
    background: transparent;
}

.day-header:hover {
    background: transparent;
}

.calendar-day.empty {
    cursor: default;
}

.calendar-day.empty:hover {
    background: transparent;
}

.day-incidents {
    margin-top: 20px;
    padding-top: 20px;
    border-top: 1px solid var(--gray-light);
}

.day-incidents h4 {
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 16px;
    color: var(--text-primary);
}

/* ==========================================
   FILTERS
   ========================================== */

.filters-section {
    background: transparent;
    border: 1px solid rgba(46, 44, 44, 0.12);
    border-radius: 12px;
    padding: 16px 20px;
    margin-bottom: 20px;
    box-shadow: none;
    cursor: pointer;
}

.filters-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0;
    cursor: pointer;
    user-select: none;
}

.filters-title {
    font-weight: 600;
    font-size: 16px;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 8px;
}

.filter-indicator {
    width: 8px;
    height: 8px;
    background: var(--accent-yellow);
    border-radius: 50%;
    display: none;
}

.filters-toggle {
    width: 20px;
    height: 20px;
    color: var(--text-primary);
    transition: transform 0.2s;
    flex-shrink: 0;
}

.filters-toggle.expanded {
    transform: rotate(180deg);
}

.filters-content {
    padding-top: 20px;
    display: none;
}

.filters-content.expanded {
    display: block;
}

.reset-filters-btn {
    padding: 14px 32px;
    min-height: 48px;
    background: transparent;
    color: var(--accent-red);
    border: 1px solid var(--accent-red);
    border-radius: 999px;
    font-size: 15px;
    cursor: pointer;
    width: 100%;
    font-weight: 500;
    margin-top: 20px;
}

.reset-filters-btn:hover {
    background: rgba(228, 142, 99, 0.05);
}

.history-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 20px;
    border-bottom: 1px solid rgba(46, 44, 44, 0.12);
}

.history-header h3 {
    margin: 0;
}

.view-mode-toggle {
    display: flex;
    gap: 8px;
}

.view-mode-btn {
    width: 48px;
    height: 48px;
    min-height: 48px;
    padding: 8px;
    background: transparent;
    border: 1px solid rgba(46, 44, 44, 0.08);
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-primary);
    transition: all 0.2s;
}

.view-mode-btn:hover {
    background: rgba(46, 44, 44, 0.04);
}

.view-mode-btn.active {
    background: rgba(46, 44, 44, 0.08);
    border-color: transparent;
}

.filter-group {
    margin-bottom: 20px;
}

.filter-group:last-child {
    margin-bottom: 0;
}

.filter-label {
    display: block;
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 12px;
}

.filter-checkboxes {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.filter-pill {
    position: relative;
}

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

.filter-pill label {
    display: inline-block;
    padding: 6px 14px;
    background: transparent;
    border: 1px solid rgba(46, 44, 44, 0.12);
    border-radius: 4px;
    font-size: 14px;
    font-weight: 400;
    color: var(--text-primary);
    cursor: pointer;
    transition: all 0.2s;
    margin: 0;
}

.filter-pill input[type="checkbox"]:checked + label {
    background: #F3AB88;
    border-color: #F3AB88;
    font-weight: 500;
}

.filter-pill label:hover {
    opacity: 0.8;
}

/* ==========================================
   CHILD AVATARS
   ========================================== */

.child-avatar {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    object-fit: cover;
    display: inline-block;
    vertical-align: middle;
    margin-right: 6px;
}

.child-avatar-dropdown {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    object-fit: cover;
    margin-right: 8px;
    vertical-align: middle;
}

.child-avatar-placeholder {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #F5D039;
    color: white;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    font-weight: 600;
    margin-right: 6px;
    vertical-align: middle;
}

/* ==========================================
   MODALS
   ========================================== */

.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal-content {
    background: white;
    border-radius: 12px;
    padding: 32px;
    max-width: 400px;
    width: 90%;
    box-shadow: none;
}

.modal-content-wide {
    max-width: 560px;
    max-height: 90vh;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

.modal-title {
    font-size: 20px;
    font-weight: 600;
    margin-bottom: 24px;
    color: var(--text-primary);
}

.avatar-upload {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
    margin-bottom: 20px;
}

.avatar-preview {
    width: 100px;
    height: 100px;
    border-radius: 50%;
    object-fit: cover;
    border: 3px solid var(--gray-light);
}

.avatar-preview-placeholder {
    width: 100px;
    height: 100px;
    border-radius: 50%;
    border: 3px dashed var(--gray-light);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--gray-medium);
    font-size: 14px;
}

.avatar-upload-label {
    cursor: pointer;
    display: block;
    transition: opacity 0.2s;
}

.avatar-upload-label:hover {
    opacity: 0.8;
}

.avatar-upload-label:hover .avatar-preview-placeholder {
    border-color: var(--accent-coral);
}

.avatar-upload-label .avatar-preview {
    width: 100px;
    height: 100px;
    border-radius: 50%;
    object-fit: cover;
    border: 3px solid var(--gray-light);
}

.avatar-upload-label:hover .avatar-preview {
    border-color: var(--accent-coral);
}

.file-input-wrapper {
    position: relative;
}

.file-input-wrapper input[type="file"] {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
}

.file-input-label {
    padding: 12px 24px;
    background: transparent;
    color: var(--accent-red);
    border: 1px solid var(--accent-red);
    border-radius: 8px;
    font-size: 14px;
    cursor: pointer;
    display: inline-block;
    transition: all 0.2s;
}

.file-input-label:hover {
    background: rgba(228, 142, 99, 0.1);
}

.modal-buttons {
    display: flex;
    gap: 12px;
    margin-top: 24px;
}

.modal-button {
    flex: 1;
    padding: 14px 20px;
    min-height: 48px;
    border-radius: 8px;
    font-size: 15px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.modal-button-primary {
    background: var(--text-primary);
    color: white;
    border: none;
}

.modal-button-secondary {
    background: transparent;
    color: var(--text-primary);
    border: 1px solid var(--gray-light);
}

.modal-button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* ==========================================
   SETTINGS PAGE
   ========================================== */

#settingsView {
    padding: 0 20px 160px 20px;
}

#settingsView > .header {
    margin-left: -20px;
    margin-right: -20px;
    padding-left: 20px;
    padding-right: 20px;
}

.settings-section {
    background: transparent;
    border-radius: 0;
    padding-top: 8px;
    padding-bottom: 8px;
    margin-bottom: 0;
    border-top: 1px solid rgba(46, 44, 44, 0.12);
}

.settings-section--first {
    border-top: none;
}


.settings-section-title {
    font-size: 18px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 0;
    padding: 20px 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
    user-select: none;
}

.settings-section-arrow {
    width: 20px;
    height: 20px;
    color: var(--text-primary);
    transition: transform 0.2s;
    flex-shrink: 0;
    transform: rotate(180deg);
}

.settings-section-arrow.collapsed {
    transform: rotate(0deg);
}

.settings-section-content {
    padding-bottom: 20px;
}

.settings-section-content.collapsed {
    display: none;
}

.settings-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 0;
    border-bottom: 1px solid var(--gray-light);
}

.settings-row:last-child {
    border-bottom: none;
}

.settings-row-label {
    font-size: 15px;
    color: var(--text-primary);
}

.settings-row-value {
    font-size: 15px;
    color: var(--text-primary);
}

.settings-button {
    padding: 24px !important;
    min-height: 40px !important;
    height: auto !important;
    background: transparent;
    border: 1px dashed rgba(46, 44, 44, 0.24);
    border-radius: 8px;
    font-size: 14px;
    color: var(--text-primary);
    cursor: pointer;
    font-weight: 500;
    transition: all 0.2s;
}

.settings-button:hover {
    background: rgba(46, 44, 44, 0.04);
}

.settings-button.danger {
    border-color: var(--accent-red);
    color: var(--accent-red);
}

.settings-button.danger:hover {
    background: rgba(228, 142, 99, 0.05);
}

.child-card {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 16px;
    background: var(--white);
    border-radius: 12px;
    margin-bottom: 8px;
    cursor: grab;
    transition: all 0.2s;
}

.child-card:active {
    cursor: grabbing;
}

.child-card.dragging {
    opacity: 0.5;
    cursor: grabbing;
}

.child-card.drag-over {
    border: 2px dashed var(--accent-blue);
}

.child-card:last-child {
    margin-bottom: 0;
}

.child-card-drag-handle {
    width: 24px;
    height: 24px;
    color: var(--gray-medium);
    cursor: grab;
    flex-shrink: 0;
    order: 3;
    margin-left: auto;
}

.child-card-drag-handle:active {
    cursor: grabbing;
}

.child-card-avatar {
    order: 0;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    object-fit: cover;
    background: var(--yellow);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    flex-shrink: 0;
}

.child-card-info {
    order: 1;
    flex: 1;
}

.child-card-actions {
    order: 2;
    display: flex;
    gap: 0px;
}

.child-card-name {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 4px;
}

.child-card-stats {
    font-size: 13px;
    color: var(--gray-medium);
}

.child-card-role {
    font-size: 13px;
    color: var(--gray-medium);
}

.icon-button {
    width: 48px !important;
    height: 48px !important;
    min-height: 48px !important;
    padding: 8px !important;
    background: transparent;
    border: 1px solid transparent;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-primary);
    transition: all 0.2s;
}

.icon-button:hover {
    background: rgba(46, 44, 44, 0.04);
    border-color: rgba(46, 44, 44, 0.08);
}

.custom-option-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    background: var(--white);
    border-radius: 8px;
    margin-bottom: 8px;
    cursor: grab;
    transition: all 0.2s;
}

.custom-option-item:active {
    cursor: grabbing;
}

.custom-option-item.dragging {
    opacity: 0.5;
    cursor: grabbing;
}

.custom-option-item.drag-over {
    border: 2px dashed var(--accent-blue);
}

.custom-option-item:last-child {
    margin-bottom: 0;
}

.custom-option-left {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 1;
}

.custom-option-drag-handle {
    width: 20px;
    height: 20px;
    color: var(--gray-medium);
    cursor: grab;
    flex-shrink: 0;
    margin-left: 16px;
}

.custom-option-drag-handle:active {
    cursor: grabbing;
}

.custom-option-name {
    font-size: 15px;
    color: var(--text-primary);
}

.custom-option-usage {
    font-size: 13px;
    color: var(--gray-medium);
    margin-left: 8px;
}

/* ==========================================
   PREFERENCES
   ========================================== */

.preference-row {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 16px 0;
}

.preference-row:last-child {
    border-bottom: none;
}

.preference-label {
    font-size: 14px;
    font-weight: 500;
    color: var(--text-primary);
}

.preference-toggle-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 0;
    border-bottom: 1px solid var(--gray-light);
}

.preference-toggle-row:last-child {
    border-bottom: none;
}

.toggle-switch {
    position: relative;
    display: inline-block;
    width: 48px;
    height: 28px;
}

.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: var(--gray-light);
    transition: .3s;
    border-radius: 28px;
}

.toggle-slider:before {
    position: absolute;
    content: "";
    height: 20px;
    width: 20px;
    left: 4px;
    bottom: 4px;
    background-color: white;
    transition: .3s;
    border-radius: 50%;
}

input:checked + .toggle-slider {
    background-color: var(--accent-blue);
}

input:checked + .toggle-slider:before {
    transform: translateX(20px);
}

.select-input {
    padding: 10px 16px;
    background: var(--bg-primary);
    border: 1px solid rgba(46, 44, 44, 0.1);
    border-radius: 8px;
    font-size: 15px;
    color: var(--text-primary);
    cursor: pointer;
}

/* ==========================================
   CUSTOM SELECTORS
   ========================================== */

.child-selector-wrapper {
    position: relative;
    width: 100%;
    overflow: visible;
}

.custom-selector-wrapper {
    position: relative;
    width: 100%;
    overflow: visible;
}

.custom-selector-display {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 18px 16px;
    background: transparent;
    border: 1px solid var(--text-16);
    border-radius: 8px;
    cursor: pointer;
    min-height: 64px;
    transition: all 0.2s;
}

.custom-selector-display:hover {
    border-color: var(--text-16);
}

.custom-selector-display.open {
    border-color: var(--accent-blue);
}

.custom-selector-name {
    flex: 1;
    font-size: 16px;
    color: var(--text-primary);
}

.custom-selector-name.placeholder {
    color: var(--text-primary);
    opacity: 0.64;
}

.custom-selector-arrow {
    width: 20px;
    height: 20px;
    color: var(--text-primary);
    transition: transform 0.2s;
    flex-shrink: 0;
}

.custom-selector-display.open .custom-selector-arrow {
    transform: rotate(180deg);
}

.custom-selector-dropdown {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    right: 0;
    background: var(--white);
    border: 1px solid rgba(46, 44, 44, 0.2);
    border-radius: 8px;
    box-shadow: none;
    max-height: 240px;
    overflow-y: auto;
    z-index: 10000;
    display: none;
}

.custom-selector-dropdown.open {
    display: block;
}

.custom-selector-option {
    padding: 12px 16px;
    cursor: pointer;
    transition: background 0.2s;
    font-size: 16px;
    color: var(--text-primary);
}

.custom-selector-option:hover {
    background: var(--bg-primary);
}

.custom-selector-option.selected {
    background: rgba(137, 162, 182, 0.1);
}

/* Child selector with avatars */
.child-selector-display {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 16px;
    background: transparent;
    border: 1px solid var(--text-16);
    border-radius: 8px;
    cursor: pointer;
    min-height: 64px;
    transition: all 0.2s;
}

.child-selector-display:hover {
    border-color: var(--text-16);
}

.child-selector-display.open {
    border-color: var(--accent-blue);
}

.child-selector-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    object-fit: cover;
    background: #F5D039;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    flex-shrink: 0;
    color: white;
    position: relative;
    overflow: hidden;
}

.child-selector-avatar img {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 50%;
    z-index: 1;
}

.child-selector-name {
    flex: 1;
    font-size: 15px;
    color: var(--text-primary);
}

.child-selector-name.placeholder {
    color: var(--gray-medium);
}

.child-selector-arrow {
    width: 20px;
    height: 20px;
    color: var(--text-primary);
    transition: transform 0.2s;
}

.child-selector-display.open .child-selector-arrow {
    transform: rotate(180deg);
}

.child-selector-dropdown {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    right: 0;
    background: var(--white);
    border: 1px solid rgba(46, 44, 44, 0.2);
    border-radius: 8px;
    box-shadow: none;
    z-index: 1000;
    max-height: 240px;
    overflow-y: auto;
    display: none;
}

.child-selector-dropdown.open {
    display: block;
}

.child-selector-option {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    cursor: pointer;
    transition: background 0.2s;
    color: var(--text-primary);
}

.child-selector-option:hover {
    background: var(--bg-primary);
}

.child-selector-option.selected {
    background: rgba(137, 162, 182, 0.1);
}

/* ==========================================
   INSIGHTS v2
   ========================================== */

#insightsView {
    padding: 0 20px 140px 20px;
}

/* Header */
.insights-header {
    padding: 48px 0 8px;
    text-align: center;
    border-top: 1px solid rgba(46, 44, 44, 0.12);
}

.insights-eyebrow {
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 1.5px;
    text-transform: uppercase;
    color: rgba(46, 44, 44, 0.5);
    margin: 0 0 10px;
}

.insights-headline {
    font-size: 26px;
    font-weight: 700;
    line-height: 1.25;
    color: var(--text-primary);
    margin: 0 0 28px;
}

/* Period tabs */
.insights-period-tabs {
    display: flex;
    background: rgba(46, 44, 44, 0.06);
    border-radius: 10px;
    padding: 4px;
    gap: 4px;
    margin-bottom: 28px;
    overflow: hidden;
}

.insights-period-tab {
    flex: 1;
    padding: 9px 0;
    background: transparent;
    border: none;
    border-radius: 7px;
    font-size: 12px;
    font-weight: 500;
    color: rgba(46, 44, 44, 0.55);
    cursor: pointer;
    transition: all 0.2s;
    font-family: inherit;
    white-space: nowrap;
}

.insights-period-tab.active {
    background: rgba(46, 44, 44, 0.08);
    color: var(--text-primary);
    font-weight: 600;
    box-shadow: none;
    border-radius: 12px;
}

/* Section labels — consistent 16px bold across all cards and breakpoints */
.insights-section-label,
.insights-donut-title {
    font-size: 16px !important;
    font-weight: 700 !important;
    font-family: 'Figtree', sans-serif;
    letter-spacing: 0;
    text-transform: none;
    color: var(--text-primary) !important;
    margin: 0 0 10px !important;
    opacity: 1;
}

/* Base card */
.insights-card {
    border-radius: 20px;
    padding: 24px;
    margin-bottom: 40px;
    display: flex;
    flex-direction: column;
    position: relative;
    overflow: hidden;
    background: rgba(46, 44, 44, 0.04);
}

/* ── Group wrappers — each section has its own spacing class ── */
.insights-group {
    margin-bottom: 32px;
}

/* Two-column grid groups — single col on mobile, 2-col at 480px+ */
.insights-group--two-col {
    display: grid;
    grid-template-columns: 1fr;
    gap: 32px;
    margin-bottom: 32px;
}

/* Always 2-col regardless of screen size (short labels fit fine) */
.insights-group--two-col-always {
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

@media (min-width: 480px) {
    .insights-group--two-col {
        grid-template-columns: 1fr 1fr;
        gap: 12px;
    }
}

/* Full-width single card groups */
.insights-group--full {
    margin-bottom: 32px;
}

/* Donut group — tighter bottom since legend sits right below */
.insights-group--donut {
    margin-bottom: 40px;
}

/* By child group */
.insights-group--by-child {
    margin-bottom: 32px;
}

/* Cards within groups have no margin — group controls spacing */
.insights-card {
    border-radius: 20px;
    padding: 24px;
    margin-bottom: 0;
    display: flex;
    flex-direction: column;
    position: relative;
    overflow: hidden;
    background: rgba(46, 44, 44, 0.04);
}

/* Stat cards — square everywhere by default */
.insights-stat-card {
    min-height: unset;
    aspect-ratio: 1 / 1;
    justify-content: space-between;
    background: rgba(46, 44, 44, 0.04); /* fallback; overridden by JS gradient */
}

/* 2col cards on mobile: rectangle with min-height, no square ratio */
.insights-group--two-col-always .insights-stat-card,
.insights-group--two-col .insights-stat-card {
    aspect-ratio: unset;
    min-height: 240px;
}

/* 2col always grid: fixed column min so cards don't get tiny on very small screens */
.insights-group--two-col-always {
    grid-template-columns: minmax(120px, 1fr) minmax(120px, 1fr);
}

@media (min-width: 480px) {
    /* All cards square on desktop */
    .insights-stat-card,
    .insights-group--two-col-always .insights-stat-card,
    .insights-group--two-col .insights-stat-card {
        aspect-ratio: 1 / 1;
        min-height: unset;
    }
}

.insights-stat-value {
    font-size: 40px;
    font-weight: 700;
    line-height: 1.05;
    color: var(--text-primary);
    word-break: break-word;
    margin-top: 0;
}

/* On wider screens, bump back up a bit */
@media (min-width: 480px) {
    .insights-stat-value {
        font-size: 48px;
    }
}

.insights-stat-delta {
    font-size: 13px;
    color: rgba(46, 44, 44, 0.6);
    margin-top: auto;
    padding-top: 16px;
    line-height: 1.3;
}

/* Override global button styles for period tabs and export */
.insights-period-tab,
.insights-export-btn {
    width: auto;
    min-height: unset;
    padding: 24px;
    border-radius: unset;
    background: unset;
    color: unset;
}

/* Donut chart card */
.insights-donut-card {
    background: rgba(46, 44, 44, 0.04);
    padding: 0;
    aspect-ratio: 1 / 1;
    margin-bottom: 16px;
    overflow: hidden;
    border-radius: 20px;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Big bold label above the card */

/* Conic bg fills edge-to-edge */
.donut-bg {
    position: absolute;
    inset: 0;
    border-radius: 20px;
}

/* Center hole */
.donut-hole {
    position: relative;
    z-index: 2;
    width: 62%;
    aspect-ratio: 1 / 1;
    border-radius: 50%;
    background: var(--bg-primary);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 16px;
    box-sizing: border-box;
}

.donut-center-name {
    font-size: 22px;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1.2;
}

.donut-center-delta {
    font-size: 13px;
    color: rgba(46, 44, 44, 0.55);
    margin-top: 8px;
    line-height: 1.3;
}



.donut-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 10px 20px;
    margin-top: 16px;
    margin-bottom: 0;
    padding: 0 2px;
}

.donut-legend-item {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-primary);
}

.donut-legend-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
}

/* By child chart */
.insights-by-child-card {
    background: rgba(46, 44, 44, 0.04);
    padding: 0;
    aspect-ratio: 1 / 1;
    margin-bottom: 0 !important;
    display: flex;
    align-items: stretch;
    position: relative;
    overflow: hidden;
}

.by-child-bars {
    display: flex;
    flex-direction: row;
    align-items: stretch;
    width: 100%;
    height: 100%;
    gap: 0;
    filter: blur(24px);
    transform: scale(1.08);
}

.by-child-col {
    min-width: 0;
}

/* Text layer sits above the blur */
.by-child-labels {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: row;
}

.by-child-label {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding: 24px;
    min-width: 0;
    border-right: 1px solid rgba(247, 232, 220, 0.6);
}

.by-child-label:last-child {
    border-right: none;
}

.by-child-count {
    font-size: 40px;
    font-weight: 700;
    line-height: 1.05;
    color: var(--text-primary);
}

.by-child-name {
    font-size: 13px;
    color: rgba(46, 44, 44, 0.6);
    line-height: 1.3;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Export button */
.insights-export-btn {
    width: 100%;
    padding: 18px;
    background: var(--text-primary);
    color: #fff;
    border: none;
    border-radius: 100px;
    font-size: 16px;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    margin-top: 32px;
    min-height: unset;
    transition: opacity 0.2s;
}

.insights-export-btn:hover {
    opacity: 0.85;
}


/* ==========================================
   TIMER & BREATHING
   ========================================== */

.timer-button {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 128px;
    z-index: 100;
    cursor: pointer;
    transition: all 0.2s;
    overflow: hidden;
}

.timer-button:active {
    transform: scale(0.98);
}

.timer-button-gradient {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-image: url('allhands-app-timer-bg.png');
    background-size: 100% 100%;
    background-repeat: no-repeat;
    background-position: center;
    opacity: 1;
    transition: opacity 0.3s;
}

.timer-button.active .timer-button-gradient {
    opacity: 1;
}

.timer-button-content {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    font-size: 20px;
    font-weight: 600;
    color: var(--text-primary);
    z-index: 1;
}

.timer-button.active .timer-button-content {
    font-size: 32px;
}

#timerDisplay {
    font-variant-numeric: tabular-nums;
}

.breathing-view {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--bg-primary);
    z-index: 10000;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

/* Lava lamp blobs */
.timer-blob {
    position: absolute;
    width: 120vw;
    height: 120vw;
    border-radius: 50%;
    filter: blur(60px);
    opacity: 0.85;
    will-change: transform;
    z-index: 0;
}

@media (min-width: 768px) {
    .timer-blob {
        width: 100vh;
        height: 100vh;
        filter: blur(100px);
        opacity: 0.9;
    }
}

.timer-blob-1 {
    background: #F58B56;
    animation: blob-drift-1 17s ease-in-out infinite;
}

.timer-blob-2 {
    background: #F4AFE4;
    animation: blob-drift-2 23s ease-in-out infinite;
}

.timer-blob-3 {
    background: #E48E63;
    animation: blob-drift-3 19s ease-in-out infinite;
}

.timer-blob-5 {
    background: #E8A0C8;
    animation: blob-drift-5 21s ease-in-out infinite;
}

.timer-blob-4 {
    background: #F58B56;
    animation: blob-drift-4 29s ease-in-out infinite;
}

@keyframes blob-drift-5 {
    0%   { transform: translate(5%, 30%); }
    33%  { transform: translate(-10%, 40%); }
    66%  { transform: translate(15%, 25%); }
    100% { transform: translate(5%, 30%); }
}

@keyframes blob-drift-1 {
    0%   { transform: translate(-15%, -20%); }
    25%  { transform: translate(20%, -10%); }
    50%  { transform: translate(10%, 20%); }
    75%  { transform: translate(-20%, 10%); }
    100% { transform: translate(-15%, -20%); }
}

@keyframes blob-drift-2 {
    0%   { transform: translate(15%, 10%); }
    25%  { transform: translate(-10%, 20%); }
    50%  { transform: translate(-20%, -10%); }
    75%  { transform: translate(15%, -20%); }
    100% { transform: translate(15%, 10%); }
}

@keyframes blob-drift-3 {
    0%   { transform: translate(5%, 20%); }
    33%  { transform: translate(-15%, -10%); }
    66%  { transform: translate(20%, -15%); }
    100% { transform: translate(5%, 20%); }
}

@keyframes blob-drift-4 {
    0%   { transform: translate(-20%, 5%); }
    33%  { transform: translate(10%, 15%); }
    66%  { transform: translate(15%, -20%); }
    100% { transform: translate(-20%, 5%); }
}

.breathing-controls {
    position: absolute;
    top: 20px;
    left: 20px;
    right: 20px;
    display: flex;
    justify-content: space-between;
    z-index: 10002;
}

.breathing-control-btn {
    height: 48px;
    min-height: 48px;
    padding: 0 20px !important;
    border-radius: 12px;
    background: rgba(46, 44, 44, 0.08);
    border: none;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    color: var(--text-primary);
    font-size: 15px;
    font-weight: 500;
    font-family: inherit;
    transition: all 0.2s;
    white-space: nowrap;
    width: auto;
}

.breathing-control-btn:hover {
    background: rgba(46, 44, 44, 0.12);
}

.breathing-control-btn:active {
    transform: scale(0.95);
}

.breathing-paused-controls {
    position: fixed;
    top: 20px;
    left: 20px;
    right: 20px;
    display: flex;
    justify-content: space-between;
    z-index: 10002;
}

.breathing-paused {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
    padding: 40px;
    position: relative;
    z-index: 10001;
}

.breathing-paused-label {
    font-size: 16px;
    font-weight: 600;
    letter-spacing: 2px;
    color: var(--text-primary);
}

.breathing-paused-time {
    font-size: 72px;
    font-weight: 600;
    color: var(--text-primary);
    font-variant-numeric: tabular-nums;
}

.breathing-submit-btn {
    padding: 16px 32px;
    min-height: 48px;
    background: transparent;
    border: 1px solid rgba(46, 44, 44, 0.12);
    border-radius: 12px;
    font-size: 16px;
    font-weight: 500;
    color: var(--text-primary);
    cursor: pointer;
    transition: all 0.2s;
}

.breathing-submit-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(46, 44, 44, 0.2);
}

.breathing-submit-btn:active {
    transform: scale(0.98);
}

.breathing-cancel-btn {
    background: none;
    border: none;
    color: var(--text-primary);
    text-decoration: underline;
    cursor: pointer;
    font-size: 15px;
    padding: 12px;
    min-height: auto;
}

.breathing-cancel-btn:hover {
    opacity: 0.7;
}

.breathing-active {
    display: flex;
    align-items: center;
    justify-content: center;
    flex: 1;
    width: 100%;
    z-index: 10001;
    position: relative;
}

.breathing-circle {
    width: 300px;
    height: 300px;
    border-radius: 50%;
    background: var(--bg-primary);
    position: relative;
    transition: transform 4s cubic-bezier(0.4, 0, 0.2, 1);
}

.breathing-circle.expand {
    transform: scale(1.75);
}

.breathing-circle.contract {
    transform: scale(0.8);
}

.breathing-text {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
    color: var(--text-primary);
    z-index: 10;
    pointer-events: none;
}

.breathing-instruction {
    font-size: 32px;
    font-weight: 600;
    margin-bottom: 8px;
}

.breathing-countdown {
    font-size: 18px;
    font-weight: 500;
    opacity: 0.8;
}

.breathing-patterns {
    position: fixed;
    bottom: 20px;
    left: 20px;
    right: 20px;
    display: flex;
    background: rgba(46, 44, 44, 0.06);
    border-radius: 10px;
    padding: 4px;
    gap: 4px;
    z-index: 10001;
}

.breathing-pattern-btn {
    flex: 1;
    padding: 24px !important;
    min-height: unset !important;
    background: transparent;
    border: none;
    border-radius: 7px;
    font-size: 12px;
    font-weight: 500;
    color: rgba(46, 44, 44, 0.55);
    cursor: pointer;
    transition: all 0.2s;
    font-family: inherit;
    white-space: nowrap;
    width: auto !important;
}

.breathing-pattern-btn.active {
    background: rgba(46, 44, 44, 0.08);
    color: var(--text-primary);
    font-weight: 600;
    border-radius: 7px;
}

/* ==========================================
   UTILITY CLASSES
   ========================================== */

.hidden {
    display: none !important;
}

.logout-btn {
    margin-top: 20px;
    min-height: 96px;
    background: transparent;
    color: var(--accent-red);
    border: 1px solid var(--accent-red);
    border-radius: 999px;
}

.logout-btn:hover {
    background: rgba(228, 142, 99, 0.1);
}

/* ==========================================
   WALKTHROUGH MODAL
   ========================================== */

.walkthrough-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: flex-end;
    justify-content: center;
    z-index: 10000;
    padding: 0 0 24px 0;
}

.walkthrough-modal {
    background: var(--bg-primary);
    border-radius: 24px;
    width: 100%;
    max-width: 600px;
    max-height: 92vh;
    position: relative;
    display: flex;
    flex-direction: column;
    box-shadow: 0 4px 32px rgba(0, 0, 0, 0.2);
    z-index: 10001;
}

.walkthrough-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 24px;
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    z-index: 10;
}

.walkthrough-close {
    width: 48px;
    height: 48px;
    min-height: 48px;
    background: var(--text-8);
    border: none;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-primary);
    padding: 0;
    transition: all 0.2s;
}

.walkthrough-close:hover {
    background: var(--text-16);
}

.walkthrough-progress {
    font-size: 15px;
    color: var(--text-primary);
    font-weight: 400;
}

.walkthrough-slides {
    position: relative;
    overflow: hidden;
    flex: 1;
    display: flex;
    touch-action: pan-y;
}

.walkthrough-slide {
    min-width: 100%;
    display: flex;
    flex-direction: column;
    opacity: 0;
    transform: translateX(100%);
    transition: all 0.3s ease-in-out;
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    height: 100%;
    padding-top: 88px;
}

.walkthrough-slide.active {
    opacity: 1;
    transform: translateX(0);
    position: relative;
}

.walkthrough-slide.prev {
    opacity: 0;
    transform: translateX(-100%);
}

.walkthrough-content-top {
    text-align: center;
    padding: 0 32px 32px 32px;
    background: var(--bg-primary);
}

.walkthrough-content-top h4 {
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 1.5px;
    color: var(--text-primary);
    margin-bottom: 12px;
    line-height: 1;
}

.walkthrough-content-top p {
    font-size: 18px;
    font-weight: 400;
    color: var(--text-primary);
    line-height: 1.4;
}

.walkthrough-image-container {
    width: 100%;
    max-width: 400px;
    aspect-ratio: 1 / 1;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto;
    background: transparent;
    border-radius: 0;
    border: none;
    overflow: hidden;
    position: relative;
}

.walkthrough-placeholder {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    background: var(--white);
    border: 2px dashed var(--text-16);
    border-radius: 16px;
    color: var(--accent-blue);
    opacity: 0.5;
}

.walkthrough-dots {
    display: flex;
    gap: 8px;
    justify-content: center;
    padding: 20px 0 32px;
    background: var(--bg-primary);
    border-radius: 0 0 24px 24px;
}

.walkthrough-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--text-16);
    transition: all 0.3s;
    cursor: pointer;
}

.walkthrough-dot:hover {
    background: rgba(46, 44, 44, 0.32);
    transform: scale(1.2);
}

.walkthrough-dot.active {
    background: var(--accent-blue);
    width: 24px;
    border-radius: 4px;
}


.walkthrough-navigation {
    display: flex;
    gap: 12px;
    padding: 24px;
    background: var(--bg-primary);
    border-top: 1px solid var(--text-16);
}

.walkthrough-nav-btn {
    flex: 1;
    min-height: 56px;
    border-radius: 12px;
    border: 1px solid var(--text-16);
    background: transparent;
    color: var(--text-primary);
    font-size: 16px;
    font-weight: 500;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: all 0.2s;
}

.walkthrough-nav-btn:hover:not(:disabled) {
    background: var(--text-8);
}

.walkthrough-nav-btn:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

.walkthrough-nav-btn.walkthrough-primary {
    background: var(--text-primary);
    color: var(--white);
    border-color: var(--text-primary);
}

.walkthrough-nav-btn.walkthrough-primary:hover {
    opacity: 0.9;
    background: var(--text-primary);
}

/* Swipe gesture support */
@media (hover: none) and (pointer: coarse) {
    .walkthrough-slides {
        scroll-snap-type: x mandatory;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
    }
    
    .walkthrough-slides::-webkit-scrollbar {
        display: none;
    }
}

/* Desktop - larger modal */
@media (min-width: 768px) {
    .walkthrough-overlay {
        align-items: center;
        padding: 0;
    }

    .walkthrough-modal {
        max-height: 80vh;
    }
}

/* ==========================================
   MOBILE RESPONSIVE
   ========================================== */

@media (max-width: 768px) {
    .stats-card {
        padding: 24px;
    }
    
    .stat-item {
        flex: 1;
    }
    
    .calendar-day.has-incident::after {
        width: 6px;
        height: 6px;
        top: 4px;
        right: 4px;
    }
    
    .nav-button {
        min-height: 64px;
    }
    
    .child-card-stats {
        display: none;
    }
    
    .custom-option-usage {
        display: none;
    }
    
    input[type="datetime-local"] {
        text-align: left !important;
    }
    
    input[type="datetime-local"]::-webkit-datetime-edit {
        text-align: left !important;
    }
}

/* ==========================================
   CAREGIVER REFLECTION MODAL
   ========================================== */

.caregiver-modal-overlay {
    z-index: 1100;
    background: rgba(0, 0, 0, 0.6);
}

.caregiver-modal-content {
    text-align: center;
    max-width: 360px;
    padding: 40px 32px 40px;
    border-radius: 20px;
    display: flex;
    flex-direction: column;
}

.caregiver-modal-subtext {
    font-size: 13px;
    color: var(--gray-medium);
    margin: 0 0 8px;
    font-style: italic;
}

.caregiver-modal-heading {
    font-size: 32px;
    font-weight: 700;
    color: var(--text-primary);
    margin: 0 0 32px;
    line-height: 1.15;
}

/* Slider */
.caregiver-slider-wrapper {
    position: relative;
    margin: 0 auto 8px;
    width: 100%;
    height: 60px;
    display: flex;
    align-items: center;
    cursor: grab;
    touch-action: none; /* prevent page scroll while dragging */
    user-select: none;
    -webkit-user-select: none;
}

.caregiver-slider-wrapper:active {
    cursor: grabbing;
}

.caregiver-slider-track-bg {
    position: absolute;
    left: 0;
    right: 0;
    height: 16px;
    border-radius: 8px;
    background: linear-gradient(to right, #E48E63, #E8A0C8);
    pointer-events: none;
}

/* The JS-rendered thumb number overlay */
.caregiver-thumb-number {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: var(--text-primary);
    color: white;
    font-size: 18px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: none;
    z-index: 2;
    box-shadow: none;
    border: none;
    transition: left 0s;
}

.caregiver-descriptor {
    font-size: 20px;
    color: var(--text-primary);
    font-style: italic;
    line-height: 1.4;
    min-height: 56px;
    margin: 16px 0 32px;
    opacity: 0.8;
}

/* Button area — pinned toward bottom */
.caregiver-modal-actions {
    margin-top: auto;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
}

.caregiver-save-btn {
    width: 100%;
    padding: 14px 24px;
    min-height: auto;
    background: var(--text-primary);
    color: white;
    border: none;
    border-radius: 999px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: opacity 0.2s;
    font-family: inherit;
}

.caregiver-save-btn:hover {
    opacity: 0.85;
}

.caregiver-skip-btn {
    background: none;
    border: none;
    min-height: auto;
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 1px;
    color: var(--gray-medium);
    text-decoration: underline;
    cursor: pointer;
    font-family: inherit;
    padding: 0;
    width: auto;
}

/* Prevent body scroll when modal is open */
body.caregiver-modal-open {
    overflow: hidden;
    position: fixed;
    width: 100%;
}

/* ==========================================
   CAREGIVER INSIGHTS CARD
   ========================================== */

/* Synopsis text sits between the title and the card */
.caregiver-synopsis-text {
    font-size: 16px;
    font-weight: 400;
    color: var(--text-primary);
    line-height: 1.45;
    margin: -4px 0 14px;
}

/* The card itself reuses donut-card layout — just override the bg */
.caregiver-donut-card {
    overflow: hidden;
    /* gradient set dynamically by JS */
}

/* Big score number in the hole */
.caregiver-donut-score {
    font-size: 80px;
    font-weight: 800;
    line-height: 1;
    color: var(--text-primary);
}

/* Unregulated / Regulated labels at the bottom of the card */
.caregiver-donut-labels {
    position: absolute;
    bottom: 18px;
    left: 20px;
    right: 20px;
    width: calc(100% - 40px);
    display: flex;
    justify-content: space-between;
    font-size: 13px;
    color: rgba(46, 44, 44, 0.6);
    font-weight: 500;
    pointer-events: none;
    z-index: 3;
}

/* ==========================================
   BOTTOM TAB NAVIGATION (v2)
   ========================================== */

/* Progressive blur overlay above the tab bar */
.bottom-tab-blur {
    position: fixed;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 100%;
    max-width: 576px;
    /* Extend height to cover safe area + nav */
    height: calc(120px + env(safe-area-inset-bottom, 0px));
    pointer-events: none;
    z-index: 499;
    /* Use gradient background instead of backdrop-filter+mask (Safari clips it) */
    background: linear-gradient(to bottom, transparent 0%, var(--bg-primary) 100%);
}

.bottom-tab-nav {
    position: fixed;
    /* Sit 12px above the safe area floor */
    bottom: calc(12px + env(safe-area-inset-bottom, 0px));
    left: 50%;
    transform: translateX(-50%);
    width: calc(100% - 24px);
    max-width: 576px;
    background: #F4AFE4;
    border-radius: 999px;
    display: flex;
    align-items: stretch;
    padding: 4px;
    z-index: 500;
    gap: 4px;
    /* Fix Safari clipping child border-radius */
    -webkit-transform: translateX(-50%);
    isolation: isolate;
}

.bottom-tab-nav.hidden,
.bottom-tab-blur.hidden {
    display: none;
}

/* Animated sliding pill */
.tab-nav-pill {
    position: absolute;
    top: 4px;
    bottom: 4px;
    left: 4px;
    width: 0; /* set dynamically by JS */
    background: rgba(46, 44, 44, 0.08);
    border-radius: 999px;
    transition: transform 0.3s cubic-bezier(0.34, 1.4, 0.64, 1),
                width 0.3s cubic-bezier(0.34, 1.4, 0.64, 1);
    pointer-events: none;
}

.tab-nav-btn {
    flex: 1;
    width: auto;
    min-height: unset;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    padding: 12px 8px;
    border: none;
    background: transparent;
    border-radius: 999px;
    cursor: pointer;
    transition: none;
    font-family: 'Figtree', sans-serif;
    position: relative;
    z-index: 1;
}

.tab-nav-btn:hover {
    background: rgba(46, 44, 44, 0.04);
}

.tab-nav-btn.active {
    background: transparent;
    color: var(--text-primary);
    border-radius: 999px;
}

.tab-nav-icon {
    width: 20px;
    height: 20px;
    opacity: 1;
    transition: opacity 0.15s;
}

/* icon opacity handled by .tab-nav-btn color */

.tab-nav-label {
    font-size: 12px;
    font-weight: 700;
    line-height: 1;
    font-variant-numeric: tabular-nums;
    opacity: 1;
    color: var(--text-primary);
}

.tab-nav-btn.active .tab-nav-label {
    font-weight: 700;
}

/* Timer tab ticker state */
.tab-nav-btn[data-tab="timer"].timer-active .tab-nav-label {
    font-size: 12px;
    font-weight: 700;
    color: var(--text-primary);
}

/* Insights needs bottom padding for tab nav */
#insightsView {
    padding-bottom: calc(120px + env(safe-area-inset-bottom, 0px));
}

/* ==========================================
   PAGE TITLES (new unified system)
   ========================================== */

.page-title {
    font-size: 28px;
    font-weight: 700;
    color: var(--text-primary);
    margin: 0 0 24px 0;
    padding-top: 4px;
    padding-bottom: 12px;
    border-bottom: 1px solid rgba(46, 44, 44, 0.12);
}

/* ==========================================
   HISTORY VIEW MODE TABS (new pill system)
   ========================================== */

.view-mode-tabs {
    display: flex;
    background: rgba(46, 44, 44, 0.06);
    border-radius: 10px;
    padding: 4px;
    gap: 4px;
    margin-bottom: 24px;
}

.view-mode-tab {
    flex: 1;
    width: auto;
    min-height: unset;
    padding: 24px 0;
    background: transparent;
    border: none;
    border-radius: 7px;
    font-size: 13px;
    font-weight: 500;
    color: rgba(46, 44, 44, 0.55);
    cursor: pointer;
    transition: all 0.2s;
    font-family: 'Figtree', sans-serif;
    white-space: nowrap;
}

.view-mode-tab.active {
    background: rgba(46, 44, 44, 0.08);
    color: var(--text-primary);
    font-weight: 600;
    border-radius: 7px;
}

/* ==========================================
   BREATHING PATTERN TABS (new pill system)
   ========================================== */

.breathing-pattern-tab {
    flex: 1;
    width: auto;
    min-height: unset;
    padding: 24px 0;
    background: transparent;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    color: rgba(46, 44, 44, 0.55);
    cursor: pointer;
    transition: all 0.2s;
    font-family: 'Figtree', sans-serif;
    white-space: nowrap;
}

.breathing-pattern-tab.active {
    background: rgba(46, 44, 44, 0.12);
    color: var(--text-primary);
    font-weight: 600;
}

/* Keep the .breathing-patterns wrapper working for both old and new */
.breathing-patterns {
    display: flex;
    gap: 8px;
}

/* ==========================================
   INCIDENT ITEMS — white cards
   ========================================== */

.incident-item {
    background: var(--white) !important;
}

/* ==========================================
   INSIGHTS VIEW — simplified header
   ========================================== */

#insightsView > .header {
    margin-left: -20px;
    margin-right: -20px;
    padding-left: 20px;
    padding-right: 20px;
}

/* Period tabs already handle spacing */
#insightsView .insights-period-tabs {
    margin-bottom: 24px;
}

/* ==========================================
   HIDE NAV BAR in fullscreen views
   ========================================== */

body.view-settings .bottom-tab-nav,
body.view-settings .bottom-tab-blur,
body.view-breathing .bottom-tab-nav,
body.view-breathing .bottom-tab-blur,
body.view-auth .bottom-tab-nav,
body.view-auth .bottom-tab-blur,
body:not(.nav-ready) .bottom-tab-nav,
body:not(.nav-ready) .bottom-tab-blur {
    display: none;
}


/* ─── PWA Standalone Mode ─────────────────────────────────────────────────────
   When launched from home screen, env(safe-area-inset-bottom) can return 0
   even when a home indicator exists. Use a guaranteed minimum of 20px. */
@media (display-mode: standalone) {
    .bottom-tab-nav {
        bottom: calc(12px + env(safe-area-inset-bottom, 20px));
    }
    .bottom-tab-blur {
        height: calc(120px + env(safe-area-inset-bottom, 20px));
    }
    #mainApp {
        padding-bottom: calc(160px + env(safe-area-inset-bottom, 20px));
    }
    #insightsView {
        padding-bottom: calc(120px + env(safe-area-inset-bottom, 20px));
    }
}
