:root {
  --color-primary-500: #2196f3;
  --color-primary-200: #90caf9;
  --color-primary-50: #e3f2fd;
  --color-white: #ffffff;
  --color-black: #000000;
  --color-grey-50: #f6f6f4;
  --color-grey-100: #d9e0e3;
  --color-grey-300: #90a4ae;
  --color-grey-500: #607d8b;
  --color-grey-600: #546e7a;
  --color-grey-700: #455a64;
  --background-base: #ffffff;

  --font-heading: "Poppins", -apple-system, BlinkMacSystemFont, sans-serif;
  --font-base: "Poppins", -apple-system, BlinkMacSystemFont, sans-serif;

  --radius-sm: 4px;
  --radius-lg: 12px;

  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 24px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: #f5f5f7;
  font-family: var(--font-base);
  color: var(--color-black);
  display: flex;
  align-items: center;
  justify-content: center;
}

.flow-nav {
  position: fixed;
  top: 18px;
  left: 20px;
  z-index: 10;
}

.flow-nav a {
  color: var(--color-grey-600);
  text-decoration: none;
  font-size: 0.75rem;
  opacity: 0.55;
  transition: opacity 0.15s ease;
}

.flow-nav a:hover {
  opacity: 1;
}

/* Mirrors .flow-nav's subtlety, mirrored to the opposite corner — a
   passive label naming which track/prototype you're currently in. */
.flow-context {
  position: fixed;
  top: 18px;
  right: 20px;
  z-index: 10;
  color: var(--color-grey-600);
  font-size: 0.75rem;
  opacity: 0.55;
}

/* Frame — same phone-like base as TR1 Classic */
.screen {
  max-width: 390px;
  width: 100%;
  height: calc(100vh - 80px);
  max-height: 844px;
  background: var(--background-base);
  display: flex;
  flex-direction: column;
  align-items: stretch;
  overflow: hidden;
  border-radius: 32px;
}

/* Chat header */
.chat-header {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: var(--space-4);
  height: 85px;
  padding: 24px 16px;
  background: var(--color-white);
  border-bottom: 1px solid var(--color-grey-100);
}

.chat-avatar {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  flex-shrink: 0;
  object-fit: cover;
}

.chat-contact {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}

.chat-name {
  margin: 0;
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: 18px;
  color: var(--color-black);
}

.chat-status {
  margin: 0;
  display: flex;
  align-items: center;
  gap: 6px;
  font-family: var(--font-base);
  font-weight: 400;
  font-style: italic;
  font-size: 12px;
  color: var(--color-grey-600);
}

.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #34c759;
  flex-shrink: 0;
}

/* Message thread */
.chat-messages {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
  padding: 24px 8px;
  background: var(--color-white);
}

/* Typing indicator */
.typing-indicator {
  display: flex;
  gap: 4px;
  align-items: center;
  padding: 10px 12px;
}

.typing-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--color-grey-300);
  animation: typing-bounce 1.2s infinite ease-in-out;
}

.typing-dot:nth-child(2) {
  animation-delay: 0.15s;
}

.typing-dot:nth-child(3) {
  animation-delay: 0.3s;
}

@keyframes typing-bounce {
  0%,
  60%,
  100% {
    transform: translateY(0);
    opacity: 0.5;
  }
  30% {
    transform: translateY(-4px);
    opacity: 1;
  }
}

.message-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
  width: 100%;
}

.message-group--user {
  align-items: flex-end;
}

.message-group--bot {
  align-items: flex-start;
}

/* Extra space only when the conversation switches sides — consecutive
   messages from the same side keep the tight default gap. */
.message-group--bot + .message-group--user,
.message-group--user + .message-group--bot {
  margin-top: 16px;
}

.message-bubble {
  margin: 0;
  max-width: 300px;
  padding: 8px 12px;
  font-family: var(--font-base);
  font-size: 16px;
  line-height: 24px;
  color: var(--color-black);
}

.message-bubble--bot {
  border-radius: var(--radius-sm);
}

.message-bubble--user {
  background: var(--color-primary-50);
  border-radius: var(--radius-lg);
}

.message-caption {
  max-width: 300px;
  white-space: pre-line;
  padding: 0 12px;
  font-family: var(--font-base);
  font-size: 12px;
  line-height: 16px;
  color: var(--color-grey-500);
}

/* Info card bubble */
.message-card-row {
  display: flex;
  gap: var(--space-3);
  width: 100%;
  overflow-x: auto;
  padding-bottom: 2px;
}

.message-card {
  flex-shrink: 0;
  width: 280px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  background: var(--color-white);
  border: 1px solid var(--color-grey-100);
  border-radius: var(--radius-lg);
}

.message-card-title {
  margin: 0;
  font-family: var(--font-heading);
  font-weight: 600;
  font-size: 20px;
  line-height: 28px;
}

.message-card-body {
  margin: 0;
  font-family: var(--font-base);
  font-size: 16px;
  line-height: 24px;
}

.message-card a {
  font-family: var(--font-base);
  font-size: 16px;
  line-height: 24px;
  color: var(--color-black);
  text-decoration: underline;
}

.text-link {
  color: var(--color-primary-500);
  text-decoration: underline;
  font-weight: 500;
}

.text-link:hover {
  color: #1c86e0;
}

/* Inline rating picker */
.rating-picker {
  display: flex;
  gap: var(--space-1);
  width: 100%;
}

.rating-option {
  flex: 1 0 0;
  height: 80px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  background: var(--color-white);
  border: 1px solid var(--color-grey-100);
  border-radius: 8px;
  font-family: var(--font-base);
  cursor: pointer;
}

.rating-option:hover {
  border-color: var(--color-primary-500);
}

.rating-option .emoji {
  font-size: 16px;
  line-height: 24px;
}

.rating-option .value {
  font-weight: 600;
  font-size: 14px;
  line-height: 14px;
}

/* Inline category picker */
.category-picker {
  display: grid;
  /* minmax(0, 1fr): a long word must wrap, not stretch its column past the frame */
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--space-3);
  width: 100%;
}

.category-card {
  min-width: 0;
  min-height: 116px;
  padding: 16px 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  background: var(--color-white);
  border: 1px solid var(--color-grey-100);
  border-radius: var(--radius-sm);
  cursor: pointer;
}

.category-card:hover {
  border-color: var(--color-primary-500);
}

.category-card img {
  width: 20px;
  height: 20px;
}

.category-card span {
  max-width: 100%;
  font-family: var(--font-base);
  font-weight: 600;
  font-size: 14px;
  line-height: 18px;
  color: var(--color-black);
  text-align: center;
  overflow-wrap: break-word;
  hyphens: auto;
}

/* Suggestion bar — quick-reply chips pinned directly above the input
   bar, outside the scrolling message thread, so they read as a prefill
   shortcut for the field below rather than a chat message. Collapses to
   zero height when empty so it never reserves space between turns. */
.suggestion-bar {
  flex-shrink: 0;
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  padding: var(--space-2) 16px 0;
}

.suggestion-bar:empty {
  padding: 0;
}

.suggestion-chip {
  padding: 10px 16px;
  background: var(--color-white);
  border: 1px solid var(--color-primary-200);
  border-radius: 20px;
  font-family: var(--font-base);
  font-size: 14px;
  line-height: 20px;
  color: var(--color-primary-500);
  cursor: pointer;
}

.suggestion-chip:hover {
  background: var(--color-primary-50);
}

/* Bottom input bar */
.chat-input-bar {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  background: var(--color-white);
}

.chat-input {
  flex: 1 0 0;
  height: 48px;
  line-height: 46px;
  padding: 0 16px;
  background: var(--color-white);
  border: 1px solid var(--color-grey-100);
  border-radius: var(--radius-lg);
  font-family: var(--font-base);
  font-size: 16px;
  color: var(--color-grey-600);
  white-space: nowrap;
  overflow-x: auto;
  overflow-y: hidden;
  cursor: text;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.chat-input:focus {
  outline: none;
  border-color: var(--color-primary-500);
  box-shadow: 0 0 0 4px rgba(33, 150, 243, 0.15);
}

.chat-input-bar[data-disabled="true"] .chat-input {
  background: var(--color-grey-50);
  cursor: default;
  pointer-events: none;
}

.chat-send {
  flex-shrink: 0;
  width: 48px;
  height: 48px;
  border-radius: 24px;
  background: var(--color-primary-500);
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.chat-send:hover {
  background: #1c86e0;
}

.chat-send:disabled {
  background: var(--color-grey-300);
  cursor: default;
}

.chat-send img {
  width: 24px;
  height: 24px;
}

/* ---- Image visualisation flow ------------------------------------------ */
.screen {
  position: relative;
}

.chat-input-bar[hidden],
.style-panel[hidden] {
  display: none;
}

/* Chips that take the place of the input bar */
.suggestion-bar--standalone {
  padding: 12px 16px;
  border-top: 1px solid var(--color-grey-100);
  background: var(--color-white);
}

.image-card {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 16px;
  background: var(--color-white);
  border: 1px solid var(--color-grey-100);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.image-card p {
  margin: 0;
}

.image-card-label {
  font-family: var(--font-base);
  font-size: 12px;
  line-height: 16px;
  color: var(--color-grey-600);
}

/* Loading */
.image-loader {
  gap: 12px;
  align-items: flex-start;
}

.image-loader p {
  font-family: var(--font-base);
  font-size: 16px;
  line-height: 24px;
  color: var(--color-black);
}

.spinner {
  width: 28px;
  height: 28px;
  border: 3px solid var(--color-grey-100);
  border-top-color: var(--color-grey-600);
  border-radius: 50%;
  animation: spin 0.9s linear infinite;
}

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

/* Style choice panel (replaces the input bar) */
.style-panel {
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 12px 16px;
  background: var(--color-white);
  border-top: 1px solid var(--color-grey-100);
}

.style-panel-title {
  margin: 0;
  font-family: var(--font-base);
  font-size: 16px;
  line-height: 24px;
  color: var(--color-black);
}

.style-options {
  display: flex;
  gap: 12px;
  overflow-x: auto;
  padding-bottom: 2px;
}

.style-option {
  position: relative;
  flex: 0 0 150px;
  width: 150px;
  height: 150px;
  display: flex;
  align-items: flex-end;
  justify-content: flex-end;
  padding: 8px;
  background-color: var(--color-grey-50);
  background-size: cover;
  background-position: center;
  border: 1px solid var(--color-grey-100);
  border-radius: var(--radius-lg);
  cursor: pointer;
  overflow: hidden;
}

.style-option:hover {
  border-color: var(--color-primary-500);
}

/* Once one is chosen the others fade back */
.style-options.has-choice .style-option:not(.is-selected)::after {
  content: "";
  position: absolute;
  inset: 0;
  background: rgba(255, 255, 255, 0.5);
}

.style-option.is-selected {
  border: 2px solid #1e88e5;
}

.style-check {
  position: relative;
  z-index: 1;
  width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--color-white);
  border: 1px solid var(--color-grey-100);
  border-radius: 10px;
}

/* Inline review of the generated image */
.image-review-img {
  width: 100%;
  height: 200px;
  object-fit: cover;
  border-radius: var(--radius-lg);
}

.image-review-text {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.image-review-caption {
  font-family: var(--font-base);
  font-size: 14px;
  line-height: 20px;
  color: var(--color-grey-600);
}

.image-review-body {
  font-family: var(--font-base);
  font-size: 16px;
  line-height: 24px;
  color: var(--color-black);
}

/* Ideas shared by others */
.shared-ideas-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-family: var(--font-base);
  font-size: 12px;
  line-height: 16px;
  color: var(--color-grey-600);
}

.shared-ideas-count {
  color: var(--color-grey-500);
}

.shared-ideas-viewport {
  display: flex;
  gap: 12px;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
}

.idea-card {
  flex: 0 0 280px;
  /* min-height (not height) so longer translations (fi/pt) are never clipped;
     all cards in a row stretch to the tallest one. */
  min-height: 360px;
  display: flex;
  flex-direction: column;
  background: var(--color-white);
  border: 1px solid var(--color-grey-100);
  border-radius: var(--radius-lg);
  overflow: hidden;
  scroll-snap-align: start;
}

.idea-card-img {
  width: 100%;
  height: 180px;
  flex-shrink: 0;
  object-fit: cover;
}

.idea-card-content {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 16px;
}

.idea-card-content p {
  margin: 0;
}

.idea-card-label {
  font-family: var(--font-base);
  font-size: 14px;
  line-height: 20px;
  color: var(--color-grey-600);
}

.idea-card-text {
  font-family: var(--font-base);
  font-size: 16px;
  line-height: 24px;
  color: var(--color-black);
}
