:root {
    --cream: #fff7ec;
    --cream-deep: #ffe8cc;
    --card-bg: rgba(255, 255, 255, 0.92);
    --text-main: #214b67;
    --text-soft: #60798b;
    --text-muted: #8aa0ad;

    --navy: #214b67;
    --green: #86b86f;
    --green-dark: #5d914f;
    --blue: #8fc7e8;
    --blue-dark: #4d93bd;
    --peach: #ff8a65;
    --peach-dark: #ee6f4b;
    --warning: #ee5f5f;

    --shadow-soft: 0 18px 50px rgba(33, 75, 103, 0.14);
    --shadow-small: 0 8px 22px rgba(33, 75, 103, 0.10);

    --border-lg: 32px;
    --border-md: 22px;
    --border-sm: 16px;

    --color-veg: #3f8f51;
    --bg-veg: #edf8e8;

    --color-fruit: #b45ac4;
    --bg-fruit: #f8e7fb;

    --color-protein: #df7a2d;
    --bg-protein: #fff0df;

    --color-grain: #a98214;
    --bg-grain: #fff7d8;

    --color-dairy: #3f91c6;
    --bg-dairy: #e9f6ff;

    --color-allergen: #d94f4f;
    --bg-allergen: #ffe8e8;

    --color-flavors: #697b86;
    --bg-flavors: #edf3f5;

    --color-other: #66727a;
    --bg-other: #edf0f2;
}

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

html {
    min-height: 100%;
    background: var(--cream);
    scroll-behavior: smooth;
}

body {
    min-height: 100%;
    font-family: 'Nunito', system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
    color: var(--text-main);
    background:
        radial-gradient(circle at top left, rgba(143, 199, 232, 0.32), transparent 32rem),
        radial-gradient(circle at top right, rgba(255, 138, 101, 0.24), transparent 28rem),
        linear-gradient(180deg, #fff7ec 0%, #f5fbff 100%);
    padding: 18px 16px 118px;
    -webkit-font-smoothing: antialiased;
}

button,
input,
select,
textarea {
    font: inherit;
}

button {
    -webkit-tap-highlight-color: transparent;
}

textarea {
    resize: vertical;
}

.hidden {
    display: none !important;
}

.app-shell {
    width: min(100%, 980px);
    margin: 0 auto;
}

/* Hero */

.app-hero {
    position: relative;
    padding: 18px 4px 24px;
    text-align: center;
}

.header-actions {
    display: flex;
    justify-content: flex-end;
    margin-bottom: 10px;
}

.icon-btn {
    display: grid;
    place-items: center;
    width: 46px;
    height: 46px;
    color: var(--text-main);
    background: rgba(255, 255, 255, 0.84);
    border: 1px solid rgba(255, 255, 255, 0.95);
    border-radius: 50%;
    box-shadow: var(--shadow-small);
    cursor: pointer;
    font-size: 1.18rem;
}

.icon-btn:active {
    transform: scale(0.98);
}

.logo-card {
    display: inline-flex;
    justify-content: center;
    align-items: center;
    width: min(100%, 430px);
    margin: 0 auto 20px;
    padding: 18px 22px;
    background: rgba(255, 255, 255, 0.72);
    border: 1px solid rgba(255, 255, 255, 0.85);
    border-radius: 28px;
    box-shadow: var(--shadow-small);
    backdrop-filter: blur(14px);
}

.app-logo {
    display: block;
    width: auto;
    max-width: 100%;
    max-height: 6.75rem;
    object-fit: contain;
}

.hero-copy {
    max-width: 620px;
    margin: 0 auto;
}

.eyebrow,
.section-kicker {
    color: var(--peach-dark);
    font-size: 0.78rem;
    font-weight: 900;
    text-transform: uppercase;
    letter-spacing: 0.11em;
}

h1 {
    margin-top: 8px;
    color: var(--navy);
    font-size: clamp(2rem, 8vw, 3.35rem);
    line-height: 0.95;
    letter-spacing: -0.055em;
}

.hero-subtitle {
    max-width: 38rem;
    margin: 14px auto 0;
    color: var(--text-soft);
    font-size: 1.08rem;
    line-height: 1.45;
    font-weight: 700;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 10px;
    margin: 22px auto 0;
}

.stat-card {
    min-height: 90px;
    padding: 16px 8px;
    background: rgba(255, 255, 255, 0.82);
    border: 1px solid rgba(255, 255, 255, 0.9);
    border-radius: 24px;
    box-shadow: var(--shadow-small);
}

.stat-number {
    display: block;
    color: var(--navy);
    font-size: 2rem;
    font-weight: 900;
    line-height: 1;
}

.stat-label {
    display: block;
    margin-top: 7px;
    color: var(--text-soft);
    font-size: 0.76rem;
    font-weight: 900;
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

.alert-stat .stat-number {
    color: var(--warning);
}

.stat-shortcut {
    cursor: pointer;
    text-align: center;
    transition: transform 0.16s ease, box-shadow 0.16s ease;
}

.stat-shortcut:active {
    transform: scale(0.98);
}

.stat-shortcut:focus-visible,
.icon-btn:focus-visible,
.bottom-nav-btn:focus-visible {
    outline: 3px solid rgba(77, 147, 189, 0.45);
    outline-offset: 3px;
}

/* App views */

.app-view {
    display: none;
}

.app-view.active-view {
    display: block;
}

/* Bottom navigation */

.bottom-nav {
    position: fixed;
    left: 50%;
    bottom: 14px;
    z-index: 900;
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 6px;
    width: min(calc(100% - 24px), 520px);
    padding: 8px;
    background: rgba(255, 255, 255, 0.88);
    border: 1px solid rgba(255, 255, 255, 0.95);
    border-radius: 28px;
    box-shadow: 0 18px 46px rgba(33, 75, 103, 0.20);
    backdrop-filter: blur(18px);
    transform: translateX(-50%);
}

.bottom-nav-btn {
    display: grid;
    place-items: center;
    gap: 3px;
    min-height: 58px;
    color: var(--text-soft);
    background: transparent;
    border: none;
    border-radius: 21px;
    cursor: pointer;
    font-weight: 900;
}

.bottom-nav-btn.active-nav {
    color: #ffffff;
    background: var(--navy);
    box-shadow: 0 8px 18px rgba(33, 75, 103, 0.22);
}

.bottom-nav-icon {
    font-size: 1.25rem;
    line-height: 1;
}

.bottom-nav-label {
    font-size: 0.72rem;
    letter-spacing: 0.02em;
}

/* Panels */

.panel,
.food-card,
.modal-content {
    background: var(--card-bg);
    border: 1px solid rgba(255, 255, 255, 0.95);
    border-radius: var(--border-lg);
    box-shadow: var(--shadow-soft);
    backdrop-filter: blur(16px);
}

.soft-panel {
    border-radius: 26px;
    box-shadow: var(--shadow-small);
}

.add-food-section,
.checklist-section {
    padding: 22px;
    margin-bottom: 30px;
}

.section-heading,
.log-heading-row,
.modal-heading {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
}

.section-heading {
    margin-bottom: 22px;
}

.section-heading.compact {
    margin-bottom: 14px;
}

.section-heading h2,
.log-heading-row h2 {
    margin-top: 3px;
    color: var(--navy);
    font-size: 1.75rem;
    line-height: 1.05;
    letter-spacing: -0.035em;
}

.section-icon {
    flex: 0 0 auto;
    display: grid;
    place-items: center;
    width: 54px;
    height: 54px;
    background: var(--cream-deep);
    border-radius: 20px;
    font-size: 1.65rem;
}

/* More details */

.more-details {
    padding: 0;
    background: rgba(255, 255, 255, 0.58);
    border: 1px solid rgba(143, 199, 232, 0.28);
    border-radius: 20px;
    overflow: hidden;
}

.more-details summary {
    list-style: none;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    padding: 15px 16px;
    color: var(--navy);
    cursor: pointer;
    font-weight: 900;
}

.more-details summary::-webkit-details-marker {
    display: none;
}

.more-details summary::after {
    content: "+";
    display: grid;
    place-items: center;
    flex: 0 0 auto;
    width: 30px;
    height: 30px;
    color: var(--navy);
    background: #eef4f7;
    border-radius: 50%;
    font-size: 1.25rem;
    line-height: 1;
    transition: transform 0.16s ease;
}

.more-details[open] summary::after {
    transform: rotate(45deg);
}

.more-details-hint {
    color: var(--text-muted);
    font-size: 0.82rem;
    font-weight: 800;
}

.more-details .nested-grid {
    padding: 0 16px 16px;
}

/* Collapsible dashboard panels */

.insights-grid {
    display: grid;
    gap: 16px;
    margin-bottom: 30px;
}

.insight-panel {
    padding: 0;
}

.collapsible-panel {
    padding: 0;
    overflow: hidden;
    margin-bottom: 16px;
}

.collapsible-summary {
    list-style: none;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    padding: 20px;
    cursor: pointer;
}

.collapsible-summary::-webkit-details-marker {
    display: none;
}

.collapsible-summary strong {
    display: block;
    margin-top: 3px;
    color: var(--navy);
    font-size: 1.35rem;
    line-height: 1.1;
    letter-spacing: -0.035em;
}

.summary-icon {
    display: grid;
    place-items: center;
    flex: 0 0 auto;
    width: 38px;
    height: 38px;
    color: var(--navy);
    background: #eef4f7;
    border-radius: 50%;
    font-size: 1.4rem;
    font-weight: 900;
    line-height: 1;
    transition: transform 0.16s ease;
}

.collapsible-panel[open] .summary-icon,
.food-tools-panel[open] .summary-icon {
    transform: rotate(45deg);
}

.collapsible-content {
    padding: 0 20px 20px;
}

.timeline-controls {
    display: none;
    gap: 8px;
    padding: 0 20px 20px;
}

.timeline-section[open] .timeline-controls {
    display: flex;
    flex-wrap: wrap;
}

.timeline-controls .secondary-btn {
    flex: 1 1 130px;
}

/* Form */

.form-grid {
    display: grid;
    gap: 17px;
}

.nested-grid {
    margin-top: 14px;
}

.full-width {
    grid-column: 1 / -1;
}

.form-group {
    display: grid;
    gap: 8px;
}

.hidden-input {
    display: none;
}

.hidden-input.visible {
    display: grid;
    animation: fadeIn 0.25s ease;
}

label {
    color: var(--text-main);
    font-size: 0.92rem;
    font-weight: 900;
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="date"],
input[type="search"],
select,
textarea {
    width: 100%;
    min-height: 58px;
    padding: 15px 16px;
    color: var(--text-main);
    background-color: #fbfdff;
    border: 2px solid rgba(143, 199, 232, 0.32);
    border-radius: var(--border-sm);
    font-size: 1.03rem;
    font-weight: 800;
    outline: none;
    appearance: none;
    transition: border-color 0.18s ease, box-shadow 0.18s ease, background-color 0.18s ease;
}

textarea {
    line-height: 1.35;
}

select {
    background-image:
        linear-gradient(45deg, transparent 50%, var(--blue-dark) 50%),
        linear-gradient(135deg, var(--blue-dark) 50%, transparent 50%);
    background-position:
        calc(100% - 22px) 50%,
        calc(100% - 16px) 50%;
    background-size: 6px 6px, 6px 6px;
    background-repeat: no-repeat;
    padding-right: 46px;
}

input:focus,
select:focus,
textarea:focus {
    border-color: var(--blue-dark);
    box-shadow: 0 0 0 5px rgba(143, 199, 232, 0.22);
    background-color: #ffffff;
}

select:disabled {
    opacity: 0.62;
    background-color: #eef4f7;
}

.conditional-group {
    display: none;
    padding: 18px;
    background: #fff3f3;
    border: 2px solid rgba(238, 95, 95, 0.18);
    border-radius: 22px;
}

.conditional-group.visible {
    display: block;
    animation: fadeIn 0.25s ease;
}

.conditional-heading {
    display: grid;
    gap: 4px;
}

.conditional-heading strong {
    color: var(--warning);
    font-size: 1.02rem;
    font-weight: 900;
}

.conditional-heading span {
    color: var(--text-soft);
    font-size: 0.88rem;
    font-weight: 800;
    line-height: 1.35;
}

#submit-btn,
#save-edit-btn {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 10px;
    width: 100%;
    min-height: 62px;
    margin-top: 22px;
    padding: 18px 20px;
    color: #ffffff;
    background: linear-gradient(135deg, var(--peach), var(--peach-dark));
    border: none;
    border-radius: 20px;
    box-shadow: 0 12px 26px rgba(238, 111, 75, 0.24);
    font-size: 1.12rem;
    font-weight: 900;
    cursor: pointer;
    transition: transform 0.16s ease, box-shadow 0.16s ease;
}

#submit-btn:active,
#save-edit-btn:active {
    transform: translateY(1px) scale(0.99);
    box-shadow: 0 6px 14px rgba(238, 111, 75, 0.20);
}

#submit-btn:disabled,
#save-edit-btn:disabled {
    opacity: 0.7;
    cursor: wait;
}

.cancel-btn,
.secondary-btn,
.danger-btn {
    min-height: 48px;
    padding: 12px 16px;
    border: none;
    border-radius: 16px;
    font-size: 0.95rem;
    font-weight: 900;
    cursor: pointer;
}

.cancel-btn,
.secondary-btn {
    color: var(--text-soft);
    background: #eef4f7;
}

.cancel-btn {
    width: 100%;
    min-height: 58px;
    margin-top: 10px;
    font-size: 1.05rem;
}

.secondary-btn {
    flex: 1 1 auto;
}

.danger-btn {
    width: 100%;
    margin-top: 16px;
    color: #ffffff;
    background: var(--warning);
}

/* Foods controls */

.food-list-controls {
    display: grid;
    gap: 12px;
    margin-bottom: 16px;
}

.date-filter-group {
    margin-bottom: 0;
}

.view-options-row {
    display: flex;
    justify-content: flex-end;
    margin: 0;
}

.toggle-control {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    color: var(--text-soft);
    font-size: 0.94rem;
    font-weight: 900;
    cursor: pointer;
    user-select: none;
}

.toggle-control input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.toggle-track {
    position: relative;
    width: 48px;
    height: 28px;
    background: #dce8ee;
    border-radius: 999px;
    transition: background-color 0.18s ease;
}

.toggle-track::before {
    content: "";
    position: absolute;
    top: 4px;
    left: 4px;
    width: 20px;
    height: 20px;
    background: #ffffff;
    border-radius: 50%;
    box-shadow: 0 2px 7px rgba(33, 75, 103, 0.2);
    transition: transform 0.18s ease;
}

.toggle-control input:checked + .toggle-track {
    background: var(--navy);
}

.toggle-control input:checked + .toggle-track::before {
    transform: translateX(20px);
}

.food-tools-panel {
    padding: 0;
    margin-bottom: 18px;
    overflow: hidden;
}

.food-tools-summary {
    padding: 18px 20px;
}

.food-tools-content {
    padding: 0 18px 18px;
}

/* Insights */

.progress-list,
.allergen-list,
.mini-list,
.timeline-list,
.checklist-content {
    display: grid;
    gap: 12px;
}

.progress-item {
    display: grid;
    gap: 8px;
}

.progress-top {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    color: var(--text-main);
    font-weight: 900;
}

.progress-count {
    color: var(--text-soft);
}

.progress-bar {
    height: 12px;
    overflow: hidden;
    background: #eef4f7;
    border-radius: 999px;
}

.progress-fill {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, var(--green), var(--blue));
    border-radius: inherit;
}

.allergen-card,
.mini-card,
.timeline-item {
    padding: 14px;
    background: rgba(255, 255, 255, 0.68);
    border: 1px solid rgba(143, 199, 232, 0.22);
    border-radius: 18px;
}

.allergen-card {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    align-items: center;
}

.allergen-name,
.mini-title,
.timeline-title {
    color: var(--navy);
    font-weight: 900;
}

.allergen-meta,
.mini-meta,
.timeline-meta {
    margin-top: 2px;
    color: var(--text-soft);
    font-size: 0.9rem;
    font-weight: 800;
    line-height: 1.35;
}

.status-pill {
    flex: 0 0 auto;
    padding: 7px 10px;
    border-radius: 999px;
    font-size: 0.72rem;
    font-weight: 900;
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

.status-not-tried {
    color: var(--text-soft);
    background: #eef4f7;
}

.status-tried {
    color: var(--green-dark);
    background: #edf8e8;
}

.status-reaction {
    color: var(--warning);
    background: #ffe8e8;
}

/* Log */

.food-log-section {
    padding-bottom: 12px;
    margin-bottom: 30px;
}

.log-heading-row {
    margin-bottom: 14px;
    padding: 0 2px;
}

.log-tools {
    padding: 18px;
    margin-bottom: 18px;
}

.tools-grid {
    margin-bottom: 14px;
}

.filter-group {
    display: flex;
    gap: 10px;
    padding: 2px 2px 8px;
    overflow-x: auto;
    scrollbar-width: none;
}

.filter-group::-webkit-scrollbar {
    display: none;
}

.filter-btn {
    flex: 0 0 auto;
    padding: 11px 17px;
    color: var(--text-soft);
    background: rgba(255, 255, 255, 0.78);
    border: 1px solid rgba(255, 255, 255, 0.95);
    border-radius: 999px;
    box-shadow: 0 5px 14px rgba(33, 75, 103, 0.08);
    font-size: 0.92rem;
    font-weight: 900;
    cursor: pointer;
}

.filter-btn.active {
    color: #ffffff;
    background: var(--navy);
}

.export-row {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.log-grid {
    display: grid;
    gap: 16px;
}

/* Food cards */

.food-card {
    position: relative;
    overflow: hidden;
    padding: 20px;
    cursor: pointer;
    transition: transform 0.16s ease, box-shadow 0.16s ease;
}

.food-card::before {
    content: "";
    position: absolute;
    inset: 0 auto 0 0;
    width: 7px;
    background: var(--blue);
}

.food-card:active {
    transform: scale(0.99);
    box-shadow: var(--shadow-small);
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    margin-bottom: 14px;
}

.category-badge,
.tally-badge,
.reaction-badge {
    display: inline-flex;
    align-items: center;
    min-height: 30px;
    padding: 7px 12px;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 900;
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

.tally-badge {
    color: #ffffff;
    background: var(--navy);
}

.reaction-badge {
    min-height: 28px;
    padding: 6px 10px;
    font-size: 0.72rem;
    letter-spacing: 0.04em;
    text-transform: none;
}

.reaction-loved-it {
    color: var(--green-dark);
    background: #edf8e8;
}

.reaction-neutral {
    color: var(--blue-dark);
    background: #e9f6ff;
}

.reaction-disliked {
    color: #b86013;
    background: #fff0df;
}

.reaction-reaction {
    color: var(--warning);
    background: #ffe8e8;
}

.vegetables {
    background-color: var(--bg-veg);
    color: var(--color-veg);
}

.fruits {
    background-color: var(--bg-fruit);
    color: var(--color-fruit);
}

.protein {
    background-color: var(--bg-protein);
    color: var(--color-protein);
}

.grains {
    background-color: var(--bg-grain);
    color: var(--color-grain);
}

.dairy {
    background-color: var(--bg-dairy);
    color: var(--color-dairy);
}

.common-allergens {
    background-color: var(--bg-allergen);
    color: var(--color-allergen);
}

.herbs-spices-and-flavors,
.herbs-and-spices,
.other-flavors {
    background-color: var(--bg-flavors);
    color: var(--color-flavors);
}

.other-foods {
    background-color: var(--bg-other);
    color: var(--color-other);
}

.food-card:has(.vegetables)::before {
    background: var(--color-veg);
}

.food-card:has(.fruits)::before {
    background: var(--color-fruit);
}

.food-card:has(.protein)::before {
    background: var(--color-protein);
}

.food-card:has(.grains)::before {
    background: var(--color-grain);
}

.food-card:has(.dairy)::before {
    background: var(--color-dairy);
}

.food-card:has(.common-allergens)::before {
    background: var(--color-allergen);
}

.food-card:has(.herbs-spices-and-flavors)::before,
.food-card:has(.herbs-and-spices)::before,
.food-card:has(.other-flavors)::before {
    background: var(--color-flavors);
}

.food-card:has(.other-foods)::before {
    background: var(--color-other);
}

.food-card h3 {
    color: var(--navy);
    font-size: 1.7rem;
    font-weight: 900;
    line-height: 1.05;
    letter-spacing: -0.035em;
    margin-bottom: 8px;
}

.last-reaction {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    color: var(--text-main);
    font-size: 1.03rem;
    font-weight: 800;
    margin-bottom: 6px;
}

.last-date,
.card-extra {
    color: var(--text-muted);
    font-size: 0.92rem;
    font-weight: 800;
}

.card-extra {
    margin-top: 8px;
    line-height: 1.35;
}

.detail-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
    margin-top: 16px;
}

.detail-box {
    padding: 12px;
    background: rgba(143, 199, 232, 0.12);
    border-radius: 16px;
}

.detail-label {
    display: block;
    color: var(--text-soft);
    font-size: 0.72rem;
    font-weight: 900;
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

.detail-value {
    display: block;
    margin-top: 4px;
    color: var(--navy);
    font-size: 0.98rem;
    font-weight: 900;
}

.history-drawer {
    display: none;
    max-height: 340px;
    margin-top: 18px;
    padding-top: 16px;
    border-top: 2px dashed rgba(143, 199, 232, 0.34);
    overflow-y: auto;
}

.food-card.expanded .history-drawer {
    display: block;
}

.history-item {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 12px 0;
    border-bottom: 1px solid rgba(143, 199, 232, 0.18);
    font-size: 0.96rem;
}

.history-item-top {
    display: flex;
    justify-content: space-between;
    gap: 12px;
}

.history-date {
    color: var(--text-soft);
    font-weight: 900;
}

.history-reaction {
    color: var(--text-main);
    font-weight: 900;
}

.history-notes,
.history-details {
    color: var(--text-soft);
    font-size: 0.9rem;
    font-weight: 800;
    line-height: 1.4;
}

.history-details strong {
    color: var(--text-main);
}

.history-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
}

.action-btn {
    padding: 7px 10px;
    border: none;
    border-radius: 999px;
    font-size: 0.82rem;
    font-weight: 900;
    cursor: pointer;
}

.edit-btn {
    color: var(--blue-dark);
    background-color: #e9f6ff;
}

.delete-btn {
    color: var(--warning);
    background-color: #ffe8e8;
}

/* Compact mode */

.log-grid.compact-mode {
    gap: 10px;
}

.log-grid.compact-mode .food-card {
    padding: 14px 16px 14px 20px;
    border-radius: 22px;
}

.log-grid.compact-mode .card-header {
    margin-bottom: 8px;
}

.log-grid.compact-mode .category-badge,
.log-grid.compact-mode .tally-badge {
    min-height: 26px;
    padding: 5px 9px;
    font-size: 0.68rem;
}

.log-grid.compact-mode .food-card h3 {
    font-size: 1.24rem;
    margin-bottom: 6px;
}

.log-grid.compact-mode .last-reaction {
    margin-bottom: 4px;
    font-size: 0.94rem;
}

.log-grid.compact-mode .last-date {
    font-size: 0.84rem;
}

.log-grid.compact-mode .card-extra,
.log-grid.compact-mode .detail-grid {
    display: none;
}

.log-grid.compact-mode .history-drawer {
    max-height: 280px;
    margin-top: 12px;
    padding-top: 12px;
}

/* Checklist */

.checklist-category {
    padding: 14px;
    background: rgba(255, 255, 255, 0.65);
    border: 1px solid rgba(143, 199, 232, 0.22);
    border-radius: 20px;
}

.checklist-category summary {
    cursor: pointer;
    color: var(--navy);
    font-weight: 900;
}

.checklist-foods {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 12px;
}

.food-chip {
    padding: 8px 10px;
    border-radius: 999px;
    font-size: 0.82rem;
    font-weight: 900;
}

.food-chip.tried {
    color: var(--green-dark);
    background: #edf8e8;
}

.food-chip.not-tried {
    color: var(--text-muted);
    background: #eef4f7;
}

/* Empty states */

.empty-message,
.log-grid:empty::before {
    display: block;
    padding: 20px;
    color: var(--text-soft);
    background: rgba(255, 255, 255, 0.72);
    border: 1px dashed rgba(143, 199, 232, 0.55);
    border-radius: var(--border-md);
    font-weight: 800;
    line-height: 1.4;
    text-align: center;
}

.log-grid:empty::before {
    content: "No foods match these filters yet.";
}

/* Modal */

.modal {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 18px;
    background: rgba(33, 75, 103, 0.42);
    backdrop-filter: blur(7px);
}

.modal.hidden {
    display: none;
}

.modal-content {
    width: min(100%, 640px);
    max-height: 92vh;
    overflow-y: auto;
    padding: 24px;
}

.settings-modal-content {
    width: min(100%, 430px);
}

.modal-heading {
    margin-bottom: 20px;
}

.modal-content h3 {
    color: var(--navy);
    font-size: 1.55rem;
    font-weight: 900;
    letter-spacing: -0.035em;
}

.modal-close {
    display: grid;
    place-items: center;
    width: 42px;
    height: 42px;
    color: var(--text-soft);
    background: #eef4f7;
    border: none;
    border-radius: 50%;
    font-size: 1.8rem;
    line-height: 1;
    cursor: pointer;
}

.settings-section {
    padding: 18px;
    background: rgba(143, 199, 232, 0.12);
    border-radius: 22px;
}

.settings-section h4 {
    margin-top: 4px;
    color: var(--navy);
    font-size: 1.25rem;
    font-weight: 900;
}

.settings-note {
    margin-top: 8px;
    color: var(--text-soft);
    font-weight: 800;
    line-height: 1.4;
}

/* Login Screen */

.login-overlay {
    position: fixed;
    inset: 0;
    z-index: 2000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background: var(--cream);
}

.login-card {
    width: 100%;
    max-width: 400px;
    padding: 30px;
    text-align: center;
    background: var(--card-bg);
    border-radius: var(--border-lg);
    box-shadow: var(--shadow-soft);
}

.login-card .app-logo {
    margin: 0 auto 16px;
}

.login-card h2 {
    color: var(--navy);
    font-size: 1.8rem;
    margin-bottom: 8px;
}

.login-card p {
    color: var(--text-soft);
    margin-bottom: 24px;
}

.login-card .form-group {
    text-align: left;
}

#login-btn {
    width: 100%;
    padding: 18px;
    margin-top: 10px;
    color: #ffffff;
    background: var(--navy);
    border: none;
    border-radius: var(--border-md);
    font-size: 1.1rem;
    font-weight: 900;
    cursor: pointer;
}

.error-message {
    color: var(--warning);
    font-size: 0.9rem;
    font-weight: 900;
    margin-top: 10px;
}

/* Animation */

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

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

/* Larger screens */

@media (min-width: 720px) {
    body {
        padding-top: 34px;
    }

    .add-food-section,
    .checklist-section {
        padding: 28px;
    }

    .form-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .tools-grid {
        grid-template-columns: 1.4fr 1fr 1fr 1fr;
    }

    #submit-btn {
        width: auto;
        min-width: 230px;
        margin-left: auto;
    }

    .insights-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .log-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .log-grid.compact-mode {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }
}

/* Small phones */

@media (max-width: 520px) {
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .detail-grid {
        grid-template-columns: 1fr;
    }

    .view-options-row {
        justify-content: flex-start;
    }

    .more-details summary {
        align-items: flex-start;
        flex-direction: column;
    }

    .more-details summary::after {
        position: absolute;
        right: 16px;
    }

    .more-details summary {
        position: relative;
        padding-right: 58px;
    }
}

@media (max-width: 390px) {
    body {
        padding-inline: 12px;
    }

    .stats-grid {
        gap: 7px;
    }

    .stat-card {
        padding-inline: 6px;
    }

    .stat-number {
        font-size: 1.7rem;
    }

    .stat-label {
        font-size: 0.72rem;
    }

    .add-food-section,
    .food-card,
    .modal-content {
        border-radius: 26px;
    }
}