/* =====================================================================
   FIDEX OS — оболочка, этап 0 (макет)
   Дизайн-токены + база. Компоненты — только через переменные.
   Страница публикуется как артефакт claude.ai: площадка сама
   оборачивает контент в doctype/head/body и уже задаёт :root
   padding по safe-area — здесь этот padding не переопределяется.
   ===================================================================== */

:root{
  /* light */
  --ground: #EEF3F1;
  --surface: #FFFFFF;
  --surface-2: #F5F8F7;
  --ink: #13201D;
  --muted: #56665F;
  --line: #D6E0DC;
  --teal: #0E7C70;
  --teal-ink: #FFFFFF;
  --teal-soft: #DDF0EC;
  --amber: #995E0E;
  --amber-soft: #FCEFD9;
  --good: #1D713B;
  --warn: #A8570B;
  --crit: #B42318;
  --nodata: #8A9A94;

  --r-sm: 8px;
  --r-md: 14px;

  --font-display: 'Unbounded', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --font-body: 'Golos Text', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-mono: 'IBM Plex Mono', 'SFMono-Regular', Consolas, 'Liberation Mono', monospace;

  /* шкала шрифта */
  --fs-2xs: 12px;
  --fs-xs: 13px;
  --fs-sm: 15px;
  --fs-md: 17px;
  --fs-lg: 20px;
  --fs-xl: 28px;
  --fs-2xl: 44px;

  color-scheme: light;
}

@media (prefers-color-scheme: dark){
  :root:not([data-theme="light"]){
    --ground: #0C1412;
    --surface: #15201D;
    --surface-2: #1B2925;
    --ink: #E4EDEA;
    --muted: #93A8A1;
    --line: #26332F;
    --teal: #3CC4B2;
    --teal-ink: #06201C;
    --teal-soft: #12302C;
    --amber: #F0A640;
    --amber-soft: #3A2A10;
    --good: #5CC98A;
    --warn: #F0A640;
    --crit: #F27A6E;
    --nodata: #6F827C;
    color-scheme: dark;
  }
}

:root[data-theme="dark"]{
  --ground: #0C1412;
  --surface: #15201D;
  --surface-2: #1B2925;
  --ink: #E4EDEA;
  --muted: #93A8A1;
  --line: #26332F;
  --teal: #3CC4B2;
  --teal-ink: #06201C;
  --teal-soft: #12302C;
  --amber: #F0A640;
  --amber-soft: #3A2A10;
  --good: #5CC98A;
  --warn: #F0A640;
  --crit: #F27A6E;
  --nodata: #6F827C;
  color-scheme: dark;
}

/* ---------------------------------------------------------------------
   База
   --------------------------------------------------------------------- */

*, *::before, *::after{ box-sizing: border-box; }

body{
  background: var(--ground);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: var(--fs-sm);
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

h1, h2, h3{ font-family: var(--font-display); margin: 0; }

a{ color: var(--teal); text-decoration: none; }
a:hover{ text-decoration: underline; }

.muted{ color: var(--muted); }

.num{
  font-variant-numeric: tabular-nums;
}

/* цифры-акценты (истории и т.п.) */
.num-hero{
  font-family: var(--font-display);
  font-size: var(--fs-2xl);
  font-variant-numeric: tabular-nums;
  line-height: 1.1;
}

/* подписи источника данных */
.source-caption{
  font-family: var(--font-mono);
  font-size: var(--fs-2xs);
  color: var(--muted);
}

/* контейнер: одна колонка телефона; нижний паддинг — чтобы контент не
   заходил под фиксированную пастки-панель (.fx-tabbar, 56px + safe-area) */
.container{
  max-width: 520px;
  margin-inline: auto;
  padding-inline: 16px;
  padding-bottom: calc(56px + env(safe-area-inset-bottom, 0px) + 12px);
  position: relative;
}

/* никакой горизонтальной прокрутки страницы на 360px */
html, body{ max-width: 100%; }

/* фокус клавиатуры всегда виден */
:focus-visible{
  outline: 2px solid var(--teal);
  outline-offset: 2px;
}

/* ---------------------------------------------------------------------
   Кнопки — цель касания не меньше 44px
   --------------------------------------------------------------------- */

.btn{
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 44px;
  padding: 10px 16px;
  border-radius: 11px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: var(--fs-sm);
  font-weight: 600;
  cursor: pointer;
  transition: transform .15s ease, background-color .15s ease, opacity .15s ease;
}
.btn:active{ transform: scale(.97); }

.btn-primary{
  background: var(--teal);
  border-color: var(--teal);
  color: var(--teal-ink);
}

.btn-ghost{
  background: transparent;
  border-color: transparent;
  color: var(--teal);
}

.btn:disabled{ opacity: .5; cursor: default; }

/* иконка-кнопка (поиск, колокольчик) — круглая серая, цель касания 44x44 */
.icon-btn{
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border-radius: 999px;
  border: none;
  background: var(--surface-2);
  color: var(--ink);
  font-size: var(--fs-sm);
  cursor: pointer;
  position: relative;
}
.icon-btn:active{ background: var(--line); }

/* amoCRM — маленькая круглая кнопка «a» вместо текстовой в шапке */
.icon-btn-amo{
  background: linear-gradient(135deg, var(--teal), var(--amber));
  color: #fff;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: var(--fs-md);
}
.icon-btn-amo:active{ background: linear-gradient(135deg, var(--teal), var(--amber)); opacity: .85; }

/* пункты-«быстрые ссылки» в листе поиска/меню (amoCRM и т.п.) */
.quicklinks{ margin-top: 12px; display: flex; flex-direction: column; gap: 8px; }
.quicklink{
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 44px;
  padding: 6px 10px;
  border-radius: 11px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: var(--fs-sm);
  font-weight: 600;
  cursor: pointer;
}
.quicklink:active{ background: var(--surface-2); }
.quicklink-icon{
  width: 28px;
  height: 28px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: var(--fs-xs);
}

/* ---------------------------------------------------------------------
   Метки (chip) — семантические цвета по роли исполнителя
   --------------------------------------------------------------------- */

.chip{
  display: inline-flex;
  align-items: center;
  gap: 4px;
  height: 24px;
  padding: 0 10px;
  border-radius: 999px;
  font-size: var(--fs-2xs);
  font-weight: 600;
  white-space: nowrap;
  line-height: 1;
}

/* markaz — задача учебного центра */
.chip-markaz{
  background: color-mix(in srgb, var(--teal) 16%, var(--surface));
  color: var(--teal);
}

/* dasturlash — задача разработки */
.chip-dasturlash{
  background: var(--surface-2);
  color: var(--muted);
  border: 1px solid var(--line);
}

/* egasi qarori — решение владельца */
.chip-egasi{
  background: var(--amber-soft);
  color: var(--amber);
}

/* устаревшие данные */
.chip-stale{
  background: color-mix(in srgb, var(--nodata) 20%, var(--surface));
  color: var(--nodata);
}

/* ---------------------------------------------------------------------
   Карточка
   --------------------------------------------------------------------- */

.card{
  background: var(--surface);
  border-radius: var(--r-md);
  padding: 16px;
}

/* лента как мобильный Facebook: посты на всю ширину контейнера,
   разделены полосой --ground 8px, без тяжёлых радиусов и теней */
.post{
  background: var(--surface);
  width: 100%;
  padding: 16px;
  border-radius: 0;
  box-shadow: none;
}
.post + .post{ margin-top: 8px; }

/* ---------------------------------------------------------------------
   Липкая шапка
   --------------------------------------------------------------------- */

.topbar{
  position: sticky;
  top: env(safe-area-inset-top, 0px);
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 10px 16px;
  padding-top: calc(10px + env(safe-area-inset-top, 0px));
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  transition: transform .2s ease;
}
/* scroll pastga — yashiradi (fb-patterns §15); reduced motion — JS umuman
   klass qoʻshmaydi, shu yerda alohida tekshirish kerak emas */
.topbar.is-hidden{ transform: translateY(-100%); }

.topbar .logo{
  font-family: var(--font-display);
  font-size: var(--fs-lg);
  font-weight: 700;
  color: var(--teal);
  letter-spacing: .01em;
  text-transform: lowercase;
}

.topbar-actions{
  display: flex;
  align-items: center;
  gap: 4px;
}

.badge{
  position: absolute;
  top: 2px;
  right: 2px;
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  border-radius: 999px;
  background: var(--crit);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  line-height: 16px;
  text-align: center;
  font-variant-numeric: tabular-nums;
}

/* точка «есть непрочитанное» — БЕЗ числа (fb-patterns §14); .badge выше
   остаётся для случаев с реальным подписанным содержимым, здесь — сигнал */
.badge-dot{
  min-width: 10px;
  width: 10px;
  height: 10px;
  padding: 0;
}

/* ---------------------------------------------------------------------
   Пастки-панель снизу (FX.boot → renderTabBar) — Lenta/Reels/amoCRM/
   Bildirishnomalar/Menyu, без голого счётчика на колокольчике.
   --------------------------------------------------------------------- */

.fx-tabbar{
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 50;
  display: flex;
  height: 56px;
  padding-bottom: env(safe-area-inset-bottom, 0px);
  background: var(--surface);
  border-top: 1px solid var(--line);
}

.fx-tab{
  flex: 1 1 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  min-width: 44px;
  min-height: 44px;
  border: none;
  background: none;
  color: var(--muted);
  font-family: var(--font-body);
  cursor: pointer;
}
.fx-tab-icon{ position: relative; display: inline-flex; }
.fx-tab-icon svg{ width: 22px; height: 22px; }
.fx-tab-label{ font-size: 11px; font-weight: 600; }
.fx-tab.is-active{ color: var(--teal); }

.fx-tab-dot{
  position: absolute;
  top: -2px;
  right: -3px;
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: var(--crit);
}

/* лист «Bildirishnomalar»: группы «Yangi» / «Avvalroq», без раздутого счёта */
.fx-notif-group + .fx-notif-group{ margin-top: 16px; }
.fx-notif-group-title{
  font-size: var(--fs-xs);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .02em;
  margin-bottom: 8px;
}
.fx-notif-item{ padding: 8px 0; border-bottom: 1px solid var(--line); }
.fx-notif-item:last-child{ border-bottom: none; }
.fx-notif-item-title{ font-weight: 600; }
.fx-notif-item-why{ font-size: var(--fs-xs); margin-top: 2px; }

/* ---------------------------------------------------------------------
   Истории — горизонтальный ряд высоких карточек с картинкой (ТЗ-образец):
   104×172, скругление 14px, затемнение снизу, кольцо-аватар сверху слева,
   крупная белая цифра + подпись в две строки внизу.
   --------------------------------------------------------------------- */

.stories{
  display: flex;
  gap: 10px;
  overflow-x: auto;
  padding: 12px 16px;
  scrollbar-width: none;
}
.stories::-webkit-scrollbar{ display: none; }

.story{
  flex: 0 0 auto;
  position: relative;
  isolation: isolate;
  width: 104px;
  height: 172px;
  min-height: 44px;
  border-radius: 14px;
  overflow: hidden;
  padding: 8px;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  gap: 2px;
  background: var(--surface-2);
  border: none;
  cursor: pointer;
}

.story-img{
  position: absolute;
  inset: 0;
  z-index: -2;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.story::after{
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  background: linear-gradient(180deg, rgba(0,0,0,0) 40%, rgba(0,0,0,.72));
}

.story-ring{
  position: absolute;
  top: 8px;
  left: 8px;
  z-index: 1;
  width: 26px;
  height: 26px;
  border-radius: 999px;
  border: 2px solid rgba(255,255,255,.92);
  background: rgba(255,255,255,.16);
}

.story-content{
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.story-card-hero{ color: #fff; font-size: 20px; line-height: 1.05; }
.story-card-hero .num-hero-unit{ color: rgba(255,255,255,.85); }

.story-label{
  font-size: var(--fs-2xs);
  color: #fff;
  text-align: left;
  max-width: 100%;
}

/* ---------------------------------------------------------------------
   Нижний лист (.sheet) + подложка
   --------------------------------------------------------------------- */

.sheet-scrim{
  position: fixed;
  inset: 0;
  background: rgba(11, 18, 16, .45);
  z-index: 70;
  opacity: 0;
  transition: opacity .2s ease;
}
.sheet-scrim.is-open{ opacity: 1; }

.sheet{
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 71;
  max-width: 520px;
  margin-inline: auto;
  max-height: 85vh;
  overflow-y: auto;
  background: var(--surface);
  border-radius: var(--r-md) var(--r-md) 0 0;
  padding: 10px 16px calc(16px + env(safe-area-inset-bottom, 0px));
  box-shadow: 0 -8px 30px rgba(0,0,0,.18);
  transform: translateY(100%);
  transition: transform .25s ease;
}
.sheet.is-open{ transform: translateY(0); }

.sheet-grabber{
  width: 36px;
  height: 4px;
  border-radius: 999px;
  background: var(--line);
  margin: 4px auto 12px;
}

.sheet-header{
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 12px;
}

.sheet-title{
  font-family: var(--font-display);
  font-size: var(--fs-md);
}

.sheet-close{
  width: 44px;
  height: 44px;
  border-radius: 999px;
  border: none;
  background: var(--surface-2);
  color: var(--ink);
  cursor: pointer;
  flex: 0 0 auto;
}

/* ---------------------------------------------------------------------
   Тост
   --------------------------------------------------------------------- */

.toast{
  position: fixed;
  left: 16px;
  right: 16px;
  bottom: calc(16px + env(safe-area-inset-bottom, 0px));
  z-index: 80;
  max-width: 488px;
  margin-inline: auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: var(--ink);
  color: var(--ground);
  border-radius: var(--r-sm);
  padding: 12px 12px 12px 16px;
  box-shadow: 0 6px 24px rgba(0,0,0,.25);
  transform: translateY(120%);
  opacity: 0;
  transition: transform .2s ease, opacity .2s ease;
}
.toast.is-open{ transform: translateY(0); opacity: 1; }

.toast-text{ font-size: var(--fs-xs); }

.toast-undo{
  flex: 0 0 auto;
  min-height: 36px;
  padding: 6px 12px;
  border-radius: var(--r-sm);
  border: 1px solid rgba(255,255,255,.3);
  background: transparent;
  color: inherit;
  font-weight: 700;
  font-size: var(--fs-xs);
  cursor: pointer;
}

/* ---------------------------------------------------------------------
   Полноэкранный слой (истории / Reels)
   --------------------------------------------------------------------- */

.overlay{
  position: fixed;
  inset: 0;
  z-index: 90;
  background: #000;
  color: #fff;
  display: flex;
  flex-direction: column;
  opacity: 0;
  transition: opacity .2s ease;
}
.overlay.is-open{ opacity: 1; }

.overlay-top{
  padding: calc(10px + env(safe-area-inset-top, 0px)) 12px 10px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.overlay-close{
  width: 44px;
  height: 44px;
  border-radius: 999px;
  border: none;
  background: rgba(255,255,255,.12);
  color: #fff;
  cursor: pointer;
}

.overlay-progress{
  flex: 1;
  display: flex;
  gap: 4px;
}
.overlay-progress-bar{
  flex: 1;
  height: 3px;
  border-radius: 999px;
  background: rgba(255,255,255,.3);
  overflow: hidden;
}
.overlay-progress-bar > span{
  display: block;
  height: 100%;
  width: 0%;
  background: #fff;
}

.overlay-body{
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
}

/* ---------------------------------------------------------------------
   Штриховка «данных нет»
   --------------------------------------------------------------------- */

.hatch{
  background-image: repeating-linear-gradient(
    45deg,
    color-mix(in srgb, var(--nodata) 22%, transparent),
    color-mix(in srgb, var(--nodata) 22%, transparent) 6px,
    transparent 6px,
    transparent 14px
  );
  background-color: var(--surface-2);
  border-radius: var(--r-sm);
}

.nodata{
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px;
  border-radius: var(--r-sm);
  background: var(--surface-2);
  border: 1px dashed var(--line);
}

.nodata-icon{
  flex: 0 0 auto;
  width: 28px;
  height: 28px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--nodata) 25%, var(--surface));
  color: var(--nodata);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--fs-xs);
  font-weight: 700;
}

.nodata-body{ flex: 1; min-width: 0; }

.nodata-reason{
  color: var(--ink);
  font-size: var(--fs-xs);
  margin-bottom: 4px;
}

.nodata-owner{ display: flex; align-items: center; gap: 6px; }

/* ---------------------------------------------------------------------
   Раскрывающийся текст «…koʻproq» / «kamroq» (FX.seeMore)
   --------------------------------------------------------------------- */

.see-more{ margin-top: 10px; }

.see-more-text{
  position: relative;
  overflow: hidden;
  max-height: calc(1.45em * var(--see-more-lines, 4));
  font-size: var(--fs-sm);
  line-height: 1.45;
  color: var(--ink);
  transition: max-height .2s ease;
}
.see-more-text p{ margin: 0 0 6px; }
.see-more-text p:last-child{ margin-bottom: 0; }

.see-more.is-expanded .see-more-text{ max-height: none; }

.see-more-text::after{
  content: "";
  position: absolute;
  left: 0; right: 0; bottom: 0;
  height: 24px;
  background: linear-gradient(180deg, transparent, var(--surface));
  pointer-events: none;
}
.see-more.is-expanded .see-more-text::after,
.see-more:not(.has-overflow) .see-more-text::after{ display: none; }

.see-more-btn{
  display: inline-block;
  margin: 4px -6px -13px 0;
  padding: 13px 6px;
  border: none;
  background: none;
  color: var(--muted);
  font-family: var(--font-body);
  font-size: var(--fs-xs);
  font-weight: 600;
  cursor: pointer;
}

/* ---------------------------------------------------------------------
   Шапка поста (FX.postHead) — эмблема раздела + заголовок + мета + «⋯»
   --------------------------------------------------------------------- */

.fx-post-head{
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}

.fx-post-icon{
  flex: 0 0 auto;
  width: 32px;
  height: 32px;
  border-radius: 999px;
  background: linear-gradient(135deg, var(--teal), var(--amber));
  color: #fff;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: var(--fs-xs);
  display: flex;
  align-items: center;
  justify-content: center;
}

.fx-post-head-text{ flex: 1 1 auto; min-width: 0; }

.fx-post-title{
  font-family: var(--font-body);
  font-weight: 700;
  font-size: var(--fs-sm);
  color: var(--ink);
}

.fx-post-meta{ font-size: var(--fs-xs); margin-top: 1px; }

.fx-post-source-chip{
  height: 16px;
  padding: 0 6px;
  font-size: 10px;
  vertical-align: middle;
}

.fx-post-more{
  flex: 0 0 auto;
  width: 44px;
  height: 44px;
  border: none;
  background: none;
  color: var(--muted);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}
.fx-post-more svg{ width: 20px; height: 20px; }

/* нижний лист «⋯»: список пунктов меню поста */
.fx-menu{
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.fx-menu-item{
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  min-height: 48px;
  padding: 8px 4px;
  border: none;
  background: none;
  color: var(--ink);
  font-family: var(--font-body);
  font-size: var(--fs-sm);
  text-align: left;
  cursor: pointer;
}
.fx-menu-item:active{ background: var(--surface-2); }
.fx-menu-item svg{ flex: 0 0 auto; width: 22px; height: 22px; color: var(--muted); }

/* ---------------------------------------------------------------------
   Реакции (FX.reactions) — «Foydali · Izoh · Ulashish»
   --------------------------------------------------------------------- */

.fx-reactions{ margin-top: 12px; }

.fx-reactions-count{
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: var(--fs-xs);
  margin-bottom: 6px;
}

.fx-reactions-row{
  display: flex;
  border-top: 1px solid var(--line);
}
.fx-reaction-btn{
  flex: 1 1 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 44px;
  border: none;
  border-right: 1px solid var(--line);
  background: none;
  color: var(--muted);
  font-family: var(--font-body);
  font-size: var(--fs-xs);
  font-weight: 600;
  cursor: pointer;
}
.fx-reaction-btn:last-child{ border-right: none; }
.fx-reaction-btn svg{ width: 18px; height: 18px; }
.fx-reaction-btn.is-active{ color: var(--teal); }
.fx-reaction-btn.is-active svg path{ fill: currentColor; }

/* ---------------------------------------------------------------------
   Плашка-предупреждение (FX.noticeHTML) — вместо моноширинной пометки
   --------------------------------------------------------------------- */

.fx-notice{
  display: flex;
  align-items: flex-start;
  gap: 6px;
  margin-top: 8px;
  padding: 8px 10px;
  border-radius: var(--r-sm);
  background: var(--amber-soft);
  color: var(--amber);
  font-family: var(--font-body);
  font-size: var(--fs-xs);
  line-height: 1.4;
}
.fx-notice svg{ flex: 0 0 auto; width: 16px; height: 16px; margin-top: 1px; }

/* ---------------------------------------------------------------------
   Reduced motion — все переходы и анимации выключены
   --------------------------------------------------------------------- */

@media (prefers-reduced-motion: reduce){
  *, *::before, *::after{
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }
}

/* Как на опубликованной странице: атрибут hidden прячет элемент при любом display */
[hidden]{ display: none !important; }

