:root {
  color-scheme: dark;
  --bg: #0b0d12;
  --panel: #12151d;
  --panel-2: #171b25;
  --line: #262b37;
  --text: #f5f7fb;
  --muted: #9098aa;
  --accent: #6f5cff;
  --accent-soft: rgba(111,92,255,.15);
  --green: #35d08b;
  --telegram-blue: #4d9fe6;
  --telegram-own: #2b5278;
  --telegram-other: #182533;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

body { overscroll-behavior: none; }

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

[hidden] { display: none !important; }

.landing {
  width: min(100%, 480px);
  min-height: 100dvh;
  margin: auto;
  padding: max(28px, env(safe-area-inset-top)) 22px calc(32px + env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  justify-content: center;
  overflow-x: hidden;
}

.brand-hero {
  width: min(210px, 54vw);
  margin: 0 auto 22px;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  overflow: visible;
  line-height: 0;
  pointer-events: none;
}

.brand-hero img {
  display: block;
  width: 100%;
  height: auto;
  object-fit: contain;
  pointer-events: none;
  -webkit-user-drag: none;
  user-drag: none;
}

.landing h1 { margin: 0; font-size: 40px; letter-spacing: -.04em; }
.landing > p { color: var(--muted); margin: 10px 0 30px; }

.primary-button, .secondary-button, .global-button {
  border: 0;
  border-radius: 15px;
  cursor: pointer;
}

.primary-button {
  width: 100%;
  padding: 15px 18px;
  background: var(--accent);
  font-weight: 700;
}

.global-button {
  width: 100%;
  margin-top: 10px;
  padding: 14px 18px;
  border: 1px solid rgba(111,92,255,.45);
  border-radius: 15px;
  background: var(--accent-soft);
  color: #d9d4ff;
  font-weight: 700;
  cursor: pointer;
}

.global-button:active {
  transform: translateY(1px);
}

.join-box {
  margin-top: 20px;
  padding-top: 20px;
  border-top: 1px solid var(--line);
}

.join-box label {
  display: block;
  color: var(--muted);
  margin-bottom: 9px;
  font-size: 13px;
}

.join-row { display: grid; grid-template-columns: 1fr auto; gap: 9px; }

.join-row input {
  width: 100%;
  min-width: 0;
  padding: 13px 14px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--panel);
  color: var(--text);
  text-transform: uppercase;
  outline: none;
}

.join-row input:focus { border-color: var(--accent); }

.secondary-button {
  padding: 0 18px;
  background: var(--panel-2);
  border: 1px solid var(--line);
}

.app-shell {
  width: min(100%, 720px);
  margin: 0 auto;
  padding: max(14px, env(safe-area-inset-top)) 16px calc(28px + env(safe-area-inset-bottom));
}

.topbar, .sub-header, .chat-header {
  min-height: 58px;
  display: flex;
  align-items: center;
  gap: 12px;
}

.topbar { justify-content: space-between; }

.circle-button {
  width: 44px;
  height: 44px;
  flex: 0 0 44px;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: var(--panel);
  display: grid;
  place-items: center;
  font-size: 28px;
  cursor: pointer;
}

.copy-button { font-size: 18px; }

.topbar-title {
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.topbar-title strong { font-size: 16px; }
.topbar-title span { color: var(--muted); font-size: 11px; letter-spacing: .16em; }

.room-strip {
  margin: 10px 0 16px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--panel);
  display: flex;
  align-items: center;
  gap: 11px;
  color: var(--muted);
  font-size: 13px;
}

.room-strip > span:first-child { color: #b4aaff; font-weight: 700; }

.mini-avatars {
  margin-left: auto;
  display: flex;
  flex-direction: row-reverse;
}

.mini-avatar {
  width: 27px;
  height: 27px;
  border-radius: 50%;
  border: 2px solid var(--panel);
  background: #323849;
  margin-left: -7px;
  display: grid;
  place-items: center;
  overflow: hidden;
  font-size: 9px;
}

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

.now-playing {
  border-radius: 26px;
  padding: 18px;
  background: linear-gradient(180deg, #151925, #10131a);
  border: 1px solid var(--line);
}

.now-playing > img {
  width: min(100%, 430px);
  aspect-ratio: 1;
  object-fit: cover;
  border-radius: 20px;
  display: block;
  margin: 0 auto 20px;
  background: #1e2330;
}

.eyebrow {
  color: var(--muted);
  font-size: 10px;
  letter-spacing: .16em;
  font-weight: 700;
}

.song-copy h2 {
  margin: 6px 0 4px;
  font-size: clamp(24px, 7vw, 34px);
  line-height: 1.08;
  letter-spacing: -.04em;
}

.song-copy p { margin: 0; color: var(--muted); }

.progress-wrap { margin-top: 18px; }

.progress-wrap input {
  width: 100%;
  accent-color: var(--accent);
}

.time-row {
  display: flex;
  justify-content: space-between;
  color: var(--muted);
  font-size: 11px;
}

.listen-button {
  width: 100%;
  margin-top: 14px;
  padding: 13px;
  border: 0;
  border-radius: 14px;
  background: var(--accent);
  font-weight: 700;
  cursor: pointer;
}

.sync-note {
  margin: 10px 0 0;
  color: var(--muted);
  text-align: center;
  font-size: 11px;
}

.action-grid {
  margin-top: 15px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.action-card {
  position: relative;
  min-height: 118px;
  padding: 15px;
  text-align: left;
  border-radius: 20px;
  border: 1px solid var(--line);
  background: var(--panel);
  cursor: pointer;
}

.action-card strong, .action-card small { display: block; }
.action-card strong { margin-top: 11px; }
.action-card small { margin-top: 4px; color: var(--muted); line-height: 1.3; }

.action-icon {
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  border-radius: 10px;
  background: var(--accent-soft);
  color: #b8afff;
  font-size: 20px;
}

.unread-badge {
  position: absolute;
  top: 12px;
  right: 12px;
  min-width: 23px;
  height: 23px;
  padding: 0 7px;
  border-radius: 99px;
  background: var(--telegram-blue);
  display: grid;
  place-items: center;
  font-size: 11px;
}

.queue-section {
  margin-top: 15px;
  padding: 17px;
  border-radius: 22px;
  border: 1px solid var(--line);
  background: var(--panel);
}

.section-title {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 12px;
}

.section-title h3 { margin: 4px 0 0; }
.section-title > span { color: var(--muted); font-size: 12px; }

.queue-list { margin-top: 10px; }

.queue-item {
  display: grid;
  grid-template-columns: 48px minmax(0,1fr) auto;
  gap: 11px;
  align-items: center;
  padding: 10px 0;
  border-top: 1px solid var(--line);
}

.queue-item:first-child { border-top: 0; }

.queue-item img {
  width: 48px;
  height: 48px;
  object-fit: cover;
  border-radius: 9px;
}

.queue-copy { min-width: 0; }
.queue-copy strong, .queue-copy span {
  display: block;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.queue-copy strong { font-size: 13px; }
.queue-copy span { margin-top: 3px; color: var(--muted); font-size: 11px; }
.queue-order { color: var(--muted); font-size: 11px; }

.empty-state { color: var(--muted); padding: 22px 4px; font-size: 13px; }

.full-screen, .chat-screen {
  position: fixed;
  inset: 0;
  z-index: 20;
  background: var(--bg);
}

.full-screen {
  overflow-y: auto;
  padding: max(10px, env(safe-area-inset-top)) 16px calc(25px + env(safe-area-inset-bottom));
}

.sub-header { width: min(100%, 720px); margin: 0 auto; }

.sub-header > div {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.sub-header span { color: var(--muted); font-size: 11px; }

.search-box {
  width: min(100%, 720px);
  margin: 12px auto;
  border: 1px solid var(--line);
  border-radius: 15px;
  background: var(--panel);
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 0 13px;
}

.search-box span { color: var(--muted); font-size: 21px; }

.search-box input {
  width: 100%;
  min-width: 0;
  padding: 13px 0;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--text);
}

.search-results { width: min(100%, 720px); margin: auto; }

.search-result {
  width: 100%;
  display: grid;
  grid-template-columns: 60px minmax(0,1fr) 38px;
  align-items: center;
  gap: 12px;
  padding: 11px 0;
  border: 0;
  border-bottom: 1px solid var(--line);
  background: transparent;
  text-align: left;
  cursor: pointer;
}

.search-result img {
  width: 60px;
  height: 60px;
  object-fit: cover;
  border-radius: 10px;
}

.search-result .search-copy { min-width: 0; }

.search-result strong, .search-result small {
  display: block;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.search-result small { color: var(--muted); margin-top: 4px; }

.search-add {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--accent-soft);
  color: #b6adff;
  font-size: 20px;
}

/* Telegram-like chat */
.chat-screen {
  display: grid;
  grid-template-rows: auto 1fr auto auto auto;
  background:
    radial-gradient(circle at 20% 20%, rgba(54,83,112,.15), transparent 22%),
    #0e1621;
}

.chat-header {
  padding: max(8px, env(safe-area-inset-top)) 12px 8px;
  background: #17212b;
  border-bottom: 1px solid rgba(255,255,255,.05);
}

.chat-header-copy {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.chat-header-copy strong { font-size: 15px; }
.chat-header-copy span { color: #93a4b5; font-size: 11px; }

.messages {
  overflow-y: auto;
  padding: 12px 10px 18px;
  scroll-behavior: smooth;
}

.day-divider {
  width: max-content;
  margin: 10px auto;
  padding: 5px 10px;
  border-radius: 99px;
  background: rgba(30,50,68,.86);
  color: #c7d3df;
  font-size: 10px;
}

.message-row {
  display: flex;
  margin: 4px 0;
  touch-action: pan-y;
}

.message-row.own { justify-content: flex-end; }

.message-bubble {
  position: relative;
  max-width: min(78%, 520px);
  min-width: 78px;
  padding: 7px 9px 5px;
  border-radius: 14px;
  background: var(--telegram-other);
  box-shadow: 0 1px 1px rgba(0,0,0,.18);
  transition: transform .12s ease;
  user-select: none;
  -webkit-user-select: none;
}

.message-row.own .message-bubble {
  background: var(--telegram-own);
  border-bottom-right-radius: 5px;
}

.message-row:not(.own) .message-bubble {
  border-bottom-left-radius: 5px;
}

.sender-name {
  margin-bottom: 3px;
  color: #72b6ef;
  font-size: 11px;
  font-weight: 700;
}

.reply-preview {
  margin-bottom: 5px;
  padding: 5px 7px;
  border-left: 2px solid #67b3ef;
  background: rgba(0,0,0,.13);
  border-radius: 5px;
}

.reply-preview strong {
  display: block;
  color: #78bdf2;
  font-size: 10px;
}

.reply-preview span {
  display: block;
  margin-top: 2px;
  color: #cbd5df;
  font-size: 10px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.message-text {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  font-size: 14px;
  line-height: 1.33;
}

.message-meta {
  float: right;
  margin: 4px 0 0 9px;
  color: rgba(220,231,240,.62);
  font-size: 9px;
  line-height: 1;
}

.message-row.own .message-meta .ticks { color: #78c6f7; }

.swipe-reply-icon {
  position: absolute;
  right: -34px;
  top: 50%;
  transform: translateY(-50%);
  opacity: 0;
  color: #8eb7d4;
  font-size: 20px;
}

.message-row.own .swipe-reply-icon {
  left: -34px;
  right: auto;
}

.typing-indicator {
  padding: 5px 13px;
  color: #8fb1ca;
  font-size: 11px;
  background: #0e1621;
}

.reply-bar {
  min-height: 52px;
  padding: 7px 10px;
  background: #17212b;
  border-top: 1px solid rgba(255,255,255,.05);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.reply-bar > div {
  min-width: 0;
  padding-left: 9px;
  border-left: 2px solid var(--telegram-blue);
}

.reply-bar strong, .reply-bar span { display: block; }
.reply-bar strong { color: #78bdf2; font-size: 11px; }
.reply-bar span {
  max-width: 80vw;
  margin-top: 2px;
  color: #c2ced8;
  font-size: 11px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.reply-bar button {
  border: 0;
  background: transparent;
  color: #8fa1b1;
  font-size: 24px;
}

.composer {
  min-height: 58px;
  padding: 8px 9px calc(8px + env(safe-area-inset-bottom));
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: end;
  gap: 8px;
  background: #17212b;
}

.composer textarea {
  width: 100%;
  max-height: 130px;
  resize: none;
  overflow-y: auto;
  padding: 10px 13px;
  border: 0;
  border-radius: 20px;
  outline: 0;
  background: #242f3d;
  color: #fff;
  line-height: 1.35;
}

.send-button {
  width: 42px;
  height: 42px;
  border: 0;
  border-radius: 50%;
  background: var(--telegram-blue);
  display: grid;
  place-items: center;
  cursor: pointer;
}

.message-menu {
  position: fixed;
  z-index: 50;
  left: 50%;
  bottom: calc(18px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  width: min(92vw, 360px);
  padding: 7px;
  border-radius: 18px;
  background: #202b36;
  box-shadow: 0 18px 50px rgba(0,0,0,.45);
}

.message-menu button {
  width: 100%;
  padding: 12px;
  border: 0;
  border-radius: 11px;
  background: transparent;
  text-align: left;
}

.message-menu button:active { background: rgba(255,255,255,.06); }

.toast {
  position: fixed;
  z-index: 80;
  left: 50%;
  bottom: calc(22px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  max-width: calc(100vw - 30px);
  padding: 10px 13px;
  border-radius: 12px;
  background: #252b36;
  border: 1px solid var(--line);
  box-shadow: 0 14px 40px rgba(0,0,0,.36);
  font-size: 12px;
}

@media (max-width: 520px) {
  .now-playing > img { width: 100%; }
  .action-grid { grid-template-columns: 1fr 1fr; }
  .action-card { min-height: 108px; padding: 13px; }
  .action-card small { font-size: 10px; }
}


/* UI protection: block native selection / callout / image dragging. */
.protected-ui body,
.protected-ui button,
.protected-ui img,
.protected-ui .app-shell,
.protected-ui .landing,
.protected-ui .full-screen,
.protected-ui .chat-screen {
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}

.protected-ui img {
  -webkit-user-drag: none;
  user-drag: none;
}

.protected-ui input,
.protected-ui textarea {
  -webkit-user-select: text;
  user-select: text;
  -webkit-touch-callout: none;
}

.fallback-audio[hidden] {
  display: none !important;
}


/* Static mobile surface: no pinch/double-tap zoom, no native text/image callout. */
html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  touch-action: pan-x pan-y;
}

html,
body,
body *:not(input):not(textarea) {
  -webkit-user-select: none !important;
  user-select: none !important;
  -webkit-touch-callout: none !important;
}

body {
  overflow-x: hidden;
}

img,
svg,
audio,
video {
  -webkit-user-drag: none !important;
  user-drag: none !important;
  -webkit-touch-callout: none !important;
}

img {
  pointer-events: none;
}

button,
.action-card,
.circle-button,
.primary-button,
.secondary-button,
.search-result,
.send-button {
  touch-action: manipulation;
}

input,
textarea {
  -webkit-touch-callout: none !important;
}

/* V4 Telegram-login chat identity */
.message-row:not(.own) {
  align-items: flex-end;
  gap: 7px;
}

.chat-avatar {
  width: 34px;
  height: 34px;
  flex: 0 0 34px;
  border-radius: 50%;
  overflow: hidden;
  display: grid;
  place-items: center;
  background: #2b5278;
  color: #eef6fc;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .2px;
  box-shadow: 0 1px 2px rgba(0,0,0,.24);
  user-select: none;
  -webkit-user-select: none;
}

.chat-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  pointer-events: none;
  -webkit-user-drag: none;
}

.message-row:not(.own) .message-bubble {
  max-width: min(calc(78% - 20px), 520px);
}

.sender-name {
  font-size: 12px;
  line-height: 1.2;
}

.message-meta {
  white-space: nowrap;
}
