:root {
  --bg: var(--tg-theme-bg-color, #ffffff);
  --text: var(--tg-theme-text-color, #000000);
  --hint: var(--tg-theme-hint-color, #999999);
  --link: var(--tg-theme-link-color, #2481cc);
  --btn-bg: var(--tg-theme-button-color, #2481cc);
  --btn-text: var(--tg-theme-button-text-color, #ffffff);
  --secondary-bg: var(--tg-theme-secondary-bg-color, #f1f1f1);
}

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

.setting-textarea,
.bl-search,
.blacklist-add input {
  -webkit-user-select: text;
  user-select: text;
}

html {
  scrollbar-width: thin;
  scrollbar-color: rgba(120, 120, 128, 0.3) transparent;
}

html::-webkit-scrollbar {
  width: 4px;
}

html::-webkit-scrollbar-track {
  background: transparent;
}

html::-webkit-scrollbar-thumb {
  background: rgba(120, 120, 128, 0.3);
  border-radius: 4px;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, sans-serif;
  font-size: 15px;
  line-height: 1.5;
  min-height: 100vh;
  position: relative;
  padding-top: 28px;
}


.screen {
  padding: 16px;
  max-width: 600px;
  margin: 0 auto;
}

.screen--subscreen {
  padding-top: 0;
}

/* ── Header ───────────────────────────────────────── */
.header {
  position: relative;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  margin-bottom: 24px;
}

.back-btn {
  position: absolute;
  left: 0;
  top: 0;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--link);
  font-size: 24px;
  padding: 0 4px;
  line-height: 1;
}

.back-btn:hover {
  opacity: 0.7;
}

.header-right {
  position: absolute;
  right: 0;
  top: 50%;
  transform: translateY(-50%);
  display: flex;
  align-items: center;
  gap: 4px;
}

.bl-sort-btn {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--link);
  font-size: 20px;
  padding: 0 4px;
  line-height: 1;
}

.bl-sort-btn:disabled {
  color: var(--hint);
  opacity: 0.4;
  cursor: default;
}

.bl-sort-btn:hover {
  opacity: 0.7;
}

.chat-info {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

.chat-avatar {
  width: 96px;
  height: 96px;
  border-radius: 50%;
  background: var(--secondary-bg);
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: transform 0.2s ease;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

.chat-avatar:hover {
  transform: scale(1.08);
}

.chat-avatar:active {
  transform: scale(0.96);
}

.chat-avatar__img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.chat-avatar__fallback {
  font-size: 38px;
  font-weight: 700;
  color: #fff;
}

.header-title {
  font-size: 22px;
  font-weight: 700;
  text-align: center;
}

.bot-status {
  position: absolute;
  top: 16px;
  right: 16px;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
  color: var(--hint);
  z-index: 100;
}

.bot-status__dot {
  width: 7px;
  height: 7px;
  background: var(--hint);
  border-radius: 50%;
  flex-shrink: 0;
  background: var(--hint);
}

.bot-status--online .bot-status__dot {
  background: #34c759;
}

.bot-status--offline .bot-status__dot {
  background: #ff3b30;
}

.version-label {
  text-align: center;
  font-size: 13px;
  font-weight: 600;
  color: var(--hint);
  padding: 12px 16px 24px;
}

.header-title.skel {
  height: 33px;
  font-size: 0;
  border-radius: 6px;
}

.header-member-count {
  font-size: 13px;
  color: var(--hint);
  text-align: center;
  margin-top: -12px;
}

.header-member-count.skel {
  height: 10px;
  font-size: 0;
  border-radius: 4px;
  min-width: 120px;
  margin-top: -3px;
}

.chat-info__avatar-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.chat-avatar--mini {
  width: 44px;
  height: 44px;
  opacity: 0.45;
  flex-shrink: 0;
  transition: transform 0.2s ease, opacity 0.2s ease;
}

.chat-avatar--mini:hover {
  opacity: 0.75;
}

.chat-avatar--mini .chat-avatar__fallback {
  font-size: 18px;
}


/* ── Stats grid ───────────────────────────────────── */
.stats-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.stat-tile {
  background: var(--secondary-bg);
  border-radius: 12px;
  padding: 12px 14px 10px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
  overflow: hidden;
}

.stat-tile__label {
  font-size: 11px;
  font-weight: 500;
  color: var(--hint);
  line-height: 1.2;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.stat-tile__label--nav {
  cursor: pointer;
}

.stat-tile__meta {
  display: flex;
  align-items: baseline;
  gap: 5px;
  flex-wrap: wrap;
}

.stat-tile__value {
  display: inline-block;
  font-size: 24px;
  font-weight: 700;
  line-height: 1;
  letter-spacing: -0.5px;
}

.stat-tile__pct {
  font-size: 12px;
  font-weight: 600;
  line-height: 1;
}

.stat-tile__graph {
  height: 36px;
  margin: 0 -4px -2px;
  overflow: hidden;
  touch-action: none;
}

.stat-tile__value.skel {
  display: inline-block;
  font-size: 0;
  height: 24px;
  min-height: 0;
  width: 64px;
}

.stat-tile .skel {
  background: linear-gradient(
    90deg,
    color-mix(in srgb, var(--hint) 20%, var(--secondary-bg)) 25%,
    color-mix(in srgb, var(--hint) 30%, var(--secondary-bg)) 50%,
    color-mix(in srgb, var(--hint) 20%, var(--secondary-bg)) 75%
  );
  background-size: 200% 100%;
}

/* ── Stats detail screen ──────────────────────────── */
.stats-overview-card {
  background: var(--secondary-bg);
  border-radius: 14px;
  padding: 14px 16px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px 12px;
  box-shadow: 0 2px 12px rgba(0,0,0,0.07);
}

.stats-overview-item {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.stats-overview-item__row {
  display: flex;
  align-items: baseline;
  gap: 5px;
  flex-wrap: wrap;
}

.stats-overview-item__value {
  font-size: 20px;
  font-weight: 700;
  line-height: 1;
}

.stats-overview-item__delta {
  font-size: 12px;
  font-weight: 600;
  line-height: 1;
}

.stats-overview-item__label {
  font-size: 11px;
  color: var(--hint);
  line-height: 1.3;
}

.stats-overview-title {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
}

.stats-overview-title__range {
  font-size: 11px;
  color: var(--hint);
  font-weight: 400;
}

.stats-detail-section {
  margin-bottom: 20px;
}

.stats-detail-section__title {
  font-size: 13px;
  font-weight: 600;
  color: var(--hint);
  letter-spacing: 0.03em;
  text-transform: uppercase;
  margin-bottom: 8px;
  padding: 0 2px;
}

.stats-detail-card {
  background: var(--secondary-bg);
  border-radius: 14px;
  padding: 14px 14px 10px;
  overflow: hidden;
  box-shadow: 0 2px 12px rgba(0,0,0,0.07);
}

.stats-detail-card__header {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin-bottom: 10px;
}

.stats-detail-card__count-label {
  font-size: 11px;
  color: var(--hint);
  line-height: 1.2;
  flex: 1;
}
.stats-detail-card__value {
  font-size: 28px;
  font-weight: 700;
  line-height: 1;
  letter-spacing: -0.5px;
}

.stats-detail-card__pct {
  font-size: 14px;
  font-weight: 600;
  line-height: 1;
}

.stats-detail-card__sep {
  font-size: 20px;
  font-weight: 300;
  color: var(--hint);
  margin: 0 4px;
}

.stats-detail-range {
  text-align: center;
  font-size: 12px;
  color: var(--hint);
  white-space: nowrap;
  margin-bottom: 6px;
}

.stats-detail-chart {
  position: relative;
  margin: 0 -14px;
  overflow: visible;
  touch-action: none;
}
.stats-detail-yaxis {
  position: absolute;
  top: 0;
  left: 0;
  pointer-events: none;
}
.stats-detail-yaxis__label {
  position: absolute;
  left: 22px;
  font-size: 11px;
  color: rgba(128,128,128,0.65);
  line-height: 1;
  white-space: nowrap;
  transform: translateY(-100%);
}
.chart-tooltip {
  position: absolute;
  top: 8px;
  background: color-mix(in srgb, var(--hint) 12%, var(--secondary-bg));
  border-radius: 8px;
  padding: 6px 10px;
  pointer-events: none;
  white-space: nowrap;
  z-index: 10;
}
.chart-tooltip--dual {
  min-width: 180px;
}
.chart-tooltip__date {
  font-size: 11px;
  font-weight: 700;
  color: var(--hint);
  margin-bottom: 4px;
}
.chart-tooltip__row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.chart-tooltip__label {
  font-size: 12px;
  color: var(--hint);
}
.chart-tooltip__value {
  font-size: 16px;
  font-weight: 700;
  color: var(--link);
}
.stats-detail-xaxis {
  position: relative;
  height: 22px;
  margin: 2px -14px 0;
}
.stats-detail-xaxis__label {
  position: absolute;
  top: 0;
  font-size: 11px;
  color: rgba(128,128,128,0.65);
  white-space: nowrap;
}

/* ── Range selector ───────────────────────────────── */
.srange {
  position: relative;
  height: 46px;
  margin-top: 10px;
  overflow: visible;
  border-radius: 8px;
  background: color-mix(in srgb, var(--hint) 10%, var(--secondary-bg));
  touch-action: none;
}

/* Sparkline SVG — bottom layer */
.srange__bg {
  position: absolute;
  inset: 0;
  z-index: 1;
  pointer-events: none;
}

/* Semi-transparent dim overlay outside the window — above SVG */
.srange__mask {
  position: absolute;
  top: 0;
  left: 0;
  height: 100%;
  background: var(--secondary-bg);
  opacity: 0.7;
  pointer-events: none;
  z-index: 2;
}

.srange__mask--right {
  left: auto;
  right: 0;
}

/* Window frame — overhangs 2px above/below so handles extend outside srange.
   The gradient fills the 2px overhang zones with srange-bg so the rounded
   handle corners don't expose the page background at the corners.
   Middle of the window stays transparent so the chart shows through. */
.srange__window {
  position: absolute;
  top: -2px;
  bottom: -2px;
  z-index: 3;
  background: linear-gradient(
    to bottom,
    color-mix(in srgb, var(--hint) 10%, var(--secondary-bg)) 2px,
    transparent 2px,
    transparent calc(100% - 2px),
    color-mix(in srgb, var(--hint) 10%, var(--secondary-bg)) calc(100% - 2px)
  );
  border-radius: 6px;
  overflow: hidden;
  display: flex;
  align-items: stretch;
  justify-content: space-between;
}

/* Lines only between the handles — avoids sticking out past rounded corners */
.srange__window::before,
.srange__window::after {
  content: '';
  position: absolute;
  left: 11px;
  right: 11px;
  height: 1px;
  background: color-mix(in srgb, var(--hint) 35%, var(--secondary-bg));
  pointer-events: none;
}

.srange__window::before { top: 0; }
.srange__window::after  { bottom: 0; }

/* Handles */
.srange__handle {
  width: 11px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  font-weight: 700;
  color: var(--bg);
  background: color-mix(in srgb, var(--hint) 35%, var(--secondary-bg));
  flex-shrink: 0;
  cursor: col-resize;
  user-select: none;
}

.srange__handle--left {
  border-radius: 6px 0 0 6px;
}

.srange__handle--right {
  border-radius: 0 6px 6px 0;
}

/* ── Settings form ────────────────────────────────── */
.settings-section {
  margin-bottom: 24px;
}

.section-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--hint);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 10px;
}

.setting-row.skel--tall {
  padding-top: 25px;
  padding-bottom: 25px;
}

.section-title--nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
}

.section-title__chevron {
  font-size: 20px;
  line-height: 1;
  opacity: 0.5;
}


.section-title > .skel {
  display: inline-block;
  height: 14px;
  line-height: 14px;
  overflow: hidden;
  border-radius: 4px;
  vertical-align: middle;
}

.how-it-works {
  font-size: 12px;
  color: var(--hint);
  background: var(--secondary-bg);
  border-radius: 12px 12px 0 0;
  padding: 5px 16px 4px 10px;
  margin-bottom: 0;
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
}

.how-it-works:active {
  opacity: 0.6;
}

.how-it-works__icon {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: rgba(120, 120, 128, 0.2);
  color: var(--hint);
  font-size: 11px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.how-it-works + .setting-row {
  border-radius: 0 0 12px 12px;
  border-top: 1px solid rgba(120, 120, 128, 0.2);
}

.setting-row {
  background: var(--secondary-bg);
  border-radius: 12px;
  padding: 12px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
  overflow: visible;
  opacity: 1;
  transition: opacity 0.2s ease;
}

.setting-label {
  flex: 1;
  min-width: 0;
}

.setting-label__name {
  font-size: 14px;
  font-weight: 500;
}

.setting-label__hint {
  font-size: 12px;
  color: var(--hint);
  margin-top: 1px;
}

.setting-input-wrap {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.setting-input-wrap input[type="number"] {
  width: 72px;
  padding: 6px 8px;
  border-radius: 8px;
  border: 1.5px solid var(--hint);
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  text-align: right;
  outline: none;
  transition: border-color 0.15s;
}

.setting-input-wrap input[type="number"]:focus {
  border-color: var(--link);
}

.unit-label {
  font-size: 12px;
  color: var(--hint);
  white-space: nowrap;
}

/* ── Experimental setting ─────────────────────────── */
.experimental-wrap {
  position: relative;
  margin: 0 0 8px 0;
  /* Tweak these to control the dashed border appearance */
  --exp-color: #f9a400;
  --exp-dash: 14;
  --exp-gap: 12;
  --exp-offset: -8;
}

.experimental-wrap .setting-row {
  margin-bottom: 0;
}

.experimental-label {
  position: absolute;
  top: 0;
  left: 20px;
  z-index: 1;
  padding: 0 4px;
  color: var(--exp-color);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  line-height: 1;
}

/* ── Custom slider ────────────────────────────────── */
.setting-row--segmented {
  flex-direction: column;
  align-items: flex-start;
  gap: 8px;
}

.setting-row--toggle-slider {
  flex-wrap: wrap;
  row-gap: 0;
}

.setting-row--toggle-slider > .setting-label {
  flex: 1;
}

.setting-row--toggle-slider > .setting-input-wrap {
  flex-shrink: 0;
}

.toggle-slider-collapse {
  display: grid;
  grid-template-rows: 1fr;
  transition: grid-template-rows 0.28s ease, opacity 0.22s ease;
  width: 100%;
  opacity: 1;
}

.toggle-slider-collapse.collapsed {
  grid-template-rows: 0fr;
  opacity: 0;
}

.toggle-slider-inner {
  overflow: hidden;
  padding: 12px 0 4px;
  transition: padding 0.28s ease;
}

.toggle-slider-collapse.collapsed .toggle-slider-inner {
  padding: 0;
}

.deps-collapse {
  width: 100%;
}

.toggle-slider-divider {
  width: 100%;
  height: 1px;
  background: rgba(120, 120, 128, 0.2);
  margin: 0 0 10px;
}

.toggle-slider-section {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.slider-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
}

.setting-row--segmented .setting-input-wrap {
  width: 100%;
}

.slider-wrap {
  display: flex;
  align-items: center;
  gap: 14px;
  width: 100%;
}

.slider-track-wrap {
  width: 100%;
  height: 20px;
  display: flex;
  align-items: center;
  overflow: visible;
}

.custom-range {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 4px;
  border-radius: 2px;
  outline: none;
  cursor: pointer;
  overflow: visible;
  background: linear-gradient(
    to right,
    var(--btn-bg) 0%,
    var(--btn-bg) var(--fill, 0%),
    rgba(120,120,128,0.2) var(--fill, 0%),
    rgba(120,120,128,0.2) 100%
  );
}

.custom-range::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 2px 8px rgba(0,0,0,0.18), 0 0 0 0.5px rgba(0,0,0,0.06);
  cursor: pointer;
  transform: scale(var(--thumb-scale, 1));
  transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.custom-range::-moz-range-thumb {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: #fff;
  border: none;
  box-shadow: 0 2px 8px rgba(0,0,0,0.18);
  cursor: pointer;
  transform: scale(var(--thumb-scale, 1));
  transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.slider-val-label {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
  flex-shrink: 0;
  white-space: nowrap;
}

/* ── Toggle switch ────────────────────────────────── */
.toggle {
  position: relative;
  width: 48px;
  height: 27px;
  flex-shrink: 0;
}

.toggle input {
  opacity: 0;
  width: 0;
  height: 0;
  position: absolute;
}

.toggle-slider {
  position: absolute;
  inset: 0;
  background: var(--hint);
  border-radius: 27px;
  cursor: pointer;
  transition: background 0.2s;
}

.toggle-slider::before {
  content: "";
  position: absolute;
  width: 21px;
  height: 21px;
  border-radius: 50%;
  background: #fff;
  left: 3px;
  top: 3px;
  transition: transform 0.2s;
}

.toggle input:checked + .toggle-slider {
  background: var(--btn-bg);
}

.toggle input:checked + .toggle-slider::before {
  transform: translateX(21px);
}


/* ── Emoji picker ─────────────────────────────────── */
.textarea-wrap {
  position: relative;
  width: 100%;
}

.emoji-trigger {
  position: absolute;
  bottom: 14px;
  right: 14px;
  background: none;
  border: none;
  cursor: pointer;
  line-height: 1;
  color: var(--hint);
  opacity: 0.6;
  transition: opacity 0.15s, color 0.15s;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.emoji-trigger:hover {
  opacity: 1;
  color: var(--link);
}

.emoji-popup {
  position: absolute;
  bottom: calc(100% + 4px);
  right: 0;
  background: var(--secondary-bg);
  border-radius: 12px;
  padding: 8px;
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  width: 220px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.15);
  z-index: 10;
}

.emoji-popup[hidden] {
  display: none;
}

.emoji-btn {
  background: none;
  border: none;
  border-radius: 8px;
  width: 36px;
  height: 36px;
  font-size: 20px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.12s;
  flex-shrink: 0;
  padding: 4px;
}

.emoji-btn:hover {
  background: var(--bg);
}

.emoji-btn__img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.editor-emoji {
  width: 22px;
  height: 22px;
  object-fit: contain;
  vertical-align: middle;
  display: inline-block;
}

/* ── Textarea setting ─────────────────────────────── */
.setting-textarea[data-placeholder].is-empty::before {
  content: attr(data-placeholder);
  color: var(--hint);
  pointer-events: none;
}

.setting-input-wrap .setting-textarea {
  width: 100%;
  padding: 8px 10px 36px 10px;
  border-radius: 10px;
  min-height: 80px;
  max-height: 300px;
  overflow-y: auto;
  border: 1.5px solid var(--hint);
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  font-family: inherit;
  line-height: 1.5;
  outline: none;
  white-space: pre-wrap;
  word-break: break-word;
  transition: border-color 0.15s;
}

.setting-input-wrap .setting-textarea:focus {
  border-color: var(--link);
}

.setting-input-wrap .setting-textarea::-webkit-resizer {
  background: var(--bg);
}

.setting-row--textarea {
  flex-direction: column;
  align-items: flex-start;
  gap: 8px;
}

.setting-row--textarea .setting-input-wrap {
  width: 100%;
}

.toggle-slider-section--textarea {
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: 100%;
}

.toggle-slider-section--textarea .setting-input-wrap {
  width: 100%;
}

/* ── Blacklist nav row ────────────────────────────── */
.bl-nav-row {
  background: var(--secondary-bg);
  border-radius: 12px;
  padding: 14px 16px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  transition: opacity 0.15s;
}

.bl-nav-row:hover { opacity: 0.8; }

.bl-nav-row--inline {
  background: none;
  border-radius: 0;
  padding: 6px 0;
}

.bl-nav-row__label {
  font-size: 15px;
  font-weight: 500;
}

.bl-nav-row__right {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--hint);
}

.bl-nav-row__count { font-size: 14px; line-height: 1; }

.bl-nav-row__arrow { font-size: 18px; line-height: 1; }

/* ── Blacklist ────────────────────────────────────── */
.bl-search {
  width: 100%;
  padding: 9px 12px;
  border-radius: 10px;
  border: 1.5px solid var(--hint);
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  outline: none;
  margin-bottom: 8px;
  transition: border-color 0.15s;
}

.bl-search:focus {
  border-color: var(--link);
}

.blacklist-list {
  display: flex;
  flex-direction: column;
  border-radius: 12px;
  overflow: hidden;
  margin-bottom: 8px;
  background: var(--secondary-bg);
}

.bl-empty {
  padding: 14px 16px;
  font-size: 14px;
  color: var(--hint);
  text-align: center;
}

.phrase-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--bg);
  cursor: pointer;
}

.phrase-row__id,
.phrase-row__text,
.phrase-row__added-by {
  transition: opacity 0.15s ease;
}

.phrase-row:active .phrase-row__id,
.phrase-row:active .phrase-row__text,
.phrase-row:active .phrase-row__added-by,
.phrase-row.is-pressed .phrase-row__id,
.phrase-row.is-pressed .phrase-row__text,
.phrase-row.is-pressed .phrase-row__added-by {
  opacity: 0.5;
}

.phrase-row:last-child {
  border-bottom: none;
}


.phrase-row__id {
  font-size: 12px;
  color: var(--hint);
  flex-shrink: 0;
  min-width: 30px;
}

.phrase-row__body {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.phrase-row__text {
  flex: 1;
  font-size: 14px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.phrase-row__added-by {
  font-size: 11px;
  color: var(--hint);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.phrase-row__remove {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--hint);
  font-size: 18px;
  line-height: 1;
  padding: 0 2px;
  flex-shrink: 0;
  transition: color 0.15s;
}

.phrase-row__remove:hover {
  color: #e53e3e;
}

.phrase-row__edit {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--hint);
  line-height: 1;
  padding: 0 2px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  transition: color 0.15s;
}

.phrase-row__edit:hover,
.phrase-row__edit.is-editing {
  color: var(--link);
}

/* ── Edit modal ───────────────────────────────────── */
@keyframes modal-overlay-in {
  from { opacity: 0; }
  to   { opacity: 1; }
}

@keyframes modal-sheet-in {
  from { transform: translateY(100%) translateZ(0); }
  to   { transform: translateY(0) translateZ(0); }
}

@keyframes modal-overlay-out {
  from { opacity: 1; }
  to   { opacity: 0; }
}

@keyframes modal-sheet-out {
  from { transform: translateY(0); }
  to   { transform: translateY(100%); }
}

.bl-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.3);
  display: flex;
  align-items: flex-end;
  z-index: 1000;
  animation: modal-overlay-in 0.2s ease;
}

[data-theme="light"] .bl-modal-overlay {
  background: rgba(0, 0, 0, 0.15);
}

.bl-modal-overlay.is-closing {
  animation: modal-overlay-out 0.18s ease forwards;
}

.bl-modal {
  width: 100%;
  background: var(--tg-theme-secondary-bg-color, color-mix(in srgb, var(--bg) 85%, #fff 15%));
  border-radius: 20px 20px 0 0;
  padding: 20px 16px 36px;
  will-change: transform;
  animation: modal-sheet-in 0.22s cubic-bezier(0.16, 1, 0.3, 1);
}

.bl-modal-overlay.is-closing .bl-modal {
  animation: modal-sheet-out 0.18s cubic-bezier(0.4, 0, 1, 1) forwards;
}

.bl-modal__title {
  font-size: 16px;
  font-weight: 600;
  text-align: center;
  margin-bottom: 6px;
}

.bl-modal__date {
  font-size: 12px;
  color: var(--hint);
  text-align: center;
  margin-bottom: 12px;
}

.bl-modal__date + .bl-modal__date {
  margin-top: -8px;
}

.bl-modal__input {
  display: block;
  width: 100%;
  background: var(--bg);
  border: none;
  border-radius: 12px;
  padding: 12px 14px;
  margin: 0;
  font-size: 14px;
  color: var(--text);
  outline: none;
  resize: none;
  line-height: 1.5;
  font-family: inherit;
  -webkit-user-select: text;
  user-select: text;
}

.bl-modal__actions {
  display: flex;
  gap: 10px;
  margin-top: 6px;
}

.bl-modal__cancel {
  flex: 1;
  padding: 13px;
  background: var(--bg);
  color: var(--text);
  border: none;
  border-radius: 12px;
  font-size: 15px;
  cursor: pointer;
  transition: opacity 0.15s;
}

.bl-modal__cancel:active { opacity: 0.6; }

.bl-modal__save {
  flex: 1;
  padding: 13px;
  background: var(--btn-bg);
  color: var(--btn-text);
  border: none;
  border-radius: 12px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.15s;
}

.bl-modal__save:active { opacity: 0.6; }

.bl-modal__save:disabled,
.bl-modal__cancel:disabled {
  opacity: 0.45;
  cursor: default;
  transition: none;
}

.bl-modal__hint {
  font-size: 12px;
  color: #e53e3e;
  min-height: 0;
}

.bl-modal__preview {
  background: var(--bg);
  border-radius: 10px;
  padding: 10px 14px;
  font-size: 14px;
  color: var(--hint);
  word-break: break-word;
  line-height: 1.45;
  margin-bottom: 2px;
  max-height: 200px;
  overflow-y: auto;
}

.bl-modal__delete {
  flex: 1;
  padding: 13px;
  background: rgba(255, 59, 48, 0.12);
  color: rgb(255, 59, 48);
  border: none;
  border-radius: 12px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.15s;
}

.bl-modal__delete:active { opacity: 0.6; }

.bl-modal__delete:disabled {
  opacity: 0.45;
  cursor: default;
}

.bl-modal__approve {
  flex: 1;
  padding: 13px;
  background: rgba(76, 175, 80, 0.13);
  color: rgb(56, 142, 60);
  border: none;
  border-radius: 12px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.15s;
}
[data-theme="dark"] .bl-modal__approve {
  color: rgb(102, 187, 106);
}
.bl-modal__approve:active { opacity: 0.6; }
.bl-modal__approve:disabled {
  opacity: 0.45;
  cursor: default;
}

/* Pagination lives inside .blacklist-list as the last row */
.bl-pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding: 8px 16px;
  border-top: 1px solid var(--bg);
}

.bl-page-btn {
  width: 32px;
  height: 32px;
  background: var(--bg);
  border: none;
  border-radius: 8px;
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
  color: var(--text);
  transition: opacity 0.15s;
  flex-shrink: 0;
}

.bl-page-btn:disabled {
  opacity: 0.25;
  cursor: default;
}

.bl-page-btn:not(:disabled):active {
  opacity: 0.55;
}

.bl-page-info {
  font-size: 13px;
  color: var(--hint);
  min-width: 44px;
  text-align: center;
}

/* Add-phrase row */
.blacklist-add {
  margin-top: 8px;
}

.bl-add__row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.bl-add__hint {
  height: 16px;
  font-size: 12px;
  color: #e53e3e;
  margin-top: 4px;
  padding-left: 2px;
}

.blacklist-add input {
  flex: 1;
  min-width: 0;
  padding: 9px 12px;
  border-radius: 10px;
  border: 1.5px solid var(--hint);
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  outline: none;
  transition: border-color 0.15s;
}

.blacklist-add input:focus {
  border-color: var(--link);
}

.blacklist-add input::placeholder {
  color: var(--hint);
}

.blacklist-add button {
  flex-shrink: 0;
  padding: 9px 16px;
  background: var(--btn-bg);
  color: var(--btn-text);
  border: none;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.15s;
  white-space: nowrap;
}

.blacklist-add button:active {
  opacity: 0.7;
}

.blacklist-add button:disabled {
  opacity: 0.45;
  cursor: default;
}

.blacklist-list .phrase-row:nth-child(even):not(.skel) {
  background: color-mix(in srgb, var(--secondary-bg) 97%, white 3%);
}

[data-theme="light"] .blacklist-list .phrase-row:nth-child(even):not(.skel) {
  background: color-mix(in srgb, var(--secondary-bg) 97%, black 3%);
}

/* ── Banned users ─────────────────────────────────── */
.ban-date-sep {
  font-size: 15px;
  font-weight: 600;
  color: var(--hint);
  padding: 8px 4px 6px;
  background: var(--bg);
  letter-spacing: 0.03em;
}

.ban-date-sep:first-child {
  padding-top: 2px;
}

.ban-date-sep__skel {
  display: inline-block;
  width: 90px;
  border-radius: 4px;
  height: 12px;
  font-size: 0;
  vertical-align: middle;
}

.ban-load-more {
  display: block;
  width: 100%;
  margin-top: 12px;
  padding: 12px;
  background: var(--secondary-bg);
  color: var(--link);
  border: none;
  border-radius: 12px;
  font-size: 15px;
  font-weight: 500;
  cursor: pointer;
  transition: opacity 0.15s;
}

.ban-load-more:active { opacity: 0.6; }
.ban-load-more:disabled { opacity: 0.4; cursor: default; }

.ban-row.ban-row--hidden { display: none; }

.ban-group-toggle {
  display: block;
  width: 100%;
  padding: 9px 12px;
  background: none;
  border: none;
  border-top: 1px solid color-mix(in srgb, var(--hint) 15%, transparent);
  color: var(--link);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  text-align: center;
  transition: opacity 0.15s;
}

.ban-group-toggle:active { opacity: 0.6; }

.ban-list {
  display: flex;
  flex-direction: column;
  border-radius: 12px;
  overflow: hidden;
  margin-bottom: 8px;
  background: var(--secondary-bg);
}

.ban-list .ban-row:nth-child(even):not(.skel) {
  background: color-mix(in srgb, var(--secondary-bg) 97%, white 3%);
}

[data-theme="light"] .ban-list .ban-row:nth-child(even):not(.skel) {
  background: color-mix(in srgb, var(--secondary-bg) 97%, black 3%);
}

.ban-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--bg);
  cursor: pointer;
  transition: opacity 0.15s;
}

.ban-row:last-child {
  border-bottom: none;
}

.ban-row:active,
.ban-row.is-pressed {
  opacity: 0.5;
}

.ban-avatar {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: var(--bg);
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

.ban-avatar__img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.ban-avatar__fallback {
  font-size: 15px;
  font-weight: 700;
  color: #fff;
}

.ban-modal__avatar-wrap {
  display: flex;
  justify-content: center;
  margin-bottom: 10px;
}

.ban-avatar--lg {
  width: 72px;
  height: 72px;
}

.ban-avatar--lg .ban-avatar__fallback {
  font-size: 28px;
}

.ban-row__info {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.ban-row__name {
  font-size: 14px;
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ban-row__username {
  font-size: 13px;
  color: var(--hint);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ban-row__deleted {
  font-size: 0.85em;
  color: var(--hint);
  font-weight: normal;
}

.ban-row__meta {
  font-size: 12px;
  color: var(--hint);
}

.ban-row__arrow {
  font-size: 18px;
  color: var(--hint);
  flex-shrink: 0;
}

.ban-modal__detail {
  background: var(--secondary-bg);
  border-radius: 10px;
  margin-bottom: 8px;
  overflow: hidden;
}

.ban-modal__detail-row {
  font-size: 14px;
  color: var(--hint);
  padding: 10px 14px;
}

.ban-modal__value {
  color: color-mix(in srgb, var(--text) 60%, var(--hint) 40%);
  font-weight: 400;
}

.ban-modal__phrase {
  color: var(--hint);
  word-break: break-word;
}

.ban-modal__sep {
  height: 1px;
  background: var(--bg);
  margin: 0;
}

/* ── Unban request message history ───────────────── */
.unban-msg {
  padding: 6px 0;
  border-bottom: 1px solid var(--bg);
}
.unban-msg:last-child {
  border-bottom: none;
}
.unban-msg__date {
  display: block;
  font-size: 11px;
  color: var(--tg-theme-hint-color, #999);
  margin-bottom: 2px;
}
.unban-msg__text {
  font-size: 13px;
  color: var(--tg-theme-text-color, #000);
  word-break: break-word;
  white-space: pre-wrap;
}

/* ── Feedback messages ────────────────────────────── */
.toast {
  padding: 10px 14px;
  border-radius: 10px;
  font-size: 14px;
  margin-bottom: 12px;
  display: none;
}

.toast.show {
  display: block;
}

.toast--success {
  background: #d4edda;
  color: #155724;
}

.toast--error {
  background: #f8d7da;
  color: #721c24;
}

.error-text {
  color: #e53e3e;
  font-size: 14px;
  text-align: center;
  padding: 20px 0;
}

/* ── Skeleton ─────────────────────────────────────── */
@keyframes shimmer {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

.skel {
  background: linear-gradient(
    90deg,
    var(--secondary-bg) 25%,
    color-mix(in srgb, var(--hint) 20%, var(--secondary-bg)) 50%,
    var(--secondary-bg) 75%
  );
  background-size: 200% 100%;
  animation: shimmer 2.2s ease-in-out infinite;
  border-radius: 6px;
  flex-shrink: 0;
  min-height: 1lh;
  color: transparent !important;
  pointer-events: none;
  user-select: none;
}

.skel--circle { border-radius: 50%; }
.skel--round  { border-radius: 12px; }
.skel--thin { min-height: 0; height: 0.55lh; }

.skel--inner {
  background: linear-gradient(
    90deg,
    color-mix(in srgb, var(--hint) 30%, var(--secondary-bg)) 25%,
    color-mix(in srgb, var(--hint) 45%, var(--secondary-bg)) 50%,
    color-mix(in srgb, var(--hint) 30%, var(--secondary-bg)) 75%
  );
  background-size: 200% 100%;
}
.skel--bar {
  min-height: 0;
  border-radius: 3px;
  background: linear-gradient(
    90deg,
    color-mix(in srgb, var(--hint) 20%, var(--secondary-bg)) 25%,
    color-mix(in srgb, var(--hint) 30%, var(--secondary-bg)) 50%,
    color-mix(in srgb, var(--hint) 20%, var(--secondary-bg)) 75%
  );
  background-size: 200% 100%;
}

/* ── Blacklist batch mode ─────────────────────────── */
.bl-select-btn {
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  cursor: pointer;
  color: var(--link);
  font-size: 16px;
  padding: 0 4px;
  line-height: 1;
  transition: opacity 0.15s;
}

.bl-select-btn:active { opacity: 0.6; }
.bl-select-btn.is-active { color: var(--hint); }

.bl-batch-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  background: var(--secondary-bg);
  border-radius: 20px 20px 0 0;
  border-top: 1px solid
    color-mix(in srgb, var(--hint) 20%, var(--secondary-bg));
  transform: translateY(100%);
  transition: transform 0.25s ease;
  z-index: 10;
}

.bl-batch-bar.is-visible { transform: translateY(0); }

.bl-batch-count {
  flex: 1;
  font-size: 14px;
  color: var(--hint);
}

.bl-batch-delete {
  background: #e53e3e;
  color: #fff;
  border: none;
  border-radius: 10px;
  padding: 8px 16px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  flex-shrink: 0;
  transition: opacity 0.15s, background-color 0.15s;
}

.bl-batch-delete:active { opacity: 0.7; }
.bl-batch-delete:disabled {
  background: color-mix(in srgb, #e53e3e 45%, var(--secondary-bg));
  cursor: default;
}

.phrase-row__check {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  border: 2px solid var(--hint);
  flex-shrink: 0;
  margin-left: auto;
  position: relative;
  transition: border-color 0.15s, background 0.15s;
}

.phrase-row__check.is-checked {
  border-color: var(--link);
  background: var(--link);
}

.phrase-row__check.is-checked::after {
  content: '';
  position: absolute;
  top: 3px;
  left: 6px;
  width: 5px;
  height: 9px;
  border: 2px solid #fff;
  border-top: none;
  border-left: none;
  transform: rotate(45deg);
}

.blacklist-list .phrase-row.is-selected,
.blacklist-list .phrase-row.is-selected:nth-child(even),
[data-theme="light"] .blacklist-list .phrase-row.is-selected,
[data-theme="light"] .blacklist-list .phrase-row.is-selected:nth-child(even) {
  background: color-mix(in srgb, var(--link) 15%, var(--secondary-bg));
}

