/* Премиум-чат Гиски. Три дизайна на одних переменных: «Стекло» (по умолчанию), «Оникс», «Редакция».
   Выбранный дизайн ставит design.js в <html data-design> до первой отрисовки. */
:root, [data-design="glass"] {
  color-scheme: dark;
  --bg: linear-gradient(135deg, #1b1f4b, #4b1d5e 45%, #0f5967);
  --glow: radial-gradient(520px 380px at 18% 18%, rgba(255, 120, 200, 0.42), transparent 60%), radial-gradient(560px 400px at 82% 72%, rgba(80, 220, 255, 0.36), transparent 60%), radial-gradient(420px 320px at 60% 8%, rgba(140, 120, 255, 0.48), transparent 60%);
  --fg: #ffffff;
  --fg-2: rgba(255, 255, 255, 0.68);
  --line: rgba(255, 255, 255, 0.16);
  --panel: rgba(255, 255, 255, 0.08);
  --panel-solid: #34245e;
  --blur: blur(28px) saturate(150%);
  --field: rgba(255, 255, 255, 0.12);
  --chip-act: #ffffff;
  --chip-act-fg: #2a1f5c;
  --item-act: rgba(255, 255, 255, 0.18);
  --in-bg: rgba(255, 255, 255, 0.16);
  --in-line: rgba(255, 255, 255, 0.2);
  --out-bg: linear-gradient(135deg, #ff6fb5, #7a6bff);
  --out-fg: #ffffff;
  --out-shadow: 0 10px 30px -12px rgba(122, 107, 255, 0.8);
  --accent: linear-gradient(135deg, #ff7ac8, #7a8bff 55%, #4fe0ff);
  --accent-fg: #ffffff;
  --accent-ink: #ffb3e1;
  --badge: #ffffff;
  --badge-fg: #4b1d5e;
  --danger: #ff8a8a;
  --online: #5dffb0;
  --display: var(--sans);
  --radius: 20px;
}
[data-design="onyx"] {
  color-scheme: dark;
  --bg: #0b0c0f;
  --glow: radial-gradient(900px 500px at 70% 0%, rgba(212, 178, 111, 0.09), transparent 60%);
  --fg: #f1ede4;
  --fg-2: #a39e93;
  --line: #262931;
  --panel: #111317;
  --panel-solid: #111317;
  --blur: none;
  --field: #1a1d22;
  --chip-act: #2b2416;
  --chip-act-fg: #e6c88a;
  --item-act: linear-gradient(90deg, #2b2416, #191b20);
  --in-bg: #191c22;
  --in-line: #272a32;
  --out-bg: linear-gradient(150deg, #3a2f18, #2a2416);
  --out-fg: #f1ede4;
  --out-shadow: none;
  --accent: linear-gradient(140deg, #e9cd8e, #b48c45);
  --accent-fg: #17120a;
  --accent-ink: #e6c88a;
  --badge: linear-gradient(140deg, #e9cd8e, #b48c45);
  --badge-fg: #17120a;
  --danger: #f0705f;
  --online: #63c191;
  --display: var(--serif);
  --radius: 18px;
}
[data-design="editorial"] {
  color-scheme: light;
  --bg: #f6f3ec;
  --glow: none;
  --fg: #16151a;
  --fg-2: #6d675d;
  --line: #ddd6c8;
  --panel: #efebe2;
  --panel-solid: #efebe2;
  --blur: none;
  --field: #ffffff;
  --chip-act: transparent;
  --chip-act-fg: #16151a;
  --item-act: #ffffff;
  --in-bg: #ffffff;
  --in-line: #e4ddcf;
  --out-bg: #16151a;
  --out-fg: #f6f3ec;
  --out-shadow: none;
  --accent: #16151a;
  --accent-fg: #f6f3ec;
  --accent-ink: #b2352f;
  --badge: #b2352f;
  --badge-fg: #ffffff;
  --danger: #b2352f;
  --online: #2b7552;
  --display: var(--serif);
  --radius: 18px;
}
:root {
  --sans: "IBM Plex Sans", system-ui, "Segoe UI", sans-serif;
  --serif: "Playfair Display", Georgia, serif;
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body { margin: 0; font-family: var(--sans); font-size: 15px; line-height: 1.45; color: var(--fg); background: var(--bg); background-attachment: fixed; overflow: hidden; -webkit-font-smoothing: antialiased; }
body::before { content: ""; position: fixed; inset: -10%; background: var(--glow); filter: blur(12px); pointer-events: none; z-index: 0; }
button, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--accent-ink); outline-offset: 2px; }

/* лёгкий режим стекла: без размытия, если браузер его не умеет или просили меньше эффектов */
@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) { :root { --panel: var(--panel-solid); } }
@media (prefers-reduced-transparency: reduce), (prefers-reduced-motion: reduce) {
  :root { --blur: none; --panel: var(--panel-solid); }
  * { transition: none !important; animation: none !important; }
}

.mark { width: 36px; height: 36px; border-radius: 12px; display: inline-grid; place-items: center; flex: none; font-weight: 700; background: var(--accent); color: var(--accent-fg); border: 0; font-family: var(--display); font-size: 17px; }
[data-design="editorial"] .mark { background: transparent; color: var(--fg); border: 1.5px solid var(--fg); border-radius: 50%; }
.mark.big { width: 72px; height: 72px; border-radius: 24px; font-size: 34px; }
.icon { width: 40px; height: 40px; border-radius: 50%; border: 0; background: var(--field); display: grid; place-items: center; font-size: 17px; flex: none; }
.primary { border: 0; border-radius: 999px; padding: 12px 22px; background: var(--accent); color: var(--accent-fg); font-weight: 600; }
.ghost { border: 1px solid var(--line); background: transparent; border-radius: 999px; padding: 10px 18px; }
.danger { width: 100%; border: 1px solid var(--danger); color: var(--danger); background: transparent; border-radius: 999px; padding: 12px; }
.err { color: var(--danger); font-size: 13px; }
.empty { padding: 30px 16px; text-align: center; color: var(--fg-2); }

/* ---------- вход ---------- */
.login { position: relative; z-index: 1; min-height: 100%; display: grid; place-items: center; padding: 16px; }
.login-card { width: min(380px, 100%); background: var(--panel); backdrop-filter: var(--blur); -webkit-backdrop-filter: var(--blur); border: 1px solid var(--line); border-radius: 26px; padding: 32px 26px; display: flex; flex-direction: column; gap: 14px; box-shadow: 0 30px 70px -30px rgba(0, 0, 0, 0.6); }
.login-card h1 { margin: 4px 0 0; font-family: var(--display); font-size: 30px; }
.login-card p { margin: 0; color: var(--fg-2); font-size: 13.5px; }
.fld { display: flex; flex-direction: column; gap: 6px; }
.fld span { font-size: 12px; color: var(--fg-2); letter-spacing: 0.06em; text-transform: uppercase; }
.fld input { border: 1px solid var(--line); background: var(--field); border-radius: 14px; padding: 12px 14px; font-size: 16px; }

/* ---------- раскладка ---------- */
.app { position: relative; z-index: 1; height: 100dvh; display: grid; grid-template-columns: 360px minmax(0, 1fr); }
.side { display: flex; flex-direction: column; min-height: 0; background: var(--panel); backdrop-filter: var(--blur); -webkit-backdrop-filter: var(--blur); border-right: 1px solid var(--line); padding-top: env(safe-area-inset-top); }
.side-top { display: flex; align-items: center; gap: 12px; padding: 18px 18px 12px; }
.side-top h1 { flex: 1; margin: 0; font-family: var(--display); font-size: 24px; font-weight: 600; }
.mark-btn { cursor: pointer; }
.search { margin: 0 18px 12px; border: 0; border-radius: 14px; padding: 11px 14px; background: var(--field); font-size: 15px; }
.search::placeholder { color: var(--fg-2); }
[data-design="editorial"] .search { border: 1px solid var(--line); }
.folders { display: flex; gap: 6px; padding: 0 18px 10px; overflow-x: auto; scrollbar-width: none; }
.folders button { flex: none; border: 1px solid transparent; background: none; color: var(--fg-2); border-radius: 999px; padding: 6px 12px; font-size: 13px; }
.folders button[aria-selected="true"] { background: var(--chip-act); color: var(--chip-act-fg); font-weight: 600; }
[data-design="onyx"] .folders button[aria-selected="true"] { box-shadow: inset 0 0 0 1px #6b5627; }
[data-design="editorial"] .folders button[aria-selected="true"] { border-color: var(--fg); }
.list { flex: 1; overflow-y: auto; padding: 2px 10px calc(10px + env(safe-area-inset-bottom)); overscroll-behavior: contain; }
.item { width: 100%; display: grid; grid-template-columns: 50px minmax(0, 1fr) auto; gap: 12px; align-items: center; padding: 10px; border: 0; background: none; border-radius: 16px; text-align: left; transition: background 0.15s; }
.item:hover { background: color-mix(in srgb, var(--fg) 6%, transparent); }
.item[aria-current="true"] { background: var(--item-act); box-shadow: inset 0 0 0 1px var(--line); }
.item b { display: block; font-size: 15px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.item small { display: block; font-size: 13px; color: var(--fg-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.item .meta { display: flex; flex-direction: column; align-items: flex-end; gap: 5px; font-size: 12px; color: var(--fg-2); }
.cnt { min-width: 22px; height: 22px; border-radius: 11px; display: grid; place-items: center; padding: 0 6px; font-size: 12px; font-weight: 700; background: var(--badge); color: var(--badge-fg); }
.item.invite small { color: var(--accent-ink); }
.av { width: 50px; height: 50px; border-radius: 50%; display: grid; place-items: center; font-weight: 600; font-size: 19px; position: relative; flex: none; background: var(--field); font-family: var(--display); }
.av.lg { width: 56px; height: 56px; font-size: 22px; background: var(--accent); color: var(--accent-fg); }
.av.on::after { content: ""; position: absolute; right: 1px; bottom: 1px; width: 12px; height: 12px; border-radius: 50%; background: var(--online); border: 2px solid var(--panel-solid); }
.av[data-hue] { background: hsl(var(--h) 55% 45%); color: #fff; }
[data-design="editorial"] .av[data-hue] { background: hsl(var(--h) 25% 82%); color: #16151a; }
.sync { padding: 8px 18px; font-size: 12px; color: var(--fg-2); border-top: 1px solid var(--line); }

.main { min-width: 0; min-height: 0; display: flex; flex-direction: column; position: relative; }
.placeholder { flex: 1; display: grid; place-content: center; justify-items: center; gap: 14px; color: var(--fg-2); }
.room { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.head { display: flex; align-items: center; gap: 12px; padding: calc(12px + env(safe-area-inset-top)) 20px 12px; background: var(--panel); backdrop-filter: var(--blur); -webkit-backdrop-filter: var(--blur); border-bottom: 1px solid var(--line); }
.head .av { width: 42px; height: 42px; font-size: 16px; }
.head .who { flex: 1; min-width: 0; }
.head b { display: block; font-size: 17px; font-family: var(--display); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.head small { color: var(--fg-2); font-size: 13px; }
.back { display: none; font-size: 26px; }

.msgs { flex: 1; overflow-y: auto; padding: 16px 22px; display: flex; flex-direction: column; gap: 4px; overscroll-behavior: contain; }
.day { align-self: center; margin: 12px 0 6px; padding: 4px 12px; border-radius: 999px; font-size: 12px; background: var(--field); color: var(--fg-2); }
[data-design="editorial"] .day { background: none; font-family: var(--serif); font-size: 14px; }
.m { max-width: min(68%, 560px); padding: 8px 13px 6px; border-radius: var(--radius); overflow-wrap: anywhere; white-space: pre-wrap; animation: pop 0.18s ease-out; }
@keyframes pop { from { opacity: 0; transform: translateY(4px); } }
.m.in { align-self: flex-start; background: var(--in-bg); border: 1px solid var(--in-line); border-bottom-left-radius: 6px; backdrop-filter: var(--blur); -webkit-backdrop-filter: var(--blur); }
.m.out { align-self: flex-end; background: var(--out-bg); color: var(--out-fg); border-bottom-right-radius: 6px; box-shadow: var(--out-shadow); }
[data-design="onyx"] .m.out { border: 1px solid #5a4824; }
.m.cont.in { border-top-left-radius: 8px; }
.m.cont.out { border-top-right-radius: 8px; }
.m .from { display: block; font-size: 12.5px; font-weight: 600; color: var(--accent-ink); margin-bottom: 2px; }
.m .t { float: right; margin: 6px 0 -2px 10px; font-size: 11px; opacity: 0.65; white-space: nowrap; }
.m a { color: inherit; }
.m.pending { opacity: 0.6; }
.m.failed { box-shadow: inset 0 0 0 1px var(--danger); }
.m .pic { display: block; max-width: 100%; max-height: 340px; min-width: 120px; min-height: 80px; border-radius: 14px; margin: 2px -6px 4px; cursor: zoom-in; background: var(--field); object-fit: cover; }
.m.notice { align-self: center; background: none; border: 0; color: var(--fg-2); font-size: 13px; max-width: 90%; text-align: center; backdrop-filter: none; }
.typing { align-self: flex-start; font-size: 13px; color: var(--fg-2); padding: 4px 6px; min-height: 24px; }
.older { align-self: center; }

.invite-bar { display: flex; align-items: center; gap: 10px; margin: 0 20px 14px; padding: 12px 14px; border-radius: 18px; background: var(--panel); border: 1px solid var(--line); backdrop-filter: var(--blur); }
.invite-bar span { flex: 1; }
.composer { display: flex; align-items: flex-end; gap: 8px; margin: 0 20px calc(16px + env(safe-area-inset-bottom)); padding: 6px; border-radius: 26px; background: var(--panel); border: 1px solid var(--line); backdrop-filter: var(--blur); -webkit-backdrop-filter: var(--blur); }
[data-design="editorial"] .composer { background: #fff; }
.composer textarea { flex: 1; min-height: 42px; max-height: 160px; resize: none; border: 0; background: transparent; padding: 10px 6px; font-size: 16px; outline: none; }
.composer textarea::placeholder { color: var(--fg-2); }
.send { width: 44px; height: 44px; border-radius: 50%; border: 0; background: var(--accent); color: var(--accent-fg); font-size: 18px; flex: none; }

/* ---------- панель и окна ---------- */
dialog { color: var(--fg); }
dialog::backdrop { background: rgba(5, 5, 15, 0.45); backdrop-filter: blur(3px); }
.drawer { margin: 0 0 0 auto; height: 100dvh; max-height: 100dvh; width: min(380px, 100vw); max-width: 100vw; padding: 0; border: 0; border-left: 1px solid var(--line); background: var(--panel-solid); display: none; flex-direction: column; }
[data-design="glass"] .drawer { background: linear-gradient(160deg, #3a2470, #23305e); }
.drawer[open] { display: flex; animation: slide 0.25s cubic-bezier(0.2, 0.8, 0.2, 1); }
@keyframes slide { from { transform: translateX(100%); } }
.drawer-head { display: flex; align-items: center; gap: 14px; padding: calc(22px + env(safe-area-inset-top)) 20px 20px; border-bottom: 1px solid var(--line); }
.drawer-head div { flex: 1; min-width: 0; }
.drawer-head b { display: block; font-family: var(--display); font-size: 20px; }
.drawer-head small { color: var(--fg-2); font-size: 12.5px; overflow-wrap: anywhere; }
.drawer-body { flex: 1; overflow-y: auto; padding: 6px 20px; }
.drawer-body section { padding: 16px 0; border-bottom: 1px solid var(--line); }
.drawer-body section:last-child { border-bottom: 0; }
.drawer-body h3 { margin: 0 0 10px; font-size: 11px; letter-spacing: 0.16em; text-transform: uppercase; color: var(--fg-2); }
.drawer-foot { padding: 16px 20px calc(20px + env(safe-area-inset-bottom)); border-top: 1px solid var(--line); }
.row { display: flex; gap: 8px; }
.row input { flex: 1; min-width: 0; border: 1px solid var(--line); background: var(--field); border-radius: 12px; padding: 10px 12px; }
.seg { display: flex; gap: 3px; padding: 4px; border-radius: 999px; background: var(--field); }
.seg button { flex: 1; border: 0; background: none; border-radius: 999px; padding: 8px 6px; color: var(--fg-2); font-size: 13.5px; }
.seg button[aria-pressed="true"] { background: var(--accent); color: var(--accent-fg); font-weight: 600; }
.setting { width: 100%; display: flex; align-items: center; justify-content: space-between; gap: 12px; border: 0; background: none; padding: 4px 0; text-align: left; }
.setting b { display: block; font-weight: 500; }
.setting small { display: block; color: var(--fg-2); font-size: 12.5px; }
.switch { position: relative; flex: none; width: 46px; height: 28px; border-radius: 999px; background: var(--field); box-shadow: inset 0 0 0 1px var(--line); }
.switch::after { content: ""; position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 50%; background: var(--fg-2); transition: transform 0.2s; }
.setting[aria-checked="true"] .switch { background: var(--accent); box-shadow: none; }
.setting[aria-checked="true"] .switch::after { transform: translateX(18px); background: #fff; }

.modal { border: 1px solid var(--line); border-radius: 24px; padding: 0; background: var(--panel-solid); width: min(420px, calc(100vw - 32px)); }
[data-design="glass"] .modal { background: linear-gradient(160deg, #3a2470, #23305e); }
.modal-card { display: flex; flex-direction: column; gap: 14px; padding: 24px; }
.modal-card h2 { margin: 0; font-family: var(--display); }
.btns { display: flex; justify-content: flex-end; gap: 8px; }
.lightbox { border: 0; padding: 0; background: transparent; max-width: 100vw; max-height: 100dvh; }
.lightbox img { max-width: 96vw; max-height: 92dvh; border-radius: 14px; display: block; }
.toast { position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 50; max-width: calc(100vw - 32px); padding: 12px 18px; border-radius: 14px; background: rgba(15, 12, 30, 0.88); color: #fff; box-shadow: 0 20px 50px -20px #000; }

/* ---------- телефон: список и переписка по очереди ---------- */
@media (max-width: 760px) {
  .app { grid-template-columns: minmax(0, 1fr); }
  .app[data-view="list"] .main { display: none; }
  .app[data-view="room"] .side { display: none; }
  .back { display: grid; }
  .head { padding-left: 8px; }
  .msgs { padding: 12px 12px; }
  .m { max-width: 84%; }
  .composer { margin: 0 10px calc(10px + env(safe-area-inset-bottom)); }
  .invite-bar { margin: 0 10px 10px; }
}
