:root {
    --primary: #d4a373;
    --secondary: #faedcd;
    --accent: #ccd5ae;
    --bg-dark: #1a1a1a;
    --bg-light: #2d2d2d;
    --text-main: #fefae0;
    --text-muted: #e9edc9;
    --glass-bg: rgba(255, 255, 255, 0.05);
    --glass-border: rgba(255, 255, 255, 0.1);
}

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

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--bg-dark);
    color: var(--text-main);
    line-height: 1.6;
}

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

.mobile-text {
    display: none;
}

.recipe-actions {
    display: flex;
    gap: 10px;
}

.recipe-controls .btn-primary,
.recipe-controls .btn-secondary,
.recipe-controls select {
    height: 40px;
    padding: 0 20px;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Dashboard Compact View (1200x640px) */
.dashboard-page .container {
    height: 640px;
    width: 1200px;
    padding: 8px 20px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.dashboard-page .main-header {
    padding: 4px 15px;
    margin-bottom: 5px;
}

.dashboard-page .header-logo {
    height: 30px;
}

.dashboard-page .main-layout {
    flex: 1;
    margin-top: 5px;
    gap: 10px;
    overflow: hidden;
}

.dashboard-page .brew-display {
    padding: 10px 15px 5px 15px;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
}

.dashboard-page .phase-selector {
    margin: 5px 0 8px 0;
    padding: 2px 5px;
}

.dashboard-page .phase-btn {
    padding: 4px 8px;
    font-size: 0.75rem;
}

.dashboard-page .phase-image {
    max-height: 350px;
    width: auto;
    margin: 0 auto 5px auto;
    padding: 5px;
}

.dashboard-page .controls-timers-wrapper {
    margin-top: 5px;
    gap: 15px;
    justify-content: center;
    align-items: center;
    /* Center buttons vertically against timers */
}

.dashboard-page .timer-logo-wrapper {
    display: flex;
    gap: 10px;
    align-items: stretch;
    /* Stretch logo to match timer box height */
}

.dashboard-page .logo-box {
    background: rgba(0, 0, 0, 0.2);
    border-radius: 10px;
    padding: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--glass-border);
}

.dashboard-page .chief-scientist-logo {
    max-height: 100%;
    width: auto;
    object-fit: contain;
}

.dashboard-page .controls {
    gap: 5px;
}

.dashboard-page .btn-control {
    padding: 6px 15px;
    font-size: 0.9rem;
    min-width: 100px;
}

.dashboard-page .timer-box {
    padding: 8px 15px;
    min-width: 260px;
}

/* Phase timer fixed width for longer times like 1:00:00 with ACK button */
.dashboard-page #phase-timer-box {
    min-width: 260px;
    min-height: 85px;
    /* Fixed height to prevent resizing when target appears */
}

.dashboard-page #phase-timer-box #phase-timer {
    min-width: 100px;
    display: inline-block;
    line-height: 1;
}

/* Reduce space between timer and target text */
.dashboard-page #phase-timer-box #timer-target {
    margin-top: 2px;
    min-height: 14px;
    /* Reserve space even when empty */
}

/* Phase timer content container for overlay positioning */
.phase-timer-content {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    position: relative;
}

/* ACK overlay button - centered over timer */
.ack-overlay-btn {
    display: none;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    padding: 10px 20px;
    font-size: 1rem;
    font-weight: 700;
    background-color: #ef4444;
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    z-index: 10;
    box-shadow: 0 4px 15px rgba(239, 68, 68, 0.5);
    animation: pulse-ack 1s ease-in-out infinite;
}

.ack-overlay-btn:hover {
    background-color: #dc2626;
    transform: translate(-50%, -50%) scale(1.05);
}

@keyframes pulse-ack {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.8;
    }
}

/* Smaller brew day timer text */
.dashboard-page .brew-day-container .timer-value {
    font-size: 1.8rem;
}

/* Editable timer input */
.timer-edit-input {
    font-size: 2.5rem;
    font-weight: 700;
    font-family: 'Courier New', monospace;
    color: var(--primary);
    background: rgba(0, 0, 0, 0.4);
    border: 2px solid var(--primary);
    border-radius: 8px;
    text-align: center;
    width: 140px;
    padding: 5px;
}

.timer-edit-input:focus {
    outline: none;
    border-color: #4ade80;
    box-shadow: 0 0 10px rgba(74, 222, 128, 0.3);
}

/* Brew day timer running state - pale green border */
.brew-day-container.running {
    border: 2px solid rgba(74, 222, 128, 0.5);
}




.addition-item {
    transition: all 0.3s ease;
}

.addition-item.due {
    color: #ff6b6b;
    font-weight: 700;
    text-shadow: 0 0 5px rgba(239, 68, 68, 0.4);
}

.addition-item.done {
    color: #666 !important;
    text-decoration: line-through;
    opacity: 0.7;
    text-shadow: none;
}

.dashboard-page .sidebar {
    padding: 8px 15px 4px 15px;
    display: flex;
    flex-direction: column;
}

.dashboard-page .sidebar h3 {
    font-size: 0.9rem;
    margin-bottom: 5px;
}

.dashboard-page .recipe-selector {
    padding: 8px;
    margin-bottom: 10px;
}

.dashboard-page .instructions-list {
    font-size: 0.7rem;
    line-height: 1.3;
}

.dashboard-page .instructions-list li {
    margin-bottom: 3px;
}

.dashboard-page .reminders-box {
    margin-top: 5px;
    padding-top: 5px;
}

.dashboard-page .chief-scientist-logo {
    max-height: 80px;
}

.dashboard-page .sidebar .instructions-list {
    max-height: 330px;
    overflow-y: auto;
}

/* Main Header Styling */
.main-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 20px;
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    border-radius: 12px;
    margin-bottom: 15px;
    backdrop-filter: blur(10px);
    position: relative;
    z-index: 100;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 12px;
    text-decoration: none;
    transition: opacity 0.3s;
}

.header-left:hover {
    opacity: 0.8;
}

.header-logo {
    height: 40px;
    width: auto;
    filter: drop-shadow(0 0 5px rgba(0, 0, 0, 0.5));
}

.header-title {
    font-size: 1.1rem;
    color: var(--primary);
    margin: 0;
    font-weight: 700;
    letter-spacing: 0.5px;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.5);
    white-space: nowrap;
}

/* Burger Menu Styles */
.burger-menu-btn {
    background: var(--glass-bg);
    border: 2px solid var(--glass-border);
    color: var(--primary);
    font-size: 1.4rem;
    padding: 6px 12px;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.3s;
    line-height: 1;
}

.burger-menu-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    box-shadow: 0 0 15px rgba(212, 163, 115, 0.3);
}

.nav-dropdown {
    display: none;
    position: absolute;
    top: 100%;
    right: 0;
    margin-top: 10px;
    background: rgba(26, 26, 26, 0.95);
    border: 1px solid var(--glass-border);
    border-radius: 12px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
    min-width: 200px;
    z-index: 1000;
    backdrop-filter: blur(10px);
    overflow: hidden;
    padding: 5px;
}

.nav-dropdown.show {
    display: block;
    animation: fadeIn 0.2s ease-out;
}

.dropdown-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 16px;
    color: var(--text-main);
    text-decoration: none;
    transition: background 0.2s;
    border-radius: 6px;
    margin-bottom: 1px;
    white-space: nowrap;
}

.dropdown-item:hover {
    background: rgba(255, 255, 255, 0.1);
    color: var(--primary);
}

.dropdown-item.active {
    background: rgba(212, 163, 115, 0.2);
    color: var(--primary);
    font-weight: 600;
}

.nav-icon-small {
    font-size: 1rem;
}

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

    to {
        opacity: 1;
        transform: translateY(0);
    }
}


/* Recipe selector */
/* Recipe selector */
.recipe-selector {
    margin: 0 0 20px 0;
    padding: 15px;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 10px;
    border: 1px solid var(--glass-border);
}

.recipe-selector label {
    font-weight: 600;
    color: var(--text-main);
    margin-right: 15px;
    font-size: 1rem;
}

.form-control,
select {
    padding: 12px 20px;
    background: rgba(0, 0, 0, 0.3);
    border: 2px solid var(--glass-border);
    border-radius: 12px;
    color: var(--text-main);
    font-family: 'Inter', sans-serif;
    font-size: 1rem;
    font-weight: 500;
    min-width: 250px;
    transition: all 0.3s;
    cursor: pointer;
}

.form-control:focus,
select:focus {
    outline: none;
    border-color: var(--primary);
    background: rgba(0, 0, 0, 0.4);
}

.form-control option,
select option {
    background: var(--bg-light);
    color: var(--text-main);
    padding: 10px;
}

nav a {
    color: var(--text-main);
    text-decoration: none;
    margin-left: 20px;
    font-weight: 500;
}

nav a:hover {
    color: var(--primary);
}

.main-layout {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 15px;
    /* Reduced gap */
    margin-top: 15px;
    /* Reduced gap */
}

.brew-display {
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    backdrop-filter: blur(10px);
    border-radius: 15px;
    padding: 30px;
    text-align: center;
}

.phase-image-container {
    position: relative;
    display: inline-block;
    max-width: 100%;
    margin-bottom: 20px;
}

.phase-image {
    max-width: 100%;
    border-radius: 10px;
    margin-bottom: 0px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
    background-color: rgba(255, 255, 255, 0.16);
    padding: 20px;
    display: block;
}

.nav-arrow {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(255, 255, 255, 0.15);
    color: white;
    border: none;
    font-size: 2rem;
    padding: 15px 20px;
    cursor: pointer;
    border-radius: 50%;
    z-index: 10;
    transition: background 0.3s, transform 0.3s;
    backdrop-filter: blur(5px);
}

.nav-arrow:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: translateY(-50%) scale(1.1);
}

.nav-arrow.nav-left {
    left: 10px;
}

.nav-arrow.nav-right {
    right: 10px;
}

.timers {
    display: flex;
    justify-content: space-around;
    gap: 10px;
}

.timer-box {
    padding: 20px;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 10px;
    min-width: 220px;
    /* Increased to fit "Strike Ready Timer" */
    text-align: center;
    border: 3px solid transparent;
    transition: all 0.3s;
}

.brew-day-flex {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 15px;
}

.brew-day-controls {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.btn-tiny {
    padding: 5px 10px;
    font-size: 0.8rem;
    min-width: auto;
    border-radius: 5px;
    line-height: 1;
}

.btn-tiny.btn-start {
    background-color: #4ade80;
    color: var(--bg-dark);
}

.btn-tiny.btn-reset-bd {
    background-color: #e76f51;
    color: white;
}

.timer-box.running {
    border-color: #4ade80;
    box-shadow: 0 0 20px rgba(74, 222, 128, 0.6),
        0 0 40px rgba(74, 222, 128, 0.4),
        inset 0 0 20px rgba(74, 222, 128, 0.1);
    animation: pulse-glow 2s ease-in-out infinite;
}

@keyframes pulse-glow {

    0%,
    100% {
        box-shadow: 0 0 20px rgba(74, 222, 128, 0.6),
            0 0 40px rgba(74, 222, 128, 0.4),
            inset 0 0 20px rgba(74, 222, 128, 0.1);
    }

    50% {
        box-shadow: 0 0 30px rgba(74, 222, 128, 0.8),
            0 0 60px rgba(74, 222, 128, 0.5),
            inset 0 0 30px rgba(74, 222, 128, 0.2);
    }
}

.timer-box.alert {
    border-color: #ef4444 !important;
    box-shadow: 0 0 20px rgba(239, 68, 68, 0.6),
        0 0 40px rgba(239, 68, 68, 0.4),
        inset 0 0 20px rgba(239, 68, 68, 0.1) !important;
    animation: pulse-alert-glow 1.5s ease-in-out infinite !important;
}

@keyframes pulse-alert-glow {

    0%,
    100% {
        box-shadow: 0 0 20px rgba(239, 68, 68, 0.6),
            0 0 40px rgba(239, 68, 68, 0.4),
            inset 0 0 20px rgba(239, 68, 68, 0.1);
    }

    50% {
        box-shadow: 0 0 30px rgba(239, 68, 68, 0.8),
            0 0 60px rgba(239, 68, 68, 0.5),
            inset 0 0 30px rgba(239, 68, 68, 0.2);
    }
}

.timer-label {
    font-size: 0.8rem;
    color: var(--text-muted);
    text-transform: uppercase;
    margin-bottom: 5px;
}

.timer-value {
    font-size: 2.5rem;
    font-weight: 700;
    font-family: 'Courier New', monospace;
    color: var(--primary);
}

/* Controls and timers wrapper */
.controls-timers-wrapper {
    display: flex;
    align-items: center;
    gap: 30px;
    margin-top: 20px;
}

.controls {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.btn-control {
    padding: 10px 20px;
    font-size: 1rem;
    font-weight: 700;
    font-family: 'Courier New', monospace;
    letter-spacing: 1px;
    min-width: 120px;
}

/* Phase selector buttons */
.phase-selector {
    display: flex;
    gap: 5px;
    justify-content: center;
    margin: 20px 0;
    flex-wrap: nowrap;
    overflow-x: auto;
    /* Allow scroll on very small mobile if needed, but try to fit */
    padding: 10px 5px;
    /* Add padding to prevent hover clipping */
}

.phase-btn {
    padding: 8px 12px;
    background: rgba(255, 255, 255, 0.05);
    border: 2px solid var(--glass-border);
    color: var(--text-muted);
    font-family: 'Inter', sans-serif;
    font-size: 0.8rem;
    font-weight: 600;
    letter-spacing: 0.5px;
    flex: 1 1 auto;
    white-space: nowrap;
    transition: all 0.3s;
    position: relative;
    /* Ensure z-index works */
    z-index: 1;
}

.phase-btn:hover {
    background: rgba(74, 222, 128, 0.1);
    border-color: #4ade80;
    color: #4ade80;
    z-index: 10;
    /* Bring to front on hover */
    box-shadow: 0 0 15px rgba(74, 222, 128, 0.3);
}

#start-btn {
    background-color: #4ade80;
    color: var(--bg-dark);
}

#stop-btn {
    background-color: var(--primary);
    color: white;
}

.phase-btn.active {
    background: #4ade80;
    border-color: #4ade80;
    color: var(--bg-dark);
    box-shadow: 0 0 20px rgba(74, 222, 128, 0.5);
}

.phase-btn.viewed {
    border-color: #fca311;
    color: #fca311;
    box-shadow: 0 0 10px rgba(252, 163, 17, 0.3);
}


button {
    padding: 12px 24px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.3s;
}

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

.btn-secondary {
    background-color: var(--accent);
    color: var(--bg-dark);
}

.btn-reset {
    background-color: #e76f51;
    color: white;
}

.btn-large {
    font-size: 1.2rem;
    padding: 15px 40px;
}

button:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.3);
}

.sidebar {
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    border-radius: 15px;
    padding: 20px;
}

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

.instructions-list li {
    padding: 10px 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.instructions-list li:before {
    content: "•";
    color: var(--primary);
    margin-right: 10px;
    font-weight: bold;
}

/* Recipe Editor Styles */
.recipe-layout {
    display: flex;
    flex-direction: column;
    gap: 15px;
    margin-top: 15px;
}

.recipe-editor {
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    border-radius: 15px;
    padding: 30px;
}

.form-section {
    margin-bottom: 30px;
    padding: 20px;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 10px;
    border-left: 3px solid var(--primary);
}

.form-section h4 {
    color: var(--primary);
    margin-bottom: 15px;
    font-size: 1.1rem;
}

.form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
}

.form-group {
    display: flex;
    flex-direction: column;
}

.form-group label {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-bottom: 5px;
    font-weight: 600;
}

.water-grid {
    grid-template-columns: repeat(4, 1fr);
}

.water-additions-grid {
    grid-template-columns: repeat(3, 1fr);
}

/* Mobile Responsiveness for Water Chemistry */
@media (max-width: 992px) {
    .water-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* Intermediate tweak for additions grid */
@media (max-width: 890px) and (min-width: 601px) {
    .water-additions-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 600px) {
    .water-grid {
        grid-template-columns: 1fr;
    }

    .water-additions-grid {
        grid-template-columns: 1fr;
        padding: 10px;
        /* More compact padding */
    }

    .water-additions-grid .form-group label {
        font-size: 0.75rem;
        /* Smaller labels */
    }

    .water-additions-grid .form-input {
        padding: 8px;
        /* Compact inputs */
        font-size: 0.85rem;
    }
}

/* Ultra-compact for very narrow screens */
@media (max-width: 400px) {
    .form-section {
        padding: 10px;
    }

    .water-additions-grid {
        padding: 8px;
    }
}

.water-additions-grid .form-input {
    background: rgba(212, 163, 115, 0.1);
    border-color: rgba(212, 163, 115, 0.3);
}

.ingredient-characteristics {
    font-size: 0.75rem;
    color: var(--text-muted);
    font-style: italic;
    margin-top: 4px;
    display: block;
    max-width: 300px;
    line-height: 1.2;
    min-height: 14px;
}

.form-input {
    padding: 10px 15px;
    background: rgba(0, 0, 0, 0.3);
    border: 2px solid var(--glass-border);
    border-radius: 8px;
    color: var(--text-main);
    font-family: 'Inter', sans-serif;
    font-size: 0.95rem;
    transition: all 0.3s;
}

.form-input:focus {
    outline: none;
    border-color: var(--primary);
    background: rgba(0, 0, 0, 0.4);
}

.json-editor-toggle {
    margin: 30px 0 10px;
    text-align: center;
}

.json-editor-section {
    margin-top: 15px;
    padding: 20px;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 10px;
    border: 2px dashed var(--glass-border);
}

.json-textarea {
    width: 100%;
    background: #000;
    color: #0f0;
    font-family: 'Courier New', monospace;
    padding: 15px;
    border-radius: 8px;
    border: 1px solid var(--glass-border);
    font-size: 0.9rem;
}

.help-text {
    margin-top: 10px;
    font-size: 0.85rem;
    color: var(--text-muted);
    font-style: italic;
}

.recipe-list {
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    border-radius: 15px;
    padding: 20px;
}

.recipe-item {
    padding: 10px;
    margin-bottom: 5px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 5px;
    cursor: pointer;
    transition: all 0.3s;
}

.recipe-item:hover {
    background: rgba(255, 255, 255, 0.1);
    border-left: 3px solid var(--primary);
}

/* Ingredients Page Styles */
.ingredients-layout {
    margin-top: 20px;
}

.ingredients-editor {
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    border-radius: 15px;
    padding: 30px;
    max-width: 900px;
    margin: 0 auto;
}

.ingredient-rows {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 15px;
}

.ingredient-row {
    display: grid;
    grid-template-columns: 1fr 200px 40px;
    gap: 10px;
    align-items: center;
}

.hop-row {
    display: flex !important;
    gap: 10px;
    align-items: flex-end;
}

.form-input.small {
    max-width: 200px;
}

/* Allow inputs in grids to shrink below global min-width */
.ingredient-row .form-input,
.ingredient-row select {
    min-width: 0;
}

.btn-add {
    padding: 8px 20px;
    background: rgba(74, 222, 128, 0.2);
    border: 2px solid #4ade80;
    color: #4ade80;
    border-radius: 8px;
    font-weight: 600;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.3s;
    margin-top: 10px;
}

.btn-add:hover {
    background: rgba(74, 222, 128, 0.3);
    transform: translateY(-2px);
}

.btn-remove {
    padding: 8px 12px;
    background: rgba(239, 68, 68, 0.2);
    border: 2px solid #ef4444;
    color: #ef4444;
    border-radius: 8px;
    font-weight: 700;
    font-size: 1.2rem;
    cursor: pointer;
    transition: all 0.3s;
    line-height: 1;
}

.btn-remove:hover {
    background: rgba(239, 68, 68, 0.4);
    /* transform: scale(1.1); removed to prevent scrollbar */
}

.square-btn {
    width: 38px;
    height: 38px;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
}

/* Unknown variety highlighting - orange border for items not in database */
.unknown-variety {
    border-color: #f97316 !important;
    box-shadow: 0 0 8px rgba(249, 115, 22, 0.4);
}

/* Upload button to add unknown variety to database */
.btn-upload {
    padding: 8px 12px;
    background: rgba(249, 115, 22, 0.2);
    border: 2px solid #f97316;
    color: #f97316;
    border-radius: 8px;
    font-weight: 700;
    font-size: 1.2rem;
    cursor: pointer;
    transition: all 0.3s;
    line-height: 1;
}

.btn-upload:hover {
    background: rgba(249, 115, 22, 0.4);
}

.add-varieties-section {
    margin-top: 40px;
    padding-top: 30px;
    border-top: 2px solid var(--glass-border);
}

.add-varieties-section h3 {
    color: var(--primary);
    margin-bottom: 20px;
}

.variety-forms {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

.variety-form {
    padding: 20px;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 10px;
    border: 1px solid var(--glass-border);
}

.variety-form h4 {
    color: var(--text-main);
    margin-bottom: 10px;
    font-size: 1rem;
}

.variety-form input {
    margin-bottom: 10px;
    width: 100%;
}

@media (max-width: 768px) {
    .container {
        padding: 12px;
    }

    @media (max-width: 400px) {
        .container {
            padding: 8px;
        }

        .header-left {
            flex: 1;
            min-width: 0;
        }

        .header-title {
            font-size: 0.85rem;
        }
    }

    /* Compact header on mobile */
    .main-header {
        padding: 6px 12px;
        border-radius: 10px;
        margin-bottom: 10px;
    }

    .header-left {
        gap: 8px;
    }

    .header-logo {
        height: 30px;
    }

    .header-title {
        font-size: 0.9rem;
        letter-spacing: 0;
        white-space: normal;
    }

    .burger-menu-btn {
        font-size: 1.2rem;
        padding: 4px 10px;
        border-radius: 8px;
    }

    .main-layout {
        grid-template-columns: 1fr;
    }

    .controls-timers-wrapper {
        flex-direction: column;
        gap: 20px;
    }

    .controls {
        flex-direction: row;
        justify-content: center;
    }

    .recipe-actions {
        order: -1;
        width: 100%;
        justify-content: space-between;
    }

    .ingredient-characteristics {
        font-size: 0.5rem;
        /* ~33% reduction from 0.75rem */
        max-width: 30%;
    }

    /* Recipe page mobile styles */
    .recipe-controls {
        flex-direction: column !important;
        align-items: stretch !important;
        gap: 10px !important;
        padding: 12px !important;
    }

    .recipe-controls>div {
        width: 100%;
    }

    .recipe-controls select {
        max-width: 100% !important;
    }

    .recipe-controls button,
    .recipe-controls select {
        height: 40px !important;
        display: flex;
        align-items: center;
        justify-content: center;
        padding: 0 15px;
    }

    .recipe-actions {
        width: 100%;
        display: flex !important;
        flex-direction: row !important;
        gap: 10px;
    }

    .recipe-actions button {
        flex: 1 1 0%;
        width: auto !important;
    }

    .mobile-text {
        display: inline;
    }

    .desktop-text {
        display: none;
    }

    .recipe-editor {
        padding: 15px;
    }

    .recipe-editor h3 {
        font-size: 1.2rem;
    }

    .form-section {
        padding: 12px;
        margin-bottom: 15px;
    }

    .form-section h4 {
        font-size: 0.9rem;
    }

    /* Single column form grid */
    .form-grid {
        grid-template-columns: 1fr;
        gap: 10px;
    }

    .form-input,
    .recipe-editor select {
        min-width: 0;
        font-size: 0.9rem;
        padding: 8px 10px;
    }

    /* Ingredient rows - intelligent wrapping */
    .hop-row {
        flex-direction: row !important;
        flex-wrap: wrap !important;
        padding: 5px !important;
        align-items: flex-end !important;
        background: rgba(0, 0, 0, 0.15);
        border-radius: 8px;
    }

    .hop-row>.form-group:first-child {
        flex: 1 0 100% !important;
        /* Item name takes full width */
        max-width: 100% !important;
        margin-bottom: 5px;
    }

    .hop-row>.form-group:not(:first-child),
    .hop-row>button {
        flex: 1 0 0% !important;
        /* Other fields and buttons share the second line */
        max-width: none !important;
        align-self: center !important;
        margin-top: 5px;
    }

    .hop-row .form-input {
        padding: 5px 8px !important;
        font-size: 0.85rem !important;
        height: 36px !important;
    }

    .hop-row .square-btn {
        width: 38px !important;
        height: 38px !important;
        font-size: 1.5rem !important;
    }

    .hop-row .btn-remove {
        align-self: center !important;
    }

    /* Hide column headers on mobile */
    .ingredient-row.hop-row[style*="background: transparent"] {
        display: none !important;
    }

    .ingredient-rows {
        gap: 15px;
    }

    .ingredient-rows .hop-row {
        padding: 10px;
        background: rgba(0, 0, 0, 0.15);
        border-radius: 8px;
    }

    /* Buttons - only full width if not in a flex row */
    .form-section>.btn-add,
    .form-section>.btn-large {
        width: 100%;
    }

    .btn-large {
        font-size: 1rem;
        padding: 12px 20px;
    }

    /* JSON editor */
    .json-textarea {
        font-size: 0.75rem;
    }
}


/* Shopping List Styles */
.shopping-list-row {
    display: grid;
    grid-template-columns: 30px 1fr 2fr 1fr 40px;
    gap: 10px;
    align-items: center;
    margin-bottom: 5px;
}

@media (max-width: 600px) {
    .ingredients-editor {
        padding: 10px;
    }

    .ingredients-editor h2 {
        font-size: 1.3rem;
    }

    .form-section h4 {
        font-size: 0.95rem;
    }

    /* Stack import button under recipe select on mobile */
    .form-section>div[style*="display: flex"] {
        flex-direction: column !important;
    }

    .form-section>div[style*="display: flex"] select {
        width: 100%;
    }

    .form-section>div[style*="display: flex"] button {
        width: 100%;
        margin-top: 8px;
    }

    .shopping-list-row {
        gap: 4px;
        grid-template-columns: 24px 1fr 1.5fr 0.8fr 32px;
    }

    /* Make inputs smaller on mobile to fit */
    .shopping-list-row .form-input,
    .shopping-list-row select {
        padding: 5px 3px;
        font-size: 0.7rem;
    }

    /* Header row text smaller */
    .header-row .ingredient-row span {
        font-size: 0.7rem;
    }

    /* Adjust checkbox size */
    .shopping-list-row input[type="checkbox"] {
        width: 16px;
        height: 16px;
    }

    /* Smaller remove button */
    .shopping-list-row .btn-remove {
        width: 28px;
        height: 28px;
        font-size: 1rem;
        padding: 4px;
    }

    /* Bottom action buttons */
    .form-section>div[style*="margin-top: 15px"] {
        flex-wrap: wrap;
    }

    .btn-add,
    .btn-primary {
        font-size: 0.85rem;
        padding: 8px 12px;
    }
}

@media (max-width: 800px) {
    .dashboard-page .container {
        width: 100% !important;
        height: auto !important;
        overflow: visible !important;
        padding: 10px;
    }

    .dashboard-page .main-layout {
        display: flex;
        flex-direction: column;
        overflow: visible;
    }

    .dashboard-page .brew-display {
        width: 100%;
        padding: 15px;
    }

    .dashboard-page .sidebar {
        width: 100%;
        margin-top: 20px;
    }

    .dashboard-page .sidebar .instructions-list {
        max-height: none;
        /* Let it grow vertical on mobile */
        font-size: 1.05rem;
        /* 0.7 * 1.5 */
        line-height: 1.5;
    }

    .dashboard-page .sidebar h3 {
        font-size: 1.35rem;
        /* 0.9 * 1.5 */
        margin-top: 15px;
    }

    .dashboard-page .phase-image {
        max-height: 250px;
        /* Smaller image on mobile */
    }
}

@media (max-width: 640px) {
    .dashboard-page .timers {
        flex-direction: column;
        align-items: center;
        gap: 15px;
    }

    .dashboard-page .timer-logo-wrapper {
        flex-direction: column;
        width: 100%;
        align-items: center;
    }

    .dashboard-page .logo-box {
        display: none !important;
    }

    .dashboard-page .timer-box {
        width: 100%;
        max-width: 300px;
    }
}

/* Mobile: Phase buttons wrap to two lines on narrow screens */
@media (max-width: 550px) {
    .phase-selector {
        flex-wrap: wrap;
        justify-content: center;
    }

    .phase-btn {
        flex: 0 1 auto;
        min-width: 80px;
    }
}