/* ToDo App V6 - Responsive Design Fixes for iPhone/iPad compatibility */
/* Performance optimized: Reduced specificity, consolidated rules, minimal repaints */

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

/* V4.1: Mobile-first touch optimizations */
html {
    -webkit-text-size-adjust: 100%;
    -ms-text-size-adjust: 100%;
    touch-action: manipulation;
}

/* V4.1: Prevent zoom on input focus for iOS */
input, textarea, select {
    font-size: 16px;
}

@media (max-width: 768px) {
    input, textarea, select {
        font-size: 16px !important;
    }
}

:root {
    /* Theme color variables for efficient switching */
    --bg-primary: #fefcf8;
    --bg-secondary: #1a1a1a;
    --text-primary: #2d2d2d;
    --text-secondary: #e8e8e8;
    --accent-primary: #f0f8ff;
    --accent-secondary: #2a2a2a;
    --border-primary: #e0e0e0;
    --border-secondary: #404040;
    --button-primary: #6b73ff;
    --button-secondary: #5a62d8;
}

/* Theme Variations - Consolidated GPU-accelerated gradients */
.light-dawnwood {
    --theme-bg: linear-gradient(135deg, #ffd6e1 0%, #d6f0ff 50%, #d6ffd6 100%);
    --theme-card: rgba(255, 255, 255, 0.15);
    --theme-accent: #6b73ff;
    --theme-fullscreen-bg: #f8f9fa;
}

.light-mintgrove {
    --theme-bg: linear-gradient(135deg, #a8e6cf 0%, #7fcdcd 50%, #41b3a3 100%);
    --theme-card: rgba(255, 255, 255, 0.2);
    --theme-accent: #2980b9;
    --theme-fullscreen-bg: #e8f5f0;
}

.light-roselake {
    --theme-bg: linear-gradient(135deg, #ff9a9e 0%, #fecfef 50%, #fecfef 100%);
    --theme-card: rgba(255, 255, 255, 0.2);
    --theme-accent: #e74c3c;
    --theme-fullscreen-bg: #fdf2f2;
}

.dark-shadowfern {
    --theme-bg: linear-gradient(135deg, #2a1f3d 0%, #1f2a3d 50%, #1f3d2a 100%);
    --theme-card: rgba(0, 0, 0, 0.2);
    --theme-accent: #5a62d8;
    --theme-fullscreen-bg: #1e1e1e;
}

.dark-moonhollow {
    --theme-bg: linear-gradient(135deg, #0c0c0c 0%, #1a1a2e 50%, #16213e 100%);
    --theme-card: rgba(255, 255, 255, 0.05);
    --theme-accent: #00d4ff;
    --theme-fullscreen-bg: #111111;
}

.dark-seabough {
    --theme-bg: linear-gradient(135deg, #134e5e 0%, #2d8659 50%, #71b280 100%);
    --theme-card: rgba(0, 0, 0, 0.3);
    --theme-accent: #27ae60;
    --theme-fullscreen-bg: #0f2027;
}

/* Optimized Animations - Hardware accelerated */
@keyframes shake {
    0%, 100% { transform: translateX(0); }
    10%, 30%, 50%, 70%, 90% { transform: translateX(-2px); }
    20%, 40%, 60%, 80% { transform: translateX(2px); }
}

@keyframes searchPulse {
    0% { background-color: rgba(100, 149, 237, 0.8); box-shadow: 0 0 5px rgba(100, 149, 237, 0.6); }
    50% { background-color: rgba(100, 149, 237, 0.4); box-shadow: 0 0 3px rgba(100, 149, 237, 0.4); }
    100% { background-color: rgba(100, 149, 237, 0.8); box-shadow: 0 0 5px rgba(100, 149, 237, 0.6); }
}

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

@keyframes pulse {
    0% { opacity: 1; }
    50% { opacity: 0.5; }
    100% { opacity: 1; }
}

@keyframes slideInFromTop {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes fadeInOut {
    0% { opacity: 0; }
    10% { opacity: 1; }
    90% { opacity: 1; }
    100% { opacity: 0; }
}

@keyframes shimmer {
    0% { transform: translateX(-100%) translateY(-100%) rotate(45deg); }
    100% { transform: translateX(100%) translateY(100%) rotate(45deg); }
}

.shake {
    animation: shake 0.5s ease-in-out;
}

/* Search Highlighting - Optimized for performance */
.search-highlight {
    background-color: rgba(100, 149, 237, 0.6);
    padding: 0.1rem 0.2rem;
    border-radius: 3px;
    box-shadow: 0 0 3px rgba(100, 149, 237, 0.4);
}

.search-highlight.current {
    background-color: rgba(255, 140, 0, 0.8);
    animation: searchPulse 1s infinite;
    box-shadow: 0 0 5px rgba(255, 140, 0, 0.6);
}

/* Optimized Scrollbars - Reduced redundancy */
::-webkit-scrollbar {
    width: 12px;
    height: 12px;
}

::-webkit-scrollbar-track {
    background: var(--theme-bg);
    border-radius: 0px;
}

::-webkit-scrollbar-thumb {
    background: var(--theme-accent);
    border-radius: 6px;
    border: 2px solid rgba(255, 255, 255, 0.1);
}

::-webkit-scrollbar-thumb:hover {
    opacity: 0.8;
}

::-webkit-scrollbar-corner {
    background: var(--theme-bg) !important;
}

/* Editor-specific scrollbar */
.rich-editor::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

.rich-editor::-webkit-scrollbar-track {
    background: transparent;
    border-radius: 15px;
    margin: 15px 4px;
}

.rich-editor::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.4);
    border-radius: 15px;
    border: none;
    margin: 2px;
}

.rich-editor::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.6);
}

.rich-editor::-webkit-scrollbar-corner {
    background: transparent;
    border-radius: 15px;
}

/* Body & Layout - Optimized transitions */
body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    line-height: 1.6;
    transition: all 0.3s ease;
    min-height: 100vh;
    background: var(--theme-bg);
    color: var(--text-primary);
    overflow: auto;
}

/* Theme-specific text colors - Consolidated */
.dark-shadowfern, .dark-moonhollow, .dark-seabough {
    color: var(--text-secondary);
}

.light-dawnwood, .light-mintgrove, .light-roselake {
    color: #2d2d2d;
}

/* Spellcheck optimizations */
.rich-editor[spellcheck="false"] *:not(.text-underline):not(.text-strikethrough) {
    text-decoration: none !important;
}

.text-underline {
    text-decoration: underline !important;
}

.text-strikethrough {
    text-decoration: line-through !important;
}

/* Icon color optimizations - Reduced specificity */
.light-dawnwood .control-btn svg, .light-mintgrove .control-btn svg, .light-roselake .control-btn svg,
.light-dawnwood .theme-main-btn svg, .light-mintgrove .theme-main-btn svg, .light-roselake .theme-main-btn svg,
.light-dawnwood .logo svg, .light-mintgrove .logo svg, .light-roselake .logo svg,
.light-dawnwood .action-btn svg, .light-mintgrove .action-btn svg, .light-roselake .action-btn svg,
.light-dawnwood .search-icon, .light-mintgrove .search-icon, .light-roselake .search-icon,
.light-dawnwood .format-btn svg, .light-mintgrove .format-btn svg, .light-roselake .format-btn svg,
.light-dawnwood .calendar-nav-btn svg, .light-mintgrove .calendar-nav-btn svg, .light-roselake .calendar-nav-btn svg {
    color: #2d2d2d;
}

.light-dawnwood .search-btn, .light-mintgrove .search-btn, .light-roselake .search-btn,
.light-dawnwood .nav-btn, .light-mintgrove .nav-btn, .light-roselake .nav-btn {
    color: #2d2d2d !important;
}

.dark-shadowfern .control-btn svg, .dark-moonhollow .control-btn svg, .dark-seabough .control-btn svg,
.dark-shadowfern .theme-main-btn svg, .dark-moonhollow .theme-main-btn svg, .dark-seabough .theme-main-btn svg,
.dark-shadowfern .logo svg, .dark-moonhollow .logo svg, .dark-seabough .logo svg,
.dark-shadowfern .action-btn svg, .dark-moonhollow .action-btn svg, .dark-seabough .action-btn svg,
.dark-shadowfern .search-icon, .dark-moonhollow .search-icon, .dark-seabough .search-icon,
.dark-shadowfern .format-btn svg, .dark-moonhollow .format-btn svg, .dark-seabough .format-btn svg,
.dark-shadowfern .calendar-nav-btn svg, .dark-moonhollow .calendar-nav-btn svg, .dark-seabough .calendar-nav-btn svg {
    color: #ffffff;
}

/* Fullscreen mode */
body.fullscreen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    overflow: hidden;
    z-index: 9999;
    background: var(--theme-fullscreen-bg) !important;
}

/* V7: Mobile adjustments for editor save status */
@media (max-width: 768px) {
    .editor-save-status {
        bottom: -1.5rem;
        right: 0.5rem;
        padding: 0;
        font-size: 0.65rem;
    }
    
    .editor-save-status .save-status-icon {
        width: 10px;
        height: 10px;
    }
    
    .editor-save-status .save-status-text {
        font-size: 0.6rem;
    }
}

/* V4.1: Mobile fullscreen adjustments */
@media (max-width: 768px) {
    body.fullscreen {
        /* Account for mobile browser chrome */
        height: 100dvh; /* Dynamic viewport height for modern browsers */
        height: 100vh; /* Fallback for older browsers */
    }
    
    .fullscreen .container {
        padding: 0.5rem;
        min-height: calc(100dvh - 60px);
        min-height: calc(100vh - 60px); /* Fallback */
    }
    
    .fullscreen .rich-editor {
        height: calc(100dvh - 200px);
        height: calc(100vh - 200px); /* Fallback */
        max-height: calc(100dvh - 200px);
        max-height: calc(100vh - 200px); /* Fallback */
    }
}

/* Header - Enhanced with save status */
.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.5rem 2rem;
    backdrop-filter: blur(10px);
    background: rgba(255, 255, 255, 0.1);
    position: relative;
    z-index: 100;
}

.dark-shadowfern .header, .dark-moonhollow .header, .dark-seabough .header {
    background: rgba(0, 0, 0, 0.2);
}

.header-left {
    display: flex;
    align-items: center;
    gap: 2rem;
    flex: 1;
}

.header-center {
    display: flex;
    align-items: center;
    justify-content: center;
    flex: 1;
}

.logo {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.logo-image {
    height: 2.5rem;
    width: auto;
    max-width: 200px;
    object-fit: contain;
}

.fullscreen-indicator {
    display: none;
    background: rgba(255, 255, 255, 0.2);
    backdrop-filter: blur(10px);
    padding: 0.5rem 1rem;
    border-radius: 20px;
    font-size: 0.9rem;
    font-weight: 500;
}

.fullscreen .fullscreen-indicator {
    display: block;
}

.dark-shadowfern .fullscreen-indicator, .dark-moonhollow .fullscreen-indicator, .dark-seabough .fullscreen-indicator {
    background: rgba(0, 0, 0, 0.3);
}

/* Save Status UI */
.save-status {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background: rgba(255, 255, 255, 0.1);
    /*backdrop-filter: blur(10px);*/
    padding: 0.5rem 1rem;
    border-radius: 20px;
    cursor: pointer;
    transition: all 0.3s ease;
    border: 2px solid transparent;
}

.save-status:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: scale(1.05);
}

.dark-shadowfern .save-status, .dark-moonhollow .save-status, .dark-seabough .save-status {
    background: rgba(0, 0, 0, 0.2);
}

.dark-shadowfern .save-status:hover, .dark-moonhollow .save-status:hover, .dark-seabough .save-status:hover {
    background: rgba(0, 0, 0, 0.3);
}

.save-status-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    position: relative;
}

.save-status-icon svg {
    width: 16px;
    height: 16px;
    position: absolute;
    transition: all 0.3s ease;
}

.save-status-text {
    font-size: 0.9rem;
    font-weight: 500;
    color: inherit;
    transition: all 0.3s ease;
}

/* Save Status States */
.save-status.saved .status-saved {
    display: block;
    color: #27ae60;
}

.save-status.saving .status-saving {
    display: block;
    color: #f39c12;
    animation: spin 1s linear infinite;
}

.save-status.syncing .status-syncing {
    display: block;
    color: #3498db;
    animation: spin 2s linear infinite;
}

.save-status.error .status-error {
    display: block;
    color: #e74c3c;
    animation: pulse 1s infinite;
}

.save-status.error {
    border-color: #e74c3c;
    background: rgba(231, 76, 60, 0.1);
}

.save-status.saved .save-status-text { color: #27ae60; }
.save-status.saving .save-status-text { color: #f39c12; }
.save-status.syncing .save-status-text { color: #3498db; }
.save-status.error .save-status-text { color: #e74c3c; }

.header-controls {
    display: flex;
    align-items: center;
    gap: 1rem;
    flex: 1;
    justify-content: flex-end;
}

/* Theme Selector - Optimized positioning */
.theme-selector {
    display: flex;
    gap: 0.5rem;
    align-items: center;
    position: relative;
}

.theme-main-btn {
    width: 2.5rem;
    height: 2.5rem;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.3s ease;
    border: 2px solid transparent;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.2);
}

.theme-main-btn:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: scale(1.05);
    border: 2px solid rgba(255, 255, 255, 0.5);
}

.theme-main-btn.active {
    border: 2px solid var(--theme-accent);
    box-shadow: 0 0 10px var(--theme-accent);
}

.theme-main-btn svg {
    width: 18px;
    height: 18px;
    color: currentColor;
}

/* Theme Dropdowns - Optimized */
.light-theme-dropdown, .dark-theme-dropdown {
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    backdrop-filter: blur(15px);
    border-radius: 12px;
    padding: 0.5rem;
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.2);
    z-index: 30;
    min-width: 150px;
    display: none;
    margin-top: 0.5rem;
}

.light-theme-dropdown {
    background: rgba(255, 255, 255, 0.95);
}

.dark-theme-dropdown {
    background: rgba(30, 30, 30, 0.95);
}

.theme-option {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 0.9rem;
}

.light-theme-dropdown .theme-option {
    color: #2d2d2d;
}

.dark-theme-dropdown .theme-option {
    color: #ffffff;
}

.theme-option:hover, .theme-option.active {
    background: var(--theme-accent);
    color: white;
}

.theme-color {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    border: 2px solid rgba(255, 255, 255, 0.3);
}

/* Control Buttons - Optimized transitions */
.control-btn {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    border-radius: 20px;
    padding: 0.5rem;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 1.2rem;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 2.5rem;
    height: 2.5rem;
    border: 2px solid transparent;
}

.control-btn:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: scale(1.05);
}

.control-btn.active {
    border: 2px solid var(--theme-accent);
    box-shadow: 0 0 10px var(--theme-accent);
}

/* V7: Editor Save Status - positioned below editor container */
.editor-save-status {
    position: absolute;
    bottom: .5rem;
    right: 1rem;
    z-index: 10;
    background: none !important;
    border: none !important;
    border-radius: 0;
    padding: 0 !important;
    font-size: 0.75rem;
    min-width: auto;
    gap: 0.3rem;
    box-shadow: none !important;
    transform: none !important;
}

.editor-save-status:hover {
    background: none !important;
    transform: none !important;
}

.editor-save-status.error {
    background: none !important;
    border: none !important;
}

.editor-save-status .save-status-icon {
    width: 12px;
    height: 12px;
}

.editor-save-status .save-status-text {
    font-size: 0.7rem;
    font-weight: 500;
}

.editor-container {
    position: relative;
    padding-top: 0.5rem;
}

/* Container & Layout */
.container {
    max-width: 900px;
    margin: 0 auto;
    padding: 1rem 2rem 2rem 2rem;
    min-height: calc(100vh - 100px);
    position: relative;
}

.fullscreen .container {
    max-width: none;
    padding: 1rem;
    min-height: calc(100vh - 80px);
}

/* Todo Card */
.todo-card {
    background: var(--theme-card);
    backdrop-filter: blur(15px);
    border-radius: 20px;
    padding: 2rem;
    transition: all 0.3s ease;
    position: relative;
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
    gap: 1rem;
}

.card-title {
    font-size: 1.8rem;
    font-weight: 600;
    color: inherit;
}

.header-actions {
    display: flex;
    gap: 0.5rem;
    align-items: center;
    position: relative;
}

/* Action Buttons */
.action-btn {
    background: var(--theme-accent);
    border: none;
    border-radius: 15px;
    padding: 0.7rem;
    color: white;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 0.9rem;
    min-width: 2.5rem;
    height: 2.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
}

.action-btn.with-text {
    padding: 0.7rem 1.5rem;
    min-width: auto;
}

.action-btn:hover {
    transform: translateY(-2px);
    opacity: 0.9;
}

/* V7.1: IMPROVED Search Container - Better responsive layout */
.search-container {
    position: relative;
    margin-bottom: 1rem;
    display: flex;
    gap: 0.5rem;
    align-items: flex-start;
    flex-direction: column;
}

.search-container.below-editor {
    margin-top: 1rem;
    margin-bottom: 0;
    order: 3;
}

.fullscreen .search-container.below-editor {
    max-width: calc(100vw - 2rem);
    overflow-x: visible;
    margin-bottom: 1rem;
}

.fullscreen .search-container.below-editor .search-row {
    flex-wrap: wrap;
    gap: 0.5rem;
}

.fullscreen .formatting-toolbar.below-editor {
    max-width: calc(100vw - 2rem);
    overflow-x: visible;
    margin-bottom: 0;
}

.fullscreen .rich-editor {
    height: calc(100vh - 220px);
    max-height: calc(100vh - 220px);
}

.fullscreen .search-container.below-editor ~ .editor-container .rich-editor {
    height: calc(100vh - 380px);
    max-height: calc(100vh - 380px);
}

/* Buttons hidden state */
.buttons-hidden .search-container, .buttons-hidden .formatting-toolbar {
    display: none !important;
}

.buttons-hidden .rich-editor {
    height: 60vh;
    max-height: 60vh;
}

.fullscreen.buttons-hidden .rich-editor {
    height: calc(100vh - 120px);
    max-height: calc(100vh - 120px);
}

/* V7.1: FIXED Search Row - Better responsive behavior */
.search-row {
    display: flex;
    gap: 0.5rem;
    width: 100%;
    position: relative;
    align-items: center;
    flex-wrap: nowrap;
}

/* V7.1: IMPROVED Search Input with responsive clear button positioning */
.search-input {
    flex: 1;
    padding: 0.8rem 1rem 0.8rem 2.5rem; /* Increased right padding for search controls */
    border: none;
    border-radius: 15px;
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
    color: inherit;
    font-size: 0.9rem;
    outline: none;
    transition: all 0.3s ease;
    border: 2px solid transparent;
    min-width: 0; /* Allow input to shrink */
}

.search-input:focus {
    background: rgba(255, 255, 255, 0.15);
    border: 2px solid rgba(255, 255, 255, 0.3);
}

.dark-shadowfern .search-input, .dark-moonhollow .search-input, .dark-seabough .search-input {
    background: rgba(0, 0, 0, 0.2);
}

.dark-shadowfern .search-input:focus, .dark-moonhollow .search-input:focus, .dark-seabough .search-input:focus {
    background: rgba(0, 0, 0, 0.3);
    border: 2px solid rgba(255, 255, 255, 0.2);
}

/* V7.1: FIXED Search Icon - Consistent positioning */
.search-icon {
    position: absolute;
    left: 0.8rem;
    top: 50%;
    transform: translateY(-50%);
    color: rgba(255, 255, 255, 0.6);
    pointer-events: none;
    z-index: 2;
}

/* V7.1: FIXED Clear Search Button - Responsive positioning inside input */
.clear-search-btn {
    position: absolute;
    right: 11.5rem; /* Positioned to account for search controls width */
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    cursor: pointer;
    padding: 0.3rem;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: rgba(255, 255, 255, 0.6);
    transition: all 0.2s ease;
    z-index: 3;
    width: 24px;
    height: 24px;
}

.clear-search-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    color: rgba(255, 255, 255, 0.9);
    transform: translateY(-50%) scale(1.1);
}

.clear-search-btn:active {
    transform: translateY(-50%) scale(0.95);
}

.dark-shadowfern .clear-search-btn, .dark-moonhollow .clear-search-btn, .dark-seabough .clear-search-btn {
    color: rgba(255, 255, 255, 0.7);
}

.dark-shadowfern .clear-search-btn:hover, .dark-moonhollow .clear-search-btn:hover, .dark-seabough .clear-search-btn:hover {
    background: rgba(255, 255, 255, 0.15);
    color: rgba(255, 255, 255, 1);
}

.light-dawnwood .clear-search-btn, .light-mintgrove .clear-search-btn, .light-roselake .clear-search-btn {
    color: rgba(45, 45, 45, 0.6);
}

.light-dawnwood .clear-search-btn:hover, .light-mintgrove .clear-search-btn:hover, .light-roselake .clear-search-btn:hover {
    background: rgba(45, 45, 45, 0.1);
    color: rgba(45, 45, 45, 0.9);
}

/* V7.1: IMPROVED Search Controls - Better responsive layout */
.search-controls {
    display: flex;
    gap: 0.25rem;
    flex-shrink: 0; /* Prevent controls from shrinking */
}

/* Search & Navigation Buttons */
.search-btn, .nav-btn {
    background: var(--theme-accent);
    border: none;
    border-radius: 10px;
    padding: 0.8rem 1rem;
    color: white;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 0.8rem;
    white-space: nowrap; /* Prevent button text wrapping */
}

.nav-btn {
    padding: 0.8rem;
    font-size: 0.9rem;
}

.search-btn:hover, .nav-btn:hover {
    transform: translateY(-1px);
    opacity: 0.9;
}

.search-btn:disabled, .nav-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Search Messages */
.search-message {
    color: #fc6b6b;
    font-size: 0.85rem;
    margin-top: 0.5rem;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.search-message.show {
    opacity: 1;
}

.search-message.success {
    color: #27ae60;
}

.search-message.info {
    color: #3498db;
}

/* V8.1: Tag Mode Indicator */
.tag-mode-indicator {
    display: none;
    align-items: center;
    gap: 0.5rem;
    background: var(--theme-accent);
    background: color-mix(in srgb, var(--theme-accent) 15%, transparent);
    color: var(--theme-accent);
    padding: 0.75rem 1rem;
    border-radius: 0.75rem;
    font-size: 0.9rem;
    font-weight: 500;
    margin: 0.75rem 0;
    backdrop-filter: blur(10px);
    opacity: 0.15;
    box-shadow: 0 2px 8px var(--theme-accent);
    box-shadow: 0 2px 8px color-mix(in srgb, var(--theme-accent) 10%, transparent);
}

.tag-mode-indicator svg {
    width: 16px;
    height: 16px;
    opacity: 0.8;
}

.tag-mode-indicator span {
    font-weight: 500;
}

/* V8.2: Automatic Hashtag Styling */
.hashtag {
    color: var(--theme-accent, #6b73ff) !important;
    font-weight: 600;
    transition: all 0.2s ease;
}

.hashtag:hover {
    opacity: 0.8;
}

/* Theme-specific hashtag colors */
.light-dawnwood .hashtag {
    color: var(--theme-accent) !important;
}

.light-mintgrove .hashtag {
    color: #2980b9 !important;
}

.light-roselake .hashtag {
    color: #e74c3c !important;
}

.dark-shadowfern .hashtag {
    color: #5a62d8 !important;
}

.dark-moonhollow .hashtag {
    color: #00d4ff !important;
}

.dark-seabough .hashtag {
    color: #27ae60 !important;
}

/* V7.1: IMPROVED Formatting Toolbar - Better responsive behavior */
.formatting-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(15px);
    border-radius: 12px;
    padding: 0.75rem;
    gap: 0.5rem;
    margin-bottom: 1rem;
    flex-wrap: nowrap;
    min-width: 0;
}

.formatting-toolbar.below-editor {
    margin-top: 1rem;
    margin-bottom: 0;
    order: 2;
}

.dark-shadowfern .formatting-toolbar, .dark-moonhollow .formatting-toolbar, .dark-seabough .formatting-toolbar {
    background: rgba(0, 0, 0, 0.2);
}

/* V7.1: FIXED Format Buttons - Better responsive layout */
.format-buttons {
    display: flex;
    gap: 0.3rem;
    flex-wrap: wrap;
    flex: 1;
    min-width: 0;
}

/* V7.1: FIXED Undo/Redo Buttons - Prevent wrapping and moving */
.undo-redo-buttons {
    display: flex;
    gap: 0.3rem;
    flex-shrink: 0; /* Prevent shrinking */
    margin-left: auto; /* Push to right */
}

/* Format Buttons */
.format-btn {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    border-radius: 8px;
    padding: 0.5rem;
    cursor: pointer;
    font-size: 0.9rem;
    transition: all 0.2s ease;
    color: inherit;
    font-weight: 500;
    min-width: 2.5rem;
    height: 2.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
}

.format-btn:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: scale(1.05);
}

/* Removed active state styling for formatting buttons per V1 behavior */
.format-btn.active {
    /* No special styling - buttons should not show active state */
}

.dark-shadowfern .format-btn, .dark-moonhollow .format-btn, .dark-seabough .format-btn {
    background: rgba(255, 255, 255, 0.1);
}

.dark-shadowfern .format-btn:hover, .dark-moonhollow .format-btn:hover, .dark-seabough .format-btn:hover {
    background: rgba(255, 255, 255, 0.2);
}

/* Editor Container */
.editor-container {
    position: relative;
    order: 1;
}

/* Rich Editor - Optimized for performance */
.rich-editor {
    width: 100%;
    height: 50vh;
    max-height: 50vh;
    padding: 1.5rem;
    border: none;
    border-radius: 15px;
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
    color: inherit;
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
    font-size: 0.95rem;
    overflow-y: auto;
    box-sizing: border-box;
    line-height: 1.8;
    outline: none;
    transition: all 0.3s ease;
    border: 2px solid transparent;
    resize: none;
}

.rich-editor.expanded {
    min-height: 60vh;
}

.rich-editor:focus {
    background: rgba(255, 255, 255, 0.15);
    border: 2px solid rgba(255, 255, 255, 0.3);
}

.dark-shadowfern .rich-editor, .dark-moonhollow .rich-editor, .dark-seabough .rich-editor {
    background: rgba(0, 0, 0, 0.2);
}

.dark-shadowfern .rich-editor:focus, .dark-moonhollow .rich-editor:focus, .dark-seabough .rich-editor:focus {
    background: rgba(0, 0, 0, 0.3);
    border: 2px solid rgba(255, 255, 255, 0.2);
}

/* Rich Text Formatting - Optimized */
.highlight {
    background-color: rgba(255, 255, 0, 0.4);
    padding: 0.1rem 0.2rem;
    border-radius: 3px;
}

.text-red { 
    color: #ff6b6b;
    font-weight: 500;
}

.text-blue { 
    color: #4ecdc4;
    font-weight: 500;
}

.text-bold { font-weight: bold; }
.text-italic { font-style: italic; }
.text-underline { text-decoration: underline; }
.text-strikethrough { text-decoration: line-through; }

/* Done/Complete functionality styles - Fixed to only highlight text, not whole line */
.text-done {
    background-color: rgba(34, 197, 94, 0.3);
    color: #16a34a;
    font-weight: 500;
    padding: 0.1rem 0.2rem;
    border-radius: 3px;
}

/* Placeholder text styling - V1 behavior */
.placeholder-text {
    color: rgba(128, 128, 128, 0.7);
    font-style: italic;
    opacity: 0.8;
    pointer-events: none;
    user-select: none;
}

.dark-shadowfern .placeholder-text, .dark-moonhollow .placeholder-text, .dark-seabough .placeholder-text {
    color: rgba(200, 200, 200, 0.5);
}

/* Placeholder overlay - V1 style background placeholder */
.placeholder-overlay {
    position: absolute;
    top: 80px; /* Position after date line */
    left: 25px;
    color: rgba(128, 128, 128, 0.6);
    font-style: italic;
    pointer-events: none;
    user-select: none;
    z-index: 0;
    font-size: inherit;
    line-height: inherit;
}

.dark-shadowfern .placeholder-overlay, .dark-moonhollow .placeholder-overlay, .dark-seabough .placeholder-overlay {
    color: rgba(200, 200, 200, 0.4);
}

/* Date Line Styling */
.date-line {
    font-weight: 600;
    background: rgba(255, 255, 255, 0.2);
    padding: 0.5rem 1rem;
    border-radius: 8px;
    margin: 0.5rem 0;
    display: block;
    text-align: center;
    user-select: none;
    pointer-events: none;
    border-left: 4px solid var(--theme-accent);
    contenteditable: false !important;
}

.dark-shadowfern .date-line, .dark-moonhollow .date-line, .dark-seabough .date-line {
    background: rgba(0, 0, 0, 0.2);
}

/* Modal System - Optimized */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1000;
    backdrop-filter: blur(5px);
}

.modal-content {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(15px);
    border-radius: 20px;
    padding: 2rem;
    max-width: 500px;
    width: 90%;
    max-height: 80vh;
    overflow-y: auto;
    color: var(--text-primary);
}

.dark-shadowfern .modal-content, .dark-moonhollow .modal-content, .dark-seabough .modal-content {
    background: rgba(30, 30, 30, 0.95);
    color: var(--text-secondary);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

.close-btn {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: inherit;
    opacity: 0.7;
}

.close-btn:hover {
    opacity: 1;
}

/* Settings - Optimized */
.setting-group {
    margin-bottom: 1.5rem;
}

.setting-label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
    color: inherit;
}

.setting-select {
    width: 100%;
    padding: 0.8rem 2rem 0.8rem 1rem;
    border: none;
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.8);
    color: var(--text-primary);
    font-size: 1rem;
    backdrop-filter: blur(5px);
    cursor: pointer;
    appearance: none;
    background-image: url('data:image/svg+xml;charset=US-ASCII,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 4 5"><path fill="%23666" d="M2 0L0 2h4zm0 5L0 3h4z"/></svg>');
    background-repeat: no-repeat;
    background-position: right 1rem center;
    background-size: 12px;
}

.setting-select:hover {
    background: var(--theme-accent);
    color: white;
    background-image: none;
}

.dark-shadowfern .setting-select, .dark-moonhollow .setting-select, .dark-seabough .setting-select {
    background: rgba(60, 60, 60, 0.9);
    color: var(--text-secondary);
    background-image: url('data:image/svg+xml;charset=US-ASCII,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 4 5"><path fill="%23ffffff" d="M2 0L0 2h4zm0 5L0 3h4z"/></svg>');
    background-repeat: no-repeat;
    background-position: right 1rem center;
    background-size: 12px;
}

.dark-shadowfern .setting-select:hover, .dark-moonhollow .setting-select:hover, .dark-seabough .setting-select:hover {
    background: var(--theme-accent);
    color: white;
    background-image: none;
}

/* Calendar Popup - V3.16 COMPLETELY REDESIGNED */
.calendar-popup {
    position: absolute;
    top: 100%;
    right: 0;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(15px);
    border-radius: 15px;
    padding: 1rem;
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.2);
    z-index: 20;
    min-width: 320px;
    max-height: 400px;
    overflow-y: auto;
    display: none;
    margin-top: 0.5rem;
}

.dark-shadowfern .calendar-popup, .dark-moonhollow .calendar-popup, .dark-seabough .calendar-popup {
    background: rgba(0, 0, 0, 0.95);
}

/* V3.16 NEW: Calendar Navigation */
.calendar-navigation {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    padding: 0.5rem 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.2);
}

.dark-shadowfern .calendar-navigation, .dark-moonhollow .calendar-navigation, .dark-seabough .calendar-navigation {
    border-bottom-color: rgba(255, 255, 255, 0.1);
}

.calendar-nav-btn {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    border-radius: 8px;
    padding: 0.5rem;
    cursor: pointer;
    transition: all 0.2s ease;
    color: inherit;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
}

.calendar-nav-btn:hover:not(:disabled) {
    background: rgba(255, 255, 255, 0.3);
    transform: scale(1.05);
}

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

.dark-shadowfern .calendar-nav-btn, .dark-moonhollow .calendar-nav-btn, .dark-seabough .calendar-nav-btn {
    background: rgba(255, 255, 255, 0.1);
}

.dark-shadowfern .calendar-nav-btn:hover, .dark-moonhollow .calendar-nav-btn:hover, .dark-seabough .calendar-nav-btn:hover {
    background: rgba(255, 255, 255, 0.2);
}

.calendar-month {
    font-weight: 600;
    font-size: 1rem;
    color: inherit;
}

.date-item {
    padding: 0.7rem;
    border-radius: 8px;
    cursor: pointer;
    margin-bottom: 0.25rem;
    transition: all 0.2s ease;
    font-weight: 500;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
}

.date-item:hover {
    background: rgba(255, 255, 255, 0.3);
}

.dark-shadowfern .date-item:hover, .dark-moonhollow .date-item:hover, .dark-seabough .date-item:hover {
    background: rgba(255, 255, 255, 0.1);
}

/* V3.16 ENHANCED: Special styling for today */
.date-item.today {
    background: var(--theme-accent);
    color: white;
    font-weight: 600;
}

.date-item.today:hover {
    background: var(--theme-accent);
    opacity: 0.9;
}

/* V3.16 ENHANCED: Visual indicators for date types */
.date-item .date-indicator {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--theme-accent);
    margin-right: 0.5rem;
}

.date-item.today .date-indicator {
    background: white;
}

.date-item.has-content .date-indicator {
    background: #27ae60;
}

.date-item.today.has-content .date-indicator {
    background: rgba(255, 255, 255, 0.9);
}

/* V3.16 NEW: Date status indicators */
.date-status {
    font-size: 0.8rem;
    opacity: 0.7;
    font-weight: 400;
}

/* Tips Section - Optimized */
.tips-section {
    margin-top: 1.5rem;
    padding: 1rem;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    font-size: 0.9rem;
    opacity: 0.9;
    border-left: 4px solid var(--theme-accent);
    order: 4;
}

.tips-section.hidden {
    display: none;
}

.fullscreen .tips-section {
    display: none;
}

.dark-shadowfern .tips-section, .dark-moonhollow .tips-section, .dark-seabough .tips-section {
    background: rgba(0, 0, 0, 0.2);
}

.tip-item {
    margin-bottom: 0.5rem;
}

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

.tip-examples {
    margin-top: 0.5rem;
    font-size: 0.85rem;
    opacity: 0.8;
    padding-left: 1rem;
}

.tip-examples div {
    margin: 0.2rem 0;
}

.shortcut {
    background: rgba(255, 255, 255, 0.2);
    padding: 0.2rem 0.4rem;
    border-radius: 4px;
    font-family: monospace;
    font-size: 0.8rem;
}

.dark-shadowfern .shortcut, .dark-moonhollow .shortcut, .dark-seabough .shortcut {
    background: rgba(255, 255, 255, 0.1);
}

/* Footer */
.footer {
    text-align: center;
    padding: 1.5rem;
    opacity: 0.7;
}

.footer-logo {
    height: 2rem;
    width: auto;
    max-width: 150px;
    object-fit: contain;
}

.todo-content {
    display: flex;
    flex-direction: column;
}

/* V6.1: Bullet Mode Styles */
.rich-editor.bullet-mode {
    position: relative;
    padding-left: 35px;
}

.bullet-container {
    position: absolute;
    left: 10px;
    top: 0;
    width: 20px;
    height: 100%;
    pointer-events: none;
    user-select: none;
    z-index: 10;
}

.bullet-point {
    position: absolute;
    left: 0px;
    width: 6px;
    height: 6px;
    background-color: var(--theme-accent);
    border-radius: 50%;
    opacity: 0.8;
    pointer-events: none;
    user-select: none;
}

/* V6.1: Mobile bullet positioning */
@media (max-width: 768px) {
    .bullet-container {
        left: -15px;
        width: 10px;
    }
    
    .bullet-point {
        width: 3px;
        height: 3px;
    }
}

/* V6.1: Ensure bullets don't interfere with text selection */
.rich-editor.bullet-mode .bullet-container,
.rich-editor.bullet-mode .bullet-point {
    pointer-events: none;
    user-select: none;
}

/* V6.1: Setting help text */
.setting-help {
    display: block;
    font-size: 0.8em;
    color: var(--text-color);
    opacity: 0.7;
    margin-top: 4px;
}

/* V8.6: Experimental Mode Styles (moved from HTML) */
.experimental-section {
    margin-top: 15px;
    padding: 15px;
    background: var(--theme-accent);
    background: linear-gradient(135deg, color-mix(in srgb, var(--theme-accent) 10%, transparent), color-mix(in srgb, var(--theme-accent) 15%, transparent));
    border-radius: 12px;
    border: 2px dashed var(--theme-accent);
    border: 2px dashed color-mix(in srgb, var(--theme-accent) 30%, transparent);
    position: relative;
    overflow: hidden;
    opacity: 1;
}

.experimental-section::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: linear-gradient(45deg, 
        transparent 30%, 
        var(--theme-accent) 50%, 
        transparent 70%);
    background: linear-gradient(45deg, 
        transparent 30%, 
        color-mix(in srgb, var(--theme-accent) 5%, transparent) 50%, 
        transparent 70%);
    animation: shimmer 3s ease-in-out infinite;
    pointer-events: none;
    opacity: 0.02;
}

.experimental-feature {
    position: relative;
    z-index: 1;
    margin-bottom: 10px;
}

.experimental-feature:last-child {
    margin-bottom: 0;
}

.experimental-feature .setting-label {
    color: var(--theme-accent);
    font-weight: 600;
}

.setting-group .setting-help {
    color: #666;
    font-size: 12px;
    margin-top: 4px;
    display: block;
}

.mode-conflict-warning {
    background: rgb(255, 107, 107);
    border: 2px solid rgba(255, 152, 0, 0.3);
    border-radius: 8px;
    padding: 10px;
    margin-bottom: 15px;
    color: #ff9800;
    font-size: 13px;
    text-align: center;
}

.error-modal {
    z-index: 2000;
}

.error-content {
    max-width: 400px;
    border: 2px solid #ff6b6b;
}

.error-header {
    color: white;
}

.error-header h2 {
    margin: 0;
    font-size: 18px;
}

.error-body {
    padding: 20px;
    text-align: center;
}

.error-body p {
    margin: 0 0 20px 0;
    color: #333;
}

.error-actions {
    display: flex;
    justify-content: center;
}

.error-btn {
    padding: 8px 20px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.2s;
}

.error-btn.primary {
    background: #ff6b6b;
    color: white;
}

.error-btn.primary:hover {
    background: #ff6b6b;
}

[class*="dark-"] .experimental-section {
    background: linear-gradient(135deg, rgba(90, 98, 216, 0.15), rgba(0, 212, 255, 0.15));
    border-color: rgba(90, 98, 216, 0.4);
}

[class*="dark-"] .experimental-feature .setting-label {
    color: #7c84ff;
}

[class*="dark-"] .setting-group .setting-help {
    color: #aaa;
}

[class*="dark-"] .mode-conflict-warning {
    background: rgba(255, 152, 0, 0.15);
    color: #ffb74d;
}

/* V7: Dark theme adjustments for editor save status */
[class*="dark-"] .editor-save-status {
    background: none;
    border: none;
}

[class*="dark-"] .error-body p {
    color: #ddd;
}

/* V2 Sync specific styles */
.share-body {
    padding: 1rem 0;
}

.share-link-container {
    display: flex;
    gap: 0.5rem;
    margin: 1rem 0;
}

.share-link-input {
    flex: 1;
    padding: 0.8rem 1rem;
    border: none;
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.8);
    color: var(--text-primary);
    font-size: 0.9rem;
    font-family: monospace;
}

.dark-shadowfern .share-link-input, .dark-moonhollow .share-link-input, .dark-seabough .share-link-input {
    background: rgba(60, 60, 60, 0.9);
    color: var(--text-secondary);
}

.copy-btn {
    background: var(--theme-accent);
    border: none;
    border-radius: 10px;
    padding: 0.8rem;
    color: white;
    cursor: pointer;
    transition: all 0.3s ease;
    min-width: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.copy-btn:hover {
    opacity: 0.9;
    transform: scale(1.05);
}

.qr-code-container {
    display: flex;
    justify-content: center;
    margin: 1rem 0;
}

.share-warning {
    font-size: 0.85rem;
    color: #e74c3c;
    text-align: center;
    margin-top: 1rem;
    padding: 0.5rem;
    background: rgba(231, 76, 60, 0.1);
    border-radius: 8px;
}

.migration-body {
    text-align: center;
    padding: 1rem 0;
}

.migration-options {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    margin: 1.5rem 0;
}

.migration-btn {
    padding: 1rem;
    border: none;
    border-radius: 15px;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.3s ease;
    text-align: left;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.migration-btn.primary {
    background: var(--theme-accent);
    color: white;
}

.migration-btn.secondary {
    background: rgba(255, 255, 255, 0.1);
    color: inherit;
}

.dark-shadowfern .migration-btn.secondary, .dark-moonhollow .migration-btn.secondary, .dark-seabough .migration-btn.secondary {
    background: rgba(255, 255, 255, 0.05);
}

.migration-btn:hover {
    transform: translateY(-2px);
    opacity: 0.9;
}

.migration-btn small {
    font-weight: 400;
    opacity: 0.8;
}

.migration-info {
    font-size: 0.9rem;
    opacity: 0.8;
    margin-top: 1rem;
}

.toast {
    position: fixed;
    top: 100px;
    right: 20px;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(15px);
    padding: 1rem;
    border-radius: 15px;
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.2);
    z-index: 1100;
    animation: slideInFromTop 0.3s ease-out;
    max-width: 300px;
}

.dark-shadowfern .toast, .dark-moonhollow .toast, .dark-seabough .toast {
    background: rgba(30, 30, 30, 0.95);
    color: var(--text-secondary);
}

.toast-content {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.toast-icon {
    font-size: 1.2rem;
}

.toast-message {
    font-weight: 500;
}

/* ENHANCED RESPONSIVE DESIGN FIXES for iPhone/iPad compatibility */

/* iPad Pro (1024px) and larger tablets */
@media (min-width: 1025px) {
    .header {
        padding: 1.5rem 2rem;
    }
    
    .container {
        padding: 1rem 2rem 2rem 2rem;
    }
}

/* iPad Mini Portrait - Specific fix for 768x1024 */
@media (min-width: 768px) and (max-width: 768px) {
    .header {
        padding: 1.2rem 1.5rem;
        flex-direction: row !important;
        gap: 1rem;
        justify-content: space-between;
        align-items: center;
    }
    
    .header-left {
        flex: 0 0 auto;
        order: 1;
        gap: 1.5rem;
        justify-content: flex-start;
    }
    
    .header-center {
        flex: 1;
        order: 2;
        justify-content: center;
    }
    
    .header-controls {
        flex: 0 0 auto;
        order: 3;
        gap: 0.8rem;
        justify-content: flex-end;
        flex-wrap: nowrap;
    }
    
    .search-row {
        flex-direction: row !important;
        align-items: center;
        gap: 0.5rem;
    }
    
    .formatting-toolbar {
        flex-direction: row !important;
        flex-wrap: nowrap;
        justify-content: space-between;
        align-items: center;
    }
}

/* iPad Mini and regular iPad (768px - 1024px) - FIXED for iPad Mini */
@media (min-width: 768px) and (max-width: 1024px) {
    .header {
        padding: 1.2rem 1.5rem;
        flex-direction: row;
        gap: 1rem;
        justify-content: space-between;
        align-items: center;
    }
    
    .header-left {
        flex: 0 0 auto;
        order: 1;
        gap: 1.5rem;
    }
    
    .header-center {
        flex: 1;
        order: 2;
        justify-content: center;
    }
    
    .header-controls {
        flex: 0 0 auto;
        order: 3;
        gap: 0.8rem;
        justify-content: flex-end;
    }
    
    .container {
        padding: 1rem 1.5rem 2rem 1.5rem;
    }
    
    .save-status {
        font-size: 0.85rem;
        padding: 0.4rem 0.8rem;
    }
    
    .control-btn, .theme-main-btn {
        width: 2.8rem;
        height: 2.8rem;
    }
    
    /* iPad Mini: Keep search row horizontal, not stacked */
    .search-row {
        flex-direction: row;
        align-items: center;
        gap: 0.5rem;
    }
    
    .search-input {
        padding-right: 8.5rem;
        font-size: 0.9rem;
    }
    
    .clear-search-btn {
        right: 11.5rem;
    }
    
    .search-controls {
        display: flex;
        gap: 0.25rem;
        flex-shrink: 0;
    }
    
    /* iPad Mini: Keep formatting toolbar horizontal */
    .formatting-toolbar {
        flex-direction: row;
        flex-wrap: nowrap;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
        -ms-overflow-style: none;
        justify-content: space-between;
        align-items: center;
    }
    
    .formatting-toolbar::-webkit-scrollbar {
        display: none;
    }
    
    .format-buttons {
        flex-wrap: nowrap;
        min-width: max-content;
        display: flex;
        gap: 0.3rem;
    }
    
    .format-btn {
        min-width: 2.8rem;
        height: 2.8rem;
        flex-shrink: 0;
    }
    
    .undo-redo-buttons {
        flex-shrink: 0;
        margin-left: 1rem;
        display: flex;
        gap: 0.3rem;
    }
    
    .rich-editor {
        font-size: 0.95rem;
        padding: 1.5rem;
    }
}

/* Large mobile / Small tablet (481px - 767px) - FIXED boundary to exclude iPad Mini */
@media (min-width: 481px) and (max-width: 767px) {
    .header {
        padding: 1rem;
        flex-direction: column;
        gap: 1rem;
    }
    
    .header-left {
        justify-content: center;
        order: 1;
        gap: 1.5rem;
    }
    
    .header-center {
        order: 2;
    }
    
    .header-controls {
        justify-content: center;
        flex-wrap: wrap;
        order: 3;
        gap: 1rem;
    }
    
    .save-status {
        order: -1;
        margin-bottom: 0.5rem;
    }
    
    .container {
        padding: 0.8rem 1rem 1.5rem 1rem;
    }
    
    .todo-card {
        padding: 1.5rem;
    }
    
    .card-header {
        flex-direction: column;
        text-align: center;
        gap: 1rem;
        margin-bottom: 1.2rem;
    }
    
    .search-row {
        flex-direction: column;
        gap: 1rem;
    }
    
    .search-input {
        padding: 1rem 3.5rem 1rem 3.5rem;
        font-size: 1rem;
        border-radius: 12px;
    }
    
    .search-icon {
        left: 1.2rem;
        top: 50%;
        transform: translateY(-50%);
    }
    
    .clear-search-btn {
        right: 1rem;
        top: 50%;
        transform: translateY(-50%);
        width: 2.8rem;
        height: 2.8rem;
    }
    
    .search-controls {
        justify-content: center;
        gap: 0.8rem;
    }
    
    .search-btn, .nav-btn {
        padding: 1rem 1.5rem;
        font-size: 0.9rem;
        border-radius: 12px;
        min-height: 3rem;
    }
    
    .nav-btn {
        min-width: 3rem;
        padding: 1rem;
    }
    
    .formatting-toolbar {
        flex-direction: column;
        gap: 1rem;
        padding: 1rem;
        border-radius: 15px;
    }
    
    .format-buttons {
        justify-content: center;
        flex-wrap: wrap;
        gap: 0.5rem;
    }
    
    .format-btn {
        min-width: 3rem;
        height: 3rem;
        border-radius: 10px;
        font-size: 0.9rem;
    }
    
    .undo-redo-buttons {
        justify-content: center;
        margin-left: 0;
        gap: 0.8rem;
    }
    
    .rich-editor {
        padding: 1.2rem;
        font-size: 1rem;
        line-height: 1.8;
        border-radius: 15px;
        min-height: 45vh;
    }
    
    .calendar-popup {
        position: fixed;
        top: 50%;
        left: 50%;
        transform: translate(-50%, -50%);
        width: 85vw;
        max-width: 380px;
        z-index: 1001;
    }
}

/* iPhone 14 Pro Max specific (430px) */
@media (min-width: 428px) and (max-width: 432px) {
    /* Hide fullscreen button on iPhone 14 Pro Max - not supported */
    #fullscreenBtn {
        display: none !important;
    }
    
    /* Compact wrapping toolbar for iPhone 14 Pro Max - Updated to match iPhone 12 style */
    .formatting-toolbar {
        flex-direction: column;
        flex-wrap: nowrap;
        padding: 0.6rem;
        margin-bottom: 0.6rem;
        gap: 0.5rem;
        border-radius: 12px;
        justify-content: center;
        align-items: center;
    }
    
    .format-buttons {
        display: flex;
        gap: 0.3rem;
        flex-wrap: wrap;
        justify-content: center;
        align-items: center;
        width: 100%;
    }
    
    .format-btn {
        min-width: 2.4rem;
        height: 2.4rem;
        padding: 0.5rem;
        font-size: 0.8rem;
        border-radius: 6px;
        flex-shrink: 0;
    }
    
    .undo-redo-buttons {
        display: flex;
        gap: 0.3rem;
        justify-content: center;
        margin-left: 0;
    }
    
    /* Optimized other elements for iPhone 14 Pro Max */
    .header {
        flex-direction: column;
        padding: 0.5rem 0.7rem;
        gap: 0.5rem;
    }
    
    .container {
        padding: 0.6rem;
    }
    
    .todo-card {
        min-height: 50vh;
        padding: 0.9rem;
        font-size: 0.9rem;
    }
    
    .search-container {
        margin-bottom: 0.6rem;
    }
    
    .rich-editor {
        min-height: 48vh;
        padding: 0.9rem;
    }
}

/* iPhone 12 Pro specific (390px) */
@media (min-width: 388px) and (max-width: 392px) {
    /* Hide fullscreen button on iPhone 12 Pro - not supported */
    #fullscreenBtn {
        display: none !important;
    }
    
    /* Compact wrapping toolbar for iPhone 12 Pro - FIXED to show all buttons */
    .formatting-toolbar {
        flex-direction: column;
        flex-wrap: nowrap;
        padding: 0.6rem;
        margin-bottom: 0.6rem;
        gap: 0.5rem;
        border-radius: 12px;
        justify-content: center;
        align-items: center;
    }
    
    .format-buttons {
        display: flex;
        gap: 0.3rem;
        flex-wrap: wrap;
        justify-content: center;
        align-items: center;
        width: 100%;
    }
    
    .format-btn {
        min-width: 2.4rem;
        height: 2.4rem;
        padding: 0.5rem;
        font-size: 0.8rem;
        border-radius: 6px;
        flex-shrink: 0;
    }
    
    .undo-redo-buttons {
        display: flex;
        gap: 0.3rem;
        justify-content: center;
        margin-left: 0;
    }
    
    /* Optimized other elements for 390px width */
    .header {
        padding: 0.6rem 0.8rem;
        gap: 0.6rem;
    }
    
    .container {
        padding: 0.6rem;
    }
    
    .todo-card {
        padding: 0.8rem;
    }
    
    .search-container {
        margin-bottom: 0.6rem;
    }
    
    .search-row {
        flex-direction: column;
        gap: 0.6rem;
    }
    
    .search-input {
        padding: 0.8rem 2.8rem 0.8rem 2.8rem;
        font-size: 0.9rem;
        border-radius: 10px;
    }
    
    .search-icon {
		top: 1.8rem;
        left: 1rem;
        width: 16px;
        height: 16px;
    }
    
    .clear-search-btn {
		top: 1.8rem;
        right: 0.6rem;
        width: 2rem;
        height: 2rem;
        padding: 0.3rem;
    }
    
    .search-controls {
        justify-content: center;
        gap: 0.4rem;
    }
    
    .search-btn, .nav-btn {
        padding: 0.7rem 0.9rem;
        font-size: 0.8rem;
        min-height: 2.6rem;
        border-radius: 10px;
    }
    
    .nav-btn {
        min-width: 2.6rem;
        padding: 0.7rem;
    }
    
    .rich-editor {
        min-height: 50vh;
        padding: 0.9rem;
        font-size: 0.9rem;
    }
    
    /* Compact header for iPhone 12 Pro */
    .header {
        flex-direction: column;
        padding: 0.5rem 0.7rem;
        gap: 0.5rem;
    }
    
    .header-left {
        justify-content: center;
        order: 1;
    }
    
    .header-center {
        order: 3;
    }
    
    .header-controls {
        justify-content: center;
        flex-wrap: wrap;
        order: 2;
        gap: 0.5rem;
    }
    
    .save-status {
        font-size: 0.75rem;
        padding: 0.3rem 0.6rem;
        margin-bottom: 0.2rem;
    }
    
    .control-btn, .theme-main-btn {
        width: 2.6rem;
        height: 2.6rem;
        padding: 0.5rem;
    }
    
    .card-header {
        flex-direction: column;
        align-items: center;
        gap: 0.6rem;
        margin-bottom: 0.6rem;
    }
    
    .card-title {
        text-align: center;
        font-size: 1.4rem;
    }

    .header-actions {
        justify-content: center;
        gap: 0.5rem;
    }
    
    .action-btn {
        min-width: 2.6rem;
        height: 2.6rem;
        padding: 0.7rem;
        border-radius: 10px;
    }
}

/* iPhone SE specific (375px) */
@media (min-width: 373px) and (max-width: 377px) {
    /* Hide fullscreen button on iPhone SE - not supported */
    #fullscreenBtn {
        display: none !important;
    }
    
    /* V7: Extra small save status for iPhone SE */
    .editor-save-status {
        bottom: -1.2rem;
        right: 0.3rem;
        padding: 0;
        font-size: 0.6rem;
    }
    
    .editor-save-status .save-status-icon {
        width: 8px;
        height: 8px;
    }
    
    .editor-save-status .save-status-text {
        font-size: 0.55rem;
    }
    
    /* Compact wrapping toolbar for iPhone SE - optimized for 375px width */
    .formatting-toolbar {
        flex-direction: column;
        flex-wrap: nowrap;
        padding: 0.5rem;
        margin-bottom: 0.5rem;
        gap: 0.4rem;
        border-radius: 10px;
        justify-content: center;
        align-items: center;
    }
    
    .format-buttons {
        display: flex;
        gap: 0.25rem;
        flex-wrap: wrap;
        justify-content: center;
        align-items: center;
        width: 100%;
    }
    
    .format-btn {
        min-width: 2.2rem;
        height: 2.2rem;
        padding: 0.4rem;
        font-size: 0.75rem;
        border-radius: 5px;
        flex-shrink: 0;
    }
    
    .undo-redo-buttons {
        display: flex;
        gap: 0.25rem;
        justify-content: center;
        margin-left: 0;
    }
    
    /* Optimized other elements for 375px width */
    .header {
        flex-direction: column;
        padding: 0.4rem 0.6rem;
        gap: 0.4rem;
    }
    
    .header-left {
        justify-content: center;
        order: 1;
    }
    
    .header-center {
        order: 3;
    }
    
    .header-controls {
        justify-content: center;
        flex-wrap: wrap;
        order: 2;
        gap: 0.4rem;
    }
    
    .save-status {
        font-size: 0.7rem;
        padding: 0.25rem 0.5rem;
        margin-bottom: 0.1rem;
    }
    
    .control-btn, .theme-main-btn {
        width: 2.4rem;
        height: 2.4rem;
        padding: 0.4rem;
    }
    
    .container {
        padding: 0.5rem;
    }
    
    .todo-card {
        padding: 0.7rem;
        border-radius: 12px;
    }
    
    .card-header {
        flex-direction: column;
        align-items: center;
        gap: 0.5rem;
        margin-bottom: 0.5rem;
    }
    
    .card-title {
        text-align: center;
        font-size: 1.3rem;
    }

    .header-actions {
        justify-content: center;
        gap: 0.4rem;
    }
    
    .action-btn {
        min-width: 2.4rem;
        height: 2.4rem;
        padding: 0.6rem;
        border-radius: 8px;
    }
    
    .search-container {
        margin-bottom: 0.5rem;
    }
    
    .search-row {
        flex-direction: column;
        gap: 0.5rem;
    }
    
    .search-input {
        padding: 0.7rem 2.5rem 0.7rem 2.5rem;
        font-size: 0.85rem;
        border-radius: 8px;
    }
    
    .search-icon {
        left: 0.8rem;
        width: 14px;
        height: 14px;
        top: 1.8rem;
        transform: translateY(-50%);
    }
    
    .clear-search-btn {
        right: 0.5rem;
        width: 1.8rem;
        height: 1.8rem;
        padding: 0.2rem;
        top: 1.8rem;
        transform: translateY(-50%);
    }
    
    .search-controls {
        justify-content: center;
        gap: 0.3rem;
    }
    
    .search-btn, .nav-btn {
        padding: 0.6rem 0.8rem;
        font-size: 0.75rem;
        min-height: 2.4rem;
        border-radius: 8px;
    }
    
    .nav-btn {
        min-width: 2.4rem;
        padding: 0.6rem;
    }
    
    .rich-editor {
        min-height: 52vh;
        padding: 0.8rem;
        font-size: 0.85rem;
        line-height: 1.6;
    }
    
    .calendar-popup {
        position: fixed;
        top: 50%;
        left: 50%;
        transform: translate(-50%, -50%);
        width: 85vw;
        max-width: 320px;
        max-height: 60vh;
        border-radius: 15px;
        padding: 0.8rem;
        z-index: 1001;
    }
    
    .tips-section {
        padding: 0.8rem;
        font-size: 0.8rem;
        border-radius: 12px;
        margin-top: 0.8rem;
    }
    
    .modal-content {
        width: 90%;
        max-width: none;
        margin: 0.6rem;
        padding: 1.2rem;
        border-radius: 15px;
    }
    
    .toast {
        right: 6px;
        left: 6px;
        max-width: none;
        top: 70px;
        font-size: 0.8rem;
    }
}

/* iPhone XR specific (414px) */
@media (min-width: 412px) and (max-width: 416px) {
    /* Hide fullscreen button on iPhone XR - not supported */
    #fullscreenBtn {
        display: none !important;
    }
    
    /* Optimized wrapping toolbar for iPhone XR - 414px width */
    .formatting-toolbar {
        flex-direction: column;
        flex-wrap: nowrap;
        padding: 0.6rem;
        margin-bottom: 0.6rem;
        gap: 0.4rem;
        border-radius: 12px;
        justify-content: center;
        align-items: center;
    }
    
    .format-buttons {
        display: flex;
        gap: 0.3rem;
        flex-wrap: wrap;
        justify-content: center;
        align-items: center;
        width: 100%;
    }
    
    .format-btn {
        min-width: 2.3rem;
        height: 2.3rem;
        padding: 0.45rem;
        font-size: 0.8rem;
        border-radius: 6px;
        flex-shrink: 0;
    }
    
    .undo-redo-buttons {
        display: flex;
        gap: 0.3rem;
        justify-content: center;
        margin-left: 0;
    }
    
    /* Optimized other elements for 414px width */
    .header {
        flex-direction: column;
        padding: 0.5rem 0.7rem;
        gap: 0.5rem;
    }
    
    .header-left {
        justify-content: center;
        order: 1;
    }
    
    .header-center {
        order: 3;
    }
    
    .header-controls {
        justify-content: center;
        flex-wrap: wrap;
        order: 2;
        gap: 0.5rem;
    }
    
    .save-status {
        font-size: 0.75rem;
        padding: 0.3rem 0.6rem;
        margin-bottom: 0.2rem;
    }
    
    .control-btn, .theme-main-btn {
        width: 2.5rem;
        height: 2.5rem;
        padding: 0.5rem;
    }
    
    .container {
        padding: 0.6rem;
    }
    
    .todo-card {
        padding: 0.8rem;
        border-radius: 12px;
    }
    
    .card-header {
        flex-direction: column;
        align-items: center;
        gap: 0.6rem;
        margin-bottom: 0.6rem;
    }
    
    .card-title {
        text-align: center;
        font-size: 1.4rem;
    }

    .header-actions {
        justify-content: center;
        gap: 0.5rem;
    }
    
    .action-btn {
        min-width: 2.5rem;
        height: 2.5rem;
        padding: 0.7rem;
        border-radius: 10px;
    }
    
    .search-container {
        margin-bottom: 0.6rem;
    }
    
    .search-row {
        flex-direction: column;
        gap: 0.6rem;
    }
    
    .search-input {
        padding: 0.8rem 7.5rem 0.8rem 2.8rem;
        font-size: 0.9rem;
        border-radius: 10px;
    }
    
    .search-icon {
        left: 0.9rem;
        width: 16px;
        height: 16px;
        top: 1.5rem;
        transform: translateY(-50%);
    }
    
    .clear-search-btn {
        right: 0.6rem;
        width: 2rem;
        height: 2rem;
        padding: 0.3rem;
        top: 1.5rem;
        transform: translateY(-50%);
    }
    
    .search-controls {
        justify-content: center;
        gap: 0.4rem;
    }
    
    .search-btn, .nav-btn {
        padding: 0.7rem 0.9rem;
        font-size: 0.8rem;
        min-height: 2.5rem;
        border-radius: 10px;
    }
    
    .nav-btn {
        min-width: 2.5rem;
        padding: 0.7rem;
    }
    
    .rich-editor {
        min-height: 50vh;
        padding: 0.9rem;
        font-size: 0.9rem;
        line-height: 1.7;
    }
    
    .calendar-popup {
        position: fixed;
        top: 50%;
        left: 50%;
        transform: translate(-50%, -50%);
        width: 87vw;
        max-width: 350px;
        max-height: 65vh;
        border-radius: 16px;
        padding: 0.9rem;
        z-index: 1001;
    }
    
    .tips-section {
        padding: 0.9rem;
        font-size: 0.85rem;
        border-radius: 12px;
        margin-top: 0.9rem;
    }
    
    .modal-content {
        width: 91%;
        max-width: none;
        margin: 0.7rem;
        padding: 1.3rem;
        border-radius: 16px;
    }
    
    .toast {
        right: 7px;
        left: 7px;
        max-width: none;
        top: 75px;
        font-size: 0.85rem;
    }
}

/* Modern iPhones (393px - 411px) - iPhone 14 Pro and similar */
@media (min-width: 393px) and (max-width: 411px) {
    .header {
        padding: 0.7rem 1rem;
        flex-direction: column;
        gap: 0.8rem;
    }
    
    .header-left {
        justify-content: center;
        order: 1;
    }
    
    .header-center {
        order: 3;
    }
    
    .header-controls {
        justify-content: center;
        flex-wrap: wrap;
        order: 2;
        gap: 0.6rem;
    }
    
    .save-status {
        font-size: 0.8rem;
        padding: 0.4rem 0.8rem;
        margin-bottom: 0.3rem;
    }
    
    .control-btn, .theme-main-btn {
        width: 2.8rem;
        height: 2.8rem;
        padding: 0.6rem;
    }
    
    .container {
        padding: 0.7rem;
    }
    
    .todo-card {
        padding: 0.9rem;
        border-radius: 15px;
    }
    
    .card-header {
        flex-direction: column;
        align-items: center;
        gap: 0.8rem;
        margin-bottom: 0.8rem;
    }
    
    .card-title {
        text-align: center;
        font-size: 1.5rem;
    }

    .header-actions {
        justify-content: center;
        gap: 0.6rem;
    }
    
    .action-btn {
        min-width: 2.8rem;
        height: 2.8rem;
        padding: 0.8rem;
        border-radius: 12px;
    }

    .search-container {
        margin-bottom: 0.8rem;
    }
    
    .search-row {
        flex-direction: column;
        gap: 0.8rem;
    }
    
    .search-input {
        padding: 0.9rem 3rem 0.9rem 3rem;
        font-size: 0.95rem;
        border-radius: 12px;
    }
    
    .search-icon {
        left: 1rem;
        width: 18px;
        height: 18px;
    }
    
    .clear-search-btn {
        right: 0.7rem;
        width: 2.2rem;
        height: 2.2rem;
        padding: 0.4rem;
    }
    
    .search-controls {
        justify-content: center;
        gap: 0.4rem;
    }
    
    .search-btn, .nav-btn {
        padding: 0.8rem 1rem;
        font-size: 0.85rem;
        min-height: 2.8rem;
        border-radius: 12px;
    }
    
    .nav-btn {
        min-width: 2.8rem;
        padding: 0.8rem;
    }

    /* Optimized formatting toolbar for iPhone 14 Pro Max */
    .formatting-toolbar {
        flex-direction: row;
        flex-wrap: wrap;
        justify-content: center;
        padding: 0.8rem;
        margin-bottom: 0.8rem;
        border-radius: 15px;
        gap: 0.4rem;
    }

    .format-buttons {
        justify-content: center;
        flex-wrap: wrap;
        gap: 0.4rem;
        flex: 1;
        min-width: 0;
    }
    
    .format-btn {
        min-width: 2.6rem;
        height: 2.6rem;
        padding: 0.6rem;
        font-size: 0.9rem;
        border-radius: 8px;
        flex-shrink: 0;
    }

    .undo-redo-buttons {
        justify-content: center;
        gap: 0.4rem;
        margin-left: 0;
        flex-shrink: 0;
    }
    
    .rich-editor {
        padding: 1rem;
        font-size: 0.95rem;
        line-height: 1.8;
        border-radius: 12px;
        min-height: 45vh;
    }
    
    .theme-selector {
        justify-content: center;
        gap: 0.6rem;
    }
    
    .calendar-popup {
        position: fixed;
        top: 50%;
        left: 50%;
        transform: translate(-50%, -50%);
        width: 88vw;
        max-width: 340px;
        max-height: 65vh;
        border-radius: 18px;
        padding: 1rem;
        z-index: 1001;
    }
    
    .tips-section {
        padding: 1rem;
        font-size: 0.9rem;
        border-radius: 15px;
        margin-top: 1rem;
    }
    
    .modal-content {
        width: 92%;
        max-width: none;
        margin: 0.8rem;
        padding: 1.3rem;
        border-radius: 18px;
    }
    
    .toast {
        right: 8px;
        left: 8px;
        max-width: none;
        top: 80px;
    }
}

/* Mobile phones (up to 392px) */
@media (max-width: 392px) {
    .header {
        padding: 0.8rem 1rem;
        flex-direction: column;
        gap: 1rem;
    }
    
    .header-left {
        justify-content: center;
        order: 1;
    }
    
    .header-center {
        order: 3;
    }
    
    .header-controls {
        justify-content: center;
        flex-wrap: wrap;
        order: 2;
        gap: 0.8rem;
    }
    
    .save-status {
        font-size: 0.8rem;
        padding: 0.4rem 0.8rem;
        margin-bottom: 0.5rem;
    }
    
    .control-btn, .theme-main-btn {
        width: 3.2rem;
        height: 3.2rem;
        padding: 0.8rem;
    }
    
    .container {
        padding: 0.8rem;
    }
    
    .todo-card {
        padding: 1rem;
        border-radius: 15px;
    }
    
    .card-header {
        flex-direction: column;
        align-items: center;
        gap: 1rem;
        margin-bottom: 1rem;
    }
    
    .card-title {
        text-align: center;
        font-size: 1.6rem;
    }

    .header-actions {
        justify-content: center;
        gap: 0.8rem;
    }
    
    .action-btn {
        min-width: 3.2rem;
        height: 3.2rem;
        padding: 1rem;
        border-radius: 12px;
    }

    .search-container {
        margin-bottom: 1.2rem;
    }
    
    .search-row {
        flex-direction: column;
        gap: 1rem;
    }
    
    .search-input {
        padding: 1rem 3.5rem 1rem 3.5rem;
        font-size: 1rem;
        border-radius: 12px;
    }
    
    .search-icon {
        left: 1.2rem;
        width: 20px;
        height: 20px;
    }
    
    .clear-search-btn {
        right: 0.8rem;
        width: 2.5rem;
        height: 2.5rem;
        padding: 0.5rem;
    }
    
    .search-controls {
        justify-content: center;
        gap: 0.5rem;
    }
    
    .search-btn, .nav-btn {
        padding: 1rem 1.2rem;
        font-size: 0.9rem;
        min-height: 3.2rem;
        border-radius: 12px;
    }
    
    .nav-btn {
        min-width: 3.2rem;
        padding: 1rem;
    }

    .formatting-toolbar {
        flex-direction: column;
        gap: 1rem;
        padding: 1rem;
        margin-bottom: 1.2rem;
        border-radius: 15px;
    }

    .format-buttons {
        justify-content: center;
        flex-wrap: wrap;
        gap: 0.8rem;
    }
    
    .format-btn {
        min-width: 3.2rem;
        height: 3.2rem;
        padding: 0.8rem;
        font-size: 1rem;
        border-radius: 10px;
    }

    .undo-redo-buttons {
        justify-content: center;
        gap: 0.8rem;
        margin-left: 0;
    }
    
    .rich-editor {
        padding: 1.2rem;
        font-size: 1rem;
        line-height: 1.9;
        border-radius: 12px;
        min-height: 50vh;
    }
    
    .theme-selector {
        justify-content: center;
        gap: 0.8rem;
    }
    
    .calendar-popup {
        position: fixed;
        top: 50%;
        left: 50%;
        transform: translate(-50%, -50%);
        width: 90vw;
        max-width: 350px;
        max-height: 70vh;
        border-radius: 20px;
        padding: 1.2rem;
        z-index: 1001;
    }
    
    .calendar-navigation {
        gap: 1rem;
        padding: 0.8rem 0;
        margin-bottom: 1.2rem;
    }
    
    .calendar-nav-btn {
        width: 3rem;
        height: 3rem;
        padding: 0.8rem;
    }
    
    .calendar-month {
        font-size: 1.1rem;
    }
    
    .date-item {
        padding: 1rem;
        border-radius: 10px;
        margin-bottom: 0.5rem;
        font-size: 1rem;
    }
    
    .tips-section {
        padding: 1.2rem;
        font-size: 0.95rem;
        border-radius: 15px;
        margin-top: 1.2rem;
    }
    
    .tip-examples {
        font-size: 0.9rem;
        padding-left: 1.2rem;
    }
    
    .modal-content {
        width: 95%;
        max-width: none;
        margin: 1rem;
        padding: 1.5rem;
        border-radius: 20px;
    }
    
    .setting-select {
        padding: 1rem 3rem 1rem 1.2rem;
        font-size: 1rem;
        border-radius: 12px;
    }
    
    .close-btn {
        font-size: 1.8rem;
        padding: 0.5rem;
    }
    
    .toast {
        right: 10px;
        left: 10px;
        max-width: none;
        top: 90px;
    }
}

/* Extra small phones (up to 360px) */
@media (max-width: 360px) {
    .header {
        padding: 0.6rem 0.8rem;
    }
    
    .container {
        padding: 0.6rem;
    }
    
    .todo-card {
        padding: 0.8rem;
    }
    
    .card-title {
        font-size: 1.4rem;
    }
    
    .control-btn, .theme-main-btn {
        width: 3rem;
        height: 3rem;
    }
    
    .action-btn {
        min-width: 3rem;
        height: 3rem;
        padding: 0.8rem;
    }
    
    .format-btn {
        min-width: 2.8rem;
        height: 2.8rem;
        font-size: 0.9rem;
    }
    
    .search-input {
        padding: 0.9rem 3rem 0.9rem 3rem;
    }
    
    .search-icon {
        left: 1rem;
        width: 18px;
        height: 18px;
    }
    
    .clear-search-btn {
        right: 0.6rem;
        width: 2.2rem;
        height: 2.2rem;
    }
    
    .search-btn, .nav-btn {
        padding: 0.9rem 1rem;
        font-size: 0.85rem;
    }
    
    .calendar-popup {
        width: 95vw;
        padding: 1rem;
    }
    
    .rich-editor {
        padding: 1rem;
        font-size: 0.95rem;
    }
}

/* Landscape mobile optimization - FIXED to exclude iPad Mini */
@media (max-width: 767px) and (orientation: landscape) {
    .header {
        flex-direction: row;
        padding: 0.6rem 1rem;
        gap: 1rem;
    }
    
    .header-left {
        order: 0;
        justify-content: flex-start;
        flex: 0 0 auto;
    }
    
    .header-center {
        order: 1;
        flex: 1;
    }
    
    .header-controls {
        order: 2;
        justify-content: flex-end;
        flex: 0 0 auto;
    }
    
    .save-status {
        margin-bottom: 0;
    }
    
    .card-header {
        flex-direction: row;
        justify-content: space-between;
        align-items: center;
    }
    
    .formatting-toolbar {
        flex-direction: row;
        flex-wrap: wrap;
        padding: 0.8rem;
        gap: 0.5rem;
    }
    
    .format-buttons {
        flex-wrap: wrap;
    }
    
    .rich-editor {
        min-height: 40vh;
    }
    
    .calendar-popup {
        max-height: 80vh;
    }
}

/* Touch device optimizations */
@media (pointer: coarse) {
    button, .action-btn, .format-btn, .control-btn, .theme-main-btn, .nav-btn, .search-btn {
        min-height: 44px;
        min-width: 44px;
    }
    
    a, .date-item, .theme-option {
        min-height: 44px;
        display: flex;
        align-items: center;
    }
    
    .rich-editor, .calendar-popup {
        -webkit-overflow-scrolling: touch;
        scroll-behavior: smooth;
    }
    
    .search-input, .setting-select {
        -webkit-appearance: none;
        border-radius: 12px;
    }
}

/* High resolution displays */
@media (-webkit-min-device-pixel-ratio: 2) {
    .logo-image, .footer-logo {
        image-rendering: -webkit-optimize-contrast;
        image-rendering: crisp-edges;
    }
}

/* Reduced motion preferences */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
    
    .shimmer, .searchPulse, .spin, .pulse {
        animation: none !important;
    }
}

/* Desired breakpoint for "Phone dimensions" to not Allow Fullscreen*/
@media (max-width: 432px) { 
  #fullscreenBtn {
    display: none;
  }
}