/* Thanksgiving planner (/thanksgiving): static/js/thanksgiving-builder.js.
 *
 * Styled after the recipe gallery modal in MAIN_PAGE. Dish tiles reuse its
 * .recipe-gallery-modal-grid / .gallery-tile / .tile-meta-chip rules; the
 * rest reads the shell's theme tokens (--modal-bg, --bg-surface,
 * --text-primary, --brand-primary, --border-default, ...) so the light,
 * dark and cookbook themes all work. Plain CSS on purpose: Tailwind classes
 * would need a rebuild of tailwind.min.css.
 *
 * Fall palette: the planner sets its own --tg-* tokens on .tg-overlay (a
 * harvest light theme; a dark-roast one under html.dark) and maps the
 * shell tokens it reads onto them, so the rules below and the gallery
 * rules it borrows all turn autumnal inside the planner only. Text pairs
 * are AA (4.5:1) or better; see the commit for the measured ratios. */

.tg-overlay {
    /* Harvest (light; the cookbook theme uses it too) */
    --tg-bg: #fdf6ec;            /* parchment: the sheet */
    --tg-surface: #fffaf3;       /* cards, inputs */
    --tg-panel: #f9eddb;         /* plan panel */
    --tg-header-bg: #f8e7cd;     /* header + controls band */
    --tg-hover: #f4e2c6;
    --tg-border: #ead6b8;
    --tg-input-border: #a87a4a;
    --tg-text: #451a03;          /* dark walnut */
    --tg-text-2: #78350f;        /* chestnut */
    --tg-muted: #7c4a1e;
    --tg-faint: #8f5f34;
    --tg-heading: #9a3412;       /* rust: section, card and list headings */
    --tg-accent: #c2410c;        /* pumpkin: icons, counts */
    --tg-accent-soft: rgba(194, 65, 12, 0.10);
    --tg-primary: #9a3412;       /* Cook this plan, search, picked check */
    --tg-primary-hover: #7c2d12;
    --tg-on-primary: #ffffff;
    --tg-chip-on: #c2410c;       /* a diet filter that is on */
    --tg-on-chip: #ffffff;
    --tg-ring: rgba(217, 119, 6, 0.38);   /* harvest gold halo on a pick */
    --tg-focus: #b45309;
    --tg-gold: #d97706;
    --tg-band: linear-gradient(90deg, #9a3412, #c2410c 30%, #d97706 60%, #f59e0b 75%, #9f1239);
    --tg-warn-bg: #fcefdc;
    --tg-warn-border: #f0c690;
    --tg-warn-text: #451a03;
    --tg-cranberry: #9f1239;
    --tg-vegan: #4d7c0f;         /* sage/olive */
    --tg-dairy-free: #6b2f5b;    /* plum */
    --tg-gluten-free: #7c5a0b;   /* wheat */
    --tg-cook-a: #c2410c;        /* pumpkin: Cook A (white ink 5.2:1) */
    --tg-cook-b: #4d7c0f;        /* olive: Cook B (white ink 5.0:1) */
    --tg-cook-c: #6b2f5b;        /* plum: Cook C */
    --tg-turkey-disc: #fde4c2;
    /* The shell tokens, read by the rules below and the gallery's. */
    --modal-bg: var(--tg-bg);
    --bg-surface: var(--tg-surface);
    --bg-elevated: var(--tg-panel);
    --bg-main: var(--tg-panel);
    --bg-raised: var(--tg-hover);
    --bg-hover: var(--tg-hover);
    --text-primary: var(--tg-text);
    --text-secondary: var(--tg-text-2);
    --text-muted: var(--tg-muted);
    --text-faint: var(--tg-faint);
    --border-default: var(--tg-border);
    --input-bg: var(--tg-surface);
    --input-border: var(--tg-input-border);
    --brand-primary: var(--tg-primary);
    --brand-primary-hover: var(--tg-primary-hover);
    --chat-system-bg: var(--tg-warn-bg);
    --chat-system-text: var(--tg-warn-text);
    --shadow-color: rgba(69, 26, 3, 0.18);
    display: none;
    position: fixed;
    inset: 0;
    /* Above the recipe gallery (1000) and the mobile tab bar (1100); below
       the login modal (13000) and the toast (9999), which the gated
       actions open on top of it. */
    z-index: 1150;
    background: var(--modal-overlay);
    align-items: center;
    justify-content: center;
    padding: 2vh 2vw;
}
.tg-overlay.active { display: flex; }
/* A new account's onboarding (interests) modal opens on top of the builder
   (it sits at 1001 elsewhere), still below the login modal. */
body.tg-open .interests-modal-overlay { z-index: 1200; }
/* Dark roast */
html.dark .tg-overlay {
    --tg-bg: #1c1410;
    --tg-surface: #261b14;
    --tg-panel: #211711;
    --tg-header-bg: #2a1d15;
    --tg-hover: #352519;
    --tg-border: #43301f;
    --tg-input-border: #8f6a48;
    --tg-text: #fbeedd;
    --tg-text-2: #ecd5b8;
    --tg-muted: #c9a47f;
    --tg-faint: #b08c69;
    --tg-heading: #fbbf24;
    --tg-accent: #f59e0b;
    --tg-accent-soft: rgba(245, 158, 11, 0.14);
    --tg-primary: #f59e0b;
    --tg-primary-hover: #fbbf24;
    --tg-on-primary: #1c1410;
    --tg-chip-on: #f59e0b;
    --tg-on-chip: #1c1410;
    --tg-ring: rgba(245, 158, 11, 0.40);
    --tg-focus: #fbbf24;
    --tg-gold: #f59e0b;
    --tg-band: linear-gradient(90deg, #9a3412, #c2410c 30%, #d97706 60%, #f59e0b 75%, #be123c);
    --tg-warn-bg: #2c1a14;
    --tg-warn-border: #7f1d1d;
    --tg-warn-text: #fbeedd;
    --tg-cranberry: #f43f5e;
    --tg-vegan: #4d7c0f;
    --tg-dairy-free: #7e3a6e;
    --tg-gluten-free: #7c5a0b;
    --tg-turkey-disc: #f3dfc1;
    --shadow-color: rgba(0, 0, 0, 0.5);
}
/* The turkey's walnut body needs a hairline of cream on a dark-roast ground. */
html.dark .tg-turkey-svg { filter: drop-shadow(0 0 0.5px #fde7c3) drop-shadow(0 0 0.5px #fde7c3); }

/* The turkey mark (static/images/turkey.svg inlined), sized and aligned
   like a Font Awesome glyph so swapping it in shifts nothing. */
.tg-turkey-svg {
    display: inline-block;
    width: 1em;
    height: 1em;
    vertical-align: -0.125em;
    overflow: visible;
    flex: none;
}
body.tg-open { overflow: hidden; }

.tg-modal {
    position: relative;
    display: flex;
    flex-direction: column;
    width: 100%;
    max-width: 1600px;
    height: 100%;
    max-height: 96vh;
    background: var(--modal-bg);
    color: var(--text-primary);
    border-radius: 12px;
    box-shadow: 0 20px 60px var(--shadow-color);
    overflow: hidden;
}

/* --- Header + controls ---------------------------------------------------- */
.tg-header {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px 12px;
    padding: 18px 22px 10px;
    /* A thin harvest band along the top, then the warm header ground. */
    background: var(--tg-band) top left / 100% 4px no-repeat, var(--tg-header-bg);
}
.tg-header h2 {
    flex: 1;
    margin: 0;
    font-size: 18px;
    font-weight: 700;
    color: var(--tg-heading);
    min-width: 0;
}
.tg-header h2 i { color: var(--tg-accent); margin-right: 4px; }
.tg-title-icon { display: inline-block; margin-right: 4px; color: var(--tg-accent); }
.tg-subtitle {
    display: block;
    font-size: 12px;
    font-weight: 500;
    color: var(--text-muted);
    margin-top: 2px;
}
.tg-close {
    position: relative;
    flex: none;
    background: none;
    border: none;
    padding: 0;
    /* The × is drawn below, not the text glyph, which sits low and left in
       most fonts and looks off-centre inside the focus ring. */
    font-size: 0;
    color: var(--text-muted);
    width: 40px;
    height: 40px;
    cursor: pointer;
    border-radius: 8px;
}
.tg-close::before,
.tg-close::after {
    content: "";
    position: absolute;
    top: 50%;
    left: 50%;
    width: 18px;
    height: 2px;
    border-radius: 1px;
    background: currentColor;
}
.tg-close::before { transform: translate(-50%, -50%) rotate(45deg); }
.tg-close::after { transform: translate(-50%, -50%) rotate(-45deg); }
.tg-close:hover { background: var(--bg-hover); color: var(--text-primary); }
.tg-close:focus-visible, .tg-picker-back:focus-visible, .tg-slot-more:focus-visible, .tg-stepper button:focus-visible, .tg-kitchen > summary:focus-visible { outline: 2px solid var(--tg-focus); outline-offset: 2px; }

/* Diet filters: two independent toggle chips (Vegan, Dairy-free), off by
   default. A chip that is on is filled and shows a check mark. */
.tg-filters {
    display: inline-flex;
    flex: none;
    align-items: center;
    gap: 6px;
}
.tg-filters-label {
    font-size: 13px;
    font-weight: 600;
    color: var(--tg-muted);
    white-space: nowrap;
}
.tg-filter {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    min-height: 32px;
    padding: 4px 12px;
    border: 1px solid var(--border-default);
    border-radius: 999px;
    background: var(--bg-surface);
    color: var(--text-secondary);
    font: inherit;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
}
.tg-filter:hover { color: var(--text-primary); background: var(--bg-hover); }
.tg-filter .tg-filter-check { display: none; font-size: 11px; }
.tg-filter[aria-pressed="true"] {
    background: var(--tg-chip-on);
    border-color: var(--tg-chip-on);
    color: var(--tg-on-chip);
}
.tg-filter[aria-pressed="true"] .tg-filter-check { display: inline-block; }
.tg-filter:focus-visible { outline: 2px solid var(--tg-focus); outline-offset: 2px; }

.tg-controls {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: 10px 16px;
    padding: 0 22px 14px;
    border-bottom: 1px solid var(--border-default);
    background: var(--tg-header-bg);
}
.tg-field { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.tg-field > label,
.tg-field > .tg-label {
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--text-muted);
}
.tg-field-serve { flex: 0 1 230px; }
.tg-input,
.tg-select {
    height: 38px;
    border: 1px solid var(--input-border);
    background: var(--input-bg);
    color: var(--text-primary);
    border-radius: 8px;
    padding: 0 10px;
    font-size: 14px;
    font-family: inherit;
    min-width: 0;
    width: 100%;
    color-scheme: light;
}
html.dark .tg-input, html.dark .tg-select { color-scheme: dark; }
.tg-input:focus, .tg-select:focus { outline: none; border-color: var(--tg-focus); box-shadow: 0 0 0 2px var(--tg-ring); }

.tg-stepper {
    display: inline-flex;
    align-items: stretch;
    height: 38px;
    border: 1px solid var(--input-border);
    border-radius: 8px;
    background: var(--input-bg);
    overflow: hidden;
}
.tg-stepper button {
    width: 38px;
    border: none;
    background: none;
    color: var(--text-secondary);
    font-size: 13px;
    cursor: pointer;
}
.tg-stepper button:hover { background: var(--bg-hover); color: var(--text-primary); }
.tg-stepper button:disabled { opacity: 0.35; cursor: default; background: none; }
.tg-stepper output {
    min-width: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 15px;
    font-variant-numeric: tabular-nums;
    border-left: 1px solid var(--border-default);
    border-right: 1px solid var(--border-default);
}

.tg-kitchen { position: relative; }
.tg-kitchen { max-width: 100%; min-width: 0; }
.tg-kitchen > summary {
    list-style: none;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    box-sizing: border-box;
    max-width: 100%;
    min-width: 0;
    height: 38px;
    padding: 0 12px;
    border: 1px solid var(--input-border);
    border-radius: 8px;
    background: var(--input-bg);
    color: var(--text-primary);
    font-size: 13px;
    cursor: pointer;
    white-space: nowrap;
}
.tg-kitchen > summary::-webkit-details-marker { display: none; }
/* The summary text gives way (ellipsis) before the box overflows: two ovens
   and every appliance is longer than a phone is wide. */
.tg-kitchen > summary > #tg-kitchen-summary {
    flex: 0 1 auto;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
}
.tg-kitchen > summary > i { flex: none; }
.tg-kitchen > summary i.fa-chevron-down { font-size: 10px; color: var(--text-muted); transition: transform 0.15s; }
.tg-kitchen[open] > summary i.fa-chevron-down { transform: rotate(180deg); }
.tg-kitchen-body {
    position: absolute;
    top: calc(100% + 6px);
    left: 0;
    z-index: 4;
    display: grid;
    grid-template-columns: repeat(2, minmax(120px, 1fr));
    gap: 10px 12px;
    padding: 14px;
    width: max-content;
    max-width: calc(100vw - 32px);
    background: var(--modal-bg);
    border: 1px solid var(--border-default);
    border-radius: 10px;
    box-shadow: 0 10px 30px var(--shadow-color);
}

.tg-check {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    height: 38px;
    font-size: 13px;
    color: var(--text-secondary);
    cursor: pointer;
    white-space: nowrap;
}
.tg-check input { width: 16px; height: 16px; accent-color: var(--tg-accent); }

/* The kitchen picker's small appliances: a row of checkboxes under the
   ovens, racks, burners and cooks. */
.tg-appliances {
    grid-column: 1 / -1;
    display: flex;
    flex-wrap: wrap;
    gap: 2px 14px;
    margin: 0;
    padding: 8px 0 0;
    border: none;
    border-top: 1px dashed var(--border-default);
    min-width: 0;
}
.tg-appliances legend {
    float: left;
    width: 100%;
    padding: 0;
    margin-bottom: 2px;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--text-muted);
}
.tg-appliances .tg-check { height: 32px; }
.tg-appliances .tg-check i { color: var(--tg-accent); font-size: 12px; width: 14px; text-align: center; }

/* --- Body: dishes on the left, the plan on the right ----------------------- */
.tg-body {
    flex: 1;
    min-height: 0;
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(320px, 420px);
}
.tg-main {
    overflow-y: auto;
    padding: 16px 22px 24px;
    min-width: 0;
}
.tg-panel {
    overflow-y: auto;
    padding: 16px 18px 24px;
    border-left: 1px solid var(--border-default);
    background: var(--bg-elevated);
    min-width: 0;
}

.tg-section + .tg-section { margin-top: 18px; }
.tg-section-title {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 0 0 10px;
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    color: var(--tg-heading);
}
.tg-section-title i, .tg-section-title .tg-turkey-svg { color: var(--tg-accent); font-size: 13px; }
.tg-section-title .tg-turkey-svg { font-size: 15px; }
.tg-section-count { font-weight: 600; color: var(--text-faint); text-transform: none; letter-spacing: 0; }

/* One row per dish: its name, the planned-oven chip, "Search more…", and
   a sideways strip of catalog recipe tiles with photos; a tile is a toggle
   (check mark and outline when picked). The strip scrolls by itself; the
   page never does. When the choices could not be loaded a row is a chip
   with the dish name alone (.tg-slot-plain), itself a toggle. */
.tg-slot {
    min-width: 0;
    padding: 10px 0 12px;
    border-top: 1px solid var(--border-default);
}
.tg-section-title + .tg-slot { border-top: none; padding-top: 0; }
.tg-slot-plain { padding: 4px 0; }
.tg-slot-plain .tg-slot-head { margin-bottom: 0; }
.tg-slot-head {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px 10px;
    margin-bottom: 8px;
    min-width: 0;
}
.tg-slot-title {
    display: inline-flex;
    align-items: baseline;
    gap: 8px;
    min-width: 0;
    max-width: 100%;
    min-height: 32px;
    padding-top: 6px;
    color: var(--text-primary);
    font-size: 14px;
    font-weight: 700;
}
.tg-slot-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tg-slot-count {
    flex: none;
    font-size: 11px;
    font-weight: 600;
    color: var(--tg-heading);
}
/* The dish name as a toggle, when there are no recipe tiles to pick. */
.tg-dish-chip {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    min-height: 36px;
    min-width: 0;
    max-width: 100%;
    padding: 4px 14px 4px 10px;
    border: 2px solid var(--border-default);
    border-radius: 999px;
    background: var(--bg-surface);
    color: var(--text-secondary);
    font: inherit;
    font-size: 14px;
    font-weight: 700;
    text-align: left;
    cursor: pointer;
}
.tg-dish-chip:hover { background: var(--bg-hover); color: var(--text-primary); }
.tg-dish-chip .tg-dish-check {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: none;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    border: 2px solid var(--border-default);
    color: transparent;
    font-size: 10px;
}
.tg-dish-chip[aria-pressed="true"] {
    border-color: var(--tg-primary);
    color: var(--text-primary);
    box-shadow: 0 0 0 3px var(--tg-ring);
}
.tg-dish-chip[aria-pressed="true"] .tg-dish-check {
    border-color: var(--tg-primary);
    background: var(--tg-primary);
    color: var(--tg-on-primary);
}
.tg-dish-chip:focus-visible { outline: 2px solid var(--tg-focus); outline-offset: 2px; }
.tg-slot-chips { display: inline-flex; flex-wrap: wrap; gap: 4px; min-width: 0; }
.tg-slot-chip {
    display: inline-flex;
    flex-wrap: wrap;
    align-items: center;
    padding: 2px 8px;
    border-radius: 999px;
    background: var(--tg-accent-soft);
    color: var(--text-secondary);
    font-size: 11px;
    font-weight: 600;
    line-height: 1.5;
}
.tg-slot-chip:empty { display: none; }
.tg-slot-chip .tg-chip-part { white-space: nowrap; }
.tg-slot-chip .tile-meta-sep { margin: 0 5px; opacity: 0.55; }
.tg-slot-chip.tg-chip-ahead { gap: 4px; }
.tg-slot-more {
    margin-left: auto;
    flex: none;
    min-height: 32px;
    padding: 4px 10px;
    border: 1px solid var(--border-default);
    border-radius: 999px;
    background: none;
    color: var(--text-secondary);
    font: inherit;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
}
.tg-slot-more:hover { background: var(--bg-hover); color: var(--text-primary); }
.tg-slot-off:not(.tg-slot-plain) .tg-slot-title { color: var(--text-muted); }
.tg-slot-off .tg-slot-chips { display: none; }

.tg-overlay .recipe-gallery-modal-grid.tg-strip {
    display: grid;
    grid-auto-flow: column;
    grid-template-columns: none;
    grid-auto-columns: 168px;
    grid-auto-rows: 132px;
    gap: 10px;
    overflow-x: auto;
    overflow-y: hidden;
    overscroll-behavior-x: contain;
    scroll-snap-type: x proximity;
    flex: none;
    min-height: 0;
    min-width: 0;
    max-width: 100%;
    padding: 4px 2px 8px;
}
.tg-strip .gallery-tile { scroll-snap-align: start; }
.tg-strip .gallery-tile:focus-visible {
    outline: 3px solid var(--tg-focus);
    outline-offset: 2px;
}
/* A picked tile: rust border, harvest-gold halo, rust check. */
.tg-overlay .recipe-gallery-modal-grid .gallery-tile.selected {
    border-color: var(--tg-primary);
    box-shadow: 0 0 0 4px var(--tg-ring), 0 4px 10px rgba(69, 26, 3, 0.22);
}
.tg-overlay .recipe-gallery-modal-grid .gallery-tile .selected-badge {
    background: var(--tg-primary);
    color: var(--tg-on-primary);
}
.tg-overlay .search-input-row button { background: var(--tg-primary); color: var(--tg-on-primary); }
.tg-overlay .search-input-row button:hover { background: var(--tg-primary-hover); }
.tg-overlay .search-input-row input:focus { border-color: var(--tg-focus); }
.tg-overlay .search-input-row button:focus-visible,
.tg-overlay .search-input-row input:focus-visible { outline: 2px solid var(--tg-focus); outline-offset: 2px; }
.tg-overlay .tg-strip .gallery-tile .tile-caption {
    white-space: normal;
    padding: 24px 9px 7px;
}
.tg-tile-name {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    font-size: 12.5px;
    line-height: 1.25;
}
.tg-tile-tag {
    display: block;
    margin-top: 2px;
    font-size: 10.5px;
    font-weight: 600;
    opacity: 0.85;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
/* Which list vouches for a tile (with no filter on): a small label on the
   photo, top left (the check mark is top right). */
.tg-tile-badge {
    position: absolute;
    top: 8px;
    left: 8px;
    z-index: 1;
    max-width: calc(100% - 50px);
    padding: 2px 7px;
    border-radius: 999px;
    font-size: 10.5px;
    font-weight: 700;
    line-height: 1.5;
    letter-spacing: 0.01em;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    color: #fff;
    background: var(--tg-vegan);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}
.tg-tile-badge.tg-badge-dairy-free { background: var(--tg-dairy-free); }
.tg-tile-badge.tg-badge-gluten-free { background: var(--tg-gluten-free); }
.tg-strip .tg-skel {
    cursor: default;
    background: linear-gradient(90deg, var(--bg-surface), var(--bg-hover), var(--bg-surface));
    background-size: 200% 100%;
    animation: tgShimmer 1.2s linear infinite;
}
.tg-strip .tg-skel:hover { transform: none; box-shadow: none; }
@keyframes tgShimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }
.tg-choices-note {
    margin: 0 0 12px;
    padding: 8px 12px;
    border-radius: 8px;
    background: var(--chat-system-bg);
    color: var(--chat-system-text);
    font-size: 13px;
}
.tg-choices-note[hidden], .tg-choices-note:empty { display: none; }
/* While the rows load: what is happening, not a silent skeleton. */
.tg-choices-note.tg-choices-loading {
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--tg-accent-soft);
    color: var(--text-primary);
    border: 1px solid var(--border-default);
    font-weight: 600;
}
.tg-choices-note.tg-choices-loading i { color: var(--tg-accent); flex: none; }

/* Placeholder while a photo resolves (or when none does): a course icon on
   an autumn gradient. */
.tg-tile-ph {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    padding-bottom: 26px;
    font-size: 40px;
    color: rgba(255, 255, 255, 0.92);
    background: linear-gradient(135deg, #d97706, #9a3412);
}
/* The main is the turkey mark, which reads on a light harvest ground. */
.tg-tile-ph[data-course="main"]    { background: linear-gradient(135deg, #fdecd2, #f6c98b); }
/* A glyph there instead (the vegan menu's leaf) is rust, not white. */
.tg-tile-ph[data-course="main"] i  { color: #9a3412; }
.tg-tile-ph[data-course="side"]    { background: linear-gradient(135deg, #4d7c0f, #3f2a12); }
.tg-tile-ph[data-course="bread"]   { background: linear-gradient(135deg, #ca8a04, #78350f); }
.tg-tile-ph[data-course="dessert"] { background: linear-gradient(135deg, #ea580c, #7c2d12); }
.tg-tile-ph[data-course="sauce"]   { background: linear-gradient(135deg, #be123c, #4c0519); }
.tg-tile-ph[data-course="starter"] { background: linear-gradient(135deg, #9d4b73, #4a1d3a); }
.tg-tile-ph[data-course="drink"]   { background: linear-gradient(135deg, #b91c1c, #7f1d1d); }
.tg-tile-ph.tg-loading i, .tg-tile-ph.tg-loading svg { animation: tgPulse 1.4s ease-in-out infinite; }

/* A tile's style ("Smoked", "Pecan streusel"): a small kicker above the
   recipe name, only in rows with two or more styles. */
.tg-tile-style {
    display: block;
    margin-bottom: 1px;
    font-size: 11px;
    font-weight: 700;
    line-height: 1.3;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    opacity: 0.82;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Turkey card: the method ("Deep-fried · Turkey fryer (outdoors)") and,
   for a smoker or fryer, the gear it takes. */
.tg-turkey-method {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 4px 10px;
    margin-bottom: 10px;
}
.tg-method-chip {
    display: inline-block;
    padding: 2px 10px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 700;
    color: var(--tg-heading);
    background: var(--tg-accent-soft);
}
.tg-method-chip i { margin-right: 2px; }
.tg-method-free { font-size: 12px; color: var(--text-muted); }
.tg-equipment { margin-top: 10px; }
.tg-equipment ul { margin: 4px 0 0; padding-left: 18px; list-style: disc; font-size: 12px; color: var(--text-secondary); }
.tg-equipment li + li { margin-top: 2px; }
.tg-gear { margin-bottom: 10px; }
@keyframes tgPulse { 0%, 100% { opacity: 0.55; } 50% { opacity: 1; } }

/* Turkey card: plan output, in the plan panel after the start / serve /
   guests boxes. A .tg-card with an accent edge; the four stats two by two. */
.tg-card.tg-turkey { border-left: 4px solid var(--tg-accent); }
.tg-card.tg-turkey > h4 { font-size: 14px; margin-bottom: 10px; }
.tg-turkey-icon {
    flex: none;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    color: var(--tg-accent);
    background: var(--tg-turkey-disc);
}
.tg-stats {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px 14px;
}
.tg-stats > div { min-width: 0; }
.tg-stat-label {
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--text-muted);
}
.tg-stat-value { font-size: 15px; font-weight: 700; font-variant-numeric: tabular-nums; }
.tg-stat-hint { font-size: 12px; color: var(--text-muted); }
.tg-turkey-birds {
    display: flex;
    flex-wrap: wrap;
    gap: 4px 16px;
    margin-top: 8px;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
}
/* Notes and gear fold under one summary, closed by default. */
.tg-turkey-more { margin-top: 10px; border-top: 1px solid var(--tg-accent-soft); padding-top: 8px; }
.tg-turkey-more > summary {
    cursor: pointer;
    font-size: 12px;
    font-weight: 700;
    color: var(--tg-heading);
    list-style-position: inside;
}
.tg-turkey-more > summary:focus-visible { outline: 2px solid var(--tg-accent); outline-offset: 2px; border-radius: 4px; }
.tg-notes { margin: 8px 0 0; padding-left: 18px; list-style: disc; font-size: 12px; color: var(--text-secondary); }
.tg-notes li + li { margin-top: 2px; }

/* --- Plan panel ------------------------------------------------------------ */
.tg-summary {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px;
    margin-bottom: 12px;
}
.tg-summary > div {
    padding: 10px 12px;
    border: 1px solid var(--border-default);
    border-radius: 10px;
    background: var(--bg-surface);
    min-width: 0;
}
.tg-summary .tg-stat-value { font-size: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tg-card {
    margin-bottom: 12px;
    padding: 12px 14px;
    border: 1px solid var(--border-default);
    border-radius: 10px;
    background: var(--bg-surface);
}
.tg-card > h4 {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 0 0 8px;
    font-size: 13px;
    font-weight: 700;
    color: var(--tg-heading);
}
.tg-card > h4 i { color: var(--tg-accent); width: 16px; text-align: center; }
.tg-card > details > summary { cursor: pointer; font-size: 13px; font-weight: 700; list-style-position: inside; }
/* The timeline is drawn on a warm cream sheet (PREVIEW_LOOK in
   thanksgiving-builder.js), kept light in every theme. */
/* The SVG is drawn at the box's width (thanksgiving-builder.js
   fillPreview) and scales with its viewBox, so the whole day fits. */
.tg-preview {
    background: #fffaf3;
    border: 1px solid var(--tg-border);
    border-radius: 8px;
    overflow: hidden;
}
.tg-preview svg { display: block; width: 100%; max-width: 100%; height: auto; }
.tg-empty { font-size: 13px; color: var(--text-muted); padding: 6px 0; }

.tg-warnings {
    margin-bottom: 12px;
    padding: 10px 12px;
    border-radius: 10px;
    background: var(--tg-warn-bg);
    color: var(--tg-warn-text);
    border: 1px solid var(--tg-warn-border);
    border-left: 4px solid var(--tg-cranberry);
    font-size: 13px;
}
.tg-warnings strong { display: flex; align-items: center; gap: 6px; margin-bottom: 4px; color: var(--tg-cranberry); }
.tg-warnings ul { margin: 0; padding-left: 18px; }
.tg-warnings li + li { margin-top: 3px; }

.tg-list { list-style: none; margin: 0; padding: 0; font-size: 13px; }
.tg-list li {
    display: grid;
    grid-template-columns: 76px minmax(0, 1fr);
    gap: 8px;
    padding: 6px 0;
    border-bottom: 1px dashed var(--border-default);
    color: var(--text-secondary);
}
.tg-list li:last-child { border-bottom: none; }
.tg-time {
    font-weight: 700;
    color: var(--text-primary);
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}
.tg-day + .tg-day { margin-top: 10px; }
.tg-day-title { font-size: 12px; font-weight: 700; color: var(--tg-heading); margin-bottom: 4px; letter-spacing: 0.02em; }
.tg-day .tg-list li { grid-template-columns: 18px minmax(0, 1fr); }
.tg-day .tg-list li::before { content: "\2610"; color: var(--text-faint); }
.tg-shop li { grid-template-columns: 104px minmax(0, 1fr); }

/* The checklist: the dish's category in bold, the recipe's name under it,
   and, split between cooks, each line's cook as a lettered badge. */
.tg-ck-text { min-width: 0; }
.tg-ck-dish { color: var(--text-primary); font-weight: 700; }
.tg-ck-recipe { display: block; margin-top: 1px; font-size: 11px; color: var(--text-muted); overflow-wrap: anywhere; }
.tg-checklist.tg-split li { grid-template-columns: 64px 22px minmax(0, 1fr); }
.tg-checklist.tg-split li:not(.tg-has-cook) .tg-ck-text { grid-column: 3; }
.tg-cook {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    border-radius: 6px;
    font-size: 11px;
    font-weight: 800;
    color: #fff;
    background: var(--tg-cook-c);
}
.tg-cook-a { background: var(--tg-cook-a); }
.tg-cook-b { background: var(--tg-cook-b); }
.tg-cook-switch { display: flex; flex-wrap: wrap; gap: 6px; margin: 2px 0 8px; }
.tg-cook-opt, .tg-seg {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    min-height: 32px;
    padding: 3px 10px;
    border: 1px solid var(--border-default);
    border-radius: 999px;
    background: var(--bg-surface);
    color: var(--text-secondary);
    font: inherit;
    font-size: 12.5px;
    font-weight: 600;
    cursor: pointer;
}
.tg-cook-opt:hover, .tg-seg:hover { background: var(--bg-hover); color: var(--text-primary); }
.tg-cook-opt.active, .tg-seg.active { border-color: var(--tg-chip-on); box-shadow: inset 0 0 0 1px var(--tg-chip-on); color: var(--text-primary); }
.tg-cook-opt:focus-visible, .tg-seg:focus-visible, .tg-jump:focus-visible, .tg-back-menu:focus-visible { outline: 2px solid var(--tg-focus); outline-offset: 2px; }
.tg-sr {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* Frozen or fresh: a two-way switch on the turkey card. */
.tg-fresh { display: inline-flex; gap: 0; margin: 8px 0 2px; }
.tg-fresh .tg-seg { border-radius: 0; }
.tg-fresh .tg-seg:first-child { border-radius: 999px 0 0 999px; }
.tg-fresh .tg-seg:last-child { border-radius: 0 999px 999px 0; margin-left: -1px; }
.tg-fresh .tg-seg.active { background: var(--tg-chip-on); color: var(--tg-on-chip); box-shadow: none; position: relative; }
.tg-shop .tg-time { white-space: normal; overflow-wrap: anywhere; }
.tg-shop .tg-shop-dishes { display: block; font-size: 11px; color: var(--text-muted); }
.tg-shop-aisle { margin-top: 10px; }
.tg-shop-est {
    display: inline-block;
    padding: 0 5px;
    border-radius: 6px;
    border: 1px solid var(--border-default);
    font-size: 10px;
    line-height: 15px;
    color: var(--text-muted);
}
.tg-shop-note { margin: 10px 0 0; font-size: 12px; color: var(--text-muted); }
.tg-shop-loading { display: flex; align-items: center; gap: 6px; }
@media (max-width: 420px) {
    .tg-shop li { grid-template-columns: 84px minmax(0, 1fr); }
}

/* --- Footer: the gallery's cart footer ------------------------------------ */
.tg-footer {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px 12px;
    padding: 12px 22px;
    border-top: 1px solid var(--border-default);
    background: var(--modal-bg);
}
.tg-footer-summary { flex: 1; min-width: 180px; }
.tg-footer-count { font-weight: 600; font-size: 14px; color: var(--text-primary); }
.tg-gate-note {
    display: none;
    align-items: center;
    gap: 6px;
    margin-top: 2px;
    font-size: 12px;
    color: var(--text-muted);
}
.tg-gate-note button {
    background: none;
    border: none;
    padding: 0;
    font: inherit;
    color: var(--tg-heading);
    text-decoration: underline;
    cursor: pointer;
}
.tg-overlay.tg-anon .tg-gate-note { display: flex; }
.tg-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.tg-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    min-height: 40px;
    padding: 8px 14px;
    border: 1px solid var(--border-default);
    border-radius: 8px;
    background: none;
    color: var(--text-secondary);
    font-size: 13px;
    font-family: inherit;
    cursor: pointer;
    white-space: nowrap;
}
.tg-btn:hover { background: var(--bg-hover); color: var(--text-primary); }
.tg-btn:focus-visible { outline: 2px solid var(--tg-focus); outline-offset: 2px; }
.tg-btn:disabled { opacity: 0.55; cursor: default; }
.tg-btn-primary {
    background: var(--tg-primary);
    border-color: var(--tg-primary);
    color: var(--tg-on-primary);
    font-weight: 600;
    font-size: 14px;
    padding: 10px 22px;
}
.tg-btn-primary:hover { background: var(--tg-primary-hover); border-color: var(--tg-primary-hover); color: var(--tg-on-primary); }
.tg-lock { display: none; font-size: 11px; opacity: 0.8; }
.tg-overlay.tg-anon .tg-lock { display: inline; }
.tg-share-result {
    display: flex;
    gap: 6px;
    width: 100%;
    align-items: center;
}
.tg-share-result[hidden] { display: none; }
.tg-share-result .tg-input { flex: 1; font-size: 13px; }
.tg-share-qr { flex: none; display: inline-flex; }
.tg-share-qr:empty { display: none; }
.tg-share-qr svg { width: 64px; height: 64px; border-radius: 4px; }

/* Phones: the plan sits under the whole menu. The footer's button jumps
   to it, and back (its label follows where the reader is); the plan opens
   with a "Back to menu" link. Hidden where menu and plan sit side by side. */
.tg-jump, .tg-back-menu { display: none; }
.tg-jump {
    align-items: center;
    gap: 6px;
    min-height: 36px;
    padding: 4px 12px;
    border: 1px solid var(--tg-chip-on);
    border-radius: 999px;
    background: var(--tg-accent-soft);
    color: var(--text-primary);
    font: inherit;
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
    white-space: nowrap;
}
.tg-jump i { color: var(--tg-accent); }
.tg-jump-menu { display: none; }
.tg-overlay.tg-in-plan .tg-jump-plan { display: none; }
.tg-overlay.tg-in-plan .tg-jump-menu { display: inline; }
.tg-back-menu {
    align-items: center;
    gap: 6px;
    margin: 0 0 10px;
    padding: 6px 0;
    border: none;
    background: none;
    color: var(--tg-heading);
    font: inherit;
    font-size: 13px;
    font-weight: 700;
    text-decoration: underline;
    cursor: pointer;
}

/* --- Recipe swap picker (a sheet over the builder) ------------------------- */
.tg-picker {
    position: absolute;
    inset: 0;
    z-index: 6;
    display: none;
    flex-direction: column;
    padding: 18px 22px 16px;
    background: var(--modal-bg);
}
.tg-picker.active { display: flex; }
.tg-picker-head { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; }
.tg-picker-head h3 { flex: 1; margin: 0; font-size: 17px; font-weight: 700; min-width: 0; }
.tg-picker-back {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 16px;
    min-width: 40px;
    min-height: 40px;
    border-radius: 8px;
    cursor: pointer;
}
.tg-picker-back:hover { background: var(--bg-hover); color: var(--text-primary); }
.tg-picker .search-input-row { margin-bottom: 10px; }
.tg-picker-status { font-size: 12px; color: var(--text-muted); margin-bottom: 8px; min-height: 16px; }
.tg-picker .recipe-gallery-modal-grid { flex: 1; }
.tg-picker .gallery-tile.tg-busy { opacity: 0.6; pointer-events: none; }

.tg-error {
    margin: 24px auto;
    max-width: 420px;
    text-align: center;
    color: var(--text-muted);
    font-size: 14px;
}

/* --- Entry points in the shell -------------------------------------------- */
.tg-welcome-cta {
    display: flex;
    align-items: center;
    gap: 14px;
    max-width: 560px;
    margin: 14px auto 18px;
    padding: 12px 16px;
    text-align: left;
    text-decoration: none;
    color: var(--text-primary);
    background: var(--bg-surface);
    border: 1px solid var(--border-default);
    border-radius: 12px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
    transition: border-color 0.15s, box-shadow 0.15s, transform 0.15s;
}
.tg-welcome-cta:hover {
    border-color: var(--brand-primary);
    box-shadow: 0 6px 16px var(--shadow-color);
    transform: translateY(-1px);
}
.tg-welcome-cta-icon {
    flex: none;
    width: 42px;
    height: 42px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    color: #c2410c;
    background: #fde4c2;
}
html.dark .tg-welcome-cta-icon { color: #fb923c; background: #f3dfc1; }
.tg-welcome-cta-text { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.tg-welcome-cta-text strong { font-size: 15px; }
.tg-welcome-cta-text span { font-size: 13px; color: var(--text-secondary); }
.tg-welcome-cta-arrow { color: var(--text-muted); }

.tg-gallery-cta {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 7px 12px;
    border: 1px solid var(--border-default);
    border-radius: 999px;
    color: var(--text-primary);
    background: var(--bg-surface);
    font-size: 13px;
    font-weight: 600;
    text-decoration: none;
    white-space: nowrap;
}
.tg-gallery-cta i { color: #c2410c; }
html.dark .tg-gallery-cta i { color: #fb923c; }
html.cookbook .tg-gallery-cta i { color: var(--brand-primary); }
.tg-gallery-cta:hover { border-color: var(--brand-primary); background: var(--bg-hover); }

/* --- Phones ---------------------------------------------------------------- */
@media (max-width: 900px) {
    .tg-body { display: block; overflow-y: auto; -webkit-overflow-scrolling: touch; }
    .tg-main, .tg-panel { overflow: visible; }
    .tg-panel { border-left: none; border-top: 1px solid var(--border-default); scroll-margin-top: 8px; }
    .tg-jump, .tg-back-menu { display: inline-flex; }
    .tg-footer-summary { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; }
    .tg-footer-count { flex: 1 1 0; min-width: 0; line-height: 1.35; }
    .tg-jump { flex: none; }
    .tg-gate-note { flex: 1 1 100%; order: 3; }
}
@media (max-width: 768px) {
    /* Size to the device width, not to the layout viewport: a page wider
       than the phone would otherwise stretch a fixed overlay past the
       screen edge. */
    .tg-overlay { padding: 0; right: auto; bottom: auto; width: 100vw; height: 100vh; height: 100dvh; }
    /* One scroll for the whole sheet: the controls scroll away, the
       header and the action footer stay. */
    .tg-modal {
        display: block;
        max-width: none;
        max-height: none;
        border-radius: 0;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        overscroll-behavior: contain;
    }
    .tg-header { position: sticky; top: 0; z-index: 3; background: var(--tg-band) top left / 100% 4px no-repeat, var(--tg-header-bg); }
    .tg-body { overflow: visible; }
    .tg-footer { position: sticky; bottom: 0; z-index: 3; }
    /* The link is on this phone already: no QR code beside it. */
    .tg-share-qr { display: none; }
    /* Clear of the sticky header when jumped to. */
    .tg-panel { scroll-margin-top: 112px; }
    .tg-picker { position: fixed; z-index: 7; right: auto; bottom: auto; width: 100vw; height: 100vh; height: 100dvh; }
    .tg-check { order: 0; }
    .tg-field-kitchen { order: 1; flex: 1 1 100%; }
    .tg-field-kitchen .tg-kitchen > summary { width: 100%; justify-content: space-between; }
    .tg-header { padding: calc(10px + env(safe-area-inset-top, 0px)) 12px 8px 16px; }
    .tg-controls { padding: 0 16px 12px; gap: 10px 12px; }
    .tg-field-serve { flex: 1 1 100%; order: -1; }
    .tg-kitchen[open] { flex: 1 1 100%; }
    .tg-kitchen-body {
        position: static;
        width: auto;
        max-width: none;
        margin-top: 8px;
        box-shadow: none;
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
    .tg-main { padding: 14px 16px 18px; }
    .tg-panel { padding: 14px 16px 20px; }
    .tg-overlay .recipe-gallery-modal-grid.tg-strip {
        grid-auto-columns: 140px;
        grid-auto-rows: 124px;
        gap: 8px;
    }
    .tg-header h2 { flex: 1 1 calc(100% - 60px); }
    .tg-filters { order: 3; flex: 1 1 100%; }
    .tg-filter { flex: 1 1 0; justify-content: center; padding: 4px 8px; }
    .tg-filters-label { flex: none; }
    .tg-footer { padding: 10px 16px calc(10px + env(safe-area-inset-bottom, 0px)); }
    .tg-footer-summary { flex: 1 1 100%; }
    .tg-actions { flex: 1 1 100%; }
    .tg-actions .tg-btn { flex: 1 1 0; padding-left: 8px; padding-right: 8px; }
    .tg-actions .tg-btn-primary { flex: 1.6 1 0; }
    .tg-picker { padding: calc(10px + env(safe-area-inset-top, 0px)) 16px calc(12px + env(safe-area-inset-bottom, 0px)); }
    .tg-picker .recipe-gallery-modal-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); grid-auto-rows: 148px; }
    .tg-summary .tg-stat-value { font-size: 14px; }
    .tg-gallery-cta { padding: 7px 10px; }

    /* Kitchen welcome on phones shows only the photo wall; keep the
       planner card visible above it (see the vertical-kitchen rules in
       MAIN_PAGE, which hide everything else). */
    html.vertical-kitchen body:not(.mobile-viz-loaded) #welcome-screen #welcome-thanksgiving-cta {
        display: flex !important;
        margin: 0 0 12px !important;
        max-width: none;
    }
}
@media (max-width: 420px) {
    .tg-gallery-cta span { display: none; }
    .tg-summary { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; }
    .tg-summary > div { padding: 8px; }
}
.tg-panel:focus { outline: none; }
