/* tooze.ru — стили по макету из Figma */

:root {
  --bg: #0a0a0b;
  --card: #1b1c1f;
  --btn: #2d2e31;
  --btn-hover: #3a3b3f;
  --hover: #232427;
  --text: #ffffff;
  --muted: #9c9ca2;
  --danger-bg: #5a161a;
  --danger-hover: #6e1c21;
  --danger: #fc5852;
  --green: #34c759;
  --speak: #34c759;
  --badge-red: #ff4d4d;
  --hangup: #fc5852;
  --line: #2d2e31;
  --shadow: 0 0 2px 0 rgba(0, 0, 0, .08), 0 0 32px 4px rgba(0, 0, 0, .48), 0 24px 32px 0 rgba(0, 0, 0, .48);
  --font: Roboto, "Segoe UI", system-ui, -apple-system, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font: 16px/22px var(--font);
  letter-spacing: .08px;
  -webkit-font-smoothing: antialiased;
}

button, input { font: inherit; color: inherit; letter-spacing: inherit; }
button { cursor: pointer; }
p { margin: 0; }
svg { display: block; flex: none; }
[data-icon], .ic { display: inline-flex; }

.hidden { display: none !important; }
.screen { height: 100vh; }

/* ============ Общие элементы ============ */

.card {
  background: var(--card);
  border-radius: 24px;
  box-shadow: var(--shadow);
}

.title {
  font-size: 20px;
  line-height: 24px;
  font-weight: 600;
  letter-spacing: .1px;
  color: var(--text);
}
.sub { font-size: 16px; line-height: 22px; color: var(--muted); }

/* Иконка-маска: берёт картинку из макета и красит её в текущий цвет текста */
.mask-icon {
  width: 24px;
  height: 24px;
  flex: none;
  background-color: currentColor;
  -webkit-mask: var(--icon) center / contain no-repeat;
  mask: var(--icon) center / contain no-repeat;
}
.mask-icon.big { width: 40px; height: 40px; }

.round-btn {
  position: relative;
  border: 0;
  padding: 0;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--btn);
  color: var(--text);
  transition: background .15s, transform .08s;
}
.round-btn:hover { background: var(--btn-hover); }
.round-btn:active { transform: scale(.95); }
.round-btn.danger { background: var(--danger-bg); }
.round-btn.danger:hover { background: var(--danger-hover); }
.round-btn.on { background: #46474c; }

.btn {
  height: 48px;
  border: 0;
  border-radius: 32px;
  padding: 0 24px;
  font-weight: 500;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: background .15s, opacity .15s;
}
.btn:disabled { opacity: .4; cursor: not-allowed; }
.btn-primary { background: #fff; color: #0a0a0b; }
.btn-primary:hover:not(:disabled) { background: #e4e4e7; }
.btn-ghost { background: var(--btn); color: var(--text); }
.btn-ghost:hover:not(:disabled) { background: var(--btn-hover); }
.btn-small { height: 36px; padding: 0 16px; font-size: 14px; }

.field {
  width: 100%;
  height: 52px;
  padding: 0 18px;
  border: 1px solid transparent;
  border-radius: 16px;
  background: var(--bg);
  color: var(--text);
  outline: none;
  transition: border-color .15s;
}
.field::placeholder { color: #6a6a70; }
.field:focus { border-color: #4a4b50; }

.form-error { font-size: 14px; color: var(--danger); text-align: center; }
.form-error:empty { display: none; }

/* ============ Аватары ============ */

.avatar {
  flex: none;
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: #fff;
  font-weight: 600;
  overflow: hidden;
  user-select: none;
}
.avatar.has-img { background: none !important; }
.avatar img { width: 100%; height: 100%; display: block; object-fit: cover; }
.avatar-120 { font-size: 40px; }
.avatar-48 { width: 48px; height: 48px; font-size: 18px; }
.avatar-40 { width: 40px; height: 40px; font-size: 16px; }
.avatar-32 { width: 32px; height: 32px; font-size: 13px; }
.avatar-24 { width: 24px; height: 24px; font-size: 11px; }

/* ============ Вход (кадры «1512px») ============ */

.login-screen { position: relative; display: grid; place-items: center; padding: 20px; }
.login-step {
  height: 240px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  max-width: 100%;
}
.login-top { display: flex; flex-direction: column; align-items: center; gap: 12px; max-width: 100%; }
.login-label { font-size: 24px; line-height: 30px; letter-spacing: .36px; color: var(--muted); text-align: center; }

/* Крупный ник с толстой кареткой: настоящий input прозрачный и лежит сверху */
.nick-box {
  position: relative;
  height: 68px;
  max-width: calc(100vw - 40px);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: text;
}
.nick-box input {
  position: absolute;
  inset: 0;
  width: 100%;
  opacity: 0;
  border: 0;
  padding: 0;
  font-size: 64px;
  cursor: text;
}
.nick-mirror {
  font-size: 64px;
  line-height: 68px;
  font-weight: 600;
  letter-spacing: .96px;
  white-space: pre;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: calc(100vw - 60px);
}
.nick-caret {
  width: 6px;
  height: 64px;
  margin-left: 4px;
  border-radius: 32px;
  background: #fff;
  flex: none;
  opacity: 0;
}
.nick-box:focus-within .nick-caret { animation: caret 1.1s steps(1) infinite; }
.nick-mirror:empty + .nick-caret { margin-left: 0; }
@keyframes caret { 0%, 50% { opacity: 1; } 50.01%, 100% { opacity: 0; } }

.btn-big { height: 56px; padding: 0 32px; font-size: 16px; line-height: 20px; letter-spacing: .24px; border-radius: 32px; }
#nick-next.empty { opacity: 0; pointer-events: none; }

.avatar-picker { display: flex; gap: 8px; }
.av-option {
  width: 96px;
  height: 96px;
  padding: 4px;
  border: 3px solid transparent;
  border-radius: 50%;
  background: var(--bg);
  transition: border-color .15s, transform .15s;
}
.av-option:hover { transform: translateY(-2px); }
.av-option.selected { border-color: var(--speak); }
.av-option img { width: 100%; height: 100%; border-radius: 50%; display: block; object-fit: cover; }

.login-error { position: absolute; left: 0; right: 0; top: calc(50% + 140px); text-align: center; font-size: 14px; color: var(--danger); }

/* ============ Приложение (кадр «800px») ============ */

.app { display: flex; }

/* ----- Левая колонка ----- */

.sidebar {
  width: 360px;
  flex: none;
  height: 100%;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.logo-row { flex: none; padding: 12px 16px; display: flex; align-items: center; }
.logo-row img { display: block; }

.channels-card {
  flex: 1;
  min-height: 0;
  display: flex;
  border-radius: 32px;
  background: var(--card);
  box-shadow: var(--shadow);
  overflow: hidden;
}
/* Прокрутка как в макете: дорожка 16px, ползунок 4px */
.channels-scroll {
  flex: 1;
  overflow-y: auto;
  padding: 16px 0 16px 16px;
}
.channels-scroll::-webkit-scrollbar { width: 16px; }
.channels-scroll::-webkit-scrollbar-track { background: transparent; margin: 32px 0; }
.channels-scroll::-webkit-scrollbar-thumb {
  background: var(--btn);
  border: 6px solid transparent;
  background-clip: padding-box;
  border-radius: 32px;
  min-height: 48px;
}
.channels-scroll { scrollbar-gutter: stable; }
.channel-list { display: flex; flex-direction: column; gap: 4px; }

.ch-row {
  width: 100%;
  padding: 12px 16px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 12px;
  border: 0;
  border-radius: 16px;
  background: rgba(255, 255, 255, .04);
  color: var(--muted);
  font-size: 16px;
  line-height: 20px;
  letter-spacing: .24px;
  text-align: left;
  transition: background .12s, color .12s;
}
.ch-row:hover { background: rgba(255, 255, 255, .06); color: #c4c4ca; }
.ch-row.active { background: rgba(255, 255, 255, .08); color: var(--text); }
.ch-head { width: 100%; display: flex; align-items: center; gap: 8px; }
.ch-head .mask-icon { width: 20px; height: 20px; }
.ch-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ch-action {
  width: 28px;
  height: 28px;
  margin: -4px -4px -4px 0;
  border-radius: 8px;
  display: grid;
  place-items: center;
  color: var(--muted);
  transition: background .12s, color .12s;
}
.ch-row:hover .ch-action { color: var(--text); }
.ch-row.active .ch-action { color: var(--danger); }
.ch-row.active .ch-action:hover { background: rgba(252, 88, 82, .14); }
.ch-people { display: flex; align-items: center; gap: 8px; }
.ch-extra { font-size: 13px; color: var(--muted); }

.stack { display: flex; align-items: center; isolation: isolate; }
.stack .avatar { margin-right: -12px; }
.stack .avatar:last-child { margin-right: 0; }
.stack .avatar:nth-child(1) { z-index: 3; }
.stack .avatar:nth-child(2) { z-index: 2; }
.stack .avatar:nth-child(3) { z-index: 1; }
.avatar-28 { width: 28px; height: 28px; font-size: 12px; }

.empty { color: var(--muted); text-align: center; padding: 0 16px; }

.me-row {
  flex: none;
  padding: 16px;
  display: flex;
  align-items: center;
  gap: 16px;
  border: 0;
  border-radius: 20px;
  background: transparent;
  text-align: left;
  transition: background .12s;
}
.me-row:hover { background: rgba(255, 255, 255, .04); }
.avatar-wrap { position: relative; flex: none; }
.status-dot {
  position: absolute;
  right: -2px;
  bottom: -2px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--green);
  border: 3px solid var(--bg);
}
.me-text { min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.me-nick { font-size: 18px; line-height: 22px; font-weight: 500; letter-spacing: .27px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.me-status { font-size: 14px; line-height: 20px; letter-spacing: .21px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ----- Звонок ----- */

.stage {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 96px 20px;
  overflow-y: auto;
}
.stage-empty { color: var(--muted); text-align: center; }

.call { display: flex; flex-direction: column; align-items: center; gap: 48px; }
.call-people { display: flex; flex-wrap: wrap; justify-content: center; gap: 16px; max-width: 720px; }

.person {
  position: relative;
  width: 128px;
  height: 128px;
  padding: 4px;
  border: 3px solid transparent;
  border-radius: 50%;
  background: var(--bg);
  transition: border-color .08s;
}
.person.clickable { cursor: pointer; }
.person .avatar { width: 100%; height: 100%; }
.person.speaking { border-color: var(--speak); }
.person-badge {
  position: absolute;
  right: 1px;
  bottom: 1px;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--badge-red);
  color: #fff;
}
.person-badge .mask-icon { width: 20px; height: 20px; }
.sound-flash {
  position: absolute;
  top: -4px;
  right: -4px;
  font-size: 30px;
  line-height: 1;
  animation: sound-pop 2s ease-out forwards;
  pointer-events: none;
}
@keyframes sound-pop {
  0% { transform: scale(.4); opacity: 0; }
  12% { transform: scale(1.3); opacity: 1; }
  25% { transform: scale(1); }
  80% { opacity: 1; }
  100% { opacity: 0; }
}

.call-actions { display: flex; gap: 16px; }
.call-actions .round-btn { width: 64px; height: 64px; }
.call-actions .mask-icon { width: 32px; height: 32px; }
.round-btn.hangup { background: var(--hangup); }
.round-btn.hangup:hover { background: #e14b45; }
#mute-btn.off { background: var(--danger-bg); color: var(--danger); }
#mute-btn.off:hover { background: var(--danger-hover); }

@media (max-width: 860px) {
  .sidebar { width: 280px; }
  .person { width: 104px; height: 104px; }
}

/* ============ Модальные окна ============ */

.modal {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(0, 0, 0, .72);
  animation: fade .12s ease-out;
}
.modal-card {
  width: min(480px, 100%);
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  animation: pop .15s ease-out;
}
.modal-head { display: flex; flex-direction: column; align-items: center; gap: 4px; text-align: center; }
.modal-head .mask-icon { margin-bottom: 8px; }
.modal-actions { display: flex; gap: 12px; }
.modal-actions .btn { flex: 1; }
.modal-card .form-error { min-height: 0; }
.modal-card .form-error:empty { display: none; }
@keyframes fade { from { opacity: 0; } }
@keyframes pop { from { transform: scale(.95); opacity: 0; } }

/* ----- Загрузка звука ----- */

.upload-card { width: min(520px, 100%); }
.file-drop {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 20px;
  border: 2px dashed var(--line);
  border-radius: 16px;
  color: var(--muted);
  font-size: 14px;
  text-align: center;
  cursor: pointer;
  transition: border-color .15s, background .15s;
}
.file-drop:hover, .file-drop.drag { border-color: #55565c; background: rgba(255, 255, 255, .02); color: var(--text); }
#file-drop-text { word-break: break-word; }

.trim-box { display: flex; flex-direction: column; gap: 8px; }
#wave { width: 100%; height: 60px; display: block; border-radius: 12px; background: var(--bg); }
.trim-row { display: flex; align-items: center; gap: 12px; }
.trim-label { width: 56px; font-size: 14px; color: var(--muted); }
.trim-row input { flex: 1; accent-color: #fff; }
.trim-val { width: 56px; text-align: right; font-size: 14px; font-variant-numeric: tabular-nums; }
#trim-play { align-self: flex-start; }

.upload-fields { display: flex; gap: 12px; }
.emoji-input { width: 64px; flex: none; padding: 0; text-align: center; font-size: 22px; }
.emoji-quick { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; }
.emoji-quick button {
  width: 36px;
  height: 36px;
  border: 0;
  border-radius: 50%;
  background: var(--btn);
  font-size: 18px;
  line-height: 1;
}
.emoji-quick button:hover { background: var(--btn-hover); }

/* ============ Звуковая панель ============ */

.soundboard {
  position: fixed;
  z-index: 45;
  width: min(560px, calc(100vw - 40px));
  padding: 20px;
  animation: pop .12s ease-out;
}
.sb-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 14px; }
.sb-volume { display: flex; align-items: center; gap: 8px; color: var(--muted); width: 200px; }
.sb-volume input { flex: 1; accent-color: #fff; }
.sb-volume-val { width: 40px; text-align: right; font-size: 13px; }

.sb-scroll { max-height: min(400px, 50vh); overflow-y: auto; margin-right: -8px; padding-right: 8px; }
.sb-section {
  margin: 0 0 8px;
  font-size: 13px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--muted);
}
.sb-grid + .sb-section { margin-top: 16px; }
#sb-count { font-weight: 400; }
.sb-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
.sb-btn {
  position: relative;
  height: 72px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 0 6px;
  border: 0;
  border-radius: 16px;
  background: var(--btn);
  color: var(--text);
  font-size: 13px;
  transition: background .12s, transform .06s;
}
.sb-btn:hover { background: var(--btn-hover); }
.sb-btn:active { transform: scale(.95); }
.sb-emoji { font-size: 24px; line-height: 1; }
.sb-btn > span:nth-child(2) { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.soundboard.cooling .sb-btn:not(.sb-add) { opacity: .4; cursor: wait; }
.sb-add { background: transparent; border: 2px dashed var(--line); color: var(--muted); }
.sb-add:hover { color: var(--text); border-color: #55565c; background: transparent; }
.sb-del {
  position: absolute;
  top: 5px;
  right: 5px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  display: none;
  place-items: center;
  background: var(--card);
  color: var(--muted);
}
.sb-del:hover { background: var(--danger-bg); color: var(--danger); }
.sb-btn:hover .sb-del { display: grid; }

.sb-cooldown { height: 3px; margin: 14px 0 10px; border-radius: 2px; background: var(--btn); overflow: hidden; }
#sb-cooldown-bar { height: 100%; width: 0; background: #fff; }
.sb-hint { font-size: 13px; color: var(--muted); text-align: center; }

/* ============ Всплывашки ============ */

.user-pop {
  position: fixed;
  z-index: 40;
  width: 260px;
  padding: 16px;
  border-radius: 20px;
}
.pop-head { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; }
.pop-head .title { font-size: 16px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pop-label { display: flex; justify-content: space-between; font-size: 14px; color: var(--muted); margin-bottom: 8px; }
#pop-range { width: 100%; accent-color: #fff; }

.tip {
  position: fixed;
  z-index: 60;
  max-width: 240px;
  padding: 6px 12px;
  border-radius: 10px;
  background: var(--btn);
  color: var(--text);
  font-size: 14px;
  line-height: 18px;
  box-shadow: 0 8px 16px rgba(0, 0, 0, .4);
  pointer-events: none;
  white-space: nowrap;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 140px;
  transform: translateX(-50%);
  z-index: 70;
  max-width: min(520px, 90vw);
  padding: 12px 18px;
  border-radius: 16px;
  background: var(--btn);
  box-shadow: var(--shadow);
  font-size: 14px;
  text-align: center;
}

::-webkit-scrollbar { width: 8px; }
::-webkit-scrollbar-thumb { background: var(--btn); border-radius: 8px; }
::-webkit-scrollbar-track { background: transparent; }
