/* ------------------------------------------------------------------
   Лира — спокойный тёмный интерфейс: три колонки, почти чёрный канвас,
   один синий акцент, пузыри с «загнутым» углом.
------------------------------------------------------------------- */

:root {
  --canvas: #0b0b0d;
  --rail: #101012;
  --surface-1: #161618;
  --surface-2: #1e1e21;
  --bubble-ai: #1c1c1f;
  --bubble-user: #26262a;
  --divider: #2a2a2e;

  --text: #ececee;
  --text-2: #9a9aa2;
  --text-3: #66666e;

  --accent: #3a7bfd;
  --accent-press: #2e63d6;
  --accent-soft: #1b2a4a;
  --accent-soft-text: #9fc0ff;
  --danger: #ff6b6b;

  --sans: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --display: "Sora", var(--sans);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  background: var(--canvas);
  color: var(--text);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.5;
  overflow: hidden;
}

/* ---------------- каркас ---------------- */

.app {
  display: flex;
  height: 100%;
}

/* ---------------- левая навигация ---------------- */

.rail {
  width: 252px;
  flex: none;
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: var(--rail);
  border-right: 1px solid var(--divider);
}

.rail-brand {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 16px 16px 12px;
}

.logo {
  width: 28px;
  height: 28px;
  flex: none;
}

.wordmark {
  font-family: var(--display);
  font-size: 20px;
  font-weight: 600;
  letter-spacing: -0.4px;
  text-transform: lowercase;
}

.rail-create {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  margin: 0 12px 10px;
  height: 40px;
  border: 0;
  border-radius: 999px;
  background: var(--accent);
  color: #fff;
  font-family: var(--display);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s ease;
}

.rail-create:hover {
  background: var(--accent-press);
}

.rail-create svg {
  width: 17px;
  height: 17px;
}

.rail-nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 0 8px 8px;
}

.rail-link {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 9px 10px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--text-2);
  font-family: var(--sans);
  font-size: 14px;
  text-align: left;
  cursor: pointer;
  transition: background 0.12s ease, color 0.12s ease;
}

.rail-link:hover {
  background: var(--surface-2);
  color: var(--text);
}

.rail-link.active {
  background: var(--surface-2);
  color: var(--text);
}

.rail-link svg {
  width: 18px;
  height: 18px;
  flex: none;
}

.rail-search {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 2px 12px 10px;
  padding: 0 10px;
  height: 36px;
  border-radius: 10px;
  background: var(--surface-2);
}

.rail-search svg {
  width: 16px;
  height: 16px;
  color: var(--text-3);
  flex: none;
}

.rail-search input {
  flex: 1;
  min-width: 0;
  border: 0;
  background: transparent;
  color: var(--text);
  font-family: var(--sans);
  font-size: 13.5px;
  outline: none;
}

.rail-search input::placeholder {
  color: var(--text-3);
}

.rail-section {
  padding: 4px 20px 6px;
  font-family: var(--display);
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.7px;
  text-transform: uppercase;
  color: var(--text-3);
}

.rail-list {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 0 8px 10px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  scrollbar-width: thin;
  scrollbar-color: var(--divider) transparent;
}

.rail-list::-webkit-scrollbar {
  width: 8px;
}

.rail-list::-webkit-scrollbar-thumb {
  background: var(--divider);
  border-radius: 8px;
}

.rail-item {
  display: flex;
  align-items: center;
  gap: 9px;
  width: 100%;
  padding: 7px 9px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--text);
  text-align: left;
  cursor: pointer;
  font-family: inherit;
}

.rail-item:hover {
  background: var(--surface-2);
}

.rail-item.active {
  background: var(--surface-2);
}

.rail-avatar {
  width: 32px;
  height: 32px;
  flex: none;
  border-radius: 50%;
  overflow: hidden;
  display: grid;
  place-items: center;
  color: #fff;
  font-family: var(--display);
  font-size: 12px;
  font-weight: 600;
}

.rail-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.rail-info {
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.rail-name {
  font-size: 13.5px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.rail-sub {
  font-size: 11.5px;
  color: var(--text-3);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.rail-empty {
  padding: 12px 12px;
  font-size: 12.5px;
  line-height: 1.5;
  color: var(--text-3);
}

.rail-foot {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 10px;
  padding: 10px 16px 12px;
  border-top: 1px solid var(--divider);
}

.rail-foot a,
.linkish {
  border: 0;
  padding: 0;
  background: transparent;
  color: var(--text-3);
  font-family: var(--sans);
  font-size: 11.5px;
  text-decoration: none;
  cursor: pointer;
}

.rail-foot a:hover,
.linkish:hover {
  color: var(--text-2);
}

/* ---------------- сцена ---------------- */

.stage {
  flex: 1;
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.view {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

/* ---------------- Discover ---------------- */

.view-discover {
  overflow-y: auto;
  padding: 26px 28px 40px;
  scrollbar-width: thin;
  scrollbar-color: var(--divider) transparent;
}

.view-head h1 {
  margin: 0 0 4px;
  font-family: var(--display);
  font-size: 22px;
  font-weight: 600;
  letter-spacing: -0.3px;
}

.view-head p {
  margin: 0 0 20px;
  font-size: 13.5px;
  color: var(--text-3);
}

.view-head-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.search-field {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 240px;
  height: 38px;
  padding: 0 12px;
  border-radius: 999px;
  background: var(--surface-2);
  border: 1px solid transparent;
  transition: border-color 0.15s ease;
}

.search-field:focus-within {
  border-color: var(--accent);
}

.search-field svg {
  width: 16px;
  height: 16px;
  color: var(--text-3);
  flex: none;
}

.search-field input {
  flex: 1;
  min-width: 0;
  border: 0;
  background: transparent;
  color: var(--text);
  font-family: var(--sans);
  font-size: 13.5px;
  outline: none;
}

.search-field input::placeholder {
  color: var(--text-3);
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 4px 0 6px;
}

.chip {
  height: 32px;
  padding: 0 14px;
  border: 1px solid var(--divider);
  border-radius: 999px;
  background: transparent;
  color: var(--text-2);
  font-family: var(--sans);
  font-size: 13px;
  cursor: pointer;
  transition: background 0.12s ease, color 0.12s ease, border-color 0.12s ease;
}

.chip:hover {
  color: var(--text);
  border-color: #3a3a42;
}

.chip.active {
  background: var(--surface-2);
  border-color: var(--accent);
  color: var(--text);
}

.tag-filter {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 14px;
}

.tag-chip {
  height: 26px;
  padding: 0 10px;
  border: 1px solid var(--divider);
  border-radius: 999px;
  background: transparent;
  color: var(--text-3);
  font-family: var(--sans);
  font-size: 11.5px;
  cursor: pointer;
}

.tag-chip:hover {
  color: var(--text-2);
  border-color: #3a3a42;
}

.tag-chip.active {
  color: var(--accent-soft-text);
  background: var(--accent-soft);
  border-color: transparent;
}

.grid-empty {
  grid-column: 1 / -1;
  padding: 28px 8px;
  text-align: center;
  font-size: 13.5px;
  color: var(--text-3);
}

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
  gap: 12px;
}

.char-card {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding: 14px;
  min-height: 168px;
  border: 1px solid var(--divider);
  border-radius: 16px;
  background: var(--surface-1);
  color: var(--text);
  text-align: left;
  cursor: pointer;
  font-family: inherit;
  transition: background 0.12s ease, transform 0.08s ease;
}

.char-card:hover {
  background: var(--surface-2);
}

.char-card:active {
  transform: scale(0.99);
}

.char-avatar {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  overflow: hidden;
  display: grid;
  place-items: center;
  color: #fff;
  font-family: var(--display);
  font-size: 17px;
  font-weight: 600;
  margin-bottom: 7px;
}

.char-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.char-name {
  font-family: var(--display);
  font-size: 14.5px;
  font-weight: 600;
}

.char-author {
  font-size: 11px;
  color: var(--text-3);
}

.char-desc {
  margin-top: 5px;
  font-size: 12.5px;
  line-height: 1.45;
  color: var(--text-2);
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.char-meta {
  margin-top: auto;
  padding-top: 8px;
  font-size: 11px;
  color: var(--text-3);
}

.card-fav {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.35);
  color: var(--text-3);
  font-size: 15px;
  line-height: 1;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.12s ease, color 0.12s ease;
}

.char-card:hover .card-fav,
.card-fav.active {
  opacity: 1;
}

.card-fav:hover {
  color: var(--text);
}

.card-fav.active {
  color: #ffd166;
}

@media (hover: none) {
  .card-fav {
    opacity: 1;
  }
}

.help-list {
  margin: 0;
  padding-left: 20px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.help-list li {
  font-size: 13px;
  line-height: 1.55;
  color: var(--text-2);
}

.help-list b {
  color: var(--text);
  font-weight: 600;
}

/* Публичная сборка: без технических разделов */
.public-mode .dev-only {
  display: none !important;
}

.public-mode .rail-foot {
  display: none;
}

.char-create {
  align-items: center;
  justify-content: center;
  text-align: center;
  border-style: dashed;
  border-color: #34343a;
  background: transparent;
}

.char-create-plus {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  margin-bottom: 8px;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent-soft-text);
  font-size: 22px;
  line-height: 1;
}

.char-create .char-desc {
  -webkit-line-clamp: 2;
}

/* ---------------- чат ---------------- */

.view-chat {
  position: relative;
}

.chat-head {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 11px 18px;
  border-bottom: 1px solid var(--divider);
  flex: none;
}

.chat-avatar {
  width: 36px;
  height: 36px;
  flex: none;
  border-radius: 50%;
  overflow: hidden;
  display: grid;
  place-items: center;
  color: #fff;
  font-family: var(--display);
  font-size: 13px;
  font-weight: 600;
}

.chat-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.chat-titles {
  flex: 1;
  min-width: 0;
}

.chat-name {
  font-family: var(--display);
  font-size: 15px;
  font-weight: 600;
}

.chat-sub {
  font-size: 12px;
  color: var(--text-3);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chat-actions {
  display: flex;
  gap: 2px;
}

.icon-btn {
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--text-3);
  cursor: pointer;
}

.icon-btn:hover {
  background: var(--surface-2);
  color: var(--text);
}

.icon-btn svg {
  width: 17px;
  height: 17px;
}

.chat-scroll {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 20px 18px 8px;
  scrollbar-width: thin;
  scrollbar-color: var(--divider) transparent;
}

.chat-scroll::-webkit-scrollbar {
  width: 10px;
}

.chat-scroll::-webkit-scrollbar-thumb {
  background: var(--divider);
  border-radius: 8px;
}

.greeting {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 28px 16px 24px;
  text-align: center;
}

.greeting-avatar {
  width: 84px;
  height: 84px;
  border-radius: 50%;
  overflow: hidden;
  display: grid;
  place-items: center;
  color: #fff;
  font-family: var(--display);
  font-size: 30px;
  font-weight: 600;
  margin-bottom: 8px;
}

.greeting-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.greeting-name {
  margin: 0;
  font-family: var(--display);
  font-size: 21px;
  font-weight: 600;
}

.greeting-desc {
  margin: 0;
  max-width: 420px;
  font-size: 13.5px;
  color: var(--text-2);
}

.messages {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.msg {
  display: flex;
  align-items: flex-start;
  gap: 9px;
}

.msg.user {
  justify-content: flex-end;
}

.msg-avatar {
  width: 26px;
  height: 26px;
  flex: none;
  border-radius: 50%;
  overflow: hidden;
  display: grid;
  place-items: center;
  color: #fff;
  font-family: var(--display);
  font-size: 10px;
  font-weight: 600;
  margin-top: 20px;
}

.msg-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.msg-col {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  min-width: 0;
  max-width: min(640px, 86%);
}

.msg.user .msg-col {
  align-items: flex-end;
}

.msg-meta {
  font-family: var(--display);
  font-size: 11px;
  font-weight: 600;
  color: var(--text-3);
  padding: 0 4px 4px;
}

.msg-bubble {
  background: var(--bubble-ai);
  border: 1px solid var(--divider);
  border-radius: 4px 18px 18px 18px;
  padding: 11px 14px;
  max-width: 100%;
}

.msg.user .msg-bubble {
  background: var(--bubble-user);
  border: 0;
  border-radius: 18px 4px 18px 18px;
}

.msg-body {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  font-size: 15px;
  line-height: 1.5;
}

.roleplay {
  font-style: italic;
  color: var(--text-2);
}

.msg.error .msg-bubble {
  border-color: rgba(255, 107, 107, 0.4);
}

.msg.error .msg-body {
  color: var(--danger);
}

.msg.pending .msg-body::after {
  content: "";
  display: inline-block;
  width: 7px;
  height: 7px;
  margin-left: 4px;
  border-radius: 50%;
  background: var(--accent);
  animation: pulse 1.2s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.35; }
}

.msg-images {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 6px;
}

.msg-images img {
  max-width: 220px;
  max-height: 220px;
  border-radius: 12px;
  border: 1px solid var(--divider);
  object-fit: cover;
}

.msg-footer {
  display: flex;
  margin-top: 3px;
  opacity: 0;
  transition: opacity 0.12s ease;
}

.msg.user .msg-footer {
  justify-content: flex-end;
}

.msg:hover .msg-footer,
.msg:focus-within .msg-footer {
  opacity: 1;
}

@media (hover: none) {
  .msg-footer {
    opacity: 1;
  }
}

.msg-action {
  width: 26px;
  height: 26px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--text-3);
  cursor: pointer;
}

.msg-action:hover {
  background: var(--surface-2);
  color: var(--text-2);
}

.msg-action svg {
  width: 13px;
  height: 13px;
}

/* композер */

.composer-wrap {
  flex: none;
  padding: 8px 16px 12px;
}

.composer {
  max-width: 760px;
  margin: 0 auto;
  border: 1px solid var(--divider);
  border-radius: 24px;
  background: var(--surface-2);
  transition: border-color 0.15s ease;
}

.composer:focus-within {
  border-color: rgba(58, 123, 253, 0.55);
}

.composer-row {
  display: flex;
  align-items: flex-end;
  gap: 6px;
  padding: 8px 8px 8px 10px;
}

.attach-btn {
  flex: none;
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--text-3);
  cursor: pointer;
}

.attach-btn:hover {
  color: var(--text);
  background: rgba(255, 255, 255, 0.05);
}

.attach-btn svg {
  width: 19px;
  height: 19px;
}

#input {
  flex: 1;
  min-height: 36px;
  max-height: 180px;
  padding: 8px 2px;
  border: 0;
  background: transparent;
  color: var(--text);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.45;
  resize: none;
  outline: none;
}

#input::placeholder {
  color: var(--text-3);
}

.send-btn {
  flex: none;
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
  transition: background 0.15s ease;
}

.send-btn:hover {
  background: var(--accent-press);
}

.send-btn.stop {
  background: var(--danger);
}

.send-btn svg {
  width: 19px;
  height: 19px;
}

.disclaimer {
  max-width: 760px;
  margin: 7px auto 0;
  text-align: center;
  font-size: 11px;
  color: var(--text-3);
}

.empty-chat {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 24px;
  text-align: center;
}

.empty-chat h2 {
  margin: 0;
  font-family: var(--display);
  font-size: 20px;
  font-weight: 600;
}

.empty-chat p {
  margin: 0 0 6px;
  max-width: 380px;
  font-size: 13.5px;
  color: var(--text-3);
}

/* вложения */

.attachments {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 10px 12px 0;
}

.att {
  position: relative;
  width: 58px;
  height: 58px;
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid var(--divider);
  background: var(--surface-1);
}

.att img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.att-remove {
  position: absolute;
  top: 2px;
  right: 2px;
  width: 18px;
  height: 18px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.7);
  color: #fff;
  cursor: pointer;
  padding: 0;
}

.att-remove svg {
  width: 10px;
  height: 10px;
}

/* ---------------- правая панель ---------------- */

.panel {
  width: 300px;
  flex: none;
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 0;
  overflow-y: auto;
  padding: 22px 18px;
  border-left: 1px solid var(--divider);
  background: var(--rail);
  scrollbar-width: thin;
  scrollbar-color: var(--divider) transparent;
}

.panel-avatar {
  width: 92px;
  height: 92px;
  border-radius: 50%;
  overflow: hidden;
  display: grid;
  place-items: center;
  color: #fff;
  font-family: var(--display);
  font-size: 32px;
  font-weight: 600;
  margin: 4px auto 0;
}

.panel-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.panel-name {
  margin: 6px 0 0;
  text-align: center;
  font-family: var(--display);
  font-size: 19px;
  font-weight: 600;
}

.panel-author {
  text-align: center;
  font-size: 12px;
  color: var(--text-3);
}

.panel-stats {
  text-align: center;
  font-size: 11.5px;
  color: var(--text-3);
  padding-bottom: 4px;
}

.panel-actions {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 8px 0;
}

.panel-btn {
  height: 36px;
  border: 1px solid var(--divider);
  border-radius: 10px;
  background: transparent;
  color: var(--text-2);
  font-family: var(--sans);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.12s ease, color 0.12s ease;
}

.panel-btn:hover {
  background: var(--surface-2);
  color: var(--text);
}

.panel-btn.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  font-weight: 600;
}

.panel-btn.primary:hover {
  background: var(--accent-press);
}

.panel-btn.danger {
  color: var(--danger);
}

.panel-btn.danger:hover {
  background: rgba(255, 107, 107, 0.1);
}

.panel-block {
  border-top: 1px solid var(--divider);
  padding-top: 10px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.panel-label {
  font-family: var(--display);
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.6px;
  text-transform: uppercase;
  color: var(--text-3);
}

.panel-text {
  margin: 0;
  font-size: 12.5px;
  line-height: 1.5;
  color: var(--text-2);
}

.panel-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.tag {
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--surface-2);
  font-size: 11px;
  color: var(--text-2);
}

.panel-prompt {
  margin: 0;
  max-height: 220px;
  overflow: auto;
  padding: 10px;
  border: 1px solid var(--divider);
  border-radius: 10px;
  background: var(--canvas);
  color: var(--text-2);
  font-family: ui-monospace, "SF Mono", Consolas, monospace;
  font-size: 11px;
  line-height: 1.5;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

/* ---------------- панели (sheet) ---------------- */

.sheet {
  width: min(720px, 94vw);
  max-height: 90vh;
  margin: auto;
  padding: 0;
  overflow: auto;
  border: 1px solid var(--divider);
  border-radius: 16px;
  background: var(--surface-1);
  color: var(--text);
  box-shadow: 0 -8px 32px rgba(0, 0, 0, 0.5);
}

.sheet::backdrop {
  background: rgba(0, 0, 0, 0.55);
}

.sheet-form {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 18px;
}

.sheet-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.sheet-head h2 {
  margin: 0;
  font-family: var(--display);
  font-size: 18px;
  font-weight: 600;
}

.sheet-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  padding-top: 4px;
}

.sheet-actions .spacer {
  flex: 1;
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.field-label {
  font-family: var(--display);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  color: var(--text-3);
}

.field-hint {
  font-size: 12px;
  color: var(--text-3);
}

.field textarea,
.field input[type="text"],
.field select {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--divider);
  border-radius: 12px;
  background: var(--surface-2);
  color: var(--text);
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.45;
  outline: none;
}

.field textarea {
  max-height: 220px;
  resize: vertical;
}

.field input[type="text"],
.field select {
  height: 40px;
  padding: 0 12px;
}

.field textarea:focus,
.field input[type="text"]:focus,
.field select:focus {
  border-color: var(--accent);
}

.field textarea::placeholder,
.field input::placeholder {
  color: var(--text-3);
}

.section {
  border: 1px solid var(--divider);
  border-radius: 14px;
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.section > summary {
  cursor: pointer;
  font-family: var(--display);
  font-size: 13px;
  font-weight: 600;
  color: var(--text-2);
  list-style: none;
}

.section > summary::-webkit-details-marker {
  display: none;
}

.section > summary::before {
  content: "▸";
  margin-right: 6px;
  color: var(--text-3);
}

.section[open] > summary::before {
  content: "▾";
}

.avatar-row {
  display: flex;
  align-items: center;
  gap: 12px;
}

.avatar-preview {
  width: 64px;
  height: 64px;
  flex: none;
  border-radius: 50%;
  overflow: hidden;
  display: grid;
  place-items: center;
  background: var(--surface-2);
  border: 1px solid var(--divider);
  font-size: 12px;
  color: var(--text-3);
}

.avatar-preview img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.avatar-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.soft-btn {
  height: 36px;
  padding: 0 14px;
  border: 0;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent-soft-text);
  font-family: var(--display);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}

.soft-btn:hover {
  background: #22315a;
}

.soft-btn.small {
  width: 36px;
  padding: 0;
  align-self: flex-start;
}

.danger-btn {
  height: 36px;
  padding: 0 14px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--danger);
  font-family: var(--display);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}

.danger-btn:hover {
  background: rgba(255, 107, 107, 0.12);
}

.create-btn {
  height: 38px;
  padding: 0 20px;
  border: 0;
  border-radius: 999px;
  background: var(--accent);
  color: #fff;
  font-family: var(--display);
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
}

.create-btn:hover {
  background: var(--accent-press);
}

.create-btn.compact {
  height: 36px;
}

.examples-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.example-row {
  display: grid;
  grid-template-columns: 1fr 1fr auto;
  gap: 6px;
  align-items: start;
}

.example-row textarea {
  min-height: 46px;
  max-height: 120px;
}

.prompt-preview-wrap {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 8px;
}

.prompt-preview {
  margin: 0;
  width: 100%;
  max-height: 260px;
  overflow: auto;
  padding: 12px;
  border: 1px solid var(--divider);
  border-radius: 12px;
  background: var(--canvas);
  color: var(--text-2);
  font-family: ui-monospace, "SF Mono", Consolas, monospace;
  font-size: 11.5px;
  line-height: 1.55;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.msg-images-edit {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

/* ---------------- адаптив ---------------- */

@media (max-width: 1180px) {
  .panel {
    display: none;
  }
}

@media (max-width: 860px) {
  .app {
    flex-direction: column;
  }

  .rail {
    width: 100%;
    max-height: 42vh;
    border-right: 0;
    border-bottom: 1px solid var(--divider);
  }

  .rail-nav {
    flex-direction: row;
  }

  .rail-link {
    flex: 1;
    justify-content: center;
  }

  .rail-list,
  .card-grid {
    flex-direction: row;
  }

  .rail-list {
    flex-direction: row;
    overflow-x: auto;
    overflow-y: hidden;
  }

  .rail-item {
    min-width: 190px;
    max-width: 210px;
  }

  .card-grid {
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  }

  .rail-foot {
    display: none;
  }

  .form-grid,
  .example-row {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 560px) {
  .view-discover {
    padding: 16px 12px 28px;
  }

  .chat-head {
    padding: 9px 12px;
  }

  .chat-scroll {
    padding: 14px 12px 6px;
  }

  .msg-col {
    max-width: 90%;
  }

  .composer-wrap {
    padding: 8px 10px 10px;
  }

  .sheet {
    width: 96vw;
  }
}
