/**
 * Genesis shell — мост стилей ai-workspace-chat внутри gw-* layout
 * Grid на .gw-glass-zone (#aiChatContainer) — не display:contents!
 */

body.genesis-workspace {
  height: 100dvh;
  max-height: 100dvh;
  overflow: hidden;
}

.genesis-workspace .gw-shell {
  height: 100dvh;
  max-height: 100dvh;
  min-height: 0;
  overflow: hidden;
}

.genesis-workspace .gw-workspace {
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

.genesis-workspace .gw-content {
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

.genesis-workspace .gw-view.is-active {
  flex: 1;
  min-height: 0;
  max-height: 100%;
  overflow: hidden;
}

.genesis-workspace #aiChatContainer.gw-glass-zone {
  display: grid !important;
  grid-template-columns: minmax(168px, 200px) minmax(0, 1fr) minmax(148px, 176px);
  grid-template-rows: minmax(0, 1fr);
  grid-template-areas: "chats command tools";
  height: 100%;
  max-height: 100%;
  min-height: 0;
  flex: 1;
  align-self: stretch;
}

.genesis-workspace .gw-chat-rail {
  grid-area: chats;
  height: 100%;
  max-height: 100%;
  min-height: 0;
  overflow: hidden;
}

.genesis-workspace .gw-chat-rail__head {
  flex-shrink: 0;
  position: sticky;
  top: 0;
  z-index: 2;
  background: inherit;
}

.genesis-workspace .gw-command--fullscreen {
  grid-area: command;
  height: 100%;
  max-height: 100%;
  min-height: 0;
  overflow: hidden;
}

.genesis-workspace .ai-chat-main {
  height: 100%;
  max-height: 100%;
  min-height: 0;
  overflow: hidden;
}

.genesis-workspace .gw-tools-column {
  grid-area: tools;
  display: flex;
  flex-direction: column;
  min-height: 0;
  max-height: 100%;
  border-left: 1.5px solid var(--gw-stroke);
  background: rgba(0, 0, 0, 0.08);
  overflow: hidden;
}

html[data-theme="light"] .genesis-workspace .gw-tools-column {
  background: rgba(255, 255, 255, 0.5);
}

.genesis-workspace .gw-tools--role {
  flex: 0 1 auto;
  max-height: 52%;
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  border-left: none;
  background: transparent;
  padding: 0.75rem 0.55rem 0.35rem;
}

html[data-theme="light"] .genesis-workspace .gw-tools--role {
  background: transparent;
}

.genesis-workspace .gw-chat-docs {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  padding: 0.35rem 0.55rem 0.75rem;
  border-top: 1px solid var(--gw-stroke-soft, rgba(255,255,255,.08));
  overflow: hidden;
}

.gw-chat-docs__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.35rem;
  margin-bottom: 0.35rem;
}

.gw-chat-docs__title {
  margin: 0;
}

.gw-chat-docs__all-btn {
  font: inherit;
  font-size: 0.65rem;
  padding: 0.2rem 0.45rem;
  border-radius: 6px;
  border: 1px solid var(--gw-stroke-soft);
  background: var(--gz-surface, rgba(255,255,255,.06));
  color: var(--hz-accent, #ed5b2f);
  cursor: pointer;
}

.gw-chat-docs__list {
  list-style: none;
  margin: 0;
  padding: 0;
  overflow-y: auto;
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.gw-chat-docs__item {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 0.35rem;
  align-items: center;
  padding: 0.35rem 0.4rem;
  border-radius: 8px;
  border: 1px solid transparent;
  cursor: pointer;
  transition: background .12s, border-color .12s;
}

.gw-chat-docs__item:hover {
  background: rgba(255,255,255,.05);
}

.gw-chat-docs__item.is-selected {
  border-color: var(--hz-accent, #ed5b2f);
  background: var(--hz-accent-muted, rgba(237,91,47,.12));
}

.gw-chat-docs__num {
  font-size: 0.68rem;
  font-weight: 700;
  color: var(--hz-accent, #ed5b2f);
  min-width: 1.4rem;
}

.gw-chat-docs__name {
  font-size: 0.68rem;
  color: var(--gz-ink, #e8edf2);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.gw-chat-docs__size {
  font-size: 0.6rem;
  color: var(--gz-ink-muted, #8899aa);
}

.gw-chat-docs__hint {
  margin: 0.35rem 0 0;
  font-size: 0.58rem;
  color: var(--gz-ink-muted, #667788);
  line-height: 1.3;
}

.gw-chat-docs-modal {
  position: fixed;
  inset: 0;
  z-index: 12000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.gw-chat-docs-modal[hidden] {
  display: none !important;
}

.gw-chat-docs-modal__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,.55);
}

.gw-chat-docs-modal__card {
  position: relative;
  width: min(420px, 100%);
  max-height: min(70vh, 520px);
  display: flex;
  flex-direction: column;
  border-radius: 14px;
  border: 1px solid var(--gw-stroke);
  background: var(--gz-surface-elevated, #121820);
  box-shadow: 0 16px 48px rgba(0,0,0,.45);
}

.gw-chat-docs-modal__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--gw-stroke-soft);
}

.gw-chat-docs-modal__head h3 {
  margin: 0;
  font-size: 0.9rem;
}

.gw-chat-docs-modal__close {
  border: none;
  background: transparent;
  color: var(--gz-ink-muted);
  font-size: 1.25rem;
  cursor: pointer;
  line-height: 1;
}

.gw-chat-docs-modal__list {
  list-style: none;
  margin: 0;
  padding: 0.5rem;
  overflow-y: auto;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.gw-chat-docs__item--modal {
  padding: 0.5rem 0.55rem;
}

.genesis-workspace .gw-tools__label {
  position: sticky;
  top: 0;
  z-index: 2;
  padding-top: 0.15rem;
  padding-bottom: 0.35rem;
  margin-bottom: 0.25rem;
  background: rgba(8, 12, 20, 0.72);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}

html[data-theme="light"] .genesis-workspace .gw-tools__label {
  background: rgba(255, 255, 255, 0.82);
}

/* Быстрые подсказки — не дублируем инструменты снизу, есть колонка справа */
.genesis-workspace .ai-chat-chips {
  display: none;
}

.genesis-workspace .gw-chat-rail__list {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  overflow-y: auto;
  flex: 1;
  min-height: 0;
}

/* Список чатов — вид gw-chat-item */
.genesis-workspace .ai-chat-list__item {
  display: flex;
  align-items: flex-start;
  gap: 0.55rem;
  width: 100%;
  padding: 0.55rem 0.5rem;
  border: 1px solid transparent;
  border-radius: 10px;
  background: transparent;
  cursor: pointer;
  margin: 0;
  text-align: left;
  transition: background 0.18s, border-color 0.18s;
}

.genesis-workspace .ai-chat-list__item:hover {
  background: rgba(255, 255, 255, 0.06);
  border-color: rgba(255, 255, 255, 0.08);
}

.genesis-workspace .ai-chat-list__item--active {
  background: rgba(237, 91, 47, 0.12);
  border-color: rgba(237, 91, 47, 0.35);
}

.genesis-workspace .ai-chat-list__item-role {
  width: 1.5rem;
  height: 1.5rem;
  border-radius: 8px;
  font-size: 0.62rem;
  background: rgba(237, 91, 47, 0.18);
  color: var(--hz-accent, #ed5b2f);
}

.genesis-workspace .ai-chat-list__item--contractor .ai-chat-list__item-role {
  background: rgba(56, 152, 236, 0.18);
  color: #5eb3ff;
}

.genesis-workspace .ai-chat-list__item-body {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
}

.genesis-workspace .ai-chat-list__item-title {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--gw-ink, #e8edf4);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.genesis-workspace .ai-chat-list__item-doc {
  font-size: 0.62rem;
  color: var(--gw-ink-muted, #8b9cb0);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.genesis-workspace .ai-chat-list__item-del {
  flex-shrink: 0;
  align-self: center;
  position: relative;
  z-index: 3;
  min-width: 22px;
  min-height: 22px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
  color: var(--gw-ink-muted, #8b9cb0);
  cursor: pointer;
  font-size: 14px;
  line-height: 1;
  padding: 2px 4px;
  opacity: 0.65;
  pointer-events: auto;
  transition: opacity 0.15s, color 0.15s;
}

.genesis-workspace .ai-chat-list__item:hover .ai-chat-list__item-del,
.genesis-workspace .ai-chat-list__item--active .ai-chat-list__item-del {
  opacity: 1;
}

.genesis-workspace .ai-chat-list__item-del:hover {
  color: #e74c3c;
}

/* Сообщения — пузыри genesis */
.genesis-workspace .ai-chat-messages {
  flex: 1 1 auto;
  overflow-y: auto;
  overflow-x: hidden;
  min-height: 0;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  padding: 0.75rem 0.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}

.genesis-workspace .ai-chat-input-area,
.genesis-workspace .gw-command__head,
.genesis-workspace .gw-command__composer {
  flex-shrink: 0;
}

.genesis-workspace .gw-command__body {
  flex: 1;
  min-height: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.genesis-workspace .ai-chat-msg {
  display: flex;
  gap: 0.5rem;
  max-width: 92%;
}

.genesis-workspace .ai-chat-msg--user {
  align-self: flex-end;
  flex-direction: row-reverse;
}

.genesis-workspace .ai-chat-msg__avatar {
  display: none;
}

.genesis-workspace .ai-chat-msg__content {
  padding: 0.65rem 0.85rem;
  border-radius: 12px;
  border: 1px solid var(--gw-stroke-soft, rgba(255, 255, 255, 0.08));
  font-size: 0.84rem;
  line-height: 1.45;
}

.genesis-workspace .ai-chat-msg--ai .ai-chat-msg__content {
  background: var(--gw-msg-ai-bg);
  color: var(--gw-ink-soft, #c8d4e4);
}

.genesis-workspace .ai-chat-msg--user .ai-chat-msg__content {
  background: var(--gw-msg-user-bg);
  color: var(--gw-ink, #e8edf4);
  border-color: rgba(237, 91, 47, 0.25);
}

.genesis-workspace .ai-chat-msg__time {
  font-size: 0.58rem;
  color: var(--gw-ink-muted);
  margin-top: 0.25rem;
}

.genesis-workspace .ai-chat-typing {
  display: flex;
  gap: 0.5rem;
  padding: 0.5rem;
}

.genesis-workspace .ai-chat-typing .ai-chat-msg__avatar {
  display: none;
}

/* Composer */
.genesis-workspace .ai-chat-input-area {
  flex-shrink: 0;
}

.genesis-workspace .ai-chat-chip {
  font-size: 0.68rem;
  padding: 0.3rem 0.55rem;
  border-radius: 999px;
  border: 1px solid var(--gw-stroke-soft);
  background: rgba(255, 255, 255, 0.04);
  color: var(--gw-ink-soft);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
}

.genesis-workspace .ai-chat-chip:hover {
  border-color: var(--gw-stroke, rgba(237, 91, 47, 0.4));
  color: var(--gw-ink);
}

.genesis-workspace .ai-chat-files {
  padding: 0.25rem 0.5rem;
}

.genesis-workspace .ai-chat-tools {
  padding: 0.35rem 0.75rem;
  font-size: 0.75rem;
  color: var(--gw-ink-muted);
  flex-shrink: 0;
  min-height: 2rem;
}

.genesis-workspace .ai-chat-tools:not([hidden]) + .ai-chat-input-area {
  border-top: 1px solid var(--gw-stroke, rgba(255, 255, 255, 0.08));
}

.genesis-workspace .ai-chat-reconnect-banner {
  margin: 0.5rem 0.75rem 0;
  background: color-mix(in srgb, var(--gw-accent, #ed5b2f) 10%, var(--gw-surface, #fff));
  border-color: color-mix(in srgb, var(--gw-accent, #ed5b2f) 25%, transparent);
  color: var(--gw-ink, #1a1a1a);
}

.genesis-workspace .ai-chat-input-area {
  position: relative;
  z-index: 3;
}

.genesis-workspace .ai-chat-dropzone {
  display: none !important;
}

.genesis-workspace .gw-command {
  position: relative;
}

.genesis-workspace .ai-chat-paywall {
  position: absolute;
  inset: 0;
  z-index: 20;
  border-radius: inherit;
  background: rgba(8, 12, 20, 0.55);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}

.genesis-workspace .ai-chat-paywall[hidden] {
  display: none !important;
}

/* Панель инструмента внутри Genesis (iframe, без ухода на Haze shell) */
.gw-tool-stage {
  display: flex;
  flex-direction: column;
  min-height: calc(100vh - var(--gw-ribbon-h) - 1.5rem);
  overflow: hidden;
}

.gw-tool-stage__head {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.75rem 1rem;
  border-bottom: 1.5px solid var(--gw-stroke-soft);
}

.gw-tool-stage__title {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--gw-ink);
}

.gw-tool-frame {
  flex: 1;
  width: 100%;
  min-height: 0;
  border: 0;
  background: transparent;
}

.genesis-workspace .ai-chat-free-timer {
  font-size: 0.68rem;
  margin-left: auto;
}

html[data-theme="light"] .genesis-workspace .ai-chat-list__item--active {
  background: rgba(237, 91, 47, 0.1);
}

.gw-projects-empty {
  margin: 0 0 1rem;
  padding: 0.75rem 1rem;
  border-radius: 10px;
  border: 1px dashed var(--gw-stroke-soft, rgba(255, 255, 255, 0.12));
  color: var(--gw-ink-muted, #8b9cb0);
  font-size: 0.84rem;
  text-align: center;
}

.gw-projects-upload {
  position: relative;
  margin: 0 0 1.1rem;
  padding: 1.1rem 1.25rem;
  border: 1.5px dashed var(--gw-stroke-soft, rgba(255, 255, 255, 0.14));
  border-radius: 12px;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.18s, background 0.18s;
}

.gw-projects-upload:hover,
.gw-projects-upload:focus-visible {
  border-color: rgba(237, 91, 47, 0.45);
  background: rgba(237, 91, 47, 0.06);
  outline: none;
}

.gw-projects-upload.is-dragover {
  border-color: rgba(237, 91, 47, 0.65);
  background: rgba(237, 91, 47, 0.1);
}

.gw-projects-upload.is-busy {
  opacity: 0.65;
  pointer-events: none;
}

.gw-projects-upload__input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.gw-projects-upload__title {
  margin: 0 0 0.35rem;
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--gw-ink, #e8edf4);
}

.gw-projects-upload__hint {
  margin: 0;
  font-size: 0.78rem;
  color: var(--gw-ink-muted, #8b9cb0);
}

.gw-projects-upload__status {
  margin: 0.65rem 0 0;
  font-size: 0.78rem;
  color: var(--gw-ink-muted, #8b9cb0);
}

.gw-projects-upload__status.is-ok {
  color: #6dd4a0;
}

.gw-projects-upload__status.is-error {
  color: #f08080;
}

.genesis-workspace .gw-carousel.is-empty {
  opacity: 0.45;
  pointer-events: none;
}

.genesis-workspace .gw-tool,
.genesis-workspace .gw-nav__item--link {
  cursor: pointer;
}
