/* ========================================
   SOCIETY ARTS - STORY BUILDER
   Layout: Centered (50/50 Split)
   Version: 9.10
   
   REQUIRES: /css/shared/tooltips.css
   
   Brand Colors:
   - Brown: #3E2318
   - Beige: #EAE4DA
   - Orange: #C73314
   - Cream: #FAF8F5
   
   Changes in 9.10:
   - Added .suggestion-btn.suggestion-primary for Create button
   
   Changes in 9.7:
   - Moved tooltip CSS to shared file
   - Include /css/shared/tooltips.css in HTML
   ======================================== */

/* ============================================
   BASE LAYOUT - Wrapper with Breadcrumbs
   ============================================ */

.layout-centered-wrapper {
  min-height: calc(100vh - 70px);
  background: #EAE4DA;
  padding: 24px 32px 32px 8px;
}

/* Breadcrumb */
.layout-breadcrumb {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  color: #8B7355;
  margin-bottom: 16px;
  font-family: 'Familjen Grotesk', -apple-system, sans-serif;
}

.layout-breadcrumb a {
  color: #8B7355;
  text-decoration: none;
  transition: color 0.2s;
}

.layout-breadcrumb a:hover {
  color: #C73314;
}

.layout-breadcrumb svg {
  width: 14px;
  height: 14px;
  color: #B8A99A;
}

.layout-breadcrumb span:last-child {
  color: #3E2318;
}

/* Grid Layout */
.layout-centered {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 32px;
  align-items: start;
}

.layout-centered * {
  box-sizing: border-box;
}

/* ============================================
   LEFT PANEL - AI Conversation
   ============================================ */

.panel-left {
  background: #3E2318;
  display: flex;
  flex-direction: column;
  height: calc(100vh - 70px - 72px);
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 
    0 2px 4px rgba(62, 35, 24, 0.04),
    0 4px 8px rgba(62, 35, 24, 0.04),
    0 8px 16px rgba(62, 35, 24, 0.03),
    0 16px 32px rgba(62, 35, 24, 0.03);
}

.panel-left-header {
  padding: 28px 32px 24px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  flex-shrink: 0;
}

.ai-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  color: #FAF8F5;
}

.ai-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.08);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
}

.ai-name-text {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.ai-name {
  font-family: 'Libre Baskerville', Georgia, serif;
  font-size: 26px;
}

.ai-subtitle {
  font-family: 'Familjen Grotesk', -apple-system, sans-serif;
  font-size: 14px;
  color: rgba(250, 248, 245, 0.6);
}

/* Messages */
.panel-left-messages {
  flex: 1;
  overflow-y: auto;
  padding: 28px 32px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.panel-left-messages::-webkit-scrollbar {
  width: 6px;
}

.panel-left-messages::-webkit-scrollbar-track {
  background: transparent;
}

.panel-left-messages::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.12);
  border-radius: 3px;
}

/* Chat Messages */
.chat-message {
  display: flex;
  gap: 12px;
  animation: messageIn 0.3s ease;
}

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

.chat-message.user {
  flex-direction: row-reverse;
}

.chat-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.08);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #FAF8F5;
  font-size: 14px;
  flex-shrink: 0;
}

.chat-bubble {
  max-width: 85%;
}

.chat-message.user .chat-bubble {
  background: rgba(255, 255, 255, 0.12);
  border-radius: 20px 20px 4px 20px;
  padding: 14px 18px;
}

.chat-message.assistant .chat-bubble {
  background: transparent;
}

.chat-text {
  font-size: 15px;
  line-height: 1.6;
  color: #FAF8F5;
  white-space: pre-line;
}

.chat-message.user .chat-text {
  opacity: 0.9;
}

/* Suggestions */
.chat-suggestions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 16px;
}

.suggestion-btn {
  padding: 10px 18px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 24px;
  color: #FAF8F5;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  font-family: 'Familjen Grotesk', -apple-system, sans-serif;
}

.suggestion-btn:hover {
  background: rgba(255, 255, 255, 0.12);
  border-color: rgba(255, 255, 255, 0.2);
  transform: translateY(-1px);
}

/* Primary action button (Create) - Orange */
.suggestion-btn.suggestion-primary {
  background: #C73314;
  border-color: #C73314;
  color: #FAF8F5;
}

.suggestion-btn.suggestion-primary:hover {
  background: #3E2318;
  border-color: #3E2318;
}

/* Typing Indicator */
.typing-indicator {
  display: flex;
  gap: 5px;
  padding: 8px 0;
}

.typing-indicator span {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.4);
  animation: typing 1.4s ease-in-out infinite;
}

.typing-indicator span:nth-child(2) { animation-delay: 0.2s; }
.typing-indicator span:nth-child(3) { animation-delay: 0.4s; }

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

/* ============================================
   INPUT AREA - Two Row Layout
   HIGH SPECIFICITY to override external styles
   ============================================ */

.panel-left .panel-left-input {
  padding: 20px 24px 24px !important;
  border-top: 1px solid rgba(255, 255, 255, 0.08) !important;
  flex-shrink: 0 !important;
  background: transparent !important;
}

/* Main input wrapper - ChatGPT two-row style */
.panel-left .panel-left-input .chat-input-wrapper,
.panel-left-input .chat-input-wrapper,
.panel-left-input > div.chat-input-wrapper,
div.chat-input-wrapper {
  display: flex !important;
  flex-direction: column !important;
  gap: 8px !important;
  background: #5C3D2E !important;
  border: 1px solid rgba(255, 255, 255, 0.18) !important;
  border-radius: 20px !important;
  padding: 12px 16px !important;
  transition: all 0.2s ease !important;
  box-shadow: none !important;
}

.panel-left .panel-left-input .chat-input-wrapper:focus-within,
.panel-left-input .chat-input-wrapper:focus-within,
div.chat-input-wrapper:focus-within {
  border-color: rgba(255, 255, 255, 0.25) !important;
}

/* Dictating state */
div.chat-input-wrapper.dictating {
  border-color: rgba(199, 51, 20, 0.5) !important;
  box-shadow: 0 0 0 2px rgba(199, 51, 20, 0.2) !important;
}

/* Input rows */
.input-row {
  display: flex !important;
  align-items: center !important;
  width: 100% !important;
}

.input-row-top {
  /* Text input row */
}

.input-row-bottom {
  justify-content: space-between !important;
}

/* Text input - expandable textarea */
.panel-left .panel-left-input .chat-text-input,
.panel-left-input .chat-text-input,
.chat-text-input,
textarea.chat-text-input {
  flex: 1 1 auto !important;
  width: 100% !important;
  min-width: 0 !important;
  min-height: 24px !important;
  max-height: 33vh !important;
  background: transparent !important;
  border: none !important;
  color: #FAF8F5 !important;
  font-size: 15px !important;
  font-family: 'Familjen Grotesk', -apple-system, sans-serif !important;
  outline: none !important;
  padding: 4px 0 !important;
  margin: 0 !important;
  box-shadow: none !important;
  resize: none !important;
  overflow-y: auto !important;
  line-height: 1.5 !important;
}

.chat-text-input::placeholder {
  color: rgba(250, 248, 245, 0.4) !important;
}

/* Custom scrollbar for textarea */
.chat-text-input::-webkit-scrollbar {
  width: 6px !important;
}

.chat-text-input::-webkit-scrollbar-track {
  background: rgba(255, 255, 255, 0.05) !important;
  border-radius: 3px !important;
}

.chat-text-input::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.2) !important;
  border-radius: 3px !important;
}

.chat-text-input::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.3) !important;
}

/* Left controls (Plus button) */
.input-controls-left {
  display: flex !important;
  align-items: center !important;
  gap: 4px !important;
  flex-shrink: 0 !important;
}

/* Right controls (Dictate + Voice/Send) */
.input-controls-right {
  display: flex !important;
  flex-direction: row !important;
  align-items: center !important;
  gap: 8px !important;
  flex-shrink: 0 !important;
  margin-left: auto !important;
}

/* Legacy support - hide old containers */
.input-actions-right {
  display: none !important;
}

/* Action buttons (add, mic, speaker) */
.panel-left .chat-input-action,
.chat-input-action,
button.chat-input-action {
  width: 36px !important;
  height: 36px !important;
  min-width: 36px !important;
  min-height: 36px !important;
  border-radius: 8px !important;
  background: transparent !important;
  border: none !important;
  color: rgba(255, 255, 255, 0.5) !important;
  cursor: pointer !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  transition: all 0.2s ease !important;
  flex-shrink: 0 !important;
  padding: 0 !important;
}

.panel-left .chat-input-action:hover,
.chat-input-action:hover,
button.chat-input-action:hover {
  color: rgba(255, 255, 255, 0.8) !important;
  background: rgba(255, 255, 255, 0.1) !important;
}

.panel-left .chat-input-action.active,
.chat-input-action.active,
button.chat-input-action.active {
  color: #C73314 !important;
  background: rgba(199, 51, 20, 0.15) !important;
}

/* Send button - up arrow style */
.panel-left .chat-send,
.chat-send,
button.chat-send {
  width: 36px !important;
  height: 36px !important;
  min-width: 36px !important;
  min-height: 36px !important;
  border-radius: 8px !important;
  background: rgba(255, 255, 255, 0.15) !important;
  border: none !important;
  color: rgba(255, 255, 255, 0.4) !important;
  cursor: not-allowed !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  transition: all 0.2s ease !important;
  flex-shrink: 0 !important;
  padding: 0 !important;
}

/* When there's text - turn orange */
.panel-left .chat-send.has-text,
.chat-send.has-text,
button.chat-send.has-text {
  background: #C73314 !important;
  color: white !important;
  cursor: pointer !important;
}

.panel-left .chat-send.has-text:hover,
.chat-send.has-text:hover,
button.chat-send.has-text:hover {
  background: #A82B11 !important;
  transform: scale(1.05);
}

/* ============================================
   ChatGPT-STYLE INPUT BUTTONS
   ============================================ */

/* Base icon button style */
.input-icon-btn {
  width: 36px !important;
  height: 36px !important;
  min-width: 36px !important;
  min-height: 36px !important;
  border-radius: 50% !important;
  border: none !important;
  background: transparent !important;
  cursor: pointer !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  color: rgba(250, 248, 245, 0.7) !important;
  transition: all 0.15s ease !important;
  flex-shrink: 0 !important;
  padding: 0 !important;
}

.input-icon-btn:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.1) !important;
  color: #FAF8F5 !important;
}

.input-icon-btn:disabled {
  opacity: 0.3 !important;
  cursor: not-allowed !important;
}

/* Plus button */
.input-icon-btn.plus-btn {
  color: rgba(250, 248, 245, 0.7) !important;
}

.input-icon-btn.plus-btn:hover:not(:disabled) {
  color: #FAF8F5 !important;
}

/* Plus expand button - fixed circle icon with floating dark label on hover */
.plus-expand-btn.expand-btn {
  position: relative;
  color: rgba(250, 248, 245, 0.7);
  width: 36px;
  height: 36px;
  min-width: 36px;
  max-width: 36px !important;   /* override inline expand */
  overflow: visible !important;  /* allow floating label to show */
  gap: 0 !important;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.12);
  transition: background-color 0.2s ease, border-color 0.2s ease, color 0.2s ease;
}

.plus-expand-btn.expand-btn:hover:not(:disabled) {
  color: #FAF8F5;
  max-width: 36px !important;   /* stay fixed on hover */
  background-color: rgba(255, 255, 255, 0.15);
  border-color: rgba(255, 255, 255, 0.25);
}

/* ============================================
   EXPAND BUTTON - Floating Label Positions
   Reusable classes for any expand button.
   Add expand-label-right or expand-label-bottom
   as a className alongside your context class.
   ============================================ */

/* Shared floating label base styles */
.expand-label-right .expand-btn__label--inline,
.expand-label-bottom .expand-btn__label--inline,
.expand-label-top .expand-btn__label--inline,
.expand-label-top .expand-btn__label--floating {
  position: absolute;
  white-space: nowrap;
  font-size: 13px;
  color: #FAF8F5;
  background: #2C1810;
  border: none;
  border-radius: 8px;
  padding: 6px 12px;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.15s ease, transform 0.15s ease;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
  z-index: 9999;
}

/* Position: RIGHT of button */
.expand-label-right .expand-btn__label--inline {
  left: calc(100% + 8px);
  top: 50%;
  transform: translateY(-50%) translateX(-4px);
}

.expand-label-right:hover .expand-btn__label--inline {
  opacity: 1;
  transform: translateY(-50%) translateX(0);
}

/* Position: LEFT-ALIGNED BELOW button */
.expand-label-bottom .expand-btn__label--inline {
  top: calc(100% + 8px);
  left: 0;
  transform: translateY(-4px);
}

.expand-label-bottom:hover .expand-btn__label--inline {
  opacity: 1;
  transform: translateY(0);
}

/* Position: ABOVE button */
.expand-label-top .expand-btn__label--inline,
.expand-label-top .expand-btn__label--floating {
  bottom: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%) translateY(4px);
}

.expand-label-top:hover .expand-btn__label--inline,
.expand-label-top:hover .expand-btn__label--floating {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}


/* Voice button (primary when empty) - prominent like ChatGPT */
.input-icon-btn.voice-btn {
  background: rgba(255, 255, 255, 0.2) !important;
  color: #FAF8F5 !important;
  border: 1px solid rgba(255, 255, 255, 0.3) !important;
}

.input-icon-btn.voice-btn:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.35) !important;
  border-color: rgba(255, 255, 255, 0.5) !important;
  transform: scale(1.05);
}

/* Dictate button (mic - always visible in normal state) */
.input-icon-btn.dictate-btn {
  color: rgba(250, 248, 245, 0.6) !important;
  background: transparent !important;
}

.input-icon-btn.dictate-btn:hover:not(:disabled) {
  color: #FAF8F5 !important;
  background: rgba(255, 255, 255, 0.1) !important;
}

/* Dictate button active state - red when recording */
.input-icon-btn.dictate-btn.active {
  color: #dc2626 !important;
  background: rgba(220, 38, 38, 0.15) !important;
}

.input-icon-btn.dictate-btn.active:hover {
  background: rgba(220, 38, 38, 0.25) !important;
}

/* Voice Mode button (waveform - shows when empty, replaced by send when has text) */
.input-icon-btn.voice-mode-btn {
  width: 36px !important;
  height: 36px !important;
  border-radius: 50% !important;
  background: transparent !important;
  color: rgba(250, 248, 245, 0.6) !important;
  border: none !important;
  cursor: pointer !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  transition: all 0.15s ease !important;
  flex-shrink: 0 !important;
}

.input-icon-btn.voice-mode-btn:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.1) !important;
  color: #FAF8F5 !important;
  transform: none;
}

/* ============================================
   VOICE MODE ACTIVE STATE
   ============================================ */

/* Voice mode wrapper state */
.chat-input-wrapper.voice-mode-active {
  border-color: rgba(220, 38, 38, 0.4) !important;
}

/* Mute buttons (speaker and mic) in voice mode */
.input-icon-btn.speaker-mute-btn,
.input-icon-btn.mic-mute-btn {
  color: rgba(250, 248, 245, 0.7) !important;
  background: transparent !important;
}

.input-icon-btn.speaker-mute-btn:hover,
.input-icon-btn.mic-mute-btn:hover {
  color: #FAF8F5 !important;
  background: rgba(255, 255, 255, 0.1) !important;
}

/* Muted state - red */
.input-icon-btn.speaker-mute-btn.muted,
.input-icon-btn.mic-mute-btn.muted {
  color: #dc2626 !important;
  background: rgba(220, 38, 38, 0.15) !important;
}

/* Voice End Button - red with animated waveform */
.voice-end-btn {
  display: flex !important;
  align-items: center !important;
  gap: 8px !important;
  padding: 8px 16px !important;
  border-radius: 20px !important;
  border: none !important;
  background: #dc2626 !important;
  color: white !important;
  font-size: 14px !important;
  font-weight: 600 !important;
  cursor: pointer !important;
  transition: all 0.15s ease !important;
  flex-shrink: 0 !important;
}

.voice-end-btn:hover {
  background: #b91c1c !important;
}

.voice-end-text {
  font-weight: 600 !important;
}

/* Animated waveform bars */
.voice-waveform-animated {
  display: flex !important;
  align-items: center !important;
  gap: 2px !important;
  height: 16px !important;
}

.voice-waveform-animated .wave-bar {
  width: 3px !important;
  height: 8px !important;
  background: white !important;
  border-radius: 2px !important;
  animation: wave-pulse 1s ease-in-out infinite !important;
}

.voice-waveform-animated .wave-bar:nth-child(1) { animation-delay: 0s !important; }
.voice-waveform-animated .wave-bar:nth-child(2) { animation-delay: 0.1s !important; }
.voice-waveform-animated .wave-bar:nth-child(3) { animation-delay: 0.2s !important; }
.voice-waveform-animated .wave-bar:nth-child(4) { animation-delay: 0.3s !important; }
.voice-waveform-animated .wave-bar:nth-child(5) { animation-delay: 0.4s !important; }

@keyframes wave-pulse {
  0%, 100% { 
    height: 4px !important; 
    opacity: 0.6 !important;
  }
  50% { 
    height: 16px !important; 
    opacity: 1 !important;
  }
}

/* Send button (primary when has text) */
.input-icon-btn.send-btn {
  background: #FAF8F5 !important;
  color: #3E2318 !important;
}

.input-icon-btn.send-btn:hover:not(:disabled) {
  background: #ffffff !important;
  transform: scale(1.05);
}

.input-icon-btn.send-btn:disabled {
  background: rgba(255, 255, 255, 0.2) !important;
  color: rgba(62, 35, 24, 0.5) !important;
}

/* Cancel button (X - dictation mode) */
.input-icon-btn.cancel-btn {
  color: rgba(250, 248, 245, 0.8) !important;
}

.input-icon-btn.cancel-btn:hover {
  color: #dc2626 !important;
  background: rgba(220, 38, 38, 0.15) !important;
}

/* Accept button (checkmark - dictation mode) */
.input-icon-btn.accept-btn {
  color: rgba(250, 248, 245, 0.8) !important;
}

.input-icon-btn.accept-btn:hover {
  color: #22c55e !important;
  background: rgba(34, 197, 94, 0.15) !important;
}


/* ============================================
   TOOLTIPS - Use shared file
   Include: /css/shared/tooltips.css
   ============================================ */

/* ============================================
   RIGHT PANEL - Story & Styles
   ============================================ */

.panel-right {
  display: block;
  height: auto;
  max-height: calc(100vh - 70px - 72px);
  overflow-y: auto;
}

.story-title {
  font-family: 'Libre Baskerville', Georgia, serif;
  font-size: 26px;
  font-weight: 400;
  color: #3E2318;
  margin: 0;
  letter-spacing: -0.01em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}

/* Panel Content */
.panel-right-content {
  display: block;
}

/* ============================================
   STORY PAPER
   ============================================ */

.story-paper {
  background: #FFFEFA;
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 
    0 2px 4px rgba(62, 35, 24, 0.04),
    0 4px 8px rgba(62, 35, 24, 0.04),
    0 8px 16px rgba(62, 35, 24, 0.03),
    0 16px 32px rgba(62, 35, 24, 0.03);
  transition: box-shadow 0.5s ease;
}

.story-paper.complete {
  box-shadow: 
    0 2px 4px rgba(62, 35, 24, 0.04),
    0 4px 8px rgba(62, 35, 24, 0.04),
    0 8px 16px rgba(62, 35, 24, 0.03),
    0 16px 32px rgba(62, 35, 24, 0.03),
    0 0 60px rgba(199, 51, 20, 0.06);
}

/* Title inside story paper (above the line) */
.story-paper-title {
  font-family: 'Libre Baskerville', Georgia, serif;
  font-size: 24px;
  font-weight: 400;
  color: #3E2318;
  text-align: center;
  margin: 0;
  padding: 32px 52px 0;
  letter-spacing: -0.01em;
}

.story-content {
  padding: 24px 52px 32px;
  position: relative;
  min-height: 160px;
}

.story-line {
  position: absolute;
  left: 52px;
  right: 52px;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(62, 35, 24, 0.1), transparent);
}

.story-line.top { top: 8px; }
.story-line.bottom { bottom: 32px; }

.story-body {
  min-height: 80px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px 0;
}

/* Empty State */
.story-empty {
  text-align: center;
}

.story-empty-icon {
  display: block;
  font-size: 28px;
  color: #D4CBC3;
  margin-bottom: 16px;
}

.story-empty p {
  font-family: 'Libre Baskerville', Georgia, serif;
  font-size: 17px;
  font-style: italic;
  color: #B8ADA3;
  margin: 0;
  line-height: 1.8;
}

/* Story Text */
.story-text {
  font-family: 'Libre Baskerville', Georgia, serif;
  font-size: 18px;
  line-height: 2;
  color: #2C1810;
  text-align: center;
  margin: 0;
  letter-spacing: 0.01em;
}

/* ============================================
   STORY FOOTER - Simplified with Create Button
   ============================================ */

.story-footer {
  background: rgba(62, 35, 24, 0.02);
  border-top: 1px solid rgba(62, 35, 24, 0.05);
  padding: 16px 36px;
  display: flex;
  align-items: center;
  justify-content: flex-end;
}

/* ============================================
   CREATE BUTTON
   ============================================ */

.story-create-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 10px 24px;
  background: #D4CBC3;
  border: none;
  border-radius: 24px;
  font-size: 14px;
  font-weight: 600;
  color: #8B8078;
  cursor: not-allowed;
  transition: all 0.2s ease;
  font-family: 'Familjen Grotesk', sans-serif;
  flex-shrink: 0;
}

.story-create-btn.ready {
  background: #C73314;
  color: white;
  cursor: pointer;
  box-shadow: 0 2px 12px rgba(199, 51, 20, 0.25);
}

.story-create-btn.ready:hover {
  background: #A82B11;
  transform: translateY(-1px);
  box-shadow: 0 4px 16px rgba(199, 51, 20, 0.3);
}

/* ============================================
   STYLES SECTION - 4 Slot Grid
   Positioned directly under story box
   ============================================ */

.styles-section {
  margin-top: 24px;
  padding-top: 0;
}

.styles-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.styles-title {
  font-family: 'Libre Baskerville', Georgia, serif;
  font-size: 26px;
  font-weight: 400;
  color: #3E2318;
}

.styles-header-text {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.styles-subtitle {
  font-family: 'Familjen Grotesk', -apple-system, sans-serif;
  font-size: 14px;
  color: #8B7355;
}

/* 4-Column Grid for Style Slots */
.styles-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  overflow: hidden;            /* iOS: prevent children from bleeding outside grid */
}

/* Style Slot - Base Styling */
.style-slot {
  background: #F2EDE6;
  border: 1px solid rgba(62, 35, 24, 0.12);
  border-radius: 10px;
  cursor: pointer;
  transition: all 0.25s ease;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-width: 0;              /* iOS Safari: prevent grid children from overflowing tracks */
  box-shadow: 
    0 2px 4px rgba(62, 35, 24, 0.04),
    0 4px 8px rgba(62, 35, 24, 0.04),
    0 8px 16px rgba(62, 35, 24, 0.03),
    0 16px 32px rgba(62, 35, 24, 0.03);
}

.style-slot:hover {
  transform: translateY(-4px);
  box-shadow: 
    0 4px 8px rgba(62, 35, 24, 0.06),
    0 8px 16px rgba(62, 35, 24, 0.05),
    0 16px 32px rgba(62, 35, 24, 0.04),
    0 24px 48px rgba(62, 35, 24, 0.03);
  border-color: rgba(62, 35, 24, 0.18);
}

/* Empty Slot Placeholder */
.style-slot.empty .style-slot-placeholder {
  aspect-ratio: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(62, 35, 24, 0.02);
  padding: 15%;
  width: 100%;                /* iOS: ensure placeholder fills container width */
}

/* Fallback for iOS < 15 that doesn't support aspect-ratio */
@supports not (aspect-ratio: 1) {
  .style-slot.empty .style-slot-placeholder {
    padding-top: 100%;
    position: relative;
  }
  .style-slot.empty .style-slot-placeholder > * {
    position: absolute;
    inset: 15%;
  }
}

/* 3x3 Dotted Grid SVG */
.style-slot-grid {
  width: 100%;
  height: 100%;
  color: rgba(62, 35, 24, 0.2);
  transition: color 0.2s ease;
}

.style-slot:hover .style-slot-grid {
  color: rgba(62, 35, 24, 0.35);
}

/* Filled Slot with Image */
.style-slot.filled {
  background: white;
}

.style-slot-image {
  position: relative;
  aspect-ratio: 1;
  width: 100%;                /* iOS: ensure image container fills slot width */
}

.style-slot-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

/* Fallback for iOS < 15 that doesn't support aspect-ratio */
@supports not (aspect-ratio: 1) {
  .style-slot-image {
    padding-top: 100%;
  }
  .style-slot-image img {
    position: absolute;
    top: 0;
    left: 0;
  }
}

.style-slot .style-remove {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(4px);
  border: none;
  color: white;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transform: scale(0.8);
  transition: all 0.2s ease;
}

.style-slot:hover .style-remove {
  opacity: 1;
  transform: scale(1);
}

.style-slot .style-remove:hover {
  background: #C73314;
}

/* Slot Label - Larger text (matches chat), wraps when long */
.style-slot-label {
  padding: 12px 10px;
  font-family: 'Familjen Grotesk', sans-serif;
  font-size: 15px;
  font-weight: 500;
  color: #3E2318;
  text-align: center;
  line-height: 1.3;
  /* Allow text to wrap */
  white-space: normal;
  word-wrap: break-word;
  overflow-wrap: break-word;
  /* Limit to 2 lines with ellipsis */
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  min-height: 42px;
}

.style-slot.empty .style-slot-label {
  color: #8B7355;
}

.style-slot-label a {
  color: inherit;
  text-decoration: none;
}

.style-slot-label a:hover {
  text-decoration: underline;
  color: var(--sa-orange, #C73314);
}


/* ============================================
   RESPONSIVE
   ============================================ */

@media (max-width: 1200px) {
  .layout-centered-wrapper {
    padding: 20px 28px 28px;
  }
  
  .layout-centered {
    gap: 28px;
  }
  
  .panel-left {
    height: calc(100vh - 70px - 64px);
  }
  
  .panel-right {
    max-height: calc(100vh - 70px - 64px);
  }
  
  .story-title {
    font-size: 24px;
  }
  
  .story-paper-title {
    font-size: 22px;
    padding: 28px 44px 0;
  }
  
  .story-content {
    padding: 20px 44px 28px;
  }
  
  .story-line {
    left: 44px;
    right: 44px;
  }
  
  .story-text {
    font-size: 17px;
  }
  
  .story-footer {
    padding: 14px 28px;
  }
  
  .story-create-btn {
    padding: 8px 20px;
    font-size: 13px;
  }
  
  .styles-grid {
    gap: 12px;
  }
  
  .style-slot-label {
    padding: 10px 8px;
    font-size: 14px;
    min-height: 38px;
  }
}

@media (max-width: 1024px) {
  .layout-centered-wrapper {
    padding: 16px 24px 24px;
  }
  
  .layout-centered {
    grid-template-columns: 45% 55%;
    gap: 24px;
  }
  
  .panel-left {
    height: calc(100vh - 70px - 56px);
  }
  
  .panel-right {
    max-height: calc(100vh - 70px - 56px);
  }
  
  .panel-left-header,
  .panel-left-messages {
    padding-left: 24px;
    padding-right: 24px;
  }
  
  .panel-left .panel-left-input {
    padding: 16px 20px 20px !important;
  }
  
  .story-create-btn {
    padding: 8px 18px;
    font-size: 13px;
  }
  
  .styles-grid {
    grid-template-columns: repeat(4, 1fr);
    gap: 10px;
  }
  
  .style-slot-label {
    padding: 8px 6px;
    font-size: 13px;
    min-height: 36px;
  }
}

@media (max-width: 900px) {
  .layout-centered-wrapper {
    padding: 16px 20px 20px;
  }
  
  .layout-centered {
    grid-template-columns: 1fr;
  }
  
  .panel-left {
    position: fixed;
    left: 0;
    top: 70px;
    bottom: 0;
    width: 100%;
    max-width: 400px;
    height: auto;
    border-radius: 0;
    transform: translateX(-100%);
    transition: transform 0.3s ease;
    z-index: 100;
  }
  
  .panel-left.open {
    transform: translateX(0);
  }
  
  .panel-right {
    height: auto;
    min-height: calc(100vh - 70px - 40px);
  }
  
  .story-title {
    font-size: 26px;
  }
  
  .story-footer {
    padding: 14px 24px;
    justify-content: center;
  }
  
  .story-create-btn {
    width: 100%;
    justify-content: center;
  }
  
  .styles-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
  }
  
  .style-slot-label {
    font-size: 14px;
    min-height: 38px;
  }
}

@media (max-width: 600px) {
  .layout-centered {
    padding: 16px;
  }
  
  .styles-header {
    flex-direction: column;
    align-items: stretch;
    gap: 16px;
  }
  
  .story-title {
    text-align: center;
  }
  
  .story-paper-title {
    font-size: 20px;
    padding: 24px 28px 0;
  }
  
  .story-content {
    padding: 16px 28px 24px;
  }
  
  .story-line {
    left: 28px;
    right: 28px;
  }
  
  .story-text {
    font-size: 16px;
  }
  
  .story-footer {
    padding: 12px 20px;
  }
  
  .story-create-btn {
    padding: 10px 20px;
  }
  
  /* Smaller buttons on mobile */
  .panel-left .chat-input-action,
  .chat-input-action {
    width: 32px !important;
    height: 32px !important;
    min-width: 32px !important;
    min-height: 32px !important;
  }
  
  .panel-left .chat-send,
  .chat-send {
    width: 32px !important;
    height: 32px !important;
    min-width: 32px !important;
    min-height: 32px !important;
  }
  
  .styles-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
  }
  
  .style-slot-label {
    padding: 8px 6px;
    font-size: 13px;
    min-height: 34px;
  }
}
