@font-face {
  font-family: "Inter";
  font-style: normal;
  font-display: swap;
  font-weight: 100 900;
  src: url(/fonts/inter-latin-ext.woff2) format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: "Inter";
  font-style: normal;
  font-display: swap;
  font-weight: 100 900;
  src: url(/fonts/inter-latin.woff2) format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

:root {
  --bg: #ffffff;
  --surface: #f0f0f2;
  --surface-2: #e6e6e9;
  --text: #0b0b0c;
  --muted: #6b6b73;
  --faint: #a2a2aa;
  --line: rgba(0, 0, 0, 0.07);
  --mine: #0b0b0c;
  --mine-text: #ffffff;
  --glass: rgba(255, 255, 255, 0.74);
  --field: #ffffff;
  --green: #30a46c;
  --danger: #e5484d;
  --overlay: rgba(10, 10, 12, 0.32);
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.08), 0 1px 3px rgba(0, 0, 0, 0.06);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);

  /* Springs (computed from real spring physics, with cubic-bezier fallbacks). */
  --spring: cubic-bezier(0.2, 0.9, 0.3, 1.03);
  --spring-bouncy: cubic-bezier(0.25, 1.3, 0.4, 1);
  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
  color-scheme: light;
}
@supports (transition-timing-function: linear(0, 1)) {
  :root {
    --spring: linear(0, 0.0291, 0.0975, 0.201, 0.3059, 0.413, 0.5164, 0.6121, 0.7064, 0.7794, 0.8409, 0.8914, 0.9318, 0.9661, 0.9889, 1.0052, 1.0162, 1.0231, 1.0267, 1.0278, 1.0271, 1.0252, 1.0227, 1.0198, 1.0165, 1.0136, 1.0109, 1.0085, 1.0065, 1.0045, 1.0031, 1.002, 1.0011, 1.0004, 0.9999, 0.9996, 1);
    --spring-bouncy: linear(0, 0.0462, 0.1545, 0.2849, 0.4363, 0.5832, 0.7154, 0.8268, 0.9098, 0.9775, 1.0246, 1.0541, 1.0694, 1.074, 1.0715, 1.064, 1.0538, 1.0427, 1.0317, 1.0225, 1.014, 1.0072, 1.002, 0.9984, 0.9963, 0.995, 0.9945, 0.9947, 0.9952, 0.9959, 0.9967, 0.9975, 0.9983, 0.9989, 0.9994, 0.9998, 1);
  }
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0b0b0c;
    --surface: #1d1d20;
    --surface-2: #28282c;
    --text: #f3f3f4;
    --muted: #9b9ba4;
    --faint: #66666e;
    --line: rgba(255, 255, 255, 0.08);
    --mine: #f3f3f4;
    --mine-text: #0b0b0c;
    --glass: rgba(11, 11, 12, 0.72);
    --field: #161618;
    --overlay: rgba(0, 0, 0, 0.6);
    --shadow: 0 10px 30px rgba(0, 0, 0, 0.5), 0 0 0 1px rgba(255, 255, 255, 0.06);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", "Malgun Gothic", "Noto Sans KR",
    "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans SC", "Segoe UI", Roboto, sans-serif,
    "Apple Color Emoji", "Segoe UI Emoji", "Noto Color Emoji";
  font-size: 15px;
  line-height: 1.4;
  font-feature-settings: "cv11", "ss03";
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  -webkit-tap-highlight-color: transparent;
  overflow: hidden;
  overscroll-behavior: none;
}

button, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; padding: 0; }
button:disabled { cursor: default; }
svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: none; }
a { color: inherit; }
:focus-visible { outline: 2px solid var(--text); outline-offset: 2px; }
.defs { position: absolute; width: 0; height: 0; overflow: hidden; }

.glass {
  background: var(--glass);
  -webkit-backdrop-filter: saturate(180%) blur(22px);
  backdrop-filter: saturate(180%) blur(22px);
}

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

.app { position: fixed; inset: 0; height: 100dvh; display: flex; }
.side, .chat { height: 100%; min-width: 0; display: flex; flex-direction: column; position: relative; }
.side { width: 100%; background: var(--bg); }
.chat { flex: 1; background: var(--bg); }

@media (max-width: 859px) {
  .app.in-chat .side { display: none; }
  .app:not(.in-chat) .chat { display: none; }
  /* During the push/pop slide both screens are on stage, the chat on top. */
  .app.transit .side, .app.transit .chat { display: flex !important; }
  .app.transit .chat { position: absolute; inset: 0; z-index: 5; box-shadow: -12px 0 40px rgba(0, 0, 0, 0.12); }
}
@media (min-width: 860px) {
  .side { width: 340px; flex: none; border-right: 1px solid var(--line); }
  .back-btn { display: none !important; }
}

.bar {
  flex: none;
  height: calc(62px + var(--safe-t));
  padding: var(--safe-t) 10px 0 16px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.brand { margin: 0; flex: 1; font-size: 30px; font-weight: 800; letter-spacing: -0.055em; }

.icon-btn {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: inline-grid;
  place-items: center;
  color: var(--text);
  transition: background-color 0.15s, transform 0.4s var(--spring);
}
.icon-btn:hover { background: var(--surface); }
.icon-btn:active { transform: scale(0.88); }

/* ---------- avatars ---------- */

.avatar {
  --c: #8b8b94;
  --size: 28px;
  position: relative;
  width: var(--size);
  height: var(--size);
  border-radius: 50%;
  flex: none;
  overflow: hidden;
  display: grid;
  place-items: center;
  background: var(--c);
  color: #fff;
  font-weight: 650;
  font-size: calc(var(--size) * 0.42);
  text-transform: uppercase;
}
.avatar img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.av-xs { --size: 16px; }
.av-sm { --size: 28px; }
.av-md { --size: 34px; }
.av-lg { --size: 50px; }
.av-xl { --size: 104px; }

.faces { display: inline-flex; align-items: center; }
.faces .avatar { box-shadow: 0 0 0 2px var(--bg); }
.faces .avatar + .avatar { margin-left: calc(var(--size) * -0.34); }

.duo { position: relative; width: 50px; height: 50px; flex: none; }
.duo .avatar { position: absolute; --size: 35px; }
.duo .avatar:first-child { top: 0; left: 0; }
.duo .avatar:last-child { right: 0; bottom: 0; box-shadow: 0 0 0 2.5px var(--bg); }
.chat-item:hover .duo .avatar:last-child, .chat-item.active .duo .avatar:last-child { box-shadow: 0 0 0 2.5px var(--surface); }

/* ---------- sidebar ---------- */

.chat-list { flex: 1; overflow-y: auto; padding: 2px 8px 8px; }

.chat-item {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px;
  border-radius: 16px;
  text-align: left;
  transition: background-color 0.15s, transform 0.4s var(--spring);
}
.chat-item:hover, .chat-item.active { background: var(--surface); }
.chat-item:active { transform: scale(0.985); }
.ci-main { flex: 1; min-width: 0; }
.ci-top { display: flex; align-items: baseline; gap: 8px; }
.ci-name { flex: 1; font-weight: 600; font-size: 15.5px; letter-spacing: -0.01em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ci-time { font-size: 12.5px; color: var(--faint); flex: none; }
.ci-bottom { display: flex; align-items: center; gap: 8px; margin-top: 2px; }
.ci-last { flex: 1; font-size: 14px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ci-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--text); flex: none; animation: pop 0.5s var(--spring-bouncy); }
.chat-item.unread .ci-last { color: var(--text); font-weight: 500; }
.chat-item.unread .ci-time { color: var(--text); }

.home-empty, .chat-blank {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 24px;
  gap: 4px;
  animation: rise 0.6s var(--ease-out) both;
}
.home-empty-mark { font-size: 72px; font-weight: 800; letter-spacing: -0.065em; line-height: 1; margin-bottom: 18px; }
.home-empty p, .chat-blank p { margin: 0 0 26px; color: var(--muted); font-size: 15px; line-height: 1.5; }
.chat-blank .home-empty-mark { color: var(--surface-2); }
.home-empty .btn { width: auto; padding: 0 30px; }

.me-bar { flex: none; padding: 8px 8px calc(8px + var(--safe-b)); }
.me-btn { width: 100%; display: flex; align-items: center; gap: 12px; padding: 8px 10px; border-radius: 16px; text-align: left; transition: background-color 0.15s; }
.me-btn:hover { background: var(--surface); }
.me-text { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.me-name { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.me-hint { font-size: 12.5px; color: var(--muted); }
.chev { width: 18px; height: 18px; color: var(--faint); }

/* ---------- chat ---------- */

.chat-inner { position: relative; height: 100%; overflow: hidden; }

.chat-bar { position: absolute; top: 0; left: 0; right: 0; z-index: 6; padding-left: 6px; box-shadow: 0 1px 0 var(--line); }
@media (min-width: 860px) { .chat-bar { padding-left: 12px; } }

.chat-title { flex: 1; min-width: 0; display: flex; align-items: center; gap: 10px; padding: 4px 6px; border-radius: 14px; text-align: left; transition: background-color 0.15s; }
.chat-title:hover { background: color-mix(in srgb, var(--surface) 70%, transparent); }
.chat-faces { flex: none; display: inline-flex; }
.chat-text { min-width: 0; display: flex; flex-direction: column; }
.chat-name { font-weight: 650; font-size: 16px; letter-spacing: -0.015em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-sub { font-size: 12.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-sub.live::before { content: ""; display: inline-block; width: 6px; height: 6px; border-radius: 50%; background: var(--green); margin-right: 6px; vertical-align: 1px; animation: pop 0.5s var(--spring-bouncy); }

.pill-btn {
  height: 36px;
  padding: 0 14px 0 12px;
  border-radius: 999px;
  background: var(--surface);
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-weight: 600;
  font-size: 14px;
  flex: none;
  transition: background-color 0.15s, transform 0.4s var(--spring);
}
.pill-btn svg { width: 17px; height: 17px; }
.pill-btn:hover { background: var(--surface-2); }
.pill-btn:active { transform: scale(0.94); }

.net {
  position: absolute;
  top: calc(var(--head-h, 62px) + 10px);
  left: 50%;
  translate: -50% 0;
  z-index: 7;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 13px;
  border-radius: 999px;
  background: var(--bg);
  box-shadow: var(--shadow);
  font-size: 13px;
  font-weight: 500;
  color: var(--muted);
  white-space: nowrap;
  animation: drop 0.6s var(--spring-bouncy);
}
.net .dot { width: 7px; height: 7px; border-radius: 50%; background: #f5a524; animation: pulse 1.2s ease-in-out infinite; }

.scroller {
  position: absolute;
  inset: 0;
  overflow-y: auto;
  overflow-x: hidden;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}
.thread {
  min-height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  padding-top: calc(var(--head-h, 62px) + 6px);
  padding-bottom: calc(var(--comp-h, 64px) + 2px);
}
.msgs, .typing { width: 100%; max-width: 780px; margin: 0 auto; padding: 0 12px; }
.msgs { padding-bottom: 4px; }
.older { display: flex; justify-content: center; padding: 14px; }

.day { text-align: center; font-size: 12px; font-weight: 600; color: var(--faint); margin: 22px 0 10px; letter-spacing: 0.01em; }

.msg { margin-top: 2px; }
.msg.first { margin-top: 12px; }
.day + .msg.first { margin-top: 0; }
.row { display: flex; align-items: flex-end; gap: 8px; }
.mine .row { justify-content: flex-end; }
.av-slot { width: 28px; flex: none; display: flex; }
.col { display: flex; flex-direction: column; align-items: flex-start; min-width: 0; max-width: min(76%, 520px); }
.mine .col { align-items: flex-end; max-width: min(80%, 540px); }

.who { font-size: 12px; font-weight: 600; color: var(--muted); margin: 0 0 3px 12px; }

.bubble {
  max-width: 100%;
  padding: 8px 13px 9px;
  border-radius: 20px;
  background: var(--surface);
  font-size: 15.5px;
  line-height: 1.38;
  white-space: pre-wrap;
  word-break: keep-all;
  overflow-wrap: anywhere;
}
.bubble .tx { display: block; }
.mine .bubble { background: var(--mine); color: var(--mine-text); }
.msg:not(.first):not(.mine):not(.quoted) .body > :is(.bubble, .photo, .voice):first-child { border-top-left-radius: 6px; }
.msg:not(.last):not(.mine) .body > :is(.bubble, .photo, .voice):last-child { border-bottom-left-radius: 6px; }
.msg.mine:not(.first):not(.quoted) .body > :is(.bubble, .photo, .voice):first-child { border-top-right-radius: 6px; }
.msg.mine:not(.last) .body > :is(.bubble, .photo, .voice):last-child { border-bottom-right-radius: 6px; }

.bubble a { text-decoration: underline; text-underline-offset: 2px; text-decoration-thickness: 1px; }
.bubble.big { background: none !important; padding: 0 2px; font-size: 46px; line-height: 1.15; }

.meta { font-size: 11.5px; color: var(--faint); margin: 4px 12px 0 48px; }
.mine .meta { text-align: right; margin: 4px 6px 0; }
.meta .fail, .status .fail { color: var(--danger); font-weight: 600; }
.meta button.fail { text-decoration: underline; text-underline-offset: 2px; }

.status {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 6px;
  margin: 4px 6px 0;
  font-size: 11.5px;
  color: var(--faint);
  animation: rise 0.45s var(--ease-out) both;
}
.status b { font-weight: 600; color: var(--muted); }
.status .faces .avatar { box-shadow: 0 0 0 1.5px var(--bg); }

.photo {
  display: block;
  position: relative;
  max-width: 100%;
  border-radius: 20px;
  overflow: hidden;
  background: var(--surface);
  cursor: zoom-in;
}
.photo img { display: block; width: 100%; height: 100%; object-fit: cover; }
.photo + .bubble { margin-top: 2px; }
.progress { position: absolute; left: 12px; right: 12px; bottom: 12px; height: 4px; border-radius: 4px; background: rgba(255, 255, 255, 0.4); overflow: hidden; }
.progress i { display: block; height: 100%; background: #fff; border-radius: 4px; transition: width 0.25s var(--ease-out); }

.card {
  display: block;
  margin-top: 4px;
  width: min(100%, 340px);
  border-radius: 18px;
  overflow: hidden;
  background: var(--bg);
  border: 1px solid var(--line);
  text-decoration: none;
  transition: background-color 0.15s, transform 0.4s var(--spring);
}
.card:hover { background: var(--surface); }
.card:active { transform: scale(0.98); }
.card img { display: block; width: 100%; aspect-ratio: 1.91 / 1; object-fit: cover; background: var(--surface); }
.card-body { padding: 10px 13px 12px; display: flex; flex-direction: column; gap: 2px; }
.card-site { font-size: 12px; color: var(--muted); font-weight: 500; }
.card-title { font-size: 14px; font-weight: 600; line-height: 1.35; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.card-desc { font-size: 13px; color: var(--muted); line-height: 1.4; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }

/* ---------- typing bubble (liquid) ---------- */

.typing { padding-top: 10px; padding-bottom: 4px; }
.tb { position: relative; width: 62px; height: 38px; flex: none; }
.tb-goo { position: absolute; left: -14px; top: -10px; right: -10px; bottom: -14px; filter: url(#goo); pointer-events: none; }
.tb-goo b { position: absolute; display: block; background: var(--surface); border-radius: 999px; }
.tb-body {
  left: 14px; top: 10px; width: 62px; height: 38px;
  transform-origin: 0 100%;
  animation: tbGrow 0.75s var(--spring-bouncy) both, tbBreathe 1.8s ease-in-out 0.75s infinite;
}
.tb-t1 { left: 8px; bottom: 9px; width: 13px; height: 13px; animation: pop 0.45s var(--spring-bouncy) both; }
.tb-t2 { left: 2px; bottom: 2px; width: 6px; height: 6px; animation: pop 0.45s var(--spring-bouncy) 0.08s both; }
.tb-dots { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; gap: 5px; animation: fadeIn 0.3s ease-out 0.18s both; }
.tb-dots i { width: 7.5px; height: 7.5px; border-radius: 50%; background: var(--faint); animation: blink 1.35s ease-in-out infinite; }
.tb-dots i:nth-child(2) { animation-delay: 0.18s; }
.tb-dots i:nth-child(3) { animation-delay: 0.36s; }
.tb-ghost { position: fixed; z-index: 8; pointer-events: none; margin: 0; }

@keyframes tbGrow { from { transform: scale(0.18); } }
@keyframes tbBreathe { 50% { transform: scale(1.045, 1.06); } }
@keyframes blink { 0%, 55%, 100% { opacity: 0.35; transform: scale(0.82); } 25% { opacity: 1; transform: scale(1); } }

/* ---------- empty / jump ---------- */

.chat-empty { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; padding: 32px 24px 48px; animation: rise 0.6s var(--ease-out) both; }
.chat-empty-icon { width: 58px; height: 58px; border-radius: 19px; background: var(--surface); display: grid; place-items: center; margin-bottom: 16px; }
.chat-empty h2 { margin: 0 0 6px; font-size: 20px; font-weight: 700; letter-spacing: -0.025em; }
.chat-empty p { margin: 0 0 22px; color: var(--muted); }
.chat-empty .btn { width: auto; padding: 0 24px; }

.jump {
  position: absolute;
  right: 16px;
  bottom: calc(var(--comp-h, 64px) + 12px);
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--bg);
  box-shadow: var(--shadow);
  z-index: 6;
  animation: pop 0.45s var(--spring-bouncy);
  transition: transform 0.4s var(--spring);
}
.jump:active { transform: scale(0.88); }
.jump svg { width: 20px; height: 20px; }

/* ---------- composer ---------- */

.composer {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 6;
  display: flex;
  flex-direction: column;
  padding: 8px max(10px, calc((100% - 800px) / 2)) calc(10px + var(--safe-b));
}
.attach-btn { color: var(--muted); margin-bottom: 1px; }
.attach-btn:hover { color: var(--text); }
.field {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: flex-end;
  background: var(--field);
  border: 1px solid var(--line);
  border-radius: 22px;
  padding: 3px;
  transition: border-color 0.2s;
}
.field:focus-within { border-color: color-mix(in srgb, var(--text) 22%, transparent); }
.field textarea {
  flex: 1;
  min-width: 0;
  border: 0;
  outline: 0;
  resize: none;
  background: transparent;
  font-size: 16px;
  line-height: 1.35;
  padding: 7px 8px 7px 12px;
  min-height: 34px;
  max-height: 160px;
  overflow-y: auto;
}
.field textarea::placeholder { color: var(--faint); }
.send-btn {
  position: relative;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  flex: none;
  background: var(--text);
  color: var(--bg);
  touch-action: none;
  transition: transform 0.45s var(--spring-bouncy), background-color 0.25s, color 0.25s;
}
.send-btn:active { transform: scale(0.86); transition-duration: 0.12s; }
.send-btn svg { position: absolute; inset: 0; margin: auto; width: 18px; height: 18px; stroke-width: 2.5; opacity: 0; transform: scale(0.3) rotate(-40deg); transition: transform 0.5s var(--spring-bouncy), opacity 0.18s; }
.send-btn .i-mic { width: 21px; height: 21px; stroke-width: 2; }
.send-btn.mode-mic { background: transparent; color: var(--muted); }
.send-btn.mode-mic:hover { color: var(--text); }
.send-btn.mode-mic .i-mic, .send-btn.mode-send .i-send, .send-btn.mode-edit .i-check { opacity: 1; transform: none; }
.send-btn.holding { background: var(--danger); color: #fff; transform: scale(1.45); }
.send-btn.locked { background: var(--text); color: var(--bg); }
.send-btn.locked .i-mic { opacity: 0; transform: scale(0.3); }
.send-btn.locked .i-send { opacity: 1; transform: none; }

.drop {
  position: absolute;
  inset: 8px;
  border: 2px dashed var(--faint);
  border-radius: 22px;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  display: grid;
  place-items: center;
  font-weight: 600;
  font-size: 17px;
  z-index: 10;
  pointer-events: none;
  animation: fadeIn 0.2s ease-out;
}

/* ---------- sheets ---------- */

.sheet-wrap {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  background: var(--overlay);
  opacity: 0;
  transition: opacity 0.25s ease-out;
}
.sheet-wrap.open { opacity: 1; }
.sheet {
  width: 100%;
  max-width: 440px;
  background: var(--bg);
  border-radius: 28px 28px 0 0;
  padding: 26px 20px calc(20px + var(--safe-b));
  transform: translateY(105%);
  transition: transform 0.55s var(--spring);
}
.sheet-wrap.open .sheet { transform: none; }
@media (min-width: 600px) {
  .sheet-wrap { align-items: center; }
  .sheet { border-radius: 26px; padding: 28px 24px 24px; box-shadow: var(--shadow); transform: translateY(24px) scale(0.96); opacity: 0; transition: transform 0.55s var(--spring), opacity 0.2s; }
  .sheet-wrap.open .sheet { opacity: 1; }
}

.sheet h2 { margin: 0 0 6px; font-size: 21px; font-weight: 700; letter-spacing: -0.025em; }
.sheet p { margin: 0 0 20px; color: var(--muted); line-height: 1.5; }
.sheet .stack { display: flex; flex-direction: column; gap: 10px; }
.sheet .center { text-align: center; }

.input {
  width: 100%;
  height: 50px;
  border-radius: 14px;
  border: 1.5px solid var(--line);
  background: var(--surface);
  padding: 0 16px;
  font-size: 16px;
  outline: none;
  transition: border-color 0.15s, background-color 0.15s;
}
.input:focus { border-color: var(--text); background: var(--bg); }

.btn {
  width: 100%;
  height: 50px;
  border-radius: 14px;
  font-size: 15.5px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: opacity 0.15s, transform 0.4s var(--spring), background-color 0.15s;
}
.btn:active { transform: scale(0.97); }
.btn-primary { background: var(--text); color: var(--bg); }
.btn-primary:disabled { opacity: 0.3; }
.btn-ghost { background: var(--surface); }
.btn-ghost:hover { background: var(--surface-2); }
.btn-danger { color: var(--danger); }
.btn svg { width: 19px; height: 19px; }

.link-box { display: flex; align-items: center; gap: 10px; padding: 0 6px 0 14px; height: 50px; border-radius: 14px; background: var(--surface); font-size: 14px; color: var(--muted); margin-bottom: 10px; }
.link-box span { flex: 1; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.link-box .btn { width: auto; height: 38px; padding: 0 14px; border-radius: 10px; font-size: 14px; }

.profile-face { position: relative; width: 104px; height: 104px; margin: 0 auto 18px; }
.profile-face .avatar { box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12); }
.shuffle {
  position: absolute;
  right: -6px;
  bottom: -2px;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--bg);
  box-shadow: var(--shadow);
  transition: transform 0.5s var(--spring-bouncy);
}
.shuffle:active { transform: scale(0.85) rotate(-20deg); }
.shuffle svg { width: 18px; height: 18px; }

.setting { display: flex; align-items: center; gap: 12px; padding: 4px 4px 4px 2px; font-weight: 500; }
.setting span { flex: 1; }
.switch {
  appearance: none;
  -webkit-appearance: none;
  position: relative;
  width: 50px;
  height: 30px;
  border-radius: 999px;
  background: var(--surface-2);
  cursor: pointer;
  margin: 0;
  transition: background-color 0.25s;
}
.switch::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
  transition: transform 0.5s var(--spring-bouncy);
}
.switch:checked { background: var(--green); }
.switch:checked::after { transform: translateX(20px); }

/* ---------- lightbox / toast ---------- */

.lightbox {
  position: fixed;
  inset: 0;
  z-index: 60;
  background: rgba(0, 0, 0, 0.94);
  display: grid;
  place-items: center;
  padding: calc(16px + var(--safe-t)) 16px calc(16px + var(--safe-b));
  cursor: zoom-out;
}
.lightbox img { max-width: 100%; max-height: 100%; object-fit: contain; border-radius: 6px; transform-origin: 0 0; }
.lb-close { position: absolute; top: calc(12px + var(--safe-t)); right: 12px; color: #fff; }
.lb-close:hover { background: rgba(255, 255, 255, 0.12); }

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(100px + var(--safe-b));
  translate: -50% 0;
  z-index: 70;
  background: var(--text);
  color: var(--bg);
  padding: 10px 18px;
  border-radius: 999px;
  font-size: 14px;
  font-weight: 500;
  white-space: nowrap;
  animation: drop-up 0.5s var(--spring-bouncy);
}

.spinner { width: 20px; height: 20px; border-radius: 50%; border: 2px solid var(--line); border-top-color: var(--muted); animation: spin 0.7s linear infinite; }

@keyframes spin { to { transform: rotate(360deg); } }
@keyframes pulse { 50% { opacity: 0.3; } }
@keyframes fadeIn { from { opacity: 0; } }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } }
@keyframes pop { from { opacity: 0; transform: scale(0.4); } }
@keyframes drop { from { opacity: 0; transform: translateY(-12px) scale(0.9); } }
@keyframes drop-up { from { opacity: 0; transform: translateY(14px) scale(0.92); } }

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

/* ======================================================================
   Messaging extras: replies, reactions, edits, unsend, voice, search,
   translation, long-press menu.
   ====================================================================== */

:root { --menu: #ffffff; --hl: rgba(255, 204, 0, 0.45); --hl-cur: #ffcc00; }
@media (prefers-color-scheme: dark) { :root { --menu: #1f1f22; --hl: rgba(255, 204, 0, 0.35); } }

.icon-btn.sm { width: 34px; height: 34px; }
.icon-btn.sm svg { width: 19px; height: 19px; }
.text-btn { font-weight: 600; font-size: 15px; padding: 8px 6px; border-radius: 10px; flex: none; }

/* Message body: the bubble (or photo / voice) plus its reaction badge */
.body { position: relative; display: flex; flex-direction: column; align-items: flex-start; max-width: 100%; transition: transform 0.35s var(--ease-out); }
.mine .body { align-items: flex-end; }
.body.has-r { margin-top: 15px; }
.body.pressing { transform: scale(0.96); }
.msg { touch-action: pan-y; }
@media (pointer: coarse) {
  .body { -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
}

.reacts {
  position: absolute;
  top: -17px;
  right: -8px;
  z-index: 2;
  display: flex;
  align-items: center;
  height: 27px;
  padding: 0 7px;
  border-radius: 999px;
  background: var(--surface);
  box-shadow: 0 0 0 2.5px var(--bg);
  font-size: 14px;
  line-height: 1;
  cursor: pointer;
  white-space: nowrap;
}
.mine .reacts { right: auto; left: -8px; }
.reacts span + span { margin-left: -2px; }
.reacts .n { font-size: 12px; font-weight: 650; color: var(--muted); margin-left: 4px; }
.reacts.me { background: var(--surface-2); }

/* Quoted reply: a faded mini-bubble above the message */
.quote {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  max-width: min(100%, 300px);
  margin: 0 0 3px;
  padding: 6px 12px 7px;
  border-radius: 16px;
  background: transparent;
  box-shadow: inset 0 0 0 1.5px var(--surface-2);
  text-align: left;
  font-size: 13px;
  line-height: 1.3;
  color: var(--muted);
  transition: background-color 0.15s, transform 0.4s var(--spring);
}
.quote:active { transform: scale(0.97); }
.quote:hover { background: var(--surface); }
.quote b { font-size: 12px; font-weight: 650; color: var(--text); opacity: 0.8; }
.quote span { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; word-break: break-word; }
.quote i { font-style: normal; opacity: 0.75; }
.mine .quote { align-items: flex-end; text-align: right; }

.edited { font-size: 11.5px; color: var(--faint); margin: 3px 8px 0; }
.unsent { font-size: 13px; color: var(--faint); padding: 3px 4px; animation: fadeIn 0.5s ease-out; }

/* Translation */
.tr-label { display: block; margin-top: 4px; font-size: 11.5px; font-weight: 500; opacity: 0.6; white-space: normal; }
.tr-label button { text-decoration: underline; text-underline-offset: 2px; }
.bubble.translating .tx { animation: shimmer 1.1s ease-in-out infinite; }
@keyframes shimmer { 50% { opacity: 0.35; } }

/* Voice messages */
.voice {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 248px;
  max-width: 100%;
  padding: 7px 14px 7px 7px;
  border-radius: 22px;
  background: var(--surface);
}
.mine .voice { background: var(--mine); color: var(--mine-text); }
.v-play {
  width: 34px;
  height: 34px;
  flex: none;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--text);
  color: var(--bg);
  transition: transform 0.45s var(--spring-bouncy);
}
.v-play:active { transform: scale(0.86); }
.mine .v-play { background: var(--mine-text); color: var(--mine); }
.v-play svg { width: 15px; height: 15px; fill: currentColor; stroke: none; }
.v-wave { position: relative; flex: 1; height: 30px; cursor: pointer; }
.v-bars { position: absolute; inset: 0; display: flex; align-items: center; gap: 2px; }
.v-bars i { flex: 1; min-height: 3px; border-radius: 2px; background: currentColor; opacity: 0.28; transform-origin: 50% 50%; }
.v-bars.fill { clip-path: inset(0 calc(100% - var(--p, 0) * 100%) 0 0); }
.v-bars.fill i { opacity: 1; }
.v-meta { display: flex; flex-direction: column; align-items: flex-end; gap: 2px; flex: none; }
.v-time { font-size: 12px; font-variant-numeric: tabular-nums; opacity: 0.7; min-width: 30px; text-align: right; }
.v-speed { font-size: 10.5px; font-weight: 700; padding: 1px 5px; border-radius: 7px; background: color-mix(in srgb, currentColor 16%, transparent); }

/* Reply / edit bar above the input */
.cbar-wrap { display: grid; grid-template-rows: 0fr; opacity: 0; transition: grid-template-rows 0.42s var(--ease-out), opacity 0.25s; }
.cbar-wrap.open { grid-template-rows: 1fr; opacity: 1; }
.cbar { min-height: 0; overflow: hidden; display: flex; align-items: center; gap: 10px; padding: 0 2px 0 8px; }
.cbar-wrap.open .cbar { padding-bottom: 8px; }
.cbar-icon { width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; background: var(--surface); flex: none; }
.cbar-icon svg { width: 16px; height: 16px; }
.cbar-text { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.3; }
.cbar-text b { font-size: 13px; font-weight: 650; }
.cbar-text span { font-size: 13px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.crow { display: flex; align-items: flex-end; gap: 6px; }
.attach-btn { transition: opacity 0.2s, transform 0.4s var(--spring), width 0.3s var(--ease-out), margin 0.3s; }
.composer.recording .attach-btn { opacity: 0; transform: scale(0.5); width: 0; margin-right: -6px; pointer-events: none; }

/* Voice recorder inside the field */
.rec { flex: 1; min-width: 0; height: 34px; display: flex; align-items: center; gap: 10px; padding: 0 6px 0 12px; animation: fadeIn 0.2s ease-out; }
.rec-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--danger); flex: none; animation: pulse 1s ease-in-out infinite; }
.rec-time { font-size: 15px; font-weight: 500; font-variant-numeric: tabular-nums; flex: none; }
.rec-wave { flex: 1; min-width: 0; height: 24px; display: flex; align-items: center; justify-content: flex-end; gap: 2px; overflow: hidden; }
.rec-wave i { width: 3px; flex: none; min-height: 3px; border-radius: 2px; background: var(--muted); transition: height 0.1s; }
.rec-hint { font-size: 13px; color: var(--muted); flex: none; transition: opacity 0.2s, transform 0.2s; }
.rec-hint::before { content: "\2039  "; }
.rec-trash { display: none; margin-left: -8px; color: var(--danger); }
.rec.locked .rec-trash { display: inline-grid; }
.rec.locked .rec-hint { display: none; }
.rec.locked { padding-left: 4px; }
.composer.recording textarea { display: none; }

/* Search */
.chat-bar > :not(.searchbar) { transition: opacity 0.2s; }
.chat-bar.searching > :not(.searchbar) { opacity: 0; pointer-events: none; }
.searchbar { position: absolute; left: 0; right: 0; bottom: 0; height: 62px; display: flex; align-items: center; gap: 2px; padding: 0 8px 0 12px; animation: drop 0.45s var(--spring); }
.search-field { flex: 1; min-width: 0; height: 38px; display: flex; align-items: center; gap: 7px; padding: 0 12px; border-radius: 12px; background: var(--surface); color: var(--muted); cursor: text; }
.search-field svg { width: 17px; height: 17px; }
.search-field input { flex: 1; min-width: 0; border: 0; outline: 0; background: transparent; font-size: 16px; color: var(--text); }
.search-field input::-webkit-search-cancel-button { display: none; }
.search-count { font-size: 13px; font-variant-numeric: tabular-nums; white-space: nowrap; }
::highlight(yo-search) { background-color: var(--hl); }
::highlight(yo-current) { background-color: var(--hl-cur); color: #000; }

/* Long-press menu (lifted bubble + reactions + actions) */
.cm { position: fixed; inset: 0; z-index: 55; }
.cm-back {
  position: absolute;
  inset: 0;
  background: color-mix(in srgb, var(--bg) 45%, transparent);
  -webkit-backdrop-filter: blur(16px) saturate(150%);
  backdrop-filter: blur(16px) saturate(150%);
}
.cm-clone { position: fixed; margin: 0; pointer-events: none; transform-origin: 50% 50%; filter: drop-shadow(0 14px 30px rgba(0, 0, 0, 0.16)); }
.cm-clone .reacts { box-shadow: none; }
.cm-reacts {
  position: fixed;
  display: flex;
  gap: 2px;
  padding: 5px;
  border-radius: 999px;
  background: var(--menu);
  box-shadow: var(--shadow);
}
.cm-reacts button {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 25px;
  line-height: 1;
  transition: transform 0.4s var(--spring-bouncy), background-color 0.15s;
}
.cm-reacts button:hover { transform: scale(1.2); }
.cm-reacts button:active { transform: scale(0.9); }
.cm-reacts button.on { background: var(--surface-2); }
.cm-menu {
  position: fixed;
  width: 236px;
  padding: 5px;
  border-radius: 18px;
  background: var(--menu);
  box-shadow: var(--shadow);
}
.cm-menu button {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 11px 12px;
  border-radius: 12px;
  font-size: 15px;
  font-weight: 500;
  text-align: left;
  transition: background-color 0.12s;
}
.cm-menu button:hover, .cm-menu button:focus-visible { background: var(--surface); outline: none; }
.cm-menu button.danger { color: var(--danger); }
.cm-menu svg { width: 19px; height: 19px; }
.cm-sep { height: 1px; margin: 4px 10px; background: var(--line); }

/* Swipe to reply */
.swipe-ico {
  position: absolute;
  left: 2px;
  top: 50%;
  width: 30px;
  height: 30px;
  margin-top: -15px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--surface);
  color: var(--muted);
  opacity: 0;
  transform: scale(0.4);
  pointer-events: none;
}
.swipe-ico svg { width: 16px; height: 16px; }
.swipe-ico.armed { background: var(--text); color: var(--bg); }
.row { position: relative; }

/* Effects */
.poof-dot { position: fixed; z-index: 9; width: 7px; height: 7px; margin: -3.5px; border-radius: 50%; background: var(--faint); pointer-events: none; }
.fly { position: fixed; z-index: 60; font-size: 25px; line-height: 1; pointer-events: none; margin: 0; }

.rx-list { display: flex; flex-direction: column; gap: 4px; margin: 4px 0 18px; }
.rx-row { display: flex; align-items: center; gap: 12px; padding: 6px 2px; }
.rx-name { flex: 1; font-weight: 500; }
.rx-e { font-size: 24px; animation: pop 0.5s var(--spring-bouncy) both; }
