/*
 * Gardening Journal - Site-Wide CSS
 *
 * Design principles:
 * - Mobile-first responsive design
 * - iOS-style photo grid with natural aspect ratios
 * - TurboTax-style centered dialogs for simple screens
 * - Optimal line length (50-75 chars) for notes
 * - Light and dark mode support
 */

/* ==========================================================================
   CSS Variables - Color Palette
   ========================================================================== */

:root {
    /* Primary - Teal */
    --teal-15: #014D40;
    --teal-23: #0C6B58;
    --teal-28: #147D64;
    --teal-34: #199473;
    --teal-41: #27AB83;
    --teal-49: #3EBD93;
    --teal-62: #65D6AD;
    --teal-74: #8EEDC7;
    --teal-87: #C6F7E2;
    --teal-96: #EFFCF6;

    /* Neutrals - Blue Grey */
    --grey-16: #102A43;
    --grey-23: #243B53;
    --grey-30: #334E68;
    --grey-39: #486581;
    --grey-49: #627D98;
    --grey-60: #829AB1;
    --grey-70: #9FB3C8;
    --grey-80: #BCCCDC;
    --grey-89: #D9E2EC;
    --grey-96: #F0F4F8;

    /* Supporting - Red */
    --red-20: #610404;
    --red-25: #780A0A;
    --red-32: #911111;
    --red-38: #A61B1B;
    --red-44: #BA2525;
    --red-55: #D64545;
    --red-66: #E66A6A;
    --red-78: #F29B9B;
    --red-89: #FACDCD;
    --red-97: #FFEEEE;

    /* Supporting - Blue */
    --blue-21: #003E6B;
    --blue-29: #0A558C;
    --blue-33: #0F609B;
    --blue-39: #186FAF;
    --blue-45: #2680C2;
    --blue-55: #4098D7;
    --blue-65: #62B0E8;
    --blue-75: #84C5F4;
    --blue-85: #B6E0FE;
    --blue-92: #DCEEFB;

    /* Supporting - Yellow */
    --yellow-17: #513C06;
    --yellow-27: #7C5E10;
    --yellow-37: #A27C1A;
    --yellow-48: #C99A2E;
    --yellow-60: #E9B949;
    --yellow-70: #F7D070;
    --yellow-76: #F9DA8B;
    --yellow-81: #F8E3A3;
    --yellow-88: #FCEFC7;
    --yellow-96: #FFFAEB;

    /* Supporting - Purple */
    --purple-18: #240754;
    --purple-25: #34126F;
    --purple-31: #421987;
    --purple-38: #51279B;
    --purple-46: #653CAD;
    --purple-51: #724BB7;
    --purple-58: #8662C7;
    --purple-68: #A081D9;
    --purple-84: #CFBCF2;
    --purple-93: #EAE2F8;

    /* Semantic - Light Mode (default) */
    --color-bg: var(--yellow-96);
    --color-bg-elevated: var(--yellow-88);
    --color-bg-subtle: var(--yellow-88);
    --color-text: var(--grey-23);
    --color-text-secondary: var(--grey-49);
    --color-text-muted: var(--grey-60);
    --color-border: var(--grey-70);
    --color-border-subtle: var(--grey-96);
    --color-primary: var(--teal-41);
    --color-primary-hover: var(--teal-34);
    --color-primary-active: var(--teal-28);
    --color-error: var(--red-44);
    --color-danger: var(--red-44);
    --color-error-bg: var(--red-97);
    --color-warning-bg: var(--yellow-81);
    --color-warning-border: var(--yellow-60);
    --color-link: var(--blue-39);
    --color-link-hover: var(--blue-21);
    --color-accent: var(--teal-49);
    --color-text-inverse: var(--yellow-96);
    --color-backdrop: var(--grey-16);
    --color-overlay: color-mix(in srgb, var(--grey-16) 50%, transparent);
    --color-overlay-badge: color-mix(in srgb, var(--grey-16) 50%, transparent);
    --color-shadow: color-mix(in srgb, var(--grey-16) 20%, transparent);
    --color-shadow-heavy: color-mix(in srgb, var(--grey-16) 15%, transparent);
    --color-input-bg: var(--color-bg);
    --color-focus-ring: color-mix(in srgb, var(--teal-28) 20%, transparent);
    --color-navbar-bg: var(--purple-93);
    --color-nav-inactive: var(--grey-39);
    --color-nav-inactive-hover: var(--color-primary);

    /* Layout */
    --header-height: 56px;
    --tab-bar-height: 56px;
    --content-max-width: 900px;
    --note-max-width: 65ch; /* Optimal reading width */
    --photo-gap: 2px;
    --spacing-xs: 0.25rem;
    --spacing-sm: 0.5rem;
    --spacing-md: 1rem;
    --spacing-lg: 1.5rem;
    --spacing-xl: 2rem;
    --radius-sm: 4px;
    --radius-md: 8px;
    --radius-lg: 12px;

    /* Typography */
    --font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    --font-size-xs: 0.75rem;
    --font-size-sm: 0.875rem;
    --font-size-base: 1rem;
    --font-size-lg: 1.125rem;
    --font-size-xl: 1.25rem;
    --font-size-2xl: 1.5rem;
    --font-size-3xl: 2rem;
    --line-height-tight: 1.25;
    --line-height-normal: 1.5;
    --line-height-relaxed: 1.75;
}

/* Dark Mode */
@media (prefers-color-scheme: dark) {
    :root {
        --color-bg: var(--grey-23);
        --color-bg-elevated: var(--grey-30);
        --color-bg-subtle: var(--grey-39);
        --color-text: var(--yellow-96);
        --color-text-secondary: var(--grey-70);
        --color-text-muted: var(--grey-60);
        --color-border: var(--grey-39);
        --color-border-subtle: var(--grey-30);
        --color-primary: var(--teal-49);
        --color-primary-hover: var(--teal-62);
        --color-primary-active: var(--teal-74);
        --color-error: var(--red-66);
        --color-error-bg: var(--red-20);
        --color-warning-bg: var(--yellow-17);
        --color-warning-border: var(--yellow-48);
        --color-link: var(--blue-65);
        --color-link-hover: var(--blue-75);
        --color-accent: var(--teal-62);
        --color-focus-ring: color-mix(in srgb, var(--teal-49) 20%, transparent);
        --color-navbar-bg: var(--purple-25);
        --color-nav-inactive: var(--grey-60);
        --color-nav-inactive-hover: var(--color-primary);
    }
}

/* ==========================================================================
   Reset & Base
   ========================================================================== */

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

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

body {
    font-family: var(--font-family);
    font-size: var(--font-size-base);
    line-height: var(--line-height-normal);
    color: var(--color-text);
    background-color: var(--color-bg);
    min-height: 100vh;
    min-height: 100dvh; /* Dynamic viewport height for mobile */
}

img {
    max-width: 100%;
    height: auto;
    display: block;
}

h1 {
    font-size: var(--font-size-2xl);
    font-weight: 700;
    line-height: var(--line-height-tight);
}

h2 {
    font-size: var(--font-size-lg);
    font-weight: 600;
    line-height: var(--line-height-tight);
}

h3 {
    font-size: var(--font-size-base);
    font-weight: 600;
    line-height: var(--line-height-tight);
    color: var(--color-text-secondary);
}

a {
    color: var(--color-link);
    text-decoration: underline;
}

a:hover {
    color: var(--color-link-hover);
}

.btn-link {
    background: none;
    border: none;
    padding: 0;
    color: var(--color-link);
    cursor: pointer;
    font-size: inherit;
    text-decoration: underline;
}

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

/* Lists */
ol, ul {
    padding-left: 1.5rem;
    margin-bottom: var(--spacing-md);
}

ol li, ul li {
    margin-bottom: var(--spacing-sm);
    line-height: var(--line-height-relaxed);
}

ol li:last-child, ul li:last-child {
    margin-bottom: 0;
}

.emphasize {
    font-weight: 600;
}

/* ==========================================================================
   Page Layouts
   ========================================================================== */

/*
 * Centered layout - TurboTax style
 * For simple screens: Home, Login, Signup Success, etc.
 * Content centers both vertically and horizontally
 */
.page-centered {
    min-height: 100vh;
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: var(--spacing-lg);
}

.page-centered-content {
    width: 100%;
    max-width: 400px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--spacing-md);
}

/*
 * App layout - with sticky header and tab bar
 * For authenticated screens: Journal, Review, Explore, Settings
 */
.page-app {
    min-height: 100vh;
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
}

.page-app-content {
    flex: 1;
    padding-top: var(--header-height);
    padding-bottom: var(--tab-bar-height);
    overflow-y: auto;
}

/* ==========================================================================
   Sticky Header
   ========================================================================== */

.header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: var(--header-height);
    background-color: var(--color-bg);
    border-bottom: 2.5px solid var(--color-border);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 var(--spacing-md);
    z-index: 100;
}

.header-inner {
    width: 100%;
    max-width: var(--content-max-width);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.header-left {
    display: flex;
    align-items: baseline;
    gap: var(--spacing-sm);
}

.header-title {
    font-size: var(--font-size-2xl);
    font-weight: 700;
    color: var(--color-text);
}

.header-date {
    font-size: var(--font-size-sm);
    font-weight: 400;
    color: var(--color-text-muted);
}

.header-actions {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
}

.header-action {
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--color-primary);
    background: none;
    border: none;
    border-radius: var(--radius-md);
    cursor: pointer;
    font-size: var(--font-size-xl);
}

.header-action:hover {
    background-color: var(--color-bg-subtle);
}

.add-photo-icon {
    -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='32' height='32' fill='%23000000' viewBox='0 0 256 256'%3E%3Cpath d='M208,56H180.28L169,39.12A16,16,0,0,0,155.72,32H100.28A16,16,0,0,0,87,39.12L75.72,56H48A24,24,0,0,0,24,80V192a24,24,0,0,0,24,24H208a24,24,0,0,0,24-24V80A24,24,0,0,0,208,56Zm-48,88H136v24a8,8,0,0,1-16,0V144H96a8,8,0,0,1,0-16h24V104a8,8,0,0,1,16,0v24h24a8,8,0,0,1,0,16Z'%3E%3C/path%3E%3C/svg%3E");
    mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='32' height='32' fill='%23000000' viewBox='0 0 256 256'%3E%3Cpath d='M208,56H180.28L169,39.12A16,16,0,0,0,155.72,32H100.28A16,16,0,0,0,87,39.12L75.72,56H48A24,24,0,0,0,24,80V192a24,24,0,0,0,24,24H208a24,24,0,0,0,24-24V80A24,24,0,0,0,208,56Zm-48,88H136v24a8,8,0,0,1-16,0V144H96a8,8,0,0,1,0-16h24V104a8,8,0,0,1,16,0v24h24a8,8,0,0,1,0,16Z'%3E%3C/path%3E%3C/svg%3E");
}

/* ==========================================================================
   Bottom Navbar (shared shell for app tab bar and content page nav)
   ========================================================================== */

.navbar {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: var(--tab-bar-height);
    background-color: var(--color-bg);
    border-top: 2.5px solid var(--color-border);
    display: flex;
    align-items: center;
    justify-content: center;
    padding-bottom: env(safe-area-inset-bottom, 0);
    z-index: 100;
}

.navbar-inner {
    width: 100%;
    max-width: var(--content-max-width);
    padding: 0 var(--spacing-md);
    display: flex;
    align-items: center;
    justify-content: space-around;
}

/* -- App tab bar items --------------------------------------------------- */

.navbar-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    padding: var(--spacing-xs);
    background: none;
    border: none;
    cursor: pointer;
    color: var(--color-nav-inactive);
    text-decoration: none;
    font-size: var(--font-size-xs);
    transition: color 0.15s;
}

/* Bottom tab bar items stretch to fill equal widths.
   The header "Add Photos" button also uses .navbar-item
   but should stay at its natural size. */
.navbar-inner .navbar-item {
    flex: 1;
}

.navbar-item:hover {
    text-decoration: none;
    color: var(--color-nav-inactive-hover);
}

.navbar-item.active {
    color: var(--color-primary);
}

.navbar-icon {
    display: inline-block;
    width: 24px;
    height: 24px;
    background-color: currentColor;
    -webkit-mask-size: contain;
    mask-size: contain;
    -webkit-mask-repeat: no-repeat;
    mask-repeat: no-repeat;
    -webkit-mask-position: center;
    mask-position: center;
}

.navbar-icon-home {
    -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='32' height='32' fill='%23000000' viewBox='0 0 256 256'%3E%3Cpath d='M224,120v96a8,8,0,0,1-8,8H160a8,8,0,0,1-8-8V164a4,4,0,0,0-4-4H108a4,4,0,0,0-4,4v52a8,8,0,0,1-8,8H40a8,8,0,0,1-8-8V120a16,16,0,0,1,4.69-11.31l80-80a16,16,0,0,1,22.62,0l80,80A16,16,0,0,1,224,120Z'%3E%3C/path%3E%3C/svg%3E");
    mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='32' height='32' fill='%23000000' viewBox='0 0 256 256'%3E%3Cpath d='M224,120v96a8,8,0,0,1-8,8H160a8,8,0,0,1-8-8V164a4,4,0,0,0-4-4H108a4,4,0,0,0-4,4v52a8,8,0,0,1-8,8H40a8,8,0,0,1-8-8V120a16,16,0,0,1,4.69-11.31l80-80a16,16,0,0,1,22.62,0l80,80A16,16,0,0,1,224,120Z'%3E%3C/path%3E%3C/svg%3E");
}

.navbar-icon-journal {
    -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='32' height='32' fill='%23000000' viewBox='0 0 256 256'%3E%3Cpath d='M232,48H168a32,32,0,0,0-32,32v87.73a8.17,8.17,0,0,1-7.47,8.25,8,8,0,0,1-8.53-8V80A32,32,0,0,0,88,48H24a8,8,0,0,0-8,8V200a8,8,0,0,0,8,8H96a24,24,0,0,1,24,23.94,7.9,7.9,0,0,0,5.12,7.55A8,8,0,0,0,136,232a24,24,0,0,1,24-24h72a8,8,0,0,0,8-8V56A8,8,0,0,0,232,48ZM208,168H168.27a8.17,8.17,0,0,1-8.25-7.47,8,8,0,0,1,8-8.53h39.73a8.17,8.17,0,0,1,8.25,7.47A8,8,0,0,1,208,168Zm0-32H168.27a8.17,8.17,0,0,1-8.25-7.47,8,8,0,0,1,8-8.53h39.73a8.17,8.17,0,0,1,8.25,7.47A8,8,0,0,1,208,136Zm0-32H168.27A8.17,8.17,0,0,1,160,96.53,8,8,0,0,1,168,88h39.73A8.17,8.17,0,0,1,216,95.47,8,8,0,0,1,208,104Z'%3E%3C/path%3E%3C/svg%3E");
    mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='32' height='32' fill='%23000000' viewBox='0 0 256 256'%3E%3Cpath d='M232,48H168a32,32,0,0,0-32,32v87.73a8.17,8.17,0,0,1-7.47,8.25,8,8,0,0,1-8.53-8V80A32,32,0,0,0,88,48H24a8,8,0,0,0-8,8V200a8,8,0,0,0,8,8H96a24,24,0,0,1,24,23.94,7.9,7.9,0,0,0,5.12,7.55A8,8,0,0,0,136,232a24,24,0,0,1,24-24h72a8,8,0,0,0,8-8V56A8,8,0,0,0,232,48ZM208,168H168.27a8.17,8.17,0,0,1-8.25-7.47,8,8,0,0,1,8-8.53h39.73a8.17,8.17,0,0,1,8.25,7.47A8,8,0,0,1,208,168Zm0-32H168.27a8.17,8.17,0,0,1-8.25-7.47,8,8,0,0,1,8-8.53h39.73a8.17,8.17,0,0,1,8.25,7.47A8,8,0,0,1,208,136Zm0-32H168.27A8.17,8.17,0,0,1,160,96.53,8,8,0,0,1,168,88h39.73A8.17,8.17,0,0,1,216,95.47,8,8,0,0,1,208,104Z'%3E%3C/path%3E%3C/svg%3E");
}

.navbar-icon-account {
    -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='32' height='32' fill='%23000000' viewBox='0 0 256 256'%3E%3Cpath d='M230.93,220a8,8,0,0,1-6.93,4H32a8,8,0,0,1-6.92-12c15.23-26.33,38.7-45.21,66.09-54.16a72,72,0,1,1,73.66,0c27.39,8.95,50.86,27.83,66.09,54.16A8,8,0,0,1,230.93,220Z'%3E%3C/path%3E%3C/svg%3E");
    mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='32' height='32' fill='%23000000' viewBox='0 0 256 256'%3E%3Cpath d='M230.93,220a8,8,0,0,1-6.93,4H32a8,8,0,0,1-6.92-12c15.23-26.33,38.7-45.21,66.09-54.16a72,72,0,1,1,73.66,0c27.39,8.95,50.86,27.83,66.09,54.16A8,8,0,0,1,230.93,220Z'%3E%3C/path%3E%3C/svg%3E");
}

.navbar-label {
    font-weight: 600;
}

/* ==========================================================================
   Photo Grid - iOS Style

   Photos display at natural aspect ratios (4:3 landscape, 3:4 portrait)
   aligned at horizontal and vertical center lines.
   Minimal gaps between photos.
   ========================================================================== */

.photo-grid {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    align-items: center;
    gap: var(--photo-gap);
    padding: var(--photo-gap);
}

.photo-grid-item {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    justify-content: center;
}

.photo-grid-item img {
    display: block;
    max-width: 100%;
    height: auto;
    background-color: var(--color-bg-subtle);
}

/*
 * Photo sizing:
 * On mobile (< 480px): 3 photos per row, each ~32% viewport width
 * On tablet (480-768px): 4 photos per row
 * On desktop (> 768px): 5+ photos per row, max individual photo size
 *
 * iOS Photos shows ~3 landscape photos per row on phone.
 * For a 4:3 photo on a 375px screen: 375/3 ≈ 125px width, 94px height
 */

/* Mobile: 3 photos per row */
.photo-grid-item {
    width: calc((100vw - var(--photo-gap) * 4) / 3);
    max-width: 150px;
}

.photo-grid-item.landscape img {
    width: 100%;
    aspect-ratio: 4 / 3;
    object-fit: cover;
}

.photo-grid-item.portrait img {
    height: calc((100vw - var(--photo-gap) * 4) / 3);
    max-height: 150px;
    aspect-ratio: 3 / 4;
    object-fit: cover;
}

/* Tablet and up: more photos per row */
@media (min-width: 480px) {
    .photo-grid-item {
        width: calc((100vw - var(--photo-gap) * 5) / 4);
        max-width: 180px;
    }

    .photo-grid-item.portrait img {
        height: calc((100vw - var(--photo-gap) * 5) / 4);
        max-height: 180px;
    }
}

@media (min-width: 768px) {
    .photo-grid-item {
        width: 160px;
        max-width: 160px;
    }

    .photo-grid-item.portrait img {
        height: 160px;
        max-height: 160px;
    }
}

/* Photo grid with +N more indicator */
.photo-grid-more {
    width: calc((100vw - var(--photo-gap) * 4) / 3);
    max-width: 150px;
    aspect-ratio: 4 / 3;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: var(--color-bg-subtle);
    color: var(--color-text-secondary);
    font-size: var(--font-size-lg);
    font-weight: 600;
    border-radius: var(--radius-sm);
}

@media (min-width: 480px) {
    .photo-grid-more {
        width: calc((100vw - var(--photo-gap) * 5) / 4);
        max-width: 180px;
    }
}

@media (min-width: 768px) {
    .photo-grid-more {
        width: 160px;
        max-width: 160px;
    }
}

/* ==========================================================================
   Timeline View

   Photos and notes organized by date sections.
   Date headers separate content.
   ========================================================================== */

.timeline {
    padding: var(--spacing-md);
    max-width: var(--content-max-width);
    margin: 0 auto;
}

.timeline-section {
    margin-bottom: var(--spacing-xl);
}

.timeline-date {
    font-size: var(--font-size-sm);
    font-weight: 600;
    color: var(--color-text);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: var(--spacing-sm) 0;
    border-bottom: 1px solid var(--color-border-subtle);
    margin-bottom: var(--spacing-sm);
}

.timeline-photos {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: var(--photo-gap);
    margin-bottom: var(--spacing-sm);
}

/* Photo items inside timeline grid fill their cells */
.timeline-photos .photo-grid-item {
    width: 100%;
    max-width: none;
}

.timeline-photos .photo-grid-item.landscape img {
    width: 100%;
    aspect-ratio: 4 / 3;
    object-fit: cover;
}

/* Tablet and up: 4 columns */
@media (min-width: 480px) {
    .timeline-photos {
        grid-template-columns: repeat(4, 1fr);
    }
}

/* Desktop: 5 columns */
@media (min-width: 768px) {
    .timeline-photos {
        grid-template-columns: repeat(5, 1fr);
    }
}

/* ==========================================================================
   Notes - Optimal Readability

   Line length between 50-75 characters for comfortable reading.
   ========================================================================== */

.note {
    background-color: var(--color-bg-elevated);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    padding: var(--spacing-md);
    margin: var(--spacing-sm) 0;
}

.note-content {
    max-width: var(--note-max-width);
    font-size: var(--font-size-base);
    line-height: var(--line-height-relaxed);
    color: var(--color-text);
}

.note-content p {
    margin-bottom: var(--spacing-md);
}

.note-content p:last-child {
    margin-bottom: 0;
}

.note-meta {
    font-size: var(--font-size-sm);
    color: var(--color-text-muted);
    margin-top: var(--spacing-sm);
}

/* Note editor */
.note-editor {
    width: 100%;
}

.note-textarea {
    width: 100%;
    max-width: var(--note-max-width);
    min-height: 120px;
    padding: var(--spacing-md);
    font-family: var(--font-family);
    font-size: var(--font-size-base);
    line-height: var(--line-height-relaxed);
    color: var(--color-text);
    background-color: var(--color-bg);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    resize: vertical;
}

.note-textarea:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px var(--color-focus-ring);
}

/* ==========================================================================
   Buttons
   ========================================================================== */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--spacing-sm);
    padding: var(--spacing-sm) var(--spacing-lg);
    font-family: var(--font-family);
    font-size: var(--font-size-base);
    font-weight: 500;
    line-height: 1;
    text-decoration: none;
    border: none;
    border-radius: var(--radius-lg);
    cursor: pointer;
    transition: background-color 0.15s, opacity 0.15s;
}

.btn:hover {
    text-decoration: none;
}

.btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

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

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

.btn-primary:active:not(:disabled) {
    background-color: var(--color-primary-active);
}

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

.btn-secondary:hover:not(:disabled) {
    background-color: var(--teal-96);
}

@media (prefers-color-scheme: dark) {
    .btn-secondary:hover:not(:disabled) {
        background-color: color-mix(in srgb, var(--teal-49) 15%, transparent);
    }
}

/* Large button - bigger tap target, same text size */
.btn-lg {
    padding: var(--spacing-md) var(--spacing-xl);
}

.btn-delete {
    background: none;
    border: none;
    color: var(--color-error);
    font-size: var(--font-size-sm);
    cursor: pointer;
    padding: var(--spacing-sm) 0;
    width: 100%;
    text-align: left;
    margin-top: var(--spacing-sm);
}

/* ==========================================================================
   Form Elements
   ========================================================================== */

.form-group {
    margin-bottom: var(--spacing-md);
}

.form-label {
    display: block;
    font-size: var(--font-size-sm);
    font-weight: 500;
    color: var(--color-text-secondary);
    margin-bottom: var(--spacing-xs);
}

.form-input {
    width: 100%;
    padding: var(--spacing-sm) var(--spacing-md);
    font-family: var(--font-family);
    font-size: var(--font-size-base);
    color: var(--color-text);
    background-color: var(--color-input-bg);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    box-sizing: border-box;
    transition: border-color 0.15s, box-shadow 0.15s;
}

.form-input:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px var(--color-focus-ring);
}

.form-input::placeholder {
    color: var(--color-text-muted);
}

textarea.form-input {
    resize: none;
    line-height: var(--line-height-relaxed);
}

.form-input-date {
    width: auto;
    padding: var(--spacing-xs) var(--spacing-sm);
    font-weight: 600;
    cursor: pointer;
}

.form-input-locked {
    color: var(--color-text-muted);
    cursor: default;
    opacity: 0.7;
}

.form-input-locked:focus {
    border-color: var(--color-border);
    box-shadow: none;
}

.form-error {
    font-size: var(--font-size-sm);
    color: var(--color-error);
    min-height: calc(var(--font-size-sm) * 1.5);
    padding-top: var(--spacing-xs);
    visibility: hidden;
}

.form-error.is-visible {
    visibility: visible;
}

.form-value {
    font-size: var(--font-size-base);
    color: var(--color-text);
    padding: var(--spacing-sm) 0;
}

/* ==========================================================================
   Cards
   ========================================================================== */

.card {
    background-color: var(--color-bg-elevated);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    overflow: hidden;
}

.card-body {
    padding: var(--spacing-md);
}

.card-title {
    font-size: var(--font-size-lg);
    font-weight: 600;
    color: var(--color-text);
    margin-bottom: var(--spacing-sm);
}

/* ==========================================================================
   Alerts & Messages
   ========================================================================== */

.alert {
    padding: var(--spacing-md);
    border-radius: var(--radius-md);
    font-size: var(--font-size-sm);
}

.alert-error {
    background-color: var(--color-error-bg);
    color: var(--color-error);
    border: 1px solid var(--color-error);
}

.alert-warning {
    background-color: var(--color-warning-bg);
    color: var(--yellow-27);
    border: 1px solid var(--color-warning-border);
}

@media (prefers-color-scheme: dark) {
    .alert-warning {
        color: var(--yellow-70);
    }
}

/* ==========================================================================
   Empty States
   ========================================================================== */

.empty-state {
    text-align: center;
    padding: var(--spacing-sm) var(--spacing-xl) var(--spacing-xl);
}


.empty-state p {
    max-width: var(--note-max-width);
    margin: var(--spacing-sm) auto 0;
}

.empty-state-arrow {
    margin: 0 auto var(--spacing-xs);
    width: 100px;
    position: relative;
    left: 30%;
    transform: rotate(var(--dynamic-angle, 1deg));
    transition: transform 0.1s linear;
}


/* ==========================================================================
   Logged-In Home Page
   ========================================================================== */

.logged-in-home {
    width: 100%;
    max-width: 65ch;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--spacing-md);
    padding: var(--spacing-md);
}

.logged-in-home .welcome {
    font-size: var(--font-size-2xl);
    font-weight: 700;
    color: var(--color-text);
    margin-bottom: var(--spacing-sm);
}

.trial-message {
    margin: var(--spacing-md) 0;
    line-height: 1.5;
}

.trial-status-secondary {
    font-size: 0.85rem;
    color: var(--color-text-muted);
    margin-top: var(--spacing-md);
    text-align: center;
}

.logged-in-home .photo-count {
    font-size: var(--font-size-base);
    color: var(--color-text-secondary);
    margin-bottom: var(--spacing-sm);
}

/* ==========================================================================
   Loading & Processing States
   ========================================================================== */

.shimmer {
    background: linear-gradient(
        90deg,
        var(--color-bg-subtle) 0%,
        var(--color-bg-elevated) 50%,
        var(--color-bg-subtle) 100%
    );
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
}

@keyframes shimmer {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.header-add-btn {
    color: var(--color-primary);
}

.header-add-btn.uploading {
    font-size: 0;
    cursor: default;
    pointer-events: none;
}

.header-add-btn.uploading .navbar-icon,
.header-add-btn.uploading .navbar-label {
    display: none;
}

.header-add-btn.uploading::after {
    content: '';
    display: block;
    width: 22px;
    height: 22px;
    border: 2.5px solid color-mix(in srgb, var(--color-primary) 40%, transparent);
    border-top-color: var(--color-primary);
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
}

.processing-indicator {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--spacing-sm);
    color: var(--color-primary);
    font-size: var(--font-size-sm);
}

/* ==========================================================================
   Review Mode Specific
   ========================================================================== */

.review-day-nav {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--spacing-md);
    border-bottom: 1px solid var(--color-border);
}

.review-day-date {
    font-size: var(--font-size-xl);
    font-weight: 600;
    color: var(--color-text);
}

.review-nav-btn {
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: none;
    border: none;
    color: var(--color-primary);
    font-size: var(--font-size-xl);
    cursor: pointer;
    border-radius: var(--radius-md);
}

.review-nav-btn:hover {
    background-color: var(--color-bg-subtle);
}

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

.review-photos {
    padding: var(--spacing-md);
}

.review-note {
    padding: var(--spacing-md);
    border-top: 1px solid var(--color-border);
}

/* ==========================================================================
   Fullscreen Photo View (Progressive Disclosure)
   ========================================================================== */

.fullscreen-photo {
    position: fixed;
    inset: 0;
    background-color: var(--color-backdrop);
    z-index: 200;
    display: flex;
    align-items: center;
    justify-content: center;
}

.fullscreen-photo img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

.fullscreen-photo-counter {
    position: absolute;
    top: var(--spacing-md);
    left: 50%;
    transform: translateX(-50%);
    color: var(--color-text-inverse);
    font-size: var(--font-size-sm);
    background-color: var(--color-overlay-badge);
    padding: var(--spacing-xs) var(--spacing-sm);
    border-radius: var(--radius-sm);
}

.fullscreen-photo-close {
    position: absolute;
    top: var(--spacing-md);
    right: var(--spacing-md);
    color: var(--color-text-inverse);
    font-size: var(--font-size-2xl);
    background: none;
    border: none;
    cursor: pointer;
    padding: var(--spacing-sm);
}

/* Full-screen photo viewer with swipe navigation */
.fullscreen-viewer {
    position: fixed;
    inset: 0;
    background-color: var(--color-backdrop);
    z-index: 200;
    display: flex;
    align-items: center;
    justify-content: center;
    touch-action: pinch-zoom;
}

.fullscreen-viewer img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    user-select: none;
    -webkit-user-drag: none;
}

.fullscreen-photo-date {
    position: absolute;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    color: var(--color-text-inverse);
    font-size: var(--font-size-sm);
    background: var(--color-overlay);
    padding: var(--spacing-xs) var(--spacing-md);
    border-radius: 20px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* ==========================================================================
   Celebration / Achievement Messages
   ========================================================================== */

.celebration {
    text-align: center;
    padding: var(--spacing-xl);
    max-width: 400px;
    margin: 0 auto;
}

.celebration-icon {
    font-size: 4rem;
    margin-bottom: var(--spacing-md);
}

.celebration-title {
    font-size: var(--font-size-xl);
    font-weight: 600;
    color: var(--color-text);
    margin-bottom: var(--spacing-sm);
}

.celebration-message {
    color: var(--color-text-secondary);
    font-size: var(--font-size-base);
    line-height: var(--line-height-relaxed);
    margin-bottom: var(--spacing-lg);
}

/* ==========================================================================
   Utility Classes
   ========================================================================== */

.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.text-center { text-align: center; }
.text-left { text-align: left; }
.text-right { text-align: right; }

.text-primary { color: var(--color-primary); }
.text-secondary { color: var(--color-text-secondary); }
.text-muted { color: var(--color-text-muted); }
.text-error { color: var(--color-error); }

.mt-0 { margin-top: 0; }
.mt-sm { margin-top: var(--spacing-sm); }
.mt-md { margin-top: var(--spacing-md); }
.mt-lg { margin-top: var(--spacing-lg); }
.mt-xl { margin-top: var(--spacing-xl); }

.mb-0 { margin-bottom: 0; }
.mb-sm { margin-bottom: var(--spacing-sm); }
.mb-md { margin-bottom: var(--spacing-md); }
.mb-lg { margin-bottom: var(--spacing-lg); }
.mb-xl { margin-bottom: var(--spacing-xl); }

/* Hide file inputs but keep accessible */
input[type="file"] {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* ==========================================================================
   Timeline Notes
   ========================================================================== */

.timeline-notes {
    margin-top: var(--spacing-sm);
}

.note-entry {
    border-radius: var(--radius-md);
    padding: var(--spacing-sm) var(--spacing-md);
    margin: var(--spacing-xs) 0;
    cursor: pointer;
}

.note-entry:hover {
    background: var(--color-border-subtle);
}

.note-entry .note-content {
    color: var(--color-text);
    font-size: var(--font-size-sm);
    line-height: var(--line-height-relaxed);
    white-space: pre-wrap;
}

.note-entry .note-time {
    font-size: var(--font-size-xs);
    margin-top: var(--spacing-xs);
}

/* ==========================================================================
   Floating Add Button
   ========================================================================== */

.floating-add-btn {
    position: fixed;
    bottom: calc(var(--tab-bar-height) + 16px);
    right: 16px;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: var(--color-primary);
    color: var(--color-text-inverse);
    font-size: 28px;
    font-weight: 300;
    border: none;
    box-shadow: 0 4px 12px var(--color-shadow);
    cursor: pointer;
    z-index: 90;
    transition: background-color 0.15s, transform 0.15s;
}

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

.floating-add-btn:active {
    transform: scale(0.95);
}

/* ==========================================================================
   Add Menu
   ========================================================================== */

.add-menu {
    position: absolute;
    top: 100%;
    right: 0;
    margin-top: 4px;
    background: var(--color-bg-elevated);
    border-radius: var(--radius-lg);
    box-shadow: 0 4px 16px var(--color-shadow-heavy);
    z-index: 90;
    overflow: hidden;
}

.add-menu.hidden {
    display: none;
}

.add-menu-item {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    padding: var(--spacing-md) var(--spacing-lg);
    width: 100%;
    border: none;
    background: none;
    font-family: var(--font-family);
    font-size: var(--font-size-base);
    color: var(--color-text);
    cursor: pointer;
    transition: background-color 0.15s;
}

.add-menu-item:hover {
    background: var(--color-bg-subtle);
}

.add-menu-item:not(:last-child) {
    border-bottom: 1px solid var(--color-border-subtle);
}

.add-menu-icon {
    display: inline-block;
    width: 20px;
    height: 20px;
    background-color: currentColor;
    -webkit-mask-size: contain;
    mask-size: contain;
    -webkit-mask-repeat: no-repeat;
    mask-repeat: no-repeat;
    -webkit-mask-position: center;
    mask-position: center;
}

.add-menu-icon-photo {
    -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 256 256'%3E%3Crect width='256' height='256' fill='none'/%3E%3Crect x='72' y='40' width='144' height='144' rx='8' fill='none' stroke='%23000' stroke-linecap='round' stroke-linejoin='round' stroke-width='12'/%3E%3Ccircle cx='120' cy='88' r='16' fill='none' stroke='%23000' stroke-linecap='round' stroke-linejoin='round' stroke-width='12'/%3E%3Cpath d='M184,184v24a8,8,0,0,1-8,8H48a8,8,0,0,1-8-8V80a8,8,0,0,1,8-8H72' fill='none' stroke='%23000' stroke-linecap='round' stroke-linejoin='round' stroke-width='12'/%3E%3Cpath d='M96.69,184l77.65-77.66a8,8,0,0,1,11.32,0L216,136.69' fill='none' stroke='%23000' stroke-linecap='round' stroke-linejoin='round' stroke-width='12'/%3E%3C/svg%3E");
    mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 256 256'%3E%3Crect width='256' height='256' fill='none'/%3E%3Crect x='72' y='40' width='144' height='144' rx='8' fill='none' stroke='%23000' stroke-linecap='round' stroke-linejoin='round' stroke-width='12'/%3E%3Ccircle cx='120' cy='88' r='16' fill='none' stroke='%23000' stroke-linecap='round' stroke-linejoin='round' stroke-width='12'/%3E%3Cpath d='M184,184v24a8,8,0,0,1-8,8H48a8,8,0,0,1-8-8V80a8,8,0,0,1,8-8H72' fill='none' stroke='%23000' stroke-linecap='round' stroke-linejoin='round' stroke-width='12'/%3E%3Cpath d='M96.69,184l77.65-77.66a8,8,0,0,1,11.32,0L216,136.69' fill='none' stroke='%23000' stroke-linecap='round' stroke-linejoin='round' stroke-width='12'/%3E%3C/svg%3E");
}

.add-menu-icon-note {
    -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 256 256'%3E%3Crect width='256' height='256' fill='none'/%3E%3Cpath d='M92.69,216H48a8,8,0,0,1-8-8V163.31a8,8,0,0,1,2.34-5.65L165.66,34.34a8,8,0,0,1,11.31,0L221.66,79a8,8,0,0,1,0,11.31L98.34,213.66A8,8,0,0,1,92.69,216Z' fill='none' stroke='%23000' stroke-linecap='round' stroke-linejoin='round' stroke-width='12'/%3E%3Cline x1='136' y1='64' x2='192' y2='120' fill='none' stroke='%23000' stroke-linecap='round' stroke-linejoin='round' stroke-width='12'/%3E%3C/svg%3E");
    mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 256 256'%3E%3Crect width='256' height='256' fill='none'/%3E%3Cpath d='M92.69,216H48a8,8,0,0,1-8-8V163.31a8,8,0,0,1,2.34-5.65L165.66,34.34a8,8,0,0,1,11.31,0L221.66,79a8,8,0,0,1,0,11.31L98.34,213.66A8,8,0,0,1,92.69,216Z' fill='none' stroke='%23000' stroke-linecap='round' stroke-linejoin='round' stroke-width='12'/%3E%3Cline x1='136' y1='64' x2='192' y2='120' fill='none' stroke='%23000' stroke-linecap='round' stroke-linejoin='round' stroke-width='12'/%3E%3C/svg%3E");
}

/* ==========================================================================
   Modal
   ========================================================================== */

.modal {
    position: fixed;
    inset: 0;
    background: var(--color-overlay);
    display: flex;
    align-items: flex-end;
    z-index: 200;
}

.modal.hidden {
    display: none;
}

.modal-content {
    background: var(--color-bg-elevated);
    width: 100%;
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    padding: var(--spacing-md);
    max-height: 80vh;
    overflow-y: auto;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--spacing-md);
}

.modal-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    line-height: 1;
    cursor: pointer;
    color: var(--color-text-muted);
    padding: var(--spacing-xs);
}

.modal-close:hover {
    color: var(--color-text);
}

.modal-actions {
    margin-top: var(--spacing-md);
    text-align: right;
}

.date-label-locked::after {
    content: " (from photo)";
    font-size: var(--font-size-sm);
}

/* Desktop: center modal */
@media (min-width: 768px) {
    .modal {
        align-items: center;
        justify-content: center;
    }

    .modal-content {
        max-width: 500px;
        border-radius: var(--radius-lg);
    }
}

/* ==========================================================================
   Margin Notes

   On wide screens, the figure floats to the right of the paragraph as a
   margin note.  On narrow screens it wraps below the paragraph.
   ========================================================================== */

.margin-note-container {
    max-width: calc(var(--note-max-width) + 220px);
}

.margin-note {
    margin-top: var(--spacing-md);
}

.margin-note img {
    border-radius: var(--radius-md);
    width: 100%;
    height: auto;
    max-width: 300px;
}

.margin-note figcaption {
    font-size: var(--font-size-xs);
    color: var(--color-text-muted);
    line-height: var(--line-height-normal);
    margin-top: var(--spacing-xs);
    max-width: 300px;
}

@media (min-width: 900px) {
    .margin-note-container {
        position: relative;
    }

    .margin-note {
        position: absolute;
        top: 0;
        left: calc(var(--note-max-width) + var(--spacing-lg));
        width: 200px;
        margin-top: 0;
    }

    .margin-note img {
        max-width: 200px;
    }

    .margin-note figcaption {
        max-width: 200px;
    }
}

/* ==========================================================================
   Page Navigation (content inside .navbar for About, Pricing, Privacy, Terms)
   ========================================================================== */

.page-nav {
    justify-content: space-between;
}

main:has(+ .navbar) {
    padding-bottom: var(--tab-bar-height);
}

.page-nav a {
    display: inline-flex;
    align-items: center;
    gap: var(--spacing-xs);
    color: var(--color-nav-inactive);
    text-decoration: none;
}

.page-nav a:hover {
    color: var(--color-nav-inactive-hover);
}

.page-nav-prev,
.page-nav-next {
    min-width: 0;
    flex: 1;
}

.page-nav-prev {
    text-align: left;
}

.page-nav-next {
    text-align: right;
    justify-content: flex-end;
}

.page-nav-home {
    flex: 0 0 auto;
}

.page-nav-home .navbar-icon {
    width: 20px;
    height: 20px;
}

/* ==========================================================================
   Photo-note card (journal timeline)
   ========================================================================== */

.photo-note-card {
    cursor: pointer;
    margin-bottom: var(--spacing-md);
    border-radius: var(--radius-md);
    overflow: hidden;
    border: 1px solid var(--color-border);
}

.photo-note-img {
    width: 100%;
    display: block;
    aspect-ratio: 4/3;
    object-fit: cover;
}

.photo-note-text {
    padding: var(--spacing-sm) var(--spacing-md);
    font-size: var(--font-size-base);
    line-height: var(--line-height-relaxed);
    color: var(--color-text);
}

/* ==========================================================================
   Photo modal — redesigned two-column layout
   ========================================================================== */

.photo-modal-body {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-md);
}

.photo-modal-image-col img.photo-modal-img {
    width: 100%;
    max-height: 50vh;
    object-fit: contain;
    border-radius: var(--radius-md);
}

.photo-modal-fields-col {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-sm);
}

.photo-modal-actions {
    display: flex;
    justify-content: space-between;
    gap: var(--spacing-sm);
    margin-top: auto;
}

/* Danger button variant */

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

.btn-danger:hover:not(:disabled) {
    opacity: 0.85;
}

/* Desktop two-column photo modal */

@media (min-width: 768px) {
    .photo-modal-content {
        max-width: 800px;
    }

    .photo-modal-body {
        flex-direction: row;
        align-items: stretch;
        min-height: 300px;
    }

    .photo-modal-image-col {
        flex: 1;
        display: flex;
        align-items: flex-start;
    }

    .photo-modal-image-col img.photo-modal-img {
        max-height: 60vh;
    }

    .photo-modal-fields-col {
        flex: 1;
    }
}
