/* Flame — общая система стилей кабинета (ванильный JS, фаза 3.5).
   Те же токены, что у лендинга: чёрный + оранжевый, бирюза в градиентах. */

:root {
  --bg: #0a0a0b;
  --surface: #131315;
  --surface-2: #1a1a1e;
  --line: rgba(245, 240, 234, .09);
  --ink: #f5f0ea;
  --muted: #9c948a;
  --orange: #ff6b1a;
  --amber: #ffb347;
  --teal: #40c8d0;
  --danger: #ff5252;
  --shadow: 0 8px 30px rgba(0, 0, 0, .45);
  --flame-grad: linear-gradient(100deg, var(--teal), var(--amber) 45%, var(--orange));
  --r-lg: 20px; --r-md: 12px; --r-btn: 10px;
}

/* Светлая тема: переключается из настроек (General),
   хранится в localStorage flame_theme. */
[data-theme="light"] {
  --bg: #f6f4f1;
  --surface: #ffffff;
  --surface-2: #efede9;
  --line: rgba(23, 21, 18, .12);
  --ink: #171512;
  --muted: #6f6a61;
  --shadow: 0 8px 30px rgba(23, 21, 18, .14);
}

* { box-sizing: border-box; margin: 0 }

/* Плавный скролл по якорям и внутри чата */
html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
}

body {
  background: var(--bg); color: var(--ink);
  font-family: "Onest", system-ui, sans-serif;
  font-size: 16px; line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  min-height: 100dvh;
  overflow-x: clip;
}

/* Лёгкая 3D-глубина логотипа (мягкая тень под пламенем) */
img[src*="flame-logo"] {
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, .35));
}

h1, h2, h3 {
  font-family: "Unbounded", "Onest", sans-serif;
  font-weight: 600; letter-spacing: -.01em; line-height: 1.2;
}
h1 { font-size: 30px } h2 { font-size: 24px } h3 { font-size: 16px }
a { color: var(--orange) }
.muted { color: var(--muted) }
.grad-text {
  background: var(--flame-grad);
  -webkit-background-clip: text; background-clip: text; color: transparent;
}

/* ---------- app shell ---------- */
.shell { display: flex; min-height: 100vh }
.sidebar {
  width: 230px; flex-shrink: 0; border-right: 1px solid var(--line);
  padding: 20px 14px; display: flex; flex-direction: column; gap: 4px;
  position: sticky; top: 0; height: 100vh;
  background: rgba(19, 19, 21, .5);
}
.sidebar__logo { display: flex; align-items: center; gap: 10px;
  text-decoration: none; color: var(--ink);
  font-family: "Unbounded", "Onest", sans-serif; font-weight: 600;
  font-size: 18px; padding: 6px 10px 18px }
.sidebar__logo img { height: 30px; width: auto }
.side-link {
  display: flex; align-items: center; gap: 10px; padding: 10px 12px;
  border-radius: var(--r-btn); color: var(--muted); text-decoration: none;
  font-size: 15px; transition: background .15s, color .15s;
}
.side-link:hover { background: var(--surface-2); color: var(--ink) }
.side-link.active {
  background: linear-gradient(100deg, rgba(64,200,208,.12), rgba(255,107,26,.16));
  color: var(--ink);
}
.sidebar__foot { margin-top: auto; font-size: 13px; color: var(--muted); padding: 10px }
.main { flex: 1; padding: 40px clamp(24px, 4vw, 72px); max-width: 1920px; width: 100% }
.page-head { margin-bottom: 28px }
.page-head .sub { color: var(--muted); margin-top: 6px }

/* ---------- controls ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 44px; padding-inline: 20px; border-radius: var(--r-btn);
  font-size: 15px; font-weight: 560; border: 1px solid transparent;
  cursor: pointer; text-decoration: none;
  transition: transform .15s, box-shadow .2s, border-color .2s;
  font-family: inherit;
}
.btn--primary { background: var(--orange); color: #0a0a0b }
.btn--primary:hover { transform: translateY(-2px); box-shadow: 0 8px 28px rgba(255,107,26,.3) }
.btn--primary:disabled { opacity: .5; transform: none; box-shadow: none; cursor: wait }
.btn--ghost { border-color: var(--line); color: var(--ink); background: transparent }
.btn--ghost:hover { border-color: rgba(245,240,234,.25) }
.btn--danger { background: transparent; border-color: rgba(255,82,82,.4); color: var(--danger) }
.btn--danger:hover { background: rgba(255,82,82,.08) }
.btn--sm { height: 36px; padding-inline: 14px; font-size: 14px }

.field { margin-bottom: 16px }
.field label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 6px }
.field input {
  width: 100%; height: 48px; padding: 0 14px; border-radius: var(--r-md);
  border: 1px solid var(--line); background: var(--surface);
  color: var(--ink); font-size: 16px; font-family: inherit;
  transition: border-color .15s;
}
.field input:focus { outline: none; border-color: var(--orange) }
.field input.mono { font-variant-numeric: tabular-nums; letter-spacing: .08em }

.card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r-lg); padding: 24px; margin-bottom: 16px;
}
.card h3 { margin-bottom: 10px }

.notice { padding: 12px 16px; border-radius: var(--r-md); font-size: 14px; margin-bottom: 16px }
.notice--error { background: rgba(255,82,82,.1); border: 1px solid rgba(255,82,82,.35); color: #ffb3b3 }
.notice--ok { background: rgba(64,200,208,.08); border: 1px solid rgba(64,200,208,.3); color: var(--teal) }
[hidden] { display: none !important }

.pill { display: inline-block; padding: 2px 10px; border-radius: 99px; font-size: 12.5px;
  border: 1px solid var(--line); color: var(--muted) }
.pill--on { color: var(--teal); border-color: rgba(64,200,208,.4) }
.pill--off { color: var(--muted) }
.pill--wait { color: var(--amber); border-color: rgba(255,179,71,.4) }

/* ---------- chat ---------- */
.chat-box { display: flex; flex-direction: column; height: calc(100vh - 220px);
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); overflow: hidden }
.chat-msgs { flex: 1; overflow-y: auto; padding: 20px; display: flex; flex-direction: column; gap: 12px }
.msg { max-width: 75%; padding: 11px 15px; border-radius: 16px; font-size: 15px;
  animation: msgin .25s ease-out; white-space: pre-wrap }
@keyframes msgin { from { opacity: 0; transform: translateY(6px) } }
.msg--me { align-self: flex-end; background: var(--orange); color: #0a0a0b; border-bottom-right-radius: 4px }
.msg--bot { align-self: flex-start; background: var(--surface-2); border: 1px solid var(--line);
  border-bottom-left-radius: 4px }
.msg--typing { display: inline-flex; gap: 4px; padding: 14px 16px }
.msg--typing i { width: 6px; height: 6px; border-radius: 50%; background: var(--muted);
  animation: blink 1s infinite }
.msg--typing i:nth-child(2) { animation-delay: .2s }
.msg--typing i:nth-child(3) { animation-delay: .4s }
@keyframes blink { 50% { opacity: .25 } }
.chat-input { display: flex; gap: 10px; padding: 14px; border-top: 1px solid var(--line) }
.chat-input input { flex: 1; height: 46px; padding: 0 14px; border-radius: var(--r-md);
  border: 1px solid var(--line); background: var(--bg); color: var(--ink);
  font-size: 15px; font-family: inherit }
.chat-input input:focus { outline: none; border-color: var(--orange) }

/* ---------- devices / tools ---------- */
.dev-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px }
.dev-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg);
  padding: 20px; transition: transform .2s, border-color .2s }
.dev-card:hover { transform: translateY(-2px); border-color: rgba(255,107,26,.3) }
.dev-card__head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px }
.dev-card__name { font-weight: 620; font-size: 17px }
.dev-card .meta { font-size: 13.5px; color: var(--muted); line-height: 1.9 }
.dev-card .actions { display: flex; gap: 8px; margin-top: 14px }

.tgroup { margin-bottom: 26px }
.trow { display: flex; justify-content: space-between; align-items: baseline; gap: 16px;
  padding: 14px 4px; border-bottom: 1px solid var(--line) }
.trow__val { font-variant-numeric: tabular-nums; color: var(--amber); font-weight: 620; white-space: nowrap }
.empty { color: var(--muted); padding: 18px 4px; font-size: 14.5px }

@media (max-width: 820px) {
  .shell { flex-direction: column }
  .sidebar {
    width: 100%; height: auto; position: sticky; top: 0; z-index: 20;
    flex-direction: row; overflow-x: auto; align-items: center;
    padding: 8px 10px; background: var(--surface);
    border-right: 0; border-bottom: 1px solid var(--line);
    -webkit-overflow-scrolling: touch;
  }
  .sidebar > * { flex-shrink: 0 }
  .sidebar__logo { padding: 4px 8px; font-size: 16px }
  .sidebar__logo img { height: 26px }
  .side-link { white-space: nowrap }
  .sidebar__foot { display: flex; margin-top: 0; margin-left: auto; padding: 0 2px }
  .main { padding: 20px 14px calc(24px + env(safe-area-inset-bottom)) }
  .page-head { margin-bottom: 20px }
  .page-head h1 { font-size: 26px }
  .card { padding: 18px }
  .dev-grid { grid-template-columns: 1fr }
  .trow { flex-wrap: wrap; gap: 4px 12px }
  .trow__val { white-space: normal }
  .chat-box { height: calc(100vh - 200px); height: calc(100dvh - 200px) }
}

@media (max-width: 480px) {
  .main { padding: 16px 12px calc(22px + env(safe-area-inset-bottom)) }
  .card { padding: 16px; border-radius: 16px }
  .page-head h1 { font-size: 23px }
  .btn { padding-inline: 16px }
  .dev-card { padding: 16px }
  .chat-box { height: calc(100vh - 176px); height: calc(100dvh - 176px) }
}
