:root {
    --ink: #20241f;
    --muted: #6d7168;
    --paper: #f6f2e9;
    --paper-deep: #ece6da;
    --line: #d8d1c4;
    --accent: #d95f3d;
    --accent-dark: #a73e28;
    --green: #2f7258;
    --danger: #ad392b;
    --shadow: 0 18px 46px rgb(75 55 36 / 12%);
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    color: var(--ink);
    background: var(--paper);
    font-synthesis: none;
}

* { box-sizing: border-box; }
html { min-height: 100%; background: var(--paper); }
body { min-height: 100%; margin: 0; background: radial-gradient(circle at 50% -20%, #fffdf7 0, var(--paper) 45%); }
button, input, select { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
button { cursor: pointer; }
button:disabled { cursor: wait; opacity: .58; }

.app-shell { max-width: 780px; min-height: 100svh; margin: 0 auto; padding: 28px 22px 108px; }
.welcome { display: flex; min-height: 82svh; max-width: 470px; flex-direction: column; justify-content: center; }
.loading-state { animation: fade-in .35s ease both; }
.eyebrow { margin: 0 0 8px; color: var(--muted); font-size: .68rem; font-weight: 800; letter-spacing: .16em; }
.welcome h1, .trip-header h1 { margin: 0 0 22px; font-family: Georgia, "Times New Roman", serif; font-size: clamp(2.65rem, 9vw, 4.7rem); font-weight: 500; letter-spacing: -.055em; line-height: .96; }
.lede { max-width: 38ch; margin: 0 0 28px; color: var(--muted); font-size: 1.04rem; line-height: 1.6; }

label { display: grid; gap: 7px; margin: 14px 0; font-size: .8rem; font-weight: 750; }
input, select { width: 100%; min-height: 42px; padding: 9px 2px; border: 0; border-bottom: 1px solid var(--line); border-radius: 0; outline: 0; background: transparent; color: var(--ink); }
input::placeholder { color: #9a9a90; }
input:focus, select:focus { border-color: var(--accent); box-shadow: 0 2px 0 -1px var(--accent); }

.primary, .accent, .member-choice, .file-action { min-height: 44px; border: 0; border-radius: 999px; font-weight: 800; }
.primary { padding: 13px 18px; background: var(--ink); color: white; }
.accent { padding: 11px 16px; background: var(--accent); color: white; box-shadow: 0 8px 22px rgb(217 95 61 / 20%); }
.plain { border: 0; background: transparent; color: var(--ink); font-weight: 750; text-decoration: none; }
.plain:hover, .plain:focus-visible { color: var(--accent-dark); }
.danger { color: var(--danger); }
.icon-button { display: inline-grid; width: 42px; height: 42px; padding: 0; flex: 0 0 auto; place-items: center; border: 1px solid var(--line); border-radius: 50%; background: transparent; color: var(--ink); font-size: 1.25rem; }

.entry-switch { display: flex; gap: 22px; margin: 18px 0 22px; border-bottom: 1px solid var(--line); }
.entry-switch button { padding: 11px 0 10px; border: 0; border-bottom: 2px solid transparent; background: transparent; color: var(--muted); font-weight: 750; }
.entry-switch button.active { border-color: var(--accent); color: var(--ink); }
.member-picker, .consumer-picker { display: flex; flex-wrap: wrap; gap: 8px; }
.member-choice, .consumer { padding: 9px 13px; border: 1px solid var(--line); background: rgb(255 255 255 / 26%); color: var(--ink); }
.member-choice:hover { border-color: var(--accent); }
.hint, .notice, .field-help, .privacy-note, .empty-state span { color: var(--muted); line-height: 1.5; }
.notice { padding-left: 12px; border-left: 2px solid var(--accent); }

.trip-header { display: flex; align-items: flex-start; justify-content: space-between; padding: 12px 0 25px; border-bottom: 1px solid var(--line); }
.trip-header h1 { margin: 0; font-size: clamp(2.35rem, 7vw, 3.65rem); }
.status-dot { display: inline-block; width: 7px; height: 7px; margin-right: 4px; border-radius: 50%; background: var(--muted); }
.status-dot.online { background: var(--green); box-shadow: 0 0 0 3px rgb(47 114 88 / 12%); }
.status-dot.offline { background: var(--accent); }
.workspace { padding-top: 28px; }
.section-title { display: flex; align-items: end; justify-content: space-between; gap: 16px; margin-bottom: 20px; }
.section-title h2, .settlement-heading h3 { margin: 0; font-family: Georgia, "Times New Roman", serif; font-size: 2rem; font-weight: 500; letter-spacing: -.04em; }

.empty-state { display: grid; gap: 5px; padding: 44px 0; border-top: 1px solid var(--line); text-align: center; }
.bill-row, .balance-row, .member-row, .transfer { display: flex; align-items: center; justify-content: space-between; gap: 18px; padding: 17px 0; border-bottom: 1px solid var(--line); }
.member-row > span:last-child { display: flex; align-items: center; justify-content: flex-end; flex-wrap: wrap; gap: 4px; }
.bill-copy { display: grid; min-width: 0; gap: 4px; }
.bill-copy > strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bill-copy > span, .member-row small { color: var(--muted); font-size: .8rem; }
.bill-side { display: grid; flex: 0 0 auto; justify-items: end; gap: 5px; }
.bill-side > b, .balance-row b, .transfer b { white-space: nowrap; font-variant-numeric: tabular-nums; }
.row-actions { display: flex; gap: 12px; }
.row-actions .plain { padding: 2px 0; font-size: .72rem; }
.pending-bill { opacity: .72; border-bottom-style: dashed; }
.pending-bill .bill-side small { color: var(--accent-dark); font-size: .68rem; }
.positive { color: var(--green); }
.negative { color: var(--accent-dark); }

.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); column-gap: 20px; }
.field-help { margin: 0 0 9px; font-size: .8rem; }
.consumer { display: flex; align-items: center; gap: 6px; margin: 0; font-size: .76rem; font-weight: 700; }
.consumer input { width: auto; min-height: 0; margin: 0; padding: 0; accent-color: var(--accent); }
.item-list { border-top: 1px solid var(--line); }
.item-editor { padding: 14px 0; border-bottom: 1px solid var(--line); }
.item-fields { display: grid; grid-template-columns: minmax(0, 1fr) minmax(92px, .4fr) 42px; gap: 12px; align-items: end; }
.item-fields input { margin: 0; }
.add-line { margin: 14px 0 4px; color: var(--accent-dark); }
.tip-line { display: flex; gap: 18px; }
.tip-line label { flex: 1; }

.photos { display: grid; gap: 11px; margin-top: 23px; padding-top: 20px; border-top: 1px solid var(--line); }
.photos p { margin-top: 0; }
.photo-actions { display: flex; flex-wrap: wrap; gap: 9px; }
.file-action { display: inline-flex; align-items: center; margin: 0; padding: 10px 14px; border: 1px solid var(--line); background: rgb(255 255 255 / 28%); font-size: .78rem; }
.file-action:focus-within { border-color: var(--accent); }
.file-action input { position: absolute; width: 1px; height: 1px; min-height: 0; padding: 0; clip: rect(0, 0, 0, 0); overflow: hidden; white-space: nowrap; }
.privacy-note { margin: 0; padding: 10px 12px; border-left: 2px solid #b99046; background: rgb(185 144 70 / 8%); font-size: .76rem; }
.queued-photo { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 9px 0; border-bottom: 1px solid var(--line); font-size: .8rem; }
.queued-photo span { display: grid; gap: 2px; overflow-wrap: anywhere; }
.queued-photo small { color: var(--muted); }
.queued-photo em { color: var(--danger); font-size: .72rem; font-style: normal; }
.sticky { position: sticky; bottom: 84px; width: 100%; margin-top: 28px; box-shadow: var(--shadow); }

.settlement-heading { margin: 34px 0 8px; }
.transfer { justify-content: flex-start; }
.transfer i { color: var(--accent); font-style: normal; font-weight: 900; }
.transfer b { margin-left: auto; }
.join-section { margin-top: 30px; padding-top: 20px; border-top: 1px solid var(--line); }
.join-code { display: block; margin: 8px 0; color: var(--accent-dark); font-size: .78rem; overflow-wrap: anywhere; }
.sign-out { margin-top: 28px; }

.bottom-nav { position: fixed; z-index: 5; right: 0; bottom: 0; left: 0; display: flex; justify-content: center; padding: 8px max(8px, env(safe-area-inset-right)) calc(8px + env(safe-area-inset-bottom)) max(8px, env(safe-area-inset-left)); border-top: 1px solid var(--line); background: rgb(246 242 233 / 92%); backdrop-filter: blur(18px); }
.bottom-nav button { display: grid; min-width: 76px; min-height: 52px; padding: 5px 12px; place-items: center; gap: 1px; border: 0; border-radius: 12px; background: transparent; color: var(--muted); font-size: .69rem; font-weight: 800; }
.bottom-nav button span { font-size: 1rem; line-height: 1; }
.bottom-nav button.selected { background: rgb(217 95 61 / 8%); color: var(--accent-dark); }

.toast { position: fixed; z-index: 20; bottom: calc(78px + env(safe-area-inset-bottom)); left: 50%; width: max-content; max-width: min(90vw, 520px); padding: 12px 16px; transform: translateX(-50%); border: 0; border-radius: 11px; background: var(--ink); box-shadow: var(--shadow); color: white; font-size: .82rem; text-align: left; animation: toast-in .2s ease both; }

.loading-progress { position: absolute; top: 50%; left: 50%; width: 5rem; height: 5rem; transform: translate(-50%, -50%) rotate(-90deg); }
.loading-progress circle { fill: none; stroke: var(--line); stroke-width: .55rem; }
.loading-progress circle:last-child { stroke: var(--accent); stroke-dasharray: calc(3.141 * var(--blazor-load-percentage, 0%)), 500%; transition: stroke-dasharray .05s ease-in-out; }
.loading-progress-text { position: absolute; top: calc(50% + 3.2rem); width: 100%; text-align: center; font-size: .75rem; }
#blazor-error-ui { position: fixed; z-index: 100; right: 16px; bottom: 16px; display: none; padding: 12px; background: #fff2d0; box-shadow: var(--shadow); }

@keyframes fade-in { from { opacity: 0; transform: translateY(4px); } }
@keyframes toast-in { from { opacity: 0; transform: translate(-50%, 6px); } }

@media (max-width: 520px) {
    .app-shell { padding: 20px 16px 108px; }
    .form-grid { grid-template-columns: 1fr; }
    .welcome h1 { font-size: 3.05rem; }
    .section-title h2 { font-size: 1.75rem; }
    .bill-row { align-items: flex-start; }
    .item-fields { grid-template-columns: minmax(0, 1fr) 92px 42px; gap: 8px; }
    .tip-line { gap: 12px; }
    .bottom-nav button { min-width: 0; flex: 1; padding-inline: 7px; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
