/* ==========================================================================
   Base: reset, buttons, avatars, login, shell and navigation, forms,
   sheets, motion and shared app furniture.
   ========================================================================== */

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

/* ==========================================================================
   Base
   ========================================================================== */

*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; min-height: 100%; }
html { -webkit-text-size-adjust: 100%; }

body {
  font-family: var(--sans);
  font-size: 1rem;
  line-height: 1.5;
  background: var(--paper);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  -webkit-tap-highlight-color: transparent;
  overflow-x: hidden;
  transition: background var(--med) var(--ease), color var(--med) var(--ease);
}
body.has-modal { overflow: hidden; }

/* Paper grain over everything, never intercepting input. */
body::after {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 300;
  opacity: var(--grain-opacity);
  mix-blend-mode: multiply;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='3' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 .45 0 0 0 0 .38 0 0 0 0 .3 0 0 0 .55 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}
[data-theme="dark"] body::after { mix-blend-mode: screen; }

h1, h2, h3 {
  font-family: var(--serif);
  font-weight: 400;
  margin: 0;
  line-height: 1.05;
  letter-spacing: -0.01em;
}
h1 em, h2 em, h3 em { font-style: italic; color: var(--wax-text); }

p { margin: 0; }
b, strong { font-weight: 600; }

button { font: inherit; cursor: pointer; border: 0; background: none; color: inherit; padding: 0; }
button:disabled { cursor: default; }
input, textarea, select { font-family: inherit; font-size: 1rem; color: inherit; }
a { color: inherit; text-decoration: none; }
fieldset { border: 0; margin: 0; padding: 0; min-width: 0; }
legend { padding: 0; }

.icon { width: 1.25em; height: 1.25em; flex-shrink: 0; display: block; }

:focus-visible { outline: 2px solid var(--wax-text); outline-offset: 3px; border-radius: var(--r-xs); }
:focus:not(:focus-visible) { outline: none; }
::selection { background: var(--wax); color: var(--on-wax); }

.visually-hidden {
  position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}

.skip-link {
  position: fixed; top: 0.75rem; left: 0.75rem; z-index: 200;
  padding: 0.55rem 0.9rem; border-radius: var(--r-sm);
  background: var(--ink); color: var(--paper); font-weight: 600;
  transform: translateY(-300%); opacity: 0; pointer-events: none;
  transition: transform var(--fast) var(--ease), opacity var(--fast) var(--ease);
}
.skip-link:focus-visible { transform: none; opacity: 1; pointer-events: auto; }

#app { min-height: 100vh; min-height: 100dvh; }

/* ==========================================================================
   Buttons
   ========================================================================== */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.45rem;
  min-height: 44px; padding: 0.65rem 1.2rem;
  border-radius: var(--r-sm);
  font-weight: 600; font-size: 0.95rem; line-height: 1.1; white-space: nowrap;
  transition: transform var(--fast) var(--ease), background var(--fast) var(--ease),
    color var(--fast) var(--ease), border-color var(--fast) var(--ease), box-shadow var(--fast) var(--ease);
}
.btn:active:not(:disabled) { transform: scale(0.97); transition-duration: var(--press); }
.btn:disabled { opacity: 0.5; }
.btn .icon { width: 1.05em; height: 1.05em; }

.btn--primary { background: var(--ink); color: var(--paper); box-shadow: 0 1px 0 rgba(0, 0, 0, 0.2); }
.btn--primary:hover:not(:disabled) { background: var(--wax); color: var(--on-wax); }
.btn--danger { background: var(--danger); color: #fff; }
[data-theme="dark"] .btn--danger { color: #1d0d08; }
.btn--full { width: 100%; }
.btn--ghost { border: 1px solid var(--rule-strong); color: var(--ink); }
.btn--ghost:hover { border-color: var(--ink); }
.btn--sm { min-height: 36px; padding: 0.4rem 0.85rem; font-size: 0.85rem; }
.btn--text {
  min-height: 36px; padding: 0.35rem 0.1rem;
  font-family: var(--mono); font-size: 0.78rem; font-weight: 500;
  color: var(--ink-soft); letter-spacing: 0.02em;
  border-radius: 0; border-bottom: 1px solid transparent;
}
.btn--text:hover { color: var(--wax-text); border-bottom-color: currentColor; }
.btn--text .icon { width: 14px; height: 14px; }
.btn--text-danger { color: var(--danger); }
.btn--icon-text { padding-left: 0.95rem; }

.icon-btn {
  width: 42px; height: 42px; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0;
  color: var(--ink-soft);
  transition: background var(--fast) var(--ease), color var(--fast) var(--ease), transform var(--press) var(--ease);
}
.icon-btn:active { transform: scale(0.9); }
.icon-btn .icon { width: 21px; height: 21px; }
.icon-btn:hover, .icon-btn[aria-expanded="true"] { background: var(--paper-deep); color: var(--ink); }
.icon-btn--sm { width: 30px; height: 30px; }
.icon-btn--sm .icon { width: 14px; height: 14px; }

/* ==========================================================================
   Avatars & wax seal
   ========================================================================== */

.avatar {
  position: relative;
  width: 40px; height: 40px; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0;
  background: var(--wax); color: var(--on-wax);
  font-family: var(--serif); font-size: 1.2rem; line-height: 1;
}
.avatar--alt { background: var(--blue); color: var(--paper); }
.avatar--sm { width: 28px; height: 28px; font-size: 0.95rem; }
.avatar--lg { width: 42px; height: 42px; font-size: 1.3rem; }
.avatar__presence[hidden] { display: none; }
.avatar__presence {
  position: absolute; right: -1px; bottom: -1px;
  width: 11px; height: 11px; border-radius: 50%;
  background: #4c9a6a; border: 2px solid var(--paper);
}

.seal {
  position: relative;
  width: 46px; height: 46px;
  display: inline-block; flex-shrink: 0;
  background: url("../assets/icons/seal.svg") center / contain no-repeat;
  filter: drop-shadow(0 2px 3px rgba(60, 10, 5, 0.3));
}
.seal .icon { display: none; }
.seal--lg { width: 64px; height: 64px; }
.seal--modal { margin: 0 auto 1rem; }

/* ==========================================================================
   Login
   ========================================================================== */

.login-screen {
  min-height: 100vh; min-height: 100dvh;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 2rem 1rem;
}

.login-card {
  position: relative;
  width: 100%; max-width: 380px;
  background: var(--card);
  border: 1px solid var(--rule);
  border-radius: var(--r-xs);
  padding: 3.25rem 1.75rem 2rem;
  box-shadow: var(--shadow-lift);
  text-align: center;
  animation: rise 700ms var(--ease) both;
}
/* A second sheet peeking out underneath */
.login-card::before {
  content: "";
  position: absolute; inset: 0;
  background: var(--card); border: 1px solid var(--rule); border-radius: var(--r-xs);
  transform: rotate(-2.2deg) translate(-4px, 6px);
  z-index: -1;
}
.login-card .seal { position: absolute; top: -32px; left: 50%; margin-left: -32px; animation: stamp 700ms 250ms var(--ease) both; }

.login-card__kicker { font-family: var(--mono); font-size: 0.74rem; color: var(--ink-faint); letter-spacing: 0.08em; }
.login-card__brand { font-size: 3.4rem; margin-top: 0.35rem; }
.login-card__tagline { font-family: var(--serif); font-style: italic; font-size: 1.25rem; color: var(--ink-soft); margin-top: 0.2rem; }

.login-form { display: flex; flex-direction: column; gap: 0.35rem; text-align: left; margin-top: 2rem; }
.login-form--shake { animation: shake 400ms var(--ease); }
.login-form__label {
  font-family: var(--mono); font-size: 0.74rem; color: var(--ink-soft);
  letter-spacing: 0.04em; margin-top: 1rem;
}
.login-form__label:first-child { margin-top: 0; }
.login-form__optional { color: var(--ink-faint); }
.login-form__people { display: grid; grid-template-columns: 1fr 1fr; gap: 0.55rem; margin-top: 0.15rem; }

.person-chip {
  display: flex; align-items: center; gap: 0.6rem;
  padding: 0.6rem 0.7rem; min-height: 50px;
  border: 1px solid var(--rule-strong); border-radius: var(--r-sm);
  background: transparent; text-align: left;
  transition: border-color var(--fast) var(--ease), background var(--fast) var(--ease);
}
.person-chip:hover { border-color: var(--ink-soft); }
.person-chip__name { font-family: var(--serif); font-size: 1.25rem; line-height: 1; }
.person-chip--active { border-color: var(--ink); background: var(--paper); box-shadow: inset 0 0 0 1px var(--ink); }

.login-form__input, .field__input {
  width: 100%; min-height: 46px;
  padding: 0.7rem 0.85rem;
  border: 1px solid var(--rule-strong); border-radius: var(--r-sm);
  background: var(--paper);
  transition: border-color var(--fast) var(--ease), box-shadow var(--fast) var(--ease);
}
.login-form__input::placeholder, .field__input::placeholder { color: var(--ink-faint); }
.login-form__input:focus, .field__input:focus { outline: none; border-color: var(--ink); box-shadow: 0 0 0 1px var(--ink); }

.login-form__error, .form__error { color: var(--danger); font-size: 0.86rem; margin-top: 0.5rem; }
.login-form .btn { margin-top: 1.4rem; }

.login-screen__note { margin-top: 2.25rem; font-family: var(--serif); font-style: italic; color: var(--ink-faint); font-size: 1.05rem; }

/* ==========================================================================
   Shell & navigation
   ========================================================================== */

.app-shell { display: flex; min-height: 100vh; min-height: 100dvh; }

.sidebar { display: none; }
.sidebar__brand { font-family: var(--serif); font-size: 2.1rem; line-height: 1; }
.sidebar__brand em { color: var(--wax-text); }
.sidebar__est { font-family: var(--mono); font-size: 0.72rem; color: var(--ink-faint); margin-top: 0.4rem; letter-spacing: 0.06em; }
.sidebar__nav { display: flex; flex-direction: column; margin-top: 2.5rem; border-top: 1px solid var(--rule); }
.sidebar__footer {
  margin-top: auto; display: flex; align-items: center; gap: 0.7rem;
  padding-top: 1rem; border-top: 1px solid var(--rule);
  font-size: 0.82rem; color: var(--ink-soft);
}
.sidebar__footer strong { color: var(--ink); }
.sidebar__avatars { display: flex; }
.sidebar__avatars .avatar + .avatar { margin-left: -7px; box-shadow: 0 0 0 2px var(--paper); }

.view-root {
  flex: 1; min-width: 0;
  display: flex; flex-direction: column;
  padding-bottom: calc(var(--nav-height) + env(safe-area-inset-bottom));
}
.view-root:focus { outline: none; }

.splash {
  min-height: 100vh; min-height: 100dvh;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1.4rem;
  padding: 2rem; text-align: center;
}
.splash .seal { animation: breathe 1.8s var(--ease) infinite; }
.splash__text { font-family: var(--serif); font-style: italic; font-size: 1.35rem; color: var(--ink-soft); max-width: 22rem; }
/* Changing pages: the old one dissolves into the new one. The tab bar is
   left out of it and stays live, so its lens keeps gliding. */
::view-transition { pointer-events: none; }
::view-transition-old(root), ::view-transition-new(root) { animation-duration: 220ms; animation-timing-function: var(--ease-out); }
.bottom-nav { view-transition-name: tabbar; }
::view-transition-group(tabbar) { animation: none; }
::view-transition-old(tabbar) { display: none; }
::view-transition-new(tabbar) { animation: none; }

/* Tab bar: a floating Liquid Glass capsule. Content scrolls behind it,
   and a clear "lens" glides to the current tab. */
.bottom-nav {
  position: fixed; z-index: 20;
  left: max(12px, env(safe-area-inset-left)); right: max(12px, env(safe-area-inset-right));
  bottom: max(8px, calc(env(safe-area-inset-bottom) - 12px));
  display: flex; align-items: stretch;
  max-width: 520px; margin-inline: auto;
  height: 60px; padding: 4px;
  border-radius: var(--r-full); isolation: isolate;
  background: var(--glass-fill);
  -webkit-backdrop-filter: blur(18px) saturate(1.8); backdrop-filter: blur(18px) saturate(1.8);
  border: 0.5px solid var(--glass-edge);
  box-shadow: inset 0 1px 0 var(--glass-shine), inset 0 -6px 12px -8px var(--glass-shine), var(--glass-shadow);
}
/* The lens. Its place follows whichever tab is current. */
.bottom-nav::before {
  content: ""; position: absolute; z-index: -1;
  top: 4px; bottom: 4px; left: 4px; width: calc((100% - 8px) / 5);
  border-radius: var(--r-full);
  background: var(--glass-lens);
  box-shadow: inset 0 1px 0 var(--glass-shine), inset 0 0 0 0.5px var(--glass-edge), 0 4px 12px -6px rgba(40, 20, 10, 0.35);
  transform: translateX(calc(var(--tab, 0) * 100%));
  transition: transform 460ms cubic-bezier(0.3, 1.35, 0.5, 1); /* older Safari */
  transition: transform 560ms linear(0.0, 0.028, 0.096, 0.188, 0.29, 0.395, 0.495, 0.588, 0.67, 0.742, 0.802, 0.853, 0.894, 0.926, 0.952, 0.971, 0.985, 0.995, 1.002, 1.007, 1.01, 1.011, 1.011, 1.011, 1.01, 1.009, 1.008, 1.007, 1);
}
.bottom-nav:has(.nav-item:nth-child(2).nav-item--active) { --tab: 1; }
.bottom-nav:has(.nav-item:nth-child(3).nav-item--active) { --tab: 2; }
.bottom-nav:has(.nav-item:nth-child(4).nav-item--active) { --tab: 3; }
.bottom-nav:has(.nav-item:nth-child(5).nav-item--active) { --tab: 4; }
.bottom-nav:not(:has(.nav-item--active))::before { opacity: 0; }

.nav-item {
  position: relative;
  flex: 1; min-width: 0;
  min-height: var(--tap);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  border-radius: var(--r-full);
  color: var(--ink-soft);
  font-size: 0.65625rem; font-weight: 500; letter-spacing: 0.01em; line-height: 1.1;
  -webkit-touch-callout: none; -webkit-user-select: none; user-select: none;
  -webkit-tap-highlight-color: transparent;
  transition: color var(--fast) var(--ease);
}
.nav-item__icon { display: flex; transition: transform var(--press) var(--ease); }
.nav-item__icon .icon { width: 24px; height: 24px; stroke-width: 1.7; }
.nav-item:active .nav-item__icon { transform: scale(0.92); }
.nav-item--active { color: var(--wax-text); }
.nav-item--active .nav-item__label { font-weight: 600; }
.nav-item--active .nav-item__icon .icon { stroke-width: 1.9; fill: currentColor; fill-opacity: 0.2; }
.nav-item[data-nav-item="us"].nav-item--active .nav-item__icon .icon { fill-opacity: 1; }
.bottom-nav .nav-item--active .nav-item__icon { animation: tab-pop 240ms var(--ease-out); }
@keyframes tab-pop { 0% { transform: scale(0.92); } 60% { transform: scale(1.05); } 100% { transform: scale(1); } }
@media (hover: hover) { .bottom-nav .nav-item:hover { color: var(--ink); } .bottom-nav .nav-item--active:hover { color: var(--wax-text); } }

/* Solid where glass isn't wanted or can't be drawn. */
@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
  .bottom-nav { background: var(--card); }
}
@media (prefers-reduced-transparency: reduce) {
  .bottom-nav { background: var(--card); -webkit-backdrop-filter: none; backdrop-filter: none; }
}
@media (prefers-reduced-motion: reduce) {
  .bottom-nav::before { transition: none; }
  .bottom-nav .nav-item--active .nav-item__icon { animation: none; }
}

/* ==========================================================================
   Page furniture
   ========================================================================== */

.page-header {
  padding: 2.25rem var(--gutter) 1.1rem;
  margin: 0 var(--gutter) 1.4rem;
  padding-left: 0; padding-right: 0;
  border-bottom: 0.5px solid var(--hairline);
  animation: rise var(--page) var(--ease-out) both;
}
.page-header--with-action { display: flex; align-items: flex-end; justify-content: space-between; gap: 1rem; }
.page-header__title { font-size: var(--text-large); letter-spacing: -0.01em; }
.page-header__subtitle { color: var(--ink-soft); margin-top: 0.4rem; font-size: var(--text-callout); }

.section-block { padding: 0 var(--gutter) 2.5rem; }
.section-block--flush { padding-bottom: 1.25rem; }
.section-block__head {
  display: flex; align-items: baseline; justify-content: space-between;
  border-bottom: 1px solid var(--rule); padding-bottom: 0.5rem; margin-bottom: 1rem;
}
.section-block__head .section-block__title { margin: 0; }
.section-block__title { font-size: var(--text-title); margin-bottom: 1rem; }

.empty-state { margin: auto; text-align: center; padding: 2.5rem 1.5rem; color: var(--ink-soft); }
.empty-state--card { grid-column: 1 / -1; border: 1px dashed var(--rule-strong); border-radius: var(--r-sm); }
.empty-state__icon { width: 44px; height: 44px; margin: 0 auto 0.75rem; color: var(--wax-text); display: flex; align-items: center; justify-content: center; }
.empty-state__icon .icon { width: 30px; height: 30px; }
.empty-state__title { font-family: var(--serif); font-size: var(--text-title); color: var(--ink); line-height: 1.15; }
.empty-state__subtitle { margin-top: 0.4rem; font-size: 0.92rem; }

.tabs {
  display: flex; gap: 1.4rem;
  padding: 0 var(--gutter) 1.4rem;
  margin-top: -0.6rem;
  overflow-x: auto; scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }
.tabs__item {
  flex-shrink: 0; padding: 0.35rem 0;
  font-family: var(--mono); font-size: var(--text-foot); font-weight: 500; color: var(--ink-faint);
  border-bottom: 1.5px solid transparent;
  transition: color var(--fast) var(--ease), border-color var(--fast) var(--ease);
}
.tabs__item:hover { color: var(--ink); }
.tabs__item--active { color: var(--ink); border-bottom-color: var(--wax-text); }

/* Toasts: a soft frosted pill that floats above the tab bar (and above
   the message bar in Chat), the same in light and dark. */
.toast {
  position: fixed; left: 50%; z-index: 150;
  bottom: calc(var(--nav-height) + env(safe-area-inset-bottom) + 16px);
  transform: translate(-50%, 14px) scale(0.96);
  width: max-content; max-width: calc(100vw - 2.5rem);
  padding: 0.7rem 1.15rem; border-radius: var(--r-full);
  background: rgba(30, 20, 17, 0.86); color: #fff8ef;
  -webkit-backdrop-filter: blur(16px) saturate(1.4); backdrop-filter: blur(16px) saturate(1.4);
  font-size: 0.875rem; font-weight: 500; line-height: 1.35; text-align: center;
  box-shadow: 0 12px 30px -12px rgba(20, 10, 8, 0.55), 0 0 0 0.5px rgba(255, 255, 255, 0.08);
  opacity: 0; pointer-events: none;
  transition: opacity 260ms var(--ease), transform 420ms var(--ease-sheet);
}
.toast--visible { opacity: 1; transform: translate(-50%, 0) scale(1); }
body:has(.chat-view) .toast { bottom: calc(var(--nav-height) + env(safe-area-inset-bottom) + 78px); }

/* The heartbeat toast: a wax pill with a heart that beats */
.toast.toast--love {
  display: flex; align-items: center; gap: 12px;
  padding: 0.55rem 1.25rem 0.55rem 0.55rem; text-align: left;
  background: linear-gradient(135deg, #b0444a 0%, #8e2a2e 55%, #6f1d22 100%); color: #fff;
  box-shadow: 0 16px 36px -12px rgba(110, 25, 30, 0.75), inset 0 1px 0 rgba(255, 255, 255, 0.14);
  transition: opacity 260ms var(--ease), transform 560ms cubic-bezier(0.34, 1.56, 0.64, 1);
}
.toast__heart {
  flex: none; width: 40px; height: 40px; border-radius: 50%;
  display: grid; place-items: center;
  background: rgba(255, 255, 255, 0.16);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.12);
}
.toast__heart .icon { width: 20px; height: 20px; fill: #fff; stroke: #fff; animation: heartbeat 1.3s ease-in-out infinite; }
.toast__text { display: flex; flex-direction: column; min-width: 0; }
.toast__title { font-family: var(--serif); font-style: italic; font-size: 1.15rem; font-weight: 400; line-height: 1.15; letter-spacing: 0.005em; }
.toast__detail { margin-top: 2px; font-size: 0.75rem; font-weight: 500; letter-spacing: 0.01em; color: rgba(255, 255, 255, 0.82); }

/* ==========================================================================
   Forms
   ========================================================================== */

.form { display: flex; flex-direction: column; gap: 1.05rem; }
.field { display: flex; flex-direction: column; gap: 0.4rem; }
.field__label { font-family: var(--mono); font-size: 0.74rem; color: var(--ink-soft); letter-spacing: 0.03em; }
.field__optional { color: var(--ink-faint); }
.field__hint { font-size: 0.82rem; color: var(--ink-faint); }
.field__input--area { resize: vertical; min-height: 110px; line-height: 1.55; }
input[type="date"].field__input { appearance: none; -webkit-appearance: none; }

.segmented { display: grid; grid-template-columns: repeat(3, 1fr); border: 1px solid var(--rule-strong); border-radius: var(--r-sm); overflow: hidden; }
.segmented__option { position: relative; }
.segmented__option + .segmented__option { border-left: 1px solid var(--rule-strong); }
.segmented__option input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.segmented__option span {
  display: flex; align-items: center; justify-content: center; min-height: 42px;
  padding: 0.35rem; font-size: 0.85rem; font-weight: 500; color: var(--ink-soft); text-align: center;
  transition: background var(--fast) var(--ease), color var(--fast) var(--ease);
}
.segmented__option input:checked + span { background: var(--ink); color: var(--paper); }
.segmented__option input:focus-visible + span { outline: 2px solid var(--wax-text); outline-offset: -3px; }

.icon-picker { display: grid; grid-template-columns: repeat(6, 1fr); gap: 0.35rem; }
.icon-picker__item { position: relative; }
.icon-picker__item input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.icon-picker__item span {
  display: flex; align-items: center; justify-content: center; aspect-ratio: 1;
  border: 1px solid var(--rule); border-radius: var(--r-sm); font-size: 1.2rem;
  transition: border-color var(--fast) var(--ease), background var(--fast) var(--ease);
}
.icon-picker__item input:checked + span { border-color: var(--ink); box-shadow: inset 0 0 0 1px var(--ink); background: var(--paper); }
.icon-picker__item input:focus-visible + span { outline: 2px solid var(--wax-text); outline-offset: 1px; }

.photo-drop {
  position: relative; display: block; cursor: pointer; overflow: hidden;
  border: 1px dashed var(--rule-strong); border-radius: var(--r-sm); background: var(--paper);
  transition: border-color var(--fast) var(--ease);
}
.photo-drop:hover, .photo-drop:focus-within { border-color: var(--ink); }
.photo-drop__empty { display: flex; flex-direction: column; align-items: center; gap: 0.3rem; padding: 1.6rem 1rem; text-align: center; color: var(--ink-soft); }
.photo-drop__empty .icon { width: 28px; height: 28px; color: var(--wax-text); margin-bottom: 0.2rem; }
.photo-drop__title { font-family: var(--serif); font-size: 1.35rem; color: var(--ink); line-height: 1.1; }
.photo-drop__hint { font-size: 0.82rem; }
.photo-drop__preview { display: block; height: 210px; background-size: cover; background-position: center; }
.photo-drop__empty[hidden], .photo-drop__preview[hidden] { display: none; }

/* ==========================================================================
   Modal / sheet
   ========================================================================== */

.modal { position: fixed; inset: 0; z-index: 100; display: flex; align-items: flex-end; justify-content: center; }
/* Bottom sheet on phones (a centred dialog from 640px up, see responsive.css).
   Swipe down from the top of the sheet to dismiss it (ui.js). */
.modal__backdrop { position: absolute; inset: 0; background: rgba(20, 12, 10, 0.42); animation: fade var(--sheet) var(--ease); }
.modal__panel {
  position: relative; width: 100%; max-width: 520px;
  max-height: 92vh; max-height: 92dvh; overflow-y: auto; overscroll-behavior: contain;
  background: var(--card);
  border-radius: var(--r-sheet) var(--r-sheet) 0 0;
  padding: 2rem max(var(--gutter), env(safe-area-inset-right)) calc(1.5rem + env(safe-area-inset-bottom)) max(var(--gutter), env(safe-area-inset-left));
  box-shadow: var(--shadow-sheet);
  animation: sheet-up var(--sheet) var(--ease-sheet);
  transition: transform 320ms var(--ease-sheet);
}
.modal__panel--dragging { transition: none; }
.modal__panel::before {
  content: ""; position: absolute; top: 0.5rem; left: 50%;
  width: 38px; height: 5px; margin-left: -19px; border-radius: 3px; background: var(--rule-strong);
}
.modal--closing .modal__backdrop { animation: fade-out 220ms var(--ease) forwards; }
.modal--closing .modal__panel { animation: sheet-down 220ms var(--ease-sheet) forwards; }

.modal__close {
  position: absolute; top: 0.9rem; right: 0.9rem; z-index: 2;
  width: 34px; height: 34px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  color: var(--ink-soft); transition: background var(--fast) var(--ease), color var(--fast) var(--ease);
}
.modal__close:hover { background: var(--paper-deep); color: var(--ink); }
.modal__close .icon { width: 18px; height: 18px; }

.modal__title { font-size: 2rem; padding-right: 2.5rem; margin-bottom: 1.2rem; }
.modal__panel--small { text-align: center; padding-top: 2.4rem; }
.modal__panel--small .modal__title { padding: 0 1.5rem; margin-bottom: 0; font-size: 1.8rem; }
.modal__panel--small .modal__title + .btn,
.modal__panel--small .modal__title + .modal__actions { margin-top: 1.5rem; }
.modal__panel--small .modal__actions { justify-content: center; }
.modal__panel-icon { width: 44px; height: 44px; margin: 0 auto 0.9rem; color: var(--wax-text); display: flex; align-items: center; justify-content: center; }
.modal__panel-icon .icon { width: 28px; height: 28px; }
.modal__panel-text { color: var(--ink-soft); margin: 0.6rem 0 1.5rem; line-height: 1.55; }

.modal__actions { display: flex; justify-content: flex-end; align-items: center; gap: 0.55rem; flex-wrap: wrap; margin-top: 0.4rem; }
.modal__actions--start { justify-content: flex-start; margin-top: 1.4rem; }
.modal__actions-left { margin-right: auto; }

/* Chat photo viewer */
.modal__panel--photo { padding: 0; background: #0d0a08; max-width: 720px; }
.modal__panel--photo::before { display: none; }
.modal__panel--photo .modal__close { background: rgba(0, 0, 0, 0.5); color: #fff; }
.photo-viewer { display: block; width: 100%; max-height: 85vh; object-fit: contain; }

/* Note reader: a sheet of ruled letter paper */
.modal__panel--note {
  background-color: var(--card);
  padding-left: calc(var(--gutter) + 0.75rem);
  border-left: 3px double var(--wax-tint);
}
.note-reader__eyebrow { font-family: var(--mono); font-size: 0.76rem; color: var(--ink-faint); }
.note-reader__title { font-size: 2.3rem; margin-top: 0.4rem; padding-right: 2rem; line-height: 1; }
.note-reader__message {
  margin-top: 1.25rem;
  font-family: var(--serif); font-size: 1.4rem; line-height: 32px;
  background-image: repeating-linear-gradient(transparent 0 31px, var(--rule) 31px 32px);
  white-space: pre-wrap; overflow-wrap: anywhere;
}
.note-reader__sign { margin-top: 1.4rem; font-family: var(--hand); font-size: 1.15rem; color: var(--wax-text); transform: rotate(-3deg); transform-origin: left; }

/* Memory viewer */
.modal__panel--memory { padding: 0; max-width: 620px; background: var(--polaroid); }
.modal__panel--memory::before { display: none; }
.modal__panel--memory .modal__close { background: rgba(20, 14, 10, 0.5); color: #fff; }
.viewer__stage { position: relative; padding: 0.9rem 0.9rem 0; }
.viewer__image { height: min(60vh, 440px); background-size: cover; background-position: center; border-radius: 2px; }
.viewer__image--photo { background-color: #0d0a08; background-size: contain; background-repeat: no-repeat; }
.viewer__nav {
  position: absolute; top: calc(50% + 0.45rem); transform: translateY(-50%);
  width: 40px; height: 40px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  background: rgba(20, 14, 10, 0.5); color: #fff;
  transition: background var(--fast) var(--ease);
}
.viewer__nav:hover { background: rgba(20, 14, 10, 0.75); }
.viewer__nav--prev { left: 1.5rem; }
.viewer__nav--next { right: 1.5rem; }
.viewer__body { padding: 1.1rem 1.4rem calc(1.25rem + env(safe-area-inset-bottom)); color: #221a15; }
.viewer__date { font-family: var(--mono); font-size: 0.76rem; color: #806e63; }
.viewer__title { font-size: 2.1rem; margin-top: 0.2rem; }
.viewer__caption { margin-top: 0.6rem; line-height: 1.55; color: #5e5249; overflow-wrap: anywhere; }
.modal__panel--memory .btn--text { color: var(--danger); }

/* ==========================================================================
   Motion
   ========================================================================== */

@keyframes fade { from { opacity: 0; } }
@keyframes fade-out { to { opacity: 0; } }
@keyframes rise { from { opacity: 0; transform: translateY(10px); } }
@keyframes drop-in { from { opacity: 0; transform: translateY(16px) rotate(calc(var(--tilt, 0deg) * 3)); } }
@keyframes sheet-up { from { transform: translateY(100%); } }
@keyframes sheet-down { to { transform: translateY(100%); } }
@keyframes pop { from { opacity: 0; transform: scale(0.94) translateY(3px); } }
@keyframes thump { 0% { transform: scale(1); } 35% { transform: scale(1.05); } 100% { transform: scale(1); } }
@keyframes stamp { 0% { opacity: 0; transform: scale(1.6) rotate(-25deg); } 60% { opacity: 1; transform: scale(0.95) rotate(4deg); } 100% { transform: scale(1) rotate(0); } }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes breathe { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.06); } }
@keyframes ping { 0% { box-shadow: 0 0 0 0 var(--wax-tint); } 70% { box-shadow: 0 0 0 9px rgba(0, 0, 0, 0); } 100% { box-shadow: 0 0 0 0 rgba(0, 0, 0, 0); } }
@keyframes shake {
  10%, 90% { transform: translateX(-2px); }
  20%, 80% { transform: translateX(4px); }
  30%, 50%, 70% { transform: translateX(-7px); }
  40%, 60% { transform: translateX(7px); }
}

/* ==========================================================================
   iPhone app polish
   ========================================================================== */

html { background: var(--paper); }
/* It's an app, not a web page: on phones, holding or double tapping never
   selects the interface, pops up Safari's callout or zooms. Typing boxes
   still select as usual; chat messages have "Copy text" on long press. */
@media (hover: none), (display-mode: standalone) {
  body { overscroll-behavior-y: none; -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; touch-action: manipulation; }
  input, textarea, [contenteditable="true"] { -webkit-user-select: text; user-select: text; -webkit-touch-callout: default; }
  img, a { -webkit-user-drag: none; }
}
@media (display-mode: standalone) {
  .login-screen { padding-top: max(2rem, env(safe-area-inset-top)); }
}
.field-row { display: grid; grid-template-columns: 1.4fr 1fr; gap: 0.75rem; }

/* ==========================================================================
   Passcode lock & privacy cover
   ========================================================================== */

body.is-locked { overflow: hidden; }
.lock, .privacy-cover {
  position: fixed; inset: 0; z-index: 250;
  background: var(--paper);
  display: flex; align-items: center; justify-content: center;
  padding: max(1.5rem, env(safe-area-inset-top)) 1.5rem max(1.5rem, env(safe-area-inset-bottom));
}
.privacy-cover { z-index: 260; }
.lock { animation: fade 240ms var(--ease); }
.lock--leaving { animation: lock-out 260ms var(--ease) forwards; }
.lock__inner { width: 100%; max-width: 300px; display: flex; flex-direction: column; align-items: center; text-align: center; }
.lock__seal { margin-bottom: 1.4rem; animation: stamp 600ms var(--ease) both; }
.lock__title { font-size: 2.4rem; line-height: 1; }
.lock__subtitle { margin-top: 0.55rem; color: var(--ink-soft); font-size: 0.95rem; min-height: 1.4em; }
.lock__dots { display: flex; gap: 1.1rem; margin: 1.6rem 0 2rem; }
.lock__dots span {
  width: 13px; height: 13px; border-radius: 50%;
  border: 1.5px solid var(--ink-soft);
  transition: background var(--fast) var(--ease), border-color var(--fast) var(--ease), transform var(--fast) var(--ease);
}
.lock__dots span.is-filled { background: var(--wax); border-color: var(--wax); transform: scale(1.1); }
.lock__dots--wrong { animation: shake 400ms var(--ease); }
.lock__dots--wrong span { border-color: var(--danger); }
.lock__pad { display: grid; grid-template-columns: repeat(3, 76px); gap: 0.9rem 1.4rem; }
.lock__key {
  width: 76px; height: 76px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-family: var(--serif); font-size: 2.2rem; line-height: 1;
  border: 1px solid var(--rule-strong);
  transition: background var(--fast) var(--ease), transform 90ms var(--ease);
}
.lock__key:active { background: var(--ink); color: var(--paper); transform: scale(0.94); }
.lock__key--del { border-color: transparent; color: var(--ink-soft); }
.lock__key--del .icon { width: 26px; height: 26px; }
.lock__footer { margin-top: 1.75rem; }
.lock__link { font-family: var(--mono); font-size: 0.78rem; color: var(--ink-faint); padding: 0.5rem; border-bottom: 1px solid transparent; }
.lock__link:hover { color: var(--wax-text); border-bottom-color: currentColor; }

/* ==========================================================================
   3D tilt + sheen for paper objects (driven by js/tilt.js)
   ========================================================================== */

.letter.is-tilting, .envelope.is-tilting {
  transform: perspective(900px) rotateX(var(--rx, 0deg)) rotateY(var(--ry, 0deg)) translateY(-3px);
  transition: transform 140ms ease-out, box-shadow var(--med) var(--ease);
  box-shadow: var(--shadow-lift);
}
.polaroid.is-tilting {
  transform: perspective(800px) rotateX(var(--rx, 0deg)) rotateY(var(--ry, 0deg)) scale(1.04);
  transition: transform 140ms ease-out, box-shadow var(--med) var(--ease);
  box-shadow: var(--shadow-lift); z-index: 2;
}
.on-this-day.is-tilting, .countdown.is-tilting {
  transform: perspective(1000px) rotateX(calc(var(--rx, 0deg) * 0.5)) rotateY(calc(var(--ry, 0deg) * 0.5)) translateY(-2px);
  transition: transform 140ms ease-out;
}
.polaroid::after, .letter::after, .envelope::after, .on-this-day::after {
  content: ""; position: absolute; inset: 0; pointer-events: none; z-index: 3;
  background: radial-gradient(circle at var(--sx, 50%) var(--sy, 30%), rgba(255, 255, 255, 0.55), transparent 55%);
  mix-blend-mode: soft-light; opacity: 0;
  transition: opacity var(--med) var(--ease);
}
.is-tilting::after { opacity: 1; }
.on-this-day { position: relative; }

/* ==========================================================================
   Profile pictures
   ========================================================================== */

.avatar { overflow: hidden; }
.avatar__presence { z-index: 2; }
.avatar--photo { background: var(--paper-deep); color: transparent; overflow: visible; }
.avatar__img {
  position: absolute; inset: 0; width: 100%; height: 100%;
  border-radius: 50%; object-fit: cover;
  animation: fade 300ms var(--ease);
}
.avatar--photo { box-shadow: 0 0 0 1.5px var(--card), 0 0 0 2.5px var(--rule); }
.avatar--xxl { width: 112px; height: 112px; font-size: 3rem; }
.avatar--hero { width: 92px; height: 92px; font-size: 2.6rem; box-shadow: 0 0 0 4px var(--paper), 0 10px 26px -10px rgba(40, 20, 10, 0.45); }
.avatar--hero.avatar--photo { box-shadow: 0 0 0 4px var(--paper), 0 0 0 5px var(--rule), 0 12px 28px -10px rgba(40, 20, 10, 0.5); }

.us-faces { display: flex; align-items: center; margin-bottom: 1.4rem; }
.us-faces__me, .us-faces__them { position: relative; display: inline-flex; border-radius: 50%; }
.us-faces__me { transition: transform var(--fast) var(--ease); }
@media (hover: hover) and (pointer: fine) { .us-faces__me:hover { transform: translateY(-2px) rotate(-2deg); } }
.us-faces__them { transform: rotate(3deg); }
.us-faces__seal { width: 44px; height: 44px; margin: 0 -14px; z-index: 2; transform: translateY(18px) rotate(-8deg); }
.us-faces__edit {
  position: absolute; left: -2px; bottom: 2px;
  width: 30px; height: 30px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  background: var(--ink); color: var(--paper);
  box-shadow: 0 0 0 3px var(--paper);
}
.us-faces__edit .icon { width: 15px; height: 15px; }
.us-faces__me--right .us-faces__edit { left: auto; right: -2px; }

.settings-row__icon--avatar { background: none; }
.login-card__faces { display: flex; justify-content: center; margin-top: 1rem; }
.login-card__faces .avatar + .avatar { margin-left: -10px; }
.sidebar__avatars .avatar--photo + .avatar--photo { box-shadow: 0 0 0 2px var(--paper); }

.heartbeat__face { position: relative; animation: heartbeat 1.2s ease-in-out infinite; }
.heartbeat__face .avatar--xxl { box-shadow: 0 0 0 5px var(--paper), 0 18px 40px -12px rgba(40, 20, 10, 0.5); }
.heartbeat__face .heartbeat__seal { position: absolute; right: -10px; bottom: -6px; width: 48px; height: 48px; animation: none; }

/* Cropper */
.modal__panel--avatar { max-width: 440px; }
.cropper {
  position: relative; width: min(300px, 78vw); aspect-ratio: 1; margin: 0.4rem auto 0;
  border-radius: var(--r-md); overflow: hidden;
  background: var(--paper-deep);
  touch-action: none; user-select: none; -webkit-user-select: none;
}
.cropper--active { cursor: grab; background: #120e0b; }
.cropper--active:active { cursor: grabbing; }
.cropper__img { position: absolute; left: 50%; top: 50%; max-width: none; transform-origin: center; pointer-events: none; will-change: transform; }
.cropper__img[hidden] { display: none; }
.cropper__ring {
  position: absolute; inset: 0; pointer-events: none; border-radius: 50%;
  box-shadow: 0 0 0 999px rgba(14, 10, 8, 0.55), inset 0 0 0 2px rgba(255, 248, 239, 0.9);
  opacity: 0; transition: opacity var(--med) var(--ease);
}
.cropper--active .cropper__ring { opacity: 1; }
.cropper__empty { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1rem; cursor: pointer; }
.cropper__empty[hidden] { display: none; }
.cropper__cta { display: inline-flex; align-items: center; gap: 0.45rem; font-weight: 600; color: var(--ink); padding: 0.55rem 1rem; border-radius: var(--r-full); background: var(--card); box-shadow: var(--shadow-paper); }
.cropper__cta .icon { width: 18px; height: 18px; color: var(--wax-text); }
.cropper__empty:hover .cropper__cta { color: var(--wax-text); }
.cropper__hint { text-align: center; font-family: var(--mono); font-size: 0.72rem; color: var(--ink-faint); margin-top: 0.8rem; }
.cropper__zoom { display: flex; align-items: center; gap: 0.7rem; max-width: 300px; margin: 0.8rem auto 0.4rem; color: var(--ink-faint); }
.cropper__zoom[hidden], .cropper__hint[hidden] { display: none; }
.cropper__zoom input { flex: 1; accent-color: var(--wax); }
.cropper__zoom .icon { width: 14px; height: 14px; }
.cropper__zoom .cropper__zoom-big .icon { width: 22px; height: 22px; }
.modal__panel--avatar .modal__actions { margin-top: 1.4rem; }
.modal__panel--avatar label.btn { cursor: pointer; }
.modal__panel--avatar label.btn[hidden] { display: none; }

/* ==========================================================================
   Lazy media
   ========================================================================== */

[data-media-as="bg"]:not(.media--ready), .msg__image img:not(.media--ready) {
  background-color: var(--paper-deep);
  background-image: linear-gradient(100deg, transparent 30%, rgba(255, 255, 255, 0.35) 50%, transparent 70%);
  background-size: 200% 100%;
  animation: shimmer 1.4s linear infinite;
}
.msg__image img { height: auto; }
/* Older photos have no saved size: give them a steady frame so nothing
   jumps as they load (iPhone doesn't hold your place when content grows). */
.msg__image img:not([width]) { width: min(240px, 62vw); aspect-ratio: 4 / 5; object-fit: cover; }
.media--ready { animation: fade 320ms var(--ease); }
.media--missing { background-image: none !important; animation: none !important; }
.voice--loading .voice__play { opacity: 0.6; }
@keyframes shimmer { from { background-position: 150% 0; } to { background-position: -50% 0; } }

.load-earlier {
  align-self: center; margin: 0.6rem 0 0.8rem;
  padding: 0.45rem 0.95rem; border-radius: var(--r-full);
  border: 1px solid var(--rule-strong); background: var(--card);
  font-family: var(--mono); font-size: 0.72rem; color: var(--ink-soft);
  transition: border-color var(--fast) var(--ease), color var(--fast) var(--ease);
}
.load-earlier:hover { border-color: var(--ink); color: var(--ink); }
.load-earlier:disabled { opacity: 0.6; }

/* ==========================================================================
   Quality of life: badge, banners, jump to latest, message actions
   ========================================================================== */

.nav-item { position: relative; }
.nav-badge {
  position: absolute; top: 3px; left: calc(50% + 6px);
  min-width: 18px; height: 18px; padding: 0 5px;
  border-radius: 9px; background: var(--wax); color: var(--on-wax);
  font-size: 0.66rem; font-weight: 700; line-height: 18px; text-align: center;
  box-shadow: 0 0 0 2px var(--paper);
  animation: pop 260ms var(--ease);
}
.nav-badge[hidden] { display: none; }
.bottom-nav .nav-badge { box-shadow: 0 1px 4px rgba(40, 10, 10, 0.35); }
.sidebar .nav-badge { position: static; margin-left: auto; align-self: center; box-shadow: none; }

.banner {
  position: fixed; z-index: 160; left: 50%;
  top: calc(env(safe-area-inset-top) + 10px);
  transform: translate(-50%, -140%);
  display: flex; align-items: center; gap: 0.6rem;
  max-width: calc(100vw - 1.5rem);
  padding: 0.55rem 0.6rem 0.55rem 0.9rem;
  border-radius: var(--r-full);
  background: rgba(30, 20, 17, 0.86); color: #fff8ef;
  -webkit-backdrop-filter: blur(16px) saturate(1.4); backdrop-filter: blur(16px) saturate(1.4);
  font-size: 0.86rem; font-weight: 500;
  box-shadow: 0 12px 30px -12px rgba(20, 10, 8, 0.55), 0 0 0 0.5px rgba(255, 255, 255, 0.08);
  transition: transform 420ms cubic-bezier(0.2, 0.9, 0.3, 1.2);
}
.banner--visible { transform: translate(-50%, 0); }
/* In Chat, sit just below the header instead of over her name */
body:has(.chat-header) .banner { top: calc(env(safe-area-inset-top) + var(--island-room) + 74px); }
.banner__dot { width: 8px; height: 8px; border-radius: 50%; background: #e39a90; flex-shrink: 0; animation: rec-blink 1.4s ease-in-out infinite; }
.banner--good .banner__dot { background: #6bbf8a; animation: none; }
.banner__text { padding-right: 0.3rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.banner__action {
  padding: 0.35rem 0.8rem; border-radius: var(--r-full);
  background: var(--wax); color: var(--on-wax); font-weight: 600; font-size: 0.82rem;
}

.chat-view { position: relative; }
.jump-latest {
  position: absolute; right: 1rem; bottom: 86px; z-index: 6;
  width: 42px; height: 42px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  background: var(--card); color: var(--ink);
  border: 1px solid var(--rule-strong); box-shadow: var(--shadow-lift);
  animation: pop 220ms var(--ease);
}
.jump-latest[hidden] { display: none; }
.jump-latest .icon { width: 20px; height: 20px; transform: rotate(90deg); }
.jump-latest__count {
  position: absolute; top: -6px; right: -4px; min-width: 18px; height: 18px; padding: 0 5px;
  border-radius: 9px; background: var(--wax); color: var(--on-wax);
  font-size: 0.66rem; font-weight: 700; line-height: 18px; text-align: center;
}
.jump-latest__count[hidden] { display: none; }

.msg__bubble { -webkit-touch-callout: none; }
@media (hover: none) { .msg__text { -webkit-user-select: none; user-select: none; } }

.modal__panel--actions { max-width: 420px; padding-top: 1.6rem; }
.modal__panel--actions .modal__close { display: none; }
.sheet-preview {
  margin: 0.4rem 0.2rem 1rem; padding: 0.7rem 0.9rem;
  border-left: 2px solid var(--wax-text); background: var(--paper);
  font-family: var(--serif); font-size: 1.15rem; line-height: 1.3; color: var(--ink-soft);
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden;
}
.sheet-actions { display: flex; flex-direction: column; border-top: 1px solid var(--rule); }
.sheet-action {
  display: flex; align-items: center; gap: 0.85rem;
  min-height: 52px; padding: 0 0.3rem; text-align: left;
  border-bottom: 1px solid var(--rule); font-size: 1rem; font-weight: 500;
  transition: background var(--fast) var(--ease), color var(--fast) var(--ease);
}
.sheet-action .icon { width: 20px; height: 20px; color: var(--ink-soft); }
.sheet-action:hover { background: var(--paper-deep); }
.sheet-action--wax .icon { color: var(--wax-text); fill: var(--wax-text); }
.sheet-action--danger, .sheet-action--danger .icon { color: var(--danger); }

/* ==========================================================================
   Tab badges ("new" dots) and the in-app message banner
   ========================================================================== */

.nav-badge--dot { min-width: 18px; }
.sidebar .nav-badge { margin-left: auto; }

.msg-banner {
  position: fixed; z-index: 170; left: 50%;
  top: calc(env(safe-area-inset-top) + 10px);
  width: min(420px, calc(100vw - 1.5rem));
  display: flex; align-items: center; gap: 0.75rem;
  padding: 0.65rem 0.8rem;
  border-radius: 18px;
  background: color-mix(in srgb, var(--card) 92%, transparent);
  -webkit-backdrop-filter: blur(16px) saturate(1.3); backdrop-filter: blur(16px) saturate(1.3);
  border: 1px solid var(--rule);
  box-shadow: var(--shadow-lift);
  text-align: left; color: var(--ink);
  transform: translate(-50%, -130%);
  transition: transform 420ms cubic-bezier(0.2, 0.9, 0.3, 1.15);
}
.msg-banner--in { transform: translate(-50%, 0); }
.msg-banner .avatar { width: 38px; height: 38px; font-size: 1.1rem; flex-shrink: 0; }
.msg-banner__text { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.msg-banner__name { font-weight: 600; font-size: 0.9rem; }
.msg-banner__body { font-size: 0.86rem; color: var(--ink-soft); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.msg-banner__go { color: var(--ink-faint); }
.msg-banner__go .icon { width: 18px; height: 18px; }

/* ==========================================================================
   Floating action button: the main action on a page, by your thumb
   ========================================================================== */

.fab {
  position: fixed; z-index: 15;
  right: max(20px, env(safe-area-inset-right));
  bottom: calc(var(--nav-height) + env(safe-area-inset-bottom) + 16px);
  width: 56px; height: 56px; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--wax); color: var(--on-wax);
  box-shadow: var(--shadow-float);
  animation: pop 320ms var(--ease) both;
  transition: transform var(--press) var(--ease), background var(--fast) var(--ease);
}
.fab .icon { width: 26px; height: 26px; stroke-width: 2; }
.fab:active { transform: scale(0.92); }
@media (hover: hover) { .fab:hover { background: var(--wax-deep); } }
body.has-modal .fab { visibility: hidden; }
@media (min-width: 980px) { .fab { bottom: 28px; right: 32px; } }

/* ==========================================================================
   Shared pieces added in Phase 5
   ========================================================================== */

/* Extended floating button: icon and a word ("Write") */
.fab.fab--extended {
  width: auto; height: 52px; padding: 0 20px 0 16px; gap: 8px;
  display: inline-flex; align-items: center; border-radius: 26px;
  font-weight: 600; font-size: var(--text-callout);
}
.fab--extended .icon { width: 20px; height: 20px; }

/* Segmented control, like iOS */
.seg-control {
  display: flex; gap: 2px; margin: -0.4rem var(--gutter) 1.25rem; padding: 3px;
  background: var(--paper-deep); border-radius: var(--r-sm);
}
.seg-control__item {
  flex: 1; min-width: 0; min-height: 36px; padding: 0 0.5rem; border-radius: 11px;
  font-size: 0.84375rem; font-weight: 500; color: var(--ink-soft);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  transition: background var(--fast) var(--ease), color var(--fast) var(--ease), box-shadow var(--fast) var(--ease);
}
.seg-control__item--on { background: var(--card); color: var(--ink); font-weight: 600; box-shadow: 0 1px 3px rgba(40, 20, 10, 0.12); }

/* Back link and a sub-page header */
.back-link {
  display: inline-flex; align-items: center; gap: 2px; min-height: 40px; margin-left: -6px;
  font-size: var(--text-callout); font-weight: 500; color: var(--wax-text);
}
.back-link .icon { width: 20px; height: 20px; }
.page-header--sub { padding-top: 1rem; }
.page-header--sub .page-header__title { margin-top: 0.2rem; }

.avatar--xs { width: 24px; height: 24px; font-size: 0.8rem; flex: none; }

/* A little wax seal on a button */
.wax-dot {
  display: inline-block; width: 15px; height: 15px; margin-right: 0.15rem; border-radius: 47% 53% 50% 50%;
  background: radial-gradient(circle at 38% 34%, #e08a84, #a3363a 60%, #6f1d22);
  box-shadow: 0 0 0 1.5px rgba(255, 255, 255, 0.5);
}

/* The form's segmented choice matches the segmented control: a soft track
   with the chosen option raised, instead of a heavy ink fill. */
.segmented { gap: 2px; padding: 3px; border: 0; border-radius: var(--r-sm); background: var(--paper-deep); grid-template-columns: repeat(3, minmax(0, 1fr)); }
.segmented__option + .segmented__option { border-left: 0; }
.segmented__option span { border-radius: 11px; transition: background var(--fast) var(--ease), color var(--fast) var(--ease), box-shadow var(--fast) var(--ease); }
.segmented__option input:checked + span { background: var(--card); color: var(--ink); font-weight: 600; box-shadow: 0 1px 3px rgba(40, 20, 10, 0.12); }

/* Dark mode: the raised option needs a lighter surface to read as raised */
[data-theme="dark"] .seg-control__item--on,
[data-theme="dark"] .segmented__option input:checked + span { background: #3a2d26; box-shadow: 0 1px 3px rgba(0, 0, 0, 0.4); }

/* ==========================================================================
   Soft surfaces (moved unchanged from refined.css in Phase 6)
   ========================================================================== */

body { font-feature-settings: "cv11", "ss01"; }

/* Buttons: solid wax */
.btn { border-radius: var(--r-full); }
.btn--primary { background: var(--wax); color: var(--on-wax); box-shadow: 0 2px 10px color-mix(in srgb, var(--wax) 24%, transparent); }
.btn--primary:hover:not(:disabled) { background: var(--wax-deep); color: var(--on-wax); }

/* Cards instead of dashed boxes */
.empty-state--card, .polaroid--add {
  border: 0.5px solid var(--rule-strong); border-style: solid; background: var(--card); box-shadow: var(--shadow-paper);
}

/* A primary button you can't press yet: quiet neutral, not faded pink */
.btn--primary:disabled { opacity: 1; background: var(--paper-deep); color: var(--ink-faint); box-shadow: none; }
