/* ===== CSS Variables ===== */
:root {
    --primary-color: #e2674a;
    --primary-hover: #c9502f;
    --primary-soft: rgba(226, 103, 74, 0.12);
    --accent-gradient: linear-gradient(135deg, #e2674a 0%, #c9502f 100%);
    --secondary-color: #efece6;
    --secondary-hover: #e6e2da;
    --success-color: #16a34a;
    --error-color: #ef4444;
    --warning-color: #f59e0b;
    --info-color: #0ea5e9;

    --bg-color: #f4f2ee;
    --bg-secondary: #ffffff;
    --bg-card: #ffffff;
    --bg-elevated: #efece6;
    --bg-input: #ffffff;

    --text-primary: #171a1d;
    --text-secondary: #6b7683;
    --text-muted: #9aa4ae;

    --border-color: #ececec;
    --border-soft: rgba(20, 32, 46, 0.06);
    --border-radius: 12px;
    --border-radius-lg: 18px;
    --border-radius-sm: 9px;

    --sidebar-width: 212px;
    --shadow: 0 1px 2px rgba(20, 28, 38, 0.05), 0 8px 20px rgba(20, 28, 38, 0.07);
    --shadow-lg: 0 18px 44px rgba(20, 28, 38, 0.13);
    --shadow-glow: 0 8px 22px rgba(226, 103, 74, 0.32);

    --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
}

/* ===== Dark mode ===== */
:root[data-theme="dark"] {
    --primary-color: #ec7355;
    --primary-hover: #e2674a;
    --primary-soft: rgba(236, 115, 85, 0.16);
    --accent-gradient: linear-gradient(135deg, #ec7355 0%, #d5563a 100%);
    --secondary-color: #2a2731;
    --secondary-hover: #332f3b;

    --bg-color: #141317;
    --bg-secondary: #1e1c22;
    --bg-card: #1e1c22;
    --bg-elevated: #2a2731;
    --bg-input: #1e1c22;

    --text-primary: #f1eee8;
    --text-secondary: #9c98a2;
    --text-muted: #6f6b74;

    --border-color: #2a2731;
    --border-soft: rgba(255, 255, 255, 0.06);
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 8px 22px rgba(0, 0, 0, 0.35);
    --shadow-lg: 0 20px 48px rgba(0, 0, 0, 0.5);
    --shadow-glow: 0 8px 22px rgba(236, 115, 85, 0.34);
}

@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        --primary-color: #ec7355;
        --primary-hover: #e2674a;
        --primary-soft: rgba(236, 115, 85, 0.16);
        --accent-gradient: linear-gradient(135deg, #ec7355 0%, #d5563a 100%);
        --secondary-color: #2a2731;
        --secondary-hover: #332f3b;
        --bg-color: #141317;
        --bg-secondary: #1e1c22;
        --bg-card: #1e1c22;
        --bg-elevated: #2a2731;
        --bg-input: #1e1c22;
        --text-primary: #f1eee8;
        --text-secondary: #9c98a2;
        --text-muted: #6f6b74;
        --border-color: #2a2731;
        --border-soft: rgba(255, 255, 255, 0.06);
        --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 8px 22px rgba(0, 0, 0, 0.35);
        --shadow-lg: 0 20px 48px rgba(0, 0, 0, 0.5);
        --shadow-glow: 0 8px 22px rgba(236, 115, 85, 0.34);
    }
}

/* ===== Reset & Base ===== */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    font-size: 16px;
}

body {
    font-family: var(--font-sans);
    background-color: var(--bg-color);
    background-image:
        radial-gradient(900px 520px at 100% -10%, rgba(226, 103, 74, 0.07), transparent 60%),
        radial-gradient(760px 520px at -8% 0%, rgba(201, 80, 47, 0.05), transparent 55%);
    background-attachment: fixed;
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    -webkit-text-size-adjust: 100%;
    -ms-text-size-adjust: 100%;
    touch-action: manipulation;
}

h1, h2, h3, h4 {
    letter-spacing: -0.02em;
    line-height: 1.25;
}

a {
    color: var(--primary-color);
    text-decoration: none;
}

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

/* ===== Sidebar Navigation ===== */
.sidebar {
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    width: var(--sidebar-width);
    background-color: var(--bg-secondary);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding: 1.25rem 0.75rem;
    z-index: 100;
}

.sidebar-top, .sidebar-bottom {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 0.25rem;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 0.7rem;
    padding: 0.4rem 0.85rem 1.25rem;
    font-weight: 800;
    font-size: 1.15rem;
    letter-spacing: -0.02em;
    color: var(--text-primary);
}

.sidebar-brand i {
    font-size: 1.4rem;
    color: var(--primary-color);
}

.nav-link {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 0.85rem;
    height: 44px;
    padding: 0 0.85rem;
    border-radius: var(--border-radius);
    color: var(--text-secondary);
    font-weight: 500;
    font-size: 0.95rem;
    transition: all 0.18s ease;
    text-decoration: none;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}

.nav-link:hover,
.nav-link:focus {
    background-color: var(--bg-elevated);
    color: var(--text-primary);
}

.nav-link.active {
    background: var(--accent-gradient);
    color: #fff;
    box-shadow: var(--shadow-glow);
}

.nav-link i {
    font-size: 1.2rem;
    width: 1.4rem;
    text-align: center;
    flex-shrink: 0;
}

/* ===== Main Content ===== */
main {
    min-height: 100vh;
    padding: 2rem;
}

main.with-sidebar {
    margin-left: var(--sidebar-width);
    padding: 2rem 3rem;
}

/* ===== Flash Messages ===== */
.flash-messages {
    position: fixed;
    top: 1rem;
    right: 1rem;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    max-width: 400px;
}

.flash-message {
    padding: 1rem 2.5rem 1rem 1rem;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-lg);
    position: relative;
    animation: slideIn 0.3s ease;
}

@keyframes slideIn {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

.flash-success { background-color: var(--success-color); color: white; }
.flash-error { background-color: var(--error-color); color: white; }
.flash-warning { background-color: var(--warning-color); color: white; }
.flash-info { background-color: var(--info-color); color: white; }

.flash-close {
    position: absolute;
    right: 0.5rem;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: white;
    font-size: 1.25rem;
    cursor: pointer;
    opacity: 0.7;
    padding: 0.25rem 0.5rem;
}

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

/* ===== Buttons ===== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: var(--border-radius);
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    min-height: 44px; /* Minimum touch target size */
    text-decoration: none;
    line-height: 1.4;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
}

.btn:focus {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
}

.btn-primary {
    background: var(--accent-gradient);
    color: white;
    box-shadow: var(--shadow);
}

.btn-primary:hover,
.btn-primary:focus {
    color: white;
    transform: translateY(-1px);
    box-shadow: var(--shadow-glow);
}

.btn-primary:active {
    transform: translateY(0);
}

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

.btn-secondary:hover,
.btn-secondary:focus {
    background-color: var(--secondary-hover);
    color: var(--text-primary);
}

.btn-block {
    width: 100%;
}

.btn-sm {
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
    min-height: 36px;
}

.btn-icon {
    width: 40px;
    height: 40px;
    min-height: 40px;
    padding: 0;
    border-radius: 50%;
    background-color: var(--bg-color);
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
}

.btn-icon:hover,
.btn-icon:focus {
    background-color: var(--bg-secondary);
    color: var(--text-primary);
}

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

.btn-danger:hover,
.btn-danger:focus {
    background-color: #dc2626;
    color: white;
}

/* ===== Form Elements ===== */
.form-group {
    margin-bottom: 1.25rem;
    flex: 1;
}

.form-group label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
    font-weight: 500;
    color: var(--text-secondary);
    font-size: 0.95rem;
}

.form-group input,
.form-group select,
.form-select {
    width: 100%;
    padding: 0.75rem 1rem;
    background-color: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    color: var(--text-primary);
    font-size: 1rem;
    transition: border-color 0.2s ease;
    min-height: 44px; /* Minimum touch target size */
    line-height: 1.4;
    -webkit-appearance: none; /* Remove iOS styling */
    appearance: none;
}

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

.form-group input::placeholder {
    color: var(--text-muted);
    opacity: 1; /* Ensure placeholder is visible */
}

.form-hint {
    display: block;
    margin-top: 0.5rem;
    font-size: 0.875rem;
    color: var(--text-muted);
    line-height: 1.4;
}

.form-row {
    display: flex;
    gap: 1rem;
    align-items: flex-start;
}

.form-actions {
    margin-top: 2rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--border-color);
}

/* ===== Login Page ===== */
.login-container {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem;
}

.login-card {
    width: 100%;
    max-width: 400px;
    background-color: var(--bg-card);
    border-radius: var(--border-radius-lg);
    padding: 2.5rem;
    box-shadow: var(--shadow-lg);
}

.login-header {
    text-align: center;
    margin-bottom: 2rem;
}

.login-header .logo-icon {
    font-size: 3rem;
    color: var(--primary-color);
    margin-bottom: 1rem;
}

.login-header .logo-image {
    width: 120px;
    height: 120px;
    margin-bottom: 1rem;
    border-radius: 24px;
}

.header-logo {
    width: 80px;
    height: 80px;
    margin-bottom: 0.5rem;
    border-radius: 16px;
}

.login-header h1 {
    font-size: 1.75rem;
    margin-bottom: 0.5rem;
}

.login-header p {
    color: var(--text-secondary);
}

.login-footer {
    margin-top: 1.5rem;
    text-align: center;
}

.login-footer .hint {
    font-size: 0.875rem;
    color: var(--text-muted);
}

/* Remember Me Checkbox in Login */
.remember-me {
    margin-bottom: 1.5rem;
}

.remember-me .checkbox-label {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    cursor: pointer;
    font-weight: 400;
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.remember-me .checkbox-label input[type="checkbox"] {
    width: 18px;
    height: 18px;
    accent-color: var(--primary-color);
    cursor: pointer;
    flex-shrink: 0;
}

/* ===== Main Page ===== */
.main-container {
    max-width: 900px;
    margin: 0 auto;
}

.header {
    text-align: center;
    margin-bottom: 3rem;
}

.header h1 {
    font-size: 2.5rem;
    margin-bottom: 0.5rem;
}

.header h1 i {
    color: var(--primary-color);
}

.header p {
    color: var(--text-secondary);
    font-size: 1.125rem;
}

/* URL Input Section */
.url-input-section {
    margin-bottom: 2rem;
}

.input-group {
    display: flex;
    gap: 1rem;
    align-items: stretch;
}

.url-input {
    flex: 1;
    padding: 1rem 1.25rem;
    background-color: var(--bg-secondary);
    border: 2px solid var(--border-color);
    border-radius: var(--border-radius-lg);
    color: var(--text-primary);
    font-size: 1rem;
    transition: border-color 0.2s ease;
    min-height: 52px;
    line-height: 1.4;
    -webkit-appearance: none; /* Remove iOS styling */
}

.url-input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.1);
}

.url-input::placeholder {
    color: var(--text-muted);
    opacity: 1;
}

.input-hint {
    text-align: center;
    margin-top: 0.75rem;
    font-size: 0.875rem;
    color: var(--text-muted);
    line-height: 1.4;
}

/* Progress Section */
.progress-section {
    background-color: var(--bg-secondary);
    border-radius: var(--border-radius-lg);
    padding: 2rem;
    margin-bottom: 2rem;
}

.progress-section h2 {
    margin-bottom: 1.5rem;
    font-size: 1.25rem;
}

.progress-section h2 i {
    color: var(--primary-color);
    margin-right: 0.5rem;
}

.progress-bar-container {
    position: relative;
    height: 24px;
    background-color: var(--bg-color);
    border-radius: 12px;
    overflow: hidden;
    margin-bottom: 2rem;
}

.progress-bar {
    height: 100%;
    background: linear-gradient(90deg, var(--primary-color), var(--info-color));
    border-radius: 12px;
    transition: width 0.3s ease;
}

.progress-text {
    position: absolute;
    right: 1rem;
    top: 50%;
    transform: translateY(-50%);
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-primary);
}

/* Progress Steps */
.progress-steps {
    display: flex;
    justify-content: space-between;
    margin-bottom: 2rem;
}

.progress-step {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    flex: 1;
    text-align: center;
}

.step-icon {
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: var(--bg-color);
    border: 2px solid var(--border-color);
    border-radius: 50%;
    font-size: 1.25rem;
    color: var(--text-muted);
    transition: all 0.3s ease;
}

.progress-step.active .step-icon {
    border-color: var(--primary-color);
    color: var(--primary-color);
    animation: pulse 1.5s infinite;
}

.progress-step.completed .step-icon {
    border-color: var(--success-color);
    background-color: var(--success-color);
    color: white;
}

.progress-step.error .step-icon {
    border-color: var(--error-color);
    background-color: var(--error-color);
    color: white;
}

@keyframes pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.05); }
}

.step-label {
    font-size: 0.75rem;
    color: var(--text-secondary);
    font-weight: 500;
}

.step-status {
    font-size: 0.7rem;
    color: var(--text-muted);
    min-height: 1rem;
}

/* Log Container */
.log-container {
    background-color: var(--bg-color);
    border-radius: var(--border-radius);
    overflow: hidden;
}

.log-container h3 {
    padding: 0.75rem 1rem;
    background-color: var(--bg-secondary);
    font-size: 0.875rem;
    border-bottom: 1px solid var(--border-color);
}

.log-container h3 i {
    margin-right: 0.5rem;
    color: var(--success-color);
}

.log-output {
    height: 200px;
    overflow-y: auto;
    padding: 1rem;
    font-family: 'Monaco', 'Menlo', monospace;
    font-size: 0.8rem;
    line-height: 1.8;
}

.log-entry {
    padding: 0.25rem 0;
    border-bottom: 1px solid var(--border-color);
}

.log-entry:last-child {
    border-bottom: none;
}

.log-entry .log-time {
    color: var(--text-muted);
    margin-right: 0.5rem;
}

.log-entry.log-info { color: var(--info-color); }
.log-entry.log-success { color: var(--success-color); }
.log-entry.log-error { color: var(--error-color); }
.log-entry.log-warning { color: var(--warning-color); }

/* Result Section */
.result-section {
    background-color: var(--bg-secondary);
    border-radius: var(--border-radius-lg);
    padding: 2rem;
    text-align: center;
}

.result-section h2 {
    color: var(--success-color);
    margin-bottom: 1.5rem;
}

.recipe-preview {
    background-color: var(--bg-color);
    border-radius: var(--border-radius);
    padding: 1.5rem;
    margin-bottom: 1.5rem;
    text-align: left;
    max-height: 400px;
    overflow-y: auto;
}

.recipe-preview h3 {
    color: var(--primary-color);
    margin-bottom: 1rem;
}

/* ===== Settings Page ===== */
.settings-container {
    max-width: 800px;
    margin: 0 auto;
}

.settings-header {
    margin-bottom: 2rem;
}

.settings-header h1 {
    font-size: 2rem;
    margin-bottom: 0.5rem;
}

.settings-header h1 i {
    color: var(--primary-color);
}

.settings-header p {
    color: var(--text-secondary);
}

.settings-section {
    background-color: var(--bg-secondary);
    border-radius: var(--border-radius-lg);
    padding: 1.5rem;
    margin-bottom: 1.5rem;
}

.settings-section h2 {
    font-size: 1.125rem;
    margin-bottom: 1.25rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid var(--border-color);
}

.settings-section h2 i {
    color: var(--primary-color);
    margin-right: 0.5rem;
}

.section-description {
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin-bottom: 1rem;
}

/* Alert boxes */
.alert {
    padding: 1rem;
    border-radius: var(--border-radius);
    margin-top: 1rem;
    font-size: 0.9rem;
    line-height: 1.5;
}

.alert-info {
    background-color: rgba(59, 130, 246, 0.15);
    border: 1px solid rgba(59, 130, 246, 0.3);
    color: var(--text-primary);
}

.alert-info i {
    color: var(--info-color);
    margin-right: 0.5rem;
}

.alert code {
    background-color: rgba(0, 0, 0, 0.3);
    padding: 0.15rem 0.4rem;
    border-radius: 4px;
    font-family: monospace;
    font-size: 0.85em;
}

/* Cookies upload container */
.cookies-upload-container {
    display: flex;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
}

.cookies-status {
    color: var(--text-secondary);
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.password-section {
    margin-top: 3rem;
}

/* ===== Checkbox Styles ===== */
.checkbox-label {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    cursor: pointer;
    padding: 0.5rem 0;
}

.checkbox-label input[type="checkbox"] {
    width: 20px;
    height: 20px;
    accent-color: var(--primary-color);
    cursor: pointer;
}

.checkbox-text {
    font-weight: 500;
    color: var(--text-primary);
}

/* ===== Preview Modal ===== */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.75);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 2rem;
    overflow-y: auto;
}

.modal-container {
    background-color: var(--bg-secondary);
    border-radius: var(--border-radius-lg);
    max-width: 800px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: var(--shadow-lg);
    animation: modalSlideIn 0.3s ease;
}

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

.modal-header {
    padding: 1.5rem 2rem;
    border-bottom: 1px solid var(--border-color);
}

.modal-header h2 {
    margin-bottom: 0.25rem;
    color: var(--primary-color);
}

.modal-header h2 i {
    margin-right: 0.5rem;
}

.modal-subtitle {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.modal-subtitle span {
    color: var(--primary-color);
    font-weight: 600;
    text-transform: capitalize;
}

.modal-body {
    padding: 2rem;
}

.preview-image-container {
    margin-bottom: 1.5rem;
    text-align: center;
}

.preview-image-container img {
    max-width: 100%;
    max-height: 300px;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow);
}

.preview-content h3 {
    color: var(--text-primary);
    font-size: 1.5rem;
    margin-bottom: 0.75rem;
}

.preview-content > p {
    color: var(--text-secondary);
    margin-bottom: 1.5rem;
    line-height: 1.6;
}

.preview-section {
    background-color: var(--bg-color);
    border-radius: var(--border-radius);
    padding: 1.25rem;
    margin-bottom: 1rem;
}

.preview-section h4 {
    color: var(--primary-color);
    margin-bottom: 1rem;
    font-size: 1rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.preview-section ul,
.preview-section ol {
    margin-left: 1.25rem;
    color: var(--text-secondary);
}

.preview-section li {
    margin-bottom: 0.5rem;
    line-height: 1.5;
}

.modal-footer {
    padding: 1.25rem 2rem;
    border-top: 1px solid var(--border-color);
    display: flex;
    gap: 1rem;
    justify-content: flex-end;
}

/* ===== Image Selection Grid ===== */
.preview-image-section {
    margin-bottom: 1.5rem;
}

.preview-image-section h4 {
    color: var(--primary-color);
    margin-bottom: 0.5rem;
    font-size: 1rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.image-selection-hint {
    color: var(--text-muted);
    font-size: 0.85rem;
    margin-bottom: 1rem;
}

.image-selection-hint i {
    color: var(--warning-color);
}

.image-candidates-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
    gap: 0.75rem;
    margin-bottom: 1.5rem;
    padding: 1rem;
    background-color: var(--bg-color);
    border-radius: var(--border-radius);
}

.image-candidate {
    position: relative;
    border-radius: var(--border-radius);
    overflow: hidden;
    cursor: pointer;
    border: 3px solid transparent;
    transition: all 0.2s ease;
    aspect-ratio: 1;
}

.image-candidate:hover {
    border-color: var(--text-muted);
    transform: scale(1.02);
}

.image-candidate.selected {
    border-color: var(--success-color);
    box-shadow: 0 0 0 2px rgba(34, 197, 94, 0.3);
}

.image-candidate.is-best .ai-badge {
    display: block;
}

.image-candidate img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.ai-badge {
    position: absolute;
    top: 0.25rem;
    right: 0.25rem;
    background-color: var(--warning-color);
    color: white;
    font-size: 0.65rem;
    padding: 0.15rem 0.4rem;
    border-radius: 4px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 0.2rem;
}

.ai-badge i {
    font-size: 0.6rem;
}

.preview-image-container {
    margin-bottom: 1rem;
    text-align: center;
    background-color: var(--bg-color);
    padding: 1rem;
    border-radius: var(--border-radius);
}

.preview-image-container img {
    max-width: 100%;
    max-height: 250px;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow);
}

/* ===== Responsive Design ===== */

/* Tablet styles (768px to 1024px) */
@media (max-width: 1024px) and (min-width: 769px) {
    .main-container {
        max-width: 700px;
    }
    
    .settings-container {
        max-width: 650px;
    }
    
    .form-row {
        gap: 0.75rem;
    }
    
    .image-candidates-grid {
        grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
    }
    
    .modal-container {
        max-width: 650px;
    }
}

/* Mobile styles (up to 768px) */
@media (max-width: 768px) {
    /* ===== Layout adjustments ===== */
    .sidebar {
        position: fixed;
        width: 100%;
        height: 60px;
        flex-direction: row;
        bottom: 0;
        left: 0;
        right: 0;
        top: auto;
        padding: 0.5rem 1rem;
        padding-bottom: calc(0.5rem + env(safe-area-inset-bottom, 0px));
        justify-content: space-evenly;
        gap: 0;
        border-right: none;
        border-top: 1px solid var(--border-color);
        z-index: 1000;
    }

    .sidebar-top, .sidebar-bottom {
        flex-direction: row;
        gap: 0;
        justify-content: space-evenly;
    }
    .sidebar-top { flex: 5 1 0; }
    .sidebar-bottom { flex: 2 1 0; }
    
    .sidebar {
        padding: 0.5rem 1rem;
        padding-bottom: calc(0.5rem + env(safe-area-inset-bottom, 0px));
    }

    .sidebar-brand,
    .nav-label {
        display: none;
    }

    /* Items share the bar instead of claiming a fixed 48px each, so adding a
       nav destination can't overflow a narrow phone. */
    .nav-link {
        flex: 1 1 0;
        width: auto;
        min-width: 0;
        max-width: 56px;
        height: 46px;
        padding: 0;
        gap: 0;
        justify-content: center;
        border-radius: var(--border-radius-lg);
    }

    .nav-link.active {
        box-shadow: none;
    }

    .nav-link i {
        font-size: 1.3rem;
        width: auto;
    }
    
    main.with-sidebar {
        margin-left: 0;
        margin-bottom: calc(70px + env(safe-area-inset-bottom, 0px));
        padding: 1rem;
        /* clears the fixed settings gear so page titles don't run under it */
        padding-top: calc(1rem + 44px + env(safe-area-inset-top, 0px));
        padding-bottom: calc(1rem + 70px + env(safe-area-inset-bottom, 0px));
    }
    
    main {
        padding: 1rem;
    }
    
    /* ===== Typography adjustments ===== */
    .header h1 {
        font-size: 1.75rem;
        margin-bottom: 0.75rem;
    }
    
    .header p {
        font-size: 1rem;
    }
    
    .settings-header h1 {
        font-size: 1.75rem;
    }
    
    /* ===== Form improvements ===== */
    .input-group {
        flex-direction: column;
        gap: 0.75rem;
    }
    
    .form-row {
        flex-direction: column;
        gap: 1rem;
    }
    
    .url-input {
        padding: 1rem;
        font-size: 1rem;
        border-radius: var(--border-radius-lg);
    }
    
    .btn {
        padding: 0.875rem 1.25rem;
        font-size: 1rem;
        min-height: 48px;
        border-radius: var(--border-radius-lg);
    }
    
    .btn-icon {
        width: 44px;
        height: 44px;
        min-height: 44px;
    }
    
    /* ===== Progress and steps ===== */
    .progress-steps {
        flex-wrap: wrap;
        gap: 0.75rem 1rem;
        margin-bottom: 1.5rem;
    }
    
    .progress-step {
        min-width: calc(25% - 0.75rem);
        flex: 1;
    }
    
    .step-icon {
        width: 40px;
        height: 40px;
        font-size: 1.1rem;
    }
    
    .step-label {
        font-size: 0.7rem;
    }
    
    .step-status {
        font-size: 0.65rem;
    }
    
    /* ===== Modal improvements ===== */
    .modal-overlay {
        padding: 0.5rem;
        align-items: flex-end;
    }
    
    .modal-container {
        max-height: 95vh;
        margin-bottom: calc(env(safe-area-inset-bottom, 0px));
        border-radius: var(--border-radius-lg) var(--border-radius-lg) 0 0;
    }
    
    .modal-header,
    .modal-body,
    .modal-footer {
        padding: 1rem;
    }
    
    .modal-footer {
        flex-direction: column-reverse;
        gap: 0.75rem;
    }
    
    .modal-footer .btn {
        width: 100%;
        order: 1;
    }
    
    .modal-footer .btn-primary {
        order: 0;
    }
    
    /* ===== Image selection improvements ===== */
    .image-candidates-grid {
        grid-template-columns: repeat(auto-fill, minmax(70px, 1fr));
        gap: 0.5rem;
        padding: 0.75rem;
    }
    
    .image-candidate {
        border-width: 2px;
        border-radius: var(--border-radius);
    }
    
    .preview-image-container img {
        max-height: 200px;
        border-radius: var(--border-radius);
    }
    
    /* ===== Flash messages ===== */
    .flash-messages {
        top: 0.5rem;
        right: 0.5rem;
        left: 0.5rem;
        max-width: none;
    }
    
    .flash-message {
        padding: 0.75rem 2rem 0.75rem 0.75rem;
        font-size: 0.9rem;
    }
}

/* Small mobile styles (up to 480px) */
@media (max-width: 480px) {
    /* ===== Extra small adjustments ===== */
    .main-container,
    .settings-container {
        padding: 0;
    }
    
    .header {
        margin-bottom: 2rem;
    }
    
    .header h1 {
        font-size: 1.5rem;
    }
    
    .url-input-section {
        margin-bottom: 1.5rem;
    }
    
    .progress-steps {
        gap: 0.5rem;
    }
    
    .progress-step {
        min-width: calc(50% - 0.25rem);
    }
    
    .step-icon {
        width: 36px;
        height: 36px;
        font-size: 1rem;
    }
    
    .step-label {
        font-size: 0.65rem;
    }
    
    /* ===== Settings specific ===== */
    .settings-section {
        padding: 1rem;
        margin-bottom: 1rem;
        border-radius: var(--border-radius);
    }
    
    .settings-section h2 {
        font-size: 1rem;
        margin-bottom: 1rem;
    }
    
    .form-group label {
        font-size: 0.9rem;
        margin-bottom: 0.4rem;
    }
    
    .form-group input,
    .form-group select {
        padding: 0.75rem;
        font-size: 1rem;
    }
    
    .form-hint {
        font-size: 0.8rem;
        margin-top: 0.4rem;
    }
    
    /* ===== Modal adjustments ===== */
    .modal-overlay {
        padding: 0;
        align-items: stretch;
    }
    
    .modal-container {
        max-height: 100vh;
        height: 100vh;
        border-radius: 0;
        margin: 0;
    }
    
    .modal-header {
        position: sticky;
        top: 0;
        background-color: var(--bg-secondary);
        z-index: 10;
        border-bottom: 1px solid var(--border-color);
    }
    
    .modal-body {
        flex: 1;
        overflow-y: auto;
        padding-bottom: 2rem;
    }
    
    .modal-footer {
        position: sticky;
        bottom: 0;
        background-color: var(--bg-secondary);
        border-top: 1px solid var(--border-color);
        padding-bottom: calc(1rem + env(safe-area-inset-bottom, 0px));
    }
    
    /* ===== Image grid further adjustments ===== */
    .image-candidates-grid {
        grid-template-columns: repeat(auto-fill, minmax(60px, 1fr));
        gap: 0.4rem;
        padding: 0.5rem;
    }
    
    .preview-image-container img {
        max-height: 160px;
    }
}

/* ===== History page responsive ===== */
@media (max-width: 768px) {
    .history-controls {
        flex-direction: column;
        gap: 0.75rem;
    }
    
    .search-box,
    .filter-box {
        min-width: 100%;
    }
    
    .history-stats {
        flex-direction: column;
        gap: 0.75rem;
        align-items: flex-start;
    }
    
    .bulk-actions {
        margin-left: 0;
        padding-left: 0;
        border-left: none;
        flex-wrap: wrap;
        gap: 0.5rem;
    }
    
    .bulk-actions .btn-sm {
        flex: 1;
        min-width: 100px;
        font-size: 0.8rem;
        padding: 0.5rem 0.75rem;
    }
    
    .history-item {
        flex-direction: column;
        align-items: stretch;
        position: relative;
        padding: 1rem;
        gap: 0.75rem;
    }
    
    .history-checkbox {
        position: absolute;
        top: 0.75rem;
        right: 0.75rem;
        z-index: 5;
    }
    
    .history-thumbnail {
        width: 100%;
        height: 140px;
        margin-bottom: 0.5rem;
    }
    
    .history-actions {
        justify-content: flex-start;
        flex-wrap: wrap;
        gap: 0.5rem;
        margin-top: 0.5rem;
    }
    
    .history-actions .btn-icon {
        flex: 0 0 auto;
    }
    
    .job-steps {
        gap: 0.5rem;
        margin-bottom: 0.75rem;
    }
    
    .job-step {
        width: 32px;
        height: 32px;
        font-size: 0.8rem;
    }
    
    .job-header {
        flex-direction: column;
        align-items: stretch;
        gap: 0.75rem;
    }
    
    .job-info {
        order: 1;
    }
    
    .job-header .btn-icon {
        order: 0;
        align-self: flex-end;
        position: absolute;
        top: 0.75rem;
        right: 0.75rem;
    }
}

/* ===== Login page responsive ===== */
@media (max-width: 768px) {
    .login-container {
        padding: 1rem;
        align-items: stretch;
    }
    
    .login-card {
        max-width: none;
        width: 100%;
        padding: 2rem 1.5rem;
        margin: auto 0;
    }
    
    .logo-image {
        width: 80px;
        height: 80px;
        margin-bottom: 0.75rem;
    }
    
    .login-header h1 {
        font-size: 1.5rem;
        margin-bottom: 0.5rem;
    }
    
    .login-header p {
        font-size: 0.9rem;
    }
    
    .form-group {
        margin-bottom: 1.5rem;
    }
    
    .form-group label {
        font-size: 0.9rem;
    }
    
    .form-group input {
        padding: 1rem;
        font-size: 1rem;
    }
    
    .remember-me {
        margin-bottom: 2rem;
    }
    
    .login-footer {
        margin-top: 2rem;
    }
    
    .login-footer .hint {
        font-size: 0.8rem;
    }
}

@media (max-width: 480px) {
    .login-container {
        padding: 0.5rem;
    }
    
    .login-card {
        padding: 1.5rem 1rem;
        border-radius: var(--border-radius);
    }
    
    .logo-image {
        width: 64px;
        height: 64px;
    }
    
    .login-header h1 {
        font-size: 1.25rem;
    }
}

/* ===== Job Cards ===== */
.jobs-section {
    margin-bottom: 2rem;
}

.jobs-section h2 {
    margin-bottom: 1rem;
    font-size: 1.25rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.jobs-section h2 i {
    color: var(--primary-color);
}

.job-count {
    color: var(--text-muted);
    font-weight: 400;
    font-size: 1rem;
}

.jobs-list {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.job-card {
    background-color: var(--bg-secondary);
    border-radius: var(--border-radius-lg);
    padding: 1.25rem;
    border: 1px solid var(--border-color);
    transition: all 0.3s ease;
}

.job-card.processing {
    border-color: var(--primary-color);
}

.job-card.completed {
    border-color: var(--success-color);
    opacity: 0.8;
}

.job-card.error {
    border-color: var(--error-color);
}

.job-card.fade-out {
    opacity: 0;
    transform: translateX(20px);
}

.job-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 1rem;
}

.job-info {
    flex: 1;
    min-width: 0;
}

.job-title {
    font-size: 1rem;
    margin-bottom: 0.25rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.job-url {
    color: var(--text-muted);
    font-size: 0.8rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.job-progress {
    margin-bottom: 0.75rem;
}

.job-progress .progress-bar-container {
    height: 8px;
    margin-bottom: 0;
}

.job-steps {
    display: flex;
    justify-content: space-between;
    margin-bottom: 0.75rem;
}

.job-step {
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: var(--bg-color);
    border: 2px solid var(--border-color);
    border-radius: 50%;
    font-size: 0.75rem;
    color: var(--text-muted);
    transition: all 0.3s ease;
}

.job-step.active {
    border-color: var(--primary-color);
    color: var(--primary-color);
}

.job-step.completed {
    border-color: var(--success-color);
    background-color: var(--success-color);
    color: white;
}

.job-step.error {
    border-color: var(--error-color);
    background-color: var(--error-color);
    color: white;
}

.job-message {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.job-message .message-text {
    display: inline-block;
}



/* ===== Completed Cards ===== */
.completed-recipes {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    margin-bottom: 1.5rem;
}

.completed-card {
    display: flex;
    align-items: center;
    gap: 1rem;
    background-color: var(--bg-color);
    border-radius: var(--border-radius);
    padding: 1rem;
}

.completed-icon {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    font-size: 1.25rem;
}

.completed-icon.success {
    background-color: rgba(34, 197, 94, 0.2);
    color: var(--success-color);
}

.completed-icon.failed {
    background-color: rgba(239, 68, 68, 0.2);
    color: var(--error-color);
}

.completed-info {
    flex: 1;
    min-width: 0;
}

.completed-title {
    font-size: 0.95rem;
    margin-bottom: 0.25rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.completed-message {
    color: var(--text-muted);
    font-size: 0.8rem;
}



/* ===== History Page ===== */
.history-controls {
    display: flex;
    gap: 1rem;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
}

.search-box {
    flex: 1;
    min-width: 200px;
    position: relative;
}

.search-box i {
    position: absolute;
    left: 1rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
}

.search-input {
    width: 100%;
    padding: 0.75rem 1rem 0.75rem 2.5rem;
    background-color: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    color: var(--text-primary);
    font-size: 0.95rem;
}

.search-input:focus {
    outline: none;
    border-color: var(--primary-color);
}

.filter-box {
    min-width: 150px;
}

.filter-select {
    width: 100%;
    padding: 0.75rem 1rem;
    background-color: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    color: var(--text-primary);
    font-size: 0.95rem;
    cursor: pointer;
}

.history-stats {
    margin-bottom: 1rem;
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.stat-item {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

.history-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    min-height: 200px;
}

.loading-spinner {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 3rem;
    color: var(--text-muted);
    gap: 1rem;
}

.loading-spinner i {
    font-size: 2rem;
    color: var(--primary-color);
}

.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 3rem;
    color: var(--text-muted);
    gap: 1rem;
}

.empty-state i {
    font-size: 3rem;
}

.history-item {
    display: flex;
    gap: 1rem;
    background-color: var(--bg-card);
    border-radius: var(--border-radius-lg);
    padding: 0.85rem;
    cursor: pointer;
    transition: transform 0.18s ease, box-shadow 0.18s ease;
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow);
}

.history-item:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.history-thumbnail {
    width: 104px;
    height: 104px;
    flex-shrink: 0;
    border-radius: var(--border-radius);
    overflow: hidden;
    background-color: var(--bg-elevated);
}

.history-thumbnail img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.no-thumbnail {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    font-size: 1.5rem;
}

.history-info {
    flex: 1;
    min-width: 0;
}

.history-title {
    font-size: 1rem;
    margin-bottom: 0.25rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.history-url {
    color: var(--text-muted);
    font-size: 0.8rem;
    margin-bottom: 0.5rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.history-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem 1rem;
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.history-status {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
}

.history-status.success {
    color: var(--success-color);
}

.history-status.failed {
    color: var(--error-color);
}

.history-error {
    margin-top: 0.5rem;
    font-size: 0.8rem;
    color: var(--error-color);
    background-color: rgba(239, 68, 68, 0.1);
    padding: 0.5rem;
    border-radius: var(--border-radius);
}

.history-actions {
    display: flex;
    gap: 0.5rem;
    align-items: flex-start;
}

.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 1rem;
    margin-top: 2rem;
}

#page-info {
    color: var(--text-secondary);
}

/* ===== Recipe Detail Modal ===== */
.modal-close {
    position: absolute;
    right: 1rem;
    top: 1rem;
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 1.5rem;
    cursor: pointer;
    padding: 0.25rem 0.5rem;
}

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

.modal-header {
    position: relative;
}

.modal-small {
    max-width: 400px;
}

.recipe-detail-image {
    text-align: center;
    margin-bottom: 1.5rem;
}

.recipe-detail-image img {
    max-width: 100%;
    max-height: 250px;
    border-radius: var(--border-radius);
}

.recipe-detail-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    margin-bottom: 1.5rem;
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.recipe-detail-meta p {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.recipe-detail-meta i {
    color: var(--primary-color);
}

.recipe-section {
    background-color: var(--bg-color);
    border-radius: var(--border-radius);
    padding: 1.25rem;
    margin-bottom: 1rem;
}

.recipe-section h4 {
    color: var(--primary-color);
    margin-bottom: 1rem;
    font-size: 1rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.recipe-section ul,
.recipe-section ol {
    margin-left: 1.25rem;
    color: var(--text-secondary);
}

.recipe-section li {
    margin-bottom: 0.5rem;
    line-height: 1.5;
}

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

/* ===== Reupload Dropdown ===== */
.reupload-dropdown {
    position: relative;
    display: inline-block;
}

.reupload-menu {
    position: absolute;
    bottom: 100%;
    right: 0;
    background-color: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-lg);
    display: none;
    min-width: 150px;
    margin-bottom: 0.5rem;
    z-index: 10;
}

.reupload-menu.show {
    display: block;
}

.reupload-option {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    width: 100%;
    padding: 0.75rem 1rem;
    background: none;
    border: none;
    color: var(--text-primary);
    cursor: pointer;
    font-size: 0.95rem;
    text-align: left;
}

.reupload-option:hover {
    background-color: var(--bg-color);
}

.reupload-option:first-child {
    border-radius: var(--border-radius) var(--border-radius) 0 0;
}

.reupload-option:last-child {
    border-radius: 0 0 var(--border-radius) var(--border-radius);
}

/* ===== History Page Responsive ===== */
@media (max-width: 768px) {
    .history-controls {
        flex-direction: column;
    }
    
    .history-item {
        flex-direction: column;
    }
    
    .history-thumbnail {
        width: 100%;
        height: 150px;
    }
    
    .history-actions {
        justify-content: flex-end;
    }
    
    .job-steps {
        gap: 0.25rem;
    }
    
    .job-step {
        width: 24px;
        height: 24px;
        font-size: 0.65rem;
    }
}

/* ===== Export/Import Settings ===== */
.section-description {
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin-bottom: 1rem;
}

.settings-section .btn {
    margin-right: 0.5rem;
}

/* File input label styled as button */
.settings-section label.btn {
    display: inline-flex;
    cursor: pointer;
}

/* Dual Export Badge */
.dual-export-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    background-color: var(--info-color);
    color: white;
    font-size: 0.75rem;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    font-weight: 500;
}

.dual-export-badge i {
    font-size: 0.7rem;
}

/* Export target display in preview */
.export-targets {
    display: flex;
    gap: 0.5rem;
    margin-top: 0.5rem;
}

.export-target-tag {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    background-color: var(--bg-color);
    color: var(--text-secondary);
    font-size: 0.8rem;
    padding: 0.35rem 0.75rem;
    border-radius: 4px;
    border: 1px solid var(--border-color);
}

.export-target-tag.active {
    background-color: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
}

.export-target-tag i {
    font-size: 0.75rem;
}

/* ===== History Page - New Status Styles ===== */
.history-item.cancelled {
    border-left: 3px solid var(--warning-color);
    opacity: 0.8;
}

.history-item.pending {
    border-left: 3px solid var(--text-muted);
}

.history-item.processing {
    border-left: 3px solid var(--primary-color);
}

.history-item.preview {
    border-left: 3px solid var(--warning-color);
    animation: pulse-border 2s infinite;
}

@keyframes pulse-border {
    0%, 100% { border-left-color: var(--warning-color); }
    50% { border-left-color: var(--primary-color); }
}

.history-status.cancelled {
    color: var(--warning-color);
}

.history-status.pending {
    color: var(--text-muted);
}

.history-status.processing {
    color: var(--primary-color);
}

.history-status.preview {
    color: var(--warning-color);
}

.history-progress {
    font-weight: 600;
    color: var(--primary-color);
}

.history-stage {
    margin-top: 0.5rem;
    font-size: 0.8rem;
    color: var(--text-secondary);
    font-style: italic;
}

/* ===== Checkbox Styles for History Items ===== */
.history-checkbox {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.history-checkbox .item-checkbox {
    width: 20px;
    height: 20px;
    accent-color: var(--primary-color);
    cursor: pointer;
}

.history-item {
    display: flex;
    gap: 1rem;
    background-color: var(--bg-secondary);
    border-radius: var(--border-radius-lg);
    padding: 1rem;
    cursor: pointer;
    transition: all 0.2s ease;
    border: 1px solid var(--border-color);
    align-items: center;
}

/* ===== Bulk Actions Styles ===== */
.bulk-actions {
    display: inline-flex;
    align-items: center;
    gap: 0.75rem;
    margin-left: 1.5rem;
    padding-left: 1.5rem;
    border-left: 1px solid var(--border-color);
}

.btn-sm {
    padding: 0.4rem 0.75rem;
    font-size: 0.85rem;
}

.bulk-actions #selected-count {
    font-weight: 600;
    color: var(--primary-color);
}

/* ===== Cancel Button Style ===== */
.btn-icon.cancel-btn {
    color: var(--warning-color);
}

.btn-icon.cancel-btn:hover {
    background-color: var(--warning-color);
    color: white;
    border-color: var(--warning-color);
}

/* ===== History Stats Responsive ===== */
@media (max-width: 768px) {
    .history-stats {
        display: flex;
        flex-direction: column;
        gap: 0.75rem;
    }
    
    .bulk-actions {
        margin-left: 0;
        padding-left: 0;
        border-left: none;
        flex-wrap: wrap;
    }
    
    .bulk-actions .btn-sm {
        flex: 1;
        min-width: 100px;
    }
    
    .history-checkbox {
        position: absolute;
        top: 0.5rem;
        left: 0.5rem;
    }
    
    .history-item {
        position: relative;
        padding-left: 2.5rem;
    }
}

/* ===== Premium recipe cards (History feed) ===== */
@keyframes cardIn {
    from { opacity: 0; transform: translateY(14px); }
    to   { opacity: 1; transform: translateY(0); }
}

.history-item {
    align-items: center;
    gap: 1rem;
    padding: 0.8rem;
    background-color: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-lg);
    box-shadow: var(--shadow);
    animation: cardIn 0.5s cubic-bezier(0.22, 1, 0.36, 1) both;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}
.history-item:hover { transform: translateY(-3px); box-shadow: var(--shadow-lg); }
.history-item:active { transform: translateY(-1px); }

.history-thumbnail {
    width: 112px;
    height: 112px;
    flex-shrink: 0;
    border-radius: var(--border-radius);
    overflow: hidden;
    position: relative;
    background: var(--bg-elevated);
}
.history-thumbnail img { width: 100%; height: 100%; object-fit: cover; transition: transform 0.4s ease; }
.history-item:hover .history-thumbnail img { transform: scale(1.06); }
.no-thumbnail { width: 100%; height: 100%; display: flex; align-items: center; justify-content: center; color: var(--text-muted); font-size: 1.6rem; }

.thumb-platform {
    position: absolute; bottom: 6px; left: 6px;
    width: 22px; height: 22px;
    display: flex; align-items: center; justify-content: center;
    background: rgba(12, 18, 30, 0.6); color: #fff;
    border-radius: 50%; font-size: 0.7rem;
}

.history-title { font-size: 1.05rem; font-weight: 700; letter-spacing: -0.01em; margin-bottom: 0.1rem; }
.history-creator { color: var(--text-secondary); font-size: 0.82rem; font-weight: 500; margin-bottom: 0.5rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.history-stats { display: flex; flex-wrap: wrap; gap: 0.4rem; margin-bottom: 0.5rem; }
.history-stats .stat { display: inline-flex; align-items: center; gap: 0.35rem; background: var(--bg-elevated); color: var(--text-secondary); border-radius: 999px; padding: 0.22rem 0.62rem; font-size: 0.78rem; font-weight: 600; }
.history-stats .stat i { color: var(--primary-color); font-size: 0.75rem; }

.history-actions { display: flex; gap: 0.4rem; align-items: center; }
.history-actions .btn-icon { transition: transform 0.15s ease, background 0.15s ease, color 0.15s ease, border-color 0.15s ease; }
.history-actions .btn-icon:hover { transform: translateY(-1px); }
.history-actions .btn-icon:active { transform: scale(0.9); }
.history-actions .view-recipe-btn:hover { background: var(--primary-soft); color: var(--primary-color); border-color: transparent; }
.history-actions .flame-btn:hover { background: #fff3ec; color: #f97316; border-color: #fed7aa; }
.history-actions .delete-quick-btn:hover { background: #fef2f2; color: var(--error-color); border-color: #fecaca; }
.history-checkbox { align-self: flex-start; padding-top: 2px; }

@media (prefers-reduced-motion: reduce) {
    .history-item { animation: none; }
    .history-item:hover, .history-item:active { transform: none; }
    .history-thumbnail img, .history-item:hover .history-thumbnail img { transition: none; transform: none; }
}

/* theme toggle button (matches nav-link) */
.nav-link.theme-toggle { background: none; border: none; width: 100%; cursor: pointer; font-family: inherit; text-align: left; }

/* ===== Recipe detail (sheet) ===== */
.recipe-detail-modal { align-items: stretch; justify-content: center; padding: 0; }
@media (min-width: 560px){ .recipe-detail-modal { align-items: center; padding: 1.5rem; } }
.rd-sheet { background: var(--bg-color); width: 100%; max-width: 460px; max-height: 100vh; overflow-y: auto;
    box-shadow: var(--shadow-lg); animation: rdUp .34s cubic-bezier(.2,.9,.3,1); scrollbar-width: none; }
.rd-sheet::-webkit-scrollbar { display: none; }
@media (min-width: 560px){ .rd-sheet { max-height: 92vh; border-radius: 24px; } }
@keyframes rdUp { from { transform: translateY(26px); opacity: 0; } to { transform: none; opacity: 1; } }
.rd-hero { position: relative; background: var(--bg-elevated); min-height: 120px; }
.rd-hero img { width: 100%; height: 270px; object-fit: cover; display: block; }
.rd-hero.no-photo { height: 120px; }
.rd-hero-shade { position: absolute; inset: 0; background: linear-gradient(180deg, rgba(0,0,0,.32), transparent 34%); }
.rd-round { position: absolute; top: 14px; width: 40px; height: 40px; border-radius: 50%; border: none;
    background: rgba(255,255,255,.94); color: #171a1d; display: flex; align-items: center; justify-content: center; cursor: pointer; font-size: 1rem; box-shadow: 0 4px 12px rgba(0,0,0,.18); }
.rd-back { left: 14px; }
.rd-body { padding: 18px 20px 30px; }
.rd-body h1 { font-size: 1.5rem; font-weight: 800; letter-spacing: -.02em; line-height: 1.18; color: var(--text-primary); }
.rd-creator { display: flex; align-items: center; gap: 8px; margin-top: 10px; font-size: .85rem; font-weight: 700; color: var(--text-secondary); }
.rd-av { width: 26px; height: 26px; border-radius: 50%; background: var(--accent-gradient); color: #fff; display: flex; align-items: center; justify-content: center; font-size: .72rem; font-weight: 800; flex-shrink: 0; }
.rd-stats { display: flex; gap: 8px; margin: 16px 0; }
.rd-stat { flex: 1; background: var(--bg-card); border: 1px solid var(--border-color); border-radius: 14px; padding: 11px 6px; text-align: center; }
.rd-stat i { color: var(--primary-color); font-size: .95rem; }
.rd-stat .n { font-size: 1rem; font-weight: 800; margin-top: 3px; }
.rd-stat .l { font-size: .62rem; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; color: var(--text-muted); margin-top: 1px; }
.rd-actions { display: flex; gap: 10px; margin-bottom: 6px; flex-wrap: wrap; }
/* min-width keeps a third action from squeezing the labels onto two lines —
   it drops to its own row instead */
.rd-actions .btn { flex: 1 1 auto; min-width: 132px; white-space: nowrap; }
.rd-h { font-size: 1.05rem; font-weight: 800; letter-spacing: -.02em; margin: 20px 0 8px; color: var(--text-primary); }
.rd-ings { list-style: none; padding: 0; margin: 0; }
.rd-ing { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--border-color); cursor: pointer; }
.rd-ing .cb { width: 22px; height: 22px; border-radius: 7px; border: 2px solid var(--border-color); flex-shrink: 0; display: flex; align-items: center; justify-content: center; color: transparent; font-size: .7rem; transition: all .15s ease; }
.rd-ing.checked .cb { background: var(--primary-color); border-color: var(--primary-color); color: #fff; }
.rd-ing .txt { font-size: .9rem; color: var(--text-primary); }
.rd-ing.checked .txt { text-decoration: line-through; color: var(--text-muted); }
.rd-steps { list-style: none; padding: 0; margin: 0; }
.rd-step { display: flex; gap: 13px; padding: 11px 0; }
.rd-step .num { width: 28px; height: 28px; border-radius: 50%; background: var(--primary-color); color: #fff; font-weight: 800; font-size: .8rem; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.rd-step .txt { font-size: .9rem; line-height: 1.5; color: var(--text-primary); padding-top: 3px; }
.rd-secondary { display: flex; gap: 8px; margin-top: 24px; padding-top: 16px; border-top: 1px solid var(--border-color); }
.rd-secondary .btn { flex: 1; }
.rd-del:hover { color: var(--error-color); border-color: var(--error-color); }

/* ===== Mobile polish: chip row + floating add button ===== */
@media (max-width: 768px) {
    .history-item { flex-direction: column; align-items: stretch; position: relative; gap: 9px; padding: 0.75rem; }
    .history-thumbnail { width: 100%; height: 168px; }
    .history-checkbox { position: absolute; top: 13px; left: 13px; z-index: 3; background: rgba(255,255,255,.92); border-radius: 6px; padding: 2px 3px; box-shadow: 0 2px 6px rgba(0,0,0,.14); }
    .history-info { width: 100%; }
    .history-stats { display: flex; flex-flow: row wrap; gap: 6px; }
    .history-stats .stat { display: inline-flex; width: auto; }
    .history-actions { flex-wrap: wrap; gap: 8px; margin-top: 2px; justify-content: flex-start; }
}
.fab-add { display: none; }
@media (max-width: 768px) {
    .fab-add {
        display: flex; position: fixed; right: 18px;
        bottom: calc(80px + env(safe-area-inset-bottom, 0px));
        width: 56px; height: 56px; border-radius: 20px;
        background: var(--accent-gradient); color: #fff;
        align-items: center; justify-content: center; font-size: 1.45rem;
        box-shadow: var(--shadow-glow); z-index: 1001; text-decoration: none;
        transition: transform 0.15s ease;
    }
    .fab-add:active { transform: scale(0.93); }
}

/* ===== Home: recently saved strip ===== */
.recent-section { margin-top: 2.25rem; }
.recent-head { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 0.85rem; }
.recent-head h2 { font-size: 1.15rem; font-weight: 800; letter-spacing: -0.02em; }
.recent-head a { font-size: 0.82rem; font-weight: 700; color: var(--primary-color); }
.recent-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 14px; }
.recent-card { display: block; text-decoration: none; color: inherit; }
.recent-img {
    display: block; position: relative; width: 100%; aspect-ratio: 4 / 3;
    background-size: cover; background-position: center; background-color: var(--bg-elevated);
    border-radius: var(--border-radius-lg); box-shadow: var(--shadow);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}
.recent-card:hover .recent-img { transform: translateY(-3px); box-shadow: var(--shadow-lg); }
.recent-time {
    position: absolute; left: 8px; bottom: 8px; display: inline-flex; align-items: center; gap: 5px;
    background: rgba(12, 14, 18, 0.62); color: #fff; font-size: 0.7rem; font-weight: 700;
    padding: 4px 9px; border-radius: 999px; backdrop-filter: blur(4px);
}
.recent-name {
    display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
    margin-top: 0.55rem; font-size: 0.88rem; font-weight: 700; line-height: 1.3; color: var(--text-primary);
}
.recent-by { display: block; font-size: 0.76rem; font-weight: 600; color: var(--text-secondary); margin-top: 2px; }

/* tuck the multi-select checkbox neatly into the card corner on mobile */
@media (max-width: 768px) {
    .history-checkbox { top: 10px; left: 10px; padding: 3px 4px; border-radius: 8px; }
    .history-checkbox .item-checkbox { width: 17px; height: 17px; display: block; }
}

/* hide the floating add button while any modal/sheet is open */
body:has(.modal-overlay[style*="flex"]) .fab-add { display: none; }

/* Settings ordering: the everyday controls come first, the plumbing last.
   Done with flex order so the markup (and the big settings form) stays put. */
.settings-container { display: flex; flex-direction: column; }
.settings-container > .settings-header { order: 0; }
.settings-container > #appearance-section { order: 1; }
.settings-container > #usage-section { order: 2; }
.settings-container > #household-section { order: 3; }
.settings-container > #invite-section { order: 4; }
.settings-container > #qa-section { order: 5; }
.settings-container > .password-section { order: 6; }
.settings-container > .adv-block { order: 7; }

.adv-block {
    background: var(--bg-card); border: 1px solid var(--border-color);
    border-radius: var(--border-radius-lg); box-shadow: var(--shadow);
    margin-bottom: 1.5rem; overflow: hidden;
}
.adv-summary {
    display: flex; align-items: center; gap: 4px 12px; flex-wrap: wrap;
    padding: 1.15rem 1.35rem; cursor: pointer; list-style: none; user-select: none;
}
.adv-summary::-webkit-details-marker { display: none; }
.adv-title { font-size: 1.05rem; font-weight: 800; color: var(--text-primary); }
.adv-title i { color: var(--text-muted); margin-right: 8px; }
.adv-sub { flex: 1 1 100%; font-size: 0.85rem; color: var(--text-secondary); }
.adv-chevron {
    margin-left: auto; color: var(--text-muted); font-size: 0.85rem;
    transition: transform 0.2s ease;
}
.adv-block[open] .adv-chevron { transform: rotate(180deg); }
.adv-summary:hover .adv-title { color: var(--primary-color); }
/* sections nested in a disclosure shouldn't re-draw the card chrome */
.adv-block .settings-section {
    background: none; border: none; box-shadow: none;
    border-top: 1px solid var(--border-color); border-radius: 0; margin-bottom: 0;
}
.adv-block .form-actions { padding: 1.25rem 1.35rem; border-top: 1px solid var(--border-color); }

.settings-row {
    display: flex; align-items: center; justify-content: space-between; gap: 1rem;
    padding: 14px 0; flex-wrap: wrap;
}
.settings-row + .settings-row { border-top: 1px solid var(--border-color); }
.settings-row strong { display: block; font-size: 0.95rem; color: var(--text-primary); }
.settings-row .form-hint { margin-top: 3px; }
.settings-row .btn { flex-shrink: 0; }
/* the sidebar hides labels on mobile; these buttons need theirs */
.settings-row .nav-label { display: inline !important; }

/* Settings gear — mobile only. The desktop sidebar is vertical and has room
   for everything, so this is hidden there. */
.nav-gear { display: none; }
@media (max-width: 768px) {
    .nav-gear {
        position: fixed; top: calc(10px + env(safe-area-inset-top, 0px)); right: 12px;
        z-index: 900; display: flex; align-items: center; justify-content: center;
        width: 40px; height: 40px; border-radius: 50%;
        background: var(--bg-card); color: var(--text-secondary);
        border: 1px solid var(--border-color); box-shadow: var(--shadow);
        font-size: 1rem; text-decoration: none;
    }
    .nav-gear.active { color: var(--primary-color); border-color: var(--primary-color); }

    /* five destinations only: settings, theme and logout are utilities, not
       places to go, and eight targets crowd a phone-width bar */
    .sidebar .nav-utility,
    .sidebar-bottom { display: none; }
}
body:has(.modal-overlay[style*="flex"]) .nav-gear { display: none; }
/* ...and on roulette, where it would sit on top of the full-width Spin button */
body:has(.rl-wrap) .fab-add { display: none; }

/* ===== Collections ===== */
/* the shared .header is centered; a title + action row needs to read left-to-right */
.col-header {
    display: flex; align-items: center; justify-content: space-between;
    gap: 1rem; text-align: left; margin-bottom: 1.75rem;
}
.col-header > div:first-child { min-width: 0; }
.col-header h1 { font-size: 1.9rem; margin-bottom: 0.15rem; }
.col-header p { font-size: 0.95rem; margin: 0; }
.col-header .btn { flex-shrink: 0; white-space: nowrap; }
.col-detail-actions { display: flex; gap: 0.4rem; flex-shrink: 0; }
.col-back {
    display: inline-flex; align-items: center; gap: 8px; margin-bottom: 0.9rem;
    font-size: 0.85rem; font-weight: 700; color: var(--text-secondary); text-decoration: none;
}
.col-back:hover { color: var(--primary-color); }

.col-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 16px; }
.col-card { display: block; text-decoration: none; color: inherit; }
.col-cover {
    display: grid; position: relative; width: 100%; aspect-ratio: 1 / 1; gap: 2px;
    grid-template-columns: 1fr 1fr; grid-template-rows: 1fr 1fr;
    background: var(--bg-elevated); border-radius: var(--border-radius-lg); overflow: hidden;
    box-shadow: var(--shadow); transition: transform 0.2s ease, box-shadow 0.2s ease;
}
.col-card:hover .col-cover { transform: translateY(-3px); box-shadow: var(--shadow-lg); }
.col-tile {
    display: block; width: 100%; height: 100%; object-fit: cover;
    background-color: var(--bg-elevated);
}
.col-cover-1 .col-tile { grid-column: 1 / 3; grid-row: 1 / 3; }
.col-cover-2 .col-tile { grid-row: 1 / 3; }
.col-cover-3 .col-tile:first-child { grid-row: 1 / 3; }
.col-cover-empty {
    display: flex; align-items: center; justify-content: center;
    color: var(--text-muted); font-size: 1.6rem;
}
.col-name {
    display: flex; align-items: center; gap: 7px; margin-top: 0.6rem;
    font-size: 0.92rem; font-weight: 700; line-height: 1.3; color: var(--text-primary);
}
.col-emoji-badge { font-size: 1rem; flex-shrink: 0; }
.col-count { display: block; font-size: 0.76rem; font-weight: 600; color: var(--text-secondary); margin-top: 2px; }

.col-recipe { position: relative; }
.col-recipe-link { display: block; text-decoration: none; color: inherit; }
.col-noimg { display: flex; align-items: center; justify-content: center; }
.col-remove {
    position: absolute; top: 8px; right: 8px; width: 28px; height: 28px; border: none;
    border-radius: 50%; background: rgba(12, 14, 18, 0.62); color: #fff; font-size: 1.15rem;
    line-height: 1; cursor: pointer; backdrop-filter: blur(4px); opacity: 0; transition: opacity 0.15s ease;
}
.col-recipe:hover .col-remove, .col-remove:focus { opacity: 1; }
.col-remove:hover { background: var(--error-color); }
@media (hover: none) { .col-remove { opacity: 1; } }

.col-empty {
    grid-column: 1 / -1; text-align: center; padding: 3rem 1.5rem; color: var(--text-secondary);
    background: var(--bg-card); border: 1px dashed var(--border-color); border-radius: var(--border-radius-lg);
}
.col-empty i { font-size: 2rem; color: var(--text-muted); margin-bottom: 0.85rem; display: block; }
.col-empty h3 { margin: 0 0 0.35rem; color: var(--text-primary); font-size: 1.05rem; }
.col-empty p { margin: 0 0 1.1rem; font-size: 0.9rem; }

.col-modal { max-width: 420px; }
.col-field-label {
    display: block; font-size: 0.72rem; font-weight: 800; letter-spacing: 0.08em;
    text-transform: uppercase; color: var(--text-muted); margin: 0 0 0.5rem;
}
.col-emoji-row { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 1.15rem; }
.col-emoji {
    width: 38px; height: 38px; font-size: 1.15rem; line-height: 1; cursor: pointer;
    background: var(--bg-elevated); border: 2px solid transparent; border-radius: 11px;
    transition: border-color 0.15s ease, transform 0.15s ease;
}
.col-emoji:hover { transform: translateY(-2px); }
.col-emoji.sel { border-color: var(--primary-color); background: var(--bg-card); }
.col-error { color: var(--error-color); font-size: 0.85rem; font-weight: 600; margin: 0.65rem 0 0; }

/* ===== Import QA queue (Settings) ===== */
.qa-count {
    display: inline-flex; align-items: center; justify-content: center;
    min-width: 24px; height: 24px; padding: 0 7px; margin-left: 6px;
    font-size: 0.78rem; font-weight: 800; color: #fff;
    background: var(--error-color); border-radius: 999px; vertical-align: middle;
}
.qa-list { display: flex; flex-direction: column; gap: 10px; }
.qa-item {
    display: flex; align-items: flex-start; justify-content: space-between; gap: 14px;
    flex-wrap: wrap; padding: 14px;
    background: var(--bg-elevated); border: 1px solid var(--border-color);
    border-radius: var(--border-radius-lg);
}
.qa-item.qa-running { border-color: var(--primary-color); }
.qa-main { flex: 1 1 220px; min-width: 0; }
.qa-name {
    display: block; font-size: 0.95rem; font-weight: 700; color: var(--text-primary);
    text-decoration: none; line-height: 1.3;
}
.qa-name:hover { color: var(--primary-color); }
.qa-note { margin: 5px 0 0; font-size: 0.85rem; color: var(--text-secondary); font-style: italic; }
.qa-note-empty { opacity: 0.6; font-style: normal; }
.qa-hint { margin: 7px 0 0; font-size: 0.8rem; color: var(--primary-color); font-weight: 600; }
.qa-actions { display: flex; gap: 8px; flex-shrink: 0; flex-wrap: wrap; }

/* ===== Recipe roulette ===== */
.rl-header { margin-bottom: 1.5rem; }
.rl-header h1 { font-size: 2rem; }
.rl-filters { display: flex; gap: 0.6rem; justify-content: center; margin-bottom: 1.5rem; flex-wrap: wrap; }
.rl-filters .filter-select { flex: 1 1 150px; max-width: 220px; }

.rl-stage { min-height: 340px; display: flex; align-items: center; justify-content: center; }
.rl-idle { text-align: center; color: var(--text-secondary); }
.rl-dice { font-size: 3.5rem; color: var(--border-color); margin-bottom: 0.85rem; }
.rl-idle p { font-size: 0.95rem; }
.rl-result { width: 100%; }

.rl-spinner { text-align: center; font-size: 3.5rem; color: var(--primary-color); }
.rl-spinner i { display: inline-block; animation: rlTumble 0.65s cubic-bezier(.36,.07,.19,.97) infinite; }
@keyframes rlTumble {
    0%   { transform: rotate(0deg)   scale(1); }
    50%  { transform: rotate(180deg) scale(1.25); }
    100% { transform: rotate(360deg) scale(1); }
}

.rl-card {
    background: var(--bg-card); border: 1px solid var(--border-color);
    border-radius: var(--border-radius-lg); overflow: hidden; box-shadow: var(--shadow-lg);
    animation: rlIn 0.42s cubic-bezier(.21,1.02,.73,1) both;
}
@keyframes rlIn {
    from { opacity: 0; transform: translateY(14px) scale(0.97); }
    to   { opacity: 1; transform: none; }
}
.rl-img {
    display: block; width: 100%; aspect-ratio: 16 / 10;
    background-size: cover; background-position: center; background-color: var(--bg-elevated);
}
.rl-img-none { display: flex; align-items: center; justify-content: center; color: var(--text-muted); font-size: 2.2rem; }
.rl-card-body { padding: 1.15rem; }
.rl-reason {
    display: inline-flex; align-items: center; gap: 6px; font-size: 0.74rem; font-weight: 800;
    letter-spacing: 0.03em; text-transform: uppercase; color: var(--primary-color);
    background: color-mix(in srgb, var(--primary-color) 12%, transparent);
    padding: 4px 10px; border-radius: 999px;
}
.rl-name { font-size: 1.35rem; font-weight: 800; line-height: 1.25; margin: 0.6rem 0 0.55rem; }
.rl-meta { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 1.1rem; }
.rl-chip {
    display: inline-flex; align-items: center; gap: 6px; font-size: 0.78rem; font-weight: 700;
    color: var(--text-secondary); background: var(--bg-elevated); padding: 5px 11px; border-radius: 999px;
}
.rl-stars { display: inline-flex; gap: 2px; font-size: 0.8rem; color: var(--border-color); }
.rl-stars .on { color: #f5a524; }
.rl-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.rl-actions .btn { flex: 1 1 auto; min-width: 132px; white-space: nowrap; }

.rl-spin { width: 100%; margin-top: 1.5rem; font-size: 1.05rem; padding: 0.95rem; }
.rl-pool { text-align: center; font-size: 0.8rem; color: var(--text-muted); margin-top: 0.7rem; }
.rl-empty { text-align: center; color: var(--text-secondary); padding: 2rem 1rem; }
.rl-empty i { font-size: 2rem; color: var(--text-muted); display: block; margin-bottom: 0.8rem; }
.rl-empty h3 { color: var(--text-primary); margin: 0 0 0.3rem; }

/* ===== Import allowance ===== */
.usage-row { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; margin-bottom: 10px; }
.usage-count { font-size: 2rem; font-weight: 800; color: var(--text-primary); line-height: 1; }
.usage-of { font-size: 0.92rem; color: var(--text-secondary); }
.usage-plan {
    margin-left: auto; font-size: 0.7rem; font-weight: 800; letter-spacing: 0.06em;
    text-transform: uppercase; padding: 3px 10px; border-radius: 999px;
    background: var(--bg-elevated); color: var(--text-secondary);
}
.usage-bar { height: 8px; border-radius: 999px; background: var(--bg-elevated); overflow: hidden; }
.usage-fill { height: 100%; background: var(--accent-gradient); border-radius: 999px; transition: width 0.3s ease; }
.usage-fill.full { background: var(--error-color); }

/* ===== Invites ===== */
.inv-items { display: flex; flex-direction: column; gap: 8px; margin-top: 0.9rem; }
.inv-item {
    display: flex; align-items: center; justify-content: space-between; gap: 12px;
    flex-wrap: wrap; padding: 12px 14px;
    background: var(--bg-elevated); border: 1px solid var(--border-color);
    border-radius: var(--border-radius-lg);
}
.inv-item.spent { opacity: 0.6; }
.inv-main { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; min-width: 0; }
.inv-code {
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: 1rem; font-weight: 800; letter-spacing: 0.1em; color: var(--primary-color);
}
.inv-open, .inv-used, .inv-revoked {
    font-size: 0.68rem; font-weight: 800; text-transform: uppercase; letter-spacing: 0.05em;
    padding: 2px 8px; border-radius: 999px;
}
.inv-open { background: color-mix(in srgb, var(--success-color) 16%, transparent); color: var(--success-color); }
.inv-used { background: var(--bg-card); color: var(--text-muted); }
.inv-revoked { background: color-mix(in srgb, var(--error-color) 14%, transparent); color: var(--error-color); }
.inv-note { font-size: 0.85rem; color: var(--text-secondary); }
.inv-actions { display: flex; gap: 6px; flex-shrink: 0; }

.login-alt { margin-top: 1.2rem; text-align: center; font-size: 0.9rem; color: var(--text-secondary); }
.login-alt a { color: var(--primary-color); font-weight: 700; }
.btn-block { width: 100%; }

/* ===== Household ===== */
.hh-card {
    background: var(--bg-elevated); border: 1px solid var(--border-color);
    border-radius: var(--border-radius-lg); padding: 14px 16px; margin-bottom: 0.5rem;
}
.hh-name { font-size: 1.05rem; font-weight: 800; color: var(--text-primary); }
.hh-members { list-style: none; margin: 10px 0 14px; padding: 0; }
.hh-members li {
    padding: 5px 0; font-size: 0.92rem; font-weight: 600; color: var(--text-primary);
}
.hh-you, .hh-owner {
    font-size: 0.68rem; font-weight: 800; text-transform: uppercase; letter-spacing: 0.05em;
    padding: 2px 7px; border-radius: 999px; margin-left: 6px; vertical-align: middle;
}
.hh-you { background: var(--primary-color); color: #fff; }
.hh-owner { background: var(--bg-card); color: var(--text-muted); }
.hh-code-row {
    display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
    padding-top: 12px; border-top: 1px solid var(--border-color);
    font-size: 0.8rem; font-weight: 700; color: var(--text-muted);
    text-transform: uppercase; letter-spacing: 0.06em;
}
.hh-code {
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: 1.15rem; font-weight: 800; letter-spacing: 0.14em;
    color: var(--primary-color); text-transform: none;
}
.hh-join { display: flex; gap: 8px; align-items: center; flex-shrink: 0; }
.hh-code-input {
    width: 116px; padding: 10px 12px; font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: 1rem; font-weight: 700; letter-spacing: 0.1em; text-transform: uppercase;
    color: var(--text-primary); background: var(--bg-card);
    border: 1px solid var(--border-color); border-radius: var(--border-radius);
}
.hh-code-input:focus { outline: none; border-color: var(--primary-color); }
.hh-msg { margin-top: 0.8rem; font-size: 0.88rem; font-weight: 600; color: var(--error-color); }

/* ===== Segmented tabs ===== */
.seg {
    display: flex; gap: 4px; padding: 4px; margin-bottom: 1.4rem;
    background: var(--bg-elevated); border-radius: var(--border-radius-lg);
}
.seg-btn {
    flex: 1; padding: 10px 12px; border: none; cursor: pointer;
    background: transparent; color: var(--text-secondary);
    font-family: inherit; font-size: 0.9rem; font-weight: 700;
    border-radius: calc(var(--border-radius-lg) - 4px);
    transition: background 0.15s ease, color 0.15s ease;
}
.seg-btn.active { background: var(--bg-card); color: var(--text-primary); box-shadow: var(--shadow); }

/* ===== Meal plan ===== */
.plan-head {
    display: flex; align-items: center; justify-content: space-between;
    gap: 12px; margin-bottom: 1.1rem;
}
.plan-nav {
    width: 38px; height: 38px; flex-shrink: 0; border-radius: 50%; cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    background: var(--bg-card); border: 1px solid var(--border-color);
    color: var(--text-secondary);
}
.plan-nav:hover { color: var(--primary-color); border-color: var(--primary-color); }
.plan-range { font-weight: 800; font-size: 1rem; color: var(--text-primary); }

.plan-days { display: flex; flex-direction: column; gap: 10px; }
.plan-day {
    background: var(--bg-card); border: 1px solid var(--border-color);
    border-radius: var(--border-radius-lg); padding: 12px 14px;
}
.plan-day.today { border-color: var(--primary-color); }
.plan-day-head {
    display: flex; align-items: baseline; gap: 8px; margin-bottom: 8px;
}
.plan-day-name { font-size: 0.9rem; font-weight: 800; color: var(--text-primary); }
.plan-day.today .plan-day-name { color: var(--primary-color); }
.plan-day-date { font-size: 0.76rem; font-weight: 600; color: var(--text-muted); }
.plan-empty { margin: 0; font-size: 0.85rem; color: var(--text-muted); }

.plan-meal {
    display: flex; align-items: center; gap: 10px; padding: 7px 0;
    border-top: 1px solid var(--border-color);
}
.plan-day-head + .plan-meal { border-top: none; }
.plan-img {
    width: 38px; height: 38px; flex-shrink: 0; border-radius: 10px;
    background-size: cover; background-position: center; background-color: var(--bg-elevated);
}
.plan-img-none { display: flex; align-items: center; justify-content: center; color: var(--text-muted); font-size: 0.85rem; }
.plan-meal-name {
    flex: 1; min-width: 0; font-size: 0.9rem; font-weight: 600; line-height: 1.3;
    color: var(--text-primary); text-decoration: none;
    display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.plan-meal-name:hover { color: var(--primary-color); }
.plan-meal-time { font-size: 0.75rem; font-weight: 700; color: var(--text-muted); flex-shrink: 0; }
.plan-remove {
    flex-shrink: 0; width: 26px; height: 26px; border-radius: 50%; border: none; cursor: pointer;
    background: none; color: var(--text-muted); font-size: 1.1rem; line-height: 1;
}
.plan-remove:hover { background: var(--bg-elevated); color: var(--error-color); }

.plan-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 1.3rem; }
.plan-actions .btn { flex: 1 1 auto; }
.plan-hint { margin-top: 0.7rem; font-size: 0.8rem; color: var(--text-muted); }

/* day picker inside the recipe sheet */
.rd-plan { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 0.75rem; }
.rd-plan-day {
    flex: 1 1 auto; min-width: 62px; padding: 9px 6px; cursor: pointer;
    background: var(--bg-elevated); border: 1px solid transparent;
    border-radius: var(--border-radius); text-align: center;
    font-family: inherit; font-size: 0.78rem; font-weight: 700; color: var(--text-primary);
}
.rd-plan-day:hover { border-color: var(--primary-color); }
.rd-plan-day.done { background: var(--primary-color); color: #fff; }
.rd-plan-day small { display: block; font-size: 0.68rem; font-weight: 600; opacity: 0.7; }

/* ===== Photo import ===== */
.photo-import { margin-top: 1.25rem; }
.photo-or {
    display: flex; align-items: center; gap: 12px;
    color: var(--text-muted); font-size: 0.8rem; font-weight: 700;
    text-transform: uppercase; letter-spacing: 0.08em; margin-bottom: 1rem;
}
.photo-or::before, .photo-or::after {
    content: ''; flex: 1; height: 1px; background: var(--border-color);
}
.photo-btn { width: 100%; cursor: pointer; }
.photo-btn.is-busy { opacity: 0.6; pointer-events: none; }
.photo-status {
    margin-top: 0.9rem; padding: 12px 14px; border-radius: var(--border-radius);
    font-size: 0.9rem; line-height: 1.5;
}
.photo-status.working { background: var(--bg-elevated); color: var(--text-secondary); }
.photo-status.ok {
    background: color-mix(in srgb, var(--success-color) 12%, transparent);
    color: var(--text-primary);
}
.photo-status.ok a { color: var(--primary-color); font-weight: 700; }
.photo-status.err {
    background: color-mix(in srgb, var(--error-color) 12%, transparent);
    color: var(--text-primary);
}

/* why an ingredient search matched this recipe */
.card-match {
    display: inline-flex; align-items: center; gap: 6px; flex-wrap: wrap;
    margin: 2px 0 4px; padding: 3px 9px; border-radius: 999px;
    font-size: 0.72rem; font-weight: 700; color: var(--primary-color);
    background: color-mix(in srgb, var(--primary-color) 12%, transparent);
}

/* ===== Cook mode ===== */
/* takes over the screen: nav, add button and gear all step aside */
body:has(.ck) .sidebar,
body:has(.ck) .fab-add,
body:has(.ck) .nav-gear { display: none; }
body:has(.ck) main.with-sidebar {
    margin: 0; padding: 0; margin-bottom: 0; padding-top: 0; padding-bottom: 0;
}

.ck {
    position: fixed; inset: 0; z-index: 1200;
    display: flex; flex-direction: column;
    background: var(--bg-color); color: var(--text-primary);
    padding-top: env(safe-area-inset-top, 0px);
    padding-bottom: env(safe-area-inset-bottom, 0px);
}
.ck-top {
    display: flex; align-items: center; gap: 12px;
    padding: 12px 14px; flex-shrink: 0;
}
.ck-close, .ck-awake {
    width: 40px; height: 40px; flex-shrink: 0; border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    background: var(--bg-elevated); border: 1px solid var(--border-color);
    color: var(--text-secondary); font-size: 1rem; cursor: pointer; text-decoration: none;
}
.ck-awake.on { color: #f5a524; border-color: #f5a524; }
.ck-awake-unsupported { opacity: 0.4; }
.ck-title {
    flex: 1; min-width: 0; text-align: center; font-weight: 800; font-size: 0.95rem;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--text-secondary);
}
.ck-progress { height: 4px; background: var(--bg-elevated); flex-shrink: 0; }
.ck-progress-fill {
    height: 100%; width: 0; background: var(--accent-gradient);
    transition: width 0.3s ease;
}

.ck-stage {
    flex: 1; display: flex; flex-direction: column; justify-content: center;
    padding: 1.5rem 1.4rem; overflow-y: auto; text-align: left;
}
.ck-fade { animation: ckIn 0.28s ease both; }
@keyframes ckIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
.ck-step-num {
    font-size: 0.78rem; font-weight: 800; letter-spacing: 0.09em; text-transform: uppercase;
    color: var(--primary-color); margin-bottom: 0.9rem;
}
/* big enough to read at arm's length with your hands busy */
.ck-step-text { font-size: 1.6rem; line-height: 1.45; font-weight: 600; margin: 0; }

.ck-nav {
    display: flex; align-items: center; gap: 10px; padding: 1rem 1.1rem 1.3rem; flex-shrink: 0;
}
.ck-btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    height: 54px; border-radius: var(--border-radius-lg); cursor: pointer;
    font-size: 1rem; font-weight: 700; font-family: inherit;
    background: var(--bg-elevated); border: 1px solid var(--border-color); color: var(--text-primary);
}
.ck-btn:disabled { opacity: 0.35; cursor: default; }
.ck-prev, .ck-next { flex: 1; }
.ck-next { background: var(--accent-gradient); border-color: transparent; color: #fff; }
.ck-ings-btn { width: 64px; flex-shrink: 0; font-size: 0.9rem; }

.ck-drawer {
    position: fixed; inset: 0; z-index: 1300; display: flex; flex-direction: column;
    justify-content: flex-end; background: rgba(8, 9, 12, 0.55); backdrop-filter: blur(2px);
}
.ck-drawer[hidden] { display: none; }
.ck-drawer-head {
    display: flex; align-items: center; justify-content: space-between;
    padding: 1.1rem 1.3rem 0.6rem; font-weight: 800; font-size: 1.05rem;
    background: var(--bg-card); color: var(--text-primary);
    border-radius: var(--border-radius-lg) var(--border-radius-lg) 0 0;
}
.ck-drawer-head button {
    background: none; border: none; color: var(--text-muted); font-size: 1.15rem; cursor: pointer;
}
.ck-ings {
    list-style: none; margin: 0; padding: 0 1.3rem calc(1.4rem + env(safe-area-inset-bottom, 0px));
    background: var(--bg-card); max-height: 62vh; overflow-y: auto;
}
.ck-ing {
    display: flex; align-items: center; gap: 12px; padding: 12px 0; cursor: pointer;
    border-bottom: 1px solid var(--border-color); font-size: 1rem;
}
.ck-cb {
    width: 24px; height: 24px; flex-shrink: 0; border-radius: 8px;
    border: 2px solid var(--border-color); color: transparent;
    display: flex; align-items: center; justify-content: center; font-size: 0.72rem;
}
.ck-ing.checked .ck-cb { background: var(--primary-color); border-color: var(--primary-color); color: #fff; }
.ck-ing.checked > span:last-child { text-decoration: line-through; color: var(--text-muted); }

.ck-done { text-align: center; }
.ck-done i { font-size: 2.6rem; color: var(--primary-color); margin-bottom: 1rem; display: block; }
.ck-done h2 { font-size: 1.9rem; margin: 0 0 0.4rem; }
.ck-done p { color: var(--text-secondary); margin: 0 0 1.6rem; }
.ck-done-btn {
    display: inline-flex; align-items: center; justify-content: center; height: 50px; padding: 0 1.6rem;
    border-radius: var(--border-radius-lg); background: var(--accent-gradient); color: #fff;
    font-weight: 700; text-decoration: none;
}

/* ===== Servings scaler ===== */
.rd-scale {
    display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
    margin: 12px 0 2px; padding: 10px 12px;
    background: var(--bg-elevated); border: 1px solid var(--border-color);
    border-radius: var(--border-radius-lg);
}
.rd-scale.scaled { border-color: var(--primary-color); }
.rd-scale-label { font-size: 0.82rem; font-weight: 800; letter-spacing: 0.04em;
    text-transform: uppercase; color: var(--text-muted); }
.rd-scale-ctrl { display: flex; align-items: center; gap: 4px; margin-left: auto; }
.rd-scale-ctrl button {
    width: 32px; height: 32px; border-radius: 10px; cursor: pointer;
    background: var(--bg-card); border: 1px solid var(--border-color);
    color: var(--text-primary); font-size: 0.8rem;
    display: flex; align-items: center; justify-content: center;
    transition: all 0.15s ease;
}
.rd-scale-ctrl button:hover { border-color: var(--primary-color); color: var(--primary-color); }
.rd-scale-value {
    min-width: 72px; text-align: center; font-size: 0.95rem; font-weight: 800;
    color: var(--text-primary); font-variant-numeric: tabular-nums;
}
.rd-scale-reset {
    display: inline-flex; align-items: center; background: none; border: none; cursor: pointer;
    font-size: 0.8rem; font-weight: 700; color: var(--primary-color); padding: 4px 2px;
}

/* batch badge on a shopping-list chip */
.sl-scale {
    flex-shrink: 0; border: none; cursor: pointer; border-radius: 999px;
    padding: 3px 9px; font-size: 0.75rem; font-weight: 800;
    background: var(--primary-color); color: #fff; font-variant-numeric: tabular-nums;
}
.sl-scale-plain { background: var(--bg-elevated); color: var(--text-muted); }
.sl-scale:hover { filter: brightness(1.08); }

/* ===== Ratings ===== */
.rd-rate {
    margin-top: 14px; padding: 14px; border-radius: var(--border-radius-lg);
    background: var(--bg-elevated); border: 1px solid var(--border-color);
}
.rd-rate-row {
    display: flex; align-items: center; justify-content: space-between;
    gap: 12px; flex-wrap: wrap;
}
.rd-rate-row + .rd-rate-row { margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--border-color); }
.rd-rate-label { font-size: 0.88rem; font-weight: 700; color: var(--text-secondary); }
.rd-stars { display: flex; gap: 3px; }
/* empty stars sit on --bg-elevated, where --border-color is nearly invisible;
   --text-muted keeps the unfilled half of the rating readable */
.rd-star {
    background: none; border: none; cursor: pointer; padding: 3px;
    font-size: 1.35rem; line-height: 1; color: var(--text-muted); opacity: 0.45;
    transition: transform 0.12s ease, color 0.12s ease, opacity 0.12s ease;
}
.rd-star:hover { transform: scale(1.15); }
.rd-star.on { color: #f5a524; opacity: 1; }
/* hovering a star previews filling everything to its left */
.rd-stars:hover .rd-star { color: #f5a524; opacity: 1; }
.rd-stars .rd-star:hover ~ .rd-star { color: var(--text-muted); opacity: 0.45; }

.rd-import { display: flex; gap: 7px; }
.rd-imp {
    width: 40px; height: 36px; border-radius: 11px; cursor: pointer;
    background: var(--bg-card); border: 2px solid var(--border-color);
    color: var(--text-muted); font-size: 0.95rem;
    transition: all 0.15s ease;
}
.rd-imp:hover { transform: translateY(-2px); }
.rd-imp.on { border-color: var(--success-color, #2e9e5b); color: var(--success-color, #2e9e5b); }
.rd-imp.bad { border-color: var(--error-color); color: var(--error-color); }
.rd-note-wrap { margin-top: 11px; }
.rd-note {
    width: 100%; padding: 10px 12px; font-size: 0.9rem; font-family: inherit;
    color: var(--text-primary); background: var(--bg-card);
    border: 1px solid var(--border-color); border-radius: var(--border-radius);
}
.rd-note:focus { outline: none; border-color: var(--primary-color); }

/* rating summary on a history card */
.card-rating { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin: 2px 0 4px; }
/* no opacity on the container — it would fade the filled stars along with the empty ones */
.card-stars { display: inline-flex; gap: 2px; font-size: 0.76rem; color: var(--border-color); }
.card-stars .on { color: #f5a524; }
.card-badimport {
    display: inline-flex; align-items: center; gap: 5px; font-size: 0.72rem; font-weight: 700;
    color: var(--error-color); background: color-mix(in srgb, var(--error-color) 12%, transparent);
    padding: 2px 8px; border-radius: 999px;
}

/* "Save to collection" picker inside the recipe detail sheet */
.rd-collections { display: flex; flex-direction: column; gap: 6px; margin-top: 0.75rem; }
.rd-col-option {
    display: flex; align-items: center; gap: 10px; width: 100%; padding: 10px 12px;
    background: var(--bg-elevated); border: 1px solid transparent; border-radius: var(--border-radius);
    font-size: 0.9rem; font-weight: 600; color: var(--text-primary); cursor: pointer; text-align: left;
    transition: border-color 0.15s ease, background 0.15s ease;
}
.rd-col-option:hover { border-color: var(--primary-color); }
.rd-col-option .rd-col-check { margin-left: auto; color: var(--primary-color); opacity: 0; }
.rd-col-option.on .rd-col-check { opacity: 1; }
.rd-col-new { color: var(--primary-color); font-weight: 700; }

/* ===== Cookbook view ===== */
.cb-page { max-width: 520px; margin: 0 auto; }

.cb-topbar {
    display: flex; align-items: center; justify-content: space-between;
    gap: 12px; margin-bottom: 12px;
}
.cb-counter { font-size: 0.85rem; color: var(--text-muted); }
.cb-icon-btn {
    background: none; border: 1px solid var(--border-color); color: var(--text-secondary);
    width: 38px; height: 38px; border-radius: 10px; cursor: pointer;
    display: inline-flex; align-items: center; justify-content: center;
}

.cb-entry-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; }
.cb-entry-btn {
    display: inline-flex; align-items: center; gap: 8px; flex-shrink: 0;
    padding: 9px 14px; border-radius: 10px; text-decoration: none;
    background: var(--primary-color); color: #fff; font-size: 0.9rem;
}

.cb-book { position: relative; width: 100%; aspect-ratio: 300 / 452; }
.cb-cover { position: absolute; inset: 0; border-radius: 10px; background: #5d5a52; }
.cb-edges {
    position: absolute; top: 9px; bottom: 9px; right: 5px; width: 9px;
    border-radius: 0 5px 5px 0;
    background: repeating-linear-gradient(to right, #efe7d6 0 1px, #d9cfb8 1px 2px);
}
.cb-stage {
    position: absolute; top: 11px; left: 30px; right: 11px; bottom: 11px;
    perspective: 1600px; perspective-origin: 0% 50%;
    /* declare vertical intent so the browser keeps horizontal drags for us,
       and stop a horizontal drag turning into an iOS text selection */
    touch-action: pan-y; user-select: none; -webkit-user-select: none;
}
.cb-pages { position: absolute; inset: 0; }

.cb-rings {
    position: absolute; top: 0; bottom: 0; left: 14px; width: 32px; z-index: 30;
    display: flex; flex-direction: column; justify-content: space-around;
    align-items: center; pointer-events: none;
}
.cb-ring {
    width: 30px; height: 12px; border: 3px solid #a6acb2; border-radius: 50%;
    box-shadow: 0 1px 2px rgba(0,0,0,.35);
}

.cb-leaf {
    position: absolute; inset: 0;
    transform-style: preserve-3d; transform-origin: left center;
    will-change: transform;
}
.cb-face {
    position: absolute; inset: 0; overflow: hidden;
    background: #f6f1e7; backface-visibility: hidden;
    box-shadow: 0 1px 5px rgba(0,0,0,.18);
}
.cb-front { border-radius: 2px 7px 7px 2px; }
.cb-back {
    border-radius: 7px 2px 2px 7px; transform: rotateY(180deg);
    background-image: repeating-linear-gradient(to bottom, transparent 0 26px, #e6ddc9 26px 27px);
}
.cb-gutter {
    position: absolute; inset: 0; pointer-events: none;
    background: linear-gradient(to right, rgba(60,40,20,.28), rgba(60,40,20,0) 45%);
}

.cb-photo {
    height: 40%; background: #b5654a; background-size: cover; background-position: center;
    display: flex; align-items: flex-end; padding: 10px 14px;
}
.cb-time {
    background: rgba(0,0,0,.45); color: #fff; font-size: 0.68rem;
    padding: 3px 8px; border-radius: 999px;
}
.cb-body { padding: 14px 15px 14px 20px; color: #2c2a26; }
.cb-kicker { font-size: 0.62rem; letter-spacing: .09em; color: #6b6459; }
.cb-name { font-family: Georgia, 'Times New Roman', serif; font-size: 1.15rem; line-height: 1.25; margin: 5px 0 7px; }
.cb-stars { margin-bottom: 10px; color: var(--primary-color); font-size: 0.75rem; }
.cb-star-off { color: #d8d0c0; }
.cb-rule { height: 1px; background: #e0d8c8; margin-bottom: 9px; }
.cb-ing { margin: 0; padding-left: 16px; font-size: 0.8rem; line-height: 1.5; }

.cb-controls { display: flex; align-items: center; justify-content: center; gap: 24px; margin-top: 16px; }
.cb-nav-btn {
    background: none; border: 1px solid var(--border-color); color: var(--text-secondary);
    width: 44px; height: 44px; border-radius: 50%; cursor: pointer;
}
.cb-nav-btn:disabled { opacity: .35; cursor: default; }

.cb-contents {
    /* 1300 matches .ck-drawer, the app's other bottom sheet. The mobile
       .sidebar is fixed at the bottom with z-index 1000, so anything lower
       puts the last ~60px of this list behind the nav bar -- taps there would
       hit nav destinations instead of recipes. */
    position: fixed; inset: 0; z-index: 1300;
    background: rgba(0,0,0,.55); display: flex; align-items: flex-end;
}
.cb-contents[hidden] { display: none; }
.cb-contents-inner {
    background: var(--bg-card); width: 100%; max-height: 78vh;
    border-radius: 16px 16px 0 0; overflow-y: auto;
    /* same safe-area pattern as .ck-ings, so the last row clears the
       home indicator */
    padding: 16px 16px calc(16px + env(safe-area-inset-bottom, 0px));
}
.cb-contents-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.cb-contents-list { list-style: none; margin: 0; padding: 0; }
.cb-contents-list li { border-bottom: 1px solid var(--border-color); }
.cb-contents-list button {
    width: 100%; text-align: left; background: none; border: 0; cursor: pointer;
    padding: 12px 4px; color: var(--text-primary); font-size: 0.95rem;
}
.cb-contents-num { color: var(--text-muted); margin-right: 10px; font-size: 0.8rem; }

.cb-message {
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    text-align: center; padding: 32px 24px; gap: 10px; color: #2c2a26;
}
.cb-message h3 { font-family: Georgia, 'Times New Roman', serif; margin: 0; }
.cb-message p { margin: 0; font-size: 0.85rem; color: #6b6459; }
/* ===== Terms and privacy ===== */
/* 46rem is a comfortable measure for a page of prose, narrower than the 900px
   .main-container gets on desktop. It is wider than the 700px the tablet block
   sets, though, and this rule comes after it — so the tablet range is restated
   here rather than letting the page silently run 36px wide there. */
.terms { max-width: 46rem; }
@media (max-width: 1024px) and (min-width: 769px) {
    .terms { max-width: 700px; }
}
.terms-head { margin-bottom: 1.25rem; }
.terms-date { color: var(--text-muted); font-size: 0.85rem; margin: 0.25rem 0 0; }
.terms-lead {
    color: var(--text-secondary); font-size: 1.02rem; line-height: 1.65;
    border-left: 3px solid var(--primary-color); padding-left: 0.9rem;
    border-radius: 0; margin-bottom: 1.75rem;
}
.terms h2 {
    font-size: 1.08rem; margin: 1.9rem 0 0.6rem; color: var(--text-primary);
}
.terms p, .terms li { color: var(--text-secondary); line-height: 1.7; }
.terms ul { padding-left: 1.15rem; margin: 0.5rem 0 0; }
.terms li { margin-bottom: 0.55rem; }
.terms strong { color: var(--text-primary); }
.terms-foot {
    margin-top: 2.25rem; padding-top: 1.1rem;
    border-top: 1px solid var(--border-color);
}

.login-terms {
    text-align: center; font-size: 0.82rem; color: var(--text-muted);
    margin: 0.9rem 0 0;
}
.login-terms a { color: var(--text-secondary); }

/* ===== UI polish: reclaim vertical space and fix undersized controls =====
   Measured on 2026-08-02 at 393px: the library's first recipe card sat at
   474px and the shopping list's first item at 567px, so barely one row was
   visible on an 852px phone. The page headings were the largest single cost
   (2.5rem title plus a 3rem bottom margin on every page). */
@media (max-width: 768px) {
    .header { margin-bottom: 1.25rem; }
    .header h1 { font-size: 1.55rem; margin-bottom: 0.15rem; }
    .header p { font-size: 0.88rem; margin-bottom: 0; }
    .history-controls { margin-bottom: 0.85rem; }
    .sl-staples { margin-bottom: 0.9rem; }
    .sl-progress { margin: 0.9rem 0 0.4rem; }
    .sl-toolbar { margin: 0.7rem 0 0.6rem; }
}

/* Controls that were genuinely under the 44px touch minimum. The grocery rows
   were already fine — their label is a full-width 46px target — but these
   three were not. */
/* Expand the hit area with an overlay rather than min-height: growing these
   buttons inflated the chips and tabs and pushed the first grocery item 25px
   further down, which is the opposite of the point. */
.sl-remove, .sl-scale { position: relative; }
.sl-remove::after, .sl-scale::after {
    content: ''; position: absolute; top: 50%; left: 50%;
    width: 44px; height: 44px; transform: translate(-50%, -50%);
}
.seg-btn { min-height: 40px; }

/* Library controls: search on its own row, the two filters sharing the next,
   and refresh reduced to its icon. Previously each control sized to content
   and took a full row, so the header alone ran to 436px on a 393px screen. */
@media (max-width: 768px) {
    /* An earlier mobile rule sets flex-direction: column, which made every
       control take a full row regardless of its flex-basis. */
    .history-controls { gap: 0.5rem; flex-direction: row; flex-wrap: wrap; }
    .history-controls .search-box { flex: 1 0 100%; min-width: 0; }
    .history-controls .filter-box { flex: 1 1 0; min-width: 0; }
    .history-controls .filter-select { font-size: 0.85rem; padding-left: 0.7rem; }
    #refresh-history { flex: 0 0 auto; width: 44px; padding: 0; justify-content: center; }
    #refresh-history .rh-label { display: none; }
}

/* The Cookbook entry button was squeezing the page title on narrow screens,
   wrapping both the heading and its subtitle. Reduce it to its icon there,
   as with refresh — the label returns above 480px. */
@media (max-width: 480px) {
    .cb-entry-btn { padding: 0; width: 44px; height: 44px; justify-content: center; }
    .cb-entry-btn span { display: none; }
}
