/* Qorgon v11.3 — rich Telegram text, reliable mouse actions and compact audio. */

/* Telegram rich-text entities */
.telegram-rich-text strong { font-weight: 800; }
.telegram-rich-text em { font-style: italic; }
.telegram-rich-text u { text-underline-offset: 2px; }
.telegram-rich-text s { opacity: .8; }
.telegram-pre-entity {
  display: block;
  margin: 3px 0;
  padding: 7px 9px;
  border-radius: 8px;
  background: color-mix(in srgb, var(--surface-2) 90%, #000 10%);
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  white-space: pre-wrap;
}
.telegram-blockquote-entity {
  display: inline-block;
  margin: 2px 0;
  padding-left: 8px;
  border-left: 2px solid var(--teal);
}
.telegram-spoiler {
  border-radius: 4px;
  color: transparent;
  background: color-mix(in srgb, var(--text) 28%, transparent);
  cursor: pointer;
  user-select: none;
}
.telegram-spoiler:hover,
.telegram-spoiler:focus,
.telegram-spoiler:active {
  color: inherit;
  background: color-mix(in srgb, var(--surface-2) 78%, transparent);
}
.telegram-entity-token { color: var(--blue); font-weight: 650; }
.telegram-custom-emoji { display: inline-block; }

/* Reply cards never overlap the author line. */
.main-panel.group-like .message-content { gap: 3px; }
.main-panel.group-like .message-author-line {
  margin: 0 0 2px;
  line-height: 1.15;
}
.reference-card { margin-top: 1px; }
.reference-card-top {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: baseline;
  gap: 5px;
}
.reply-card .reference-card-top { grid-template-columns: auto minmax(0, 1fr); }
.reply-card .reference-preview { margin-top: 2px; }

/* Composer edit/reply context is a two-column compact card instead of one
   long text line that can cover the username. */
.composer-context:not([hidden]) {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: 4px 8px;
}
.composer-context-label {
  color: var(--blue);
  font-size: 11px;
  font-weight: 800;
}
.composer-context-preview {
  min-width: 0;
  overflow: hidden;
  color: var(--muted);
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Message-level audio: Telegram-like play state and hairline progress. */
.telegram-audio-trigger {
  position: relative;
  grid-template-columns: 34px minmax(0, 1fr) auto !important;
  grid-template-rows: auto 3px;
  column-gap: 9px;
  row-gap: 4px;
  width: min(410px, 72vw);
  padding: 7px 9px 5px !important;
  overflow: hidden;
}
.telegram-audio-icon {
  grid-row: 1 / 3;
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  color: #fff;
  background: linear-gradient(135deg, var(--blue), var(--teal));
}
.telegram-audio-icon svg { width: 17px; height: 17px; }
.telegram-audio-copy { display: grid; min-width: 0; gap: 1px; text-align: left; }
.telegram-audio-copy strong,
.telegram-audio-copy small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.telegram-audio-copy small { color: var(--muted); }
.telegram-audio-time { color: var(--muted); font-size: 10px; font-variant-numeric: tabular-nums; }
.telegram-audio-track {
  grid-column: 2 / 4;
  position: relative;
  display: block;
  height: 2px;
  border-radius: 99px;
  background: color-mix(in srgb, var(--muted) 22%, transparent);
  overflow: hidden;
}
.telegram-audio-track > span {
  display: block;
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: var(--teal);
  transition: width 120ms linear;
}
.telegram-audio-trigger.active { border-color: color-mix(in srgb, var(--teal) 55%, var(--line)); }

/* Topbar audio player: compact controls and a 2px seek line. */
.qorgon-global-audio {
  position: relative;
  grid-template-columns: repeat(3, 24px) minmax(120px, 220px) auto minmax(100px, 1fr) auto auto 24px !important;
  gap: 5px !important;
  width: min(760px, 58vw) !important;
  min-height: 34px !important;
  padding: 1px 6px !important;
}
.qorgon-audio-icon {
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  padding: 0;
  color: var(--muted);
  border: 0;
  border-radius: 50%;
  background: transparent;
}
.qorgon-audio-icon:hover,
.qorgon-audio-icon.active { color: var(--teal); background: color-mix(in srgb, var(--teal) 12%, transparent); }
.qorgon-audio-icon svg { width: 14px; height: 14px; }
.qorgon-audio-play { color: var(--teal); }
.qorgon-audio-copy strong { font-size: 10.5px !important; }
.qorgon-audio-copy small { font-size: 8.5px !important; }
.qorgon-audio-time { font-size: 8.5px !important; }
.qorgon-audio-modes { display: flex; align-items: center; gap: 1px; }
.qorgon-audio-seek {
  height: 10px;
  margin: 0;
  appearance: none;
  background: transparent;
  cursor: pointer;
}
.qorgon-audio-seek::-webkit-slider-runnable-track {
  height: 2px;
  border-radius: 99px;
  background: linear-gradient(to right, var(--teal) 0 var(--audio-progress, 0%), color-mix(in srgb, var(--muted) 30%, transparent) var(--audio-progress, 0%) 100%);
}
.qorgon-audio-seek::-webkit-slider-thumb {
  width: 7px;
  height: 7px;
  margin-top: -2.5px;
  appearance: none;
  border: 0;
  border-radius: 50%;
  background: var(--teal);
}
.qorgon-audio-seek::-moz-range-track {
  height: 2px;
  border-radius: 99px;
  background: color-mix(in srgb, var(--muted) 30%, transparent);
}
.qorgon-audio-seek::-moz-range-progress { height: 2px; background: var(--teal); }
.qorgon-audio-seek::-moz-range-thumb { width: 7px; height: 7px; border: 0; border-radius: 50%; background: var(--teal); }
.qorgon-audio-queue {
  position: absolute;
  z-index: 9500;
  top: calc(100% + 7px);
  right: 0;
  width: min(360px, 82vw);
  max-height: 420px;
  padding: 8px;
  overflow-y: auto;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: color-mix(in srgb, var(--surface) 96%, #111 4%);
  box-shadow: 0 18px 50px rgba(0,0,0,.25);
}
.qorgon-audio-queue[hidden] { display: none; }
.qorgon-audio-queue header { display: flex; justify-content: space-between; gap: 10px; padding: 3px 5px 7px; }
.qorgon-audio-queue header small { color: var(--muted); }
.qorgon-audio-queue-row {
  display: grid;
  grid-template-columns: 26px minmax(0, 1fr);
  align-items: center;
  gap: 7px;
  width: 100%;
  padding: 6px;
  text-align: left;
  border-radius: 8px;
  background: transparent;
}
.qorgon-audio-queue-row:hover,
.qorgon-audio-queue-row.active { background: color-mix(in srgb, var(--teal) 12%, transparent); }
.qorgon-audio-queue-row > span { display: grid; min-width: 0; }
.qorgon-audio-queue-row strong,
.qorgon-audio-queue-row small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.qorgon-audio-queue-row small { color: var(--muted); }

/* Context menu remains clickable after scrolling and does not inherit message
   drag transforms. */
.message-menu { pointer-events: auto; isolation: isolate; }
.message-menu button { pointer-events: auto; }

@media (max-width: 1100px) {
  .qorgon-audio-modes { display: none; }
  .qorgon-global-audio { grid-template-columns: repeat(3, 24px) minmax(80px, 1fr) auto minmax(70px, 1fr) auto 24px !important; }
}
