/* ===== AI STORY GENERATOR CSS v2 ===== */

.story-wrapper { margin-bottom: 28px; }
.story-grid    { display: grid; grid-template-columns: 1fr 1.15fr; gap: 20px; }

/* Cards */
.story-input-card,
.story-output-card {
    background: #fff; border: 2px solid #e5e7eb;
    border-radius: 20px; padding: 24px;
}
.story-output-card { border-color: #ddd6fe; }
.story-card-title  { font-size: 16px; font-weight: 800; color: #1f2937; margin-bottom: 18px; }

/* Fields */
.story-field { margin-bottom: 16px; }
.story-label { display: block; font-size: 13px; font-weight: 700; color: #374151; margin-bottom: 8px; }
.req  { color: #ef4444; }
.opt  { color: #9ca3af; font-weight: 400; font-size: 11px; }

/* Textarea */
.story-textarea {
    width: 100%; min-height: 100px; border: 2px solid #e5e7eb; border-radius: 12px;
    padding: 12px 14px; font-size: 14px; font-family: inherit; resize: vertical;
    outline: none; transition: border-color 0.2s; box-sizing: border-box; color: #1f2937; line-height: 1.6;
}
.story-textarea:focus { border-color: #7c3aed; }
.story-char-count { font-size: 11px; color: #9ca3af; text-align: right; margin-top: 3px; }

/* Input */
.story-input {
    width: 100%; border: 2px solid #e5e7eb; border-radius: 10px;
    padding: 10px 14px; font-size: 14px; outline: none; font-family: inherit;
    transition: border-color 0.2s; box-sizing: border-box; color: #1f2937;
}
.story-input:focus { border-color: #7c3aed; }

/* ===== PRE-BUILD GRID ===== */
.prebuild-grid {
    display: grid; grid-template-columns: repeat(5, 1fr); gap: 7px; margin-bottom: 10px;
}
.prebuild-btn {
    background: linear-gradient(135deg, #f0fdf4, #dcfce7);
    border: 2px solid #86efac; border-radius: 10px;
    padding: 9px 5px; cursor: pointer; transition: all 0.2s;
    display: flex; flex-direction: column; align-items: center; gap: 3px;
    font-size: 20px;
}
.prebuild-btn span  { font-size: 10px; font-weight: 800; color: #065f46; line-height: 1.2; text-align: center; }
.prebuild-btn small { font-size: 9px; color: #4ade80; font-weight: 400; }
.prebuild-btn:hover {
    background: linear-gradient(135deg, #10b981, #059669);
    border-color: #059669; transform: translateY(-2px);
}
.prebuild-btn:hover span, .prebuild-btn:hover small { color: #fff; }
.prebuild-btn.active {
    background: linear-gradient(135deg, #10b981, #059669);
    border-color: #059669; transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(16,185,129,0.3);
}
.prebuild-btn.active span, .prebuild-btn.active small { color: #fff; }

.prebuild-selected {
    display: flex; align-items: center; gap: 8px; margin-top: 6px;
}
.prebuild-tag {
    background: #d1fae5; color: #065f46; font-size: 12px; font-weight: 700;
    padding: 4px 12px; border-radius: 20px; border: 1.5px solid #86efac;
}
.prebuild-clear {
    background: #fff; border: 1.5px solid #e5e7eb; border-radius: 6px;
    padding: 4px 10px; font-size: 11px; color: #6b7280; cursor: pointer;
    transition: all 0.2s;
}
.prebuild-clear:hover { border-color: #ef4444; color: #ef4444; }

/* Genre Grid */
.story-genre-grid { display: grid; grid-template-columns: repeat(6, 1fr); gap: 7px; }
.genre-btn {
    background: #f8fafc; border: 2px solid #e5e7eb; border-radius: 9px;
    padding: 9px 5px; cursor: pointer; transition: all 0.2s;
    display: flex; flex-direction: column; align-items: center; gap: 3px; font-size: 17px;
}
.genre-btn span { font-size: 10px; font-weight: 700; color: #374151; }
.genre-btn:hover { border-color: #7c3aed; transform: translateY(-2px); }
.genre-btn.active { background: linear-gradient(135deg, #7c3aed, #a855f7); border-color: #a855f7; }
.genre-btn.active span { color: #fff; }

/* Length Group */
.story-length-group { display: flex; gap: 7px; }
.length-btn {
    flex: 1; background: #f8fafc; border: 2px solid #e5e7eb; border-radius: 10px;
    padding: 9px 7px; cursor: pointer; transition: all 0.2s;
    display: flex; flex-direction: column; align-items: center; gap: 2px;
    font-size: 12px; font-weight: 700; color: #374151;
}
.length-btn small { font-size: 10px; color: #9ca3af; font-weight: 400; }
.length-btn:hover { border-color: #7c3aed; }
.length-btn.active { background: linear-gradient(135deg, #7c3aed, #a855f7); border-color: #a855f7; color: #fff; }
.length-btn.active small { color: #e9d5ff; }

/* Row 2 */
.story-row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }

/* Audience */
.story-audience-group { display: flex; gap: 5px; }
.audience-btn {
    flex: 1; background: #f8fafc; border: 2px solid #e5e7eb; border-radius: 8px;
    padding: 8px 5px; cursor: pointer; transition: all 0.2s;
    font-size: 11px; font-weight: 700; color: #374151; text-align: center;
}
.audience-btn:hover { border-color: #7c3aed; }
.audience-btn.active { background: linear-gradient(135deg, #7c3aed, #a855f7); border-color: #a855f7; color: #fff; }

/* Lang Grid */
.story-lang-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 5px; }
.lang-btn {
    background: #f8fafc; border: 2px solid #e5e7eb; border-radius: 7px;
    padding: 6px 8px; font-size: 11px; font-weight: 700; color: #374151;
    cursor: pointer; transition: all 0.2s; text-align: center;
}
.lang-btn:hover { border-color: #7c3aed; }
.lang-btn.active { background: linear-gradient(135deg, #7c3aed, #a855f7); border-color: #a855f7; color: #fff; }

/* Generate Button */
.story-generate-btn {
    width: 100%; background: linear-gradient(135deg, #7c3aed, #a855f7);
    color: #fff; border: none; border-radius: 14px; padding: 15px;
    font-size: 17px; font-weight: 800; cursor: pointer; transition: all 0.25s;
    box-shadow: 0 4px 16px rgba(124,58,237,0.35); margin-top: 4px;
}
.story-generate-btn:hover:not(:disabled) { transform: translateY(-2px); box-shadow: 0 8px 24px rgba(124,58,237,0.45); }
.story-generate-btn:disabled { opacity: 0.7; cursor: not-allowed; }

/* ===== PLACEHOLDER ===== */
.story-placeholder { display: flex; flex-direction: column; align-items: center; justify-content: center; min-height: 400px; text-align: center; gap: 10px; }
.ph-icon  { font-size: 56px; }
.ph-title { font-size: 16px; font-weight: 800; color: #374151; }
.ph-sub   { font-size: 13px; color: #9ca3af; margin-bottom: 16px; }
.ph-preview { display: flex; flex-direction: column; gap: 7px; width: 100%; max-width: 280px; }
.ph-line { height: 9px; background: #f3f4f6; border-radius: 5px; animation: ph-pulse 1.6s ease-in-out infinite; }
.ph-line.long   { width: 100%; }
.ph-line.medium { width: 75%; }
.ph-line.short  { width: 50%; }
@keyframes ph-pulse { 0%,100%{opacity:0.5} 50%{opacity:1} }

/* Loading */
.story-loading { display: flex; flex-direction: column; align-items: center; justify-content: center; min-height: 400px; gap: 14px; }
.loading-quill { margin-bottom: 4px; }
.quill-anim { font-size: 46px; animation: quill-bounce 0.8s ease-in-out infinite alternate; display: inline-block; }
@keyframes quill-bounce { from{transform:translateY(0) rotate(-5deg)} to{transform:translateY(-10px) rotate(5deg)} }
.loading-title { font-size: 16px; font-weight: 800; color: #374151; }
.loading-steps { display: flex; flex-direction: column; gap: 7px; width: 100%; max-width: 260px; }
.loading-step { font-size: 12px; color: #9ca3af; padding: 6px 14px; border-radius: 20px; transition: all 0.4s; }
.loading-step.active { color: #6d28d9; background: #ede9fe; font-weight: 600; }

/* Result Header */
.story-result-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; margin-bottom: 12px; padding-bottom: 12px; border-bottom: 2px solid #ede9fe; }
.story-title-box { flex: 1; }
.story-title-label { font-size: 10px; font-weight: 700; color: #9ca3af; text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 3px; }
.story-title-text  { font-size: 17px; font-weight: 800; color: #1f2937; line-height: 1.4; }
.story-actions-top { display: flex; align-items: center; gap: 5px; flex-shrink: 0; }
.word-count-badge  { font-size: 11px; font-weight: 700; padding: 3px 9px; background: #ede9fe; color: #6d28d9; border-radius: 20px; border: 1.5px solid #ddd6fe; }
.story-action-btn  { background: #fff; border: 2px solid #ddd6fe; border-radius: 8px; padding: 5px 11px; font-size: 12px; font-weight: 700; color: #6d28d9; cursor: pointer; transition: all 0.2s; }
.story-action-btn:hover { border-color: #7c3aed; background: #faf5ff; }
.story-action-btn.regenerate { background: linear-gradient(135deg,#7c3aed,#a855f7); color: #fff; border-color: #a855f7; }

/* ===== AUDIO BAR ===== */
.story-audio-bar {
    display: flex; align-items: center; justify-content: space-between; gap: 10px;
    background: linear-gradient(135deg, #1e1b4b, #312e81);
    border-radius: 12px; padding: 10px 14px; margin-bottom: 12px;
    flex-wrap: wrap;
}
.audio-bar-left  { display: flex; align-items: center; gap: 10px; }
.audio-play-btn  {
    width: 40px; height: 40px; border-radius: 50%;
    background: linear-gradient(135deg, #7c3aed, #a855f7);
    border: none; color: #fff; font-size: 16px;
    cursor: pointer; transition: all 0.2s; display: flex; align-items: center; justify-content: center;
    flex-shrink: 0; font-weight: 900;
}
.audio-play-btn:hover { transform: scale(1.1); box-shadow: 0 0 14px rgba(124,58,237,0.6); }
.audio-play-btn.playing { background: linear-gradient(135deg, #059669, #10b981); animation: pulse-ring 1.5s infinite; }
@keyframes pulse-ring { 0%{box-shadow:0 0 0 0 rgba(16,185,129,0.5)} 70%{box-shadow:0 0 0 8px rgba(16,185,129,0)} 100%{box-shadow:0 0 0 0 rgba(16,185,129,0)} }
.audio-info      { display: flex; flex-direction: column; gap: 1px; }
.audio-label     { font-size: 12px; font-weight: 700; color: #e9d5ff; }
.audio-status    { font-size: 10px; color: #a78bfa; }

.audio-bar-right { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.audio-speed-group { display: flex; gap: 4px; }
.speed-btn {
    background: rgba(255,255,255,0.1); border: 1px solid rgba(255,255,255,0.2);
    border-radius: 6px; padding: 4px 8px; font-size: 11px; font-weight: 700;
    color: #c4b5fd; cursor: pointer; transition: all 0.2s;
}
.speed-btn:hover { background: rgba(255,255,255,0.2); }
.speed-btn.active { background: #7c3aed; border-color: #7c3aed; color: #fff; }

.ambient-toggle-btn {
    background: rgba(255,255,255,0.08); border: 1.5px solid rgba(255,255,255,0.15);
    border-radius: 8px; padding: 5px 10px; font-size: 11px; font-weight: 700;
    color: #c4b5fd; cursor: pointer; transition: all 0.2s; white-space: nowrap;
}
.ambient-toggle-btn:hover { background: rgba(255,255,255,0.15); }
.ambient-toggle-btn.on { background: rgba(16,185,129,0.2); border-color: #10b981; color: #6ee7b7; }

/* Story Body */
.story-body-text {
    font-size: 15px; line-height: 1.9; color: #374151; white-space: pre-wrap;
    max-height: 440px; overflow-y: auto; padding: 14px;
    background: #faf5ff; border-radius: 12px; border: 2px solid #ede9fe;
    margin-bottom: 12px;
    scrollbar-width: thin; scrollbar-color: #ddd6fe #faf5ff;
}
.story-body-text::-webkit-scrollbar { width: 4px; }
.story-body-text::-webkit-scrollbar-track { background: #faf5ff; }
.story-body-text::-webkit-scrollbar-thumb { background: #ddd6fe; border-radius: 3px; }

/* Highlighted word during TTS */
.story-body-text .tts-highlight { background: #fde68a; border-radius: 3px; }

/* Footer Actions */
.story-footer-actions { display: flex; gap: 8px; }
.story-copy-full-btn,
.story-share-btn,
.story-download-btn {
    flex: 1; padding: 10px; border-radius: 10px;
    font-size: 13px; font-weight: 700; cursor: pointer; transition: all 0.2s; border: 2px solid;
}
.story-copy-full-btn { background: linear-gradient(135deg,#7c3aed,#a855f7); color: #fff; border-color: #a855f7; }
.story-copy-full-btn:hover { transform: translateY(-2px); }
.story-share-btn     { background: #25d366; border-color: #25d366; color: #fff; }
.story-share-btn:hover { background: #22c55e; }
.story-download-btn  { background: #fff; border-color: #ddd6fe; color: #6d28d9; }
.story-download-btn:hover { background: #faf5ff; border-color: #7c3aed; }

/* Error */
.story-error { display: flex; align-items: center; gap: 8px; padding: 20px; background: #fff5f5; border-radius: 12px; color: #dc2626; font-size: 14px; min-height: 80px; }

/* Info Box */
.info-box { background: linear-gradient(135deg,#faf5ff,#ede9fe); border-radius: 16px; padding: 26px; margin-bottom: 24px; border: 2px solid rgba(124,58,237,0.12); }
.info-box h4 { color: #4c1d95; font-size: 20px; margin-bottom: 16px; }
.info-grid   { display: grid; grid-template-columns: repeat(auto-fit,minmax(200px,1fr)); gap: 12px; }
.info-item   { background: #fff; border-radius: 12px; padding: 14px; font-size: 13px; color: #374151; line-height: 1.6; border: 2px solid rgba(124,58,237,0.1); }
.info-item strong { display: block; color: #7c3aed; font-size: 13px; font-weight: 700; margin-bottom: 3px; }

/* SEO */
.seo-content { padding: 70px 20px; background: #fff; }
.content-article { max-width: 900px; margin: 0 auto; line-height: 1.8; }
.content-article h2 { font-size: 26px; font-weight: 800; margin-top: 32px; margin-bottom: 14px; color: #333; }
.content-article h2:first-child { margin-top: 0; }
.content-article h3 { font-size: 19px; font-weight: 700; margin-top: 22px; margin-bottom: 10px; color: #444; }
.content-article p  { margin-bottom: 14px; color: #666; font-size: 16px; }
.content-article strong { color: #333; font-weight: 700; }

.story-wrapper {
    max-width: 100%;
    margin: 0 auto;
}
/* Responsive */
@media (max-width: 960px) { .story-grid { grid-template-columns: 1fr; } }
@media (max-width: 700px) {
    .prebuild-grid  { grid-template-columns: repeat(5, 1fr); }
    .story-genre-grid { grid-template-columns: repeat(4, 1fr); }
    .story-row-2    { grid-template-columns: 1fr; }
    .story-lang-grid { grid-template-columns: repeat(4, 1fr); }
    .story-footer-actions { flex-direction: column; }
    .audio-bar-right { width: 100%; }
}
@media (max-width: 480px) {
    .prebuild-grid { grid-template-columns: repeat(5, 1fr); }
    .story-genre-grid { grid-template-columns: repeat(3, 1fr); }
    .story-input-card, .story-output-card { padding: 14px; }
    .story-lang-grid { grid-template-columns: repeat(2, 1fr); }
}