/* CoWork — оформление в духе навигационных табличек:
   графит + сигнальный жёлтый, Golos Text, структура линиями, а не карточками. */

@font-face { font-family: "Golos"; font-weight: 400; font-display: swap; src: url(/fonts/golos-text-cyrillic-400-normal.woff2) format("woff2"); unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116; }
@font-face { font-family: "Golos"; font-weight: 500; font-display: swap; src: url(/fonts/golos-text-cyrillic-500-normal.woff2) format("woff2"); unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116; }
@font-face { font-family: "Golos"; font-weight: 600; font-display: swap; src: url(/fonts/golos-text-cyrillic-600-normal.woff2) format("woff2"); unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116; }
@font-face { font-family: "Golos"; font-weight: 700; font-display: swap; src: url(/fonts/golos-text-cyrillic-700-normal.woff2) format("woff2"); unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116; }
@font-face { font-family: "Golos"; font-weight: 400; font-display: swap; src: url(/fonts/golos-text-latin-400-normal.woff2) format("woff2"); unicode-range: U+0000-00FF, U+2000-206F, U+20AC, U+2122, U+2190-2199; }
@font-face { font-family: "Golos"; font-weight: 500; font-display: swap; src: url(/fonts/golos-text-latin-500-normal.woff2) format("woff2"); unicode-range: U+0000-00FF, U+2000-206F, U+20AC, U+2122, U+2190-2199; }
@font-face { font-family: "Golos"; font-weight: 600; font-display: swap; src: url(/fonts/golos-text-latin-600-normal.woff2) format("woff2"); unicode-range: U+0000-00FF, U+2000-206F, U+20AC, U+2122, U+2190-2199; }
@font-face { font-family: "Golos"; font-weight: 700; font-display: swap; src: url(/fonts/golos-text-latin-700-normal.woff2) format("woff2"); unicode-range: U+0000-00FF, U+2000-206F, U+20AC, U+2122, U+2190-2199; }

:root {
  /* палитра */
  --graphite: #26313d;     /* текст, основные кнопки, табло */
  --graphite-2: #3a4757;
  --signal: #f5c400;       /* бренд и «это вы» */
  --signal-soft: #fff4c2;
  --paper: #eceef1;        /* фон рабочей области */
  --surface: #ffffff;
  --line: #d5d9df;
  --line-soft: #e6e9ed;
  --muted: #66707c;
  --danger: #c62828;

  /* статусы */
  --st-free: #2e9e5b;
  --st-working: #2f6db5;
  --st-break: #d98a12;
  --st-meeting: #7b4bb7;
  --st-away: #9aa3ad;

  /* зоны (полы плана) */
  --zone-desks: #e7eef8;
  --zone-meeting: #efe9f7;
  --zone-common: #f2f3f5;
  --zone-kitchen: #fbeedd;
  --zone-lounge: #e4f2ec;

  --r-s: 4px;   /* кнопки, поля, чипы */
  --r-m: 8px;   /* панели, комнаты */

  font-family: "Golos", system-ui, -apple-system, "Segoe UI", sans-serif;
  font-size: 14px;
  line-height: 1.45;
  color: var(--graphite);
  background: var(--paper);
  font-feature-settings: "tnum" 1; /* цифры одной ширины — счётчики не «прыгают» */
}

* { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; }
h1, h2, h3 { margin: 0; font-weight: 600; letter-spacing: -0.005em; }
p { margin: 0; }
button { font: inherit; color: inherit; }
input { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--graphite); outline-offset: 2px; }
::selection { background: var(--signal); color: var(--graphite); }

.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.row { display: flex; align-items: center; gap: 8px; }
.row.end { justify-content: flex-end; }
.gap-s { gap: 6px; }
.plain { list-style: none; padding: 0; margin: 6px 0; display: grid; gap: 3px; }
.error { color: var(--danger); }

/* ---------- иконки ---------- */
.i { width: 20px; height: 20px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.i--sm { width: 16px; height: 16px; }

/* ---------- бренд ---------- */
.brand { display: flex; align-items: center; gap: 10px; }
.brand__mark { width: 28px; height: 28px; }
.brand__name { font-weight: 700; font-size: 18px; letter-spacing: -0.02em; }
.brand--light .brand__name { color: #fff; }

/* ---------- кнопки ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: 1px solid var(--line); background: var(--surface); border-radius: var(--r-s);
  padding: 8px 14px; cursor: pointer; font-weight: 500; white-space: nowrap;
}
.btn:hover:not(:disabled) { border-color: var(--graphite); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn--primary { background: var(--graphite); border-color: var(--graphite); color: #fff; }
.btn--primary:hover:not(:disabled) { background: var(--graphite-2); }
.btn--accent { background: var(--signal); border-color: var(--signal); color: var(--graphite); }
.btn--ghost { background: transparent; border-color: transparent; text-decoration: underline; text-underline-offset: 3px; text-decoration-color: var(--line); }
.btn--ghost:hover:not(:disabled) { border-color: transparent; text-decoration-color: currentColor; }
.btn--sm { padding: 5px 10px; font-size: 13px; }
.btn--block { width: 100%; padding: 11px; }

.icon-btn { display: inline-grid; place-items: center; width: 34px; height: 34px; border: 0; border-radius: var(--r-s); background: transparent; cursor: pointer; color: var(--muted); }
.icon-btn:hover:not(:disabled) { color: var(--graphite); background: var(--paper); }
.icon-btn:disabled { opacity: .4; cursor: not-allowed; }
.icon-btn--boxed { border: 1px solid var(--line); height: auto; align-self: stretch; width: 42px; }
.icon-btn--primary { background: var(--graphite); color: #fff; }
.icon-btn--primary:hover:not(:disabled) { background: var(--graphite-2); color: #fff; }

/* ---------- аватары и статусы ---------- */
.avatar {
  --c: var(--graphite);
  position: relative; display: inline-grid; place-items: center; flex: none;
  width: 34px; height: 34px; border-radius: 50%; font-size: 18px; line-height: 1;
  background: color-mix(in srgb, var(--c) 16%, white);
  box-shadow: inset 0 0 0 2px var(--c);
}
.avatar--sm { width: 28px; height: 28px; font-size: 15px; }
.avatar--lg { width: 52px; height: 52px; font-size: 28px; }
.avatar--ghost { opacity: .45; filter: grayscale(.4); }
.avatar .dot { position: absolute; right: -1px; bottom: -1px; width: 11px; height: 11px; border: 2px solid #fff; }

.st-free { --st: var(--st-free); }
.st-working { --st: var(--st-working); }
.st-break { --st: var(--st-break); }
.st-meeting { --st: var(--st-meeting); }
.st-away { --st: var(--st-away); }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--st); flex: none; }
.status { display: inline-flex; align-items: center; gap: 5px; font-size: 12.5px; white-space: nowrap; }

.badge { display: inline-block; min-width: 18px; padding: 0 5px; border-radius: 9px; background: var(--signal); color: var(--graphite); font-size: 11.5px; font-weight: 600; text-align: center; }

/* ---------- вход ---------- */
.login-screen { min-height: 100vh; display: grid; grid-template-columns: minmax(380px, 5fr) 6fr; }

.board { background: var(--graphite); color: #fff; padding: 36px 48px; display: flex; flex-direction: column; gap: 48px; }
.board__body { margin-top: auto; margin-bottom: auto; max-width: 520px; }
.board__title { font-size: 40px; line-height: 1.1; font-weight: 700; letter-spacing: -0.025em; }
.board__lead { margin-top: 16px; color: #c4ccd6; font-size: 16px; max-width: 42ch; }
.board__rows { margin: 40px 0 0; }
.board__row { display: flex; align-items: baseline; justify-content: space-between; gap: 16px; padding: 14px 0; border-top: 1px solid #3d4a5a; }
.board__row:last-child { border-bottom: 1px solid #3d4a5a; }
.board__row dt { color: #c4ccd6; }
.board__row dd { margin: 0; color: var(--signal); font-size: 28px; font-weight: 600; line-height: 1; letter-spacing: -0.01em; }
.board__row dd small { font-size: 15px; font-weight: 500; color: #c4ccd6; margin-left: 2px; }
.board__row dd.board__text { font-size: 16px; font-weight: 500; text-align: right; }

.signin { display: grid; place-items: center; padding: 40px 24px; background: var(--surface); }
.signin__form { width: min(420px, 100%); display: grid; gap: 20px; }
.signin__form h2 { font-size: 24px; letter-spacing: -0.015em; }
.signin__form > .muted { margin-top: -12px; }
.signin__preview { display: flex; align-items: center; gap: 14px; padding: 14px 0; border-top: 1px solid var(--line-soft); border-bottom: 1px solid var(--line-soft); }
.signin__preview > span:last-child { display: grid; }

.field { display: grid; gap: 7px; }
.field__label { font-size: 13px; font-weight: 600; }
.input-row { display: flex; gap: 6px; }
.field input, .chat__form input {
  width: 100%; border: 1px solid var(--line); border-radius: var(--r-s); padding: 9px 11px; background: #fff; outline: none;
}
.field input:focus, .chat__form input:focus { border-color: var(--graphite); box-shadow: 0 0 0 1px var(--graphite); }
.field input[type=checkbox] { width: 16px; height: 16px; padding: 0; margin: 0; flex: none; accent-color: var(--graphite); box-shadow: none; }

.avatar-picker { display: grid; grid-template-columns: repeat(10, 1fr); gap: 4px; }
.avatar-option { aspect-ratio: 1; border: 1px solid transparent; background: var(--paper); border-radius: var(--r-s); font-size: 18px; cursor: pointer; }
.avatar-option:hover { border-color: var(--line); }
.avatar-option.is-active { background: color-mix(in srgb, var(--c) 18%, white); border-color: var(--c); box-shadow: inset 0 0 0 1px var(--c); }
.color-picker { display: flex; gap: 8px; }
.color-option { width: 26px; height: 26px; border-radius: 50%; border: 0; background: var(--c); cursor: pointer; }
.color-option.is-active { box-shadow: 0 0 0 2px #fff, 0 0 0 4px var(--c); }

/* ---------- раскладка приложения ---------- */
.layout {
  height: 100vh; display: grid;
  grid-template-columns: minmax(0, 1fr) 280px 340px;
  grid-template-rows: auto minmax(0, 1fr);
  grid-template-areas: "top top top" "office side right";
}
.topbar { grid-area: top; display: flex; align-items: center; gap: 20px; padding: 10px 20px; background: var(--surface); border-bottom: 1px solid var(--line); }
.conn { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); }
.conn__dot { width: 8px; height: 8px; border-radius: 50%; background: var(--st-free); }
.conn--bad .conn__dot { background: var(--danger); animation: blink 1s steps(2) infinite; }
@keyframes blink { 50% { opacity: .25; } }
.me { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.me__info { display: grid; line-height: 1.25; }

.dropdown { position: relative; }
.status-btn { display: flex; align-items: center; gap: 6px; border: 1px solid var(--line); background: var(--surface); border-radius: var(--r-s); padding: 5px 8px 5px 10px; cursor: pointer; font-size: 13px; }
.status-btn:hover { border-color: var(--graphite); }
.dropdown__menu { position: absolute; right: 0; top: calc(100% + 4px); z-index: 20; background: #fff; border: 1px solid var(--line); border-radius: var(--r-s); box-shadow: 0 8px 24px rgba(38, 49, 61, .14); padding: 4px; min-width: 180px; display: grid; }
.dropdown__menu button { display: flex; align-items: center; gap: 8px; padding: 7px 10px; border: 0; background: none; border-radius: 3px; cursor: pointer; text-align: left; }
.dropdown__menu button:hover:not(:disabled) { background: var(--paper); }
.dropdown__menu button:disabled { opacity: .4; cursor: not-allowed; }

/* ---------- офис ---------- */
.office { grid-area: office; overflow: auto; padding: 14px 20px 20px; display: flex; flex-direction: column; gap: 12px; }
.viewbar { display: flex; align-items: center; gap: 14px; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: var(--r-s); overflow: hidden; background: var(--surface); }
.seg button { border: 0; background: none; padding: 5px 14px; cursor: pointer; font-size: 13px; color: var(--muted); }
.seg button + button { border-left: 1px solid var(--line); }
.seg button.is-on { background: var(--graphite); color: #fff; }

/* 2D-план: комнаты, разделённые «стенами» */
.plan {
  flex: 1; display: grid; gap: 0; min-width: 760px;
  grid-template-columns: 1.15fr 1fr 1fr;
  grid-template-rows: minmax(min-content, 1.15fr) minmax(min-content, 1fr);
  grid-template-areas: "desks desks meeting" "common kitchen lounge";
  border: 3px solid var(--graphite); border-radius: var(--r-m); overflow: hidden; background: var(--graphite);
}
.room { padding: 16px; display: flex; flex-direction: column; gap: 12px; min-height: 210px; outline: 1.5px solid var(--graphite); position: relative; }
.room.is-here::after { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 4px; background: var(--signal); }
.room__head { display: flex; align-items: center; justify-content: space-between; gap: 6px 8px; flex-wrap: wrap; }
.room__head h2 { font-size: 15px; display: flex; align-items: center; gap: 8px; white-space: nowrap; }
.zone-i { color: var(--muted); }
.room__meta { font-size: 13px; color: var(--muted); }
.room__meta.is-warn { color: var(--danger); font-weight: 600; }
.room__actions { margin-top: auto; }
.room__empty { display: grid; gap: 10px; justify-items: start; margin: auto 0; }
.room--desks { grid-area: desks; background: var(--zone-desks); }
.room--meeting { grid-area: meeting; background: var(--zone-meeting); }
.room--common { grid-area: common; background: var(--zone-common); }
.room--kitchen { grid-area: kitchen; background: var(--zone-kitchen); }
.room--lounge { grid-area: lounge; background: var(--zone-lounge); }

.desks { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.desk {
  position: relative; display: grid; justify-items: center; align-content: center; gap: 4px; min-height: 100px;
  border: 1px solid #c6d3e6; border-radius: var(--r-s); background: #fff; padding: 18px 6px 8px; cursor: pointer;
}
.desk.is-free { border-style: dashed; background: rgba(255,255,255,.55); }
.desk.is-free:hover { border-style: solid; border-color: var(--graphite); }
.desk.is-taken { cursor: default; }
.desk.is-mine { border: 2px solid var(--graphite); box-shadow: inset 0 3px 0 var(--signal); }
.desk__num { position: absolute; left: 7px; top: 5px; font-size: 12px; font-weight: 600; color: var(--muted); }
.desk__free { font-size: 12.5px; color: var(--st-free); }
.desk__owner { display: grid; justify-items: center; gap: 3px; max-width: 100%; }
.desk__name { font-size: 12.5px; font-weight: 600; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; padding: 0 4px; }
.desk__sub { font-size: 11.5px; color: var(--muted); }
.desk__release { font-size: 11.5px; text-decoration: underline; text-underline-offset: 2px; cursor: pointer; }

.people { display: flex; flex-wrap: wrap; gap: 10px 6px; align-content: flex-start; }
.chip { display: inline-grid; justify-items: center; gap: 3px; width: 66px; }
.chip__name { font-size: 11.5px; max-width: 66px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chip.is-me .chip__name { font-weight: 700; background: var(--signal); padding: 0 4px; border-radius: 2px; }
.chip.is-off { opacity: .5; }

.meeting { display: flex; flex-direction: column; gap: 8px; flex: 1; }
.meeting__title { font-weight: 600; font-size: 16px; }

.coffee { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; padding: 10px 0; border-top: 1px solid #ecd7bb; border-bottom: 1px solid #ecd7bb; }
.coffee__info { flex: 1; min-width: 120px; display: grid; gap: 5px; }
.coffee > .btn { flex-basis: 100%; }
.progress { height: 4px; background: #ecd7bb; margin-top: 5px; }
.progress span { display: block; height: 100%; background: var(--graphite); transition: width .25s linear; }

/* 3D-сцена */
.scene3d { position: relative; flex: 1; min-height: 460px; border: 1px solid var(--line); border-radius: var(--r-m); overflow: hidden; background: var(--paper); }
.scene3d > canvas { display: block; touch-action: none; }
/* Слои сцены. CSS2DRenderer сам ставит меткам z-index по глубине (до десятков), поэтому
   контейнер меток — отдельный контекст наложения: метки сортируются только между собой. */
.scene3d__labels { position: absolute; inset: 0; pointer-events: none; z-index: 1; }
.scene3d__controls { position: absolute; left: 12px; bottom: 12px; z-index: 3; display: flex; background: #fff; border: 1px solid var(--line); border-radius: var(--r-s); }
.scene3d__controls button { width: 34px; height: 34px; display: grid; place-items: center; border: 0; background: none; cursor: pointer; color: var(--graphite); }
.scene3d__controls button + button { border-left: 1px solid var(--line); }
.scene3d__controls button:hover { background: var(--paper); }
.scene3d__hint { position: absolute; z-index: 5; pointer-events: none; background: var(--graphite); color: #fff; font-size: 12.5px; padding: 5px 9px; border-radius: var(--r-s); white-space: nowrap; }
.scene3d__loading { position: absolute; inset: 0; display: grid; place-items: center; color: var(--muted); z-index: 2; background: var(--paper); }

.a3d { display: grid; justify-items: center; gap: 2px; transition: opacity .3s; }
.a3d .avatar { width: 30px; height: 30px; font-size: 17px; pointer-events: auto; box-shadow: inset 0 0 0 2px var(--c), 0 2px 6px rgba(38, 49, 61, .25); background: color-mix(in srgb, var(--c) 20%, white); }
.a3d .dot { width: 10px; height: 10px; }
.a3d__name { font-size: 11px; font-weight: 600; padding: 0 5px; border-radius: 2px; background: #fff; color: var(--graphite); white-space: nowrap; max-width: 110px; overflow: hidden; text-overflow: ellipsis; opacity: 0; }
.a3d:hover .a3d__name, .a3d.is-me .a3d__name { opacity: 1; }
.a3d.is-me .avatar { box-shadow: inset 0 0 0 2px var(--c), 0 0 0 3px var(--signal), 0 2px 6px rgba(38, 49, 61, .25); }
.a3d.is-me .a3d__name { background: var(--signal); }
.a3d.is-off { opacity: .5; }
.a3d--enter .avatar { animation: pop .35s ease-out; }
@keyframes pop { from { transform: scale(0); } }

.desk3d { font-size: 11px; font-weight: 600; }
.desk3d--free { pointer-events: auto; cursor: pointer; color: #fff; background: var(--st-free); padding: 1px 6px; border-radius: 2px; }
.desk3d--reserved span { --c: #999; display: grid; place-items: center; width: 22px; height: 22px; border-radius: 50%; font-size: 12px; opacity: .55; filter: grayscale(.3); background: color-mix(in srgb, var(--c) 20%, white); box-shadow: inset 0 0 0 1.5px var(--c); pointer-events: auto; }
.desk3d--hidden { display: none; }

.zone3d { display: grid; font-size: 12px; background: #fff; border-left: 3px solid var(--graphite); padding: 3px 9px 4px 7px; white-space: nowrap; margin: 0 0 4px 4px; }
.zone3d b { font-weight: 600; }
.zone3d span { color: var(--muted); font-size: 11.5px; }
.zone3d span:empty { display: none; }

.coffee3d { display: none; }
.coffee3d.is-busy { display: grid; gap: 3px; background: #fff; padding: 3px 7px 5px; border-radius: 2px; font-size: 11.5px; font-weight: 600; min-width: 64px; box-shadow: 0 1px 4px rgba(38, 49, 61, .2); }
.coffee3d i { display: block; height: 3px; background: var(--graphite); transition: width .25s linear; }

/* ---------- боковая колонка ---------- */
.sidebar { grid-area: side; overflow: auto; background: var(--surface); border-left: 1px solid var(--line); }
.block { padding: 16px 18px; border-bottom: 1px solid var(--line-soft); }
.block__title { font-size: 14px; font-weight: 600; display: flex; align-items: baseline; gap: 8px; margin-bottom: 10px; }
.count { font-weight: 400; color: var(--muted); font-size: 13px; }

.users { list-style: none; margin: 0 -8px; padding: 0; display: grid; }
.users li { display: flex; align-items: center; gap: 10px; padding: 6px 8px; border-radius: var(--r-s); }
.users li.is-me { background: var(--signal-soft); }
.users li.is-off { opacity: .5; }
.users__info { display: grid; gap: 1px; min-width: 0; flex: 1; line-height: 1.3; }
.users__name { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.users__meta { display: flex; align-items: center; gap: 8px; min-width: 0; font-size: 12.5px; }
.users__meta .muted { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.desk-chips { display: grid; grid-template-columns: repeat(8, 1fr); gap: 4px; margin-bottom: 8px; }
.desk-chip { aspect-ratio: 1; display: grid; place-items: center; border-radius: var(--r-s); font-size: 12.5px; font-weight: 600; cursor: pointer;
  border: 1px solid color-mix(in srgb, var(--st-free) 55%, white); background: color-mix(in srgb, var(--st-free) 10%, white); color: #1f6b3e; }
.desk-chip.is-taken { border-color: var(--line); background: var(--paper); color: var(--muted); cursor: default; }
.desk-chip.is-mine { border-color: var(--graphite); background: var(--signal); color: var(--graphite); }
.legend { display: flex; gap: 14px; }
.legend span { display: inline-flex; align-items: center; gap: 5px; }
.legend__sw { width: 10px; height: 10px; border-radius: 2px; display: inline-block; }
.legend__sw--free { background: color-mix(in srgb, var(--st-free) 35%, white); }
.legend__sw--taken { background: #cdd2d9; }
.legend__sw--mine { background: var(--signal); }
.history summary { cursor: pointer; margin-top: 10px; text-decoration: underline; text-underline-offset: 3px; text-decoration-color: var(--line); }

/* ---------- уведомления и чат ---------- */
.right { grid-area: right; display: flex; flex-direction: column; min-height: 0; background: var(--surface); border-left: 1px solid var(--line); }

.notifications { display: flex; flex-direction: column; max-height: 36%; min-height: 0; flex: none; border-bottom: 1px solid var(--line); }
.notifications__head { display: flex; align-items: center; gap: 8px; width: 100%; padding: 14px 18px 10px; border: 0; background: none; cursor: pointer; text-align: left; }
.notifications__head .block__title { margin: 0; }
.notifications__chev { margin-left: auto; color: var(--muted); transition: transform .15s; }
.notifications.is-collapsed .notifications__chev { transform: rotate(-90deg); }
.notifications.is-collapsed .notifications__head { padding-bottom: 14px; }
.notifications ul { list-style: none; margin: 0; padding: 0 10px 10px; overflow: auto; display: grid; }
.n { display: grid; grid-template-columns: 16px 1fr auto; gap: 8px; align-items: start; padding: 6px 8px; font-size: 13px; border-radius: var(--r-s); }
.n .i { margin-top: 2px; color: var(--muted); }
.n time { font-size: 12px; }
.n--desks .i { color: var(--st-working); }
.n--meeting .i { color: var(--st-meeting); }
.n--kitchen .i { color: var(--st-break); }
.n--empty { padding: 6px 8px; }

.chat { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.chat__title { padding: 14px 18px 0; }
.chat__list { flex: 1; overflow: auto; padding: 0 14px; display: flex; flex-direction: column; gap: 2px; }
.chat__empty { padding: 4px; max-width: 32ch; }
.msg { display: flex; gap: 8px; padding: 5px 0; }
.msg__body { min-width: 0; }
.msg__meta { font-size: 12.5px; margin-bottom: 2px; }
.msg__meta time { font-size: 12px; margin-left: 4px; }
.msg__text { background: var(--paper); padding: 7px 11px; border-radius: 2px var(--r-m) var(--r-m) var(--r-m); white-space: pre-wrap; overflow-wrap: anywhere; display: inline-block; max-width: 100%; }
.msg--mine { flex-direction: row-reverse; }
.msg--mine .msg__body { text-align: right; }
.msg--mine .msg__text { background: var(--signal-soft); border-radius: var(--r-m) 2px var(--r-m) var(--r-m); text-align: left; }
.msg--cont { padding-top: 0; }
.msg--cont .avatar { visibility: hidden; height: 0; }
.msg--cont .msg__meta { display: none; }
.chat__form { display: flex; gap: 6px; padding: 12px 14px; border-top: 1px solid var(--line); }
.chat__form .icon-btn { width: 40px; height: auto; flex: none; }

/* ---------- модалка и тосты ---------- */
.modal { position: fixed; inset: 0; background: rgba(38, 49, 61, .45); display: grid; place-items: center; z-index: 50; padding: 20px; }
.modal__card { width: min(440px, 100%); background: #fff; border-radius: var(--r-m); padding: 22px; display: grid; gap: 16px; }
.modal__card h2 { font-size: 18px; }
.invite-list { max-height: 240px; overflow: auto; display: grid; border: 1px solid var(--line); border-radius: var(--r-s); }
.invite-item { display: flex; align-items: center; gap: 9px; padding: 7px 10px; cursor: pointer; }
.invite-item + .invite-item { border-top: 1px solid var(--line-soft); }
.invite-item:hover { background: var(--paper); }
.invite-item .status { margin-left: auto; }
.invite-list > .muted { padding: 10px; }

.toasts { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); display: grid; gap: 8px; z-index: 60; width: min(480px, calc(100% - 32px)); }
.toast { display: flex; align-items: center; gap: 10px; background: var(--graphite); color: #fff; padding: 10px 10px 10px 14px; border-radius: var(--r-s); box-shadow: 0 10px 30px rgba(38, 49, 61, .3); font-size: 13.5px; border-left: 4px solid var(--signal); }
.toast > span { flex: 1; }
.toast--error { border-left-color: #ff6b5a; }
.toast__close { display: grid; place-items: center; border: 0; background: none; color: inherit; opacity: .7; cursor: pointer; padding: 4px; }
.toast__close:hover { opacity: 1; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* ---------- адаптив ---------- */
@media (max-width: 1280px) {
  .layout { grid-template-columns: minmax(0, 1fr) 330px; grid-template-areas: "top top" "office right" "side right"; grid-template-rows: auto minmax(0, 1fr) auto; }
  .sidebar { display: grid; grid-template-columns: repeat(3, 1fr); border-top: 1px solid var(--line); }
  .sidebar .block { border-bottom: 0; }
  .sidebar .block + .block { border-left: 1px solid var(--line-soft); }
}
/* ---------- телефон ---------- */
.tabbar { display: none; }

@media (max-width: 900px) {
  :root { --top-h: 52px; --tab-h: 58px; --safe-b: env(safe-area-inset-bottom, 0px); }

  /* вход: табло сверху, форма снизу */
  .login-screen { grid-template-columns: 1fr; }
  .board { padding: 20px 20px 24px; gap: 24px; }
  .board__body { margin: 0; }
  .board__title { font-size: 28px; }
  .board__lead { font-size: 15px; }
  .board__rows { margin-top: 24px; }
  .board__row { padding: 10px 0; }
  .board__row dd { font-size: 22px; }
  .signin { padding: 28px 20px calc(28px + var(--safe-b)); place-items: start stretch; }
  .signin__form { width: 100%; }
  .avatar-picker { grid-template-columns: repeat(auto-fill, minmax(40px, 1fr)); }
  .avatar-option { font-size: 20px; }
  /* 16px и больше — иначе iOS приближает страницу при фокусе на поле */
  .field input, .chat__form input { font-size: 16px; padding: 10px 12px; }

  /* каркас: шапка сверху, вкладки снизу, офис между ними */
  .layout { display: flex; flex-direction: column; height: auto; min-height: 100dvh; padding-bottom: calc(var(--tab-h) + var(--safe-b)); }
  .topbar { position: sticky; top: 0; z-index: 20; height: var(--top-h); padding: 0 12px; gap: 10px; flex-wrap: nowrap; }
  .topbar .brand__name { display: none; }
  .me { gap: 4px; }
  .me > .avatar, .me__info { display: none; }
  .status-btn { padding: 6px 8px 6px 10px; }

  .office { flex: 1; overflow: visible; padding: 10px 10px 12px; gap: 10px; }
  .viewbar > .muted { display: none; }
  .seg { flex: none; }
  .seg button { padding: 7px 18px; }

  /* 3D — на всё место между шапкой и вкладками */
  .scene3d { flex: 1; min-height: 340px; }
  .scene3d__controls { left: 8px; bottom: 8px; }
  .scene3d__controls button { width: 40px; height: 40px; }

  /* план — комнаты одна под другой, страница прокручивается вертикально */
  .plan { flex: none; min-width: 0; grid-template-columns: 1fr; grid-template-rows: none; grid-auto-rows: auto;
          grid-template-areas: "desks" "meeting" "kitchen" "lounge" "common"; }
  .room { min-height: 0; padding: 14px 12px; }
  .desks { grid-template-columns: repeat(auto-fill, minmax(76px, 1fr)); gap: 6px; }
  .desk { min-height: 92px; }
  .people { gap: 10px 4px; }

  /* разделы «Люди», «Чат», «Уведомления» — отдельные экраны поверх офиса */
  .sidebar, .right { display: none; }
  .layout.show-people .sidebar,
  .layout.show-chat .right,
  .layout.show-notifications .right {
    display: flex; flex-direction: column; position: fixed; z-index: 30;
    top: var(--top-h); bottom: calc(var(--tab-h) + var(--safe-b)); left: 0; right: 0;
    border: 0; background: var(--surface); overscroll-behavior: contain;
  }
  .layout.show-people .sidebar { display: block; overflow: auto; }
  .sidebar .block + .block { border-left: 0; border-top: 1px solid var(--line-soft); }
  .layout.show-chat .notifications { display: none; }
  .layout.show-notifications .chat { display: none; }
  .layout.show-notifications .notifications { flex: 1; max-height: none; border-bottom: 0; }
  .notifications__head { pointer-events: none; }  /* на телефоне список всегда раскрыт */
  .notifications__chev { display: none; }
  .n { padding: 9px 8px; font-size: 14px; }
  .chat__list { padding: 0 12px; }
  .chat__form { padding: 10px 12px; }
  .chat__form .icon-btn { width: 46px; }

  /* нижние вкладки */
  .tabbar {
    display: grid; grid-template-columns: repeat(4, 1fr); position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
    height: calc(var(--tab-h) + var(--safe-b)); padding-bottom: var(--safe-b);
    background: var(--surface); border-top: 1px solid var(--line);
  }
  .tabbar button { display: grid; justify-items: center; align-content: center; gap: 3px; border: 0; background: none; cursor: pointer; color: var(--muted); font-size: 11.5px; position: relative; }
  .tabbar button.is-on { color: var(--graphite); font-weight: 600; }
  .tabbar button.is-on::before { content: ""; position: absolute; top: 0; left: 28%; right: 28%; height: 3px; background: var(--signal); }
  .tabbar .i { width: 22px; height: 22px; }
  .tabbar__icon { position: relative; display: grid; }
  .tabbar__icon .badge { position: absolute; top: -5px; left: 14px; font-size: 10.5px; line-height: 16px; min-width: 16px; padding: 0 4px; border: 2px solid var(--surface); box-sizing: content-box; }

  .toasts { bottom: calc(var(--tab-h) + var(--safe-b) + 10px); }
  .modal { place-items: end stretch; padding: 0; }
  .modal__card { width: 100%; border-radius: var(--r-m) var(--r-m) 0 0; padding: 20px 16px calc(20px + var(--safe-b)); }
}

@media (max-width: 380px) {
  .conn span:last-child { font-size: 12px; }
  .status-btn span:not(.dot) { max-width: 92px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
}
