*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
.hidden { display: none !important; }

:root {
  --bg: #f5f7f6;
  --surface: #ffffff;
  --surface2: #edf2f0;
  --border: #d4e2de;
  --accent: #c9a96e;
  --accent2: #3d8fa3;
  --text: #1a3a44;
  --muted: #6a8f9a;
  --radius: 14px;
}

body {
  font-family: 'Helvetica Neue', 'PingFang TC', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Tabs */
.tabs {
  display: flex;
  gap: 4px;
  justify-content: center;
  padding: 20px 20px 0;
}

.tab {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--muted);
  border-radius: 8px 8px 0 0;
  padding: 9px 24px;
  font-size: 0.9rem;
  cursor: pointer;
  transition: all 0.15s;
  border-bottom: none;
}

.tab.active {
  background: var(--surface);
  color: var(--text);
  border-color: var(--border);
}

.tab:hover:not(.active) { color: var(--text); }

header {
  text-align: center;
  padding: 48px 20px 20px;
  border-bottom: 1px solid var(--border);
}

header h1 {
  font-size: 2rem;
  font-weight: 700;
  background: linear-gradient(135deg, #c9a96e, #e8cc99);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: 8px;
}

header p {
  color: var(--muted);
  font-size: 0.95rem;
}

main {
  display: grid;
  grid-template-columns: 400px 1fr;
  gap: 0;
  flex: 1;
  max-width: 1300px;
  margin: 0 auto;
  width: 100%;
  padding: 32px 24px;
  gap: 28px;
}

@media (max-width: 900px) {
  main { grid-template-columns: 1fr; }
}

/* Input Panel */
.input-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px;
  display: flex;
  flex-direction: column;
  gap: 22px;
  height: fit-content;
  position: sticky;
  top: 24px;
}

.field label {
  display: block;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 10px;
}

input[type="text"] {
  width: 100%;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 9px;
  color: var(--text);
  padding: 11px 14px;
  font-size: 0.95rem;
  outline: none;
  transition: border-color 0.2s;
}

input[type="text"]:focus {
  border-color: var(--accent);
}

input[type="text"]::placeholder { color: var(--muted); }

.pill-group {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.pill {
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--muted);
  border-radius: 999px;
  padding: 6px 15px;
  font-size: 0.85rem;
  cursor: pointer;
  transition: all 0.15s;
}

.pill:hover { border-color: var(--accent); color: var(--text); }

.pill.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

input[type="range"] {
  width: calc(100% - 80px);
  accent-color: var(--accent);
  vertical-align: middle;
  cursor: pointer;
}

#count-label {
  margin-left: 12px;
  font-size: 0.9rem;
  color: var(--accent);
  font-weight: 600;
}

#generate-btn, #ai-btn, #produce-btn {
  position: relative;
  width: 100%;
  background: linear-gradient(135deg, var(--accent), #e8cc99, var(--accent2));
  background-size: 200% 200%;
  background-position: 0% 50%;
  color: #fff;
  border: none;
  border-radius: 12px;
  padding: 15px 20px;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  letter-spacing: 0.04em;
  box-shadow: 0 4px 15px rgba(201, 169, 110, 0.35);
  transition: background-position 0.4s ease, transform 0.15s, box-shadow 0.2s;
  overflow: hidden;
}

#generate-btn::after, #ai-btn::after, #produce-btn::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(120deg, transparent 30%, rgba(255,255,255,0.18) 50%, transparent 70%);
  transform: translateX(-100%);
  transition: transform 0.5s ease;
}

#generate-btn:hover::after, #ai-btn:hover::after, #produce-btn:hover::after {
  transform: translateX(100%);
}

#generate-btn:hover, #ai-btn:hover, #produce-btn:hover {
  background-position: 100% 50%;
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(201, 169, 110, 0.45);
}

#generate-btn:active, #ai-btn:active, #produce-btn:active {
  transform: translateY(0);
  box-shadow: 0 2px 8px rgba(201, 169, 110, 0.3);
}

#generate-btn.loading, #ai-btn.loading, #produce-btn.loading {
  opacity: 0.7;
  pointer-events: none;
  background-position: 100% 50%;
  animation: btnPulse 1.2s ease-in-out infinite;
}

@keyframes btnPulse {
  0%, 100% { box-shadow: 0 4px 15px rgba(201, 169, 110, 0.35); }
  50%       { box-shadow: 0 4px 25px rgba(201, 169, 110, 0.6); }
}

/* Output Panel */
.output-panel {
  min-height: 300px;
}

.output-placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 200px;
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  color: var(--muted);
  font-size: 0.9rem;
}

.output-placeholder.hidden { display: none; }

#ideas-container {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

/* Textarea */
textarea {
  width: 100%;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 9px;
  color: var(--text);
  padding: 11px 14px;
  font-size: 0.9rem;
  font-family: inherit;
  outline: none;
  resize: vertical;
  transition: border-color 0.2s;
  line-height: 1.55;
}

textarea:focus { border-color: var(--accent); }
textarea::placeholder { color: var(--muted); }

/* AI result panel */
.ai-output-panel { min-height: 300px; }

.ai-result {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px 30px;
  font-size: 0.92rem;
  line-height: 1.75;
  color: var(--text);
  white-space: pre-wrap;
  word-break: break-word;
}

.ai-result:empty { display: none; }

.typing-cursor::after {
  content: '▌';
  color: var(--accent);
  animation: blink 0.8s step-end infinite;
}

@keyframes blink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0; }
}

/* Idea Card */
.idea-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px 24px;
  position: relative;
  transition: border-color 0.2s, transform 0.15s;
  animation: fadeIn 0.35s ease both;
}

.idea-card:hover {
  border-color: var(--accent);
  transform: translateY(-2px);
}

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

.card-index {
  position: absolute;
  top: 18px;
  right: 20px;
  font-size: 0.75rem;
  color: var(--muted);
  font-weight: 600;
}

.card-tag {
  display: inline-block;
  background: rgba(201, 169, 110, 0.15);
  color: var(--accent);
  border-radius: 999px;
  padding: 3px 10px;
  font-size: 0.75rem;
  font-weight: 600;
  margin-bottom: 10px;
}

.card-title {
  font-size: 1.08rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 10px;
  line-height: 1.4;
}

.card-hook {
  font-size: 0.9rem;
  color: #4a7a8a;
  font-style: italic;
  border-left: 3px solid var(--accent);
  padding-left: 12px;
  margin-bottom: 14px;
  line-height: 1.5;
}

.card-outline {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.card-outline li {
  font-size: 0.85rem;
  color: var(--muted);
  padding-left: 18px;
  position: relative;
  line-height: 1.4;
}

.card-outline li::before {
  content: '▸';
  position: absolute;
  left: 0;
  color: var(--accent2);
  font-size: 0.75rem;
  top: 1px;
}

.card-footer {
  display: flex;
  gap: 8px;
  margin-top: 16px;
  flex-wrap: wrap;
}

.tag-badge {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 3px 10px;
  font-size: 0.75rem;
  color: var(--muted);
}

.copy-btn {
  margin-left: auto;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 7px;
  color: var(--muted);
  padding: 4px 12px;
  font-size: 0.78rem;
  cursor: pointer;
  transition: all 0.15s;
}

.copy-btn:hover { border-color: var(--accent); color: var(--text); }
.copy-btn.copied { border-color: #4ade80; color: #4ade80; }

/* Chat area */
.chat-area {
  margin-top: 24px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.chat-divider {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 20px;
  background: var(--surface2);
  border-bottom: 1px solid var(--border);
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

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

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

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

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

.chat-bubble.ai {
  align-self: flex-start;
  background: var(--surface2);
  color: var(--text);
  border: 1px solid var(--border);
  border-bottom-left-radius: 4px;
}

.chat-input-row {
  display: flex;
  gap: 10px;
  padding: 12px 16px;
  background: var(--surface);
  border-top: 1px solid var(--border);
}

.chat-input-row textarea {
  flex: 1;
  resize: none;
  font-size: 0.9rem;
  border-radius: 10px;
  padding: 10px 14px;
}

#chat-send-btn {
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 10px;
  padding: 0 20px;
  font-size: 0.9rem;
  font-weight: 700;
  cursor: pointer;
  transition: opacity 0.2s, transform 0.1s;
  white-space: nowrap;
}

#chat-send-btn:hover { opacity: 0.85; transform: translateY(-1px); }
#chat-send-btn:disabled { opacity: 0.5; pointer-events: none; }

/* Produce result */
.produce-result {
  white-space: pre-wrap;
  word-break: break-word;
  position: relative;
}

.produce-copy-bar {
  display: flex;
  justify-content: flex-end;
  margin-top: 16px;
}

.produce-copy-btn {
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 8px 20px;
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.2s;
}

.produce-copy-btn:hover { opacity: 0.85; }
.produce-copy-btn.copied { background: #4ade80; color: #fff; }
