/* Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --nav-bg: #ffffff;
    --nav-text: #333333;
    --nav-text-hover: #000000;
    --editor-bg: #ffffff;
    --editor-text: #333333;
    --preview-bg: #ffffff;
    --border-color: #e0e0e0;
    --line-numbers-bg: #f8f8f8;
    --line-numbers-text: #999999;
    --button-bg: #f5f5f5;
    --button-hover: #e8e8e8;
    --primary-color: #007bff;
    --primary-hover: #0056b3;
}

/* Momo Trust Display Font */
.momo-trust-display-regular {
    font-family: "Momo Trust Display", sans-serif;
    font-weight: 400;
    font-style: normal;
}

/* Open Sans Font */
.open-sans {
    font-family: "Open Sans", sans-serif;
    font-optical-sizing: auto;
    font-weight: 400;
    font-style: normal;
    font-variation-settings: "wdth" 100;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    margin: 0;
    padding: 0;
    padding-top: 64px; /* Account for fixed navigation bar */
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    background-color: #ffffff;
}

/* Allow scrolling on editor pages with footer - using class-based approach for better compatibility */
body.has-footer {
    overflow-y: auto !important;
    overflow-x: hidden;
    height: auto !important;
    min-height: 100vh !important;
}

/* Adjust editor container when footer is present - allow page scroll to show footer */
body.has-footer .editor-container {
    flex: 0 1 auto !important;
    min-height: calc(100vh - 64px - 80px - 64px) !important; /* nav + header + footer space */
    max-height: none !important;
    margin-bottom: 0 !important;
    position: relative !important;
    z-index: 0 !important;
    overflow: visible !important;
    height: auto !important;
}

/* Screen reader only - for SEO accessibility */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border-width: 0;
}

/* Navigation Bar */
.app-nav {
    background-color: var(--nav-bg);
    color: var(--nav-text);
    height: 64px;
    display: flex;
    align-items: center;
    border-bottom: 1px solid var(--border-color);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 1000;
    font-family: "Momo Trust Display", sans-serif;
    font-weight: 400;
    font-style: normal;
}

.nav-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    padding: 0 40px 0 20px;
    height: 100%;
}

.nav-left {
    display: flex;
    align-items: center;
    gap: 20px;
    padding-left: 0;
    margin-left: 0;
}

.logo-wrapper {
    display: flex;
    align-items: center;
    margin-right: 40px;
    padding-left: 0;
    margin-left: 0;
    min-height: 60px; /* Reserve space to prevent layout shift */
    min-width: 200px; /* Reserve minimum width for logo area */
}

.logo-wrapper .logo {
    height: 60px;
    width: auto;
    max-width: 280px;
    min-width: 200px; /* Reserve minimum width to prevent layout shift */
    display: block;
    image-rendering: -webkit-optimize-contrast;
    image-rendering: crisp-edges;
    /* Prevent layout shift when logo loads */
    object-fit: contain;
    aspect-ratio: attr(width) / attr(height); /* Maintain aspect ratio */
    content-visibility: auto; /* Performance optimization */
}

.logo-link {
    text-decoration: none;
    display: flex;
    align-items: center;
}

.logo-fallback-text {
    font-size: 24px;
    font-weight: 400;
    color: #2d2d2d;
    letter-spacing: -0.5px;
    font-family: "Momo Trust Display", sans-serif;
    /* Reserve space to prevent layout shift when logo loads */
    min-width: 200px;
    height: 60px;
    display: flex;
    align-items: center;
    visibility: visible;
    opacity: 1;
    transition: opacity 0.2s ease;
}

.logo-wrapper .logo ~ .logo-fallback-text {
    visibility: hidden;
    opacity: 0;
    position: absolute;
    width: 0;
    height: 0;
    overflow: hidden;
}

/* Fallback for browsers that support :has() */
@supports selector(:has(*)) {
    .logo-wrapper:has(.logo) .logo-fallback-text {
        visibility: hidden;
        opacity: 0;
        position: absolute;
        width: 0;
        height: 0;
        overflow: hidden;
    }
}

.logo-link:hover .logo-fallback-text {
    color: #000000;
}

.nav-links {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-left: 20px;
}

.nav-link {
    color: var(--nav-text);
    text-decoration: none;
    font-size: 15px;
    padding: 8px 14px;
    border-radius: 4px;
    transition: all 0.2s;
    white-space: nowrap;
    font-weight: 400;
}

.nav-link:hover {
    color: var(--nav-text-hover);
    background-color: #f8f8f8;
}

.nav-link.active {
    color: var(--primary-color);
    font-weight: 500;
}

/* Dropdown Menu Styles */
.nav-dropdown {
    position: relative;
    display: inline-block;
}

.nav-dropdown-toggle {
    color: var(--nav-text);
    text-decoration: none;
    font-size: 15px;
    padding: 8px 14px;
    border-radius: 4px;
    transition: all 0.2s;
    white-space: nowrap;
    font-weight: 400;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 4px;
    background: none;
    border: none;
    font-family: inherit;
}

.nav-dropdown-toggle:hover {
    color: var(--nav-text-hover);
    background-color: #f8f8f8;
}

.nav-dropdown-toggle::after {
    content: '▼';
    font-size: 10px;
    transition: transform 0.2s;
    margin-left: 4px;
}

.nav-dropdown.active .nav-dropdown-toggle::after {
    transform: rotate(180deg);
}

.nav-dropdown-menu {
    position: absolute;
    top: 100%;
    left: 0;
    background-color: #ffffff;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    min-width: 200px;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    transition: all 0.2s ease;
    z-index: 1001;
    margin-top: 4px;
    padding: 8px 0;
}

.nav-dropdown.active .nav-dropdown-menu {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.nav-dropdown-item {
    display: block;
    padding: 10px 16px;
    color: var(--nav-text);
    text-decoration: none;
    font-size: 14px;
    transition: all 0.2s;
    white-space: nowrap;
}

.nav-dropdown-item:hover {
    background-color: #f8f8f8;
    color: var(--nav-text-hover);
}

.nav-dropdown-item.active {
    color: var(--primary-color);
    font-weight: 500;
    background-color: #f0f7ff;
}

.nav-right {
    display: flex;
    align-items: center;
    gap: 15px;
}

/* Pushable Button Style */
.pushable {
    position: relative;
    background: transparent;
    padding: 0;
    border: none;
    cursor: pointer;
    outline-offset: 4px;
    outline-color: var(--primary-color);
    transition: filter 250ms;
    -webkit-tap-highlight-color: rgba(0, 0, 0, 0);
}

.pushable .shadow {
    position: absolute;
    top: 0;
    left: 0;
    height: 100%;
    width: 100%;
    background: hsl(214, 35%, 75%);
    border-radius: 8px;
    filter: blur(2px);
    will-change: transform;
    transform: translateY(2px);
    transition: transform 600ms cubic-bezier(0.3, 0.7, 0.4, 1);
}

.pushable .edge {
    position: absolute;
    top: 0;
    left: 0;
    height: 100%;
    width: 100%;
    border-radius: 8px;
    background: linear-gradient(
        to right,
        hsl(214, 64%, 35%) 0%,
        hsl(214, 64%, 45%) 8%,
        hsl(214, 64%, 35%) 92%,
        hsl(214, 64%, 25%) 100%
    );
}

.pushable .front {
    display: block;
    position: relative;
    border-radius: 8px;
    background: hsl(214, 100%, 50%);
    padding: 10px 20px;
    color: white;
    font-weight: 400;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-size: 13px;
    font-family: "Momo Trust Display", sans-serif;
    transform: translateY(-4px);
    transition: transform 600ms cubic-bezier(0.3, 0.7, 0.4, 1);
}

.pushable:hover {
    filter: brightness(110%);
}

.pushable:hover .front {
    transform: translateY(-6px);
    transition: transform 250ms cubic-bezier(0.3, 0.7, 0.4, 1.5);
}

.pushable:active .front {
    transform: translateY(-2px);
    transition: transform 34ms;
}

.pushable:hover .shadow {
    transform: translateY(4px);
    transition: transform 250ms cubic-bezier(0.3, 0.7, 0.4, 1.5);
}

.pushable:active .shadow {
    transform: translateY(1px);
    transition: transform 34ms;
}

.pushable:focus:not(:focus-visible) {
    outline: none;
}

/* Secondary Pushable Button (for Clear, etc.) */
.pushable-secondary .shadow {
    background: hsl(0, 0%, 75%);
}

.pushable-secondary .edge {
    background: linear-gradient(
        to right,
        hsl(0, 0%, 40%) 0%,
        hsl(0, 0%, 50%) 8%,
        hsl(0, 0%, 40%) 92%,
        hsl(0, 0%, 30%) 100%
    );
}

.pushable-secondary .front {
    background: hsl(0, 0%, 60%);
    font-family: "Momo Trust Display", sans-serif;
}

/* Legacy nav-btn class - now uses pushable style */
.nav-btn {
    position: relative;
    background: transparent;
    padding: 0;
    border: none;
    cursor: pointer;
    outline-offset: 4px;
}

.nav-btn .shadow {
    position: absolute;
    top: 0;
    left: 0;
    height: 100%;
    width: 100%;
    background: hsl(214, 35%, 75%);
    border-radius: 8px;
    filter: blur(2px);
    transform: translateY(2px);
    transition: transform 600ms cubic-bezier(0.3, 0.7, 0.4, 1);
}

.nav-btn .edge {
    position: absolute;
    top: 0;
    left: 0;
    height: 100%;
    width: 100%;
    border-radius: 8px;
    background: linear-gradient(
        to right,
        hsl(214, 64%, 35%) 0%,
        hsl(214, 64%, 45%) 8%,
        hsl(214, 64%, 35%) 92%,
        hsl(214, 64%, 25%) 100%
    );
}

.nav-btn .front {
    display: block;
    position: relative;
    border-radius: 8px;
    background: hsl(214, 100%, 50%);
    padding: 10px 20px;
    color: white;
    font-weight: 400;
    font-size: 13px;
    font-family: "Momo Trust Display", sans-serif;
    transform: translateY(-4px);
    transition: transform 600ms cubic-bezier(0.3, 0.7, 0.4, 1);
}

.nav-btn:hover .front {
    transform: translateY(-6px);
    transition: transform 250ms cubic-bezier(0.3, 0.7, 0.4, 1.5);
}

.nav-btn:active .front {
    transform: translateY(-2px);
    transition: transform 34ms;
}

.nav-btn:hover .shadow {
    transform: translateY(4px);
    transition: transform 250ms cubic-bezier(0.3, 0.7, 0.4, 1.5);
}

.nav-btn:active .shadow {
    transform: translateY(1px);
    transition: transform 34ms;
}

.sync-scroll-label {
    display: flex;
    align-items: center;
    gap: 6px;
    color: var(--nav-text);
    font-size: 14px;
    cursor: pointer;
    user-select: none;
    padding: 6px 12px;
    border-radius: 4px;
    transition: background-color 0.2s;
}

.sync-scroll-label:hover {
    background-color: #f8f8f8;
}

.sync-scroll-label input[type="checkbox"] {
    cursor: pointer;
}

/* Editor Container */
.editor-header {
    margin-top: 0; /* Body already has padding-top for nav */
    padding: 20px 20px 0px 20px;
    text-align: center;
    background-color: #ffffff;
    border-bottom: 1px solid var(--border-color);
    position: relative;
    z-index: 10;
    flex-shrink: 0; /* Prevent header from shrinking */
}

.editor-header h1 {
    margin: 0 0 10px 0;
    padding-top: 0;
    font-size: 32px;
    font-weight: 600;
    color: #2d2d2d;
    font-family: "Momo Trust Display", sans-serif;
    line-height: 1.2;
    overflow: visible;
}

.editor-subtitle {
    margin: 0;
    padding: 0;
    font-size: 16px;
    color: #666;
    font-family: "Open Sans", sans-serif;
    line-height: 1.4;
    overflow: visible;
}

.editor-container {
    display: flex;
    flex: 1; /* Fill remaining vertical space */
    min-height: 0; /* Allow flexbox to shrink */
    overflow: hidden;
    background-color: #ffffff;
}


.editor-pane-wrapper {
    flex: 1;
    display: flex;
    border-right: 1px solid var(--border-color);
    position: relative;
    background: var(--editor-bg);
    min-height: 0;
    overflow: hidden;
}

/* Ensure editor and preview panes can scroll when footer is present */
body.has-footer .editor-pane-wrapper,
body.has-footer .preview-pane-wrapper {
    min-height: 0 !important;
    overflow: hidden !important;
    height: calc(100vh - 64px - 80px - 64px) !important;
    max-height: calc(100vh - 64px - 80px - 64px) !important;
}

body.has-footer .markdown-editor,
body.has-footer .preview-pane-wrapper {
    overflow-y: auto !important;
    overflow-x: hidden !important;
    height: 100% !important;
    max-height: calc(100vh - 64px - 80px - 64px) !important;
}

/* Mobile-specific footer container adjustments */
@media (max-width: 768px) {
    body.has-footer .editor-container {
        min-height: calc(100vh - 100px - 80px - 64px) !important; /* taller mobile nav */
    }
    
    body.has-footer .editor-pane-wrapper,
    body.has-footer .preview-pane-wrapper {
        height: calc(100vh - 100px - 80px - 64px) !important;
        max-height: calc(100vh - 100px - 80px - 64px) !important;
    }
    
    body.has-footer .markdown-editor,
    body.has-footer .preview-pane-wrapper {
        max-height: calc(100vh - 100px - 80px - 64px) !important;
    }
}

.line-numbers {
    background-color: var(--line-numbers-bg);
    color: var(--line-numbers-text);
    padding: 15px 10px 15px 10px; /* Match editor's vertical padding exactly */
    font-family: 'Courier New', monospace;
    font-size: 14px;
    line-height: 1.5; /* Must match markdown-editor line-height exactly */
    text-align: right;
    user-select: none;
    border-right: 1px solid var(--border-color);
    min-width: 50px;
    white-space: pre-wrap; /* Match editor's white-space to preserve blank lines */
    word-wrap: break-word; /* Match editor */
    overflow-y: auto;
    overflow-x: hidden;
    scrollbar-width: none; /* Firefox */
    -ms-overflow-style: none; /* IE and Edge */
    flex-shrink: 0; /* Don't shrink line numbers */
}

.line-numbers::-webkit-scrollbar {
    display: none; /* Chrome, Safari, Opera */
}

.syntax-highlight {
    position: absolute;
    top: 0;
    left: 50px; /* Match line-numbers width */
    right: 0;
    bottom: 0;
    padding: 15px;
    font-family: "Open Sans", sans-serif;
    font-optical-sizing: auto;
    font-weight: 400;
    font-style: normal;
    font-variation-settings: "wdth" 100;
    font-size: 14px;
    line-height: 1.5;
    white-space: pre-wrap;
    word-wrap: break-word;
    overflow: hidden;
    pointer-events: none;
    z-index: 1;
    color: transparent;
}

.markdown-editor {
    flex: 1;
    border: none;
    outline: none;
    padding: 15px;
    font-family: "Open Sans", sans-serif;
    font-optical-sizing: auto;
    font-weight: 400;
    font-style: normal;
    font-variation-settings: "wdth" 100;
    font-size: 14px;
    line-height: 1.5;
    color: var(--editor-text);
    background: transparent;
    overflow-y: auto;
    overflow-x: auto;
    tab-size: 2;
    position: relative;
    z-index: 2;
    white-space: pre-wrap;
    word-wrap: break-word;
    min-height: 0;
    text-indent: 0;
}

.markdown-editor * {
    text-indent: 0;
    margin: 0;
    padding: 0;
}

.markdown-editor::placeholder {
    color: #999;
}

.preview-pane-wrapper {
    flex: 1;
    overflow-y: auto;
    background: #ffffff;
    padding: 30px;
}

/* Hide scrollbar when sync scroll is enabled */
.preview-pane-wrapper.hide-scrollbar,
.markdown-editor.hide-scrollbar {
    scrollbar-width: none; /* Firefox */
    -ms-overflow-style: none; /* IE and Edge */
}

.preview-pane-wrapper.hide-scrollbar::-webkit-scrollbar,
.markdown-editor.hide-scrollbar::-webkit-scrollbar {
    display: none; /* Chrome, Safari, Opera */
    width: 0;
    height: 0;
}

.markdown-preview {
    max-width: 800px;
    margin: 0 auto;
    color: var(--editor-text);
    line-height: 1.6;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji";
    font-size: 16px;
}

.markdown-preview h1 {
    font-size: 2em;
    margin-top: 0;
    margin-bottom: 16px;
    font-weight: 600;
    border-bottom: 1px solid #eaecef;
    padding-bottom: 0.3em;
}

.markdown-preview h2 {
    font-size: 1.5em;
    margin-top: 24px;
    margin-bottom: 16px;
    font-weight: 600;
    border-bottom: 1px solid #eaecef;
    padding-bottom: 0.3em;
}

.markdown-preview h3 {
    font-size: 1.25em;
    margin-top: 24px;
    margin-bottom: 16px;
    font-weight: 600;
    padding-bottom: 0;
}

.markdown-preview h4 {
    font-size: 1em;
    margin-top: 24px;
    margin-bottom: 16px;
    font-weight: 600;
}

.markdown-preview h5 {
    font-size: 0.875em;
    margin-top: 24px;
    margin-bottom: 16px;
    font-weight: 600;
}

.markdown-preview h6 {
    font-size: 0.85em;
    margin-top: 24px;
    margin-bottom: 16px;
    font-weight: 600;
    color: #6a737d;
}

/* Remove top margin when headers immediately follow other headers (no gap in source) */
.markdown-preview h1 + h1,
.markdown-preview h1 + h2,
.markdown-preview h1 + h3,
.markdown-preview h1 + h4,
.markdown-preview h1 + h5,
.markdown-preview h1 + h6,
.markdown-preview h2 + h1,
.markdown-preview h2 + h2,
.markdown-preview h2 + h3,
.markdown-preview h2 + h4,
.markdown-preview h2 + h5,
.markdown-preview h2 + h6,
.markdown-preview h3 + h1,
.markdown-preview h3 + h2,
.markdown-preview h3 + h3,
.markdown-preview h3 + h4,
.markdown-preview h3 + h5,
.markdown-preview h3 + h6,
.markdown-preview h4 + h1,
.markdown-preview h4 + h2,
.markdown-preview h4 + h3,
.markdown-preview h4 + h4,
.markdown-preview h4 + h5,
.markdown-preview h4 + h6,
.markdown-preview h5 + h1,
.markdown-preview h5 + h2,
.markdown-preview h5 + h3,
.markdown-preview h5 + h4,
.markdown-preview h5 + h5,
.markdown-preview h5 + h6,
.markdown-preview h6 + h1,
.markdown-preview h6 + h2,
.markdown-preview h6 + h3,
.markdown-preview h6 + h4,
.markdown-preview h6 + h5,
.markdown-preview h6 + h6 {
    margin-top: 0;
}

/* Also handle when headers follow paragraphs - adjust spacing */
.markdown-preview p + h1,
.markdown-preview p + h2,
.markdown-preview p + h3,
.markdown-preview p + h4,
.markdown-preview p + h5,
.markdown-preview p + h6 {
    margin-top: 24px;
}

.markdown-preview p {
    margin-bottom: 10px;
    margin-top: 0;
}

.markdown-preview p:last-child {
    margin-bottom: 0;
}

.markdown-preview ul, .markdown-preview ol {
    margin-bottom: 16px;
    margin-top: 0;
    padding-left: 2em;
}

.markdown-preview ul:last-child, .markdown-preview ol:last-child {
    margin-bottom: 0;
}

.markdown-preview ul {
    list-style-type: disc;
}

.markdown-preview ol {
    list-style-type: decimal;
}

.markdown-preview ol ol {
    list-style-type: lower-roman;
}

.markdown-preview ol ol ol {
    list-style-type: lower-alpha;
}

.markdown-preview ul ul {
    list-style-type: circle;
}

.markdown-preview ul ul ul {
    list-style-type: square;
}

.markdown-preview li {
    margin-bottom: 0.25em;
}

.markdown-preview li > p {
    margin-top: 16px;
}

.markdown-preview li + li {
    margin-top: 0.25em;
}

.markdown-preview code {
    padding: 0.2em 0.4em;
    margin: 0;
    font-size: 85%;
    background-color: rgba(27, 31, 35, 0.05);
    border-radius: 3px;
    font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, Courier, monospace;
    color: #e83e8c;
}

.markdown-preview code:not(pre code) {
    background-color: rgba(27, 31, 35, 0.05);
}

.markdown-preview pre {
    padding: 16px;
    overflow: auto;
    font-size: 85%;
    line-height: 1.45;
    background-color: #f6f8fa;
    border-radius: 6px;
    margin-bottom: 16px;
    margin-top: 0;
    color: #24292e;
    border: 1px solid #e1e4e8;
}

.markdown-preview pre code {
    display: block;
    max-width: auto;
    padding: 0;
    margin: 0;
    overflow: visible;
    line-height: inherit;
    word-wrap: normal;
    background-color: transparent;
    border: 0;
    font-size: 100%;
    color: inherit;
    font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, Courier, monospace;
    white-space: pre;
}

.markdown-preview blockquote {
    padding: 0 1em;
    color: #6a737d;
    border-left: 0.25em solid #dfe2e5;
    margin: 0 0 16px 0;
}

.markdown-preview blockquote > :first-child {
    margin-top: 0;
}

.markdown-preview blockquote > :last-child {
    margin-bottom: 0;
}

/* Nested blockquotes - additional indentation */
.markdown-preview blockquote blockquote {
    padding-left: 1.5em;
    margin-top: 8px;
    margin-bottom: 8px;
}

.markdown-preview blockquote blockquote blockquote {
    padding-left: 2em;
}

.markdown-preview table {
    border-collapse: collapse;
    border-spacing: 0;
    width: 100%;
    margin-bottom: 16px;
    margin-top: 0;
    display: table;
    border: 1px solid #dfe2e5;
    table-layout: auto;
}

.markdown-preview table th,
.markdown-preview table td {
    padding: 6px 13px;
    border: 1px solid #dfe2e5;
}

.markdown-preview table th {
    font-weight: 600;
    background-color: #f6f8fa;
}

.markdown-preview table tr {
    background-color: #fff;
    border-top: 1px solid #c6cbd1;
}

.markdown-preview table tr:nth-child(2n) {
    background-color: #f6f8fa;
}

.markdown-preview table thead tr {
    background-color: #f6f8fa;
}

.markdown-preview table th[align="center"],
.markdown-preview table td[align="center"],
.markdown-preview table th[style*="text-align:center"],
.markdown-preview table td[style*="text-align:center"] {
    text-align: center;
}

.markdown-preview table th[align="right"],
.markdown-preview table td[align="right"],
.markdown-preview table th[style*="text-align:right"],
.markdown-preview table td[style*="text-align:right"] {
    text-align: right;
}

.markdown-preview table th[align="left"],
.markdown-preview table td[align="left"],
.markdown-preview table th[style*="text-align:left"],
.markdown-preview table td[style*="text-align:left"] {
    text-align: left;
}

.markdown-preview a {
    color: #0366d6;
    text-decoration: none;
}

.markdown-preview a:hover {
    text-decoration: underline;
}

.markdown-preview img {
    max-width: 100%;
    box-sizing: content-box;
    background-color: #fff;
    border-style: none;
    margin: 10px 0;
    display: block;
    height: auto;
    /* Prevent layout shift - ensure images load with proper sizing */
    object-fit: contain;
}

/* Mobile Performance Optimizations */
@media (max-width: 768px) {
    /* Reduce repaints and reflows */
    * {
        -webkit-font-smoothing: antialiased;
        -moz-osx-font-smoothing: grayscale;
    }
    
    /* Optimize rendering performance */
    body {
        text-rendering: optimizeSpeed;
    }
    
    /* Navigation Mobile Fixes */
    .app-nav {
        height: auto !important;
        min-height: 64px;
        padding: 0;
    }
    
    .nav-content {
        flex-direction: column !important;
        padding: 10px 15px !important;
        gap: 10px;
    }
    
    .nav-left {
        width: 100%;
        justify-content: space-between;
        flex-wrap: wrap;
        gap: 10px;
    }
    
    .logo-wrapper {
        margin-right: 0 !important;
    }
    
    .nav-links {
        display: flex !important;
        flex-wrap: wrap !important;
        gap: 4px !important;
        margin-left: 0 !important;
        width: 100%;
        justify-content: flex-start;
        order: 3;
        margin-top: 10px;
        padding-top: 10px;
        border-top: 1px solid var(--border-color);
    }
    
    .nav-link {
        font-size: 13px !important;
        padding: 6px 10px !important;
        white-space: nowrap;
        min-height: 36px; /* Touch target size */
        display: flex;
        align-items: center;
    }
    
    /* Mobile Dropdown Styles */
    .nav-dropdown {
        width: 100%;
    }
    
    .nav-dropdown-toggle {
        font-size: 13px !important;
        padding: 6px 10px !important;
        width: 100%;
        justify-content: space-between;
        min-height: 36px;
    }
    
    .nav-dropdown-menu {
        position: static !important;
        opacity: 1 !important;
        visibility: visible !important;
        transform: none !important;
        box-shadow: none !important;
        border: none !important;
        border-top: 1px solid var(--border-color) !important;
        border-radius: 0 !important;
        margin-top: 0 !important;
        padding: 0 !important;
        background-color: #f8f8f8 !important;
        display: none;
    }
    
    .nav-dropdown.active .nav-dropdown-menu {
        display: block;
    }
    
    .nav-dropdown-item {
        padding: 10px 20px !important;
        font-size: 13px !important;
        border-bottom: 1px solid var(--border-color);
    }
    
    .nav-dropdown-item:last-child {
        border-bottom: none;
    }
    
    .nav-right {
        gap: 8px !important;
        order: 2;
        flex-shrink: 0;
    }
    
    .pushable {
        min-width: 60px; /* Minimum touch target */
        min-height: 36px;
    }
    
    .pushable .front {
        padding: 8px 12px !important;
        font-size: 12px !important;
    }
    
    .sync-scroll-label {
        font-size: 11px !important;
        white-space: nowrap;
        min-height: 36px;
        display: flex;
        align-items: center;
    }
    
    .sync-scroll-label input[type="checkbox"] {
        width: 18px !important;
        height: 18px !important;
        margin-right: 6px;
    }
    
    /* Update body padding for mobile nav */
    body {
        padding-top: 100px !important; /* More space for taller mobile nav */
    }
    
    body.has-footer {
        padding-top: 100px !important;
    }
    
    .editor-header {
        padding: 20px 15px 10px 15px !important;
    }
    
    .editor-header h1 {
        font-size: 24px;
        margin-bottom: 8px !important;
    }
    
    .editor-subtitle {
        font-size: 14px;
    }
    
    .editor-container {
        flex-direction: column !important;
        flex: 1 !important; /* Still fill remaining space on mobile */
        min-height: 0;
        height: calc(100vh - 100px - 80px - 64px) !important; /* nav + header + footer */
    }
    
    .editor-pane-wrapper {
        height: 50% !important;
        min-height: 200px !important;
        border-right: none !important;
        border-bottom: 1px solid var(--border-color) !important;
    }
    
    .preview-pane-wrapper {
        height: 50% !important;
        min-height: 200px !important;
        overflow-y: auto !important;
    }
    
    .nav-btn {
        padding: 8px 12px !important;
        font-size: 12px !important;
        min-height: 36px; /* Touch target */
    }
    
    /* Reduce layout shifts on mobile */
    .markdown-editor,
    .markdown-preview {
        contain: layout style paint; /* CSS containment for performance */
        content-visibility: auto; /* Modern performance optimization */
    }
    
    /* Ensure text inputs are mobile-friendly */
    textarea, input[type="text"] {
        font-size: 16px !important; /* Prevents zoom on iOS */
        -webkit-appearance: none;
        appearance: none;
        border-radius: 0;
    }
    
    /* Improve touch targets */
    button, .pushable, .nav-link, a {
        min-height: 36px;
        -webkit-tap-highlight-color: rgba(0, 0, 0, 0.1);
    }
}

/* Footer Styles - Dark Footer matching Nav Height */
.site-footer {
    background: #1a1a1a !important;
    border-top: 1px solid #333333 !important;
    padding: 0 20px !important;
    margin-top: 0 !important;
    width: 100% !important;
    flex-shrink: 0 !important;
    position: relative !important;
    z-index: 10 !important;
    display: flex !important;
    align-items: center !important;
    box-sizing: border-box !important;
    clear: both !important;
    min-height: 64px !important;
    max-height: 64px !important;
    height: 64px !important;
}

.footer-container {
    max-width: 1400px !important;
    margin: 0 auto !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    height: 100% !important;
    width: 100% !important;
    box-sizing: border-box !important;
    flex-wrap: wrap !important;
    gap: 24px !important;
}

.footer-section {
    box-sizing: border-box;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    gap: 12px !important;
    width: 100% !important;
}

.footer-section h3 {
    display: none !important;
}

.footer-section ul {
    list-style: none !important;
    padding: 0 !important;
    margin: 0 !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    gap: 8px !important;
    flex-wrap: wrap !important;
    width: 100% !important;
}

.footer-section li {
    margin: 0 !important;
    display: inline-block !important;
    list-style: none !important;
}

.footer-section a {
    color: #e0e0e0 !important;
    text-decoration: none !important;
    font-size: 14px !important;
    font-weight: 400 !important;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif !important;
    transition: all 0.2s ease !important;
    display: inline-block !important;
    padding: 8px 14px !important;
    border-radius: 6px !important;
    white-space: nowrap !important;
    letter-spacing: 0.2px !important;
    line-height: 1.4 !important;
}

.footer-section a:hover {
    color: #ffffff !important;
    background-color: rgba(255, 255, 255, 0.12) !important;
    transform: translateY(-1px) !important;
}

.footer-home-button {
    display: inline-block !important;
    color: #ffffff !important;
    font-weight: 600 !important;
    font-size: 14px !important;
    text-decoration: none !important;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif !important;
    letter-spacing: 0.3px !important;
}

.footer-bottom {
    display: none !important;
}

@media (max-width: 768px) {
    .site-footer {
        min-height: auto !important;
        max-height: none !important;
        height: auto !important;
        padding: 15px 20px !important;
    }
    
    .footer-container {
        flex-direction: column !important;
        align-items: flex-start !important;
        gap: 15px !important;
    }
    
    .footer-section {
        flex-direction: column !important;
        align-items: flex-start !important;
        gap: 10px !important;
    }
    
    .footer-section ul {
        flex-direction: column !important;
        align-items: flex-start !important;
        gap: 10px !important;
    }
    
    .footer-section a {
        font-size: 13px !important;
        padding: 4px 8px !important;
    }
}

@media (max-width: 480px) {
    .site-footer {
        padding: 12px 15px !important;
    }
    
    .footer-section a {
        font-size: 12px !important;
    }
    
    /* Additional mobile optimizations for very small screens */
    body {
        text-rendering: optimizeSpeed; /* Prioritize speed over quality on very small screens */
    }
    
    .editor-header h1 {
        font-size: 22px !important;
    }
    
    .editor-subtitle {
        font-size: 13px !important;
    }
    
    /* Further optimize small screen performance */
    * {
        will-change: auto; /* Reset will-change for better memory management */
    }
}

/* Cookie Notice Popup */
.cookie-notice {
    position: fixed;
    bottom: 20px;
    left: 20px;
    right: 20px;
    max-width: 500px;
    background: #ffffff;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    padding: 20px;
    z-index: 10000;
    /* Prevent layout shift - use transform instead of display */
    visibility: hidden;
    opacity: 0;
    transform: translateY(100px) scale(0.95);
    transition: visibility 0s linear 0.3s, opacity 0.3s ease-out, transform 0.3s ease-out;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    /* Use transform-based animation to not affect layout */
    pointer-events: none;
}

.cookie-notice.show {
    visibility: visible;
    opacity: 1;
    transform: translateY(0) scale(1);
    transition: visibility 0s linear 0s, opacity 0.3s ease-out, transform 0.3s ease-out;
    pointer-events: auto;
}

.cookie-notice-content {
    margin-bottom: 15px;
}

.cookie-notice-content h3 {
    font-size: 18px;
    font-weight: 600;
    color: #2d2d2d;
    margin: 0 0 10px 0;
    font-family: "Momo Trust Display", sans-serif;
}

.cookie-notice-content p {
    font-size: 14px;
    color: #666;
    line-height: 1.5;
    margin: 0;
}

.cookie-notice-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.cookie-notice-btn {
    padding: 10px 20px;
    border: none;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
}

.cookie-notice-btn-accept {
    background: hsl(214, 100%, 50%);
    color: #ffffff;
}

.cookie-notice-btn-accept:hover {
    background: hsl(214, 100%, 45%);
    transform: translateY(-1px);
}

.cookie-notice-btn-decline {
    background: #f5f5f5;
    color: #333;
    border: 1px solid var(--border-color);
}

.cookie-notice-btn-decline:hover {
    background: #e8e8e8;
    transform: translateY(-1px);
}

.cookie-notice-link {
    color: hsl(214, 100%, 50%);
    text-decoration: none;
}

.cookie-notice-link:hover {
    text-decoration: underline;
}

/* Removed slideUp animation - using transform-based transitions instead to prevent layout shift */

@media (max-width: 768px) {
    .cookie-notice {
        bottom: 10px;
        left: 10px;
        right: 10px;
        padding: 15px;
        max-width: none;
    }
    
    .cookie-notice-content h3 {
        font-size: 16px;
    }
    
    .cookie-notice-content p {
        font-size: 13px;
    }
    
    .cookie-notice-actions {
        flex-direction: column;
    }
    
    .cookie-notice-btn {
        width: 100%;
        padding: 12px 20px;
    }
}
