/* ChatBack - 嘴替君 - Apple-style clean design */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --accent: #1976D2;
  --accent-hover: #1565C0;
  --accent-light: #E3F2FD;
  --accent-bg: rgba(25, 118, 210, 0.08);
  --text-primary: #1d1d1f;
  --text-secondary: #6e6e73;
  --text-tertiary: #aeaeb2;
  --bg-primary: #ffffff;
  --bg-secondary: #f5f5f7;
  --bg-hover: #e8e8ed;
  --border: #d2d2d7;
  --border-strong: #b8b8be;
  --them-color: #FF6B6B;
  --me-color: #1976D2;
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.06);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.08);
  --shadow-lg: 0 8px 30px rgba(0, 0, 0, 0.1);
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 20px;
  --font-sans: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', sans-serif;
}

body {
  font-family: var(--font-sans);
  background: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}

.container {
  max-width: 920px;
  margin: 0 auto;
  padding: 56px 24px 80px;
}

/* Header */
.header {
  text-align: center;
  padding-bottom: 40px;
  margin-bottom: 32px;
  border-bottom: 1px solid var(--border);
}

.logo {
  font-size: 48px;
  font-weight: 700;
  letter-spacing: -0.03em;
  color: var(--text-primary);
  line-height: 1.1;
  margin-bottom: 4px;
}

.logo-en {
  font-size: 16px;
  font-weight: 500;
  color: var(--accent);
  letter-spacing: 0.08em;
  margin-bottom: 16px;
}

.subtitle {
  font-size: 18px;
  color: var(--text-secondary);
  font-weight: 400;
}

.nav-links {
  margin-top: 20px;
}

.nav-links a {
  color: var(--accent);
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
  transition: opacity 0.2s;
}

.nav-links a:hover {
  opacity: 0.7;
}

/* Turn / conversation */
.conversation {
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.turn {
  background: var(--bg-primary);
  border-radius: var(--radius-lg);
}

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

.turn-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.turn-num {
  color: var(--accent);
}

.turn-context {
  font-size: 13px;
  color: var(--text-secondary);
}

/* Quote box (对方说) */
.quote-box {
  background: #FFF5F5;
  border: 1px solid #FFD9D9;
  border-left: 4px solid var(--them-color);
  border-radius: var(--radius-md);
  padding: 20px;
  margin-bottom: 20px;
}

.quote-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--them-color);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 10px;
}

#theirWords {
  width: 100%;
  min-height: 80px;
  padding: 0;
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.6;
  border: none;
  background: transparent;
  color: var(--text-primary);
  resize: vertical;
  outline: none;
}

#theirWords::placeholder {
  color: var(--text-tertiary);
}

/* Style selector */
.style-section {
  margin-bottom: 20px;
}

.style-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 10px;
}

.style-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

.style-card {
  padding: 14px 12px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--bg-primary);
  cursor: pointer;
  transition: all 0.18s ease;
  text-align: left;
  display: flex;
  flex-direction: column;
  gap: 2px;
  font-family: inherit;
}

.style-card:hover {
  border-color: var(--border-strong);
  background: var(--bg-secondary);
  transform: translateY(-1px);
}

.style-card.selected {
  border-color: var(--accent);
  background: var(--accent-bg);
  box-shadow: 0 0 0 3px rgba(25, 118, 210, 0.08);
}

.style-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
}

.style-card.selected .style-name {
  color: var(--accent);
}

.style-desc {
  font-size: 12px;
  color: var(--text-secondary);
}

/* Actions */
.actions {
  display: flex;
  gap: 12px;
  align-items: center;
  margin-bottom: 16px;
}

.btn-primary, .btn-secondary {
  padding: 11px 24px;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 15px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
  font-family: inherit;
}

.btn-primary {
  background: var(--accent);
  color: white;
}

.btn-primary:hover {
  background: var(--accent-hover);
  box-shadow: var(--shadow-sm);
}

.btn-primary:disabled {
  background: #90CAF9;
  cursor: not-allowed;
}

.btn-secondary {
  background: var(--bg-secondary);
  color: var(--text-primary);
  border: 1px solid var(--border);
}

.btn-secondary:hover {
  background: var(--bg-hover);
}

.btn-secondary:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Examples */
.examples {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.example-label {
  font-size: 13px;
  color: var(--text-secondary);
}

.example-btn {
  padding: 5px 12px;
  border: 1px solid var(--border);
  border-radius: 20px;
  background: var(--bg-primary);
  color: var(--accent);
  font-size: 12px;
  cursor: pointer;
  transition: all 0.18s;
  font-family: inherit;
}

.example-btn:hover {
  background: var(--accent-light);
  border-color: var(--accent);
}

/* Response (我方回嘴) */
.response-section {
  background: var(--accent-bg);
  border: 1.5px solid var(--accent);
  border-radius: var(--radius-lg);
  padding: 20px 24px;
  animation: fadeIn 0.3s ease;
}

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

.response-label {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 13px;
  font-weight: 600;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 12px;
}

.copy-btn {
  padding: 4px 12px;
  border: 1px solid var(--accent);
  border-radius: 16px;
  background: transparent;
  color: var(--accent);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
  font-family: inherit;
  text-transform: none;
  letter-spacing: 0;
}

.copy-btn:hover {
  background: var(--accent);
  color: white;
}

.copy-btn.copied {
  background: var(--accent);
  color: white;
}

.response-content {
  font-size: 15px;
  line-height: 1.75;
  color: var(--text-primary);
  white-space: pre-wrap;
  word-break: break-word;
  margin-bottom: 16px;
  padding: 12px 0;
}

.response-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  padding-top: 12px;
  border-top: 1px solid rgba(25, 118, 210, 0.15);
}

/* Loading */
.loading-section {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 32px;
  color: var(--text-secondary);
  font-size: 14px;
}

.spinner {
  display: inline-block;
  width: 18px;
  height: 18px;
  border: 2px solid rgba(25, 118, 210, 0.2);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

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

.btn-primary.loading {
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.btn-primary.loading::before {
  content: '';
  display: inline-block;
  width: 14px;
  height: 14px;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-top-color: white;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  margin-right: 8px;
}

/* Error */
.error-section {
  margin-top: 16px;
}

.error-message {
  background: #FFF0F0;
  border: 1px solid #FFCCCC;
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  color: #C73838;
  font-size: 14px;
}

/* Footer */
.footer {
  text-align: center;
  padding-top: 60px;
  color: var(--text-tertiary);
  font-size: 13px;
}

/* Turn separation - when new turn appears */
.turn-separator {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 0;
  font-size: 12px;
  color: var(--text-tertiary);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.turn-separator::before,
.turn-separator::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}

/* Multi-turn display */
.turn-history {
  margin-top: 8px;
  padding: 14px 18px;
  background: var(--bg-secondary);
  border-radius: var(--radius-md);
  margin-bottom: 16px;
}

.turn-history-item {
  padding: 8px 0;
  border-bottom: 1px dashed var(--border);
  font-size: 13px;
}

.turn-history-item:last-child {
  border-bottom: none;
}

.turn-history-quote {
  color: var(--them-color);
  font-weight: 500;
  margin-bottom: 4px;
}

.turn-history-quote::before {
  content: '对方: ';
  font-size: 11px;
  color: var(--text-tertiary);
  margin-right: 4px;
}

.turn-history-response {
  color: var(--text-primary);
  line-height: 1.6;
}

.turn-history-response::before {
  content: '我方: ';
  font-size: 11px;
  color: var(--text-tertiary);
  margin-right: 4px;
}

/* Responsive */
@media (max-width: 720px) {
  .container { padding: 32px 16px 48px; }
  .logo { font-size: 36px; }
  .style-grid { grid-template-columns: repeat(2, 1fr); }
  .actions { flex-direction: column; align-items: stretch; }
  .actions button { width: 100%; }
}

@media (max-width: 480px) {
  .logo { font-size: 32px; }
  .style-grid { grid-template-columns: 1fr; }
  .response-section { padding: 16px 18px; }
}