/* Recipe Consolidator app layer: mobile-first layout and a calmer look.
   Loaded after the inline styles in index.html, so it overrides them. */

:root {
    --bg: #faf8f5;
    --surface: #ffffff;
    --ink: #26221e;
    --muted: #776f68;
    --line: #ebe6e0;
    --line-strong: #dcd5cd;
    --accent: #c8743a;
    --accent-ink: #a95c27;
    --accent-soft: #fbf0e6;
    --active-soft: #f1f7ef;
    --active-ink: #3c7a34;
    --danger: #b3261e;
    --radius: 14px;
    --radius-sm: 10px;
    --appbar-h: 56px;
    --tabbar-h: 64px;
    --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    color-scheme: light;
}

html { -webkit-text-size-adjust: 100%; }

.rc-body {
    background: var(--bg);
    color: var(--ink);
    font-family: var(--font);
    line-height: 1.5;
    -webkit-tap-highlight-color: transparent;
}
.rc-body button, .rc-body input, .rc-body select, .rc-body textarea { font-family: var(--font); }
.rc-body.rc-sheet-open { overflow: hidden; }

/* ---------- App bar + tabs ---------- */
.rc-appbar {
    position: sticky;
    top: 0;
    z-index: 1000;
    background: rgba(255, 255, 255, 0.92);
    -webkit-backdrop-filter: saturate(180%) blur(12px);
    backdrop-filter: saturate(180%) blur(12px);
    border-bottom: 1px solid var(--line);
    padding-top: env(safe-area-inset-top);
}
.rc-appbar-inner {
    max-width: 960px;
    margin: 0 auto;
    height: var(--appbar-h);
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 0 16px;
}
.rc-appbar-back {
    width: 36px; height: 36px;
    display: inline-flex; align-items: center; justify-content: center;
    border-radius: 50%;
    color: var(--muted);
    text-decoration: none;
    margin-left: -8px;
}
.rc-appbar-back:hover { background: var(--bg); color: var(--ink); }
.rc-appbar-title {
    font-size: 17px;
    font-weight: 650;
    letter-spacing: -0.01em;
    flex: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Desktop: tabs sit in the app bar as a segmented control */
.rc-workflow-tabs {
    position: static;
    top: auto;
    background: var(--bg);
    border: 1px solid var(--line);
    border-radius: 999px;
    padding: 3px;
    display: flex;
    gap: 2px;
}
.rc-tab {
    position: relative;
    padding: 6px 14px;
    border: none;
    border-radius: 999px;
    font-size: 14px;
    font-weight: 550;
    color: var(--muted);
    gap: 7px;
}
.rc-tab i { font-size: 13px; }
.rc-tab:hover { color: var(--ink); }
.rc-tab.active {
    color: var(--ink);
    background: var(--surface);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
    border: none;
}
.rc-tab .tab-badge {
    background: var(--accent-soft);
    color: var(--accent-ink);
    font-size: 11px;
    padding: 0 6px;
    border-radius: 999px;
    line-height: 18px;
}

/* ---------- Views ---------- */
.rc-section {
    max-width: 960px;
    margin: 0 auto;
    padding: 20px 16px 48px;
}
.rc-view { display: none; }
.rc-view.active { display: block; animation: rc-fade 0.18s ease-out; }
@keyframes rc-fade { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

.rc-card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.03);
    padding: 20px;
    margin-bottom: 16px;
}
.rc-card h2 {
    font-size: 22px;
    font-weight: 700;
    letter-spacing: -0.02em;
    color: var(--ink);
    margin: 0;
}
.rc-card h3 { font-size: 15px; font-weight: 650; color: var(--ink); margin: 0 0 10px; }

.rc-view-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 16px;
}
.rc-view-header h2 { flex: 1; }

.rc-hint { font-size: 13px; color: var(--muted); margin: 0 0 10px; }
.rc-section-anchor { scroll-margin-top: calc(var(--appbar-h) + 16px); }

/* ---------- Controls ---------- */
.btn {
    background: var(--accent);
    color: #fff;
    border: 1px solid var(--accent);
    border-radius: var(--radius-sm);
    padding: 10px 18px;
    font-size: 15px;
    font-weight: 600;
    line-height: 1.2;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    min-height: 40px;
    margin: 0; /* style.css gives .btn a large site-wide margin */
}
.btn:hover { background: var(--accent-ink); border-color: var(--accent-ink); }
.btn-secondary, .btn-quiet {
    background: var(--surface);
    color: var(--ink);
    border: 1px solid var(--line-strong);
}
.btn-secondary:hover, .btn-quiet:hover { background: var(--bg); border-color: var(--line-strong); color: var(--ink); }
.rc-add-btn { padding: 8px 14px; min-height: 38px; font-size: 14px; }

.rc-icon-btn, .rc-actions-btn {
    width: 38px; height: 38px;
    padding: 0;
    display: inline-flex; align-items: center; justify-content: center;
    border: 1px solid var(--line-strong);
    border-radius: var(--radius-sm);
    background: var(--surface);
    color: var(--muted);
    cursor: pointer;
    font-size: 15px;
}
.rc-icon-btn:hover, .rc-actions-btn:hover { color: var(--ink); border-color: var(--line-strong); background: var(--bg); }
.rc-actions-menu[open] .rc-actions-btn { color: var(--ink); border-color: var(--ink); }
.rc-actions-dropdown {
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.12);
    min-width: 230px;
    padding: 6px;
}
.rc-actions-item { border-radius: 8px; padding: 10px 12px; font-size: 15px; color: var(--ink); }
.rc-actions-item:hover { background: var(--bg); }
.rc-actions-item.danger, .rc-actions-item.danger i { color: var(--danger); }

.rc-select, .rc-body select {
    appearance: none;
    -webkit-appearance: none;
    background: var(--surface) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath d='M1 1l4 4 4-4' stroke='%23776f68' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E") no-repeat right 12px center !important;
    border: 1px solid var(--line-strong) !important;
    border-radius: var(--radius-sm) !important;
    padding: 8px 32px 8px 12px !important;
    font-size: 15px !important;
    color: var(--ink);
    min-height: 38px;
    cursor: pointer;
}

/* Text fields: one quiet style, and 16px so iOS does not zoom on focus */
.rc-body input[type="text"],
.rc-body input[type="url"],
.rc-body input[type="number"],
.rc-body input[type="password"],
.rc-body input[type="search"],
.rc-body textarea {
    border: 1px solid var(--line-strong) !important;
    border-radius: var(--radius-sm) !important;
    font-size: 16px !important;
    color: var(--ink);
    background: var(--surface);
}
.rc-body input:focus, .rc-body textarea:focus, .rc-body select:focus {
    outline: none;
    border-color: var(--accent) !important;
    box-shadow: 0 0 0 3px rgba(200, 116, 58, 0.15);
}
.rc-body input[type="checkbox"] { accent-color: var(--accent); }
.rc-body textarea:disabled { background: var(--bg); }

/* ---------- Recipes ---------- */
.rc-filters { border: none; margin-bottom: 8px; }
.rc-filter-row { padding: 0; }
#unifiedFilterInput { padding: 10px 34px !important; background: var(--bg) !important; border-color: transparent !important; }
#unifiedFilterInput:focus { background: var(--surface) !important; border-color: var(--accent) !important; }
#activeFiltersContainer { padding: 8px 0 0 !important; }

.recipe-list { margin-top: 4px; }
.rc-quick-filters { display: flex; gap: 6px; overflow-x: auto; padding: 2px 0 8px; scrollbar-width: none; -webkit-overflow-scrolling: touch; }
.rc-quick-filters::-webkit-scrollbar { display: none; }
.rc-quick-filters .rc-chip-btn { flex-shrink: 0; white-space: nowrap; }
.rc-chip-btn.is-on { background: var(--ink); border-color: var(--ink); color: #fff; }
.recipe-item {
    background: transparent;
    border-bottom: 1px solid var(--line);
    border-radius: 0;
    margin: 0;
    padding: 4px 0;
}
.recipe-item:last-of-type { border-bottom: none; }
.recipe-item.is-active { background: transparent; }
.recipe-row-summary { gap: 12px; padding: 8px 4px; min-height: 52px; }
.recipe-row-summary input[type="checkbox"] { width: 22px !important; height: 22px !important; }
.recipe-item-name { font-size: 16px; font-weight: 550; }
.recipe-item.is-active .recipe-item-name { color: var(--active-ink); }
.recipe-item .recipe-tag {
    background: var(--bg);
    color: var(--muted);
    padding: 1px 8px;
    font-size: 12px;
    font-weight: 500;
    border-radius: 999px;
}
.recipe-row-detail { margin: 0 0 8px 38px; padding-top: 8px; border-top: none; }
.recipe-item-actions { flex-wrap: wrap; gap: 6px; }
.recipe-action-btn {
    border: 1px solid var(--line-strong);
    border-radius: 999px;
    padding: 6px 12px;
    font-size: 13px;
    color: var(--ink);
    min-height: 34px;
}
.recipe-action-btn:hover { border-color: var(--ink); color: var(--ink); }
.recipe-show-more-btn {
    border: none;
    color: var(--accent-ink);
    font-weight: 600;
    padding: 12px;
}
.recipe-show-more-btn:hover { background: var(--bg); color: var(--accent-ink); }
.recipe-item .recipe-tag { cursor: pointer; white-space: nowrap; flex-shrink: 0; }
.recipe-item .recipe-tag.is-selected { background: var(--accent); color: #fff; }
.recipe-item .rc-tag-more { background: none; cursor: default; padding-left: 2px; }
#noRecipesMessage { padding: 32px 12px !important; }

/* ---------- Add / edit recipe sheet ---------- */
.rc-sheet {
    position: fixed;
    inset: 0;
    z-index: 1500;
    background: rgba(20, 16, 12, 0.38);
    display: none;
    align-items: center;
    justify-content: center;
    padding: 24px;
}
.rc-sheet.open { display: flex; animation: rc-fade-in 0.15s ease-out; }
@keyframes rc-fade-in { from { opacity: 0; } to { opacity: 1; } }
.rc-sheet-panel {
    width: 100%;
    max-width: 640px;
    max-height: calc(100vh - 48px);
    max-height: calc(100dvh - 48px);
    overflow-y: auto;
    overscroll-behavior: contain;
    margin: 0;
    padding: 0 20px 0;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.2);
}
.rc-sheet .rc-card-header {
    position: sticky;
    top: 0;
    z-index: 2;
    background: var(--surface);
    padding: 16px 0 12px;
    cursor: default;
}
.rc-sheet .rc-card-body,
.rc-sheet .rc-card-body.collapsed { max-height: none !important; opacity: 1 !important; overflow: visible; }
.rc-sheet-actions {
    position: sticky;
    bottom: 0;
    background: var(--surface);
    border-top: 1px solid var(--line);
    margin: 8px -20px 0;
    padding: 12px 20px calc(12px + env(safe-area-inset-bottom));
    display: flex;
    justify-content: flex-end;
    gap: 8px;
}
#editRecipeActions { gap: 8px; }
#editRecipeActions[style*="block"] { display: flex !important; }
#addRecipeDescription { font-size: 14px; margin: 12px 0 !important; }
#recipeServings { width: 120px !important; }
.recipe-input-area, #recipeInput { min-height: 180px !important; }
.rc-add-mode-toggle { border-bottom: 1px solid var(--line); }
.rc-dev-only { display: none !important; }
body.rc-dev .rc-dev-only { display: flex !important; }
.rc-dev-only-inline { display: none !important; }
body.rc-dev .rc-dev-only-inline { display: inline-flex !important; }
/* With only one way to add a recipe, the mode switch is just noise */
body:not(.rc-dev) .rc-add-mode-toggle { display: none; }
.rc-lock-badge, .rc-unlock-badge { font-size: 11px; padding: 1px 8px; }

/* ---------- Plan ---------- */
.rc-meal-types { margin-bottom: 16px; }
#mealTypesContainer { gap: 6px !important; }
.meal-type-box {
    background: var(--accent-soft);
    color: var(--accent-ink);
    border-radius: 999px;
    padding: 6px 14px;
    font-size: 13px;
    font-weight: 600;
    cursor: grab;
}
.meal-type-box:hover { background: #f6e2d0; }

#dayPlannerContainer {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 12px;
    overflow: visible;
    padding-bottom: 0;
}
.day-planner-day {
    min-width: 0;
    max-width: none;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 14px;
    background: var(--surface);
}
.day-header { border-bottom: none; padding-bottom: 0; margin-bottom: 10px; gap: 8px; }
.day-title { font-size: 16px; font-weight: 650; line-height: 1.3; }
.remove-day {
    background: none !important;
    border: none !important;
    color: var(--muted) !important;
    font-size: 13px !important;
    padding: 4px 6px !important;
    white-space: nowrap;
}
.remove-day:hover { color: var(--danger) !important; }
.meal-slot {
    min-height: 0;
    padding: 10px;
    background: var(--bg);
    border: 1px dashed var(--line-strong);
    border-radius: var(--radius-sm);
    margin-bottom: 8px;
}
.meal-slot.drag-over { background: var(--accent-soft); border-color: var(--accent); }
.meal-slot-label {
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--muted);
    margin-bottom: 6px;
}
.meal-slot-content { min-height: 28px; }
.meal-slot-content:empty::after,
.meal-slot-content > div[style*="italic"] { font-size: 13px; }
.day-drop-zone.meal-slot { min-height: 0; padding: 10px 12px; border: 1px solid var(--line); background: var(--bg); margin-bottom: 8px; }
.day-drop-zone.meal-slot.drag-over { border-color: var(--accent); background: var(--accent-soft); }
.remove-meal-slot { background: none; color: var(--muted); top: 6px; right: 6px; font-size: 15px; font-weight: 400; opacity: 0.7; }
.remove-meal-slot:hover { color: var(--danger); opacity: 1; }
.planned-recipe {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 8px 10px;
    margin-bottom: 6px;
    font-size: 14px;
    line-height: 1.35;
    gap: 6px;
}
.planned-recipe:hover { box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06); }
.planned-recipe .btn { background: none !important; border: none !important; min-height: 0; padding: 2px 4px !important; opacity: 0.7; }
.remove-meal { background: none; color: var(--muted); margin-left: 0; font-size: 16px; padding: 2px 6px; }
.remove-meal:hover { background: #fdecea; color: var(--danger); }
.day-drop-zone.empty { border: 1px dashed var(--line-strong) !important; border-radius: var(--radius-sm); background: var(--bg) !important; }

.rc-unplanned { margin-top: 20px; padding-top: 16px; border-top: 1px solid var(--line); }
.rc-unplanned h3 { font-size: 13px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em; }
.unplanned-recipes-container { display: flex; flex-wrap: wrap; gap: 6px; min-height: 0; padding: 0; background: none; border: none; }
.unplanned-recipe {
    margin: 0;
    border: 1px solid var(--line-strong);
    border-radius: 999px;
    padding: 6px 12px;
    font-size: 14px;
    cursor: grab;
}

/* ---------- Shop ---------- */
.rc-shop-controls { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 8px; }
.shopping-list { margin-top: 0; }
.shopping-item {
    background: transparent;
    border-bottom: 1px solid var(--line);
    border-radius: 0;
    margin: 0;
    padding: 10px 2px;
}
.shopping-item:not(.rc-shop-item) > div {
    display: grid;
    grid-template-columns: 1fr auto;
    column-gap: 16px;
    width: 100%;
    align-items: baseline;
}
.shopping-item-name { font-size: 15px; font-weight: 500; line-height: 1.35; }
.shopping-item-quantity { font-size: 14px; color: var(--muted); text-align: right; white-space: nowrap; }
.shopping-item-sources { grid-column: 1 / -1; font-size: 12px; color: #a39a92; font-style: normal; margin-top: 2px; }
.shopping-category-header {
    font-size: 12px !important;
    font-weight: 700 !important;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--muted) !important;
    border-bottom: none !important;
    margin: 20px 0 2px !important;
    padding-bottom: 0 !important;
}


/* ---------- Step 2: planning, picker, tick-off shopping ---------- */
.rc-plan-bar { display: flex; align-items: center; flex-wrap: wrap; gap: 8px 16px; margin: -4px 0 14px; }
.rc-headcount { display: inline-flex; align-items: center; gap: 8px; font-size: 15px; color: var(--ink); }
.rc-headcount i { color: var(--muted); }
.rc-headcount-input { width: 64px; text-align: center; padding: 6px 8px; }
.rc-plan-summary { font-size: 13px; color: var(--muted); }
.rc-plan-empty .btn { margin-top: 12px; }
.empty-state .btn i { font-size: inherit; display: inline; margin: 0; color: inherit; }
.rc-plan-empty p { margin: 0 0 4px; }

.rc-slot-add {
    display: flex; align-items: center; gap: 6px;
    width: 100%;
    margin-top: 2px;
    padding: 8px 10px;
    min-height: 38px;
    border: 1px dashed var(--line-strong);
    border-radius: 8px;
    background: transparent;
    color: var(--muted);
    font-size: 14px;
    cursor: pointer;
}
.rc-slot-add:hover { color: var(--accent-ink); border-color: var(--accent); background: var(--surface); }
.day-drop-zone.rc-add-meals { display: flex; flex-wrap: wrap; gap: 6px; padding: 4px 0 0 !important; border: none !important; background: none !important; min-height: 0 !important; margin-top: 4px !important; }
.day-drop-zone.rc-add-meals.drag-over { outline: 2px dashed var(--accent); outline-offset: 2px; }

.rc-chip-row { display: flex; flex-wrap: wrap; gap: 6px; }
.rc-chip-btn {
    display: inline-flex; align-items: center; gap: 5px;
    border: 1px solid var(--line-strong);
    background: var(--surface);
    color: var(--ink);
    border-radius: 999px;
    padding: 6px 12px;
    min-height: 34px;
    font-size: 13px;
    cursor: pointer;
}
.rc-chip-btn i { font-size: 10px; color: var(--muted); }
.rc-chip-btn:hover { border-color: var(--ink); }
.rc-check-chip { position: relative; }
.rc-check-chip input { position: absolute; opacity: 0; pointer-events: none; }
.rc-check-chip span {
    display: inline-flex; align-items: center;
    border: 1px solid var(--line-strong); border-radius: 999px;
    padding: 6px 12px; min-height: 34px; font-size: 14px; cursor: pointer; background: var(--surface);
}
.rc-check-chip input:checked + span { background: var(--accent-soft); border-color: var(--accent); color: var(--accent-ink); font-weight: 600; }
.rc-check-chip input:focus-visible + span { box-shadow: 0 0 0 3px rgba(200, 116, 58, 0.25); }

.rc-picker-body { padding-bottom: 16px; }
.rc-picker-body .rc-sheet-actions { margin-top: 16px; }
.rc-field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.rc-field > span { font-size: 13px; font-weight: 600; color: var(--muted); }
.rc-field input, .rc-field textarea, .rc-field select { width: 100%; padding: 10px 12px; }
.rc-body input[type="date"], .rc-body input[type="email"] { border: 1px solid var(--line-strong); border-radius: var(--radius-sm); font-size: 16px; min-height: 42px; background: var(--surface); color: var(--ink); }
.rc-form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.rc-pick-search { width: 100%; padding: 10px 12px; margin-bottom: 8px; }
.rc-pick-group { font-size: 12px; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); margin: 14px 0 4px; }
.rc-pick-row {
    display: flex; flex-direction: column; align-items: flex-start; gap: 1px;
    width: 100%;
    padding: 10px 4px;
    min-height: 48px;
    background: none;
    border: none;
    border-bottom: 1px solid var(--line);
    text-align: left;
    cursor: pointer;
}
.rc-pick-row:hover { background: var(--bg); }
.rc-pick-name { font-size: 16px; font-weight: 550; color: var(--ink); }
.rc-pick-meta { font-size: 12px; color: var(--muted); }
.rc-slot-day { padding: 10px 0; border-bottom: 1px solid var(--line); }
.rc-slot-day-name { font-weight: 650; margin-bottom: 8px; }

.rc-shop-summary { font-size: 13px; color: var(--muted); margin: 0 0 8px; }
.rc-shop-summary:empty { display: none; }
.rc-shop-count { white-space: nowrap; margin-left: 4px; color: var(--ink); }
.rc-shop-warn { margin-top: 6px; padding: 8px 10px; border-radius: 8px; background: #fff7e8; color: #7a5317; }
.rc-shop-item {
    display: flex !important;
    align-items: flex-start;
    gap: 12px;
    cursor: pointer;
    padding: 11px 2px !important;
}
.rc-shop-item input[type="checkbox"] { width: 22px; height: 22px; margin: 0; flex-shrink: 0; }
.rc-shop-text { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.rc-shop-item .shopping-item-sources { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rc-shop-item.is-checked .shopping-item-name { text-decoration: line-through; color: var(--muted); }
.rc-shop-item.is-checked .shopping-item-quantity, .rc-shop-item.is-checked .shopping-item-sources { opacity: 0.6; }
.rc-got-header { display: flex; align-items: center; justify-content: space-between; margin-top: 28px !important; }
.rc-link-btn { background: none; border: none; color: var(--accent-ink); font-size: 13px; font-weight: 600; text-transform: none; letter-spacing: 0; cursor: pointer; padding: 4px; }
.rc-shop-done { text-align: center; padding: 16px 0; }
.rc-hint a { color: var(--accent-ink); font-weight: 600; text-decoration: none; }

@media (max-width: 720px) {
    .rc-form-grid { grid-template-columns: 1fr; gap: 0; }
    .rc-picker-body .rc-sheet-actions { margin-left: -16px; margin-right: -16px; }
}
/* Touch screens get tap controls, so the drag palette is not needed */
@media (hover: none) {
    .rc-meal-types { display: none; }
}

/* ---------- Empty states, toasts, modals ---------- */
.empty-state { padding: 32px 12px; color: var(--muted); }
.empty-state i { font-size: 32px; color: var(--line-strong); margin-bottom: 10px; display: block; }

.rc-toast {
    position: fixed;
    left: 50%;
    bottom: 24px;
    transform: translateX(-50%);
    z-index: 3000;
    max-width: min(520px, calc(100vw - 32px));
    width: max-content;
    margin: 0 !important;
    padding: 12px 16px !important;
    border-radius: 12px !important;
    font-size: 14px;
    line-height: 1.4;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.18);
    cursor: pointer;
    animation: rc-toast-in 0.2s ease-out;
}
.rc-toast.success-message { background: var(--ink); color: #fff; }
@keyframes rc-toast-in { from { opacity: 0; transform: translate(-50%, 8px); } to { opacity: 1; transform: translate(-50%, 0); } }

.modal-overlay { z-index: 2000; background: rgba(20, 16, 12, 0.38); }
.modal-content {
    border-radius: var(--radius);
    padding: 20px;
    max-height: 85vh;
    max-height: 85dvh;
    overscroll-behavior: contain;
}
.modal-header { border-bottom: 1px solid var(--line); padding-bottom: 12px; margin-bottom: 14px; }
.modal-title { font-size: 19px; font-weight: 650; }

/* Drag-and-drop hints only make sense with a mouse */
@media (hover: none) {
    .rc-hint-desktop { display: none; }
}

/* ---------- Phones ---------- */
@media (max-width: 720px) {
    /* No blur here: a backdrop-filter would trap the fixed bottom tab bar inside the header */
    .rc-appbar { -webkit-backdrop-filter: none; backdrop-filter: none; background: var(--surface); }
    .rc-appbar-inner { padding: 0 12px; }
    #recipeSortSelect { display: none; }
    .rc-appbar-title { text-align: center; margin-right: 28px; }

    /* Tabs move to a bottom bar, like a native app */
    .rc-workflow-tabs {
        position: fixed;
        top: auto; left: 0; right: 0; bottom: 0;
        z-index: 1000;
        display: grid;
        grid-template-columns: repeat(3, 1fr);
        gap: 0;
        border: none;
        border-top: 1px solid var(--line);
        border-radius: 0;
        background: rgba(255, 255, 255, 0.96);
        -webkit-backdrop-filter: saturate(180%) blur(12px);
        backdrop-filter: saturate(180%) blur(12px);
        padding: 6px 8px calc(6px + env(safe-area-inset-bottom));
    }
    .rc-tab {
        flex-direction: column;
        justify-content: center;
        gap: 3px;
        padding: 6px 0;
        font-size: 11px;
        border-radius: 10px;
    }
    .rc-tab i { font-size: 19px; }
    .rc-tab.active { background: none; box-shadow: none; color: var(--accent-ink); }
    .rc-tab .tab-badge { position: absolute; top: 2px; left: calc(50% + 8px); }

    .rc-section { padding: 12px 12px calc(var(--tabbar-h) + 32px + env(safe-area-inset-bottom)); }
    .rc-card { padding: 16px; border-radius: 12px; }
    .rc-card h2 { font-size: 24px; }
    .rc-hide-narrow { display: none; }

    .recipe-item { flex-direction: column; align-items: stretch; gap: 0; }
    .recipe-row-summary > div > div:last-child { flex-wrap: nowrap !important; overflow: hidden; -webkit-mask-image: linear-gradient(to right, #000 82%, transparent); mask-image: linear-gradient(to right, #000 82%, transparent); }
    .recipe-row-summary > div > div:last-child > span:not(.recipe-tag) { white-space: nowrap; }
    /* Narrow rows: servings and tags matter more than the ingredient count */
    .recipe-row-summary > div > div:last-child > span:first-child:not(.recipe-tag) { display: none; }
    .recipe-row-detail { margin-left: 0; }

    #dayPlannerContainer { grid-template-columns: 1fr; }

    /* Sheets and modals rise from the bottom */
    .rc-sheet, .modal-overlay { padding: 0; align-items: flex-end; }
    .rc-sheet-panel, .modal-content {
        max-width: none;
        width: 100%;
        border-radius: 18px 18px 0 0;
        max-height: calc(100vh - 24px);
        max-height: calc(100dvh - 24px);
        animation: rc-sheet-up 0.22s ease-out;
    }
    .rc-sheet-panel { padding: 0 16px; }
    .rc-sheet-actions { margin: 8px -16px 0; padding-left: 16px; padding-right: 16px; }
    .rc-sheet-actions .btn, #editRecipeActions { flex: 1; }
    #editRecipeActions .btn { flex: 1; }
    .modal-content { padding: 16px 16px calc(16px + env(safe-area-inset-bottom)); }

    .rc-toast { bottom: calc(var(--tabbar-h) + 16px + env(safe-area-inset-bottom)); }
}
@keyframes rc-sheet-up { from { transform: translateY(24px); opacity: 0.6; } to { transform: none; opacity: 1; } }

/* Running as an installed app: no back-to-site link needed */
@media (display-mode: standalone) {
    .rc-appbar-back { display: none; }
    .rc-appbar-title { margin-right: 0; }
}

@media print {
    .rc-appbar, .rc-workflow-tabs, .rc-sheet, .rc-toast { display: none !important; }
}

/* ---------- Trip mode (backpacking) ---------- */
html:not(.rc-trip-mode) .rc-trip-only { display: none !important; }
html.rc-trip-mode .rc-event-only { display: none !important; }
html.rc-trip-mode {
    --bg: #f6f8f5;
    --accent: #3d7a5a;
    --accent-ink: #2f6247;
    --accent-soft: #e9f3ec;
    --active-ink: #2f6247;
}
.rc-trip-input { width: 76px; text-align: center; padding: 6px 8px; }
.rc-plan-bar .rc-headcount { white-space: nowrap; }

.rc-density { font-weight: 650; }
.rc-density.is-great { color: #2f6247; }
.rc-density.is-good { color: #6b6a1f; }
.rc-density.is-heavy { color: #a35a1c; }
.rc-row-kcal {
    font-size: 12px;
    padding: 1px 8px;
    border-radius: 999px;
    background: var(--accent-soft);
    white-space: nowrap;
    flex-shrink: 0;
}

.rc-trail-panel {
    border: 1px solid var(--line);
    background: var(--bg);
    border-radius: var(--radius-sm);
    padding: 12px;
    margin: 4px 0 16px;
}
.rc-trail-panel > .rc-hint:only-child { margin: 0; }
.rc-trail-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; flex-wrap: wrap; font-weight: 700; font-size: 13px; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); margin-bottom: 8px; }
.rc-trail-head .rc-density { text-transform: none; letter-spacing: 0; font-size: 14px; }
.rc-trail-totals { display: grid; gap: 4px; margin-bottom: 8px; }
.rc-trail-totals > div { display: flex; justify-content: space-between; gap: 8px; font-size: 14px; }
.rc-trail-totals span { color: var(--muted); }
.rc-trail-rows { border-top: 1px solid var(--line); }
.rc-trail-row { display: flex; align-items: center; gap: 8px; padding: 7px 0; border-bottom: 1px solid var(--line); font-size: 14px; }
.rc-trail-name { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.rc-trail-name small { font-size: 11px; color: var(--muted); }
.rc-trail-vals { text-align: right; color: var(--ink); white-space: nowrap; font-size: 13px; }
.rc-trail-row.is-water .rc-trail-vals { color: #2d6a8a; }
.rc-trail-missing { color: #a35a1c; font-weight: 600; }
.rc-trail-edit { background: none; border: none; color: var(--muted); padding: 6px; cursor: pointer; font-size: 12px; }
.rc-trail-edit:hover { color: var(--ink); }
.rc-trail-warn { font-size: 13px; padding: 8px 10px; border-radius: 8px; background: #fff7e8; color: #7a5317; margin: 6px 0 8px; }
.rc-trail-note { margin: 8px 0 0; font-size: 12px; }
.rc-food-editor { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 8px; padding: 8px 0 10px; border-bottom: 1px solid var(--line); }
.rc-food-editor[hidden] { display: none; }
.rc-food-editor label { display: flex; flex-direction: column; gap: 3px; font-size: 12px; color: var(--muted); }
.rc-food-editor input { width: 110px; padding: 6px 8px; }
.rc-food-editor .rc-hint { flex-basis: 100%; margin: 0; font-size: 12px; }

.rc-trip-summary:empty { display: none; }
.rc-trip-summary { margin-bottom: 14px; }
.rc-trip-stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-bottom: 8px; }
.rc-trip-stats > div { background: var(--bg); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 10px; display: flex; flex-direction: column; gap: 2px; }
.rc-trip-stats span { font-size: 12px; color: var(--muted); }
.rc-trip-stats strong { font-size: 17px; }
.rc-trip-stats strong small { font-size: 12px; font-weight: 500; color: var(--muted); }
.rc-trip-stats > div > small { font-size: 11px; color: var(--muted); }
.rc-trip-summary .rc-hint { font-size: 12px; margin: 4px 0; }

.rc-day-trip { margin: -4px 0 10px; font-size: 13px; color: var(--muted); }
.rc-day-trip strong { color: var(--ink); }
.rc-bar { height: 6px; border-radius: 999px; background: var(--line); overflow: hidden; margin-top: 5px; }
.rc-bar span { display: block; height: 100%; background: #c9a34a; border-radius: 999px; transition: width 0.2s; }
.rc-bar span.is-full { background: var(--accent); }

.rc-segmented { display: inline-flex; background: var(--bg); border: 1px solid var(--line); border-radius: 999px; padding: 3px; margin-bottom: 10px; }
.rc-segmented button { border: none; background: none; padding: 7px 16px; border-radius: 999px; font-size: 14px; font-weight: 600; color: var(--muted); cursor: pointer; }
.rc-segmented button.active { background: var(--surface); color: var(--ink); box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08); }
.rc-pack-day { margin-bottom: 8px; }
.rc-pack-row { display: flex; align-items: baseline; gap: 10px; padding: 9px 2px; border-bottom: 1px solid var(--line); font-size: 15px; }
.rc-pack-meal { width: 76px; flex-shrink: 0; font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); }
.rc-pack-name { flex: 1; min-width: 0; }
.rc-pack-vals { white-space: nowrap; color: var(--ink); font-size: 14px; }
.rc-pack-vals small { color: var(--muted); }

@media (max-width: 720px) {
    .rc-trip-stats { grid-template-columns: 1fr 1fr; }
    .rc-food-editor input { width: 96px; }
}
