/* ── Character Detail — Split Panel Layout ────────── */

.char-detail {
  display: flex;
  height: 100vh;
}

.char-detail-left {
  flex: 70;
  overflow-y: auto;
  padding: 24px 32px;
  border-right: 1px solid var(--border);
}

.char-detail-right {
  flex: 30;
  display: flex;
  flex-direction: column;
  height: 100vh;
  min-width: 280px;
  max-width: 380px;
}

/* ── Detail Header ──────────────────────────────────── */

.char-detail-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 24px;
}

.char-detail-back {
  background: none;
  border: 1px solid var(--border);
  color: var(--text-dim);
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition);
  flex-shrink: 0;
}

.char-detail-back:hover {
  border-color: var(--text-dim);
  color: var(--text);
}

.char-detail-title {
  font-size: 20px;
  font-weight: 600;
  color: var(--text-bright);
}

/* ── Editable Fields ────────────────────────────────── */

.char-fields {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin-bottom: 24px;
}

.char-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.char-field.full-width {
  grid-column: 1 / -1;
}

.char-field label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.char-field input,
.char-field textarea {
  width: 100%;
  padding: 8px 12px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 14px;
  font-family: inherit;
  outline: none;
  transition: border-color var(--transition);
}

.char-field input:focus,
.char-field textarea:focus {
  border-color: var(--border-focus);
}

.char-field textarea {
  resize: vertical;
  min-height: 60px;
}

/* ── Pose Grid ──────────────────────────────────────── */

.char-poses-section {
  margin-top: 8px;
}

.char-poses-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.char-poses-header h3 {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-bright);
}

/* Layout: full_body tall center, 4 portraits in corners
   ┌───────┐ ┌──────────┐ ┌───────┐
   │ Front │ │          │ │ Right │
   │  1:1  │ │  Full    │ │  1:1  │
   └───────┘ │  Body    │ └───────┘
   ┌───────┐ │  9:16    │ ┌───────┐
   │ Left  │ │          │ │ Back  │
   │  1:1  │ │          │ │  1:1  │
   └───────┘ └──────────┘ └───────┘
*/
.char-poses-grid {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  grid-template-rows: 1fr 1fr;
  gap: 10px;
  /* Height driven by the full-body 9:16 center column */
}

.char-pose-slot {
  background: var(--bg-card);
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  position: relative;
  overflow: hidden;
  cursor: pointer;
  transition: border-color var(--transition);
}

/* Portrait slots (1:1) */
.char-pose-slot.portrait-slot {
  aspect-ratio: 1;
}

/* Full body slot spans 2 rows, 9:16 */
.char-pose-slot.fullbody-slot {
  grid-column: 2;
  grid-row: 1 / 3;
  aspect-ratio: auto;
}

.char-pose-slot:hover {
  border-color: var(--text-dim);
}

.char-pose-slot.has-image {
  border-style: solid;
}

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

.char-pose-placeholder {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  color: var(--text-dim);
  font-size: 12px;
}

.char-pose-placeholder-icon {
  font-size: 24px;
  opacity: 0.5;
}

.char-pose-label {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 4px 8px;
  background: rgba(0, 0, 0, 0.7);
  color: var(--text);
  font-size: 11px;
  font-weight: 500;
  text-align: center;
}

.char-pose-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  opacity: 0;
  transition: opacity var(--transition);
}

.char-pose-slot:hover .char-pose-overlay {
  opacity: 1;
}

.char-pose-overlay button {
  padding: 4px 10px;
  font-size: 11px;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(255, 255, 255, 0.3);
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
  cursor: pointer;
  transition: all var(--transition);
}

.char-pose-overlay button:hover {
  background: rgba(255, 255, 255, 0.2);
  border-color: rgba(255, 255, 255, 0.5);
}

.char-pose-overlay .btn-delete {
  border-color: rgba(229, 115, 115, 0.5);
  color: var(--priority-high);
}

.char-pose-overlay .btn-delete:hover {
  background: rgba(229, 115, 115, 0.2);
}

.char-pose-spinner {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-card);
}

/* ── Style Chips (in detail) ─────────────────────── */

.char-detail-style-section {
  margin-bottom: 20px;
}

.char-detail-style-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 6px;
}

.char-detail-style-chips {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.char-detail-style-chip {
  padding: 3px 10px;
  font-size: 11px;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: none;
  color: var(--text-dim);
  cursor: pointer;
  transition: all var(--transition);
}

.char-detail-style-chip:hover {
  border-color: var(--text-dim);
  color: var(--text);
}

.char-detail-style-chip.active {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-soft);
}

/* ── Chat Panel (right side) ─────────────────────── */

.char-chat-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  font-size: 14px;
  font-weight: 600;
  color: var(--text-bright);
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.char-chat-header-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--green);
}

.char-chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.char-chat-empty {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-dim);
  font-size: 13px;
  text-align: center;
  padding: 20px;
  line-height: 1.5;
}

.char-chat-msg {
  display: flex;
}

.char-chat-msg-user {
  justify-content: flex-end;
}

.char-chat-bubble {
  max-width: 85%;
  padding: 10px 14px;
  border-radius: 12px;
  font-size: 13px;
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-word;
}

.char-chat-bubble-user {
  background: var(--accent);
  color: #fff;
  border-bottom-right-radius: 4px;
}

.char-chat-bubble-ai {
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text);
  border-bottom-left-radius: 4px;
}

.char-chat-tools {
  margin-top: 6px;
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.char-chat-tool {
  font-size: 10px;
  padding: 2px 8px;
  background: var(--accent-soft);
  color: var(--accent);
  border-radius: 10px;
  font-weight: 500;
}

.char-chat-error {
  margin-top: 6px;
  font-size: 12px;
  color: var(--red);
}

.char-chat-typing {
  display: flex;
  gap: 4px;
  padding: 8px 14px;
}

.char-chat-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--text-dim);
  animation: chatDotPulse 1.4s infinite;
}

.char-chat-dot:nth-child(2) { animation-delay: 0.2s; }
.char-chat-dot:nth-child(3) { animation-delay: 0.4s; }

@keyframes chatDotPulse {
  0%, 80%, 100% { opacity: 0.3; transform: scale(0.8); }
  40% { opacity: 1; transform: scale(1); }
}

.char-chat-input-bar {
  padding: 12px 16px;
  border-top: 1px solid var(--border);
  display: flex;
  gap: 8px;
  flex-shrink: 0;
}

.char-chat-input {
  flex: 1;
  padding: 8px 12px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 13px;
  font-family: inherit;
  outline: none;
  resize: none;
  max-height: 80px;
}

.char-chat-input:focus {
  border-color: var(--border-focus);
}

.char-chat-send {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--accent);
  border: none;
  color: #fff;
  font-size: 16px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background var(--transition);
  flex-shrink: 0;
}

.char-chat-send:hover:not(:disabled) {
  background: var(--accent-hover);
}

.char-chat-send:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

