/* Pizza Dough Calculator - Modern Italian Style */
:root {
    --italy-green: #009246;
    --italy-white: #FFFFFF;
    --italy-red: #CE2B37;
    --bg-cream: #FFF8F0;
    --text-dark: #2D2D2D;
    --shadow: 0 4px 20px rgba(0,0,0,0.1);
    --radius: 16px;
}

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

html, body {
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
    -webkit-tap-highlight-color: transparent;
    scroll-behavior: smooth;
}

body {
    position: relative;
    width: 100%;
    max-width: 100vw;
}

body {
    font-family: 'Segoe UI', system-ui, sans-serif;
    background: var(--bg-cream);
    color: var(--text-dark);
    max-width: 680px;
    margin: 0 auto;
    padding: 24px 16px;
    min-height: 100vh;
}

h1 {
    color: var(--italy-green);
    font-size: 2rem;
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    gap: 12px;
}

h1::before {
    content: "\1F355 ";
    font-size: 2.5rem;
}

.subtitle {
    color: #666;
    margin-bottom: 24px;
    font-size: 1rem;
}

/* Unit Switch */
.unit-switch {
    display: flex;
    gap: 8px;
    margin-bottom: 24px;
}

.unit-switch button {
    flex: 1;
    padding: 16px;
    border: 2px solid var(--italy-green);
    background: white;
    border-radius: var(--radius);
    cursor: pointer;
    font-weight: 600;
    transition: all 0.2s;
    min-height: 52px;
}

.unit-switch button:hover {
    background: #f0fdf4;
}

.unit-switch button:active {
    background: var(--italy-green);
    color: white;
}

.unit-switch button.active {
    background: var(--italy-green);
    color: white;
}

.unit-switch button.active:active {
    background: #007a38;
}

/* Option Groups */
label {
    display: block;
    font-weight: 700;
    color: var(--italy-red);
    font-size: 0.9rem;
    margin: 20px 0 10px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.option-group {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
    margin-bottom: 16px;
}

.option-button {
    padding: 18px 12px;
    background: white;
    border: 2px solid #E0E0E0;
    border-radius: var(--radius);
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    font-size: 0.9rem;
    font-weight: 600;
    min-height: 56px;
}

.option-button:hover {
    border-color: var(--italy-green);
    transform: translateY(-2px);
    box-shadow: var(--shadow);
}

.option-button:active {
    transform: translateY(0);
    box-shadow: inset 0 2px 4px rgba(0,0,0,0.1);
}

.option-button.selected {
    background: var(--italy-red);
    color: white;
    border-color: var(--italy-red);
}

.option-button.selected:active {
    transform: translateY(0);
}

.option-button img {
    width: 40px;
    height: 40px;
    object-fit: contain;
}

/* Sliders */
#hydration-slider {
    margin: 20px 0;
}

.hydration-value {
    text-align: center;
    font-size: 2rem;
    font-weight: 700;
    color: var(--italy-green);
}

/* Inputs */
input, select {
    width: 100%;
    padding: 14px 16px;
    border: 2px solid #E0E0E0;
    border-radius: var(--radius);
    font-size: 1rem;
    transition: border-color 0.2s;
}

input:focus, select:focus {
    outline: none;
    border-color: var(--italy-green);
}

/* Time Select */
.time-grid {
    display: grid;
    grid-template-columns: 2fr 1fr 1fr;
    gap: 10px;
    margin-bottom: 16px;
}

/* Calculate Button */
.calculate-btn {
    width: 100%;
    padding: 20px;
    background: linear-gradient(135deg, var(--italy-red), #b0242f);
    color: white;
    border: none;
    border-radius: var(--radius);
    font-size: 1.2rem;
    font-weight: 700;
    cursor: pointer;
    transition: transform 0.15s, box-shadow 0.15s;
    margin: 24px 0;
    min-height: 60px;
}

.calculate-btn:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 24px rgba(206,43,55,0.35);
}

.calculate-btn:active {
    transform: translateY(0);
    box-shadow: 0 2px 8px rgba(206,43,55,0.3);
}

/* Results */
#result {
    background: white;
    border-radius: var(--radius);
    padding: 24px;
    box-shadow: var(--shadow);
    margin: 20px 0;
    animation: slideIn 0.3s ease;
}

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

.result-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
    padding-bottom: 16px;
    border-bottom: 2px solid var(--italy-red);
}

.result-title {
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--italy-green);
}

.party-badge {
    background: var(--italy-green);
    color: white;
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 600;
}

.ingredient-list {
    list-style: none;
}

.ingredient-list li {
    display: flex;
    justify-content: space-between;
    padding: 12px 0;
    border-bottom: 1px solid #EEE;
}

.ingredient-list li:last-child {
    border-bottom: none;
}

.ingredient-name {
    font-weight: 600;
}

.ingredient-amount {
    color: var(--italy-red);
    font-weight: 700;
}

/* Timeline */
#timeline {
    background: white;
    border-radius: var(--radius);
    padding: 16px;
    margin: 20px 0;
    box-shadow: var(--shadow);
}

/* Chart */
#dough-chart {
    max-height: 300px;
    margin: 20px 0;
}

/* Footer */
.footer {
    text-align: center;
    margin-top: 40px;
    padding-top: 20px;
    border-top: 1px solid #EEE;
    color: #888;
    font-size: 0.85rem;
}

.footer a {
    color: var(--italy-green);
    text-decoration: none;
}

/* Mobile Optimizations - WCAG 2.5.8 Touch Target Size */
@media (max-width: 768px) {
    body {
        padding: 16px 12px;
        max-width: 100%;
    }

    h1 {
        font-size: 1.75rem;
    }

    h1::before {
        font-size: 2rem;
    }

    .subtitle {
        font-size: 1rem;
    }

    /* Larger touch targets - minimum 44px */
    .option-group {
        grid-template-columns: repeat(3, 1fr);
        gap: 8px;
    }

    .option-button {
        padding: 14px 6px;
        min-height: 60px;
        font-size: 0.8rem;
    }

    .unit-switch button {
        padding: 14px;
        min-height: 48px;
    }

    .calculate-btn {
        padding: 20px;
        font-size: 1.1rem;
        min-height: 56px;
    }

    /* Better touch on sliders */
    .nouislider {
        height: 40px;
    }

    /* Time inputs - stack vertically */
    .time-grid {
        grid-template-columns: 1fr;
        gap: 12px;
    }

    /* Dough inputs - stack on small screens */
    .dough-inputs-grid {
        grid-template-columns: 1fr;
        gap: 16px;
    }

@media (min-width: 769px) {
  .dough-inputs-grid {
    grid-template-columns: 1fr 1fr;
  }

  .dough-inputs-grid > div:nth-child(3) {
    grid-column: 1 / -1;
  }
}

    .dough-inputs-grid input[type="number"] {
        padding: 14px;
        min-height: 48px;
        font-size: 1rem;
    }

    /* Quick date chips - larger touch */


    /* Timeline - better touch scrolling */
    #timeline {
        padding: 16px;
        overflow-x: auto;
    }

    /* Results - better spacing */
    #result {
        padding: 20px;
    }

    /* Ingredient list - larger touch targets */
    .ingredient-list li {
        padding: 14px 0;
        min-height: 48px;
    }

    /* Footer - larger tap */
    .footer a {
        padding: 8px 12px;
        display: inline-block;
    }
    .dough-inputs-grid > div:nth-child(3) {
        grid-column: 1 / -1;
        width: 100%;
    }
    /* Prevent overflow on small screens */
    .dough-inputs-grid {
        overflow: hidden;
    }
    /* Ball weight label alignment on mobile */
    #ballWeightInput {
        width: 100% !important;
        max-width: 100% !important;
    }
    .style-card, .yeast-card, .fermentation-card, .oven-card {
        min-height: 44px;
    }
    label {
        min-height: 44px;
        display: flex;
        align-items: center;
    }
}

/* Small phones */
@media (max-width: 400px) {
    .option-group {
        grid-template-columns: repeat(2, 1fr);
    }

    h1 {
        font-size: 1.5rem;
        gap: 8px;
    }

    .option-button {
        padding: 12px 4px;
        min-height: 56px;
    }

    .result-header {
        flex-direction: column;
        gap: 12px;
        text-align: center;
    }
}

/* Landscape mobile */
@media (max-height: 500px) and (orientation: landscape) {
    body {
        padding: 12px 16px;
    }

    h1 {
        font-size: 1.25rem;
    }

    .calculate-btn {
        padding: 12px;
    }
}

/* Loading State */
.loading {
    animation: pulse 1s infinite;
}

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

/* Warning */
.warning {
    background: #FFF3CD;
    color: #856404;
    padding: 12px;
    border-radius: var(--radius);
    margin: 16px 0;
    font-size: 0.9rem;
}

/* Tips Section */
.tips-section {
    margin-top: 20px;
    padding: 16px;
    background: linear-gradient(135deg, #f8f9fa, #e9ecef);
    border-radius: var(--radius);
}

.tips-section h4 {
    color: var(--italy-green);
    margin-bottom: 12px;
    font-size: 1rem;
}

.tip-item {
    padding: 8px 0;
    border-bottom: 1px solid #ddd;
    font-size: 0.9rem;
}

.tip-item:last-child {
    border-bottom: none;
}

/* Tutorial Section */
.tutorial-section {
    margin-top: 16px;
}

.tutorial-link {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 14px 16px;
    background: linear-gradient(135deg, #ff0000, #cc0000);
    color: white;
    text-decoration: none;
    border-radius: var(--radius);
    font-weight: 600;
    transition: transform 0.2s, box-shadow 0.2s;
}

.tutorial-link:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(255, 0, 0, 0.3);
}

/* Quick date chips - modern button style */

.quick-dates

/* Quick date chips - equal width, WCAG touch targets */
.quick-dates {
    display: flex;
    gap: 10px;
    margin-top: 10px;
}

.quick-date-chip {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 14px 12px;
    background: #f0fdf4;
    border: 2px solid #86efac;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.15s ease;
    flex: 1;
    min-width: 0;
    min-height: 52px;
}

.quick-date-chip:hover {
    background: #dcfce7;
    border-color: #22c55e;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(34,197,94,0.25);
}

.quick-date-chip:active {
    transform: translateY(0);
    background: #bbf7d0;
    box-shadow: inset 0 2px 4px rgba(0,0,0,0.1);
}

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

.chip-text {
    font-size: 0.8rem;
    color: #166534;
    line-height: 1.3;
}

.chip-text strong {
    color: #15803d;
}

.chip-text small {
    color: #4ade80;
}

/* Dough inputs grid - both fields side by side */
.dough-inputs-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    align-items: end;
    margin-bottom: 20px;
}

.dough-inputs-grid > div:nth-child(3) {
    grid-column: 1 / -1;
}

.dough-inputs-grid > div {
    text-align: left;
}

.dough-inputs-grid input[type="number"] {
    width: 100%;
    padding: 10px 12px;
    border: 1.5px solid #e5e7eb;
    border-radius: 8px;
    font-size: 1rem;
    background: white;
}

.dough-inputs-grid input[type="number"]:focus {
    outline: none;
    border-color: #009246;
    box-shadow: 0 0 0 3px rgba(0, 146, 70, 0.1);
}

.dough-inputs-grid label {
    display: block;
    margin-bottom: 6px;
    font-weight: 500;
    color: #374151;
}

/* Ã¢ÂÂÃ¢ÂÂÃ¢ÂÂÃ¢ÂÂÃ¢ÂÂÃ¢ÂÂÃ¢ÂÂÃ¢ÂÂÃ¢ÂÂÃ¢ÂÂÃ¢ÂÂÃ¢ÂÂÃ¢ÂÂÃ¢ÂÂÃ¢ÂÂÃ¢ÂÂÃ¢ÂÂÃ¢ÂÂÃ¢ÂÂÃ¢ÂÂÃ¢ÂÂÃ¢ÂÂÃ¢ÂÂÃ¢ÂÂÃ¢ÂÂÃ¢ÂÂÃ¢ÂÂÃ¢ÂÂÃ¢ÂÂÃ¢ÂÂÃ¢ÂÂÃ¢ÂÂÃ¢ÂÂÃ¢ÂÂÃ¢ÂÂÃ¢ÂÂÃ¢ÂÂÃ¢ÂÂÃ¢ÂÂÃ¢ÂÂÃ¢ÂÂÃ¢ÂÂ */
/* CONTRAST-OPTIMIZED THEME SYSTEM           */
/* Ã¢ÂÂÃ¢ÂÂÃ¢ÂÂÃ¢ÂÂÃ¢ÂÂÃ¢ÂÂÃ¢ÂÂÃ¢ÂÂÃ¢ÂÂÃ¢ÂÂÃ¢ÂÂÃ¢ÂÂÃ¢ÂÂÃ¢ÂÂÃ¢ÂÂÃ¢ÂÂÃ¢ÂÂÃ¢ÂÂÃ¢ÂÂÃ¢ÂÂÃ¢ÂÂÃ¢ÂÂÃ¢ÂÂÃ¢ÂÂÃ¢ÂÂÃ¢ÂÂÃ¢ÂÂÃ¢ÂÂÃ¢ÂÂÃ¢ÂÂÃ¢ÂÂÃ¢ÂÂÃ¢ÂÂÃ¢ÂÂÃ¢ÂÂÃ¢ÂÂÃ¢ÂÂÃ¢ÂÂÃ¢ÂÂÃ¢ÂÂÃ¢ÂÂÃ¢ÂÂ */

/* Light mode improvements */
.option-button { transition: all 0.2s ease; border: 2px solid #ddd; }

.option-button:hover { border-color: #009246; transform: translateY(-1px); }

.option-button.selected { background: #c41e3a; color: #fff; border-color: #c41e3a; }

.option-button.selected span { color: #fff !important; }

.option-button.selected span:last-child { opacity: 0.85; }

.option-button span:last-child { color: #555; }

.section-title { letter-spacing: 0.5px; }

/* CONTRAST-OPTIMIZED THEME SYSTEM */

/* Light mode - betere button states */
.option-button { transition: all 0.2s ease; border: 2px solid #ddd; }

/* Dark Mode - volledig herzien voor contrast */
[data-theme="dark"] body { background: #111827; color: #f3f4f6; }

[data-theme="dark"] .calculator-card, [data-theme="dark"] .result-card { background: #1f2937; border: 1px solid #374151; }

[data-theme="dark"] .option-button { background: #1f2937; border: 2px solid #4b5563; color: #e5e7eb; }

[data-theme="dark"] .option-button:hover { border-color: #22c55e; }

[data-theme="dark"] .option-button span { color: #e5e7eb !important; }

[data-theme="dark"] .option-button span:last-child { color: #9ca3af !important; }

[data-theme="dark"] .option-button.selected { background: #dc2626; border-color: #dc2626; color: #fff; }

[data-theme="dark"] .option-button.selected span { color: #fff !important; }

[data-theme="dark"] .option-button.selected span:last-child { color: rgba(255,255,255,0.8) !important; }

[data-theme="dark"] .section-title { color: #4ade80; }

[data-theme="dark"] input, [data-theme="dark"] select { background: #1f2937; color: #f3f4f6; border: 2px solid #4b5563; }

[data-theme="dark"] input:focus, [data-theme="dark"] select:focus { border-color: #22c55e; outline: none; }

[data-theme="dark"] #hydration-value { color: #f87171; }

[data-theme="dark"] .noUi-target { background: #374151; border-color: #4b5563; }

[data-theme="dark"] .noUi-connect { background: #22c55e; }

[data-theme="dark"] .noUi-handle { background: #f3f4f6; border-color: #d1d5db; }

[data-theme="dark"] .ingredient-name { color: #e5e7eb; }

[data-theme="dark"] .ingredient-amount { color: #f87171; }

[data-theme="dark"] .party-badge { background: #065f46; color: #6ee7b7; border-color: #059669; }

[data-theme="dark"] .tip-section { background: #1a2e1a; border-color: #374151; }

[data-theme="dark"] .tip-item { color: #d1d5db; }

[data-theme="dark"] .tip-section h4 { color: #4ade80; }

[data-theme="dark"] .timeline-container, [data-theme="dark"] .timeline-wrapper,
[data-theme="dark"] [style*="background:#fff"], [data-theme="dark"] [style*="background:white"] { background: #1f2937 !important; color: #f3f4f6 !important; }

[data-theme="dark"] .warning, [data-theme="dark"] [style*="background:#FFF3CD"],
[data-theme="dark"] [style*="background:#fff3cd"] { background: #422006 !important; border-color: #92400e !important; color: #fbbf24 !important; }

[data-theme="dark"] button[onclick*="printRecipe"], [data-theme="dark"] button[onclick*="shareRecipe"] { background: #1f2937 !important; color: #f87171 !important; border-color: #f87171 !important; }

[data-theme="dark"] #sourdough-section { background: #1a2e1a !important; }

[data-theme="dark"] #sourdough-section label { color: #4ade80 !important; }

[data-theme="dark"] #sourdough-section span { color: #4ade80 !important; }

[data-theme="dark"] #sourdough-section p { color: #9ca3af !important; }

[data-theme="dark"] .step-details { color: #d1d5db !important; }

[data-theme="dark"] .step-details strong { color: #f3f4f6; }

[data-theme="dark"] .step-details em { color: #9ca3af; }

[data-theme="dark"] [style*="background:#f0fdf4"] { background: #1a2e1a !important; }

[data-theme="dark"] [style*="background:#f8f9fa"] { background: #1f2937 !important; }

[data-theme="dark"] canvas { filter: invert(0.85) hue-rotate(180deg); }

.dark-toggle { position: fixed; top: 16px; right: 16px; width: 44px; height: 44px; border-radius: 50%; border: 2px solid #d1d5db; background: white; font-size: 20px; cursor: pointer; z-index: 1000; display: flex; align-items: center; justify-content: center; box-shadow: 0 2px 8px rgba(0,0,0,0.15); transition: all 0.3s; }

[data-theme="dark"] .dark-toggle { background: #374151; border-color: #6b7280; box-shadow: 0 2px 8px rgba(0,0,0,0.4); }

[data-theme="dark"] #recipe-history div[style*="background"] { background: #1f2937 !important; border-color: #374151 !important; color: #e5e7eb !important; }

[data-theme="dark"] .timeline-step-label { color: #e8e8e8 !important; }

[data-theme="dark"] footer, [data-theme="dark"] .footer { color: #9ca3af; }

[data-theme="dark"] footer a { color: #f87171; }

/* Mobile layout - clean stacked inputs */
@media (max-width: 600px) {
    /* Force flour input full width above dough balls */
    #flourAmount, #doughBalls {
        width: 100% !important;
        font-size: 1.1rem !important;
        padding: 12px !important;
    }

    /* Ball weight row: label + wider input */
    #ballWeightInput {
        min-width: 80px !important;
        font-size: 1.1rem !important;
        padding: 10px !important;
    }

    /* Flour container - full width block */
    #flourAmount + span,
    #flourAmount ~ * {
        display: inline;
    }
    /* Nav: fix overflow + touch targets */
    .app-nav-inner {
        padding: 0 16px;
    }
    .app-nav-logo {
        min-height: 44px;
        display: flex;
        align-items: center;
        font-size: 1rem;
    }
    .app-nav-link {
        min-height: 44px;
        min-width: 44px;
        display: flex;
        align-items: center;
        justify-content: center;
        padding: 0 14px;
    }

    /* Inputs: min 44px for comfortable touch */
    .dough-inputs-grid input[type="number"],
    input[type="number"],
    input[type="date"],
    select {
        min-height: 44px;
    }

    /* Share/print bar: stack on very small screens */
    .share-print-bar {
        flex-direction: column;
    }
}

/* ── App navigation bar ── */
.app-nav {
    background: #006d3a;
    padding: 0;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}

.app-nav-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 20px;
    max-width: 600px;
    margin: 0 auto;
}

.app-nav-logo {
    color: #fff;
    font-size: 1.1rem;
    font-weight: 700;
    text-decoration: none;
    letter-spacing: -0.3px;
}

.app-nav-link {
    color: #fff;
    font-size: 0.9rem;
    font-weight: 500;
    text-decoration: none;
    background: rgba(255,255,255,0.15);
    padding: 6px 14px;
    border-radius: 6px;
    transition: background 0.2s;
}

.app-nav-link:hover {
    background: rgba(255,255,255,0.28);
}

/* ── Share / Print bar ── */
.share-print-bar {
    display: flex;
    gap: 10px;
    margin-top: 20px;
    padding-top: 16px;
    border-top: 1px solid var(--border, #e5e7eb);
}

.btn-share, .btn-print {
    flex: 1;
    padding: 10px 16px;
    border: none;
    border-radius: 8px;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: opacity 0.2s;
}

.btn-share {
    background: #006d3a;
    color: #fff;
}

.btn-print {
    background: #f3f4f6;
    color: #374151;
}

.btn-share:hover, .btn-print:hover { opacity: 0.85; }

@media print {
    .app-nav, .unit-switch, label, .option-group,
    .noUi-target, .dough-inputs-grid, .time-grid,
    .share-print-bar, #dough-chart, #timeline { display: none !important; }
    #result { box-shadow: none !important; }
}

/* ── Mobile fixes ── */

/* ── Pizza Diameter display ── */
.diameter-info {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.95rem;
    color: #444;
    margin: 10px 0 4px;
    padding: 10px 14px;
    background: linear-gradient(135deg, #f0faf4 0%, #e8f5e9 100%);
    border-radius: 10px;
    border-left: 3px solid #006d3a;
    font-weight: 500;
}

.diameter-info strong {
    color: #006d3a;
    font-size: 1.05rem;
}

.diameter-icon {
    font-size: 1.1rem;
    opacity: 0.7;
}

.pan-info {
    background: linear-gradient(135deg, #fff8f0 0%, #fef3e2 100%);
    border-left-color: #c41e3a;
}

.pan-info strong {
    color: #c41e3a;
}

/* Input validation warnings */
input.field-error { border-color: #c0392b !important; }

/* Mobile: ball weight full width below the 50-50 grid */

/* Touch target minimum on mobile */

/* ============================================
   CSS CUSTOM PROPERTIES + DARK MODE SUPPORT
   ============================================ */
:root {
    --clr-muted: #666;
    --clr-body: #555;
    --clr-hint: #777;
    --clr-subtle: #888;
    --clr-faint: #aaa;
    --clr-green-label: #006400;
    --clr-green-dark: #2d5a1b;
    --clr-green-step: #009246;
    --clr-red: #c41e3a;
    --bg-green-soft: #f0f7f0;
    --bg-warning-soft: #fff3cd;
    --bg-surface: #fff;
    --border-green: #c3e0c3;
    --border-success: #4CAF50;
    --border-warning: #ffc107;
}

@media (prefers-color-scheme: dark) {
    :root {
        --clr-muted: #b0b0b0;
        --clr-body: #d0d0d0;
        --clr-hint: #c0c0c0;
        --clr-subtle: #a0a0a0;
        --clr-faint: #909090;
        --clr-green-label: #5cb85c;
        --clr-green-dark: #5cb85c;
        --clr-green-step: #5cb85c;
        --clr-red: #ff6b6b;
        --bg-green-soft: #1a2e1a;
        --bg-warning-soft: #2e2500;
        --bg-surface: #2a2a2a;
        --border-green: #2d4a2d;
        --border-success: #3a7a3a;
        --border-warning: #7a6000;
    }

    /* Result card in dark mode */
    .result-card {
        background: #1e1e1e !important;
        border-color: #333 !important;
        color: #e0e0e0 !important;
    }

    /* Ingredient rows */
    .ingredient-row {
        border-bottom-color: #333 !important;
        color: #e0e0e0 !important;
    }

    /* Time steps */
    .time-steps-container {
        background: #1e1e1e !important;
    }

    /* Diameter info box */
    .diameter-info {
        background: #1a2e1a !important;
        color: #5cb85c !important;
        border-color: #2d4a2d !important;
    }

    /* Pro tips */
    .pro-tips {
        background: #1e2a1e !important;
        border-color: #2d4a2d !important;
        color: #d0d0d0 !important;
    }
    .tip-item {
        color: #d0d0d0 !important;
    }

    /* Bake time box */
    .bake-time-box, [style*="bg-green-soft"] {
        background: #1a2e1a !important;
        border-color: #2d4a2d !important;
        color: #d0d0d0 !important;
    }

    /* Time warning box */
    .time-warning, [style*="bg-warning-soft"] {
        background: #2e2500 !important;
        border-color: #5a4500 !important;
        color: #ffd54f !important;
    }

    /* Share/print buttons */
    .share-btn, .print-btn {
        background: #2a2a2a !important;
        color: #ff6b6b !important;
        border-color: #ff6b6b !important;
    }

    /* Party badge */
    .party-badge {
        background: #1a3a1a !important;
        color: #5cb85c !important;
    }

    /* Recalculate button in warning */
    [style*="background:#c41e3a"] {
        background: #8b0000 !important;
    }

    /* Sourdough tooltip */
    [style*="bg-green-soft"] {
        background: #1a2e1a !important;
        border-color: #2d4a2d !important;
    }
}

/* Accessibility: improved color contrast ratios */
.ingredient-label, .ingredient-name {
    color: #555 !important; /* contrast ratio 7.4:1 on white */
}

/* Ensure all muted text meets 4.5:1 minimum */
.tip-item, .pro-tips p, .guide-card p {
    color: #545454; /* 7.0:1 */
}

/* Style card subtitle text */
.style-card .subtitle, .style-subtitle {
    color: #545454;
}

/* Focus visible indicators for keyboard navigation */
button:focus-visible,
input:focus-visible,
select:focus-visible,
a:focus-visible {
    outline: 3px solid #2d5a1b;
    outline-offset: 2px;
}

/* Reduce layout shift: pre-set min-height on result area */
#result {
    min-height: 0;
    contain: layout;
}

/* Reduce CLS: stable nav height */
nav {
    min-height: 52px;
}

/* Calculate button loading state */
.calculate-btn:disabled {
    cursor: wait !important;
    transform: none !important;
}

.calculate-btn {
    transition: opacity 0.2s, transform 0.1s;
}

/* Fix: g unit label inline with flour input */
.dough-inputs-grid > div:nth-child(2) {
    display: flex;
    align-items: center;
    gap: 6px;
}

.dough-inputs-grid > div:nth-child(2) input {
    flex: 1;
    min-width: 0;
}

.dough-inputs-grid .unit-label,
.dough-inputs-grid span.unit {
    flex-shrink: 0;
    white-space: nowrap;
    font-size: 14px;
    color: var(--clr-muted, #666);
}

/* Ball weight unit label fix */
#ballWeightInput {
    flex: 1;
    min-width: 0;
    width: 100% !important;
}

/* Fix: date/time inputs overflow on mobile */
input[type="date"],
input[type="time"],
select#endHour,
select#endMinute {
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
    min-width: 0;
}

.time-grid {
    display: grid;
    grid-template-columns: 1fr auto auto;
    gap: 8px;
    width: 100%;
    overflow: hidden;
}

@media (max-width: 500px) {
    .time-grid {
        grid-template-columns: 1fr;
    }
    input[type="date"] {
        width: 100% !important;
        max-width: 100% !important;
    }
}

/* ── Mobile: g label inline met flour input ── */
.input-with-unit {
    display: flex !important;
    align-items: center !important;
    gap: 6px !important;
    width: 100% !important;
}

.input-with-unit input {
    flex: 1 !important;
    min-width: 0 !important;
}

.input-with-unit .unit,
.input-with-unit span:last-child {
    flex-shrink: 0 !important;
    white-space: nowrap !important;
}

/* Fallback: elk input+span combo in grid */
/* Dough inputs: label above, full-width input below */
.dough-inputs-grid > div {
    display: flex !important;
    flex-direction: column !important;
    gap: 6px;
    width: 100%;
    align-items: stretch !important;
    text-align: left !important;
}

.dough-inputs-grid > div label {
    text-align: left !important;
    font-size: 14.4px !important;
    font-weight: 700 !important;
    color: #CE2B37 !important;
    letter-spacing: 0.05em !important;
    text-transform: uppercase !important;
    margin-bottom: 4px !important;
    display: block !important;
    align-self: flex-start !important;
}

.dough-inputs-grid > div input[type="number"] {
    width: 100% !important;
    box-sizing: border-box !important;
    padding: 14px !important;
    min-height: 48px !important;
    font-size: 1rem !important;
    border: 1px solid #ddd !important;
    border-radius: 10px !important;
}

#ballWeightInput {
    width: 100% !important;
    box-sizing: border-box !important;
    padding: 14px !important;
    min-height: 48px !important;
    font-size: 1rem !important;
    border: 1px solid #ddd !important;
    border-radius: 10px !important;
}

.bw-wrapper {
    display: flex !important;
    flex-direction: column !important;
    align-items: stretch !important;
    width: 100% !important;
    grid-column: 1 / -1;
}

/* ── Mobile: datum veld niet buiten beeld ── */
@media (max-width: 768px) {
    .time-grid {
        display: flex !important;
        flex-direction: column !important;
        gap: 8px !important;
        width: 100% !important;
        overflow: hidden !important;
    }
    .time-grid > * {
        width: 100% !important;
        max-width: 100% !important;
        box-sizing: border-box !important;
    }
    input[type="date"],
    input[type="time"],
    select {
        width: 100% !important;
        max-width: 100% !important;
        box-sizing: border-box !important;
        -webkit-appearance: none !important;
        appearance: none !important;
    }
    /* Uur en minuut naast elkaar */
    .time-grid-hm {
        display: grid !important;
        grid-template-columns: 1fr 1fr !important;
        gap: 8px !important;
    }
}

/* ── Mobile fixes ── */
/* Ball weight: input + g inline */
#ballWeightInput {
    flex: 1 !important;
    min-width: 0 !important;
    width: auto !important;
}

/* Wrapper div around ballWeightInput + g */
#ballWeightInput ~ span,
#ballWeightInput + span {
    flex-shrink: 0 !important;
    white-space: nowrap !important;
    align-self: center !important;
}

/* Ensure parent div is flex row */
div:has(> #ballWeightInput) {
    display: flex !important;
    align-items: center !important;
    gap: 6px !important;
    flex-wrap: nowrap !important;
}

/* Date field: stack vertically on mobile so nothing overflows */
@media (max-width: 600px) {
    .time-grid {
        display: flex !important;
        flex-direction: column !important;
        gap: 8px !important;
        width: 100% !important;
    }
    .time-grid input[type="date"],
    .time-grid select {
        width: 100% !important;
        max-width: 100% !important;
        box-sizing: border-box !important;
        -webkit-appearance: none !important;
        appearance: none !important;
        font-size: 16px !important;
    }
    /* Hour + minute: side by side */
    .time-grid-hm {
        display: grid !important;
        grid-template-columns: 1fr 1fr !important;
        gap: 8px !important;
    }
}

/* ── Mobile grid fixes ── */
@media (max-width: 500px) {
    /* Stack dough balls + flour vertically on very small screens */
    .dough-inputs-grid {
        grid-template-columns: 1fr !important;
    }
    .dough-inputs-grid > div:nth-child(3) {
        grid-column: 1 !important;
    }
}

/* Ball weight wrapper */
.bw-wrapper {
    width: 100%;
    padding: 0;
}

.bw-wrapper label {
    display: block !important;
    min-height: auto !important;
    margin-bottom: 8px !important;
    font-size: 0.75rem !important;
    font-weight: 700 !important;
    color: var(--clr-green-dark, #2d5a1b) !important;
    letter-spacing: 0.05em !important;
    text-transform: uppercase !important;
}

.bw-wrapper div {
    display: flex !important;
    align-items: center !important;
    gap: 8px !important;
}

.bw-wrapper input {
    flex: 1 !important;
    min-width: 0 !important;
    width: auto !important;
}

.bw-wrapper span {
    flex-shrink: 0 !important;
}

/* Dark mode: input fields readable */
@media (prefers-color-scheme: dark) {
    input[type="number"],
    input[type="date"],
    input[type="text"],
    input[type="time"],
    select,
    textarea {
        color: #e0e0e0 !important;
        background: #2a2a2a !important;
        border-color: #444 !important;
    }
    input[type="number"]::placeholder,
    input[type="text"]::placeholder {
        color: #888 !important;
    }
    /* noUISlider dark mode */
    .noUi-target {
        background: #333 !important;
        border-color: #555 !important;
    }
    .noUi-connect {
        background: #2d5a1b !important;
    }
    .noUi-handle {
        background: #2d5a1b !important;
        border-color: #5cb85c !important;
    }
}

/* Ball weight: full width, no suffix needed */
.bw-wrapper {
    width: 100%;
}

.bw-wrapper label {
    display: block !important;
    margin-bottom: 8px !important;
    min-height: auto !important;
}

.bw-wrapper input {
    width: 100% !important;
    box-sizing: border-box !important;
    max-width: 100% !important;
}

/* Remove old flex layout from bw-wrapper */
.bw-wrapper > div {
    display: block !important;
}

/* Step label — leesbaar in beide modes via CSS var */
.timeline-step-label {
    flex: 1;
    color: var(--timeline-text, #1a1a1a);
}

@media (prefers-color-scheme: dark) {
    :root {
        --timeline-text: #e0e0e0;
        --timeline-bg: #1e1e1e;
        --timeline-border: #333;
        --timeline-date-color: #5cb85c;
        --timeline-detail-color: #b0b0b0;
    }
    .time-steps-container, .timeline-container, #timeline-steps {
        background: var(--timeline-bg, #1e1e1e) !important;
        border-color: var(--timeline-border, #333) !important;
    }
    .timeline-step-label {
        color: var(--timeline-text, #e0e0e0) !important;
    }
    .step-details {
        color: var(--timeline-detail-color, #b0b0b0) !important;
        background: #252525 !important;
    }
}

/* ══════════════════════════════
   TIMELINE — clean dark/light mode
   ══════════════════════════════ */
#timeline {
    background: transparent;
}

@media (prefers-color-scheme: dark) {
    .timeline-step-label {
        color: #e8e8e8 !important;
    }
    #timeline {
        background: transparent !important;
    }
}

/* ── Ball Weight: force full width (nuclear fix) ── */
.bw-wrapper,
.dough-inputs-grid > .bw-wrapper {
    display: flex !important;
    flex-direction: column !important;
    align-items: stretch !important;
    width: 100% !important;
}

.bw-wrapper input,
.bw-wrapper input[type="number"],
#ballWeightInput,
.dough-inputs-grid .bw-wrapper input {
    width: 100% !important;
    max-width: 100% !important;
    min-width: 100% !important;
    box-sizing: border-box !important;
    padding: 14px !important;
    min-height: 48px !important;
    font-size: 1rem !important;
    border: 1px solid #ddd !important;
    border-radius: 10px !important;
    flex: none !important;
}

label {
    margin-bottom: 10px !important;
}

.dough-inputs-grid > div > label {
    margin-bottom: 4px !important;
}

/* ── Spacing: all labels identical ── */
label {
    min-height: auto !important;
    height: auto !important;
    margin-top: 16px !important;
    margin-bottom: 6px !important;
    padding-top: 0 !important;
    padding-bottom: 0 !important;
}

.dough-inputs-grid {
    gap: 0 !important;
    margin-top: 0 !important;
    margin-bottom: 0 !important;
}

.dough-inputs-grid > div {
    gap: 0 !important;
}

.bw-wrapper {
    gap: 0 !important;
}

/* ── Time grid: date + hour/min side by side on desktop ── */
@media (min-width: 769px) {
    .time-grid {
        display: grid !important;
        grid-template-columns: 2fr 1fr !important;
        gap: 10px !important;
        align-items: start !important;
    }
}

.time-grid-hm {
    display: grid !important;
    grid-template-columns: 1fr 1fr !important;
    gap: 8px !important;
}

/* ── Hide result/timeline/chart until populated ── */
#result:empty,
#timeline:empty,
#dough-chart:empty {
    display: none !important;
}

.share-print-bar:empty {
    display: none !important;
}

.footer {
    margin-top: 20px !important;
    padding-top: 16px !important;
}

/* ── Calculator CTA button in nav: full-width on mobile ── */
nav a[href="/app/"] {
    order: 99;
}

@media (max-width: 768px) {
    nav a[href="/app/"] {
        width: 100% !important;
        justify-content: center !important;
        margin-top: 4px !important;
        padding: 10px 20px !important;
    }
}

/* ── Nav: compact on mobile ── */
@media (max-width: 768px) {
    nav {
        gap: 10px !important;
        padding: 10px 14px !important;
    }
    nav a {
        font-size: 13px !important;
        min-height: 36px !important;
    }
}
