/* Фирменная палитра ИНМАШ: графит + оранжевый. Mobile-first. */
:root {
  --graphite-900: #14171b;
  --graphite-800: #1c1f24;
  --graphite-700: #262a31;
  --graphite-600: #333842;
  --line: #383e49;
  --text: #e8eaed;
  --text-dim: #9aa2ad;
  --orange: #f07f1a;
  --orange-dim: #b85f10;
  --danger: #e05b4b;
  --radius: 12px;
  --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  font-family: var(--font);
  background: var(--graphite-900);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  overscroll-behavior: none;
}
.hidden { display: none !important; }
button, input, textarea { font: inherit; color: inherit; }

.brand { font-weight: 700; letter-spacing: .08em; font-size: 22px; }
.brand.small { font-size: 16px; }
.brand-mark { color: var(--orange); }

/* ---------- вход ---------- */
.login {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 24px;
  position: relative;
  /* Кадр горизонтальный: на узком экране держим низ, где стоят модули. */
  background: #14171b url('/login-bg.jpg') 50% 78% / cover no-repeat;
}
/* Затемняющая вуаль: фон остаётся фоном, поля читаются всегда. */
.login::after {
  content: '';
  position: absolute; inset: 0;
  background: linear-gradient(180deg, rgba(20,23,27,.45) 0%, rgba(20,23,27,.72) 100%);
}
.login > * { position: relative; z-index: 1; }

/* Логотип — на светлой плашке-шильде: сам знак тёмный и на графите теряется. */
.logo {
  width: 168px; height: auto; display: block;
  background: #f3f4f6;
  border-radius: 10px;
  padding: 14px 18px;
  margin: 0 auto 4px;
}
.logo-small {
  width: 92px; height: auto; display: block;
  background: #f3f4f6; border-radius: 7px; padding: 7px 9px;
}
.login-card {
  width: 100%;
  max-width: 360px;
  background: rgba(28, 31, 36, .92);
  backdrop-filter: blur(12px);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 28px 24px;
  display: grid;
  gap: 14px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, .5);
}
.login-sub {
  margin: -2px 0 10px; color: var(--text-dim); font-size: 13px;
  text-align: center; letter-spacing: .04em;
}
.login-card label { display: grid; gap: 6px; font-size: 13px; color: var(--text-dim); }
.login-card input {
  background: var(--graphite-700);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  font-size: 16px; /* 16px — иначе iOS зумит поле при фокусе */
}
.login-card input:focus { outline: 2px solid var(--orange); outline-offset: -1px; }
.btn-primary {
  background: var(--orange);
  color: #14171b;
  font-weight: 600;
  border: 0;
  border-radius: 8px;
  padding: 12px;
  cursor: pointer;
}
.btn-primary:disabled { background: var(--orange-dim); cursor: default; }
.error { color: var(--danger); font-size: 13px; margin: 0; }

/* ---------- каркас приложения ---------- */
.app { display: flex; height: 100dvh; }

.sidebar {
  width: 264px;
  flex: 0 0 264px;
  background: var(--graphite-800);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
}
.sidebar-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 8px; padding: 14px 14px 10px;
}
.btn-ghost {
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 6px 10px;
  color: var(--text-dim);
  cursor: pointer;
}
.btn-ghost:hover { color: var(--text); border-color: var(--graphite-600); }

.thread-list { flex: 1; overflow-y: auto; padding: 4px 8px; }
.thread-counter { margin: 0; padding: 0 14px 8px; font-size: 11px; color: var(--text-dim); }

.projects { border-top: 1px solid var(--line); padding: 10px 12px; display: grid; gap: 4px; max-height: 32vh; overflow-y: auto; }
.project {
  text-align: left; background: transparent; border: 0; border-radius: 6px;
  padding: 6px 8px; font-size: 13px; color: var(--text-dim); cursor: pointer;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.project:hover { background: var(--graphite-700); color: var(--text); }
.projects-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.projects-empty { margin: 2px 0 0; font-size: 12px; color: var(--text-dim); }
.project-row { display: flex; align-items: center; gap: 4px; }
.project-row .project { flex: 1; }
.project-row .del { opacity: 0; border: 0; background: none; color: var(--text-dim); cursor: pointer; }
.project-row:hover .del { opacity: 1; }
.btn-ghost.tiny { padding: 1px 7px; font-size: 13px; line-height: 1.3; }
.thread {
  display: flex; align-items: center; gap: 6px;
  padding: 9px 10px; border-radius: 8px;
  color: var(--text-dim); font-size: 14px; cursor: pointer;
}
.thread:hover { background: var(--graphite-700); color: var(--text); }
.thread.active { background: var(--graphite-700); color: var(--text); box-shadow: inset 2px 0 0 var(--orange); }
.thread span { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.thread .del { opacity: 0; border: 0; background: none; color: var(--text-dim); cursor: pointer; }
.thread:hover .del { opacity: 1; }

.sidebar-foot { border-top: 1px solid var(--line); padding: 10px 12px; display: grid; gap: 10px; }
.outbox { display: grid; gap: 6px; max-height: 30vh; overflow-y: auto; }
.outbox a {
  color: var(--text-dim); font-size: 13px; text-decoration: none;
  display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.outbox a:hover { color: var(--orange); }
.outbox-title { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--text-dim); }
.user-row { display: flex; align-items: center; justify-content: space-between; font-size: 13px; color: var(--text-dim); }

/* ---------- чат ---------- */
.chat { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.chat-head {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 16px; border-bottom: 1px solid var(--line);
}
.chat-head h1 { font-size: 15px; font-weight: 500; margin: 0; color: var(--text-dim);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.messages { flex: 1; overflow-y: auto; padding: 20px 16px 8px; display: grid; gap: 16px; align-content: start; }
.msg { max-width: 760px; width: 100%; margin: 0 auto; display: grid; gap: 6px; }
.msg .who { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--text-dim); }
.msg .body {
  background: var(--graphite-800); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 12px 14px;
  white-space: pre-wrap; word-wrap: break-word; line-height: 1.5; font-size: 15px;
}
.msg.user .body { background: var(--graphite-700); border-color: var(--graphite-600); }
.msg.error .body { border-color: var(--danger); }
.msg .body code { background: var(--graphite-900); padding: 1px 5px; border-radius: 4px; font-size: 13px; }
.msg .attachments { font-size: 12px; color: var(--text-dim); }

.status { max-width: 760px; width: 100%; margin: 0 auto; font-size: 13px; color: var(--orange); }
.status .dot { animation: pulse 1.2s infinite; }
@keyframes pulse { 0%, 100% { opacity: .3 } 50% { opacity: 1 } }

/* ---------- ввод ---------- */
.composer { border-top: 1px solid var(--line); padding: 10px 16px calc(10px + env(safe-area-inset-bottom)); }
.composer-row { max-width: 760px; margin: 0 auto; display: flex; gap: 8px; align-items: flex-end; }
.btn-attach {
  border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px;
  cursor: pointer; color: var(--text-dim); line-height: 1;
}
#input {
  flex: 1; resize: none; max-height: 200px;
  background: var(--graphite-800); border: 1px solid var(--line);
  border-radius: 8px; padding: 11px 12px; font-size: 16px; line-height: 1.4;
}
#input:focus { outline: 2px solid var(--orange); outline-offset: -1px; }
.send { padding: 11px 16px; }
.hint { max-width: 760px; margin: 6px auto 0; font-size: 11px; color: var(--text-dim); }
.pending-files { max-width: 760px; margin: 0 auto 8px; font-size: 12px; color: var(--text-dim); }

.only-mobile { display: none; }
.backdrop { position: fixed; inset: 0; background: rgba(0,0,0,.5); z-index: 5; }

/* ---------- телефон ---------- */
@media (max-width: 720px) {
  .only-mobile { display: inline-block; }
  /* На узком экране cover режет панораму в глухую стену: кладём её лентой понизу. */
  .login { background-size: auto 44%; background-position: center bottom; }
  .login::after { background: linear-gradient(180deg, rgba(20,23,27,.5) 0%, rgba(20,23,27,.75) 55%, rgba(20,23,27,.35) 100%); }
  .sidebar {
    position: fixed; z-index: 10; top: 0; bottom: 0; left: 0;
    transform: translateX(-100%); transition: transform .2s ease;
  }
  .sidebar.open { transform: translateX(0); }
  .hint { display: none; }
  .messages { padding: 14px 12px 4px; }
}
