/* Video Summarizer WebApp.
   Ranglar foydalanuvchining Telegram mavzusidan (--tg-theme-*), Telegram'dan
   tashqarida — Telegram'ning standart yorug'/qorong'i ranglari. Alohida "AI" rangi yo'q:
   xulosa panellari ham Telegram'ning o'z aksenti va fonlarida — ilova Telegram'ning bir qismidek. */

:root {
  --fb-bg: #ffffff;
  --fb-bg2: #f0f2f5;
  --fb-text: #000000;
  --fb-hint: #8e8e93;
  --fb-link: #2481cc;
  --fb-button: #3390ec;
  --fb-sep: rgba(0, 0, 0, 0.09);
  --ok: #31a24c;
  --thumb-bg: #dfe4ea;
}
:root[data-theme="dark"] {
  --fb-bg: #212121;
  --fb-bg2: #0f0f0f;
  --fb-text: #ffffff;
  --fb-hint: #aaaaaa;
  --fb-link: #8774e1;
  --fb-button: #8774e1;
  --fb-sep: rgba(255, 255, 255, 0.08);
  --ok: #5fc36f;
  --thumb-bg: #2c2c2e;
}
:root {
  --page: var(--tg-theme-secondary-bg-color, var(--fb-bg2));
  --surface: var(--tg-theme-section-bg-color, var(--tg-theme-bg-color, var(--fb-bg)));
  --field: var(--tg-theme-secondary-bg-color, var(--fb-bg2));
  --text: var(--tg-theme-text-color, var(--fb-text));
  --muted: var(--tg-theme-hint-color, var(--fb-hint));
  --link: var(--tg-theme-link-color, var(--fb-link));
  --accent: var(--tg-theme-button-color, var(--fb-button));
  --on-accent: var(--tg-theme-button-text-color, #ffffff);
  --sep: var(--tg-theme-section-separator-color, var(--fb-sep));
  --danger: var(--tg-theme-destructive-text-color, #e53935);
  --head: var(--tg-theme-header-bg-color, var(--surface));
  /* Xulosa (AI) elementlari — oddiy Telegram ranglarida */
  --ai: var(--accent);
  --ai-text: var(--link);
  --ai-soft: var(--field);
  --ai-track: rgba(127, 127, 127, 0.22);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--page); color: var(--text);
  font: 15px/1.4 -apple-system, "SF Pro Text", Roboto, "Segoe UI", system-ui, sans-serif;
  min-height: 100vh; overscroll-behavior-y: none;
}
button { font: inherit; color: inherit; border: 0; background: none; cursor: pointer; padding: 0; }
input { font: inherit; color: inherit; }
svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.hidden { display: none !important; }
#app { max-width: 640px; margin: 0 auto; padding-bottom: calc(76px + env(safe-area-inset-bottom)); overflow-x: clip; }

/* ── Tepa panel ─────────────────────────────────────────────────────── */
.topbar {
  position: sticky; top: 0; z-index: 20; display: flex; align-items: center; justify-content: space-between;
  gap: 10px; padding: 8px 12px; background: var(--head); border-bottom: 0.5px solid var(--sep);
}
.topbar, .sticky-head, #view-chat .chat-head { transform: translateZ(0); backface-visibility: hidden; }
.acc-pill { display: flex; align-items: center; gap: 8px; min-width: 0; padding: 3px 10px 3px 3px; border-radius: 999px; background: var(--field); }
.acc-ava {
  position: relative; overflow: hidden; width: 28px; height: 28px; border-radius: 50%; flex: none;
  display: grid; place-items: center; color: #fff; font-weight: 600; font-size: 12px; background: var(--accent);
}
.acc-ava img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.acc-name { font-weight: 600; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 170px; }
.chev { width: 16px; height: 16px; color: var(--muted); }
.top-ai {
  display: flex; align-items: center; gap: 6px; padding: 5px 11px; border-radius: 999px;
  font-weight: 600; font-size: 12px; color: var(--ai-text); background: var(--ai-soft); max-width: 55%;
}
.top-ai span:last-child { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.top-ai .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--accent); flex: none; animation: pulse 1.2s ease infinite; }
@keyframes pulse { 50% { opacity: .3; } }

/* ── Ko'rinishlar ───────────────────────────────────────────────────── */
.view { display: none; }
.view.active { display: block; animation: fadeIn .2s ease both; }
@keyframes fadeIn { from { opacity: 0; } }
.page-head { padding: 14px 16px 2px; }
.page-head h2 { margin: 0; font-size: 22px; font-weight: 700; }
.hint { color: var(--muted); margin: 4px 16px 12px; font-size: 13px; }
.section-title { margin: 14px 16px 6px; font-size: 13px; font-weight: 500; text-transform: uppercase; color: var(--muted); letter-spacing: .02em; }

/* ── Qidiruv ────────────────────────────────────────────────────────── */
.sticky-head { position: sticky; top: var(--top-h, 49px); z-index: 15; background: var(--surface); padding: 8px 12px 0; }
.search { display: flex; align-items: center; gap: 8px; height: 36px; padding: 0 6px 0 10px; border-radius: 10px; background: var(--field); }
.search svg { width: 18px; height: 18px; color: var(--muted); flex: none; }
.search input { flex: 1; min-width: 0; border: 0; outline: 0; background: none; height: 100%; font-size: 15px; }
.search input::placeholder { color: var(--muted); }
.search input::-webkit-search-cancel-button { display: none; }
.search-go { padding: 4px 10px; border-radius: 8px; color: var(--on-accent); background: var(--accent); font-weight: 600; font-size: 13px; }
.search .icon-btn { width: 26px; height: 26px; }
.search .icon-btn svg { width: 16px; height: 16px; }

/* ── Tablar (Telegram "Shared media" kabi) ──────────────────────────── */
.segments { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); margin: 6px -12px 0; border-bottom: 0.5px solid var(--sep); }
.seg {
  position: relative; min-width: 0; padding: 10px 2px 9px; text-align: center; font-weight: 500; font-size: 14px;
  color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.seg.active { color: var(--accent); }
.seg.active::after { content: ""; position: absolute; left: 22%; right: 22%; bottom: 0; height: 3px; border-radius: 3px 3px 0 0; background: var(--accent); }

/* ── Sana filtri ────────────────────────────────────────────────────── */
.date-row { display: flex; align-items: center; gap: 8px; padding: 8px 12px; background: var(--surface); border-bottom: 0.5px solid var(--sep); min-width: 0; }
.date-chip { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 999px; font-weight: 500; font-size: 13px; color: var(--link); background: var(--field); flex: none; }
.date-chip svg { width: 15px; height: 15px; }
.date-chip.on { color: var(--on-accent); background: var(--accent); }
.date-x { width: 24px; height: 24px; border-radius: 50%; color: var(--muted); background: var(--field); flex: none; font-size: 12px; }
.date-q { color: var(--muted); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.date-presets { display: flex; flex-wrap: wrap; gap: 8px; margin: 4px 0 8px; }
.date-presets .chip { padding: 7px 13px; border-radius: 999px; font-weight: 500; font-size: 14px; background: var(--field); }
.date-presets .chip.active { color: var(--on-accent); background: var(--accent); }
.date-inputs { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 10px; margin-bottom: 14px; }
.date-inputs label { display: grid; gap: 4px; font-size: 12px; color: var(--muted); }
.date-inputs input { width: 100%; min-width: 0; padding: 9px; border-radius: 10px; border: 0; outline: 0; background: var(--field); }

/* ── Ro'yxat (kanallar) ─────────────────────────────────────────────── */
.cards { background: var(--surface); }
.card {
  content-visibility: auto; contain-intrinsic-size: auto 68px;
  display: flex; align-items: center; gap: 12px; width: 100%; min-width: 0; text-align: left;
  padding: 8px 12px; position: relative;
}
.card:active { background: var(--field); }
.card + .card::before { content: ""; position: absolute; top: 0; right: 0; left: 72px; border-top: 0.5px solid var(--sep); }
.card-main { flex: 1; min-width: 0; }
.card-title { min-width: 0; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.card-sub, .card-last { min-width: 0; color: var(--muted); font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.card-side { display: flex; flex-direction: column; align-items: flex-end; gap: 5px; color: var(--muted); font-size: 12px; flex: none; align-self: flex-start; padding-top: 2px; }
.badge-count { min-width: 20px; height: 20px; padding: 0 6px; border-radius: 999px; display: grid; place-items: center; color: var(--on-accent); font-weight: 600; font-size: 12px; background: var(--accent); }

.ava { position: relative; border-radius: 50%; overflow: hidden; flex: none; display: grid; place-items: center; color: #fff; font-weight: 600; background: #5ca5e9; }
.card .ava { width: 48px; height: 48px; font-size: 17px; }
.ava img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.ava.g1 { background: #e17076; } .ava.g2 { background: #7bc862; } .ava.g3 { background: #ee7aae; } .ava.g4 { background: #faa774; }

.hero { margin: 12px; padding: 20px; border-radius: 14px; background: var(--surface); text-align: center; }
.hero h3 { margin: 0 0 6px; font-size: 18px; }
.hero p { margin: 0 0 14px; color: var(--muted); font-size: 14px; }
.empty { text-align: center; color: var(--muted); padding: 44px 24px; font-size: 14px; line-height: 1.45; }
.empty-ico { display: inline-grid; place-items: center; width: 52px; height: 52px; margin-bottom: 10px; border-radius: 50%; background: var(--field); }
.empty-ico svg { width: 24px; height: 24px; stroke-width: 1.8; }
.more-loader { margin-top: 1px; }

/* ── Tugmalar ───────────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 46px; padding: 0 20px;
  border-radius: 12px; font-weight: 600; color: var(--on-accent); background: var(--accent); transition: transform .1s;
}
.btn:active { transform: scale(.98); }
.btn.block { width: 100%; }
.btn.ghost { background: var(--field); color: var(--link); }
.btn.danger { background: var(--danger); color: #fff; }
.btn[disabled] { opacity: .6; pointer-events: none; }
.icon-btn { width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; flex: none; color: var(--link); }

/* ── Kanal sarlavhasi ───────────────────────────────────────────────── */
#view-chat .chat-head {
  position: sticky; top: var(--top-h, 49px); z-index: 16; display: flex; align-items: center; gap: 10px;
  padding: 6px 12px 6px 4px; background: var(--surface);
}
.chat-head-ava .ava { width: 40px; height: 40px; font-size: 15px; }
.chat-head-text { flex: 1; min-width: 0; }
.chat-title { font-weight: 600; font-size: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-sub { color: var(--muted); font-size: 13px; }
.sticky-sub { top: calc(var(--top-h, 49px) + var(--chat-head-h, 52px)); padding-top: 2px; }
#app.no-top { --top-h: 0px; }
#app.no-top .topbar { display: none; }

/* ── Rasm grid (Telegram kabi zich) ─────────────────────────────────── */
.grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 2px; background: var(--surface); }
.tile { position: relative; aspect-ratio: 1 / 1; overflow: hidden; background: var(--thumb-bg); }
.tile img { width: 100%; height: 100%; object-fit: cover; display: block; }
.tile.sent::after { content: "✓"; position: absolute; top: 5px; right: 5px; width: 20px; height: 20px; border-radius: 50%; display: grid; place-items: center; font-size: 11px; font-weight: 700; color: #fff; background: var(--ok); }
.tile-badge { position: absolute; right: 4px; bottom: 4px; padding: 1px 5px; border-radius: 6px; font-size: 11px; font-weight: 600; color: #fff; background: rgba(0, 0, 0, .55); }
.sentinel { height: 40px; }

/* ── Media qatori: video / audio / fayl ─────────────────────────────── */
.mlist { background: var(--surface); }
.mrow { content-visibility: auto; contain-intrinsic-size: auto 96px; position: relative; padding: 10px 12px; }
.mrow + .mrow::before { content: ""; position: absolute; top: 0; left: 12px; right: 0; border-top: 0.5px solid var(--sep); }
.mrow-top { display: flex; align-items: flex-start; gap: 12px; width: 100%; min-width: 0; text-align: left; }
.mthumb {
  position: relative; width: 112px; aspect-ratio: 16 / 10; border-radius: 8px; overflow: hidden; flex: none;
  display: grid; place-items: center; color: var(--muted); background: var(--thumb-bg);
}
.mthumb img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.mthumb svg { width: 26px; height: 26px; }
.mthumb.square { width: 52px; aspect-ratio: 1 / 1; border-radius: 50%; color: var(--on-accent); background: var(--accent); }
.mthumb.square svg { width: 22px; height: 22px; }
.mthumb .tile-badge { right: 4px; bottom: 4px; font-size: 10px; }
.minfo { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.msub { color: var(--text); opacity: .72; font-size: 13.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mthumb.doc { width: 52px; aspect-ratio: 1 / 1; border-radius: 10px; color: var(--on-accent); background: var(--accent); }
.mthumb.doc svg { width: 22px; height: 22px; }
.mthumb .ext { font-weight: 700; font-size: 12px; letter-spacing: .02em; }
.mtitle { font-weight: 500; font-size: 15px; line-height: 1.3; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; overflow-wrap: anywhere; }
.mmeta { color: var(--muted); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mrow.sent .mmeta::after { content: " · ✓"; color: var(--ok); }
.mrow.sent .mthumb { box-shadow: 0 0 0 2px var(--ok); }
.mactions { display: flex; gap: 18px; margin-top: 6px; }
.mlink { display: inline-flex; align-items: center; gap: 5px; color: var(--link); font-weight: 500; font-size: 14px; white-space: nowrap; }
.mlink svg { width: 17px; height: 17px; }
.mlink.ai { color: var(--ai-text); }
.mlink.done { color: var(--ok); }
.mlink[disabled] { opacity: .7; pointer-events: none; }
.ring { position: relative; width: 17px; height: 17px; flex: none; }
.ring svg { width: 17px; height: 17px; transform: rotate(-90deg); }
.ring circle { stroke: currentColor; stroke-opacity: .25; stroke-width: 3; fill: none; }
.ring circle.fg { stroke-opacity: 1; stroke-dasharray: 57; stroke-dashoffset: 57; transition: stroke-dashoffset .3s; }

/* ── AI panel (studiya): bosqichlar, muhim joylar ───────────────────── */
.ai-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; font-size: 13px; font-weight: 600; color: var(--text); }
.ai-head svg { width: 16px; height: 16px; vertical-align: -3px; margin-right: 4px; }
.hl { list-style: none; margin: 8px 0 0; padding: 0; display: grid; gap: 6px; }
.hl li { display: flex; gap: 8px; align-items: baseline; min-width: 0; font-size: 14px; }
.ts {
  flex: none; padding: 1px 6px; border-radius: 6px; font: 600 12px/1.5 ui-monospace, "SF Mono", Menlo, monospace;
  color: var(--ai-text); background: var(--field);
}
button.ts:active { opacity: .6; }
.hl span:last-child { min-width: 0; overflow-wrap: anywhere; }
.lang-tog { display: inline-flex; padding: 2px; border-radius: 8px; background: var(--surface); }
.lang-tog button { padding: 2px 8px; border-radius: 6px; font-size: 12px; font-weight: 600; color: var(--muted); }
.lang-tog button.on { color: var(--on-accent); background: var(--accent); }
.ai-err { margin-top: 6px; font-size: 13px; color: var(--danger); }

/* ── Xulosalar ──────────────────────────────────────────────────────── */
.tlist { display: grid; grid-template-columns: minmax(0, 1fr); gap: 8px; padding: 0 0 8px; }
.tcard { position: relative; padding: 12px; background: var(--surface); }
.tcard-head { display: flex; gap: 12px; align-items: flex-start; min-width: 0; text-align: left; width: 100%; }
.ttitle { font-weight: 600; font-size: 15px; line-height: 1.3; overflow-wrap: anywhere; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.tsub { color: var(--muted); font-size: 13px; margin-top: 2px; }
.post-text { margin: 8px 12px; padding: 12px; border-radius: 12px; background: var(--surface); white-space: pre-wrap; font-size: 15px; overflow-wrap: anywhere; }

/* ── Skeleton ───────────────────────────────────────────────────────── */
.sk { background: linear-gradient(90deg, var(--field) 25%, var(--surface) 50%, var(--field) 75%); background-size: 200% 100%; animation: shimmer 1.3s infinite; }
@keyframes shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }
.sk-card { height: 64px; margin: 1px 0; }
.sk-tile { aspect-ratio: 1 / 1; }

/* ── Pastki tab-bar ─────────────────────────────────────────────────── */
.dock {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; display: flex; justify-content: center;
  padding: 4px 0 calc(4px + env(safe-area-inset-bottom)); background: var(--head); border-top: 0.5px solid var(--sep);
}
.dock-btn { flex: 1; max-width: 200px; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 4px 0; color: var(--muted); font-size: 11px; font-weight: 500; }
.dock-btn svg { width: 25px; height: 25px; }
.dock-btn.active { color: var(--accent); }

/* ── Sheet va dialog ────────────────────────────────────────────────── */
.sheet-backdrop { position: fixed; inset: 0; z-index: 40; background: rgba(0, 0, 0, .4); animation: fadeIn .2s ease; }
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 50; max-width: 640px; margin: 0 auto; max-height: 90vh; overflow-y: auto;
  border-radius: 14px 14px 0 0; background: var(--surface); padding: 6px 16px calc(18px + env(safe-area-inset-bottom));
  transform: translateY(105%); transition: transform .28s cubic-bezier(.2, .8, .2, 1);
}
.sheet.open { transform: none; }
.sheet-handle { width: 36px; height: 5px; border-radius: 3px; background: var(--sep); margin: 4px auto 12px; }
.sheet h3 { margin: 0 0 10px; font-size: 18px; }
.sheet h4 { margin: 16px 0 6px; font-size: 13px; font-weight: 600; text-transform: uppercase; color: var(--muted); }
.sheet .overview { margin: 0; font-size: 15px; line-height: 1.5; }
.sheet .hl li { align-items: flex-start; }
.sheet .hl-text b { display: block; font-weight: 600; }
.sheet .hl-text span { color: var(--muted); font-size: 14px; }
.sheet ul.bul { margin: 0; padding-left: 18px; display: grid; gap: 4px; font-size: 15px; }
.preview { position: relative; border-radius: 12px; overflow: hidden; background: var(--thumb-bg); aspect-ratio: 16 / 10; max-height: 52vh; margin: 0 auto 12px; }
.preview img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; display: block; }
.preview .pv-low { object-fit: cover; filter: blur(12px); transform: scale(1.08); opacity: .8; }
.preview .pv-low.sharp { object-fit: contain; filter: none; transform: none; opacity: 1; }
.preview .pv-hi { opacity: 0; transition: opacity .25s; }
.preview .pv-hi.ready { opacity: 1; }
.sv-loader { position: absolute; inset: 0; display: grid; place-items: center; z-index: 1; pointer-events: none; }
.spin { width: 36px; height: 36px; border-radius: 50%; border: 3px solid rgba(127, 127, 127, .25); border-top-color: var(--accent); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.meta-row { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }
.meta-chip { padding: 3px 9px; border-radius: 999px; background: var(--field); font-size: 12px; color: var(--muted); }
.caption { color: var(--text); font-size: 14px; margin: 0 0 10px; white-space: pre-wrap; max-height: 120px; overflow: auto; }
.sheet .mactions { margin: 6px 0 8px; gap: 8px; }
.sheet .mactions .mlink { flex: 1; justify-content: center; height: 44px; border-radius: 12px; font-weight: 600; font-size: 15px; color: var(--on-accent); background: var(--accent); }
.sheet .mactions .mlink.ai { color: var(--link); background: var(--field); }
.sheet .mactions .mlink.done { color: var(--ok); background: var(--field); }
.list { display: grid; gap: 1px; margin-bottom: 14px; border-radius: 12px; overflow: hidden; }
.list-item { display: flex; align-items: center; gap: 12px; min-width: 0; padding: 8px 10px; background: var(--field); text-align: left; width: 100%; }
.list-item.active { box-shadow: inset 3px 0 0 var(--accent); }
.list-item .ava { width: 40px; height: 40px; font-size: 15px; }

.dlg-backdrop { z-index: 80; }
.dlg {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 85; max-width: 640px; margin: 0 auto; text-align: center;
  border-radius: 14px 14px 0 0; background: var(--surface); padding: 6px 18px calc(16px + env(safe-area-inset-bottom));
  transform: translateY(105%); transition: transform .28s cubic-bezier(.2, .8, .2, 1);
}
.dlg.open { transform: none; }
.dlg-icon { width: 54px; height: 54px; border-radius: 50%; margin: 2px auto 10px; display: grid; place-items: center; }
.dlg-icon svg { width: 26px; height: 26px; }
.dlg-icon.tone-brand { color: var(--link); background: var(--field); }
.dlg-icon.tone-danger { color: var(--danger); background: rgba(229, 57, 53, .12); }
.dlg-icon.tone-ok { color: var(--ok); background: rgba(49, 162, 76, .12); }
.dlg h3 { margin: 0 0 6px; font-size: 18px; }
.dlg p { margin: 0 0 16px; color: var(--muted); font-size: 15px; white-space: pre-wrap; }
.dlg .btn + .btn { margin-top: 8px; }

/* ── Toast ──────────────────────────────────────────────────────────── */
.toast {
  position: fixed; left: 50%; top: calc(10px + env(safe-area-inset-top)); z-index: 90; display: flex; align-items: center; gap: 10px;
  width: max-content; max-width: min(92vw, 420px); padding: 8px 14px 8px 8px; border-radius: 14px; color: #fff;
  background: rgba(30, 30, 32, .94); transform: translateX(-50%); cursor: pointer; font-weight: 500; font-size: 14px; line-height: 1.3;
}
.toast.show { animation: toastIn .3s cubic-bezier(.2, 1.2, .3, 1) both; }
.toast.out { animation: toastOut .2s ease both; }
@keyframes toastIn { from { transform: translateX(-50%) translateY(-20px); opacity: 0; } }
@keyframes toastOut { to { transform: translateX(-50%) translateY(-20px); opacity: 0; } }
.isl-ico { width: 26px; height: 26px; border-radius: 50%; flex: none; display: grid; place-items: center; }
.isl-ico svg { width: 15px; height: 15px; stroke-width: 3; }
.isl-ok .isl-ico { background: var(--ok); }
.isl-error .isl-ico { background: #e53935; }
.isl-info .isl-ico { background: #3390ec; }
.isl-text { min-width: 0; overflow-wrap: anywhere; }

/* ── Kontekst inputi (PDF qilish oynasi) ────────────────────────────── */
.dlg-input {
  display: block; width: 100%; min-height: 76px; resize: vertical; margin: -4px 0 6px; padding: 10px 12px;
  border: 1.5px solid transparent; border-radius: 12px; outline: 0; background: var(--field); color: var(--text);
  font: inherit; font-size: 15px; text-align: left;
}
.dlg-input:focus { border-color: var(--ai); }
.dlg-input::placeholder { color: var(--muted); }
.dlg-select {
  display: flex; align-items: center; justify-content: space-between; gap: 10px; margin: -4px 0 10px;
  font-size: 14px; color: var(--muted); text-align: left;
}
.dlg-select select {
  flex: 0 1 60%; min-width: 0; padding: 9px 32px 9px 12px; border: 1.5px solid var(--sep); border-radius: 12px;
  outline: 0; color: var(--text); font: inherit; font-size: 15px;
  /* Telegram WebView'da tizim select'i oq bo'lib qoladi — o'zimiz chizamiz. */
  -webkit-appearance: none; appearance: none;
  background: var(--field) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' fill='none' stroke='%23999' stroke-width='2' stroke-linecap='round'/%3E%3C/svg%3E") no-repeat right 12px center;
}
.dlg-select option { background: var(--surface); color: var(--text); }
.dlg-select select:focus { border-color: var(--ai); }
.dlg-hint { margin: 0 0 14px; font-size: 12px; color: var(--muted); text-align: left; }
.tctx { margin-top: 4px; font-size: 13px; color: var(--ai-text); overflow-wrap: anywhere; }
.ctx-note { margin: 14px 0 0; font-size: 13px; color: var(--muted); }

/* ── Konspekt bo'limlari (to'liq xulosa oynasida) ───────────────────── */
details.kons { border-top: 0.5px solid var(--sep); }
details.kons summary { display: flex; gap: 8px; align-items: baseline; padding: 10px 0; cursor: pointer; list-style: none; font-weight: 600; font-size: 15px; }
details.kons summary::-webkit-details-marker { display: none; }
details.kons summary::after { content: "›"; margin-left: auto; color: var(--muted); transition: transform .2s; }
details.kons[open] summary::after { transform: rotate(90deg); }
.kons-body { padding: 0 0 10px; font-size: 15px; line-height: 1.55; }
.kons-body p { margin: 0 0 8px; }
.kons-body ul { margin: 0 0 8px; padding-left: 18px; }

/* ── AI panel qo'shimchalari ────────────────────────────────────────── */

/* ── ⏰ Avtomatik rejim ─────────────────────────────────────────────── */
.auto-btn { color: var(--muted); }
.auto-btn.on { color: var(--ai-text); background: var(--ai-soft); }
.auto-ico { width: 36px; height: 36px; border-radius: 50%; flex: none; display: grid; place-items: center; color: var(--ai-text); background: var(--ai-soft); }
.auto-ico svg { width: 20px; height: 20px; }
.auto-ico.big { width: 56px; height: 56px; margin: 4px auto 10px; }
.auto-ico.big svg { width: 28px; height: 28px; }
.auto-ico.live svg { animation: spin 6s linear infinite; }
.auto-hero { text-align: left; padding: 2px 0 4px; }
.auto-hero h3 { margin: 0 0 3px; }
.auto-hero p { margin: 0 0 8px; color: var(--muted); font-size: 14px; line-height: 1.4; }
.auto-label { margin: 14px 0 6px; font-size: 13px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .02em; }
.auto-input { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 8px; padding: 9px 12px; border-radius: 12px; background: var(--field); font-size: 14px; }
.auto-input input { border: 0; outline: 0; background: none; font: inherit; color: var(--text); text-align: right; min-width: 0; }
.auto-toggle { position: relative; display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 16px; padding: 10px 12px; border-radius: 12px; background: var(--field); cursor: pointer; }
.auto-toggle span { display: grid; gap: 2px; min-width: 0; }
.auto-toggle b { font-weight: 600; font-size: 15px; }
.auto-toggle small { color: var(--muted); font-size: 12px; }
.auto-toggle input { position: absolute; opacity: 0; pointer-events: none; }
.auto-toggle i { flex: none; width: 44px; height: 26px; border-radius: 13px; background: rgba(127, 127, 127, .35); position: relative; transition: background .2s; }
.auto-toggle i::after { content: ""; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.25); transition: transform .2s; }
.auto-toggle input:checked + i { background: var(--ai); }
.auto-toggle input:checked + i::after { transform: translateX(18px); }
.auto-note { margin: 10px 0 14px; }
.auto-state { font-weight: 600; font-size: 14px; color: var(--link); margin: 4px 0 2px; }
.auto-prog { margin-top: 8px; }
.auto-bar { height: 6px; border-radius: 3px; background: var(--ai-track); overflow: hidden; }
.auto-bar i { display: block; height: 100%; background: var(--ai); border-radius: 3px; transition: width .4s; }
.auto-nums { display: flex; gap: 12px; margin-top: 6px; font-size: 13px; color: var(--muted); }
.auto-nums span:last-child { margin-left: auto; }
.auto-nums .bad { color: var(--danger); }
.auto-current { display: flex; gap: 8px; align-items: baseline; margin-top: 12px; padding: 10px 12px; border-radius: 12px; background: var(--ai-soft); font-size: 14px; min-width: 0; }
.auto-current span:nth-child(2) { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.auto-current b { flex: none; font-size: 12px; font-weight: 600; color: var(--ai-text); }
.auto-facts { list-style: none; margin: 14px 0 0; padding: 0; display: grid; gap: 8px; font-size: 14px; }
.auto-facts li { display: flex; gap: 8px; align-items: flex-start; color: var(--text); }
.auto-facts svg { width: 17px; height: 17px; flex: none; color: var(--muted); margin-top: 1px; }
.auto-actions { display: grid; grid-template-columns: repeat(auto-fit, minmax(0, 1fr)); gap: 8px; margin-top: 16px; }
.auto-actions .btn { height: 42px; padding: 0 10px; font-size: 14px; }
.auto-actions .btn svg { width: 17px; height: 17px; }
.auto-actions .btn:only-child { grid-column: 1 / -1; }
.btn.danger-text { color: var(--danger); }
.auto-list { display: grid; gap: 8px; margin-bottom: 4px; }
.auto-card { display: block; width: 100%; text-align: left; padding: 12px; background: var(--surface); }
.auto-card-head { display: flex; gap: 10px; align-items: center; min-width: 0; }

.auto-sheet .date-presets { gap: 6px; }
.auto-sheet .date-presets .chip { padding: 6px 11px; font-size: 13px; }

/* ── ⏰ bo'limi ─────────────────────────────────────────────────────── */
.page-head.with-action { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.head-action { display: inline-flex; align-items: center; gap: 4px; padding: 6px 12px; border-radius: 999px; font-weight: 600; font-size: 14px; color: var(--on-accent); background: var(--accent); }
.head-action svg { width: 17px; height: 17px; }
.auto-empty { margin: 8px 12px; padding: 24px 18px; border-radius: 14px; background: var(--surface); text-align: center; }
.auto-empty h3 { margin: 0 0 6px; font-size: 18px; }
.auto-empty p { margin: 0 0 16px; color: var(--muted); font-size: 14px; line-height: 1.5; }
.auto-empty .btn svg { width: 18px; height: 18px; }
.auto-card .ava { font-size: 16px; }
.auto-card.paused { opacity: .75; }
.auto-card .tsub.live { color: var(--ai-text); display: flex; align-items: center; gap: 6px; }
.auto-card .tsub .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--ai); flex: none; animation: pulse 1.2s ease infinite; }
.chev-r { color: var(--muted); flex: none; }
.chev-r svg { width: 18px; height: 18px; }
.auto-current.small { margin-top: 8px; padding: 7px 10px; font-size: 13px; }
.auto-current.small span { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pick-list { display: grid; gap: 1px; margin: 10px 0; border-radius: 12px; overflow: hidden; max-height: 55vh; overflow-y: auto; }
.pick-list .list-item .card-title { font-weight: 600; }
.auto-tag { flex: none; color: var(--ai-text); }
.auto-tag svg { width: 18px; height: 18px; }

/* ── Bir nechta kanal tanlash ───────────────────────────────────────── */
.picker-hint { margin: -4px 0 10px; }
.list-item.pick { position: relative; }
.pick-check { flex: none; width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center; border: 2px solid var(--sep); color: transparent; transition: all .15s; }
.pick-check svg { width: 14px; height: 14px; stroke-width: 3; }
.list-item.pick.sel { box-shadow: inset 3px 0 0 var(--accent); }
.list-item.pick.sel .pick-check { border-color: var(--accent); background: var(--accent); color: var(--on-accent); }
.picker-foot { position: sticky; bottom: calc(-18px - env(safe-area-inset-bottom)); margin: 8px -16px 0; padding: 10px 16px calc(14px + env(safe-area-inset-bottom)); background: var(--surface); border-top: 0.5px solid var(--sep); }
.picker-foot .btn[disabled] { opacity: .45; }
.auto-chans { display: flex; flex-wrap: wrap; gap: 6px; margin: 0 0 6px; }
.auto-chan { padding: 4px 10px; border-radius: 999px; font-size: 13px; font-weight: 500; color: var(--text); background: var(--field); max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.auto-sub { margin: 6px 0 0; font-size: 12px; }
.auto-input input[type="number"] { width: 90px; }
.auto-actions .btn span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.auto-actions .btn { flex-direction: column; gap: 3px; height: 58px; padding: 0 6px; font-size: 12.5px; }
.auto-actions .btn svg { width: 19px; height: 19px; }

/* ── Qo'shimchalar ──────────────────────────────────────────────────── */
.st-dot { display: inline-block; width: 7px; height: 7px; margin-right: 4px; border-radius: 50%; background: var(--danger); vertical-align: 1px; }
.st-dot.on { background: var(--ok); }
/* Ikki tanlovli segment (masalan: eng yangisidan / eng eskisidan) */
.date-presets.seg2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0; padding: 2px; border-radius: 10px; background: var(--field); }
.date-presets.seg2 .chip { border-radius: 8px; padding: 8px 6px; text-align: center; background: none; color: var(--muted); font-weight: 600; }
.date-presets.seg2 .chip.active { color: var(--text); background: var(--surface); box-shadow: 0 1px 3px rgba(0, 0, 0, .18); }
.auto-static { color: var(--muted); }
.auto-empty .auto-ico.big { color: var(--muted); background: var(--field); }

/* ── PDF tayyor: ✓ belgi, til tanlash, holat qatori ────────────────── */
.mrow.pdf-done, .tcard.pdf-done { padding-right: 34px; }
.done-mark { position: absolute; top: 10px; right: 10px; width: 20px; height: 20px; border-radius: 50%; display: grid; place-items: center; color: #fff; background: var(--ok); pointer-events: none; }
.done-mark svg { width: 12px; height: 12px; stroke-width: 3.2; }
.mactions { align-items: center; flex-wrap: wrap; row-gap: 6px; }
.plang { display: inline-flex; padding: 2px; border-radius: 8px; background: var(--field); flex: none; }
.plang button { min-width: 30px; padding: 2px 7px; border-radius: 6px; font-size: 12px; font-weight: 700; color: var(--muted); }
.plang button.on { color: var(--on-accent); background: var(--accent); }
.mstatus { display: flex; align-items: center; gap: 8px; margin-top: 7px; font-size: 12.5px; color: var(--link); min-width: 0; }
.mstatus span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.mstatus.bad { color: var(--danger); }
.mstatus.bad svg { width: 15px; height: 15px; flex: none; }
.mbar { flex: none; width: 64px; height: 4px; border-radius: 2px; background: var(--ai-track); overflow: hidden; }
.mbar i { display: block; height: 100%; background: var(--accent); border-radius: 2px; transition: width .4s; }
.sheet-links { display: flex; flex-wrap: wrap; gap: 6px 16px; margin: 4px 0 6px; }
.sheet-links button { display: inline-flex; align-items: center; gap: 6px; padding: 6px 0; font-size: 14px; font-weight: 500; color: var(--link); }
.sheet-links svg { width: 16px; height: 16px; }
.sheet .mstatus { margin: 4px 0 8px; }

/* ── Xulosalar: ikki tab (hammasi / kanallar) va kartalar ──────────── */
.task-seg { position: sticky; top: var(--top-h, 49px); z-index: 12; margin: 4px 0 8px; background: var(--surface); }
.seg-n { margin-left: 4px; font-size: 12px; font-weight: 600; opacity: .7; }
.tchan-list .card-sub { font-size: 13px; }
.tchan-head { display: flex; align-items: center; gap: 10px; padding: 8px 12px 8px 4px; margin-bottom: 8px; background: var(--surface); }
.tchan-head .card-title { font-size: 16px; }
.tthumb { position: relative; flex: none; width: 96px; aspect-ratio: 16 / 10; border-radius: 8px; overflow: hidden; display: grid; place-items: center; color: var(--muted); background: var(--thumb-bg); }
.tthumb img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.tthumb svg { width: 22px; height: 22px; }
.tthumb .tile-badge { right: 4px; bottom: 4px; font-size: 10px; }
.tinfo { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.torig { color: var(--muted); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tchan { display: flex; align-items: center; gap: 6px; min-width: 0; margin-top: 2px; font-size: 13px; }
.tchan .ava { width: 18px; height: 18px; font-size: 8px; }
.tchan-name { min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--text); opacity: .8; font-weight: 500; }
.tchan-date { flex: none; color: var(--muted); }
.tchan-date::before { content: "·"; margin-right: 6px; }
.tactions { display: flex; align-items: center; gap: 12px; margin-top: 10px; padding-top: 8px; border-top: 0.5px solid var(--sep); }
.tactions .tgrow { flex: 1; }
.tactions .icon-btn { width: 32px; height: 32px; }
.tactions .icon-btn svg { width: 19px; height: 19px; }
.tcard .mstatus { margin-top: 10px; }
.auto-more { margin: 4px 12px 12px; width: calc(100% - 24px); }
