:root {
  --paper-deep: #E7E4D5;
  --paper: #F2F1E9;
  --card: #FFFFFF;
  --ink: #21231F;
  --ink-muted: #6B6D63;
  --hairline: #DAD7C8;
  --cobalt: #2B3EA8;
  --cobalt-dim: #24357F;
  --coral: #E2603A;
  --radius-page: 22px;
  --radius-bubble: 18px;
  --serif: 'Source Serif 4', Georgia, serif;
  --sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --doodle-bg: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='200' height='200'%3E%3Cg fill='none' stroke='%23212D1F' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round' opacity='0.07'%3E%3Cpath transform='translate(16,16) scale(0.9)' d='M12 21s-6.5-4.35-9.5-8.5C-0.9 8.9 1.6 4 6 4c2.4 0 4 1.6 6 4 2-2.4 3.6-4 6-4 4.4 0 6.9 4.9 3.5 8.5C18.5 16.65 12 21 12 21z'/%3E%3Cpath transform='translate(122,28) scale(0.8)' d='M12 2l1.5 6.5L20 10l-6.5 1.5L12 18l-1.5-6.5L4 10l6.5-1.5z'/%3E%3Cpath transform='translate(28,118) scale(0.85)' d='M9 18V5l12-2v13'/%3E%3Ccircle cx='38' cy='133' r='2.3'/%3E%3Ccircle cx='59' cy='129' r='2.3'/%3E%3Cpath transform='translate(142,142) scale(0.9)' d='M12 21s-6.5-4.35-9.5-8.5C-0.9 8.9 1.6 4 6 4c2.4 0 4 1.6 6 4 2-2.4 3.6-4 6-4 4.4 0 6.9 4.9 3.5 8.5C18.5 16.65 12 21 12 21z'/%3E%3Cpath transform='translate(162,64) scale(0.7)' d='M12 2l1.5 6.5L20 10l-6.5 1.5L12 18l-1.5-6.5L4 10l6.5-1.5z'/%3E%3C/g%3E%3C/svg%3E");
}

[data-theme="dark"] {
  --paper-deep: #0E0F0C;
  --paper: #191A15;
  --card: #232420;
  --ink: #EDEBE2;
  --ink-muted: #9A9C90;
  --hairline: #34362F;
  --cobalt: #6C8CFF;
  --cobalt-dim: #8AA3FF;
  --coral: #F0806A;
  --doodle-bg: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='200' height='200'%3E%3Cg fill='none' stroke='%23EDEBE2' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round' opacity='0.06'%3E%3Cpath transform='translate(16,16) scale(0.9)' d='M12 21s-6.5-4.35-9.5-8.5C-0.9 8.9 1.6 4 6 4c2.4 0 4 1.6 6 4 2-2.4 3.6-4 6-4 4.4 0 6.9 4.9 3.5 8.5C18.5 16.65 12 21 12 21z'/%3E%3Cpath transform='translate(122,28) scale(0.8)' d='M12 2l1.5 6.5L20 10l-6.5 1.5L12 18l-1.5-6.5L4 10l6.5-1.5z'/%3E%3Cpath transform='translate(28,118) scale(0.85)' d='M9 18V5l12-2v13'/%3E%3Ccircle cx='38' cy='133' r='2.3'/%3E%3Ccircle cx='59' cy='129' r='2.3'/%3E%3Cpath transform='translate(142,142) scale(0.9)' d='M12 21s-6.5-4.35-9.5-8.5C-0.9 8.9 1.6 4 6 4c2.4 0 4 1.6 6 4 2-2.4 3.6-4 6-4 4.4 0 6.9 4.9 3.5 8.5C18.5 16.65 12 21 12 21z'/%3E%3Cpath transform='translate(162,64) scale(0.7)' d='M12 2l1.5 6.5L20 10l-6.5 1.5L12 18l-1.5-6.5L4 10l6.5-1.5z'/%3E%3C/g%3E%3C/svg%3E");
}

* { box-sizing: border-box; }

[hidden] {
  display: none !important;
}

html, body {
  height: 100%;
  height: calc(var(--vh, 1vh) * 100);
}

body {
  margin: 0;
  background: var(--paper-deep);
  font-family: var(--sans);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
  touch-action: manipulation;
}

button {
  font-family: inherit;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

.composer-input,
.panel-body button {
  touch-action: manipulation;
}

.screen {
  height: 100vh;
  height: calc(var(--vh, 1vh) * 100);
  height: 100dvh;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.page {
  width: 100%;
  height: 100%;
  background: var(--paper);
  display: flex;
  flex-direction: column;
}

.icon {
  width: 19px;
  height: 19px;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex: 0 0 auto;
}

.icon--sm { width: 13px; height: 13px; }

.key .icon { width: 16px; height: 16px; stroke-width: 2; }

/* On larger screens with enough height, the app sits like a page on a
   desk. Short, wide screens (phone-frame-mounted picture frames, kiosk
   panels, etc.) stay full-bleed instead, regardless of width. */
@media (min-width: 560px) and (min-height: 700px) {
  .screen { padding: 32px 16px; }
  .page {
    max-width: 460px;
    height: min(100%, 820px);
    border-radius: var(--radius-page);
    box-shadow: 0 24px 60px -20px rgba(33, 35, 31, 0.35), 0 2px 0 rgba(255,255,255,0.4) inset;
    overflow: hidden;
  }
}

/* ---------- Login ---------- */

.page--login {
  align-items: center;
  justify-content: center;
  padding: 32px;
  gap: 8px;
  text-align: center;
}

.login-mark {
  font-family: var(--serif);
  font-style: italic;
  font-weight: 600;
  font-size: 44px;
  letter-spacing: -0.01em;
}

.login-sub {
  margin: 0 0 36px;
  color: var(--ink-muted);
  font-size: 14px;
}

.pin-dots {
  display: flex;
  gap: 14px;
  margin-bottom: 10px;
}

.dot {
  width: 13px;
  height: 13px;
  border-radius: 50%;
  border: 1.5px solid var(--ink-muted);
  transition: background 0.15s ease, border-color 0.15s ease, transform 0.15s ease;
}

.dot.is-filled {
  background: var(--cobalt);
  border-color: var(--cobalt);
  transform: scale(1.08);
}

.dot.is-error {
  background: var(--coral);
  border-color: var(--coral);
}

.login-error {
  min-height: 20px;
  color: var(--coral);
  font-size: 13px;
  margin: 8px 0 26px;
}

.keypad {
  display: grid;
  grid-template-columns: repeat(3, clamp(52px, 15vw, 68px));
  gap: clamp(10px, 3vw, 14px);
}

.key {
  width: clamp(52px, 15vw, 68px);
  height: clamp(52px, 15vw, 68px);
  border-radius: 50%;
  border: 1px solid var(--hairline);
  background: var(--card);
  font-size: clamp(17px, 4vw, 20px);
  color: var(--ink);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.08s ease, background 0.15s ease;
}

.key:active {
  transform: scale(0.93);
  background: var(--paper-deep);
}

.key--ghost {
  background: transparent;
  border-color: transparent;
  color: var(--ink-muted);
  font-size: 12px;
}

/* ---------- Chat ---------- */

.page--chat {
  height: 100%;
}

.chat-header {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1px solid var(--hairline);
  gap: 10px;
}

.chat-header__id {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.chat-header__title {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.chat-header__for {
  font-style: italic;
  color: var(--ink-muted);
  font-size: 12px;
  font-family: var(--serif);
}

.chat-header__name {
  font-size: 18px;
  font-weight: 600;
  font-family: var(--serif);
  line-height: 1.2;
}

.chat-header__status {
  font-size: 12px;
  color: var(--ink-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chat-header__actions {
  display: flex;
  align-items: center;
  gap: 2px;
  flex: 0 0 auto;
}

.icon-btn.is-active {
  color: var(--cobalt);
  background: var(--paper-deep);
}

.icon-btn {
  border: none;
  background: transparent;
  font-size: clamp(17px, 4vw, 19px);
  color: var(--ink-muted);
  width: clamp(34px, 9vw, 38px);
  height: clamp(34px, 9vw, 38px);
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  flex: 0 0 auto;
  transition: background 0.15s ease, color 0.15s ease;
}

.custom-row {
  display: flex;
  gap: 8px;
  margin-top: 8px;
}

.custom-row input {
  flex: 1;
  border: 1px solid var(--hairline);
  background: var(--card);
  color: var(--ink);
  border-radius: 999px;
  padding: 8px 14px;
  font-size: 13px;
  font-family: inherit;
}

.icon-btn--ping {
  color: var(--coral);
}

/* ---------- Love heart ping toggle (adapted) ---------- */

.icon--hangup {
  transform: rotate(135deg);
}

.love {
  width: 38px;
  height: 38px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  margin-right: 10px;
}

.love-heart:before, .love #pingSwitch {
  display: none;
}

.love-heart, .love-heart::after {
  border-color: var(--ink-muted);
  border: 1px solid;
  border-top-left-radius: 100px;
  border-top-right-radius: 100px;
  width: 10px;
  height: 8px;
  border-bottom: 0;
}

.love-heart {
  box-sizing: border-box;
  position: relative;
  top: -3px;
  left: -2px;
  transform: rotate(-45deg) scale(1.3);
  display: block;
  cursor: pointer;
}

#pingSwitch:checked + .love-heart,
#pingSwitch:checked + .love-heart::after,
#pingSwitch:checked + .love-heart .bottom {
  border-color: var(--coral);
  box-shadow: inset 6px -5px 0px 2px color-mix(in srgb, var(--coral) 65%, white);
}

.love-heart::after, .love-heart .bottom {
  content: "";
  display: block;
  box-sizing: border-box;
  position: absolute;
  border-color: var(--ink-muted);
}

.love-heart::after {
  right: -9px;
  transform: rotate(90deg);
  top: 7px;
}

.love-heart .bottom {
  width: 11px;
  height: 11px;
  border-left: 1px solid;
  border-bottom: 1px solid;
  border-color: var(--ink-muted);
  left: -1px;
  top: 5px;
  border-radius: 0px 0px 0px 5px;
}

.round {
  position: absolute;
  z-index: 1;
  width: 8px;
  height: 8px;
  background: var(--card);
  box-shadow: rgba(0, 0, 0, 0.24) 0px 0px 4px 0px;
  border-radius: 100%;
  left: 0px;
  bottom: -1px;
  transition: all 0.5s ease;
  animation: check-animation2 0.5s forwards;
}

#pingSwitch:checked + label .round {
  transform: translate(0px, 0px);
  animation: check-animation 0.5s forwards;
  background-color: var(--card);
}

@keyframes check-animation {
  0% { transform: translate(0px, 0px); }
  50% { transform: translate(0px, 7px); }
  100% { transform: translate(7px, 7px); }
}

@keyframes check-animation2 {
  0% { transform: translate(7px, 7px); }
  50% { transform: translate(0px, 7px); }
  100% { transform: translate(0px, 0px); }
}

.pill-btn--danger {
  background: var(--coral);
}

.icon-btn:hover { background: var(--paper-deep); color: var(--ink); }

/* ---------- Avatars ---------- */

.avatar {
  position: relative;
  flex: 0 0 auto;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: none;
  padding: 0;
  overflow: hidden;
  background: var(--cobalt);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
}

.avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.avatar__fallback {
  font-family: var(--serif);
  font-style: italic;
  font-size: 16px;
}

.avatar--you {
  width: 72px;
  height: 72px;
}

.avatar--you .avatar__fallback { font-size: 26px; }

.avatar__edit {
  position: absolute;
  inset: auto 0 0 0;
  height: 24px;
  background: rgba(0,0,0,0.45);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
}

.thread {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  padding: 18px 16px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  scroll-behavior: smooth;
  background-image: var(--doodle-bg);
  background-repeat: repeat;
  background-size: 200px 200px;
}

.thread-empty {
  margin: auto;
  color: var(--ink-muted);
  font-size: 14px;
  font-style: italic;
  font-family: var(--serif);
}

.bubble-row {
  display: flex;
  flex-shrink: 0;
  margin: 5px 0;
  max-width: 100%;
}

.bubble-row.is-you { justify-content: flex-end; }
.bubble-row.is-them { justify-content: flex-start; }

.bubble {
  max-width: 76%;
  padding: 9px 13px;
  border-radius: var(--radius-bubble);
  font-size: 15px;
  line-height: 1.42;
  word-wrap: break-word;
  white-space: pre-wrap;
  position: relative;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}

.is-you .bubble {
  background: var(--cobalt);
  color: #F5F5F2;
  border-bottom-right-radius: 5px;
}

.is-them .bubble {
  background: var(--card);
  color: var(--ink);
  border: 1px solid var(--hairline);
  border-bottom-left-radius: 5px;
}

.bubble-time {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 3px;
  font-size: 10.5px;
  margin-top: 3px;
  opacity: 0.65;
}

.tick {
  display: inline-flex;
  font-size: 12px;
  line-height: 1;
}

.tick--read { color: var(--tick-read, #8FD6C6); opacity: 1; }

.typing-row .bubble {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 12px 14px;
}

.typing-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--ink-muted);
  animation: typing-bounce 1.2s infinite ease-in-out;
}

.typing-dot:nth-child(2) { animation-delay: 0.15s; }
.typing-dot:nth-child(3) { animation-delay: 0.3s; }

@keyframes typing-bounce {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.5; }
  30% { transform: translateY(-4px); opacity: 1; }
}

.bubble--image { padding: 4px; }
.bubble--image img {
  display: block;
  max-width: 100%;
  max-height: 320px;
  border-radius: 13px;
  background: var(--paper-deep);
}
.bubble--image .bubble-time {
  padding: 4px 6px 0;
}

.bubble--video { padding: 4px; }
.bubble--video video {
  display: block;
  max-width: 100%;
  max-height: 320px;
  border-radius: 13px;
  background: var(--paper-deep);
}
.bubble--video .bubble-time {
  padding: 4px 6px 0;
}

.bubble--sticker {
  background: transparent !important;
  border: none !important;
  padding: 0;
  font-size: 56px;
  line-height: 1;
}

.bubble--voice {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 180px;
}

.bubble--voice audio {
  height: 32px;
  max-width: 190px;
}

.is-you .bubble--voice audio { filter: invert(1) hue-rotate(180deg) brightness(1.15); }

.media-loading {
  font-size: 13px;
  color: var(--ink-muted);
  font-style: italic;
  padding: 6px 2px;
}

.bubble-row.is-ping {
  justify-content: center;
  margin: 12px 0;
}

.bubble--ping {
  background: linear-gradient(135deg, var(--coral), #F0A08A);
  color: #fff;
  font-weight: 600;
  font-size: 16px;
  padding: 11px 20px;
  border-radius: 999px;
  max-width: 90%;
  animation: ping-pop 0.35s ease;
}

@keyframes ping-pop {
  0% { transform: scale(0.7); opacity: 0; }
  60% { transform: scale(1.08); opacity: 1; }
  100% { transform: scale(1); }
}

.bubble--deleted {
  background: transparent !important;
  border: 1px dashed var(--hairline) !important;
  color: var(--ink-muted);
  font-style: italic;
  font-size: 13px;
}

.heart-shower {
  position: fixed;
  inset: 0;
  z-index: 200;
  pointer-events: none;
  overflow: hidden;
}

.heart-shower span {
  position: absolute;
  top: -40px;
  will-change: transform, opacity;
  animation-name: heart-fall;
  animation-timing-function: ease-in;
  animation-fill-mode: forwards;
}

@keyframes heart-fall {
  0% { transform: translateY(0) rotate(0deg); opacity: 0; }
  10% { opacity: 1; }
  90% { opacity: 1; }
  100% { transform: translateY(112vh) rotate(30deg); opacity: 0; }
}

/* ---------- Kawaii hue sliders (adapted) ---------- */

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

.hue-label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 12px;
  color: var(--ink-muted);
}

[type="range"].kawaii {
  --base: #fe8ce4;
  --light: color-mix(in srgb, var(--base) 60%, #fff);
  --lighter: color-mix(in srgb, var(--base) 30%, #fff);
  --dark: color-mix(in srgb, var(--base) 95%, #000);
  --transparent: color-mix(in srgb, var(--base) 0%, transparent);
  appearance: none;
  -webkit-appearance: none;
  font-size: 1em;
  width: 100%;
  height: 2em;
  border: 0.4em solid var(--card);
  border-radius: 2em;
  box-shadow: 0 0 1em #0001, 0 0.25em 0.5em #0001;
  overflow: hidden;
}

[type="range"].kawaii::-webkit-slider-runnable-track {
  background:
    radial-gradient(circle at 0.75em 0.6em, var(--light) calc(0.2em - 1px), transparent 0.2em),
    radial-gradient(circle at 1.25em 0.6em, var(--light) calc(0.2em - 1px), transparent 0.2em),
    radial-gradient(circle at 5em 0.6em, var(--light) calc(0.2em - 1px), transparent 0.2em),
    linear-gradient(var(--light) 0 0) 1.25em 0.4em / 3.75em calc(0.4em - 0.5px) no-repeat,
    linear-gradient(90deg, var(--base), var(--transparent) 1em),
    linear-gradient(transparent 70%, var(--dark) 80%),
    var(--base);
  border-radius: 2em;
  height: 100%;
  overflow: hidden;
}

[type="range"].kawaii::-webkit-slider-thumb {
  appearance: none;
  -webkit-appearance: none;
  height: 2.6em;
  width: 2.6em;
  color: var(--lighter);
  background:
    radial-gradient(circle at 0.98em 0.78em, var(--light) calc(0.26em - 1px), transparent 0.26em),
    linear-gradient(90deg, transparent 0.98em, var(--base) 0) 0 0 / 100% 50% no-repeat;
  border-radius: 50%;
  box-shadow: inset -0.65em 0 0.65em -0.33em var(--base);
}

[type="range"].kawaii::-moz-range-track {
  background:
    radial-gradient(circle at 0.75em 30%, var(--light) calc(0.2em - 1px), transparent 0.2em),
    radial-gradient(circle at 1.5em 30%, var(--light) calc(0.2em - 1px), transparent 0.2em),
    radial-gradient(circle at 5.5em 30%, var(--light) calc(0.2em - 1px), transparent 0.2em),
    linear-gradient(var(--light) 0 0) 1.5em calc(15% + 0.18em) / 4em calc(0.4em - 0.5px) no-repeat,
    linear-gradient(90deg, var(--base), var(--transparent) 1em),
    linear-gradient(var(--transparent) 70%, var(--dark) 80%),
    var(--base);
  border-radius: 2em;
  height: 100%;
  overflow: hidden;
}

[type="range"].kawaii::-moz-range-thumb {
  appearance: none;
  height: 2.6em;
  width: 2.6em;
  border: 0;
  color: var(--lighter);
  background:
    radial-gradient(circle at 0.98em 0.78em, var(--light) calc(0.26em - 1px), transparent 0.26em),
    linear-gradient(90deg, var(--transparent) 0.98em, var(--base) 0) 0 0 / 100% 50% no-repeat;
  border-radius: 50% 0 50% 50% 0;
  box-shadow: inset -0.65em 0 0.65em -0.33em var(--base);
}

/* ---------- Toast ---------- */

.toast {
  position: absolute;
  left: 50%;
  bottom: 90px;
  transform: translateX(-50%);
  z-index: 40;
  background: var(--ink);
  color: var(--paper);
  padding: 10px 16px;
  border-radius: 999px;
  font-size: 13px;
  max-width: 85%;
  text-align: center;
  box-shadow: 0 10px 30px rgba(0,0,0,0.25);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.toast.is-visible {
  opacity: 1;
  transform: translateX(-50%) translateY(-4px);
}

/* ---------- Calls ---------- */

.call-overlay {
  position: absolute;
  inset: 0;
  z-index: 20;
  background: var(--paper);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 18px;
}

.call-overlay__label {
  font-family: var(--serif);
  font-style: italic;
  font-size: 22px;
  margin: 0;
}

.call-overlay__ring {
  width: 84px;
  height: 84px;
  border-radius: 50%;
  border: 2px solid var(--cobalt);
  opacity: 0.5;
  animation: ring-pulse 1.6s ease-out infinite;
}

@keyframes ring-pulse {
  0% { transform: scale(0.7); opacity: 0.7; }
  100% { transform: scale(1.4); opacity: 0; }
}

.call-overlay__actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 14px;
  margin-top: 8px;
}

.pill-btn--accept {
  background: #2E9E6B;
}

.page--chat { position: relative; }

.in-call {
  position: absolute;
  inset: 0;
  z-index: 25;
  background: #12130F;
  display: flex;
  align-items: center;
  justify-content: center;
}

.in-call__remote {
  width: 100%;
  height: 100%;
  object-fit: cover;
  background: #12130F;
}

.in-call__local {
  position: absolute;
  bottom: 90px;
  right: 14px;
  width: 96px;
  height: 128px;
  object-fit: cover;
  border-radius: 12px;
  border: 2px solid rgba(255,255,255,0.35);
  background: #1c1e17;
}

.in-call__bar {
  position: absolute;
  bottom: 18px;
  left: 0;
  right: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 18px;
}

.icon-btn--call {
  background: rgba(255,255,255,0.14);
  color: #fff;
  width: 50px;
  height: 50px;
  font-size: 20px;
}

.icon-btn--call.is-off {
  background: rgba(226, 96, 58, 0.85);
}

.icon-btn--hangup {
  background: var(--coral);
  color: #fff;
  width: 56px;
  height: 56px;
  font-size: 22px;
}

/* ---------- Sheets (menu / games) ---------- */

.sheet-backdrop {
  position: absolute;
  inset: 0;
  z-index: 30;
  background: rgba(20, 20, 16, 0.4);
  display: flex;
  align-items: flex-end;
}

.sheet {
  position: relative;
  width: 100%;
  max-height: 86%;
  background: var(--paper);
  border-radius: 20px 20px 0 0;
  padding: 10px 20px 24px;
  overflow-y: auto;
  box-shadow: 0 -12px 40px rgba(0,0,0,0.25);
}

.sheet__handle {
  width: 36px;
  height: 4px;
  border-radius: 4px;
  background: var(--hairline);
  margin: 6px auto 14px;
}

.sheet__close {
  position: absolute;
  top: 10px;
  right: 12px;
}

.sheet__section {
  margin-bottom: 22px;
}

.sheet__section--profile {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.sheet__you-name {
  font-family: var(--serif);
  font-style: italic;
  font-size: 16px;
  margin: 0;
  color: var(--ink-muted);
}

.sheet__heading {
  font-family: var(--serif);
  font-style: italic;
  font-weight: 600;
  font-size: 15px;
  margin: 0 0 10px;
}

.pill-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.pill-choice {
  border: 1px solid var(--hairline);
  background: var(--card);
  color: var(--ink);
  border-radius: 999px;
  padding: 7px 13px;
  font-size: 13px;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}

.pill-choice.is-selected {
  background: var(--cobalt);
  border-color: var(--cobalt);
  color: #fff;
}

.sheet__section--rows {
  border-top: 1px solid var(--hairline);
  padding-top: 8px;
  margin-bottom: 4px;
}

.sheet__row {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 12px;
  border: none;
  background: transparent;
  padding: 13px 4px;
  font-size: 15px;
  color: var(--ink);
  text-align: left;
}

.sheet__row--danger {
  color: var(--coral);
}

/* ---------- Cycle tracker ---------- */

.cycle-nav {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  margin-bottom: 8px;
  font-size: 14px;
  font-weight: 600;
}

.cycle-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
  text-align: center;
  font-size: 12px;
}

.cycle-grid .cycle-dow {
  color: var(--ink-muted);
  font-size: 10px;
  padding-bottom: 4px;
}

.cycle-day {
  aspect-ratio: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
}

.cycle-day.is-period {
  background: var(--coral);
  color: #fff;
  font-weight: 600;
}

.cycle-day.is-predicted {
  background: color-mix(in srgb, var(--coral) 30%, transparent);
  color: var(--ink);
}

.cycle-controls {
  margin-top: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.cycle-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 12px;
  color: var(--ink-muted);
}

.cycle-field input {
  border: 1px solid var(--hairline);
  background: var(--card);
  color: var(--ink);
  border-radius: 10px;
  padding: 8px 10px;
  font-size: 14px;
  font-family: inherit;
}

/* ---------- Games ---------- */

.ttt-board {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  max-width: 240px;
  margin: 16px auto 0;
}

.ttt-cell {
  aspect-ratio: 1;
  border: 1px solid var(--hairline);
  background: var(--card);
  border-radius: 12px;
  font-size: 28px;
  font-family: var(--serif);
  color: var(--cobalt);
  display: flex;
  align-items: center;
  justify-content: center;
}

.game-status {
  text-align: center;
  font-size: 14px;
  color: var(--ink-muted);
  margin-top: 14px;
}

.rps-choices {
  display: flex;
  justify-content: center;
  gap: 14px;
  margin-top: 16px;
}

.rps-choice {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  border: 1px solid var(--hairline);
  background: var(--card);
  font-size: 28px;
}

.rps-choice.is-picked {
  border-color: var(--cobalt);
  background: color-mix(in srgb, var(--cobalt) 12%, var(--card));
}

.rps-score {
  text-align: center;
  font-size: 13px;
  color: var(--ink-muted);
  margin-top: 10px;
}

/* ---------- Gallery & lightbox ---------- */

.gallery-empty {
  color: var(--ink-muted);
  font-size: 14px;
  font-style: italic;
  font-family: var(--serif);
  text-align: center;
  padding: 20px 0;
}

.gallery-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
}

.gallery-grid button {
  aspect-ratio: 1;
  border: none;
  padding: 0;
  border-radius: 10px;
  overflow: hidden;
  background: var(--card);
  position: relative;
}

.gallery-grid img,
.gallery-grid video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.gallery-grid button.is-video::after {
  content: '▶';
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 18px;
  background: rgba(0,0,0,0.15);
}

.lightbox {
  position: fixed;
  inset: 0;
  z-index: 60;
  background: rgba(10, 10, 8, 0.92);
  display: flex;
  align-items: center;
  justify-content: center;
}

.lightbox img,
.lightbox video {
  max-width: 92%;
  max-height: 78%;
  object-fit: contain;
  border-radius: 6px;
}

.lightbox__close {
  position: absolute;
  top: 16px;
  right: 16px;
  color: #fff;
  background: rgba(255,255,255,0.15);
}

.lightbox__actions {
  position: absolute;
  bottom: 26px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 10px;
}

.lightbox__save,
.lightbox__sticker {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.lightbox__sticker {
  background: var(--card);
  color: var(--ink);
}

/* ---------- Reply ---------- */

.reply-bar {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 16px;
  border-top: 1px solid var(--hairline);
  background: var(--card);
  color: var(--ink-muted);
}

.reply-bar__text {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  font-size: 12px;
}

.reply-bar__sender {
  font-weight: 600;
  color: var(--cobalt);
}

.reply-bar__preview {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.reply-quote {
  border-left: 3px solid var(--cobalt);
  background: rgba(0,0,0,0.05);
  border-radius: 6px;
  padding: 4px 8px;
  margin-bottom: 5px;
  font-size: 12px;
  line-height: 1.3;
}

.is-you .reply-quote {
  border-left-color: rgba(255,255,255,0.7);
  background: rgba(255,255,255,0.12);
}

.reply-quote__sender {
  display: block;
  font-weight: 600;
  opacity: 0.9;
}

.reply-quote__preview {
  display: block;
  opacity: 0.75;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.hangman-word {
  text-align: center;
  font-size: 26px;
  letter-spacing: 6px;
  font-family: var(--serif);
  margin: 14px 0 10px;
}

.hangman-stage {
  text-align: center;
  font-size: 30px;
  margin-bottom: 6px;
}

.hangman-keyboard {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 5px;
  margin-top: 10px;
}

.hangman-keyboard button {
  border: 1px solid var(--hairline);
  background: var(--card);
  color: var(--ink);
  border-radius: 8px;
  padding: 7px 0;
  font-size: 13px;
  font-weight: 600;
}

.hangman-keyboard button:disabled {
  opacity: 0.3;
}

.mahjong-board {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
  max-width: 280px;
  margin: 16px auto 0;
}

.mahjong-tile {
  aspect-ratio: 1;
  border: 1px solid var(--hairline);
  background: var(--card);
  border-radius: 10px;
  font-size: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.mahjong-tile.is-closed {
  background: var(--cobalt);
  color: var(--cobalt);
}

.mahjong-tile.is-matched {
  opacity: 0.55;
}

/* ---------- Record bar ---------- */

.record-bar {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  border-top: 1px solid var(--hairline);
  background: var(--card);
}

.record-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--coral);
  animation: pulse 1.1s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.25; }
}

.record-time {
  font-variant-numeric: tabular-nums;
  font-size: 14px;
  font-weight: 600;
}

.record-hint {
  color: var(--ink-muted);
  font-size: 13px;
  flex: 1;
}

.pill-btn {
  border: none;
  border-radius: 999px;
  padding: 8px 16px;
  font-size: 13px;
  font-weight: 600;
  background: var(--cobalt);
  color: #fff;
}

.pill-btn--ghost {
  background: transparent;
  color: var(--ink-muted);
}

/* ---------- Emoji / sticker panel ---------- */

.panel {
  flex: 0 0 auto;
  border-top: 1px solid var(--hairline);
  background: var(--card);
  height: 220px;
  display: flex;
  flex-direction: column;
}

.panel-tabs {
  display: flex;
  gap: 4px;
  padding: 10px 14px 0;
}

.panel-tab {
  border: none;
  background: transparent;
  font-family: var(--serif);
  font-style: italic;
  font-size: 14px;
  color: var(--ink-muted);
  padding: 6px 10px 10px;
  border-bottom: 2px solid transparent;
}

.panel-tab.is-active {
  color: var(--ink);
  border-bottom-color: var(--cobalt);
}

.panel-body {
  flex: 1;
  overflow-y: auto;
  padding: 8px 10px 14px;
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 2px;
  align-content: start;
}

.panel-body button {
  border: none;
  background: transparent;
  font-size: 22px;
  padding: 6px 0;
  border-radius: 8px;
}

.panel-body button:hover { background: var(--paper-deep); }

.panel-body.stickers button { font-size: 30px; }

.sticker-thumb {
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  border-radius: 8px;
  display: block;
}

.bubble--sticker.bubble--sticker-image {
  padding: 2px;
}

.bubble--sticker-image img {
  width: 120px;
  height: 120px;
  object-fit: cover;
  border-radius: 14px;
  display: block;
}

/* ---------- Composer ---------- */

.composer {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 10px 10px calc(10px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--hairline);
  background: var(--paper);
}

.composer-input {
  flex: 1;
  border: 1px solid var(--hairline);
  background: var(--card);
  border-radius: 20px;
  padding: 10px 15px;
  font-size: 15px;
  font-family: var(--sans);
  color: var(--ink);
  min-width: 0;
}

.composer-input:focus {
  outline: none;
  border-color: var(--cobalt);
}

.icon-btn--send {
  background: var(--cobalt);
  color: #fff;
  font-size: 16px;
}

.icon-btn--send:hover { background: var(--cobalt-dim); color: #fff; }

.icon-btn--recording {
  color: var(--coral);
}

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

::-webkit-scrollbar { width: 8px; }
::-webkit-scrollbar-thumb { background: var(--hairline); border-radius: 8px; }

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}

button, input, a {
  outline: none;
}

button:focus-visible,
input:focus-visible {
  outline: 2px solid var(--cobalt);
  outline-offset: 2px;
}

:focus-visible {
  outline: 2px solid var(--cobalt);
  outline-offset: 2px;
}
