/* Chat playground — clean, ChatGPT-adjacent layout (solid colors, dark theme) */

:root {
  --chat-max: min(48rem, 100%);
  --chat-composer-radius: 26px;
  --chat-surface: #0f0f0f;
  --chat-surface-2: #1a1a1a;
  --chat-user-bg: #2a2a2a;
  --chat-border: rgba(255, 255, 255, 0.12);
  --chat-border-focus: rgba(255, 255, 255, 0.28);
  --chat-muted: rgba(255, 255, 255, 0.55);
  --chat-text: #ececec;
}

/* Header */
.top-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 52px;
  border-bottom: 1px solid var(--chat-border);
  padding: 0 12px 0 16px;
  background: #000000;
  backdrop-filter: none;
  z-index: 1000;
}

@media (min-width: 768px) {
  .top-nav {
    padding: 0 20px 0 24px;
  }
}

.top-nav__tools {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: nowrap;
  gap: 8px;
  margin-left: auto;
  min-width: 0;
}

.top-nav .menu-toggle {
  display: flex;
  flex-shrink: 0;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 10px;
  width: 42px;
  height: 42px;
  color: #ffffff;
  cursor: pointer;
  order: 2;
}

@media (min-width: 1024px) {
  .top-nav .menu-toggle {
    display: none;
  }
}

.top-nav .menu-toggle:hover {
  background: rgba(255, 255, 255, 0.08);
  color: #ffffff;
  border-color: rgba(255, 255, 255, 0.35);
}

.top-nav .menu-toggle svg,
.top-nav .menu-toggle i {
  stroke: #ffffff;
  color: #ffffff;
}

.top-nav__tools #playground-user-menu {
  order: 1;
}

.top-nav .menu-toggle:focus-visible {
  outline: 2px solid var(--chat-border-focus);
  outline-offset: 2px;
}

.chat-top-nav-left {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
  flex: 1;
}

@media (max-width: 1023px) {
  .chat-top-nav-left {
    padding-right: 4px;
  }
}

.chat-header-model {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.chat-header-model label {
  font-size: 11px;
  font-weight: 600;
  color: var(--chat-muted);
  white-space: nowrap;
  letter-spacing: 0.02em;
}

.chat-header-model select {
  background: var(--chat-surface);
  color: #ffffff;
  border: 1px solid var(--chat-border);
  border-radius: 8px;
  padding: 6px 28px 6px 10px;
  font-size: 13px;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  max-width: min(200px, 42vw);
  min-width: 0;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23ffffff' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 8px center;
}

.chat-header-model select:hover,
.chat-header-model select:focus {
  border-color: var(--chat-border-focus);
  outline: none;
}

@media (max-width: 380px) {
  .chat-header-model label {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
  }

  .chat-header-model select {
    max-width: min(200px, 58vw);
  }
}

/* Main column */
.console-container {
  padding: 0;
  background: #000000;
  align-items: stretch;
}

.console-inner {
  flex: 1 1 0;
  display: flex;
  flex-direction: column;
  min-height: 0;
  max-width: var(--chat-max);
  width: 100%;
  margin: 0 auto;
  padding: 0 16px 20px;
  box-sizing: border-box;
}

@media (min-width: 768px) {
  .console-inner {
    padding: 0 24px 28px;
  }
}

.chat-composer-dock {
  flex-shrink: 0;
  margin-top: auto;
  width: 100%;
  padding-top: 2px;
}

/* Toolbar — quiet text actions */
.chat-toolbar {
  margin: 0 0 8px;
  padding: 12px 0 10px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.chat-toolbar-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 8px;
  width: 100%;
}

.chat-toolbar-label-inline {
  font-size: 11px;
  color: var(--chat-muted);
  margin-right: 4px;
  font-weight: 500;
}

.chat-toolbar-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 2px 4px;
  flex: 1;
  min-width: 0;
}

.chat-toolbar-overflow {
  position: relative;
  flex-shrink: 0;
  margin-left: auto;
}

.chat-toolbar-overflow-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  padding: 0;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--chat-muted);
  cursor: pointer;
  transition: color 0.15s ease, background 0.15s ease;
}

.chat-toolbar-overflow-btn:hover {
  color: #ffffff;
  background: rgba(255, 255, 255, 0.08);
}

.chat-toolbar-overflow-btn:focus-visible {
  outline: 2px solid var(--chat-border-focus);
  outline-offset: 1px;
  color: #ffffff;
}

.chat-toolbar-menu {
  position: absolute;
  top: calc(100% + 4px);
  right: 0;
  min-width: 11rem;
  padding: 6px;
  background: var(--chat-surface-2);
  border: 1px solid var(--chat-border);
  border-radius: 10px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.45);
  z-index: 50;
}

.chat-toolbar-menu-item {
  display: block;
  width: 100%;
  text-align: left;
  padding: 10px 12px;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: #ffffff;
  font-size: 13px;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  transition: background 0.12s ease;
}

.chat-toolbar-menu-item:hover,
.chat-toolbar-menu-item:focus-visible {
  background: rgba(255, 255, 255, 0.08);
  outline: none;
}

@media (min-width: 640px) {
  .chat-toolbar-overflow {
    display: none;
  }
}

@media (max-width: 639px) {
  .chat-toolbar-actions {
    display: none !important;
  }

  .chat-toolbar-label-inline {
    display: none;
  }

  .chat-toolbar-row {
    justify-content: flex-end;
  }
}

.chat-toolbar-link {
  background: none;
  border: none;
  color: var(--chat-muted);
  font-size: 12px;
  font-weight: 500;
  font-family: inherit;
  padding: 6px 8px;
  border-radius: 6px;
  cursor: pointer;
  transition: color 0.15s ease, background 0.15s ease;
}

.chat-toolbar-link:hover {
  color: #ffffff;
  background: rgba(255, 255, 255, 0.06);
}

.chat-toolbar-link:focus-visible {
  outline: 2px solid var(--chat-border-focus);
  outline-offset: 1px;
  color: #ffffff;
}

.chat-toolbar.chat-toolbar--empty {
  display: none;
}

/* Scroll region */
.output-stream {
  flex: 1 1 0;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 12px 0 100px;
  font-size: 16px;
  line-height: 1.65;
  scroll-behavior: smooth;
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.22) transparent;
}

.output-stream,
.output-stream .bubble-text,
.output-stream .log-bubble,
.input-area textarea {
  user-select: text;
  -webkit-user-select: text;
}

.output-stream::-webkit-scrollbar {
  width: 8px;
}

.output-stream::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.14);
  border-radius: 8px;
}

.output-stream::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.26);
}

/* Empty state (ChatGPT-style) */
.pg-empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 48px 20px 56px;
  min-height: min(45vh, 360px);
  box-sizing: border-box;
}

.pg-empty-state-title {
  font-size: clamp(1.35rem, 3.5vw, 1.65rem);
  font-weight: 600;
  color: #ffffff;
  letter-spacing: -0.02em;
  margin: 0 0 12px;
  line-height: 1.25;
}

.pg-empty-state-hint {
  font-size: 14px;
  line-height: 1.55;
  color: var(--chat-muted);
  max-width: 26rem;
  margin: 0;
}

.pg-empty-state-hint kbd {
  font-family: "JetBrains Mono", ui-monospace, monospace;
  font-size: 11px;
  padding: 2px 6px;
  border-radius: 4px;
  border: 1px solid var(--chat-border);
  background: var(--chat-surface);
  color: #e8e8e8;
}

.pg-empty-state-chips {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  margin-top: 24px;
  max-width: 38rem;
  padding: 0 4px;
}

.pg-suggest-chip {
  padding: 9px 14px;
  border-radius: 999px;
  border: 1px solid var(--chat-border);
  background: var(--chat-surface);
  color: #f0f0f0;
  font-size: 13px;
  font-weight: 500;
  font-family: inherit;
  line-height: 1.35;
  cursor: pointer;
  text-align: left;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
  max-width: 100%;
}

.pg-suggest-chip:hover {
  background: var(--chat-surface-2);
  border-color: var(--chat-border-focus);
  color: #ffffff;
}

.pg-suggest-chip:focus-visible {
  outline: 2px solid var(--chat-border-focus);
  outline-offset: 2px;
}

/* Message rows — thread layout */
.log-row--vortex {
  display: flex;
  justify-content: flex-start;
  margin-bottom: 0;
}

.log-row--user {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 0;
}

.log-col--stacked {
  flex: 0 1 min(48rem, 100%);
  min-width: 0;
  max-width: min(48rem, 100%);
}

.log-row--vortex .log-col--stacked {
  max-width: 100%;
  width: 100%;
}

.log-row--user .log-col--stacked {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  max-width: 100%;
}

.log-row--user .log-bubble {
  text-align: left;
  max-width: min(85%, 32rem);
}

.log-row--vortex .log-bubble {
  max-width: 100%;
}

.log-head {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}

.log-head--user {
  flex-direction: row-reverse;
}

.log-head .log-header {
  margin-bottom: 0;
}

.user-bubble-attach {
  margin-bottom: 12px;
}

.user-bubble-attach img {
  max-width: min(280px, 100%);
  max-height: 200px;
  border-radius: 8px;
  border: 1px solid var(--chat-border);
  display: block;
}

.role-system {
  color: rgba(255, 255, 255, 0.35);
}

.output-stream .log-bubble > .bubble-text:not(.vortex-md) {
  font-family: "JetBrains Mono", ui-monospace, monospace;
  font-size: 14px;
  line-height: 1.65;
}

/* Message rows */
.log-entry {
  margin-bottom: 28px;
  animation: pgFadeIn 0.28s ease both;
}

@keyframes pgFadeIn {
  from {
    opacity: 0;
    transform: translateY(4px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.log-header {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0;
  text-transform: none;
  color: var(--chat-muted);
}

.log-header-label {
  letter-spacing: 0;
  text-transform: none;
}

.role-vortex .log-header-label,
.role-user .log-header-label {
  color: var(--chat-muted);
}

.chat-avatar {
  flex-shrink: 0;
  width: 28px;
  height: 28px;
  border-radius: 6px;
  overflow: hidden;
  background: #0d0d0d;
  border: 1px solid var(--chat-border);
  display: flex;
  align-items: center;
  justify-content: center;
}

.chat-avatar--assistant {
  background: #000000;
}

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

.chat-avatar--assistant .chat-avatar-img {
  object-fit: contain;
  padding: 4px;
}

.chat-avatar-fallback {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  color: rgba(255, 255, 255, 0.85);
}

/* Bubbles */
.log-bubble {
  background: transparent;
  border: none;
  padding: 4px 0 2px;
  border-radius: 0;
  color: var(--chat-text);
  max-width: 100%;
}

.log-row--user .log-bubble {
  background: var(--chat-user-bg);
  border: 1px solid var(--chat-border);
  border-radius: 18px;
  padding: 12px 16px;
  max-width: min(90%, 34rem);
}

.log-row--vortex .log-bubble {
  padding-left: 2px;
}

.log-row--user .bubble-text {
  font-size: 15px;
  line-height: 1.55;
  color: #f5f5f5;
}

/* Assistant markdown inherits .vortex-md */

.feedback-group {
  display: flex;
  gap: 12px;
}

.action-group {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

/* Bubble footer — visible but quiet */
.bubble-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  opacity: 0.75;
}

.log-entry:hover .bubble-footer,
.log-entry:focus-within .bubble-footer {
  opacity: 1;
}

.bubble-btn {
  background: transparent;
  border: none;
  color: var(--chat-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 6px;
  border-radius: 6px;
  transition: color 0.15s ease, background 0.15s ease;
}

.bubble-btn:hover {
  color: #ffffff;
  background: rgba(255, 255, 255, 0.08);
}

.bubble-btn:focus-visible {
  outline: 2px solid var(--chat-border-focus);
  outline-offset: 1px;
}

.bubble-btn.active {
  color: #ffffff;
}

/* Composer */
.pg-attachment-bar {
  margin-top: 0;
  margin-bottom: 10px;
  border-radius: 12px;
  background: var(--chat-surface);
}

.input-area {
  display: flex;
  margin-top: 0;
  background: var(--chat-surface);
  border: 1px solid var(--chat-border);
  border-radius: var(--chat-composer-radius);
  padding: 6px 8px 6px 10px;
  align-items: flex-end;
  gap: 2px;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.4);
}

.input-area:focus-within {
  border-color: var(--chat-border-focus);
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.12);
}

.input-area textarea {
  flex: 1;
  width: 100%;
  min-width: 0;
  padding: 12px 8px;
  font-family: 'Outfit', system-ui, -apple-system, sans-serif;
  font-size: 15px;
  line-height: 1.5;
  min-height: 44px;
  max-height: 200px;
  resize: none;
  background: transparent;
  border: none;
  color: #ffffff;
  outline: none;
}

.send-btn {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  flex-shrink: 0;
  margin-bottom: 4px;
  background: #ffffff;
  color: #0a0a0a;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s ease, opacity 0.15s ease;
}

.send-btn:hover {
  transform: none;
  background: #e8e8e8;
}

.send-btn:focus-visible {
  outline: 2px solid var(--chat-border-focus);
  outline-offset: 1px;
}

.send-btn svg {
  stroke: currentColor;
}

.send-btn.stop-mode {
  background: #ffffff;
  color: #000000;
  border: 2px solid #f43f5e;
}

.send-btn.stop-mode:hover {
  background: #f5f5f5;
}

.input-action-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 10px;
  margin-bottom: 4px;
  color: var(--chat-muted);
  background: transparent;
  border: none;
  cursor: pointer;
  transition: color 0.15s ease, background 0.15s ease;
}

.input-action-btn:focus-visible {
  outline: 2px solid var(--chat-border-focus);
  outline-offset: 1px;
}

.input-action-btn:hover {
  color: #ffffff;
  background: rgba(255, 255, 255, 0.08);
}

.input-action-btn.recording {
  color: #ffffff;
  animation: pgMicPulse 1.5s ease-in-out infinite;
}

@keyframes pgMicPulse {
  0%,
  100% {
    opacity: 1;
    transform: scale(1);
  }
  50% {
    opacity: 0.65;
    transform: scale(1.06);
  }
}

@keyframes pgSpin {
  to {
    transform: rotate(360deg);
  }
}

.lucide-spin {
  animation: pgSpin 0.9s linear infinite;
}

.pg-composer-hint {
  margin: 10px 8px 0;
  font-size: 11px;
  line-height: 1.45;
  color: var(--chat-muted);
  text-align: center;
}

/* Sidebar — new chat & thread picker */
.sidebar-thread-wrap {
  width: 100%;
  margin-bottom: 20px;
}

.sidebar-thread-wrap .nav-label {
  margin-bottom: 8px;
}

.playground-new-chat-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 10px 14px;
  margin-bottom: 20px;
  background: #ffffff;
  color: #0a0a0a;
  border: none;
  border-radius: 10px;
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0;
  text-transform: none;
  cursor: pointer;
  transition: background 0.15s ease, opacity 0.15s ease;
}

.playground-new-chat-btn:hover {
  background: #e8e8e8;
}

.playground-new-chat-btn:focus-visible {
  outline: 2px solid var(--chat-border-focus);
  outline-offset: 2px;
}

.playground-new-chat-btn i,
.playground-new-chat-btn svg {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  stroke: currentColor;
}

.playground-thread-select {
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
  min-width: 0;
  background: var(--chat-surface);
  color: #ffffff;
  border: 1px solid var(--chat-border);
  border-radius: 10px;
  font-size: 13px;
  font-weight: 500;
  padding: 10px 12px;
  cursor: pointer;
  font-family: inherit;
}

.playground-thread-select:hover,
.playground-thread-select:focus {
  border-color: var(--chat-border-focus);
  outline: none;
}

/* Footer strip */
.playground-footer-minimal {
  border-top-color: var(--chat-border);
  padding-top: 12px;
  padding-bottom: 14px;
  font-size: 11px;
  opacity: 0.85;
}

.chat-revenue-strip {
  background: var(--chat-surface);
  border-bottom-color: var(--chat-border);
}

.main-wrapper .chat-revenue-strip-cta {
  font-weight: 600;
  text-transform: none;
  letter-spacing: 0;
  border-radius: 8px;
  padding: 6px 14px;
}

.output-stream .vortex-md {
  font-size: 16px;
  line-height: 1.7;
  color: var(--chat-text);
}

#playground-setup {
  background: var(--chat-surface);
  border-bottom-color: var(--chat-border);
}

/* Skip link: css/app-baseline.css (loaded on chat.html) */

#chat-main:focus-visible {
  outline: 2px solid var(--chat-border-focus);
  outline-offset: 2px;
}

/* Non-blocking copy / share feedback */
.pg-chat-toast {
  position: fixed;
  bottom: calc(88px + env(safe-area-inset-bottom, 0px));
  left: 50%;
  transform: translateX(-50%);
  max-width: min(22rem, calc(100vw - 24px));
  padding: 10px 16px;
  background: var(--chat-surface-2);
  border: 1px solid var(--chat-border);
  border-radius: 10px;
  font-size: 13px;
  font-weight: 500;
  color: #ffffff;
  text-align: center;
  z-index: 70;
  pointer-events: none;
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.45);
}

@media (prefers-reduced-motion: reduce) {
  .log-entry {
    animation: none;
  }

  .output-stream {
    scroll-behavior: auto;
  }

  .input-action-btn.recording,
  .lucide-spin {
    animation: none;
  }

  .chat-toolbar-link,
  .chat-toolbar-overflow-btn,
  .chat-toolbar-menu-item,
  .input-action-btn,
  .send-btn,
  .input-area {
    transition: none;
  }
}
