/* ==========================================================================
   Ruth & Anson - design system
   Simple, romantic, cute. Warm paper, wobbly hand-drawn edges, soft pastels.
   ========================================================================== */

@import url('../vendor/font-gaegu.css');
@import url('../vendor/font-patrickhand.css');
@import url('../vendor/font-nunito.css');
@import url('../vendor/font-zcoolkuaile.css');

:root {
  /* --- palette --- */
  --cream: #fdf8f2;
  --paper: #fffdfb;
  --ink: #4a3a3a;
  --ink-soft: #7d6a68;
  --ink-faint: #a89a97;
  --rose: #f286a0;
  --rose-deep: #dd5f80;
  --rose-soft: #ffd9e2;
  --rose-bg: #fff1f4;
  --mint: #6bbfa2;
  --mint-soft: #cdece0;
  --sky: #7c9ed4;
  --sky-soft: #dbe6f8;
  --butter: #f5c860;
  --butter-soft: #fdeec4;
  --lilac: #b39ddb;
  --lilac-soft: #e9e1f8;

  --line: #eedfd6;
  --line-strong: #e2cec4;

  /* Ruth's theme (rose) - also the default before anyone is chosen */
  --accent: #f286a0;
  --accent-deep: #dd5f80;
  --accent-soft: #ffd9e2;
  --accent-bg: #fff1f4;
  --accent-line: #fbd3dd;
  --blob-1: rgba(255, 214, 226, 0.55);
  --blob-2: rgba(213, 236, 228, 0.5);
  --blob-3: rgba(231, 224, 250, 0.5);
  --blob-4: rgba(253, 238, 196, 0.45);

  /* --- type --- */
  --font-hand: 'Gaegu', 'ZCOOL KuaiLe', 'Segoe Print', 'Comic Sans MS', cursive;
  --font-hand-ui: 'Patrick Hand', 'Segoe Print', cursive;
  --font-body: 'Nunito', 'PingFang SC', 'Microsoft YaHei', 'Hiragino Sans GB',
    system-ui, -apple-system, 'Segoe UI', sans-serif;

  /* --- shape --- */
  --r-sm: 10px;
  --r-md: 16px;
  --r-lg: 22px;
  --r-xl: 30px;
  --r-pill: 999px;

  --shadow-sm: 0 2px 6px rgba(160, 120, 120, 0.07);
  --shadow: 0 6px 18px rgba(160, 120, 120, 0.1);
  --shadow-lg: 0 18px 40px rgba(150, 110, 110, 0.16);
  --shadow-inner: inset 0 1px 0 rgba(255, 255, 255, 0.8);

  --header-h: 68px;
  --maxw: 1120px;
  --ease-bounce: cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* Anson's theme: the whole site turns light blue when his view is active. */
html[data-viewer='anson'] {
  --accent: #6f9fd8;
  --accent-deep: #3f78b8;
  --accent-soft: #d3e4f8;
  --accent-bg: #f0f6fd;
  --accent-line: #cfe0f4;
  --blob-1: rgba(200, 224, 250, 0.6);
  --blob-2: rgba(213, 240, 236, 0.5);
  --blob-3: rgba(216, 232, 252, 0.55);
  --blob-4: rgba(230, 240, 255, 0.5);
  --line: #e2e9f1;
  --line-strong: #ccd9e8;
  --cream: #f7fafd;
}

/* Chinese mode: the playful Chinese display font is capped on Latin, so let the
   Chinese system font do the work and keep ZCOOL for the accents. */
html[data-lang='zh'] {
  --font-hand: 'ZCOOL KuaiLe', 'Gaegu', 'Yuanti SC', 'PingFang SC', 'Microsoft YaHei', cursive;
  --font-hand-ui: 'Nunito', 'PingFang SC', 'Microsoft YaHei', sans-serif;
}

* { box-sizing: border-box; }

/* Any element with the `hidden` attribute stays hidden, even when a component
   rule below sets an explicit display value (the gate is display:grid). */
[hidden] { display: none !important; }

html, body {
  margin: 0;
  padding: 0;
  min-height: 100%;
}

body {
  font-family: var(--font-body);
  color: var(--ink);
  background-color: var(--cream);
  /* soft hand-drawn paper grain + pastel light blobs */
  background-image:
    radial-gradient(circle at 12% 8%, var(--blob-1), transparent 42%),
    radial-gradient(circle at 88% 4%, var(--blob-2), transparent 40%),
    radial-gradient(circle at 78% 92%, var(--blob-3), transparent 45%),
    radial-gradient(circle at 20% 96%, var(--blob-4), transparent 40%),
    url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='140' height='140'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='3'/><feColorMatrix type='saturate' values='0'/></filter><rect width='140' height='140' filter='url(%23n)' opacity='0.035'/></svg>");
  background-attachment: fixed;
  font-size: 16px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  transition: background-color 0.5s ease;
  overflow-x: hidden;
}

h1, h2, h3, h4 {
  font-family: var(--font-hand);
  font-weight: 400;
  letter-spacing: 0.01em;
  margin: 0 0 0.35em;
  line-height: 1.25;
}

h1 { font-size: clamp(1.9rem, 4vw, 2.8rem); }
h2 { font-size: clamp(1.4rem, 2.6vw, 1.95rem); }
h3 { font-size: 1.2rem; }

p { margin: 0 0 0.8em; }

a { color: var(--accent-deep); text-decoration: none; }
a:hover { text-decoration: underline wavy var(--accent-soft); }

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

::selection { background: var(--accent-soft); color: var(--ink); }

:focus-visible {
  outline: 3px dashed var(--accent);
  outline-offset: 3px;
  border-radius: 6px;
}

/* ---------------- layout ---------------- */

.wrap {
  width: min(100% - 2rem, var(--maxw));
  margin: 0 auto;
}

.page {
  padding: 26px 0 96px;
  animation: pageIn 0.45s var(--ease-bounce) both;
}

@keyframes pageIn {
  from { opacity: 0; transform: translateY(14px) scale(0.995); }
  to { opacity: 1; transform: none; }
}

.page-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 18px;
}

.page-head .sub {
  color: var(--ink-soft);
  font-family: var(--font-hand-ui);
  font-size: 1.06rem;
  margin: 0;
}

.grid { display: grid; gap: 18px; }
.grid.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid.auto { grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }
.grid.side { grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); align-items: start; }

.stack { display: flex; flex-direction: column; gap: 12px; }
.row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.row.tight { gap: 6px; }
.spacer { flex: 1; }
.center { text-align: center; }
.muted { color: var(--ink-soft); }
.faint { color: var(--ink-faint); }
.hand { font-family: var(--font-hand); }
.small { font-size: 0.86rem; }
.tiny { font-size: 0.76rem; }
.hidden { display: none !important; }
.nowrap { white-space: nowrap; }

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

/* ---------------- hand-drawn card ---------------- */

.card {
  position: relative;
  background: var(--paper);
  border: 2px solid var(--line);
  border-radius: var(--r-lg);
  padding: 20px;
  box-shadow: var(--shadow);
  /* the wobbly "drawn by hand" edge: two uneven radii per corner */
  border-radius: 24px 20px 26px 18px / 20px 26px 18px 24px;
}

.card.flat { box-shadow: var(--shadow-sm); }
.card.tight { padding: 14px; }
.card.pad-lg { padding: 28px; }
.card.rose { background: linear-gradient(180deg, var(--accent-bg), var(--paper)); border-color: var(--accent-line); }
.card.mint { background: linear-gradient(180deg, var(--accent-bg), var(--paper)); border-color: #cfeade; }
.card.sky { background: linear-gradient(180deg, #f4f8ff, var(--paper)); border-color: #d6e3f7; }
.card.butter { background: linear-gradient(180deg, #fffbf0, var(--paper)); border-color: #f7e6bd; }

.card-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-hand);
  font-size: 1.15rem;
  margin-bottom: 10px;
}

.card-title .dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-bg);
}

/* washi tape accent */
.tape::before {
  content: '';
  position: absolute;
  top: -11px;
  left: 50%;
  transform: translateX(-50%) rotate(-2deg);
  width: 84px;
  height: 22px;
  background: var(--accent-soft);
  opacity: 0.85;
  border-left: 1px dashed rgba(255, 255, 255, 0.9);
  border-right: 1px dashed rgba(255, 255, 255, 0.9);
  border-radius: 2px;
}

/* ---------------- buttons ---------------- */

.btn {
  --btn-bg: var(--accent);
  --btn-fg: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 18px;
  border: 2px solid rgba(0, 0, 0, 0.06);
  border-radius: var(--r-pill);
  background: var(--btn-bg);
  color: var(--btn-fg);
  font-family: var(--font-hand-ui);
  font-size: 1.02rem;
  letter-spacing: 0.02em;
  cursor: pointer;
  box-shadow: 0 3px 0 rgba(180, 120, 130, 0.22), var(--shadow-sm);
  transition: transform 0.16s var(--ease-bounce), box-shadow 0.16s, filter 0.16s;
  user-select: none;
  white-space: nowrap;
}

.btn:hover { transform: translateY(-2px) rotate(-0.6deg); filter: brightness(1.03); }
.btn:active { transform: translateY(1px); box-shadow: 0 1px 0 rgba(180, 120, 130, 0.2); }
.btn[disabled] { opacity: 0.5; cursor: not-allowed; transform: none; box-shadow: none; }

.btn.ghost {
  --btn-bg: transparent;
  --btn-fg: var(--ink-soft);
  border: 2px dashed var(--line-strong);
  box-shadow: none;
}
.btn.ghost:hover { --btn-fg: var(--accent-deep); border-color: var(--accent-soft); }

.btn.soft { --btn-bg: var(--accent-bg); --btn-fg: var(--accent-deep); box-shadow: none; border-color: var(--accent-line); }
.btn.mint { --btn-bg: var(--mint); }
.btn.sky { --btn-bg: var(--sky); }
.btn.butter { --btn-bg: var(--butter); --btn-fg: #6b5320; }
.btn.small { padding: 6px 13px; font-size: 0.92rem; }
.btn.tiny { padding: 4px 10px; font-size: 0.84rem; }
.btn.block { width: 100%; }
.btn.icon { padding: 8px; width: 38px; height: 38px; border-radius: 50%; }

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 2px solid transparent;
  background: transparent;
  cursor: pointer;
  color: var(--ink-soft);
  transition: background 0.16s, transform 0.16s var(--ease-bounce), color 0.16s;
}
.icon-btn:hover { background: var(--accent-bg); color: var(--accent-deep); transform: rotate(-6deg) scale(1.06); }

/* ---------------- phone behaviour ----------------
   Everything a thumb touches should feel like an app, not a web page:
   no blue tap flash, no long-press menu, no double-tap zoom, no text
   selection on controls - but the actual content stays selectable. */
.btn,
.chip,
.mood-chip,
.opt-pill,
.swatch,
.tabbar-seg .tab,
.icon-btn,
.pill-select,
.tabbar a,
.nav a,
.brand,
.care,
.switch,
.mood-row .chip,
.card-title {
  -webkit-tap-highlight-color: transparent;
  -webkit-touch-callout: none;
  user-select: none;
  touch-action: manipulation;
}

/* Keep typing comfortable: below 16px Android/iOS zoom the page on focus. */
@media (max-width: 820px) {
  input[type='date'], input[type='time'], input[type='password'], textarea {
    font-size: 16px;
  }
  /* thumbs, not cursors */
  .btn { min-height: 44px; }
  .btn.small, .btn.tiny { min-height: 36px; }
  .chip { min-height: 34px; padding: 7px 14px; }
  .icon-btn { width: 42px; height: 42px; }
  .mood-chip { width: 40px; height: 40px; }
  .note-tools { opacity: 1; }
  .note-tools .btn { min-height: 34px; }
  .tabbar-seg .tab { padding: 13px 18px; }
  .select { padding-top: 12px; padding-bottom: 12px; }
}

/* Anything scrolled horizontally (city list, tabs, quick replies) should glide
   and not bounce the whole page. */
.scroll-x, .tabbar-seg, .opt-row, .filters {
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-x: contain;
}

/* Safe areas: nothing hides under a notch or the gesture bar. */
@supports (padding: env(safe-area-inset-bottom)) {
  .site-header .header-inner { padding-left: env(safe-area-inset-left); padding-right: env(safe-area-inset-right); }
  .tabbar { padding-bottom: calc(6px + env(safe-area-inset-bottom)); }
  .toast-wrap { bottom: calc(26px + env(safe-area-inset-bottom)); }
  .wrap { padding-left: env(safe-area-inset-left); padding-right: env(safe-area-inset-right); }
}

/* Pixel-art icons from the optional assets/pixel pack */
.pixel-icon {
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  vertical-align: middle;
  flex: none;
}

/* ---------------- forms ---------------- */

.field { display: flex; flex-direction: column; gap: 5px; margin-bottom: 12px; }
.field > label {
  font-family: var(--font-hand-ui);
  font-size: 0.95rem;
  color: var(--ink-soft);
}

.input, .textarea, .select {
  width: 100%;
  padding: 10px 13px;
  background: #fff;
  border: 2px solid var(--line);
  border-radius: 14px 12px 15px 11px / 12px 15px 11px 14px;
  transition: border-color 0.16s, box-shadow 0.16s;
  font-family: var(--font-body);
}

.textarea { min-height: 92px; resize: vertical; line-height: 1.55; }

.input:focus, .textarea:focus, .select:focus {
  outline: none;
  border-color: var(--accent-soft);
  box-shadow: 0 0 0 4px rgba(255, 217, 226, 0.55);
}

.input::placeholder, .textarea::placeholder { color: var(--ink-faint); }

.select {
  appearance: none;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%237d6a68' stroke-width='2.4' stroke-linecap='round'><path d='M6 9l6 6 6-6'/></svg>");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 34px;
}

/* segmented control */
.seg {
  display: inline-flex;
  padding: 4px;
  gap: 3px;
  background: var(--accent-bg);
  border: 2px solid var(--line);
  border-radius: var(--r-pill);
}

.seg button {
  border: none;
  background: transparent;
  padding: 6px 14px;
  border-radius: var(--r-pill);
  cursor: pointer;
  font-family: var(--font-hand-ui);
  color: var(--ink-soft);
  transition: all 0.18s var(--ease-bounce);
}

.seg button[aria-pressed='true'] {
  background: #fff;
  color: var(--accent-deep);
  box-shadow: var(--shadow-sm);
  transform: translateY(-1px);
}

/* chips */
.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 12px;
  border-radius: var(--r-pill);
  background: var(--accent-bg);
  border: 1.5px solid var(--accent-line);
  color: var(--accent-deep);
  font-family: var(--font-hand-ui);
  font-size: 0.9rem;
  cursor: pointer;
  transition: transform 0.16s var(--ease-bounce), background 0.16s;
}
.chip:hover { transform: translateY(-2px) rotate(-1deg); }
.chip[aria-pressed='true'] { background: var(--accent); color: #fff; border-color: var(--accent); }
.chip.mint { background: #eefaf5; border-color: #cfeade; color: #3f8b72; }
.chip.mint[aria-pressed='true'] { background: var(--mint); color: #fff; }
.chip.sky { background: #f1f6ff; border-color: #d6e3f7; color: #4f6ea8; }
.chip.plain { background: #fff; border-color: var(--line); color: var(--ink-soft); cursor: default; }
.chip.plain:hover { transform: none; }

/* mood picker: a round emoji button */
.mood-chip {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: 2px solid var(--line);
  background: #fff;
  font-size: 1.15rem;
  line-height: 1;
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: transform 0.16s var(--ease-bounce), border-color 0.16s, background 0.16s;
}
.mood-chip:hover { transform: translateY(-2px) rotate(-6deg); border-color: var(--accent-soft); }
.mood-chip.mint { background: var(--accent-bg); border-color: var(--accent); }

/* ---------------- header ---------------- */

.site-header {
  position: sticky;
  top: 0;
  z-index: 40;
  background: rgba(253, 248, 242, 0.86);
  backdrop-filter: blur(10px) saturate(1.2);
  border-bottom: 2px dashed var(--line);
}

.header-inner {
  display: flex;
  align-items: center;
  gap: 14px;
  height: var(--header-h);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  background: none;
  border: none;
  padding: 4px;
}

.brand .logo { width: 40px; height: 40px; flex: none; }
.brand .logo svg { width: 100%; height: 100%; display: block; }

.brand-text { display: flex; flex-direction: column; line-height: 1.05; text-align: left; }
.brand-name { font-family: var(--font-hand); font-size: 1.3rem; color: var(--ink); }
.brand-sub { font-family: var(--font-hand-ui); font-size: 0.76rem; color: var(--ink-faint); }

.nav {
  display: flex;
  align-items: center;
  gap: 2px;
  margin-left: 6px;
}

.nav a {
  position: relative;
  padding: 8px 13px;
  border-radius: var(--r-pill);
  color: var(--ink-soft);
  font-family: var(--font-hand-ui);
  font-size: 1rem;
  white-space: nowrap;
  transition: color 0.16s, background 0.16s;
}
.nav a:hover { text-decoration: none; background: rgba(255, 255, 255, 0.8); color: var(--accent-deep); }
.nav a.active { color: var(--accent-deep); background: #fff; box-shadow: var(--shadow-sm); }
.nav a.active::after {
  content: '';
  position: absolute;
  left: 18%;
  right: 18%;
  bottom: 1px;
  height: 3px;
  border-radius: 3px;
  background: var(--accent-soft);
}

.header-tools { display: flex; align-items: center; gap: 8px; margin-left: auto; }

.pill-select {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 6px 12px;
  background: #fff;
  border: 2px solid var(--line);
  border-radius: var(--r-pill);
  cursor: pointer;
  font-family: var(--font-hand-ui);
  font-size: 0.94rem;
  color: var(--ink-soft);
  box-shadow: var(--shadow-sm);
  transition: transform 0.16s var(--ease-bounce), border-color 0.16s, color 0.16s;
}
.pill-select:hover { transform: translateY(-2px); border-color: var(--accent-soft); color: var(--accent-deep); }
.pill-select .who { font-weight: 700; color: var(--ink); }
.pill-select .face {
  width: 24px; height: 24px; border-radius: 50%;
  display: grid; place-items: center;
  font-size: 0.95rem;
  background: var(--accent-bg);
  flex: none;
}
.pill-select.anson .face { background: #eefaf5; }

.menu-toggle { display: none; }

/* mobile bottom nav */
.tabbar { display: none; }

/* ---------------- password gate ---------------- */

.gate {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: grid;
  place-items: center;
  padding: 22px;
  background-color: var(--cream);
  background-image:
    radial-gradient(circle at 15% 15%, var(--blob-1), transparent 45%),
    radial-gradient(circle at 85% 10%, var(--blob-2), transparent 45%),
    radial-gradient(circle at 75% 88%, var(--blob-3), transparent 45%);
  overflow: hidden;
}

.gate.leaving { animation: gateOut 0.7s ease forwards; }
@keyframes gateOut {
  40% { transform: scale(1.02); }
  to { opacity: 0; transform: scale(1.08); visibility: hidden; }
}

.gate-card {
  position: relative;
  width: min(430px, 100%);
  padding: 34px 30px 28px;
  text-align: center;
  background: var(--paper);
  border: 2px solid var(--line);
  border-radius: 30px 24px 32px 26px / 26px 32px 24px 30px;
  box-shadow: var(--shadow-lg);
  animation: gateCardIn 0.7s var(--ease-bounce) both;
  z-index: 2;
}

@keyframes gateCardIn {
  from { opacity: 0; transform: translateY(26px) rotate(-1.4deg); }
  to { opacity: 1; transform: none; }
}

.gate-card h1 { margin-bottom: 2px; }
.gate-card .sub { color: var(--ink-soft); font-family: var(--font-hand-ui); margin-bottom: 20px; }

.gate-lock { width: 74px; height: 74px; margin: 0 auto 6px; }
.gate-lock svg { width: 100%; height: 100%; }

.gate-form { display: flex; flex-direction: column; gap: 12px; }

.gate-input {
  width: 100%;
  text-align: center;
  font-family: var(--font-hand-ui);
  font-size: 1.15rem;
  padding: 13px 14px;
  border: 2px solid var(--line);
  border-radius: var(--r-md);
  background: #fff;
}
.gate-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 4px var(--accent-bg);
}
.gate-input.shake { animation: shake 0.45s; border-color: var(--accent-deep); }
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-9px) rotate(-1deg); }
  40% { transform: translateX(8px) rotate(1deg); }
  60% { transform: translateX(-6px); }
  80% { transform: translateX(4px); }
}

.gate-msg { min-height: 22px; font-family: var(--font-hand-ui); color: var(--accent-deep); }

.float-heart {
  position: absolute;
  bottom: -40px;
  font-size: 22px;
  opacity: 0;
  animation: floatUp linear infinite;
  pointer-events: none;
  z-index: 1;
}
@keyframes floatUp {
  0% { transform: translateY(0) rotate(0deg) scale(0.8); opacity: 0; }
  12% { opacity: 0.85; }
  100% { transform: translateY(-108vh) rotate(28deg) scale(1.15); opacity: 0; }
}

.clock-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; }

.clock-card { padding: 14px 16px; text-align: left; position: relative; min-width: 0; }
.clock-card .who { display: flex; align-items: center; gap: 7px; font-family: var(--font-hand-ui); color: var(--ink-soft); }
.clock-card .city { font-size: 0.82rem; color: var(--ink-faint); }
.clock-card .time {
  font-family: var(--font-hand);
  font-size: clamp(1.4rem, 2.1vw, 2.05rem);
  line-height: 1.12;
  margin: 3px 0 2px;
  letter-spacing: 0.01em;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
.clock-card .zone { font-size: 0.76rem; color: var(--ink-faint); }

/* little heart badge used instead of a flag emoji (flags do not render
   everywhere - Windows falls back to the bare "US" / "CN" letters) */
.flag-badge {
  display: inline-grid;
  place-items: center;
  width: 17px;
  height: 17px;
  border-radius: 50%;
  font-size: 0.6rem;
  line-height: 1;
  flex: none;
  color: #fff;
  box-shadow: var(--shadow-sm);
}
.flag-badge.ruth { background: linear-gradient(140deg, #f9a8bd, #e2688a); }
.flag-badge.anson { background: linear-gradient(140deg, #8fd4bb, #4f9d80); }

.presence {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 0.78rem;
  font-family: var(--font-hand-ui);
  padding: 2px 9px;
  border-radius: var(--r-pill);
  background: #eefaf5;
  color: #3f8b72;
}
.presence.off { background: #f3eeee; color: var(--ink-faint); }
.presence .dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; animation: pulse 2.4s ease-in-out infinite; }
@keyframes pulse { 0%, 100% { opacity: 1; transform: scale(1); } 50% { opacity: 0.45; transform: scale(0.8); } }

@keyframes popIn { from { opacity: 0; transform: translate(-50%, -80%) scale(0.85); } to { opacity: 1; transform: translate(-50%, -100%) scale(1); } }

.quick-note { display: flex; gap: 10px; align-items: flex-start; }
.quick-note .textarea { min-height: 62px; }

.mini-note {
  display: flex;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--r-md);
  background: #fff;
  border: 1.5px dashed var(--line);
}
.mini-note .body { min-width: 0; }
.mini-note .text {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  overflow-wrap: anywhere;
}

/* ---------------- person chips (who wrote / whose view) ---------------- */

.person-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 11px 3px 8px;
  border-radius: var(--r-pill);
  font-family: var(--font-hand-ui);
  font-size: 0.92rem;
  line-height: 1.25;
  white-space: nowrap;
  flex: none;
  border: 1.5px solid transparent;
}
.person-chip .chip-glyph { font-size: 0.9em; line-height: 1; }
.person-chip.ruth { background: #fff1f4; border-color: #fbd3dd; color: #c04f6e; }
.person-chip.anson { background: #eefaf5; border-color: #cfeade; color: #3f8b72; }
.person-chip.sm { font-size: 0.8rem; padding: 2px 9px 2px 6px; gap: 4px; }
.person-chip.sm .chip-glyph { font-size: 0.85em; }
.person-chip.lg {
  font-size: 1.35rem;
  padding: 8px 20px 8px 16px;
  font-family: var(--font-hand);
  margin-bottom: 6px;
}

/* ---------------- message wall ---------------- */

.composer { position: relative; }
.composer .textarea { min-height: 96px; border-color: var(--accent-line); background: #fffdfd; }
.composer-actions { display: flex; align-items: center; gap: 8px; margin-top: 10px; flex-wrap: wrap; }
.composer .counter { font-size: 0.78rem; color: var(--ink-faint); font-family: var(--font-hand-ui); }

.attach-preview { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.attach-item {
  position: relative;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 34px 7px 10px;
  background: var(--accent-bg);
  border: 1.5px dashed #f6c9d6;
  border-radius: var(--r-md);
  font-size: 0.85rem;
  max-width: 100%;
}
.attach-item img { width: 42px; height: 42px; object-fit: cover; border-radius: 8px; }
.attach-item .name { max-width: 190px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.attach-item .remove {
  position: absolute;
  right: 4px;
  top: 50%;
  transform: translateY(-50%);
  width: 22px; height: 22px;
  border-radius: 50%;
  border: none;
  background: #fff;
  cursor: pointer;
  color: var(--ink-soft);
  display: grid; place-items: center;
  box-shadow: var(--shadow-sm);
}

.rec-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  margin-top: 10px;
  background: var(--accent-bg);
  border: 2px dashed var(--accent-line);
  border-radius: var(--r-md);
  font-family: var(--font-hand-ui);
}
.rec-dot { width: 11px; height: 11px; border-radius: 50%; background: var(--accent-deep); animation: pulse 1.1s infinite; }
.rec-time { font-variant-numeric: tabular-nums; color: var(--accent-deep); }

.filters { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 14px; }

.note-list { display: flex; flex-direction: column; gap: 14px; }

.note {
  position: relative;
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 15px 17px;
  background: var(--paper);
  border: 2px solid var(--line);
  border-radius: 20px 17px 21px 16px / 17px 21px 16px 20px;
  box-shadow: var(--shadow-sm);
  animation: noteIn 0.4s var(--ease-bounce) both;
}
/* a name chip is a label, never a column - do not let the flex row stretch it */
.note > .person-chip,
.mini-note > .person-chip,
.score-row > .person-chip { align-self: flex-start; height: fit-content; }
.note > .person-chip { margin-top: 3px; }
@keyframes noteIn { from { opacity: 0; transform: translateY(10px) rotate(-0.4deg); } to { opacity: 1; transform: none; } }

.note.ruth { border-left: 6px solid #f7b8c8; }
.note.anson { border-left: 6px solid #8fd4bb; }
.note.reply { margin-left: 34px; background: #fffdfa; }
.note.by-viewer { background: linear-gradient(180deg, var(--accent-bg), var(--paper)); }

.note-body { min-width: 0; flex: 1; }
.note-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 5px; }
.note-author { font-family: var(--font-hand); font-size: 1.08rem; }
.note-sig {
  font-size: 0.78rem;
  color: var(--ink-faint);
  font-family: var(--font-hand-ui);
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}
.note-sig .zone {
  padding: 1px 8px;
  border-radius: var(--r-pill);
  background: #f6f1ee;
  font-size: 0.72rem;
  cursor: help;
}
.note-sig .alt { color: var(--accent-deep); opacity: 0.85; }
.note-mood { font-size: 1.15rem; }
.note-text {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  font-size: 1.02rem;
  margin: 4px 0 6px;
}
.note-quote {
  border-left: 3px solid var(--line-strong);
  padding: 4px 10px;
  margin: 0 0 6px;
  color: var(--ink-soft);
  font-size: 0.88rem;
  background: #faf7f5;
  border-radius: 0 10px 10px 0;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.note-media { display: flex; flex-wrap: wrap; gap: 10px; margin: 6px 0 2px; }
.note-media .media { max-width: 100%; }
.note-media img.photo, .note-media video {
  max-width: min(420px, 100%);
  max-height: 420px;
  border-radius: var(--r-md);
  border: 2px solid var(--line);
  display: block;
  background: #f4efec;
  cursor: zoom-in;
}
.note-tools { display: flex; gap: 4px; align-items: center; margin-top: 6px; opacity: 0.65; transition: opacity 0.2s; }
.note:hover .note-tools { opacity: 1; }

.voice {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 8px 14px 8px 10px;
  background: var(--accent-bg);
  border: 2px solid #f8d3dd;
  border-radius: var(--r-pill);
  min-width: 200px;
}
.voice .play {
  width: 34px; height: 34px; border-radius: 50%;
  border: none; cursor: pointer;
  background: var(--accent); color: #fff;
  display: grid; place-items: center;
  flex: none;
  transition: transform 0.18s var(--ease-bounce);
}
.voice .play:hover { transform: scale(1.09); }
.voice .bars { display: flex; align-items: center; gap: 2.5px; height: 26px; flex: 1; }
.voice .bars i {
  display: block;
  width: 3px;
  border-radius: 2px;
  background: #f5b9c8;
  height: 30%;
  transition: height 0.18s, background 0.18s;
}
.voice.playing .bars i { background: var(--accent-deep); animation: bounceBar 0.9s ease-in-out infinite; }
.voice .bars i:nth-child(3n) { animation-delay: 0.12s; }
.voice .bars i:nth-child(3n + 1) { animation-delay: 0.26s; }
@keyframes bounceBar { 0%, 100% { height: 26%; } 50% { height: 100%; } }
.voice .dur { font-size: 0.78rem; color: var(--ink-soft); font-variant-numeric: tabular-nums; }

.media-file {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  border-radius: var(--r-md);
  background: #f7f4ff;
  border: 2px dashed #ddd3f2;
  font-size: 0.9rem;
}

.empty {
  text-align: center;
  padding: 44px 20px;
  color: var(--ink-faint);
  font-family: var(--font-hand-ui);
}
.empty svg { width: 120px; height: 120px; opacity: 0.9; margin-bottom: 6px; }
.empty p { margin: 4px 0; }

/* ---------------- timeline ---------------- */

.timeline { position: relative; padding-left: 34px; }
.timeline::before {
  content: '';
  position: absolute;
  left: 11px;
  top: 6px;
  bottom: 6px;
  width: 3px;
  border-radius: 3px;
  background-image: linear-gradient(180deg, var(--accent-soft) 60%, transparent 0);
  background-size: 3px 14px;
  background-repeat: repeat-y;
}

.tl-item { position: relative; margin-bottom: 20px; animation: noteIn 0.45s var(--ease-bounce) both; }
.tl-item::before {
  content: '';
  position: absolute;
  left: -29px;
  top: 22px;
  width: 15px;
  height: 15px;
  border-radius: 50% 50% 50% 4px;
  transform: rotate(45deg);
  background: #fff;
  border: 3px solid var(--accent);
  box-shadow: 0 0 0 4px rgba(255, 241, 244, 1);
}
.tl-item.anson::before { border-color: var(--mint); }
.tl-item.milestone::before { background: var(--butter); border-color: #e0ab34; }

.tl-date {
  font-family: var(--font-hand-ui);
  font-size: 0.86rem;
  color: var(--ink-faint);
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 4px;
}
.tl-photo img {
  width: 100%;
  max-height: 320px;
  object-fit: cover;
  border-radius: var(--r-md);
  border: 2px solid var(--line);
  margin-top: 8px;
  cursor: zoom-in;
}
.tl-cat { font-size: 0.8rem; padding: 1px 9px; border-radius: var(--r-pill); background: var(--butter-soft); color: #8a6a1e; }

/* ---------------- games ---------------- */

.points-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  border-radius: var(--r-pill);
  background: linear-gradient(140deg, #fff4d8, #ffe8b8);
  border: 2px solid #f3dda4;
  font-family: var(--font-hand);
  font-size: 1.2rem;
  color: #8a6a1e;
  box-shadow: var(--shadow-sm);
}
.points-badge .n { font-size: 1.5rem; }

.score-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border-radius: var(--r-md);
  background: #fff;
  border: 2px dashed var(--line);
  margin-bottom: 10px;
}
.score-row.lead { border-style: solid; border-color: #f3dda4; background: linear-gradient(180deg, #fffdf4, #fff); }
.score-row .pts { font-family: var(--font-hand); font-size: 1.5rem; color: var(--accent-deep); }
.score-row .bar { flex: 1; height: 10px; border-radius: 6px; background: #f6f1ee; overflow: hidden; }
.score-row .bar i { display: block; height: 100%; border-radius: 6px; background: linear-gradient(90deg, var(--accent-soft), var(--accent)); transition: width 0.7s var(--ease-bounce); }
.score-row.anson .bar i { background: linear-gradient(90deg, #9fdcc5, #57ab8d); }
.score-row.anson .pts { color: #3f8b72; }

.game-card { display: flex; flex-direction: column; gap: 10px; height: 100%; }
.game-card .thumb {
  height: 108px;
  border-radius: var(--r-md);
  display: grid;
  place-items: center;
  font-size: 2.6rem;
  background: linear-gradient(140deg, var(--accent-bg), #f4fbf8);
  border: 2px dashed var(--line);
}
.game-card.soon { opacity: 0.75; }

/* games page tabs */
.tabbar-seg {
  display: flex;
  gap: 8px;
  margin: 4px 0 16px;
  overflow-x: auto;
  padding-bottom: 4px;
}
.tabbar-seg .tab {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 11px 20px;
  border-radius: var(--r-pill);
  border: 2px solid var(--line);
  background: #fff;
  color: var(--ink-soft);
  font-family: var(--font-hand-ui);
  font-size: 1.02rem;
  cursor: pointer;
  white-space: nowrap;
  transition: transform 0.16s var(--ease-bounce), border-color 0.16s, color 0.16s, background 0.16s;
}
.tabbar-seg .tab:hover { transform: translateY(-2px); border-color: var(--accent-soft); }
.tabbar-seg .tab[aria-selected='true'] {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  box-shadow: var(--shadow-sm);
}
.tab-body { animation: pageIn 0.35s var(--ease-bounce) both; }

.attempt-log { display: flex; flex-direction: column; gap: 6px; }
.attempt-log .line {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.92rem;
  padding: 6px 12px;
  border-radius: var(--r-md);
  background: var(--accent-bg);
  border: 1.5px dashed var(--accent-line);
}
.attempt-log .line.ok { background: #f0fbf6; border-color: #bfe6d6; }

.big-answer {
  font-family: var(--font-hand);
  font-size: 2rem;
  color: var(--accent-deep);
  letter-spacing: 0.03em;
}

/* ---------------- profile / settings ---------------- */

.person-card { text-align: center; padding-top: 22px; display: flex; flex-direction: column; align-items: center; }
.person-card .where { display: inline-flex; align-items: center; gap: 2px; }
.person-card .person-chip.lg { margin: 4px auto 8px; }
.person-card .name { font-family: var(--font-hand); font-size: 1.6rem; }
.person-card .where { color: var(--ink-faint); font-size: 0.86rem; }
.person-card .stat-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; margin-top: 14px; }
.person-card .btn { flex: 0 1 auto; width: auto; }
.person-card .stat {
  padding: 9px 6px;
  border-radius: var(--r-md);
  background: var(--accent-bg);
  border: 1.5px dashed var(--line);
}
.person-card .stat .v { font-family: var(--font-hand); font-size: 1.35rem; color: var(--accent-deep); }
.person-card .stat .k { font-size: 0.74rem; color: var(--ink-faint); }

.setting-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 12px 2px;
  border-bottom: 1.5px dashed var(--line);
  flex-wrap: wrap;
}
.setting-row:last-child { border-bottom: none; }
.setting-row .info { min-width: 0; }
.setting-row .info .k { font-family: var(--font-hand-ui); font-size: 1.02rem; }
.setting-row .info .d { font-size: 0.82rem; color: var(--ink-faint); }

.switch {
  position: relative;
  width: 52px;
  height: 30px;
  border-radius: var(--r-pill);
  background: #efe7e3;
  border: 2px solid var(--line);
  cursor: pointer;
  transition: background 0.2s;
  flex: none;
}
.switch::after {
  content: '';
  position: absolute;
  top: 2px; left: 2px;
  width: 22px; height: 22px;
  border-radius: 50%;
  background: #fff;
  box-shadow: var(--shadow-sm);
  transition: transform 0.22s var(--ease-bounce);
}
.switch[aria-checked='true'] { background: var(--accent-soft); }
.switch[aria-checked='true']::after { transform: translateX(22px); background: var(--accent); }

/* ---------------- modal / toast ---------------- */

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 120;
  background: rgba(74, 58, 58, 0.32);
  backdrop-filter: blur(3px);
  display: grid;
  place-items: center;
  padding: 18px;
  animation: fadeIn 0.22s ease both;
  overflow-y: auto;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.modal {
  width: min(560px, 100%);
  max-height: 88vh;
  overflow-y: auto;
  background: var(--paper);
  border: 2px solid var(--line);
  border-radius: 26px 22px 28px 20px / 22px 28px 20px 26px;
  box-shadow: var(--shadow-lg);
  padding: 22px;
  animation: modalIn 0.34s var(--ease-bounce) both;
  margin: auto;
}
.modal.wide { width: min(880px, 100%); }
@keyframes modalIn { from { opacity: 0; transform: translateY(18px) scale(0.97); } to { opacity: 1; transform: none; } }

.modal-head { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.modal-head h3 { margin: 0; flex: 1; }
.modal-foot { display: flex; gap: 8px; justify-content: flex-end; margin-top: 16px; flex-wrap: wrap; }

.toast-wrap {
  position: fixed;
  left: 50%;
  bottom: 26px;
  transform: translateX(-50%);
  z-index: 300;
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: center;
  pointer-events: none;
}

.toast {
  padding: 10px 20px;
  border-radius: var(--r-pill);
  background: rgba(74, 58, 58, 0.93);
  color: #fff;
  font-family: var(--font-hand-ui);
  box-shadow: var(--shadow-lg);
  animation: toastIn 0.34s var(--ease-bounce) both;
  max-width: min(88vw, 460px);
  text-align: center;
}
.toast.love { background: linear-gradient(120deg, var(--accent), #dd5f80); }
.toast.good { background: linear-gradient(120deg, #6bbfa2, #4fa387); }
@keyframes toastIn { from { opacity: 0; transform: translateY(16px) scale(0.9); } to { opacity: 1; transform: none; } }
.toast.out { animation: toastOut 0.3s ease forwards; }
@keyframes toastOut { to { opacity: 0; transform: translateY(10px) scale(0.94); } }

/* lightbox */
.lightbox {
  position: fixed;
  inset: 0;
  z-index: 200;
  background: rgba(40, 30, 30, 0.86);
  display: grid;
  place-items: center;
  padding: 20px;
  cursor: zoom-out;
  animation: fadeIn 0.2s ease both;
}
.lightbox img, .lightbox video { max-width: 96vw; max-height: 90vh; border-radius: var(--r-md); box-shadow: var(--shadow-lg); }

/* floating hearts burst */
.burst { position: fixed; inset: 0; pointer-events: none; z-index: 250; overflow: hidden; }
.burst span { position: absolute; font-size: 26px; animation: burstUp 1.6s ease-out forwards; }
@keyframes burstUp {
  0% { opacity: 1; transform: translateY(0) scale(0.6) rotate(0deg); }
  100% { opacity: 0; transform: translateY(-180px) scale(1.25) rotate(24deg); }
}

@keyframes draw { to { stroke-dashoffset: 0; } }

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

/* ---------------- misc ---------------- */

.kbd {
  padding: 1px 7px;
  border-radius: 6px;
  background: #fff;
  border: 1.5px solid var(--line);
  font-size: 0.8rem;
  font-family: var(--font-hand-ui);
}

.list-plain { list-style: none; margin: 0; padding: 0; }

.divider { height: 2px; background-image: linear-gradient(90deg, var(--line) 50%, transparent 0); background-size: 12px 2px; margin: 18px 0; }

.scroll-x { overflow-x: auto; padding-bottom: 4px; }
.scroll-x::-webkit-scrollbar { height: 8px; }
.scroll-x::-webkit-scrollbar-thumb { background: var(--line-strong); border-radius: 6px; }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #ecdcd4; border-radius: 8px; border: 3px solid var(--cream); }
::-webkit-scrollbar-thumb:hover { background: #e0c8bd; }

/* ---------------- responsive ---------------- */

@media (max-width: 1000px) {
  .hero { grid-template-columns: 1fr; }
  .grid.side { grid-template-columns: 1fr; }
  .home-left, .home-right { gap: 14px; }
}

@media (max-width: 820px) {
  .nav { display: none; }
  .menu-toggle { display: inline-flex; }
  .grid.cols-2, .grid.cols-3 { grid-template-columns: 1fr; }

  .header-tools .pill-select .label-text { display: none; }
  .header-tools .pill-select { padding: 6px 9px; }

  /* Room for the fixed bottom tab bar, once, on the body. The pages carry
     their own padding, so drop theirs to avoid a huge empty gap. */
  body { padding-bottom: calc(72px + env(safe-area-inset-bottom, 0px)); }
  .page { padding-bottom: 18px; }

  .tabbar {
    display: flex;
    position: fixed;
    left: 0; right: 0; bottom: 0;
    z-index: 60;
    background: rgba(255, 253, 251, 0.95);
    backdrop-filter: blur(10px);
    border-top: 2px dashed var(--line);
    padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
    justify-content: space-around;
  }
  .tabbar a {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1px;
    flex: 1;
    min-width: 0;
    min-height: 54px;
    padding: 5px 2px;
    border-radius: var(--r-md);
    color: var(--ink-faint);
    font-size: 0.66rem;
    line-height: 1.15;
    font-family: var(--font-hand-ui);
    text-align: center;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .tabbar a span { max-width: 100%; overflow: hidden; text-overflow: ellipsis; }
  .tabbar a.active { color: var(--accent-deep); background: var(--accent-bg); }
  .tabbar svg, .tabbar img { width: 21px; height: 21px; }
  .tabbar a:hover { text-decoration: none; }
}

@media (max-width: 520px) {
  .wrap { width: min(100% - 1.4rem, var(--maxw)); }
  .card { padding: 15px; }
  .card.pad-lg { padding: 18px; }
  .page { padding: 16px 0 18px; }
  .note { padding: 12px; gap: 9px; }
  .note.reply { margin-left: 16px; }
  .timeline { padding-left: 26px; }
  .timeline::before { left: 7px; }
  .tl-item::before { left: -25px; }
  .btn { padding: 9px 15px; }
  .brand-name { font-size: 1.1rem; }
  .brand .logo { width: 32px; height: 32px; }
  .header-inner { gap: 6px; }
  .header-tools { gap: 5px; }
  .pill-select { padding: 5px 8px; font-size: 0.85rem; }
  .header-tools .pill-select .label-text { display: none; }
  .pill-select .face { width: 22px; height: 22px; }
  .clock-card { padding: 11px 12px; }
  .clock-card .time { font-size: 1.35rem; }
  .mood-chip { width: 33px; height: 33px; font-size: 1rem; }
  .voice { min-width: 0; }
}

/* ---------------- motion preferences ---------------- */

body.calm *, body.calm *::before, body.calm *::after {
  animation-duration: 0.001s !important;
  animation-iteration-count: 1 !important;
  transition-duration: 0.06s !important;
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001s !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.06s !important;
  }
}

@media print {
  .site-header, .tabbar, .composer, .note-tools { display: none !important; }
  body { background: #fff; }
}

