/* ============================================================
   Дружба · Афиша — база: темы, шапка, кнопки, оверлеи
   Палитра плеера DrujbaTV (#131313 / #E10300) поверх «скелета» Google Таблиц
   ============================================================ */

:root {
  --accent: #e10300;
  --accent-ink: #ffffff;
  --radius: 8px;
  --radius-sm: 6px;
  --appbar-h: 56px;
  --font: 'Google Sans', 'Segoe UI', Roboto, 'Helvetica Neue', Arial, 'Noto Sans', sans-serif;
  --mono: 'Roboto Mono', 'Cascadia Mono', Consolas, monospace;

  /* редкости CS2 */
  --r-consumer: #4b69ff;
  --r-restricted: #8847ff;
  --r-classified: #d32ce6;
  --r-covert: #eb4b4b;
  --r-gold: #ffd700;
}

html[data-theme='dark'] {
  --bg: #131313;
  --bg-chrome: #1e1e1e;
  --bg-elev: #232324;
  --bg-elev2: #2a2a2c;
  --bg-grid: #171717;
  --bg-cell: #1a1a1a;
  --bg-head: #262628;
  --line: rgba(217, 217, 217, 0.18);
  --line-strong: rgba(217, 217, 217, 0.32);
  --ink: #ffffff;
  --ink-2: #b9b9b9;
  --ink-3: #707070;
  --chip: rgba(255, 255, 255, 0.12);
  --chip-soft: rgba(255, 255, 255, 0.07);
  --hover: rgba(255, 255, 255, 0.07);
  --ok: #3ddc97;
  --warn: #ffbb33;
  --shadow: 0 8px 28px rgba(0, 0, 0, 0.6);
  --pick: rgba(61, 220, 151, 0.16);
  --pick-line: rgba(61, 220, 151, 0.75);
  color-scheme: dark;
}

html[data-theme='light'] {
  --bg: #ffffff;
  --bg-chrome: #f8f9fa;
  --bg-elev: #ffffff;
  --bg-elev2: #f1f3f4;
  --bg-grid: #ffffff;
  --bg-cell: #ffffff;
  --bg-head: #f1f3f4;
  --line: rgba(0, 0, 0, 0.14);
  --line-strong: rgba(0, 0, 0, 0.28);
  --ink: #202124;
  --ink-2: #5f6368;
  --ink-3: #80868b;
  --chip: rgba(0, 0, 0, 0.08);
  --chip-soft: rgba(0, 0, 0, 0.05);
  --hover: rgba(0, 0, 0, 0.06);
  --ok: #128a5b;
  --warn: #b06000;
  --shadow: 0 8px 28px rgba(0, 0, 0, 0.18);
  --pick: rgba(18, 138, 91, 0.13);
  --pick-line: rgba(18, 138, 91, 0.7);
  color-scheme: light;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  overscroll-behavior: none;
}

body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.45;
  display: flex;
  flex-direction: column;
  height: 100dvh;
  overflow: hidden;
  -webkit-tap-highlight-color: transparent;
}

h1, h2, h3 { margin: 0; font-weight: 500; }
button, input, select, textarea { font: inherit; color: inherit; }
::selection { background: color-mix(in srgb, var(--accent) 45%, transparent); }

.muted { color: var(--ink-2); }
.small { font-size: 12px; }
[hidden] { display: none !important; }

/* скроллбары «как в таблицах» */
* { scrollbar-width: thin; scrollbar-color: var(--line-strong) transparent; }
*::-webkit-scrollbar { width: 12px; height: 12px; }
*::-webkit-scrollbar-thumb { background: var(--line-strong); border-radius: 8px; border: 3px solid transparent; background-clip: content-box; }
*::-webkit-scrollbar-thumb:hover { background: var(--ink-3); background-clip: content-box; }
*::-webkit-scrollbar-track { background: transparent; }

/* ------------------------- Шапка ------------------------- */
.appbar {
  flex: 0 0 auto;
  height: var(--appbar-h);
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 12px;
  background: var(--bg-chrome);
  border-bottom: 1px solid var(--line);
  position: relative;
  z-index: 40;
}

.appbar__left { display: flex; align-items: center; gap: 10px; min-width: 0; }
.appbar__logo {
  width: 34px; height: 34px; object-fit: contain; flex: 0 0 auto;
  filter: drop-shadow(0 0 6px rgba(225, 3, 0, 0.35));
}
html[data-theme='light'] .appbar__logo { filter: invert(1) drop-shadow(0 0 3px rgba(225, 3, 0, 0.3)); }

.appbar__titles { min-width: 0; }
.appbar__name {
  font-size: 15px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  max-width: 34vw;
}
.menubar { display: flex; gap: 2px; margin-left: -6px; }
.menubar__item {
  background: none; border: 0; color: var(--ink-2); font-size: 12px; padding: 1px 6px;
  border-radius: 4px; cursor: pointer;
}
.menubar__item:hover { background: var(--hover); color: var(--ink); }

.appbar__tabs {
  display: flex; gap: 8px; margin: 0 auto;
  position: absolute; left: 50%; transform: translateX(-50%);
}
.vtab {
  display: flex; align-items: center; gap: 7px;
  background: transparent; border: 1px solid var(--line-strong); color: var(--ink-2);
  padding: 7px 18px; border-radius: 999px; cursor: pointer; font-size: 14px;
  transition: background .15s, color .15s, border-color .15s;
  white-space: nowrap;
}
.vtab:hover { background: var(--hover); color: var(--ink); }
.vtab.is-active {
  background: color-mix(in srgb, var(--accent) 16%, transparent);
  border-color: var(--accent); color: var(--ink);
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--accent) 35%, transparent) inset;
}
.vtab__ico { font-size: 15px; line-height: 1; }

.appbar__right { margin-left: auto; display: flex; align-items: center; gap: 8px; }

.badge {
  font-size: 11px; padding: 3px 8px; border-radius: 999px; letter-spacing: .04em;
  text-transform: uppercase; border: 1px solid var(--line-strong); color: var(--ink-2);
}
.badge--admin { color: var(--accent); border-color: color-mix(in srgb, var(--accent) 60%, transparent); background: color-mix(in srgb, var(--accent) 12%, transparent); }
.badge--view { color: var(--ink-3); }

.iconbtn {
  width: 34px; height: 34px; border-radius: 50%; border: 1px solid var(--line);
  background: transparent; cursor: pointer; display: grid; place-items: center;
  color: var(--ink-2); font-size: 12px; transition: background .15s;
}
.iconbtn:hover { background: var(--hover); color: var(--ink); }
.iconbtn__dot {
  width: 15px; height: 15px; border-radius: 50%;
  background: linear-gradient(135deg, var(--accent) 50%, var(--bg) 50%);
  border: 1px solid var(--line-strong);
}
.iconbtn--lang { width: auto; padding: 0 11px; border-radius: 999px; font-size: 12px; font-weight: 500; }

/* ------------------------- Кнопки ------------------------- */
.btn {
  display: inline-flex; align-items: center; gap: 7px;
  background: var(--bg-elev2); color: var(--ink);
  border: 1px solid var(--line); border-radius: var(--radius-sm);
  padding: 8px 14px; cursor: pointer; white-space: nowrap;
  transition: background .15s, border-color .15s, transform .08s;
}
.btn:hover { background: var(--hover); border-color: var(--line-strong); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .45; cursor: not-allowed; transform: none; }
.btn--primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 500; }
.btn--primary:hover { background: color-mix(in srgb, var(--accent) 85%, #fff); border-color: transparent; }
.btn--ghost { background: transparent; }
.btn--danger { color: #ff6b6b; }
.btn--sm { padding: 6px 11px; font-size: 13px; }
.btn--xs { padding: 4px 9px; font-size: 12px; }
.btn__ico { font-size: 14px; line-height: 1; }

.chip {
  display: inline-grid; place-items: center; min-width: 20px; height: 20px; padding: 0 6px;
  border-radius: 999px; background: var(--chip); font-size: 11px; color: var(--ink-2);
}
.chip--pool { background: color-mix(in srgb, var(--ok) 25%, transparent); color: var(--ok); }

.input {
  width: 100%; background: var(--bg-elev); color: var(--ink);
  border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 8px 10px;
}
.input:focus { outline: none; border-color: var(--accent); }
.input:disabled { opacity: .45; }

/* ------------------------- Виды ------------------------- */
.view { flex: 1 1 auto; min-height: 0; display: none; flex-direction: column; }
.view.is-active { display: flex; }

/* ------------------------- Оверлеи ------------------------- */
.tooltip {
  position: fixed; z-index: 90; pointer-events: none;
  background: #1a1a1acc; backdrop-filter: blur(10px);
  border: 1px solid var(--line-strong); border-radius: 10px;
  padding: 10px 12px; min-width: 220px; max-width: 330px;
  box-shadow: var(--shadow); color: #fff;
  animation: tipIn .12s ease-out;
}
html[data-theme='light'] .tooltip { background: #202124f2; }
@keyframes tipIn { from { opacity: 0; transform: translateY(4px); } }
.tooltip__title { font-weight: 600; font-size: 14px; margin-bottom: 7px; line-height: 1.25; }
.tooltip__row { display: flex; gap: 7px; font-size: 12.5px; color: #dcdcdc; padding: 2px 0; align-items: flex-start; }
.tooltip__ico { flex: 0 0 auto; width: 16px; text-align: center; }
.tooltip__k { color: #9aa0a6; }
.tooltip__rar { margin-top: 8px; font-size: 11px; text-transform: uppercase; letter-spacing: .06em; display: flex; align-items: center; gap: 6px; }
.tooltip__rar i { width: 9px; height: 9px; border-radius: 2px; display: inline-block; }

.ctxmenu {
  position: fixed; z-index: 95; min-width: 216px; padding: 6px;
  background: var(--bg-elev2); border: 1px solid var(--line-strong);
  border-radius: 10px; box-shadow: var(--shadow);
}
.ctxmenu button {
  display: flex; align-items: center; gap: 10px; width: 100%; text-align: left;
  background: none; border: 0; padding: 8px 10px; border-radius: 6px; cursor: pointer; font-size: 13px;
}
.ctxmenu button:hover { background: var(--hover); }
.ctxmenu button:disabled { opacity: .4; cursor: not-allowed; }
.ctxmenu hr { border: 0; border-top: 1px solid var(--line); margin: 5px 2px; }
.ctxmenu .danger { color: #ff6b6b; }

.popover {
  position: fixed; z-index: 95; min-width: 200px; padding: 10px;
  background: var(--bg-elev2); border: 1px solid var(--line-strong);
  border-radius: 10px; box-shadow: var(--shadow);
}
.popover h4 { margin: 0 0 8px; font-size: 12px; text-transform: uppercase; letter-spacing: .05em; color: var(--ink-3); font-weight: 500; }
.popover .pop-row { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 10px; }
.popover .pop-row:last-child { margin-bottom: 0; }
.popover .pop-btn {
  flex: 1 1 auto; background: var(--chip-soft); border: 1px solid transparent; color: var(--ink);
  border-radius: 6px; padding: 7px 10px; cursor: pointer; font-size: 13px; text-align: center;
}
.popover .pop-btn:hover { background: var(--hover); }
.popover .pop-btn.is-on { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 16%, transparent); }
.popover .swatch { width: 26px; height: 26px; border-radius: 50%; border: 2px solid transparent; cursor: pointer; }
.popover .swatch.is-on { border-color: var(--ink); box-shadow: 0 0 0 2px var(--bg-elev2) inset; }

/* ------------------------- Тосты ------------------------- */
.toasts {
  position: fixed; z-index: 120; left: 50%; bottom: 68px; transform: translateX(-50%);
  display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none;
  width: min(92vw, 520px);
}
.toast {
  background: #2a2a2ce8; color: #fff; border: 1px solid var(--line-strong);
  border-radius: 10px; padding: 10px 14px; box-shadow: var(--shadow); font-size: 13px;
  display: flex; gap: 9px; align-items: center; animation: toastIn .18s ease-out; backdrop-filter: blur(8px);
  max-width: 100%;
}
.toast--err { border-color: #ff6b6b88; }
.toast--ok { border-color: color-mix(in srgb, var(--ok) 55%, transparent); }
@keyframes toastIn { from { opacity: 0; transform: translateY(10px); } }

/* ------------------------- Модалка ------------------------- */
.modal { position: fixed; inset: 0; z-index: 110; display: grid; place-items: center; padding: 16px; }
.modal__backdrop { position: absolute; inset: 0; background: rgba(0, 0, 0, .6); backdrop-filter: blur(3px); }
.modal__box {
  position: relative; width: min(560px, 100%); max-height: 88dvh; display: flex; flex-direction: column;
  background: var(--bg-elev2); border: 1px solid var(--line-strong); border-radius: 14px;
  box-shadow: var(--shadow); animation: modalIn .16s ease-out; overflow: hidden;
}
@keyframes modalIn { from { opacity: 0; transform: translateY(12px) scale(.98); } }
.modal__head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 16px; border-bottom: 1px solid var(--line); }
.modal__head h3 { font-size: 16px; }
.modal__body { padding: 16px; overflow: auto; }
.modal__foot { display: flex; gap: 8px; justify-content: flex-end; padding: 12px 16px; border-top: 1px solid var(--line); flex-wrap: wrap; }
.field { margin-bottom: 12px; }
.field label { display: block; font-size: 12px; color: var(--ink-2); margin-bottom: 5px; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

/* ------------------------- Загрузка ------------------------- */
.loader { position: fixed; inset: 0; z-index: 130; display: grid; place-items: center; background: rgba(0, 0, 0, .35); }
.loader__spin {
  width: 42px; height: 42px; border-radius: 50%;
  border: 3px solid var(--chip); border-top-color: var(--accent); animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ------------------------- Мобилка ------------------------- */
@media (max-width: 900px) {
  .appbar { height: auto; padding: 8px 10px; flex-wrap: wrap; gap: 8px; }
  .appbar__tabs { position: static; transform: none; order: 3; width: 100%; justify-content: center; }
  .menubar { display: none; }
  .appbar__name { max-width: 46vw; font-size: 14px; }
  .vtab { flex: 1 1 0; justify-content: center; padding: 8px 10px; }
  .badge--view, .badge--admin { display: none; }
  .toasts { bottom: 16px; }
}
@media (max-width: 420px) {
  .appbar__logo { width: 28px; height: 28px; }
}
