/* Chat-only layout. The page themes own the backgrounds and color palette. */
.echo-theme-container {
  --chat-space: clamp(12px, 1.5vw, 24px);
}

.echo-theme-container .theme-band-top,
.echo-theme-container .theme-band-bottom {
  border-width: 1px;
}

.echo-theme-container .theme-band-top :is(.info-header, .header-retro) {
  grid-template-columns: minmax(0, 1fr) auto auto;
  column-gap: 16px;
  row-gap: 2px;
  padding: 6px var(--chat-space) 7px;
  text-align: start;
}

.echo-theme-container :is(.info-header-left, .header-retro-left) {
  font-size: .7rem !important;
  line-height: 1.4;
  flex-wrap: wrap;
}

.echo-theme-container .chat-title-row {
  justify-content: flex-start;
}

.echo-theme-container .chat-title-row :is(.info-title, .title-compact-retro) {
  font-size: 16px !important;
  line-height: 1.2;
  margin: 0;
  letter-spacing: -.025em;
}

.echo-theme-container .theme-band-bottom {
  padding: 0 var(--chat-space) 4px;
}

.echo-theme-container [data-bind="descriptionContainer"] {
  padding: 8px 12px !important;
  margin-bottom: 4px;
}

.echo-theme-container [data-bind="descriptionContainer"] .page-description-body {
  font-size: .9rem;
  line-height: 1.6;
}

/* Scheme 2 is a cream card with dark type. Do not inherit the felt's light text. */
.echo-theme-container.theme-container2 [data-bind="descriptionContainer"] {
  background: linear-gradient(150deg, #FFFEFC 0%, #F8F0E0 100%);
  border: 1px solid #5a3e28;
  color: #3b2a14;
}
.echo-theme-container.theme-container2 [data-bind="descriptionContainer"] :is(
  .page-description-body, .page-description-toggle, pre, span
) {
  color: #3b2a14;
}

.echo-theme-container .echo-picture-chat-row {
  gap: 16px;
}

.echo-theme-container .echo-left-col,
.echo-theme-container .echo-chat-col.chat-preview-panel {
  border-radius: 18px;
  box-shadow: none;
}

.echo-theme-container .echo-chat-col.chat-preview-panel {
  padding: 6px 8px 2px !important;
}

.echo-theme-container .echo-left-scrolls {
  padding: 10px;
}

.echo-theme-container .echo-left-scrolls-head {
  gap: 6px;
  margin-bottom: 8px;
}

/* Parked on the theme band. Desktop and phone each place that copy. */
.echo-theme-container #chatContainer .echo-chat-heading {
  position: absolute;
  inset: -12px 8px auto;
  z-index: 6;
  margin: 0;
  padding: 0;
  gap: 8px;
  flex-wrap: nowrap;
  justify-content: flex-start;
  pointer-events: none;
}
.echo-theme-container .echo-chat-heading > * { pointer-events: auto; }
.echo-theme-container .echo-chat-heading .echo-voice-picker-wrap:has(.chat-voice-picker-select option) {
  margin-inline-start: 0;
  padding: 4px 8px;
  border: 1px solid color-mix(in srgb, var(--echo-accent) 30%, transparent);
  border-radius: 10px;
  background: color-mix(in srgb, var(--echo-accent) 12%, #fff);
}

.echo-theme-container .echo-chat-toggler {
  padding: 2px;
  border-radius: 10px;
  height: auto;
  gap: 2px;
}

.echo-theme-container .echo-chat-toggler :is(#echoTogglePublic, #echoTogglePrivate) {
  height: 26px;
  line-height: 1.2;
  padding: 0 12px !important;
  font-size: .75rem;
  border-radius: 8px;
}

.echo-theme-container #chatContainer {
  position: relative;
  overflow: visible;
  padding-bottom: 0;
}
.echo-theme-container #chatContainer .echo-chat-body-wrap {
  margin-top: 12px;
  overflow: visible;
}

.echo-theme-container .echo-chat-body-wrap .chat-body {
  position: static;
  padding: 24px 10px 2px !important;
  border-radius: 14px;
  scrollbar-width: thin;
  scroll-padding-block: 24px 2px;
}

.echo-theme-container .chat-message {
  width: fit-content;
  max-width: min(88%, 68ch);
  margin-bottom: 5px;
  padding: 7px 12px;
  font-size: .98rem;
  line-height: 1.45;
  border-radius: 18px;
  box-shadow: none;
  overflow-wrap: anywhere;
}

.echo-theme-container .chat-message.assistant { border-end-start-radius: 5px; }
.echo-theme-container .chat-message.user { border-end-end-radius: 5px; }
.echo-theme-container .chat-message--speech { padding-inline-end: 38px; }
.echo-theme-container .chat-message:last-child { margin-bottom: 0; }
.echo-theme-container .chat-message-speech-btn {
  top: 3px;
  right: 4px;
  width: 28px;
  height: 28px;
  border-radius: 8px;
}
.echo-theme-container .chat-message-speech-btn svg { width: 22px; height: 22px; margin: auto; }

/* A compact composer sits just over the transcript's bottom edge. */
.echo-theme-container #chatContainer .chat-input-container {
  flex: 0 0 auto;
  z-index: 3;
  margin-top: -2px;
  margin-bottom: 0;
  padding: 1px 2px;
  border: 1px solid color-mix(in srgb, var(--echo-accent) 24%, transparent);
  border-radius: 12px;
  background: #fff;
  transition: border-color .15s, box-shadow .15s;
}
.echo-theme-container #chatContainer .chat-input-container:focus-within {
  border-color: var(--echo-accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--echo-accent) 12%, transparent);
}
.echo-theme-container .chat-input-row {
  flex-wrap: nowrap;
  align-items: flex-end;
  gap: 4px;
}
.echo-theme-container .chat-input-row > .flex {
  flex: 1 1 auto;
  gap: 4px;
  align-items: flex-end;
}
.echo-theme-container #chatInput {
  min-height: 36px;
  padding: 6px !important;
  font-size: 16px !important;
  line-height: 1.5;
  resize: none;
  border: 0;
  background: transparent;
  color: #1f2937;
  box-shadow: none;
}
.echo-theme-container .chat-controls { margin-inline-start: auto; gap: 4px; align-items: flex-end; }
.echo-theme-container #chatContainer .chat-input-row button {
  min-width: 36px;
  min-height: 36px;
  height: 36px;
  border-radius: 9px;
  font-size: .8rem;
}
.echo-theme-container #chatContainer :is(#voiceInputBtn, #nickToggleBtn, #imageUploadBtn, #chatLoadMore) {
  background: color-mix(in srgb, var(--echo-accent) 8%, transparent) !important;
  color: var(--echo-accent) !important;
  border: 0;
}
.echo-theme-container #chatContainer #chatRestart {
  background: transparent;
  color: #dc2626;
}
.echo-theme-container #chatContainer #chatLoadMore {
  max-width: none;
  padding: 0 10px;
  font-size: .75rem;
  white-space: normal;
  order: -1;
}
.echo-theme-container #chatContainer :is(#chatSend, #chatStop) { padding-inline: 12px; }
.echo-restart-col {
  position: relative;
  flex: 0 0 auto;
  display: flex;
  align-items: flex-end;
}
.echo-theme-container #echoCurrentModel {
  position: absolute;
  right: 0;
  top: 100%;
  z-index: 4;
  max-width: 11rem;
  margin-top: -7px;
  padding: 0 5px;
  border: 1px solid color-mix(in srgb, var(--echo-accent) 24%, transparent);
  border-radius: 999px;
  background: #fff;
  color: #5a6278;
  opacity: 1;
  font-size: 9px;
  line-height: 1.1;
  text-align: right;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  pointer-events: none;
}
.echo-theme-container #echoCurrentModel:empty { display: none; }

.echo-theme-container .echo-chat-login-panel { max-width: 28rem; gap: 20px; padding: 20px; }
.echo-theme-container .echo-chat-login-heading { font-size: clamp(24px, 2.4vw, 34px); letter-spacing: -.025em; }
.echo-theme-container .echo-chat-login-blurb { font-size: 1rem; line-height: 1.7; }
.echo-theme-container .echo-chat-login-btn { min-height: 48px; border-radius: 12px; padding: 12px 24px; }

/* Existing tag links become explicit discovery chips, without another panel. */
.echo-theme-container .echo-badges-tags-row { margin: 0; gap: 8px; }
.echo-theme-container .info-tags-row [data-bind="tagsContainer"] {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  padding: 4px 0;
  background: transparent;
  border: 0;
  box-shadow: none;
  font-size: .78rem;
  line-height: 1.4;
  color: inherit;
}
.echo-theme-container .info-tags-row { color: inherit; }
.echo-theme-container.theme-container2 .info-tags-row { color: #f4efe3; }
.echo-theme-container .info-tags-row [data-bind="tagsContainer"].hidden { display: none; }
.echo-theme-container [data-bind="tagsContainer"] strong { font-weight: 600; margin-inline-end: 4px; }
.echo-theme-container .info-tags-row [data-bind="tagsContainer"] a.badge {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 32px;
  padding: 6px 12px;
  border: 1px solid color-mix(in srgb, currentColor 25%, transparent);
  border-radius: 999px;
  background: transparent;
  color: inherit;
  text-decoration: none;
  font-size: .75rem;
  font-weight: 600;
}
.echo-theme-container [data-bind="tagsContainer"] a::after { content: '↗'; opacity: .7; }
.echo-theme-container .info-tags-row [data-bind="tagsContainer"] a:hover {
  background: color-mix(in srgb, var(--echo-accent) 14%, transparent);
  border-color: currentColor;
}
.echo-theme-container :is(button, a):focus-visible { outline: 2px solid var(--echo-accent); outline-offset: 3px; }

@media (min-width: 769px) {
  .echo-theme-container .theme-band-bottom { padding-top: 26px; }
  /* Direct child of the band, 24px above the old overlap, aligned to the chat column. */
  .echo-theme-container .theme-band-bottom > .echo-chat-heading {
    position: absolute;
    z-index: 7;
    top: 4px;
    left: calc(var(--chat-space) + (100% - 2 * var(--chat-space)) * 0.2 + 32px);
    right: calc(var(--chat-space) + 16px);
    margin: 0;
    padding: 0;
    gap: 8px;
    width: auto;
    flex-wrap: nowrap;
    justify-content: flex-start;
    pointer-events: none;
  }
  .echo-theme-container #chatContainer .echo-chat-body-wrap { margin-top: 0; }
  .echo-theme-container .echo-chat-body-wrap .chat-body {
    padding-top: 8px !important;
    scroll-padding-block-start: 8px;
  }
  .echo-theme-container .echo-left-col-stack [data-bind="descriptionContainer"] {
    flex: 0 1 auto;
    margin: 0;
    padding: 8px 12px !important;
    max-height: min(35vh, 260px);
    overflow-y: auto;
  }
  .echo-theme-container .echo-left-col-stack .page-description-toggle--header { gap: 8px; }
}

@media (max-width: 768px) {
  .echo-theme-container .theme-band-top :is(.info-header, .header-retro) { padding: 4px 8px; column-gap: 8px; }
  .echo-theme-container .chat-title-row :is(.info-title, .title-compact-retro) { font-size: 18px !important; }
  .echo-theme-container .chat-title-row :is(.echo-title-long, .echo-title-very-long) { font-size: 15px !important; }
  .echo-theme-container .theme-band-bottom { padding: 30px 0 4px; }
  .echo-theme-container .theme-band-bottom > .echo-chat-heading {
    position: absolute;
    z-index: 7;
    top: 6px;
    left: 8px;
    right: 8px;
    margin: 0;
    padding: 0;
    gap: 8px;
    width: auto;
    flex-wrap: nowrap;
    justify-content: flex-start;
    pointer-events: none;
  }
  .echo-theme-container .echo-picture-chat-row { gap: 0; }
  .echo-theme-container .echo-chat-toggler :is(#echoTogglePublic, #echoTogglePrivate) { padding: 0 9px !important; font-size: .72rem; }
  .echo-theme-container .echo-chat-col.chat-preview-panel { padding: 4px 4px 1px !important; }
  .echo-theme-container #chatContainer .echo-chat-body-wrap { margin-top: 0; }
  .echo-theme-container .echo-chat-body-wrap .chat-body {
    margin-top: 0;
    padding: 8px 6px 12px !important;
  }
  .echo-theme-container .chat-message { max-width: 94%; padding: 6px 10px; margin-bottom: 5px; }
  .echo-theme-container .chat-message--speech { padding-inline-end: 36px; }
  .echo-theme-container #chatContainer .chat-input-container { margin-top: -2px; padding: 1px; border-radius: 12px; }
  .echo-theme-container #chatInput {
    outline: 4px solid var(--echo-accent);
    outline-offset: 1px;
  }
  .echo-theme-container .chat-input-row > .flex { gap: 4px; }
  .echo-theme-container #chatContainer .chat-input-row button { width: 36px; padding: 0 !important; }
  .echo-theme-container .echo-chat-login-panel { padding: 12px; gap: 16px; }
  .echo-theme-container .echo-badges-tags-row { margin: 8px; }
  .echo-theme-container .info-tags-row [data-bind="tagsContainer"] { justify-content: flex-start; gap: 6px; }
  .echo-theme-container [data-bind="tagsContainer"] strong { flex: 0 0 100%; }
  .echo-theme-container .info-tags-row [data-bind="tagsContainer"] a.badge { min-height: 32px; padding: 5px 10px; }
}

@media (prefers-reduced-motion: reduce) {
  .echo-theme-container #chatContainer .chat-input-container { transition: none; }
}
