/* Ellen ChatGPT-style shell — IAOS Komuta / panel */
.ellen-panel-chat-mount .ellen-chat-shell {
  display: grid;
  grid-template-columns: 260px 1fr;
  height: 100dvh;
  min-height: 100dvh;
  max-height: 100dvh;
  overflow: hidden;
  border: 1px solid var(--border, #334155);
  border-radius: 10px;
  background: var(--panel, #0f1419);
}

.ellen-chat-sidebar {
  border-right: 1px solid var(--border, #334155);
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: visible;
}

.ellen-sidebar-header {
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex-shrink: 0;
}

.ellen-new-chat-btn {
  width: 100%;
  padding: 8px 12px;
  border-radius: 8px;
  border: 1px solid var(--border, #334155);
  background: var(--accent, #2563eb);
  color: #fff;
  cursor: pointer;
}
.ellen-new-chat-btn.sm { width: auto; padding: 6px 10px; }

.ellen-search-box {
  width: 100%;
  padding: 8px;
  border-radius: 8px;
  border: 1px solid var(--border, #334155);
  background: transparent;
  color: inherit;
}

.ellen-conversation-groups {
  flex: 1;
  overflow-y: auto;
  overflow-x: visible;
  padding: 0 8px 12px;
}

.ellen-conversation-group { margin-bottom: 12px; }

.ellen-conversation-item {
  position: relative;
  display: flex;
  align-items: center;
  gap: 2px;
  border-radius: 8px;
  margin-bottom: 2px;
  list-style: none;
}
.ellen-conversation-item:hover { background: rgba(255,255,255,0.05); }
.ellen-conversation-active { background: rgba(37, 99, 235, 0.18); }

.ellen-conversation-item button {
  -webkit-appearance: none;
  appearance: none;
  font: inherit;
}

.ellen-conversation-main {
  flex: 1;
  min-width: 0;
  text-align: left;
  border: none;
  background: transparent;
  color: inherit;
  padding: 10px 8px;
  cursor: pointer;
  box-shadow: none;
}
.ellen-conversation-title {
  display: block;
  font-size: 0.9rem;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.ellen-conversation-preview {
  display: block;
  font-size: 0.75rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ellen-conversation-kebab,
.ellen-kebab-menu.ellen-conversation-kebab {
  flex-shrink: 0;
  width: 36px;
  min-width: 36px;
  height: 36px;
  min-height: 36px;
  margin: 4px 6px 4px auto;
  padding: 0;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: inherit;
  cursor: pointer;
  font-size: 1.25rem;
  line-height: 1;
  opacity: 0.75;
  transition: opacity 0.15s ease, background 0.15s ease;
}
.ellen-conversation-kebab:hover,
.ellen-conversation-kebab:focus-visible {
  opacity: 1;
  background: rgba(255,255,255,0.06);
}
.ellen-conversation-item:hover .ellen-conversation-kebab,
.ellen-conversation-active .ellen-conversation-kebab {
  opacity: 1;
}

.ellen-chat-main {
  display: flex;
  flex-direction: column;
  min-height: 0;
  min-width: 0;
  overflow: hidden;
}

.ellen-chat-topbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-bottom: 1px solid var(--border, #334155);
  flex-shrink: 0;
}

.ellen-chat-title { font-weight: 700; flex: 1; min-width: 120px; }
.ellen-chat-status { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; font-size: 0.8rem; }

.ellen-message-list {
  flex: 1;
  overflow-y: auto;
  padding: 12px;
  padding-bottom: calc(var(--composer-height, 88px) + env(safe-area-inset-bottom, 0px));
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.ellen-empty-state {
  padding: 24px;
  text-align: center;
}
.ellen-empty-state[hidden] { display: none !important; }

.ellen-quick-starts {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
  margin-top: 12px;
}

.ellen-message-row { max-width: 92%; display: flex; }
.ellen-message-row.user { align-self: flex-end; justify-content: flex-end; }
.ellen-message-row.assistant { align-self: flex-start; }
.ellen-message-row.system { align-self: center; max-width: 96%; }

.ellen-message-bubble {
  padding: 10px 12px;
  border-radius: 12px;
  line-height: 1.45;
  white-space: pre-wrap;
  word-break: break-word;
}
.ellen-message-user { background: var(--accent, #2563eb); color: #fff; }
.ellen-message-assistant {
  background: var(--card-bg, #1e293b);
  border: 1px solid var(--border, #334155);
}
.ellen-message-system {
  background: rgba(234, 179, 8, 0.12);
  border: 1px solid rgba(234, 179, 8, 0.35);
  font-size: 0.9rem;
}

.ellen-message-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 6px;
}

.ellen-composer-wrap {
  position: sticky;
  bottom: 0;
  padding: 8px 12px calc(8px + env(safe-area-inset-bottom, 0px));
  border-top: 1px solid var(--border, #334155);
  background: var(--panel, #0f1419);
  flex-shrink: 0;
}

.ellen-composer {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  border: 1px solid var(--border, #334155);
  border-radius: 12px;
  padding: 8px;
}

.ellen-composer-input {
  flex: 1;
  min-height: 44px;
  max-height: 180px;
  resize: none;
  border: none;
  background: transparent;
  color: inherit;
  font: inherit;
  line-height: 1.4;
}

.ellen-composer-plus,
.ellen-composer-voice,
.ellen-composer-speak,
.ellen-composer-send,
.ellen-composer-stop {
  flex-shrink: 0;
  min-width: 44px;
  min-height: 44px;
  border-radius: 8px;
  border: 1px solid var(--border, #334155);
  background: var(--card-bg, #1e293b);
  color: inherit;
  cursor: pointer;
}
.ellen-composer-send:disabled { opacity: 0.45; cursor: not-allowed; }
.ellen-composer-stop { background: #b45309; color: #fff; }
.ellen-composer-send[hidden],
.ellen-composer-stop[hidden] { display: none !important; }

.ellen-kebab-menu {
  position: fixed;
  min-width: 220px;
  z-index: 9999;
  background: var(--panel, #161b22);
  border: 1px solid var(--border, #334155);
  border-radius: 10px;
  padding: 6px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.35);
}
.ellen-kebab-menu[hidden] { display: none !important; }

.ellen-kebab-menu-item {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 38px;
  width: 100%;
  padding: 8px 12px;
  border: none;
  background: transparent;
  color: inherit;
  text-align: left;
  border-radius: 6px;
  cursor: pointer;
}
.ellen-kebab-menu-item:hover { background: rgba(255,255,255,0.06); }
.ellen-kebab-menu-item.danger { color: #f87171; }

.ellen-bottom-sheet-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.45);
  z-index: 9998;
}
.ellen-bottom-sheet-backdrop[hidden] { display: none !important; }

.ellen-bottom-sheet {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 9999;
  background: var(--panel, #161b22);
  border-top: 1px solid var(--border, #334155);
  padding: 12px 16px calc(16px + env(safe-area-inset-bottom, 0px));
  border-radius: 16px 16px 0 0;
  max-height: 70vh;
  overflow-y: auto;
}
.ellen-bottom-sheet[hidden] { display: none !important; }
.ellen-bottom-sheet-handle {
  width: 40px;
  height: 4px;
  background: rgba(255,255,255,0.25);
  border-radius: 2px;
  margin: 0 auto 12px;
}
.ellen-bottom-sheet h3 { margin: 0 0 12px; font-size: 1rem; }
.ellen-bottom-sheet .ellen-kebab-menu-item {
  min-height: 44px;
  margin-bottom: 4px;
  background: rgba(255,255,255,0.04);
}

.ellen-share-dialog,
.ellen-rename-dialog,
.ellen-delete-dialog,
.ellen-export-dialog {
  border: 1px solid var(--border, #334155);
  border-radius: 10px;
  padding: 16px;
  background: var(--panel, #161b22);
  color: inherit;
  max-width: 420px;
}
.btn.danger, .ellen-delete-dialog .danger { color: #fecaca; }

@media (max-width: 768px) {
  .ellen-panel-chat-mount .ellen-chat-shell {
    grid-template-columns: 1fr;
    height: 100dvh;
    min-height: 100dvh;
    max-height: 100dvh;
  }
  .ellen-chat-sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: min(86vw, 340px);
    z-index: 9000;
    transform: translateX(-100%);
    transition: transform 0.2s ease;
    background: var(--panel, #0f1419);
  }
  .ellen-chat-sidebar.open { transform: translateX(0); }
  .ellen-composer { border-radius: 22px; }
  .ellen-conversation-kebab { opacity: 1; }
}

@supports (height: 100dvh) {
  .ellen-panel-chat-mount .ellen-chat-shell { min-height: 100dvh; }
}
