/* ===== Animal Hospital — mini app theme ===== */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

:root {
  /* Animal Hospital — ВСЕГДА тёмная тема (глубокий больничный ночной) */
  --bg: #0d1a22;
  --bg2: #12232c;
  --card: #16292f;
  --ink: #eaf4f8;
  --muted: #8aa6b4;
  --line: #24424c;
  --brand: #ff7a3d;        /* оранжевый маскот */
  --brand-ink: #ffffff;
  --teal: #1fc7bd;         /* бирюза */
  --blue: #4a90e0;         /* больничный синий */
  --mint: #1e4a3c;
  --green: #4bbf7b;
  --danger: #ff5470;
  --radius: 20px;
  --shadow: 0 10px 30px rgba(0,0,0,.42);
  --shadow-sm: 0 4px 14px rgba(0,0,0,.34);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --nav-h: 66px;
  color-scheme: dark;
}

html, body { height: 100%; overflow-x: hidden; max-width: 100%; }
body {
  background:
    radial-gradient(1200px 500px at 50% -10%, rgba(61,127,214,.16), transparent 60%),
    linear-gradient(180deg, var(--bg), var(--bg2));
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  min-height: 100dvh;
  overscroll-behavior-y: none;
  overflow-x: hidden;
}
#app { max-width: 620px; margin: 0 auto; min-height: 100dvh; display: flex; flex-direction: column; }

svg.i { width: 22px; height: 22px; display: block; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
svg.i.sm { width: 18px; height: 18px; }
svg.i.fill { fill: currentColor; stroke: none; }

/* ===== Header ===== */
.hdr {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 12px;
  padding: calc(10px + env(safe-area-inset-top)) 16px 12px;
  background: color-mix(in srgb, var(--bg) 78%, transparent);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--line);
}
.hdr .logo {
  width: 46px; height: 46px; border-radius: 14px; flex: 0 0 46px;
  background: #fff center/cover no-repeat; box-shadow: var(--shadow-sm);
  animation: bob 3.2s ease-in-out infinite;
}
@keyframes bob { 0%,100%{ transform: translateY(0) rotate(-2deg);} 50%{ transform: translateY(-4px) rotate(2deg);} }
.hdr .htxt { flex: 1; min-width: 0; }
.hdr h1 { font-size: 18px; font-weight: 800; letter-spacing: -.3px; line-height: 1.1; }
.hdr .sub { font-size: 12px; color: var(--muted); display: flex; align-items: center; gap: 5px; margin-top: 2px; }
.hdr .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--green); box-shadow: 0 0 0 0 rgba(75,191,123,.6); animation: pulse 2s infinite; }
@keyframes pulse { 0%{ box-shadow: 0 0 0 0 rgba(75,191,123,.55);} 70%{ box-shadow: 0 0 0 8px rgba(75,191,123,0);} 100%{ box-shadow: 0 0 0 0 rgba(75,191,123,0);} }
.hdr .stat-chip { display: none; }
.chip { background: var(--card); border: 1px solid var(--line); border-radius: 999px; padding: 6px 10px; font-size: 12px; color: var(--muted); font-weight: 600; white-space: nowrap; }
.chip b { color: var(--ink); }

/* ===== Main ===== */
main { flex: 1; padding: 14px 14px calc(var(--nav-h) + var(--safe-b) + 14px); }
.panel { display: none; animation: fade .28s ease both; }
.panel.on { display: block; }
@keyframes fade { from{ opacity:0; transform: translateY(8px);} to{ opacity:1; transform:none;} }

.section-title { font-size: 13px; font-weight: 800; color: var(--muted); text-transform: uppercase; letter-spacing: .5px; margin: 4px 4px 10px; }

/* ===== Buttons ===== */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; width: 100%;
  font-weight: 800; font-size: 15px; padding: 14px 16px; border-radius: 16px; border: none; cursor: pointer;
  text-decoration: none; transition: transform .12s ease, box-shadow .2s ease, background .2s; }
.btn:active { transform: scale(.97); }
.btn-brand { background: linear-gradient(135deg, var(--brand), #ff5b7a); color: #fff; box-shadow: 0 8px 22px rgba(255,122,61,.4); }
.btn-teal { background: linear-gradient(135deg, var(--teal), var(--blue)); color: #fff; box-shadow: 0 8px 22px rgba(23,184,176,.35); }
.btn-ghost { background: var(--card); color: var(--ink); border: 1px solid var(--line); box-shadow: var(--shadow-sm); }
.btn-sm { width: auto; padding: 9px 14px; font-size: 13.5px; border-radius: 12px; }

/* ===== Cards ===== */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; box-shadow: var(--shadow-sm); margin-bottom: 11px; animation: fade .3s ease both; }
.card .top { display: flex; align-items: center; gap: 12px; }
.card .grow { flex: 1; min-width: 0; }
.card .name { font-weight: 800; font-size: 15.5px; letter-spacing: -.2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card .meta { font-size: 12.5px; color: var(--muted); margin-top: 2px; }
.card .text { font-size: 14.5px; line-height: 1.45; margin: 8px 0; }

.badge { font-size: 12.5px; font-weight: 800; padding: 5px 11px; border-radius: 999px; white-space: nowrap; background: rgba(255,122,61,.16); color: #ff9a63; }
.badge.full { background: rgba(75,191,123,.18); color: #6ee0a0; }
.badge.teal { background: rgba(31,199,189,.16); color: var(--teal); }

.progress { height: 7px; border-radius: 999px; background: var(--line); overflow: hidden; margin: 11px 0 4px; }
.progress i { display: block; height: 100%; border-radius: 999px; background: linear-gradient(90deg, var(--brand), var(--teal)); transition: width .5s cubic-bezier(.2,.8,.2,1); }

/* ===== Avatars (плейсхолдеры-зверьки) ===== */
.ava { width: 44px; height: 44px; border-radius: 14px; flex: 0 0 44px; overflow: hidden; background: var(--bg2) center/cover no-repeat; display: flex; align-items: center; justify-content: center; position: relative; box-shadow: inset 0 0 0 1px rgba(0,0,0,.04); }
.ava.sm { width: 36px; height: 36px; flex-basis: 36px; border-radius: 11px; }
.ava img { width: 100%; height: 100%; object-fit: cover; }
.ava .ini { font-weight: 800; font-size: 16px; color: #fff; }

/* ===== Rooms list ===== */
.room { display: flex; align-items: center; gap: 13px; }
.room .icon { width: 48px; height: 48px; border-radius: 15px; flex: 0 0 48px; display: flex; align-items: center; justify-content: center; color: #fff; }
.room .icon.general { background: linear-gradient(135deg, var(--teal), var(--blue)); }
.room .icon.user { background: linear-gradient(135deg, var(--brand), #ff5b7a); }
.room .chev { color: var(--muted); }

/* ===== Chat ===== */
.chat-wrap { display: flex; flex-direction: column; height: calc(100dvh - var(--nav-h) - var(--safe-b) - 76px); border-radius: var(--radius); overflow: hidden; background: var(--bg2); border: 1px solid var(--line); box-shadow: var(--shadow); }
.chat-head { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-bottom: 1px solid var(--line); background: var(--bg2); }
.icon-btn { width: 38px; height: 38px; border-radius: 12px; border: 1px solid var(--line); background: var(--card); color: var(--ink); display: flex; align-items: center; justify-content: center; cursor: pointer; transition: transform .1s, background .2s; }
.icon-btn:active { transform: scale(.9); }
.icon-btn.active { background: var(--brand); color: #fff; border-color: var(--brand); }
.chat-head .rname { flex: 1; min-width: 0; }
.chat-head .rname b { font-size: 15px; font-weight: 800; display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-head .rname span { font-size: 11.5px; color: var(--muted); }

.chat-log { flex: 1; overflow-y: auto; padding: 14px 12px; display: flex; flex-direction: column; gap: 10px;
  background-color: var(--bg2); }
.msg { position: relative; display: flex; gap: 9px; align-items: flex-end; max-width: 78%; animation: pop .25s cubic-bezier(.2,.9,.3,1.2); will-change: transform; }
.msg.swiping { transition: none; }
.msg.swipe-hit .bubble { box-shadow: 0 0 0 2px var(--brand); }
@keyframes pop { from{ opacity:0; transform: translateY(10px) scale(.96);} to{ opacity:1; transform:none;} }
.msg.mine { align-self: flex-end; flex-direction: row-reverse; }
.msg .bubble { background: #1c333b; border: none; border-radius: 18px; border-bottom-left-radius: 6px; padding: 9px 13px; }
.msg.mine .bubble { background: linear-gradient(135deg, var(--brand), #ff5b7a); border: none; color: #fff; border-bottom-left-radius: 18px; border-bottom-right-radius: 6px; }
.msg .who { font-size: 11.5px; font-weight: 800; color: var(--teal); margin-bottom: 2px; }
.msg.mine .who { display: none; }
.msg .body { font-size: 14.5px; line-height: 1.4; word-break: break-word; }
.msg .time { font-size: 10px; opacity: .6; margin-top: 3px; text-align: right; }

.chat-input { display: flex; gap: 9px; padding: 10px; border-top: 1px solid var(--line); background: var(--bg2); }
.chat-input input { flex: 1; border: 1px solid var(--line); background: var(--bg); border-radius: 999px; padding: 12px 16px; font-size: 15px; color: var(--ink); outline: none; transition: border-color .2s; }
.chat-input input:focus { border-color: var(--brand); }
.send { width: 46px; height: 46px; flex: 0 0 46px; border: none; border-radius: 50%; background: linear-gradient(135deg, var(--brand), #ff5b7a); color: #fff; display: flex; align-items: center; justify-content: center; cursor: pointer; box-shadow: 0 6px 16px rgba(255,122,61,.4); transition: transform .12s; }
.send:active { transform: scale(.88) rotate(-8deg); }

/* ===== Empty / guest ===== */
.empty { text-align: center; color: var(--muted); padding: 40px 20px; font-size: 14.5px; line-height: 1.5; }
.empty .big { font-size: 40px; margin-bottom: 8px; display: inline-block; animation: bob 3s ease-in-out infinite; }
.guest { text-align: center; color: var(--muted); font-size: 13.5px; padding: 12px; background: var(--card); border: 1px dashed var(--line); border-radius: 14px; margin: 8px; }

/* ===== Bottom nav ===== */
.nav { position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; height: calc(var(--nav-h) + var(--safe-b)); padding-bottom: var(--safe-b);
  max-width: 620px; margin: 0 auto; display: flex; background: color-mix(in srgb, var(--card) 92%, transparent);
  backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px); border-top: 1px solid var(--line); }
.nav button { flex: 1; border: none; background: none; color: var(--muted); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; font-size: 11px; font-weight: 700; cursor: pointer; transition: color .2s; position: relative; }
.nav button.on { color: var(--brand); }
.nav button.on::before { content: ''; position: absolute; top: 0; width: 26px; height: 3px; border-radius: 0 0 4px 4px; background: var(--brand); }
.nav button.on svg { transform: translateY(-1px) scale(1.08); }
.nav svg { transition: transform .2s; }
.nav .bdg { position: absolute; top: 8px; right: calc(50% - 20px); min-width: 16px; height: 16px; padding: 0 4px; border-radius: 8px; background: var(--danger); color: #fff; font-size: 10px; font-weight: 800; display: none; align-items: center; justify-content: center; }
.nav .bdg.show { display: flex; }

/* fab */
.fab { position: fixed; right: 16px; bottom: calc(var(--nav-h) + var(--safe-b) + 14px); z-index: 25; width: 56px; height: 56px; border-radius: 50%; border: none; background: linear-gradient(135deg, var(--brand), #ff5b7a); color: #fff; box-shadow: 0 10px 26px rgba(255,122,61,.5); display: flex; align-items: center; justify-content: center; cursor: pointer; animation: bob 3.5s ease-in-out infinite; }
.fab:active { transform: scale(.9); }

/* toast */
.toast { position: fixed; left: 50%; bottom: calc(var(--nav-h) + var(--safe-b) + 20px); transform: translateX(-50%) translateY(20px); background: var(--ink); color: var(--bg); padding: 11px 18px; border-radius: 999px; font-size: 13.5px; font-weight: 700; opacity: 0; pointer-events: none; transition: opacity .3s, transform .3s; z-index: 50; box-shadow: var(--shadow); }
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* sheet (create room) */
.sheet-bg { position: fixed; inset: 0; background: rgba(10,25,35,.5); opacity: 0; pointer-events: none; transition: opacity .25s; z-index: 40; backdrop-filter: blur(2px); }
.sheet-bg.show { opacity: 1; pointer-events: auto; }
.sheet { position: fixed; left: 0; right: 0; bottom: 0; z-index: 41; max-width: 620px; margin: 0 auto; background: var(--card); border-radius: 24px 24px 0 0; padding: 20px 18px calc(20px + var(--safe-b)); transform: translateY(110%); transition: transform .3s cubic-bezier(.2,.9,.3,1); box-shadow: 0 -10px 40px rgba(0,0,0,.2); }
.sheet.show { transform: none; }
.sheet .grab { width: 40px; height: 5px; border-radius: 3px; background: var(--line); margin: 0 auto 16px; }
.sheet h3 { font-size: 18px; font-weight: 800; margin-bottom: 12px; }
.sheet input { width: 100%; border: 1px solid var(--line); background: var(--bg); border-radius: 14px; padding: 14px 16px; font-size: 16px; color: var(--ink); outline: none; margin-bottom: 12px; }
.sheet input:focus { border-color: var(--brand); }

/* ===== HERO (Animal Hospital) ===== */
.hero { position: relative; border-radius: 24px; overflow: hidden; margin: 2px 2px 14px; min-height: 148px; display: flex; align-items: flex-end; box-shadow: var(--shadow); isolation: isolate; }
.hero-bg { position: absolute; inset: 0; z-index: -2;
  background: #123 center/cover no-repeat var(--hero-img, none); transform: scale(1.05); }
.hero::after { content: ''; position: absolute; inset: 0; z-index: -1;
  background: linear-gradient(180deg, rgba(11,25,35,.12) 0%, rgba(11,25,35,.74) 100%),
              linear-gradient(100deg, rgba(255,122,61,.55) 0%, transparent 58%); }
/* сцена ward.jpg уже полна зверьков — отдельный маскот не нужен */
.hero-mascot { display: none; }
.hero-body { position: relative; z-index: 1; padding: 16px 16px 15px; color: #fff; }
.hero-kicker { font-size: 11px; font-weight: 900; letter-spacing: 2px; opacity: .95; text-shadow: 0 1px 6px rgba(0,0,0,.3); }
.hero-title { font-size: 26px; font-weight: 900; line-height: 1.02; letter-spacing: -.6px; margin: 5px 0 9px; text-shadow: 0 2px 10px rgba(0,0,0,.28); }
.hero-stats { display: flex; gap: 7px; }
.hero-stats .hp { background: rgba(255,255,255,.22); backdrop-filter: blur(6px); border: 1px solid rgba(255,255,255,.3); color: #fff; border-radius: 999px; padding: 5px 11px; font-size: 12px; font-weight: 800; }
.hero-stats .hp b { font-weight: 900; }

/* ===== BAIT card ===== */
.bait { position: relative; overflow: hidden; background: var(--card); border: 1.5px solid color-mix(in srgb, var(--brand) 40%, var(--line)); border-radius: 22px; padding: 15px; margin: 0 2px 16px; box-shadow: 0 12px 30px rgba(255,122,61,.18); }
.bait-glow { position: absolute; top: -60px; right: -60px; width: 160px; height: 160px; border-radius: 50%; background: radial-gradient(circle, rgba(255,122,61,.35), transparent 70%); pointer-events: none; }
.bait-badge { display: inline-block; font-size: 10.5px; font-weight: 900; letter-spacing: .8px; color: #ffb38a; background: #3a2417; padding: 4px 10px; border-radius: 999px; margin-bottom: 11px; }
.bait-row { display: flex; gap: 12px; align-items: center; }
.bait-art { width: 58px; height: 58px; flex: 0 0 58px; border-radius: 16px; background: var(--bg2) center/cover no-repeat var(--intern-img, none); box-shadow: var(--shadow-sm); }
.bait-txt { min-width: 0; }
.bait-txt > b { display: block; font-size: 16.5px; font-weight: 900; letter-spacing: -.3px; }
.bait-txt span { display: block; font-size: 13px; color: var(--muted); line-height: 1.4; margin-top: 2px; }
.bait-txt span b { color: var(--brand); font-weight: 800; }
.bait-perks { display: flex; gap: 6px; margin: 12px 0; flex-wrap: wrap; }
.bait-perks span { font-size: 12px; font-weight: 800; color: var(--ink); background: var(--bg); border: 1px solid var(--line); border-radius: 999px; padding: 6px 11px; }
.bait .btn-brand { margin-top: 2px; }
.bait-alt { display: block; text-align: center; font-size: 13px; font-weight: 700; color: var(--muted); margin-top: 11px; text-decoration: none; }
.bait-alt:active { color: var(--brand); }

/* ===== chat-sheet (add to chat) ===== */
.cs-hero { display: flex; justify-content: center; margin: -4px 0 10px; }
.cs-art { width: 92px; height: 92px; border-radius: 24px; background: var(--bg2) center/cover no-repeat var(--scene-img, none); box-shadow: var(--shadow); animation: bob 3.4s ease-in-out infinite; }
.cs-perks { display: flex; gap: 8px; margin: 14px 0; }
.cs-perks > div { flex: 1; text-align: center; background: var(--bg); border: 1px solid var(--line); border-radius: 14px; padding: 10px 6px; }
.cs-perks b { display: block; font-size: 14px; font-weight: 900; }
.cs-perks span { display: block; font-size: 11px; color: var(--muted); margin-top: 2px; }
.cs-steps { list-style: none; counter-reset: s; margin: 4px 0 16px; }
.cs-steps li { counter-increment: s; position: relative; padding: 8px 0 8px 38px; font-size: 14px; line-height: 1.4; border-bottom: 1px solid var(--line); }
.cs-steps li:last-child { border-bottom: none; }
.cs-steps li::before { content: counter(s); position: absolute; left: 0; top: 7px; width: 26px; height: 26px; border-radius: 50%; background: linear-gradient(135deg, var(--brand), #ff5b7a); color: #fff; font-weight: 900; font-size: 13px; display: flex; align-items: center; justify-content: center; }

/* ===== Fullscreen chat ===== */
#chat-view.open { position: fixed; inset: 0; z-index: 60; background: var(--bg2); }
html:has(body.chat-open), body.chat-open { background: var(--bg2) !important; }
#chat-view.open .chat-wrap { height: 100dvh; height: 100svh; border-radius: 0; border: none; width: 100%; max-width: 620px; margin: 0 auto; box-shadow: none; }
body.chat-open .nav, body.chat-open .fab, body.chat-open .hdr { display: none !important; }
#chat-view.open .chat-head { padding-top: calc(10px + env(safe-area-inset-top)); }
#chat-view.open .chat-input { padding-bottom: calc(10px + env(safe-area-inset-bottom)); }
.ava.clickable { cursor: pointer; }

/* reply-цитата в пузыре */
.reply-quote { border-left: 3px solid var(--brand); padding: 3px 8px; margin-bottom: 5px; font-size: 12.5px; line-height: 1.3; border-radius: 6px; background: rgba(127,127,127,.12); max-height: 46px; overflow: hidden; }
.reply-quote b { display: block; color: var(--brand); font-size: 11px; font-weight: 800; }
.msg.mine .reply-quote { border-left-color: rgba(255,255,255,.7); background: rgba(255,255,255,.14); }
.msg.mine .reply-quote b { color: #fff; }

/* панель ответа над инпутом */
.reply-bar { display: flex; align-items: center; gap: 10px; padding: 8px 12px; border-top: 1px solid var(--line); background: var(--card); }
.reply-bar .bar-line { width: 3px; align-self: stretch; border-radius: 2px; background: var(--brand); }
.reply-bar .rb-txt { flex: 1; min-width: 0; font-size: 12.5px; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.reply-bar .rb-txt b { color: var(--brand); display: block; font-size: 11px; }
.reply-bar .rb-x { border: none; background: none; color: var(--muted); font-size: 20px; cursor: pointer; padding: 0 4px; }

/* LFG sheet + roblox-код */
.sheet textarea { width: 100%; border: 1px solid var(--line); background: var(--bg); border-radius: 14px; padding: 12px 14px; font-size: 15px; color: var(--ink); outline: none; margin-bottom: 10px; resize: none; font-family: inherit; }
.sheet textarea:focus { border-color: var(--brand); }
.rb-code { display: flex; align-items: center; gap: 8px; margin-top: 9px; background: var(--bg); border: 1px dashed var(--line); border-radius: 12px; padding: 8px 12px; }
.rb-code .lbl { font-size: 11px; color: var(--muted); font-weight: 700; text-transform: uppercase; letter-spacing: .5px; }
.rb-code .val { flex: 1; min-width: 0; font-weight: 800; font-size: 14.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-family: ui-monospace, monospace; }
.rb-code button { border: none; background: var(--brand); color: #fff; border-radius: 9px; padding: 6px 11px; font-size: 12.5px; font-weight: 800; cursor: pointer; }
.rb-code button:active { transform: scale(.94); }

/* ===== ОП-гейт в мини-аппе ===== */
.op-gate { position: fixed; inset: 0; z-index: 100; background: var(--bg2);
  display: flex; align-items: center; justify-content: center; padding: 26px; }
.op-card { max-width: 380px; width: 100%; text-align: center; }
.op-card .op-emoji { font-size: 64px; margin-bottom: 12px; animation: bob 3s ease-in-out infinite; }
.op-card h2 { font-size: 25px; font-weight: 900; letter-spacing: -.4px; margin-bottom: 10px; }
.op-card p { color: var(--muted); font-size: 15px; line-height: 1.5; margin: 0 auto 22px; max-width: 330px; }
.op-card .btn { max-width: 320px; margin: 0 auto; }
body.op-locked { overflow: hidden; }
