/* =====================================================================
   JARAN GIFT — styles
   Layout concept: a wedding "gift book" table card centred on the page;
   the couple's cover (photo, names, date) on top, the typing box in the
   middle, live list below. Each of the 10 layouts is its own visual world
   (set with data-layout), so colours are defined explicitly per layout.
   ===================================================================== */
:root {
  --font-display: "Cormorant Garamond", "Noto Serif Khmer", Georgia, serif;
  --font-body: "Kantumruy Pro", "Noto Sans Khmer", system-ui, -apple-system, "Segoe UI", sans-serif;

  /* Jaran brand (login + admin): navy & silver */
  --bg: #F4F5F8;
  --surface: #FFFFFF;
  --surface-2: #EEF0F5;
  --ink: #18213A;
  --muted: #69728A;
  --line: #DCE0EA;
  --accent: #1E2C52;
  --accent-ink: #FFFFFF;
  --accent-2: #A8B0C2;
  --hero: linear-gradient(160deg, #1E2C52, #2F416F);
  --hero-ink: #F3F4F8;
  --hero-muted: #C3C9D8;
  --ornament: none;

  --ok: #1F7A4D;
  --ok-bg: #E6F4EC;
  --warn: #8A5A00;
  --warn-bg: #FFF4CC;
  --bad: #B3261E;
  --bad-bg: #FCE9E7;

  --radius: 14px;
  --radius-sm: 9px;
  --shadow: 0 1px 2px rgba(20, 20, 40, .06), 0 8px 28px rgba(20, 20, 40, .07);
  color-scheme: light;
}

/* ---------- 10 wedding layouts ---------- */
[data-layout="ivory"] {
  --bg: #FAF7F1; --surface: #FFFFFF; --surface-2: #F3EEE4; --ink: #2F2A22; --muted: #877D6C; --line: #E8E0D0;
  --accent: #A9853F; --accent-ink: #FFFFFF; --accent-2: #D9C9A3;
  --hero: linear-gradient(175deg, #FFFDF8 0%, #F1E7D3 100%); --hero-ink: #3A3225; --hero-muted: #8C7F66;
}
[data-layout="champagne"] {
  --bg: #F9F2EC; --surface: #FFFDFB; --surface-2: #F3E7DE; --ink: #3B2E29; --muted: #957E73; --line: #EBDCD1;
  --accent: #B98C68; --accent-ink: #FFFFFF; --accent-2: #E8CDBB;
  --hero: linear-gradient(170deg, #FBEFE7 0%, #EED6C6 100%); --hero-ink: #4A362D; --hero-muted: #9A7D6E;
}
[data-layout="khmer-royal"] {
  --bg: #FBF4EA; --surface: #FFFBF4; --surface-2: #F4E6D3; --ink: #3A1511; --muted: #8C665A; --line: #E9D4BD;
  --accent: #8E1A17; --accent-ink: #FFF6E3; --accent-2: #C9A04A;
  --hero: linear-gradient(180deg, #7C1512 0%, #5E0F0D 100%); --hero-ink: #F4D88F; --hero-muted: #E2C27A;
  --ornament: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='28' height='14' viewBox='0 0 28 14'%3E%3Cpath d='M0 7 L7 0 L14 7 L7 14Z M14 7 L21 0 L28 7 L21 14Z' fill='none' stroke='%23C9A04A' stroke-width='1.2'/%3E%3Ccircle cx='7' cy='7' r='1.6' fill='%23C9A04A'/%3E%3Ccircle cx='21' cy='7' r='1.6' fill='%23C9A04A'/%3E%3C/svg%3E");
}
[data-layout="minimal"] {
  --bg: #FFFFFF; --surface: #FFFFFF; --surface-2: #F4F4F2; --ink: #151515; --muted: #767672; --line: #E6E6E2;
  --accent: #151515; --accent-ink: #FFFFFF; --accent-2: #CFCFCA;
  --hero: #FFFFFF; --hero-ink: #151515; --hero-muted: #767672;
}
[data-layout="emerald"] {
  --bg: #F2F5F1; --surface: #FFFFFF; --surface-2: #E6EEE8; --ink: #12281E; --muted: #5C7366; --line: #D3E0D7;
  --accent: #1D5A40; --accent-ink: #FFFFFF; --accent-2: #C7A65A;
  --hero: linear-gradient(170deg, #17442F 0%, #0F3022 100%); --hero-ink: #F1E3B8; --hero-muted: #C9D8C6;
}
[data-layout="navy"] {
  --bg: #F3F4F8; --surface: #FFFFFF; --surface-2: #E8EBF2; --ink: #151C2E; --muted: #646E88; --line: #DBDFE9;
  --accent: #1B2948; --accent-ink: #FFFFFF; --accent-2: #CDAE66;
  --hero: linear-gradient(170deg, #1C2A4C 0%, #121C35 100%); --hero-ink: #E9D39B; --hero-muted: #B8C0D6;
}
[data-layout="rustic"] {
  --bg: #F4EEE4; --surface: #FFFCF6; --surface-2: #ECE2D2; --ink: #382D22; --muted: #826F5B; --line: #E0D3BF;
  --accent: #6E7E50; --accent-ink: #FFFFFF; --accent-2: #C8B08A;
  --hero: linear-gradient(175deg, #EFE3CF 0%, #E2D1B5 100%); --hero-ink: #3E3226; --hero-muted: #7D6A55;
}
[data-layout="rose"] {
  --bg: #FCF4F5; --surface: #FFFFFF; --surface-2: #F7E7EA; --ink: #3C2128; --muted: #977580; --line: #F0D9DE;
  --accent: #A9505F; --accent-ink: #FFFFFF; --accent-2: #E9BFC8;
  --hero: linear-gradient(170deg, #FBE7EA 0%, #F2CDD4 100%); --hero-ink: #4A2830; --hero-muted: #9B6E79;
}
[data-layout="blacktie"] {
  --bg: #111111; --surface: #1B1B1B; --surface-2: #242424; --ink: #F1ECE2; --muted: #A49B8A; --line: #33302B;
  --accent: #CDAA5E; --accent-ink: #141414; --accent-2: #6E5E3A;
  --hero: linear-gradient(180deg, #0A0A0A 0%, #161616 100%); --hero-ink: #E4C77F; --hero-muted: #A49B8A;
  --ok-bg: #16301F; --ok: #7FD0A0; --warn-bg: #3A2F0E; --warn: #F2D27A; --bad-bg: #3B1614; --bad: #F2948C;
  --shadow: 0 1px 2px rgba(0, 0, 0, .5), 0 8px 28px rgba(0, 0, 0, .45);
  color-scheme: dark;
}
[data-layout="pastel"] {
  --bg: #F7F6FB; --surface: #FFFFFF; --surface-2: #EFEDF7; --ink: #2E2B3C; --muted: #7F7B93; --line: #E3E0EF;
  --accent: #7E74BE; --accent-ink: #FFFFFF; --accent-2: #F3C9B7;
  --hero: linear-gradient(135deg, #DDF1EA 0%, #E6E1F6 50%, #FBE3D8 100%); --hero-ink: #34304A; --hero-muted: #7F7B93;
}

/* ---------- base ---------- */
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { min-height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--accent); }
h1, h2, h3 { text-wrap: balance; margin: 0; line-height: 1.2; }
.num { font-variant-numeric: tabular-nums; }
:focus-visible { outline: 3px solid color-mix(in srgb, var(--accent) 55%, transparent); outline-offset: 2px; }
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }

.wrap {
  width: 100%;
  max-width: 760px;
  margin: 0 auto;
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
}
.wrap.wide { max-width: 1100px; }

/* ---------- buttons & inputs ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .45em;
  min-height: 44px; padding: 0 18px;
  border: 1px solid var(--line); border-radius: 999px;
  background: var(--surface); color: var(--ink);
  font-weight: 600; font-size: .95rem; cursor: pointer; text-decoration: none;
  transition: background .15s, border-color .15s, transform .05s;
}
.btn:hover { border-color: var(--accent-2); }
.btn:active { transform: translateY(1px); }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.danger { background: var(--bad); border-color: var(--bad); color: #fff; }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.small { min-height: 34px; padding: 0 12px; font-size: .85rem; }
.btn.block { width: 100%; }
.btn.big { min-height: 58px; font-size: 1.15rem; border-radius: var(--radius); }

.field { display: grid; gap: 6px; }
.field > span { font-size: .8rem; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; color: var(--muted); }
.input, select.input, textarea.input {
  width: 100%; min-height: 48px; padding: 10px 14px;
  border: 1.5px solid var(--line); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--ink);
}
textarea.input { min-height: 110px; resize: vertical; }
.input:focus { border-color: var(--accent); outline: none; box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 18%, transparent); }
.input.xl { min-height: 60px; font-size: 1.35rem; font-weight: 600; }
.hint { font-size: .85rem; color: var(--muted); }

.seg { display: inline-grid; grid-auto-flow: column; grid-auto-columns: 1fr; border: 1.5px solid var(--line); border-radius: var(--radius-sm); overflow: hidden; background: var(--surface); }
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg label { display: flex; align-items: center; justify-content: center; min-height: 48px; padding: 0 14px; font-weight: 600; cursor: pointer; color: var(--muted); white-space: nowrap; }
.seg label:not(:first-of-type) { border-left: 1.5px solid var(--line); }
.seg input:checked + label { background: var(--accent); color: var(--accent-ink); }
.seg input:focus-visible + label { outline: 3px solid color-mix(in srgb, var(--accent) 55%, transparent); outline-offset: -3px; }

.switch { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 0; }
.switch input { width: 46px; height: 26px; accent-color: var(--accent); }

.pill { display: inline-flex; align-items: center; gap: 4px; padding: 2px 9px; border-radius: 999px; font-size: .75rem; font-weight: 700; letter-spacing: .03em; white-space: nowrap; }
.pill.ok { background: var(--ok-bg); color: var(--ok); }
.pill.warn { background: var(--warn-bg); color: var(--warn); }
.pill.bad { background: var(--bad-bg); color: var(--bad); }
.pill.neutral { background: var(--surface-2); color: var(--muted); }
.pill.aba { background: color-mix(in srgb, var(--accent) 14%, var(--surface)); color: var(--accent); }

/* ---------- login ---------- */
.login { min-height: 100vh; display: grid; place-items: center; padding-block: 32px; }
.login-card { width: 100%; max-width: 440px; background: var(--surface); border-radius: 22px; box-shadow: var(--shadow); overflow: hidden; }
.login-top { background: var(--hero); color: var(--hero-ink); padding: 34px 28px 28px; text-align: center; }
.wordmark { font-family: var(--font-display); font-size: 2.6rem; font-weight: 600; letter-spacing: .02em; line-height: 1; }
.wordmark small { display: block; font-family: var(--font-body); font-size: .72rem; letter-spacing: .32em; text-transform: uppercase; color: var(--hero-muted); margin-top: 10px; font-weight: 600; }
.login-top p { margin: 14px 0 0; color: var(--hero-muted); font-size: .95rem; }
.login-body { padding: 22px 24px 26px; display: grid; gap: 16px; }
.tabs { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 4px; padding: 4px; background: var(--surface-2); border-radius: 999px; }
.tabs button { min-height: 40px; border: 0; border-radius: 999px; background: transparent; font-weight: 600; color: var(--muted); cursor: pointer; }
.tabs button[aria-selected="true"] { background: var(--surface); color: var(--ink); box-shadow: 0 1px 3px rgba(0,0,0,.08); }
.divider { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: .8rem; }
.divider::before, .divider::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.demo-box { border: 1.5px dashed var(--accent-2); border-radius: var(--radius); padding: 14px; display: grid; gap: 10px; background: var(--surface-2); }
.demo-box .row { display: flex; flex-wrap: wrap; gap: 8px; }
.g-btn { background: var(--surface); }
.g-btn svg { width: 18px; height: 18px; }

/* ---------- wedding cover (header) ---------- */
.cover {
  background: var(--hero); color: var(--hero-ink);
  margin-top: calc(-1 * env(safe-area-inset-top, 0px));
  padding-top: calc(env(safe-area-inset-top, 0px) + 18px);
  padding-bottom: 22px;
  position: relative;
}
.cover::after {
  content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 14px;
  background: var(--ornament); background-repeat: repeat-x; background-position: center; opacity: .9;
}
.cover-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; font-size: .8rem; color: var(--hero-muted); }
.cover-top .btn { min-height: 34px; background: color-mix(in srgb, var(--hero-ink) 12%, transparent); border-color: transparent; color: var(--hero-ink); }
.cover-main { display: flex; align-items: center; gap: 18px; margin-top: 12px; }
.photo-frame {
  flex: 0 0 auto; width: 92px; height: 92px; border-radius: 50%; overflow: hidden;
  border: 3px solid color-mix(in srgb, var(--hero-ink) 55%, transparent);
  box-shadow: 0 0 0 5px color-mix(in srgb, var(--hero-ink) 12%, transparent);
  background: color-mix(in srgb, var(--hero-ink) 10%, transparent);
  display: grid; place-items: center;
}
.photo-frame img { width: 100%; height: 100%; object-fit: cover; display: block; }
.photo-frame .initials { font-family: var(--font-display); font-size: 2rem; font-weight: 600; color: var(--hero-ink); }
.couple-names { font-family: var(--font-display); font-weight: 600; font-size: clamp(1.9rem, 6vw, 2.6rem); line-height: 1.05; }
.couple-names .amp { font-style: italic; font-weight: 400; color: var(--hero-muted); padding: 0 .15em; }
.cover-meta { margin-top: 6px; font-size: .9rem; color: var(--hero-muted); display: flex; flex-wrap: wrap; gap: 6px 14px; }
.sync { display: inline-flex; align-items: center; gap: 6px; }
.sync::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: #3DBE7B; }
.sync.wait::before { background: #E6A700; }
.sync.off::before { background: #D6453D; }

.test-banner { background: #FFE27A; color: #4A3700; text-align: center; font-weight: 700; font-size: .9rem; padding: 8px 16px; letter-spacing: .02em; }
.support-banner { background: var(--ink); color: var(--bg); text-align: center; font-size: .85rem; padding: 7px 16px; }

/* ---------- nav ---------- */
.nav { position: sticky; top: env(safe-area-inset-top, 0px); z-index: 5; background: var(--bg); border-bottom: 1px solid var(--line); }
body::before { content: ""; position: fixed; inset: 0 0 auto; height: env(safe-area-inset-top, 0px); z-index: 10; background: var(--bg); }
.nav .wrap { display: flex; gap: 2px; overflow-x: auto; scrollbar-width: none; }
.nav button { flex: 0 0 auto; min-height: 50px; padding: 0 14px; border: 0; background: none; color: var(--muted); font-weight: 600; cursor: pointer; border-bottom: 3px solid transparent; }
.nav button[aria-current="page"] { color: var(--ink); border-bottom-color: var(--accent); }

main { padding-block: 20px 28px; }
.stack { display: grid; gap: 16px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; }
.card h2 { font-size: 1.1rem; font-family: var(--font-body); font-weight: 700; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 12px; flex-wrap: wrap; }
.section-title { font-family: var(--font-display); font-size: 1.6rem; font-weight: 600; }

/* ---------- entry screen ---------- */
.entry-layout { display: grid; gap: 18px; }
.entry-card { background: var(--surface); border-radius: 20px; box-shadow: var(--shadow); padding: 22px 20px; border: 1px solid var(--line); }
.monogram { display: block; margin: 0 auto 14px; max-height: 76px; max-width: 160px; object-fit: contain; }
.entry-form { display: grid; gap: 14px; }
.amount-row { display: grid; grid-template-columns: 1fr auto; gap: 10px; align-items: end; }
.sugg { display: flex; flex-wrap: wrap; gap: 8px; margin-top: -4px; }
.sugg-item { min-height: 40px; max-width: 100%; padding: 0 14px; border: 1.5px solid var(--accent-2); border-radius: 999px; background: var(--surface-2); color: var(--ink); font-weight: 600; font-size: .95rem; cursor: pointer; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sugg-item:active { background: var(--accent); color: var(--accent-ink); }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { min-height: 38px; padding: 0 14px; border: 1.5px solid var(--line); border-radius: 999px; background: var(--surface-2); font-weight: 600; cursor: pointer; font-size: .9rem; }
.chip:hover { border-color: var(--accent); }
.flash { margin-top: 14px; padding: 12px 14px; border-radius: var(--radius-sm); background: var(--ok-bg); color: var(--ok); font-weight: 600; display: flex; align-items: center; justify-content: space-between; gap: 10px; animation: pop .25s ease-out; }
.flash .env-no { font-size: 1.6rem; font-weight: 800; letter-spacing: .04em; }
@keyframes pop { from { transform: scale(.97); opacity: .4; } to { transform: none; opacity: 1; } }

.totals { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.tot { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; min-width: 0; }
.tot .label { font-size: .72rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.tot .value { font-size: 1.45rem; font-weight: 700; font-variant-numeric: tabular-nums; line-height: 1.25; overflow-wrap: anywhere; }
.tot .sub { font-size: .8rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.tot.gifts { grid-column: 1 / -1; }
.tot.grand { grid-column: 1 / -1; background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.tot.grand .label, .tot.grand .sub { color: color-mix(in srgb, var(--accent-ink) 78%, transparent); }
.tot.grand .value { font-size: 1.9rem; font-family: var(--font-display); }

.list { display: grid; }
.row {
  display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 4px 12px; align-items: center;
  padding: 12px 4px; border-bottom: 1px solid var(--line); text-align: left; width: 100%;
  background: none; border-left: 0; border-right: 0; border-top: 0; cursor: default;
}
button.row { cursor: pointer; }
button.row:hover { background: var(--surface-2); }
.row .no { font-variant-numeric: tabular-nums; font-size: .8rem; color: var(--muted); font-weight: 700; min-width: 2.6em; }
.row .who { min-width: 0; }
.row .name { font-weight: 600; overflow-wrap: anywhere; }
.row .meta { font-size: .8rem; color: var(--muted); display: flex; flex-wrap: wrap; gap: 4px 8px; align-items: center; }
.row .amt { text-align: right; font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }
.row .amt small { display: block; font-weight: 500; font-size: .75rem; color: var(--muted); }
.row.deleted .name, .row.deleted .amt { text-decoration: line-through; text-decoration-color: var(--bad); text-decoration-thickness: 2px; color: var(--muted); }
.row.pending { opacity: .75; }
.row .del { border: 0; background: var(--bad-bg); color: var(--bad); border-radius: 999px; min-height: 32px; padding: 0 12px; font-weight: 700; font-size: .8rem; cursor: pointer; }
.empty { text-align: center; color: var(--muted); padding: 22px 8px; }

.toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.toolbar .input { flex: 1 1 200px; min-height: 44px; }
.toolbar select.input { flex: 0 1 190px; }

/* layout picker */
.layouts { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; }
.layout-opt { border: 2px solid var(--line); border-radius: var(--radius); overflow: hidden; cursor: pointer; background: var(--surface); text-align: left; padding: 0; }
.layout-opt[aria-pressed="true"] { border-color: var(--ink); }
.layout-opt .sw { height: 54px; background: var(--hero); display: grid; place-items: center; color: var(--hero-ink); font-family: var(--font-display); font-size: 1.2rem; font-weight: 600; }
.layout-opt .nm { padding: 8px 10px; font-size: .82rem; font-weight: 600; color: var(--ink); background: var(--surface); }
.layout-opt[disabled] { opacity: .45; cursor: not-allowed; }

.media-row { display: flex; gap: 14px; align-items: center; flex-wrap: wrap; }
.media-thumb { width: 84px; height: 84px; border-radius: 50%; overflow: hidden; background: var(--surface-2); display: grid; place-items: center; border: 1px solid var(--line); }
.media-thumb.logo { border-radius: var(--radius-sm); }
.media-thumb img { width: 100%; height: 100%; object-fit: cover; }
.media-thumb.logo img { object-fit: contain; padding: 6px; }

/* admin */
.admin-bar { background: var(--hero); color: var(--hero-ink); padding-block: calc(env(safe-area-inset-top, 0px) + 16px) 16px; margin-top: calc(-1 * env(safe-area-inset-top, 0px)); }
.admin-bar .inner { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.admin-bar .wordmark { font-size: 1.9rem; }
.admin-bar .btn { background: color-mix(in srgb, var(--hero-ink) 12%, transparent); border-color: transparent; color: var(--hero-ink); }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; }
.ev-list { display: grid; gap: 10px; }
.ev-item { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 10px; align-items: center; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; }
.ev-item .title { font-family: var(--font-display); font-size: 1.35rem; font-weight: 600; }
.ev-item .meta { font-size: .85rem; color: var(--muted); display: flex; flex-wrap: wrap; gap: 6px 10px; align-items: center; margin-top: 2px; }
.ev-actions { display: flex; flex-wrap: wrap; gap: 6px; justify-content: flex-end; }
.bars { display: grid; gap: 8px; }
.bar-row { display: grid; grid-template-columns: 70px minmax(0, 1fr) 70px; gap: 10px; align-items: center; font-size: .85rem; font-variant-numeric: tabular-nums; }
.bar-track { height: 10px; border-radius: 999px; background: var(--surface-2); overflow: hidden; }
.bar-fill { height: 100%; background: var(--accent); border-radius: 999px; }
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; }
.check-list { display: flex; flex-wrap: wrap; gap: 8px; }
.check-list label { display: inline-flex; align-items: center; gap: 6px; padding: 6px 10px; border: 1px solid var(--line); border-radius: 999px; font-size: .85rem; cursor: pointer; }

/* modal + toast */
.overlay { position: fixed; inset: 0; background: rgba(15, 15, 25, .5); z-index: 50; display: grid; place-items: end center; padding: 0; }
.modal {
  width: 100%; max-width: 520px; max-height: 92vh; overflow: auto; background: var(--surface); color: var(--ink);
  border-radius: 22px 22px 0 0; padding: 22px max(20px, env(safe-area-inset-right, 0px)) calc(22px + env(safe-area-inset-bottom, 0px)) max(20px, env(safe-area-inset-left, 0px));
  display: grid; gap: 14px; animation: up .2s ease-out;
}
.modal h3 { font-size: 1.25rem; }
.modal .actions { display: flex; flex-wrap: wrap; gap: 8px; justify-content: flex-end; }
.modal .actions .btn { flex: 1 1 auto; }
@media (min-width: 640px) {
  .overlay { place-items: center; padding: 20px; }
  .modal { border-radius: 22px; }
}
@keyframes up { from { transform: translateY(24px); opacity: 0; } to { transform: none; opacity: 1; } }
.toast-host { position: fixed; left: 0; right: 0; bottom: calc(18px + env(safe-area-inset-bottom, 0px)); display: grid; justify-items: center; gap: 8px; z-index: 60; pointer-events: none; padding-inline: 16px; }
.toast { background: #1C1C22; color: #fff; padding: 10px 16px; border-radius: 12px; font-weight: 600; font-size: .92rem; box-shadow: 0 8px 24px rgba(0,0,0,.25); max-width: 520px; animation: up .2s ease-out; }
.toast.bad { background: #8F1F18; }

.footer { text-align: center; padding-block: 18px calc(24px + env(safe-area-inset-bottom, 0px)); color: var(--muted); font-size: .82rem; display: grid; gap: 6px; justify-items: center; }
.footer a { color: var(--muted); }
.footer .brand { font-family: var(--font-display); font-weight: 600; font-size: 1rem; color: var(--ink); }

.kv { display: grid; grid-template-columns: auto 1fr; gap: 4px 14px; font-size: .92rem; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; font-weight: 600; overflow-wrap: anywhere; }
.diff-pos { color: var(--ok); font-weight: 700; }
.diff-neg { color: var(--bad); font-weight: 700; }
.code-box { font-family: ui-monospace, Menlo, monospace; font-size: 1.4rem; font-weight: 700; letter-spacing: .18em; padding: 8px 14px; background: var(--surface-2); border-radius: var(--radius-sm); display: inline-block; }
.link-box { display: grid; gap: 8px; padding: 12px; border: 1.5px dashed var(--accent-2); border-radius: var(--radius-sm); background: var(--surface-2); }
.link-box code { font-size: .8rem; overflow-wrap: anywhere; }

/* ---------- tablet & desktop ---------- */
@media (min-width: 600px) {
  .totals { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .tot.grand { grid-column: span 3; }
  .tot.gifts { grid-column: auto; }
  .photo-frame { width: 116px; height: 116px; }
}
/* tablet in landscape: typing box left-centre, live list on the right */
@media (min-width: 900px) and (orientation: landscape) {
  .wrap.entry-wide { max-width: 1180px; }
  .entry-layout { grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); align-items: start; }
  .entry-side { position: sticky; top: 64px; }
  .totals { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .tot.grand { grid-column: span 2; }
  .tot.gifts { grid-column: 1 / -1; }
}
