:root {
    --bg: #0b1017;
    --surface: #121a24;
    --card-blue: #162536;
    --card-cream: #171e28;
    --ink: #f4f7fb;
    --muted: #94a3b8;
    --line: #243244;
    --accent: #63b3ff;
    --accent-warm: #ffbf47;
    --accent-green: #57c08a;
    --danger: #ff8e8e;
    --radius-card: 34px;
    --shadow-card: 0 20px 48px rgba(2, 8, 20, 0.46);
    --card-height: 440px;
}

* {
    box-sizing: border-box;
}

[hidden] {
    display: none !important;
}

body {
    margin: 0;
    min-height: 100vh;
    overflow-x: hidden;
    background:
        radial-gradient(circle at top left, rgba(99, 179, 255, 0.12), transparent 32%),
        radial-gradient(circle at top right, rgba(87, 192, 138, 0.08), transparent 28%),
        linear-gradient(180deg, #0f1722 0%, var(--bg) 100%);
    color: var(--ink);
    font-family: "DM Sans", "Segoe UI", sans-serif;
}

.page {
    position: relative;
    width: min(1260px, calc(100% - 24px));
    margin: 16px auto 32px;
}

.app-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    padding: 14px 18px;
    margin-bottom: 18px;
    border: 1px solid rgba(148, 163, 184, 0.14);
    border-radius: 28px;
    background: rgba(18, 26, 36, 0.72);
    box-shadow: var(--shadow-card);
    backdrop-filter: blur(14px);
}

.brand-block {
    display: flex;
    align-items: center;
    gap: 14px;
    min-width: 0;
}

.brand-mark {
    display: inline-grid;
    place-items: center;
    width: 54px;
    height: 54px;
    border-radius: 18px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(148, 163, 184, 0.14);
    box-shadow: 0 14px 28px rgba(2, 8, 20, 0.28);
}

.brand-mark svg {
    width: 34px;
    height: 34px;
}

.brand-copy {
    display: grid;
    gap: 3px;
    min-width: 0;
}

.brand-copy strong {
    font-size: 1.2rem;
    line-height: 1.1;
    letter-spacing: -0.03em;
}

.brand-copy span {
    color: var(--muted);
    font-size: 0.88rem;
    white-space: nowrap;
}

.session-bar {
    display: flex;
    align-items: center;
    gap: 12px;
    color: var(--muted);
    margin-left: auto;
}

.back-arrow-link {
    display: inline-grid;
    place-items: center;
    width: 48px;
    height: 48px;
    border-radius: 16px;
    border: 1px solid rgba(148, 163, 184, 0.14);
    background: rgba(18, 26, 36, 0.92);
    color: var(--ink);
    text-decoration: none;
    box-shadow: var(--shadow-card);
}

.back-arrow-link svg {
    width: 20px;
    height: 20px;
}

.account-menu {
    position: relative;
}

.account-button {
    display: inline-grid;
    place-items: center;
    width: 54px;
    height: 54px;
    border: 1px solid rgba(148, 163, 184, 0.14);
    border-radius: 18px;
    background: rgba(18, 26, 36, 0.92);
    box-shadow: var(--shadow-card);
    cursor: pointer;
}

.account-avatar {
    display: inline-grid;
    place-items: center;
    width: 34px;
    height: 34px;
    border-radius: 12px;
    background: linear-gradient(135deg, rgba(99, 179, 255, 0.24), rgba(87, 192, 138, 0.18));
    color: var(--accent);
    font-weight: 800;
    font-size: 1rem;
}

.account-menu-panel {
    position: absolute;
    top: calc(100% + 10px);
    right: 0;
    display: grid;
    gap: 8px;
    width: 260px;
    padding: 12px;
    border-radius: 22px;
    border: 1px solid rgba(148, 163, 184, 0.14);
    background: rgba(18, 26, 36, 0.98);
    box-shadow: 0 22px 46px rgba(2, 8, 20, 0.42);
    z-index: 50;
}

.account-menu-item {
    display: grid;
    gap: 4px;
    width: 100%;
    padding: 14px 16px;
    border: 0;
    border-radius: 16px;
    background: rgba(255, 255, 255, 0.03);
    color: var(--ink);
    text-decoration: none;
    text-align: left;
    font: inherit;
    cursor: pointer;
}

.account-menu-item strong {
    font-size: 0.98rem;
}

.account-menu-item span {
    color: var(--muted);
    font-size: 0.86rem;
    line-height: 1.4;
}

.account-menu-item:hover {
    background: rgba(255, 255, 255, 0.07);
}

.account-menu-item.logout {
    background: rgba(255, 142, 142, 0.08);
}

.account-menu-form {
    margin: 0;
}

.session-actions {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-right: 12px;
}

.date-filter-button,
.date-chip {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    border-radius: 999px;
    border: 1px solid var(--line);
    background: rgba(18, 26, 36, 0.92);
    color: var(--ink);
    font: inherit;
    box-shadow: var(--shadow-card);
}

.date-chip {
    cursor: pointer;
    font-weight: 700;
    appearance: none;
}

.date-chip small {
    color: var(--muted);
    white-space: nowrap;
}

.date-chip-clear {
    color: var(--danger);
    font-weight: 800;
    line-height: 1;
}

.date-filter-form {
    display: block;
    padding: 12px 14px;
    border-radius: 18px;
    background: rgba(18, 26, 36, 0.98);
    box-shadow: var(--shadow-card);
}

.date-filter-form.hidden-form {
    display: none;
}

.date-filter-row {
    display: flex;
    align-items: center;
    gap: 14px;
    flex-wrap: nowrap;
}

.date-filter-input {
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 10px 12px;
    font: inherit;
    min-width: 190px;
    background: #0f1722;
    color: var(--ink);
}

.date-filter-meta {
    color: var(--muted);
    font-size: 0.86rem;
    white-space: nowrap;
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    border: 0;
}

.logout-button,
.auth-submit {
    border: 0;
    border-radius: 999px;
    padding: 10px 16px;
    background: var(--accent);
    color: #fff;
    font: inherit;
    font-weight: 700;
    cursor: pointer;
}

.auth-page {
    min-height: 100vh;
    display: grid;
    place-items: center;
}

.account-shell {
    display: grid;
    gap: 14px;
}

.account-inline-message {
    padding: 14px 16px;
    border-radius: 18px;
    background: rgba(18, 26, 36, 0.92);
    border: 1px solid rgba(148, 163, 184, 0.14);
    box-shadow: var(--shadow-card);
    color: var(--accent);
}

.account-inline-message.error {
    color: var(--danger);
}

.account-grid {
    display: grid;
    grid-template-columns: 0.8fr 1.2fr;
    gap: 14px;
    align-items: stretch;
}

.account-grid > .card,
.account-settings > .card,
.account-macro-grid > .card {
    height: auto !important;
    min-height: 0 !important;
    align-self: start;
}

.account-grid > .card {
    height: 100% !important;
}

.account-profile-card,
.account-target-card {
    display: flex;
    flex-direction: column;
}

.account-target-card .account-target-form {
    flex: 1;
}

.account-target-card .account-target-form textarea {
    flex: 1;
}

.account-profile {
    display: flex;
    align-items: center;
    gap: 18px;
}

.account-profile-avatar {
    display: grid;
    place-items: center;
    width: 88px;
    height: 88px;
    border-radius: 28px;
    background: linear-gradient(135deg, rgba(99, 179, 255, 0.28), rgba(87, 192, 138, 0.18));
    color: var(--ink);
    font-size: 2rem;
    font-weight: 800;
}

.account-profile-copy h1 {
    margin: 0 0 6px;
    font-size: 1.8rem;
}

.account-profile-copy p {
    margin: 0 0 10px;
    color: var(--muted);
}

.account-chip {
    display: inline-flex;
    align-items: center;
    padding: 8px 12px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.08);
    color: var(--ink);
    font-size: 0.9rem;
    font-weight: 700;
}

.account-target-note {
    margin-top: 18px;
    display: grid;
    gap: 4px;
    color: var(--muted);
}

.account-target-note strong {
    color: var(--ink);
    font-size: 1.2rem;
}

.account-card-copy {
    margin: 8px 0 14px;
    color: var(--muted);
    line-height: 1.55;
}

.account-target-form {
    display: grid;
    gap: 12px;
}

.account-target-form textarea {
    min-height: 148px;
    resize: vertical;
    border: 1px solid var(--line);
    border-radius: 18px;
    padding: 14px 16px;
    background: #0f1722;
    color: var(--ink);
    font: inherit;
    line-height: 1.55;
}

.account-macro-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 12px;
}

.account-macro-grid .account-macro-card {
    height: auto !important;
    min-height: 0 !important;
    align-self: start;
    padding: 18px 22px;
    display: grid;
    align-content: start;
    gap: 4px;
    border-radius: 30px;
}

.account-macro-label {
    color: var(--muted);
    font-size: 0.82rem;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.account-macro-card strong {
    font-size: 1.3rem;
    line-height: 1;
}

.account-macro-card small {
    color: var(--muted);
    font-size: 0.86rem;
    line-height: 1.35;
}

.account-settings {
    display: grid;
}

.auth-card {
    width: min(460px, 100%);
    padding: 32px;
    border-radius: var(--radius-card);
    background: rgba(18, 26, 36, 0.96);
    box-shadow: var(--shadow-card);
}

.auth-copy h1 {
    margin: 0 0 10px;
}

.auth-copy p {
    margin: 0 0 22px;
    color: var(--muted);
}

.auth-form {
    display: grid;
    gap: 14px;
}

.auth-label {
    font-weight: 700;
}

.auth-input {
    width: 100%;
    padding: 14px 16px;
    border: 1px solid var(--line);
    border-radius: 16px;
    font: inherit;
    background: #0f1722;
    color: var(--ink);
}

.focus-grid {
    display: grid;
    grid-template-columns: 0.85fr 1.15fr 1fr;
    grid-template-areas:
        "summary nutrition macros"
        "entries entries entries";
    gap: 16px;
    align-items: start;
}

.card {
    padding: 26px 28px;
    border-radius: var(--radius-card);
    background: var(--surface);
    box-shadow: var(--shadow-card);
    height: var(--card-height);
    min-height: var(--card-height);
    overflow: hidden;
}

.card.blue {
    background: var(--card-blue);
}

.card.cream {
    background: var(--card-cream);
}

.card.tall {
    min-height: var(--card-height);
}

.card.wide {
    grid-column: span 2;
    min-height: var(--card-height);
}

.focus-grid > .card:nth-child(1) {
    grid-area: summary;
}

#nutrition-facts {
    grid-area: macros;
    min-height: var(--card-height);
}

#daily-log {
    grid-area: nutrition;
    grid-column: span 1;
}

#today-entries {
    grid-area: entries;
    grid-column: 1 / -1;
    width: 100%;
    min-width: 0;
    overflow: hidden;
}

.card-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 20px;
}

.card-header.compact {
    margin-bottom: 0;
}

.card-header h2,
.card-header h3 {
    margin: 0;
    font-size: 1.2rem;
    line-height: 1.3;
    font-weight: 800;
}

.card-link,
.plus-button {
    color: var(--accent);
    font-weight: 800;
}

.plus-button {
    font-size: 2rem;
    line-height: 1;
}

.summary-gauge {
    display: grid;
    place-items: center;
    min-height: 220px;
}

.gauge {
    --progress: 0deg;
    position: relative;
    display: grid;
    place-items: center;
    width: 210px;
    height: 210px;
    border-radius: 50%;
    background: conic-gradient(var(--accent) 0deg var(--progress), rgba(255, 255, 255, 0.08) var(--progress) 360deg);
}

.gauge::before {
    content: "";
    width: 164px;
    height: 164px;
    border-radius: 50%;
    background: var(--card-blue);
}

.gauge-content {
    position: absolute;
    display: grid;
    gap: 10px;
    text-align: center;
}

.gauge-content strong {
    font-size: 2.8rem;
    line-height: 1;
}

.gauge-content span {
    color: var(--muted);
    font-size: 1rem;
}

.gauge-content small {
    color: var(--muted);
    font-size: 0.88rem;
}

.summary-next-meal {
    margin: 16px 0 0;
    max-width: none;
    padding-top: 0;
    color: var(--muted);
    font-size: 0.94rem;
    line-height: 1.45;
    text-align: left;
}

.macro-list {
    display: grid;
    gap: 14px;
}

.macro-row {
    display: flex;
    align-items: end;
    justify-content: space-between;
    gap: 16px;
}

.macro-row strong {
    display: block;
    font-size: 1.2rem;
    margin-bottom: 6px;
}

.macro-row span {
    color: var(--muted);
    font-size: 1rem;
}

.macro-stat {
    color: var(--accent);
    font-size: 1.15rem;
    font-weight: 800;
}

.macro-bar {
    height: 14px;
    border-radius: 999px;
    background: rgba(77, 159, 230, 0.14);
    overflow: hidden;
    margin-bottom: 14px;
}

.macro-bar span {
    display: block;
    height: 100%;
    border-radius: inherit;
    background: var(--accent);
}

.macro-bar.protein {
    background: rgba(255, 191, 47, 0.18);
}

.macro-bar.protein span {
    background: var(--accent-warm);
}

.macro-bar.fat {
    background: rgba(73, 168, 119, 0.18);
}

.macro-bar.fat span {
    background: var(--accent-green);
}

.nutrition-list {
    display: grid;
    gap: 0;
    overflow: auto;
}

.nutrition-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 18px 0;
    border-bottom: 1px dashed #e2e8ef;
}

.nutrition-row:last-child {
    border-bottom: 0;
}

.nutrition-label {
    font-size: 1.1rem;
}

.nutrition-row strong {
    font-size: 1.05rem;
}

.nutrition-recommendation {
    margin: 16px 0 0;
    color: var(--muted);
    font-size: 0.94rem;
    line-height: 1.45;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.entries-empty {
    color: var(--muted);
    padding: 10px 0;
}

.entries-table {
    display: grid;
    gap: 0;
    overflow-y: auto;
    overflow-x: hidden;
    max-height: calc(var(--card-height) - 72px);
    scrollbar-width: none;
}

.entries-table::-webkit-scrollbar {
    width: 0;
    height: 0;
}

.entries-table-head,
.entries-row {
    display: grid;
    grid-template-columns: minmax(260px, 2.2fr) minmax(92px, 0.8fr) minmax(124px, 1fr) minmax(128px, 0.9fr);
    gap: 18px;
    align-items: start;
}

.entries-table-head {
    position: sticky;
    top: 0;
    z-index: 2;
    padding: 0 0 16px;
    border-bottom: 1px solid rgba(148, 163, 184, 0.18);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    font-size: 0.8rem;
    font-weight: 700;
    color: #8f9caf;
    background: var(--card-cream);
}

.entries-row {
    padding: 16px 0;
    border-bottom: 1px solid rgba(148, 163, 184, 0.14);
}

.entries-row:last-child {
    border-bottom: 0;
}

.entries-meal {
    display: grid;
    grid-template-columns: 80px 1fr;
    gap: 14px;
}

.entries-meal img {
    width: 80px;
    height: 80px;
    border-radius: 18px;
    object-fit: cover;
}

.entries-text-badge {
    display: grid;
    place-items: center;
    width: 80px;
    height: 80px;
    border-radius: 18px;
    background:
        radial-gradient(circle at 30% 25%, rgba(99, 179, 255, 0.14), transparent 42%),
        linear-gradient(180deg, #223449, #172332);
    border: 1px solid rgba(148, 163, 184, 0.16);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
    color: #b8d7ff;
    line-height: 1;
}

.entries-text-badge.text {
    font-size: 1.12rem;
    font-weight: 800;
    letter-spacing: 0.08em;
}

.entries-text-badge.symbol {
    font-size: 2rem;
    font-weight: 500;
    letter-spacing: 0;
    transform: translateY(-1px);
}

.entries-meal-copy h3 {
    margin: 0 0 8px;
    font-size: 1.15rem;
    line-height: 1.3;
}

.entries-meal-copy p {
    margin: 0;
    color: var(--muted);
    line-height: 1.55;
}

.entries-value,
.entries-time {
    font-size: 1.05rem;
    line-height: 1.45;
}

.entries-row-actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    justify-self: stretch;
    position: relative;
    width: 100%;
}

.entries-value {
    font-weight: 700;
}

.entries-time {
    text-align: left;
    white-space: nowrap;
}

.confidence-pill {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 10px 18px;
    border-radius: 999px;
    border: 0;
    font-weight: 700;
    font: inherit;
    background: rgba(77, 159, 230, 0.14);
    color: var(--accent);
    cursor: pointer;
}

.confidence-pill.low {
    background: rgba(195, 92, 92, 0.12);
    color: var(--danger);
}

.confidence-pill.medium {
    background: rgba(255, 191, 47, 0.16);
    color: #c48813;
}

.confidence-pill.high {
    background: rgba(73, 168, 119, 0.14);
    color: var(--accent-green);
}

.confidence-tooltip {
    position: absolute;
    z-index: 4;
    margin-top: 8px;
    max-width: 220px;
    padding: 10px 12px;
    border-radius: 14px;
    background: rgba(14, 21, 31, 0.98);
    border: 1px solid rgba(148, 163, 184, 0.14);
    box-shadow: 0 16px 36px rgba(2, 8, 20, 0.34);
    color: var(--ink);
    font-size: 0.9rem;
    line-height: 1.45;
}

.entry-menu {
    position: relative;
}

.entry-menu-button {
    display: inline-grid;
    place-items: center;
    width: 38px;
    height: 38px;
    border: 0;
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.08);
    color: #9eb0c6;
    cursor: pointer;
    box-shadow: 0 10px 24px rgba(2, 8, 20, 0.28);
    transition: background-color 160ms ease, color 160ms ease, transform 160ms ease, box-shadow 160ms ease;
}

.entry-menu-button:hover,
.entry-menu.is-open .entry-menu-button {
    background: rgba(255, 255, 255, 0.12);
    color: var(--ink);
    transform: translateY(-1px);
    box-shadow: 0 14px 28px rgba(2, 8, 20, 0.34);
}

.entry-menu-button svg {
    width: 18px;
    height: 18px;
    fill: currentColor;
}

.entry-menu-panel {
    position: absolute;
    right: 0;
    display: grid;
    min-width: 132px;
    padding: 8px;
    border-radius: 18px;
    background: rgba(18, 26, 36, 0.98);
    box-shadow: 0 18px 40px rgba(2, 8, 20, 0.42);
    animation: entry-menu-in 160ms cubic-bezier(0.2, 0.8, 0.2, 1);
    z-index: 5;
}

.entry-menu.open-down .entry-menu-panel {
    top: calc(100% + 8px);
    bottom: auto;
}

.entry-menu.open-up .entry-menu-panel {
    bottom: calc(100% + 8px);
    top: auto;
}

.entry-delete-button {
    border: 0;
    border-radius: 12px;
    padding: 10px 14px;
    background: rgba(255, 255, 255, 0.06);
    color: var(--ink);
    font: inherit;
    font-weight: 700;
    cursor: pointer;
    text-align: left;
    transition: background-color 160ms ease, transform 160ms ease;
}

.entry-delete-button:hover {
    background: rgba(255, 255, 255, 0.12);
    transform: translateY(-1px);
}

@keyframes entry-menu-in {
    from {
        opacity: 0;
        transform: translateY(6px) scale(0.96);
    }

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

.toast-region {
    position: fixed;
    top: 94px;
    left: 50%;
    transform: translateX(-50%);
    width: min(720px, calc(100% - 32px));
    display: grid;
    justify-items: center;
    pointer-events: none;
    z-index: 60;
}

.toast {
    width: 100%;
    padding: 14px 18px;
    border-radius: 18px;
    border: 1px solid rgba(148, 163, 184, 0.14);
    background: rgba(18, 26, 36, 0.94);
    color: var(--ink);
    font-weight: 500;
    box-shadow: 0 18px 40px rgba(2, 8, 20, 0.34);
    opacity: 1;
    transform: translateY(0);
    transition: opacity 220ms ease, transform 220ms ease;
}

.toast.success {
    color: var(--accent);
}

.toast.error {
    color: var(--danger);
}

.toast.is-hiding {
    opacity: 0;
    transform: translateY(-8px);
}

.fab-wrap {
    position: fixed;
    right: 28px;
    bottom: 28px;
    display: grid;
    justify-items: end;
    gap: 12px;
    z-index: 30;
}

.upload-actions {
    display: grid;
    gap: 10px;
    order: -1;
    transform-origin: bottom right;
}

.upload-actions:not([hidden]) {
    display: grid;
}

.upload-actions .upload-action-card {
    opacity: 0;
    transform: translateY(10px) scale(0.96);
    transition:
        opacity 160ms ease,
        transform 180ms cubic-bezier(0.2, 0.8, 0.2, 1),
        box-shadow 180ms ease,
        background-color 180ms ease;
}

.upload-actions.is-open .upload-action-card {
    opacity: 1;
    transform: translateY(0) scale(1);
}

.upload-actions.is-open .upload-action-card:nth-child(2) {
    transition-delay: 24ms;
}

.upload-action-card,
.upload-fab {
    border: 0;
    box-shadow: var(--shadow-card);
    cursor: pointer;
}

.upload-action-card {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    min-width: 180px;
    padding: 16px 18px;
    border-radius: 22px;
    background: rgba(18, 26, 36, 0.98);
    color: var(--ink);
    font-weight: 700;
    text-align: left;
    box-shadow:
        0 12px 28px rgba(2, 8, 20, 0.3),
        0 2px 8px rgba(2, 8, 20, 0.22);
}

.upload-action-card:hover {
    background: #192231;
    box-shadow:
        0 18px 34px rgba(2, 8, 20, 0.34),
        0 4px 10px rgba(2, 8, 20, 0.24);
}

.upload-action-card span:last-child {
    display: inline-block;
    min-width: 72px;
    font-size: 1rem;
    line-height: 1;
}

.upload-action-icon {
    display: inline-grid;
    place-items: center;
    width: 42px;
    height: 42px;
    border-radius: 14px;
    background: linear-gradient(180deg, #1a2a3d, #142233);
    color: var(--accent);
    flex: 0 0 42px;
}

.upload-action-icon svg {
    width: 20px;
    height: 20px;
}

.upload-fab {
    display: grid;
    place-items: center;
    width: 62px;
    height: 62px;
    border-radius: 50%;
    background: rgba(18, 26, 36, 0.96);
    color: var(--accent);
    font-size: 2rem;
    line-height: 1;
    box-shadow: var(--shadow-card);
    transition: transform 180ms ease, box-shadow 180ms ease;
}

.quick-camera-fab {
    display: none;
    place-items: center;
    width: 54px;
    height: 54px;
    border: 0;
    border-radius: 18px;
    background: rgba(18, 26, 36, 0.96);
    color: var(--accent);
    box-shadow: var(--shadow-card);
    cursor: pointer;
}

.quick-camera-fab svg {
    width: 22px;
    height: 22px;
}

.upload-fab:hover {
    transform: translateY(-2px);
    box-shadow: 0 24px 40px rgba(2, 8, 20, 0.4);
}

.upload-fab[aria-expanded="true"] {
    transform: rotate(45deg);
}

.analysis-overlay {
    position: fixed;
    inset: 0;
    display: grid;
    place-items: center;
    padding: 24px;
    background: rgba(8, 12, 20, 0.72);
    backdrop-filter: blur(8px);
    z-index: 40;
}

.analysis-card {
    width: min(420px, 100%);
    padding: 28px 30px;
    border-radius: 28px;
    background: rgba(18, 26, 36, 0.98);
    box-shadow: 0 24px 60px rgba(2, 8, 20, 0.42);
    text-align: center;
}

.analysis-card strong {
    display: block;
    margin-bottom: 10px;
    font-size: 1.1rem;
}

.analysis-card p {
    margin: 0;
    color: var(--muted);
    line-height: 1.55;
}

.text-entry-overlay {
    position: fixed;
    inset: 0;
    display: grid;
    place-items: center;
    padding: 24px;
    background: rgba(8, 12, 20, 0.62);
    backdrop-filter: blur(8px);
    z-index: 45;
}

.text-entry-card {
    width: min(460px, 100%);
    padding: 24px;
    border-radius: 28px;
    background: rgba(18, 26, 36, 0.98);
    box-shadow: 0 24px 60px rgba(2, 8, 20, 0.42);
}

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

.text-entry-header strong {
    font-size: 1.1rem;
}

.text-entry-close {
    width: 38px;
    height: 38px;
    border: 0;
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.08);
    color: var(--ink);
    font: inherit;
    font-size: 1.3rem;
    cursor: pointer;
}

.text-entry-card p {
    margin: 0 0 16px;
    color: var(--muted);
    line-height: 1.5;
}

.text-entry-form {
    display: grid;
    gap: 14px;
}

.text-entry-form textarea {
    min-height: 140px;
    resize: vertical;
    border: 1px solid var(--line);
    border-radius: 18px;
    padding: 14px 16px;
    background: #0f1722;
    color: var(--ink);
    font: inherit;
    line-height: 1.5;
}

.text-entry-submit {
    border: 0;
    border-radius: 999px;
    padding: 12px 18px;
    background: var(--accent);
    color: #fff;
    font: inherit;
    font-weight: 700;
    cursor: pointer;
}

.camera-overlay {
    position: fixed;
    inset: 0;
    display: grid;
    place-items: center;
    padding: 24px;
    background: rgba(8, 12, 20, 0.74);
    backdrop-filter: blur(10px);
    z-index: 46;
}

.camera-card {
    width: min(520px, 100%);
    padding: 20px;
    border-radius: 28px;
    background: rgba(18, 26, 36, 0.98);
    box-shadow: 0 24px 60px rgba(2, 8, 20, 0.42);
}

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

.camera-header strong {
    font-size: 1.05rem;
}

.camera-close {
    width: 38px;
    height: 38px;
    border: 0;
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.08);
    color: var(--ink);
    font: inherit;
    font-size: 1.3rem;
    cursor: pointer;
}

.camera-stage {
    position: relative;
    overflow: hidden;
    border-radius: 24px;
    background: #0b121b;
    border: 1px solid rgba(148, 163, 184, 0.12);
    aspect-ratio: 3 / 4;
}

.camera-preview {
    width: 100%;
    height: 100%;
    display: block;
    object-fit: cover;
    background: #0b121b;
}

.camera-placeholder {
    position: absolute;
    inset: 0;
    display: grid;
    place-items: center;
    padding: 24px;
    text-align: center;
    color: var(--muted);
    line-height: 1.5;
}

.camera-actions {
    display: flex;
    gap: 12px;
    margin-top: 16px;
}

.camera-primary,
.camera-secondary {
    flex: 1;
    border: 0;
    border-radius: 999px;
    padding: 12px 16px;
    font: inherit;
    font-weight: 700;
    cursor: pointer;
}

.camera-primary {
    background: var(--accent);
    color: #fff;
}

.camera-secondary {
    background: rgba(255, 255, 255, 0.08);
    color: var(--ink);
}

.analysis-spinner {
    width: 52px;
    height: 52px;
    margin: 0 auto 16px;
    border-radius: 50%;
    border: 4px solid rgba(77, 159, 230, 0.16);
    border-top-color: var(--accent);
    animation: spin 0.9s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

@media (max-width: 1180px) {
    .focus-grid {
        grid-template-columns: 1fr 1fr;
        grid-template-areas:
            "summary nutrition"
            "macros macros"
            "entries entries";
    }

    .card.wide {
        grid-column: span 2;
    }

    :root {
        --card-height: 400px;
    }

    .entries-table-head,
    .entries-row {
        grid-template-columns: minmax(220px, 2fr) minmax(84px, 0.8fr) minmax(118px, 1fr) minmax(118px, 0.9fr);
    }

    .account-grid,
    .account-macro-grid {
        grid-template-columns: 1fr 1fr;
    }
}

@media (max-width: 760px) {
    .session-bar,
    .session-actions {
        flex-wrap: wrap;
    }

    .app-header {
        flex-wrap: wrap;
        padding: 16px;
    }

    .brand-copy span {
        white-space: normal;
    }

    .session-actions {
        margin-left: 0;
        margin-right: 0;
    }

    .date-filter-row {
        flex-wrap: wrap;
    }

    .account-grid,
    .account-macro-grid {
        grid-template-columns: 1fr;
    }

    .account-menu-panel {
        width: min(260px, calc(100vw - 32px));
    }

    .page {
        width: min(100%, calc(100% - 16px));
        margin: 8px auto;
        padding-bottom: 112px;
    }

    .toast-region {
        top: 88px;
        width: calc(100% - 24px);
    }

    .focus-grid {
        grid-template-columns: 1fr;
        grid-template-areas:
            "summary"
            "nutrition"
            "macros"
            "entries";
    }

    .card,
    .card.wide {
        grid-column: span 1;
        min-height: auto;
    }

    .card {
        padding: 24px;
    }

    .card.tall {
        min-height: auto;
    }

    #nutrition-facts {
        min-height: auto;
    }

    .card,
    .card.wide {
        height: auto;
        min-height: auto;
    }

    .entries-table {
        max-height: none;
        padding-bottom: 96px;
    }

    #today-entries {
        padding-bottom: 28px;
    }

    .gauge {
        width: 200px;
        height: 200px;
    }

    .gauge::before {
        width: 156px;
        height: 156px;
    }

    .gauge-content strong {
        font-size: 2.5rem;
    }

    .entries-table-head {
        display: none;
    }

    .entries-row {
        grid-template-columns: minmax(0, 1fr) auto auto;
        grid-template-areas:
            "meal meal meal"
            "value confidence actions"
            "time time actions";
        gap: 10px 12px;
        align-items: start;
        padding: 18px 0;
    }

    .entries-row > .entries-meal {
        grid-area: meal;
        min-width: 0;
    }

    .entries-row > .entries-value {
        grid-area: value;
        align-self: center;
        font-size: 1.65rem;
        line-height: 1;
    }

    .entries-row > div:nth-child(3) {
        grid-area: confidence;
        justify-self: start;
        align-self: center;
    }

    .entries-row-actions {
        grid-area: actions;
        display: flex;
        flex-direction: column;
        align-items: flex-end;
        justify-content: center;
        justify-self: end;
        width: auto;
        min-width: 0;
        gap: 8px;
    }

    .entries-time {
        grid-area: time;
        text-align: left;
        font-size: 1rem;
        white-space: nowrap;
        color: var(--muted);
    }

    .entries-meal {
        grid-template-columns: 82px 1fr;
        gap: 14px;
        align-items: start;
    }

    .entries-meal img {
        width: 82px;
        height: 82px;
        border-radius: 20px;
    }

    .entries-text-badge {
        width: 82px;
        height: 82px;
        border-radius: 20px;
    }

    .entries-meal-copy {
        min-width: 0;
    }

    .entries-meal-copy h3 {
        margin-bottom: 6px;
        font-size: 1rem;
        line-height: 1.3;
    }

    .entries-meal-copy p {
        font-size: 0.98rem;
        line-height: 1.45;
    }

    .confidence-pill {
        padding: 8px 14px;
        font-size: 0.98rem;
    }

    .entry-menu-button {
        width: 40px;
        height: 40px;
        border-radius: 14px;
    }

    .fab-wrap {
        right: 16px;
        bottom: calc(16px + env(safe-area-inset-bottom, 0px));
    }

    .upload-fab {
        width: 56px;
        height: 56px;
        font-size: 1.65rem;
    }

    .quick-camera-fab {
        display: grid;
        width: 50px;
        height: 50px;
    }

    .camera-overlay {
        padding: 16px;
    }

    .camera-card {
        padding: 16px;
        border-radius: 24px;
    }

}
