/* ==========================================================================
   meme-bot.riNN.dev: Telegram style, light and night themes
   ========================================================================== */

:root,
[data-theme="light"] {
  --wall-1: #cfe6b0;
  --wall-2: #9ccfa9;
  --wall-3: #b6dcc4;
  --wall-dots: rgba(56, 120, 70, .14);
  --surface: #ffffff;
  --surface-2: #f4f4f5;
  --text: #000000;
  --text-2: #707579;
  --accent: #3390ec;
  --accent-text: #2b7fd4;
  --on-accent: #ffffff;
  --sep: #e7e7e9;
  --in: #ffffff;
  --out: #e3fec6;
  --in-time: #a2acb4;
  --out-time: #4fae4e;
  --inline-btn: rgba(255, 255, 255, .62);
  --inline-btn-text: #2b7a3d;
  --key: #ffffff;
  --service: rgba(39, 90, 52, .32);
  --shadow: 0 1px 2px rgba(16, 35, 47, .15);
  color-scheme: light;
}

[data-theme="dark"] {
  --wall-1: #0e1621;
  --wall-2: #0f1b28;
  --wall-3: #13202e;
  --wall-dots: rgba(110, 160, 210, .06);
  --surface: #17212b;
  --surface-2: #1e2c3a;
  --text: #f5f5f5;
  --text-2: #8a98a6;
  --accent: #5eb5f7;
  --accent-text: #6ab3f3;
  --on-accent: #0e1621;
  --sep: #0f1922;
  --in: #182533;
  --out: #2b5278;
  --in-time: #6d8193;
  --out-time: #7da8d3;
  --inline-btn: rgba(43, 82, 120, .55);
  --inline-btn-text: #ffffff;
  --key: #1e2c3a;
  --service: rgba(0, 0, 0, .35);
  --shadow: 0 1px 2px rgba(0, 0, 0, .35);
  color-scheme: dark;
}

:root {
  --font: "Inter", -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, Consolas, monospace;
}

*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; background: var(--wall-1); }
body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.45;
  background:
    radial-gradient(circle at 12px 12px, var(--wall-dots) 1.6px, transparent 2px) 0 0 / 34px 34px,
    radial-gradient(circle at 29px 27px, var(--wall-dots) 1.1px, transparent 1.5px) 0 0 / 34px 34px,
    linear-gradient(135deg, var(--wall-1), var(--wall-2) 55%, var(--wall-3));
  background-attachment: fixed;
  transition: color .3s ease;
}
a { color: var(--accent-text); text-decoration: none; }
a:hover { text-decoration: underline; }
p, h1, h2, ul, ol { margin: 0; }
ul, ol { padding: 0; list-style: none; }
svg { display: block; }
button, input { font: inherit; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.sr-only { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip { position: absolute; left: 12px; top: -60px; z-index: 50; padding: 10px 14px; border-radius: 10px; background: var(--accent); color: var(--on-accent); }
.skip:focus { top: 12px; }

/* ---------- Header bar ---------- */

.bar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 16px;
  height: 56px;
  padding: 0 clamp(12px, 3vw, 24px);
  background: var(--surface);
  box-shadow: var(--shadow);
  transition: background-color .3s;
}
.bar-back { display: flex; align-items: center; gap: 4px; color: var(--accent-text); font-weight: 500; }
.bar-back svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
.bar-title { display: flex; align-items: center; gap: 12px; margin: 0 auto; }
.bar-avatar { width: 38px; height: 38px; }
.bar-name { font-weight: 600; }
.bar-sub { color: var(--text-2); font-size: 13px; }
.bar-actions { display: flex; align-items: center; gap: 10px; }
.theme-toggle { --tt-track: var(--surface-2); --tt-knob: var(--accent); --tt-icon-on: var(--on-accent); color: var(--text-2); }

/* ---------- Layout ---------- */

.layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(340px, 420px);
  gap: 24px;
  width: min(1120px, 100% - 2 * clamp(12px, 3vw, 24px));
  margin: 24px auto 0;
  align-items: start;
}
.col-info { display: grid; gap: 16px; min-width: 0; }
.col-info > * { min-width: 0; }
.col-chat { position: sticky; top: 80px; min-width: 0; }

.card {
  padding: 18px 20px;
  border-radius: 14px;
  background: var(--surface);
  box-shadow: var(--shadow);
  transition: background-color .3s;
}
.card-title { margin-bottom: 8px; color: var(--accent-text); font-size: 15px; font-weight: 600; }

.profile { display: grid; justify-items: center; padding: 32px 24px 24px; text-align: center; }
.profile-avatar { width: 120px; height: 120px; margin-bottom: 14px; filter: drop-shadow(0 6px 16px rgba(47, 142, 230, .35)); }
.profile-name { font-size: 26px; font-weight: 700; letter-spacing: -0.01em; }
.profile-sub { color: var(--text-2); }
.profile-desc { max-width: 44ch; margin-top: 12px; }
.profile-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; margin-top: 18px; }
.tg-btn {
  display: inline-flex;
  align-items: center;
  height: 42px;
  padding: 0 22px;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--accent-text);
  font-weight: 600;
  text-decoration: none;
  transition: filter .15s;
}
.tg-btn:hover { text-decoration: none; filter: brightness(.96); }
.tg-btn--primary { background: var(--accent); color: var(--on-accent); }

.rows { display: grid; }
.row { display: grid; grid-template-columns: 40px minmax(0, 1fr); gap: 14px; align-items: start; padding: 10px 0; }
.row + .row { border-top: 1px solid var(--sep); }
.row-ic { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 10px; color: var(--text-2); }
.row-ic svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
.row-ic--blue, .row-ic--orange, .row-ic--green, .row-ic--violet, .row-ic--cyan { color: #fff; }
.row-ic--blue { background: #3d9bf2; }
.row-ic--orange { background: #f5a033; }
.row-ic--green { background: #4fbc5e; }
.row-ic--violet { background: #8e6cf0; }
.row-ic--cyan { background: #3cc1d8; }
.row-main { font-weight: 500; overflow-wrap: anywhere; }
.row-sub { color: var(--text-2); font-size: 14px; }

.code {
  margin: 0;
  padding: 14px 16px;
  overflow-x: auto;
  border-radius: 10px;
  background: var(--surface-2);
  font-family: var(--mono);
  font-size: 12.5px;
  line-height: 1.75;
}

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

.phone {
  display: flex;
  flex-direction: column;
  height: min(660px, calc(100vh - 110px));
  min-height: 480px;
  overflow: hidden;
  border-radius: 18px;
  background:
    radial-gradient(circle at 12px 12px, var(--wall-dots) 1.6px, transparent 2px) 0 0 / 30px 30px,
    linear-gradient(160deg, var(--wall-1), var(--wall-2));
  box-shadow: 0 10px 40px rgba(0, 0, 0, .22), 0 0 0 1px rgba(0, 0, 0, .06);
}
.chat-head { display: flex; align-items: center; gap: 12px; padding: 10px 14px; background: var(--surface); }
.chat-avatar { width: 42px; height: 42px; }
.chat-name { font-size: 16px; font-weight: 600; }
.chat-status { color: var(--text-2); font-size: 13px; min-height: 1.4em; }
.chat-status.is-typing { color: var(--accent-text); }
.chat-badge { margin-left: auto; padding: 3px 9px; border-radius: 999px; background: var(--surface-2); color: var(--text-2); font-size: 12px; font-weight: 500; }

.chat-scroll { flex: 1 1 auto; overflow-y: auto; padding: 14px 12px; scrollbar-width: thin; }
.msgs { display: flex; flex-direction: column; gap: 6px; }
.service {
  align-self: center;
  padding: 3px 12px;
  border-radius: 999px;
  background: var(--service);
  color: #fff;
  font-size: 13px;
  font-weight: 500;
}
.msg { max-width: 82%; animation: pop .22s ease-out both; }
@keyframes pop { from { opacity: 0; transform: translateY(6px) scale(.98); } }
.msg--in { align-self: flex-start; }
.msg--out { align-self: flex-end; }
.bubble {
  position: relative;
  padding: 6px 10px 6px;
  border-radius: 14px;
  background: var(--in);
  box-shadow: var(--shadow);
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}
.msg--in .bubble { border-bottom-left-radius: 4px; }
.msg--out .bubble { background: var(--out); border-bottom-right-radius: 4px; }
.meta { float: right; display: inline-flex; align-items: center; gap: 3px; margin: 8px 0 -4px 10px; color: var(--in-time); font-size: 12px; line-height: 1; }
.msg--out .meta { color: var(--out-time); }
.meta svg { width: 16px; height: 11px; }
.bubble--media { padding: 4px; }
.bubble--media .cap { padding: 6px 6px 2px; }
.bubble b { font-weight: 700; }

.meme {
  position: relative;
  display: grid;
  place-items: center;
  width: 260px;
  max-width: 100%;
  aspect-ratio: 1 / 1;
  overflow: hidden;
  border-radius: 11px;
  color: #fff;
  text-align: center;
}
.meme-emoji { font-size: 92px; line-height: 1; filter: drop-shadow(0 4px 10px rgba(0, 0, 0, .25)); }
.meme-top, .meme-bottom {
  position: absolute;
  left: 8px; right: 8px;
  font-family: "Archivo", Impact, sans-serif;
  font-weight: 900;
  font-stretch: 75%;
  font-size: 22px;
  line-height: 1.05;
  text-transform: uppercase;
  -webkit-text-stroke: 1.5px #000;
  paint-order: stroke fill;
  text-shadow: 0 2px 0 rgba(0, 0, 0, .4);
}
.meme-top { top: 10px; }
.meme-bottom { bottom: 10px; }

.inline-kb { display: grid; grid-auto-flow: column; gap: 4px; margin-top: 4px; }
.inline-btn {
  padding: 8px 10px;
  border: 0;
  border-radius: 10px;
  background: var(--inline-btn);
  color: var(--inline-btn-text);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  backdrop-filter: blur(6px);
}
.inline-btn:hover { filter: brightness(1.06); }
.inline-btn:disabled { opacity: .55; cursor: default; }

.typing { display: inline-flex; gap: 4px; padding: 12px 14px; }
.typing i { width: 7px; height: 7px; border-radius: 50%; background: var(--text-2); animation: typing 1s infinite ease-in-out; }
.typing i:nth-child(2) { animation-delay: .15s; }
.typing i:nth-child(3) { animation-delay: .3s; }
@keyframes typing { 0%, 60%, 100% { transform: translateY(0); opacity: .5; } 30% { transform: translateY(-4px); opacity: 1; } }

.chat-bottom { background: var(--surface); }
.start-wrap { padding: 10px; }
.start {
  width: 100%;
  height: 46px;
  border: 0;
  border-radius: 12px;
  background: var(--accent);
  color: var(--on-accent);
  font-weight: 700;
  letter-spacing: .04em;
  cursor: pointer;
}
.start:hover { filter: brightness(1.05); }
.composer { display: flex; align-items: center; gap: 6px; padding: 8px 8px 8px 14px; border-bottom: 1px solid var(--sep); }
.composer input {
  flex: 1 1 auto;
  min-width: 0;
  height: 40px;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--text);
}
.composer input::placeholder { color: var(--text-2); }
.send { display: grid; place-items: center; width: 40px; height: 40px; border: 0; border-radius: 50%; background: transparent; color: var(--accent); cursor: pointer; }
.send svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.send:hover { background: var(--surface-2); }
.reply-kb { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; padding: 8px; background: var(--surface-2); }
.key {
  height: 40px;
  border: 0;
  border-radius: 8px;
  background: var(--key);
  color: var(--text);
  box-shadow: var(--shadow);
  cursor: pointer;
}
.key:hover { color: var(--accent-text); }
.chat-note { margin: 12px 4px 0; color: var(--text); opacity: .75; font-size: 13px; }

/* ---------- Footer ---------- */

.foot {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 10px;
  width: min(1120px, 100% - 2 * clamp(12px, 3vw, 24px));
  margin: 40px auto 0;
  padding: 16px 20px;
  border-radius: 14px 14px 0 0;
  background: var(--surface);
  box-shadow: var(--shadow);
}
.foot a { font-weight: 600; }

/* ---------- Responsive ---------- */

@media (max-width: 900px) {
  .layout { grid-template-columns: minmax(0, 1fr); }
  .col-chat { position: static; order: -1; }
  .col-info { order: 0; }
  .phone { height: 560px; }
  .bar-back span { display: none; }
}
@media (max-width: 480px) {
  .meme { width: 220px; }
  .meme-emoji { font-size: 76px; }
  .meme-top, .meme-bottom { font-size: 18px; }
  .msg { max-width: 90%; }
}
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation: none !important; transition-duration: 0s !important; }
}
