/* ═══════════════════════════════════════════════════════════════════
 * calendar-mobile.css — мобильная версия календаря (≤ 768px)
 * Источник: mobile-calendar.html (эталон).
 * Все классы с префиксами .m-, .feed-, .week-, .month-, .sheet-
 * Десктопная версия (> 768px) не затрагивается.
 * ═══════════════════════════════════════════════════════════════════
 */

/* ─── Недостающие токены (нет в tokens.css) — глобально ─── */
:root {
  --green-bg: rgba(48,209,88,0.10);
  --green-border: rgba(48,209,88,0.30);
  --red-bg: rgba(255,69,58,0.10);
  --red-border: rgba(255,69,58,0.30);
  --yellow-bg: rgba(255,214,10,0.10);
  --yellow-border: rgba(255,214,10,0.30);
  --blue-bg: rgba(10,132,255,0.10);
  --blue-border: rgba(10,132,255,0.30);
  --purple-bg: rgba(191,90,242,0.10);
  --purple-border: rgba(191,90,242,0.30);
  --gray: #8e8e93;
  --gray-bg: rgba(142,142,147,0.10);
  --gray-border: rgba(142,142,147,0.30);

  --ev-bid: var(--acc);
  --ev-bid-bg: var(--acc-soft);
  --ev-bid-bor: var(--acc-border);
  --ev-inspect: var(--green);
  --ev-inspect-bg: var(--green-bg);
  --ev-inspect-bor: var(--green-border);
  --ev-call: var(--blue);
  --ev-call-bg: var(--blue-bg);
  --ev-call-bor: var(--blue-border);
  --ev-remind: var(--yellow);
  --ev-remind-bg: var(--yellow-bg);
  --ev-remind-bor: var(--yellow-border);
  --ev-other: var(--gray);
  --ev-other-bg: var(--gray-bg);
  --ev-other-bor: var(--gray-border);
}

/* ═══════════ Мобилка (≤ 768px) ═══════════ */
@media (max-width: 768px) {

  /* Скрыть десктопные элементы календаря */
  body.cal-mobile-active .cal-toolbar,
  body.cal-mobile-active .cal-preview-panel,
  body.cal-mobile-active .cal-body { display: none !important; }

  /* ═══════════ MOBILE APP ═══════════ */
  .m-app {
    width: 100%;
    background: var(--bg0);
    display: flex;
    flex-direction: column;
    position: relative;
    font-size: 14px;
    min-height: calc(100vh - 56px); /* минус глобальная шапка проекта */
  }

  /* Тулбар (Сегодня · Май · .ics) */
  .m-toolbar {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    background: var(--bg1);
    border-bottom: 1px solid var(--bg4);
    flex-shrink: 0;
  }
  .m-tb-btn {
    padding: 6px 10px;
    border-radius: 8px;
    background: var(--bg2);
    border: 1px solid var(--bg4);
    color: var(--fg0);
    font-size: 12px;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-family: inherit;
    cursor: pointer;
  }
  .m-tb-btn.icon { padding: 6px 8px; color: var(--fg1); }
  .m-tb-title {
    flex: 1;
    text-align: center;
    font-size: 13px;
    font-weight: 700;
    letter-spacing: -0.2px;
    color: var(--fg0);
  }
  .m-tb-title .sub { color: var(--fg2); font-weight: 500; margin-left: 4px; }
  .m-tb-btn.ics { color: var(--acc); font-family: var(--mono); font-size: 11px; }

  /* Переключатель видов — segmented */
  .m-segments {
    display: flex;
    gap: 2px;
    padding: 4px;
    margin: 8px 14px 0;
    background: var(--bg1);
    border: 1px solid var(--bg4);
    border-radius: 10px;
    flex-shrink: 0;
  }
  .m-seg {
    flex: 1;
    padding: 7px 0;
    border-radius: 7px;
    color: var(--fg1);
    font-size: 12px;
    font-weight: 600;
    text-align: center;
    background: transparent;
    border: none;
    font-family: inherit;
    cursor: pointer;
  }
  .m-seg.active {
    background: var(--bg3);
    color: var(--fg0);
    box-shadow: 0 1px 2px rgba(0,0,0,0.3);
  }

  /* Фильтры событий */
  .m-filters {
    display: flex;
    gap: 6px;
    padding: 8px 14px;
    overflow-x: auto;
    flex-shrink: 0;
    scrollbar-width: none;
  }
  .m-filters::-webkit-scrollbar { display: none; }
  .m-filter {
    padding: 5px 9px;
    border-radius: 7px;
    background: var(--bg1);
    border: 1px solid var(--bg4);
    color: var(--fg1);
    font-size: 11px;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    white-space: nowrap;
    font-family: inherit;
    cursor: pointer;
  }
  .m-filter.active {
    background: var(--acc-soft);
    border-color: var(--acc-border);
    color: var(--acc);
  }
  .m-filter .cnt {
    font-family: var(--mono);
    font-size: 10px;
    font-weight: 700;
    padding: 0 4px;
    border-radius: 4px;
    background: var(--bg2);
  }
  .m-filter.active .cnt { background: var(--acc); color: #fff; }
  .m-filter .dotc { width: 7px; height: 7px; border-radius: 50%; }

  /* Главный контент */
  .m-main {
    flex: 1;
    min-height: 0;
    padding: 0 0 80px;
    background: var(--bg0);
  }

  /* FAB-кнопка «+ Событие» */
  .m-create {
    position: fixed;
    left: 14px;
    right: 14px;
    bottom: 14px;
    height: 48px;
    border-radius: 12px;
    background: var(--acc);
    color: #fff;
    font-size: 14px;
    font-weight: 700;
    letter-spacing: -0.2px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    box-shadow: 0 4px 14px rgba(255,106,47,0.4), 0 1px 2px rgba(0,0,0,0.4);
    border: none;
    font-family: inherit;
    cursor: pointer;
    z-index: 40;
  }
  .m-create:active { background: var(--acc-dim); }

  /* ═══════════════════════════════════════════════════════
     ВАРИАНТ A: ЛЕНТА
     ═══════════════════════════════════════════════════════ */
  .feed { padding: 8px 0 24px; }
  .feed-day {
    padding: 14px 14px 4px;
    display: flex;
    align-items: baseline;
    gap: 8px;
    justify-content: space-between;
  }
  .feed-day .l { display: flex; align-items: baseline; gap: 8px; }
  .feed-day .h { font-size: 18px; font-weight: 800; letter-spacing: -0.5px; color: var(--fg0); }
  .feed-day .h.today { color: var(--acc); }
  .feed-day .dow {
    font-size: 11px;
    color: var(--fg2);
    text-transform: uppercase;
    font-weight: 700;
    letter-spacing: 0.5px;
  }
  .feed-day .cnt { font-size: 11px; color: var(--fg2); }

  .feed-now {
    margin: 8px 14px 0;
    padding: 6px 10px;
    background: linear-gradient(90deg, var(--acc-soft), transparent);
    border-left: 2px solid var(--acc);
    font-size: 11px;
    color: var(--acc);
    font-weight: 700;
    letter-spacing: -0.2px;
    display: flex;
    align-items: center;
    gap: 8px;
  }
  .feed-now .pulse {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--acc);
    box-shadow: 0 0 0 4px var(--acc-soft);
  }

  .feed-event {
    margin: 8px 14px 0;
    padding: 12px 12px;
    background: var(--bg1);
    border: 1px solid var(--bg4);
    border-radius: 14px;
    border-left: 3px solid var(--ev-other);
    display: flex;
    flex-direction: column;
    gap: 6px;
    transition: transform .15s, background .15s;
    cursor: pointer;
  }
  .feed-event:active { background: var(--bg2); transform: scale(0.99); }
  .feed-event.bid { border-left-color: var(--ev-bid); }
  .feed-event.inspect { border-left-color: var(--ev-inspect); }
  .feed-event.call { border-left-color: var(--ev-call); }
  .feed-event.remind { border-left-color: var(--ev-remind); }

  .feed-event-top { display: flex; align-items: center; gap: 8px; }
  .feed-event-time {
    font-family: var(--mono);
    font-size: 13px;
    font-weight: 700;
    color: var(--fg0);
    letter-spacing: -0.3px;
  }
  .feed-event-type {
    padding: 2px 7px;
    border-radius: 6px;
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.4px;
  }
  .feed-event.bid .feed-event-type { background: var(--ev-bid-bg); color: var(--ev-bid); }
  .feed-event.inspect .feed-event-type { background: var(--ev-inspect-bg); color: var(--ev-inspect); }
  .feed-event.call .feed-event-type { background: var(--ev-call-bg); color: var(--ev-call); }
  .feed-event.remind .feed-event-type { background: var(--ev-remind-bg); color: var(--ev-remind); }

  .feed-event-title {
    font-size: 14px;
    font-weight: 700;
    color: var(--fg0);
    letter-spacing: -0.2px;
  }
  .feed-event-sub {
    font-size: 12px;
    color: var(--fg1);
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
  }
  .feed-event-sub .price {
    font-family: var(--mono);
    color: var(--acc);
    font-weight: 700;
  }
  .feed-event-sub .src {
    padding: 1px 6px;
    border-radius: 4px;
    background: var(--bg2);
    color: var(--fg2);
    font-size: 10px;
    font-family: var(--mono);
    font-weight: 700;
  }

  .feed-empty {
    padding: 14px;
    margin: 8px 14px 0;
    border: 1px dashed var(--bg4);
    border-radius: 12px;
    color: var(--fg2);
    font-size: 12px;
    text-align: center;
  }

  /* ═══════════════════════════════════════════════════════
     ВАРИАНТ B: НЕДЕЛЯ
     ═══════════════════════════════════════════════════════ */
  .week-strip {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 4px;
    padding: 10px 14px;
    background: var(--bg1);
    border-bottom: 1px solid var(--bg4);
  }
  .wd {
    aspect-ratio: 1/1.2;
    border-radius: 10px;
    background: var(--bg2);
    border: 1px solid var(--bg4);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    position: relative;
    transition: all .15s;
    cursor: pointer;
  }
  .wd:active { transform: scale(0.95); }
  .wd .dow {
    font-size: 9px;
    font-weight: 700;
    color: var(--fg2);
    text-transform: uppercase;
    letter-spacing: 0.4px;
  }
  .wd .num {
    font-size: 16px;
    font-weight: 800;
    color: var(--fg0);
    letter-spacing: -0.5px;
  }
  .wd .dots {
    display: flex;
    gap: 2px;
    height: 6px;
    align-items: center;
  }
  .wd .dt { width: 5px; height: 5px; border-radius: 50%; }
  .wd.today { background: var(--acc-soft); border-color: var(--acc-border); }
  .wd.today .num,
  .wd.today .dow { color: var(--acc); }
  .wd.selected { background: var(--bg3); border-color: var(--fg2); }
  .wd.selected .num { color: var(--fg0); }

  .week-day-head {
    padding: 14px 14px 6px;
    display: flex;
    align-items: baseline;
    justify-content: space-between;
  }
  .week-day-head .l { display: flex; align-items: baseline; gap: 8px; }
  .week-day-head h2 {
    font-size: 20px;
    font-weight: 800;
    letter-spacing: -0.5px;
    margin: 0;
    color: var(--fg0);
  }
  .week-day-head .dow {
    font-size: 12px;
    color: var(--fg2);
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
  }
  .week-day-head .cnt { font-size: 11px; color: var(--fg2); }

  .week-events {
    padding: 0 14px;
    display: flex;
    flex-direction: column;
    gap: 8px;
  }
  .we {
    padding: 11px 12px;
    background: var(--bg1);
    border: 1px solid var(--bg4);
    border-radius: 12px;
    display: flex;
    gap: 10px;
    align-items: flex-start;
    border-left: 3px solid var(--ev-other);
    cursor: pointer;
  }
  .we:active { background: var(--bg2); }
  .we.bid { border-left-color: var(--ev-bid); }
  .we.inspect { border-left-color: var(--ev-inspect); }
  .we.call { border-left-color: var(--ev-call); }
  .we.remind { border-left-color: var(--ev-remind); }
  .we-time {
    flex-shrink: 0;
    font-family: var(--mono);
    font-size: 13px;
    font-weight: 700;
    color: var(--fg0);
    min-width: 50px;
  }
  .we-time .end {
    color: var(--fg2);
    font-size: 11px;
    display: block;
  }
  .we-body { flex: 1; min-width: 0; }
  .we-title {
    font-size: 14px;
    font-weight: 700;
    color: var(--fg0);
    letter-spacing: -0.2px;
  }
  .we-sub {
    font-size: 12px;
    color: var(--fg1);
    margin-top: 2px;
  }
  .we-sub .price {
    color: var(--acc);
    font-family: var(--mono);
    font-weight: 700;
  }

  /* ═══════════════════════════════════════════════════════
     ВАРИАНТ C: МЕСЯЦ
     ═══════════════════════════════════════════════════════ */
  .month-head {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    padding: 6px 8px 4px;
    background: var(--bg1);
    border-bottom: 1px solid var(--bg4);
  }
  .month-head div {
    text-align: center;
    font-size: 10px;
    font-weight: 700;
    color: var(--fg2);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 4px 0;
  }
  .month-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 1px;
    background: var(--bg4);
    border-bottom: 1px solid var(--bg4);
  }
  .mc {
    aspect-ratio: 1/1.05;
    background: var(--bg0);
    padding: 4px 5px;
    display: flex;
    flex-direction: column;
    position: relative;
    transition: background .15s;
    cursor: pointer;
  }
  .mc:active { background: var(--bg1); }
  .mc.outside { background: var(--bg1); opacity: 0.45; }
  .mc .num {
    font-size: 12px;
    font-weight: 600;
    color: var(--fg0);
    letter-spacing: -0.2px;
    line-height: 1.2;
  }
  .mc.outside .num { color: var(--fg2); font-weight: 500; }
  .mc.today { background: var(--acc-soft); }
  .mc.today .num { color: var(--acc); font-weight: 800; }
  .mc.selected { box-shadow: inset 0 0 0 2px var(--acc); }
  .mc-fill {
    flex: 1;
    display: flex;
    align-items: flex-end;
    justify-content: flex-start;
    gap: 3px;
    flex-wrap: wrap;
  }
  .mc-dot { width: 6px; height: 6px; border-radius: 50%; }
  .mc-cnt {
    margin-top: auto;
    font-family: var(--mono);
    font-size: 10px;
    font-weight: 700;
    background: var(--acc);
    color: #fff;
    padding: 1px 4px;
    border-radius: 4px;
    align-self: flex-start;
    line-height: 1.3;
  }
  .mc.has-event .num { color: var(--fg0); }

  .month-day-list {
    padding: 12px 14px 4px;
    border-top: 1px solid var(--bg4);
  }
  .mdl-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    margin-bottom: 8px;
  }
  .mdl-head h3 {
    font-size: 16px;
    font-weight: 800;
    letter-spacing: -0.3px;
    margin: 0;
    color: var(--fg0);
  }
  .mdl-head h3 .dow {
    color: var(--fg2);
    font-weight: 600;
    font-size: 11px;
    margin-left: 6px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
  }
  .mdl-head .cnt { font-size: 11px; color: var(--fg2); }

  /* ═══════════════════════════════════════════════════════
     BOTTOM SHEET
     ═══════════════════════════════════════════════════════ */
  .sheet-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 9000;
    opacity: 0;
    pointer-events: none;
    transition: opacity .2s;
  }
  .sheet-overlay.show { opacity: 1; pointer-events: auto; }
  .sheet {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--bg1);
    border-top: 1px solid var(--bg4);
    border-radius: 20px 20px 0 0;
    padding: 8px 0 24px;
    z-index: 9001;
    transform: translateY(100%);
    transition: transform .25s cubic-bezier(.2,.8,.2,1);
    max-height: 85vh;
    overflow-y: auto;
  }
  .sheet.show { transform: translateY(0); }
  .sheet-handle {
    width: 36px;
    height: 5px;
    border-radius: 3px;
    background: var(--bg4);
    margin: 0 auto 14px;
  }
  .sheet-content { padding: 0 16px; }
  .sheet-type-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 10px;
  }
  .sheet-type {
    padding: 3px 8px;
    border-radius: 6px;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.4px;
  }
  .sheet-type.bid { background: var(--ev-bid-bg); color: var(--ev-bid); }
  .sheet-type.inspect { background: var(--ev-inspect-bg); color: var(--ev-inspect); }
  .sheet-type.call { background: var(--ev-call-bg); color: var(--ev-call); }
  .sheet-type.remind { background: var(--ev-remind-bg); color: var(--ev-remind); }
  .sheet-time {
    font-family: var(--mono);
    font-size: 13px;
    font-weight: 700;
    color: var(--fg0);
  }
  .sheet-title {
    font-size: 20px;
    font-weight: 800;
    letter-spacing: -0.5px;
    margin: 0 0 4px;
    color: var(--fg0);
  }
  .sheet-meta {
    font-size: 13px;
    color: var(--fg1);
    margin-bottom: 14px;
  }
  .sheet-deposit {
    padding: 10px 12px;
    background: var(--ev-bid-bg);
    border: 1px solid var(--ev-bid-bor);
    border-radius: 10px;
    font-size: 12px;
    color: var(--fg0);
    margin-bottom: 10px;
  }
  .sheet-deposit-label {
    font-size: 10px;
    color: var(--ev-bid);
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 4px;
  }
  .sheet-deposit-row {
    display: flex;
    justify-content: space-between;
  }
  .sheet-deposit-row .v {
    font-family: var(--mono);
    font-weight: 700;
  }
  .sheet-deposit-row .d { color: var(--fg1); }

  .sheet-card {
    margin-top: 12px;
    padding: 12px;
    background: var(--bg2);
    border: 1px solid var(--bg4);
    border-radius: 12px;
    display: flex;
    gap: 10px;
    align-items: flex-start;
    cursor: pointer;
  }
  .sheet-card .thumb {
    width: 52px;
    height: 52px;
    border-radius: 8px;
    background: var(--bg3);
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    overflow: hidden;
  }
  .sheet-card .thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
  }
  .sheet-card .info { flex: 1; min-width: 0; }
  .sheet-card .info .ttl {
    font-size: 13px;
    font-weight: 700;
    color: var(--fg0);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .sheet-card .info .sub {
    font-size: 11px;
    color: var(--fg1);
    margin-top: 2px;
  }
  .sheet-card .price {
    font-family: var(--mono);
    font-size: 14px;
    font-weight: 700;
    color: var(--acc);
    margin-top: 4px;
  }
  .sheet-card .arrow {
    color: var(--fg2);
    align-self: center;
    font-size: 18px;
  }

  .sheet-actions {
    margin-top: 14px;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
  }
  .sheet-act {
    padding: 11px;
    border-radius: 10px;
    background: var(--bg2);
    border: 1px solid var(--bg4);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    font-size: 13px;
    font-weight: 600;
    color: var(--fg0);
    font-family: inherit;
    cursor: pointer;
  }
  .sheet-act.primary {
    background: var(--acc);
    border-color: var(--acc);
    color: #fff;
    grid-column: 1 / -1;
  }
  .sheet-act.danger { color: var(--red); }

} /* end @media (max-width: 768px) */

/* ═══════════ Light theme overrides (мобилка) ═══════════ */
@media (max-width: 768px) {
  [data-theme="light"] .feed-event,
  [data-theme="light"] .we,
  [data-theme="light"] .feed-empty {
    background: var(--bg1);
    border-color: var(--bg3);
  }
  [data-theme="light"] .mc { background: var(--bg0); }
  [data-theme="light"] .mc.outside { background: var(--bg1); }
  [data-theme="light"] .month-grid { background: var(--bg3); }
  [data-theme="light"] .sheet { background: var(--bg1); }
  [data-theme="light"] .sheet-card { background: var(--bg2); }
}
