/* Ovozqani Mini App — all colors derive from Telegram theme vars so light/dark and any
   custom user theme are honored automatically. Fallbacks match Telegram iOS defaults so it also
   renders sanely in a plain browser during development. */
:root {
  --bg: var(--tg-theme-bg-color, #ffffff);
  --secondary-bg: var(--tg-theme-secondary-bg-color, #efeff4);
  --section-bg: var(--tg-theme-section-bg-color, #ffffff);
  --text: var(--tg-theme-text-color, #000000);
  --hint: var(--tg-theme-hint-color, #8e8e93);
  --subtitle: var(--tg-theme-subtitle-text-color, #8e8e93);
  --link: var(--tg-theme-link-color, #007aff);
  --accent: var(--tg-theme-button-color, #007aff);
  --accent-text: var(--tg-theme-button-text-color, #ffffff);
  --section-header: var(--tg-theme-section-header-text-color, #6d6d72);
  --separator: var(--tg-theme-section-separator-color, rgba(0,0,0,0.12));
  --destructive: var(--tg-theme-destructive-text-color, #ff3b30);

  --green: #34c759;
  --orange: #ff9500;

  --header-h: 48px;
  --tabbar-h: calc(56px + env(safe-area-inset-bottom, 0px));
  --radius: 12px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--secondary-bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: none;
}

button { font-family: inherit; cursor: pointer; border: none; background: none; color: inherit; }

/* ---------- Header ---------- */
.app-header {
  position: sticky;
  top: 0;
  z-index: 20;
  height: var(--header-h);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 12px;
  background: var(--bg);
  border-bottom: 0.5px solid var(--separator);
}
.app-title { margin: 0; font-size: 17px; font-weight: 600; letter-spacing: -0.2px; }
.header-action {
  position: absolute;
  right: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 38px; height: 38px;
  color: var(--accent);
  border-radius: 50%;
  transition: background .15s, transform .1s;
}
.header-action:active { background: var(--secondary-bg); transform: scale(.9); }

/* ---------- Screen ---------- */
.screen {
  min-height: calc(100vh - var(--header-h) - var(--tabbar-h));
  padding-bottom: calc(var(--tabbar-h) + 8px);
}

/* ---------- Search ---------- */
.search-wrap { padding: 8px 12px 4px; background: var(--bg); position: sticky; top: var(--header-h); z-index: 15; }
.search-box {
  display: flex; align-items: center; gap: 7px;
  background: var(--secondary-bg);
  border-radius: 10px;
  padding: 8px 11px;
  color: var(--hint);
}
.search-box svg { flex: none; opacity: .55; }
.search-box input {
  flex: 1; border: none; outline: none; background: transparent;
  color: var(--text); font-size: 16px; min-width: 0;
}
.search-box input::placeholder { color: var(--hint); }

/* ---------- List meta row (count + sort) ---------- */
.list-meta {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 16px 6px;
  font-size: 13px; color: var(--hint);
  background: var(--bg);
}
.sort-btn { color: var(--link); font-size: 15px; display: inline-flex; align-items: center; gap: 3px; }
.sort-btn svg { transition: transform .2s; }

/* ---------- Filter chips ---------- */
.chips {
  display: flex; gap: 8px; padding: 10px 12px; overflow-x: auto;
  background: var(--bg); position: sticky; top: var(--header-h); z-index: 15;
  scrollbar-width: none;
}
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: none;
  padding: 7px 15px; border-radius: 16px;
  background: var(--secondary-bg); color: var(--text);
  font-size: 14px; font-weight: 500; white-space: nowrap;
  transition: background .15s, color .15s;
}
.chip.active { background: var(--accent); color: var(--accent-text); }

/* ---------- Voice list ---------- */
.list { background: var(--bg); }
.row {
  display: flex; align-items: center; gap: 12px;
  padding: 11px 16px;
  position: relative;
}
.row::after {
  content: ""; position: absolute; left: 64px; right: 0; bottom: 0;
  height: 0.5px; background: var(--separator);
}
.row:last-child::after { display: none; }

.play {
  flex: none; width: 44px; height: 44px; border-radius: 50%;
  background: var(--accent); color: var(--accent-text);
  display: flex; align-items: center; justify-content: center;
  transition: transform .1s, opacity .15s;
}
.play:active { transform: scale(.9); }
.play.disabled { background: var(--secondary-bg); color: var(--hint); }

.row-body { flex: 1; min-width: 0; }
.row-name { font-size: 16px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* waveform + duration line */
.wave-line { display: flex; align-items: center; gap: 8px; margin-top: 4px; }
.wave {
  flex: 1; display: flex; align-items: center; gap: 2px; height: 22px;
  position: relative; overflow: hidden; min-width: 0;
}
.wave i {
  display: block; width: 2.5px; border-radius: 2px;
  background: var(--hint); opacity: .5;
  transition: background .1s, opacity .1s;
}
.wave i.on { background: var(--accent); opacity: 1; }
.dur { font-size: 13px; color: var(--hint); flex: none; min-width: 30px; }

.sub { margin-top: 3px; font-size: 13px; }
.sub.uses { color: var(--hint); }
.status-line { display: flex; align-items: center; gap: 6px; margin-top: 4px; font-size: 13px; font-weight: 500; }
.dot { width: 7px; height: 7px; border-radius: 50%; flex: none; }
.st-active   { color: var(--green); }    .st-active   .dot { background: var(--green); }
.st-awaiting { color: var(--orange); }   .st-awaiting .dot { background: var(--orange); }
.st-inactive { color: var(--destructive);} .st-inactive .dot { background: var(--destructive); }

.send {
  flex: none; width: 40px; height: 40px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  color: var(--hint); transition: transform .1s, color .15s, background .15s;
}
.send.enabled { color: var(--accent); }
.send:active { transform: scale(.85); background: var(--secondary-bg); }

/* ---------- About ---------- */
.about { padding: 16px 0 8px; }
.about-hero { text-align: center; padding: 16px 24px 8px; background: var(--bg); }
.about-logo {
  width: 84px; height: 84px; border-radius: 20px; margin: 0 auto 14px;
  background: var(--accent); color: var(--accent-text);
  display: flex; align-items: center; justify-content: center;
}
.about-name { font-size: 24px; font-weight: 700; margin: 0 0 6px; }
.about-tagline { color: var(--subtitle); font-size: 15px; line-height: 1.4; margin: 0 auto; max-width: 320px; }

.section-header { padding: 24px 16px 7px; font-size: 13px; color: var(--section-header); text-transform: uppercase; letter-spacing: .3px; }
.card { background: var(--bg); border-radius: var(--radius); margin: 0 12px; overflow: hidden; }
.policy-item { display: flex; gap: 11px; padding: 13px 16px; position: relative; font-size: 15px; line-height: 1.35; }
.policy-item::after { content: ""; position: absolute; left: 16px; right: 0; bottom: 0; height: .5px; background: var(--separator); }
.policy-item:last-child::after { display: none; }
.policy-item .bullet { flex: none; width: 7px; height: 7px; border-radius: 50%; background: var(--accent); margin-top: 7px; }
.card-text { padding: 14px 16px; font-size: 15px; line-height: 1.45; color: var(--text); }

/* language selector */
.lang-card { background: var(--bg); border-radius: var(--radius); margin: 0 12px; overflow: hidden; }
.lang-row { display: flex; align-items: center; justify-content: space-between; padding: 13px 16px; position: relative; font-size: 16px; }
.lang-row::after { content: ""; position: absolute; left: 16px; right: 0; bottom: 0; height: .5px; background: var(--separator); }
.lang-row:last-child::after { display: none; }
.lang-row:active { background: var(--secondary-bg); }
.lang-check { color: var(--accent); display: none; }
.lang-row.active .lang-check { display: block; }

/* ---------- States ---------- */
.empty, .loading-state { text-align: center; padding: 64px 32px; color: var(--hint); }
.empty .big { font-size: 17px; color: var(--text); font-weight: 600; margin-bottom: 6px; }
.spinner {
  width: 28px; height: 28px; margin: 0 auto 14px;
  border: 2.5px solid var(--separator); border-top-color: var(--accent);
  border-radius: 50%; animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.skeleton-row { display: flex; align-items: center; gap: 12px; padding: 11px 16px; }
.sk { background: var(--secondary-bg); border-radius: 6px; animation: pulse 1.3s ease-in-out infinite; }
.sk.circle { width: 44px; height: 44px; border-radius: 50%; flex: none; }
.sk.line1 { height: 13px; width: 45%; margin-bottom: 8px; }
.sk.line2 { height: 11px; width: 70%; }
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: .45; } }

.btn-retry { margin-top: 12px; padding: 9px 22px; border-radius: 10px; background: var(--accent); color: var(--accent-text); font-size: 15px; font-weight: 600; }

/* ---------- Tab bar ---------- */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  height: var(--tabbar-h);
  padding-bottom: env(safe-area-inset-bottom, 0px);
  display: flex;
  background: var(--bg);
  border-top: 0.5px solid var(--separator);
}
.tab {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 3px; color: var(--hint); font-size: 10px; font-weight: 500;
  transition: color .15s;
}
.tab .tab-ico { width: 26px; height: 26px; }
.tab.active { color: var(--accent); }
.tab:active { opacity: .6; }
