/* ===== KIDS STORY TIME ===== */
.ks-wrapper{margin-bottom:28px}

/* Characters Animation Bar */
.ks-characters{display:flex;justify-content:center;gap:16px;padding:16px;background:linear-gradient(135deg,#fef3c7,#fde68a,#fef3c7);border-radius:16px;margin-bottom:20px;overflow:hidden;position:relative}
.ks-char{font-size:28px;animation:ks-bounce 2s ease-in-out infinite;cursor:default;user-select:none}
.ks-char:nth-child(1){animation-delay:0s}
.ks-char:nth-child(2){animation-delay:.25s}
.ks-char:nth-child(3){animation-delay:.5s}
.ks-char:nth-child(4){animation-delay:.75s}
.ks-char:nth-child(5){animation-delay:1s}
.ks-char:nth-child(6){animation-delay:1.25s}
.ks-char:nth-child(7){animation-delay:1.5s}
.ks-char:nth-child(8){animation-delay:1.75s}
@keyframes ks-bounce{0%,100%{transform:translateY(0) scale(1)}50%{transform:translateY(-10px) scale(1.15)}}

/* Layout */
.ks-layout{display:grid;grid-template-columns:320px 1fr;gap:22px}

/* Controls */
.ks-controls{background:#fff;border:2px solid #fde68a;border-radius:20px;padding:20px;position:sticky;top:80px;max-height:92vh;overflow-y:auto;scrollbar-width:thin;scrollbar-color:#fde68a #fff}
.ks-controls::-webkit-scrollbar{width:4px}
.ks-controls::-webkit-scrollbar-thumb{background:#fde68a;border-radius:3px}
.ks-section{margin-bottom:16px;padding-bottom:16px;border-bottom:2px solid #fef9c3}
.ks-section:last-of-type{border-bottom:none;margin-bottom:0}
.ks-section-title{font-size:12px;font-weight:800;color:#92400e;margin-bottom:10px;letter-spacing:.3px}

/* Input */
.ks-input{width:100%;border:2px solid #fde68a;border-radius:10px;padding:10px 14px;font-size:14px;font-family:inherit;outline:none;transition:border-color .2s;box-sizing:border-box;color:#1f2937;background:#fffbeb}
.ks-input:focus{border-color:#f59e0b}

/* Age Buttons */
.ks-age-btns{display:flex;flex-wrap:wrap;gap:5px}
.ks-age-btn{background:#fef9c3;border:2px solid #fde68a;border-radius:8px;padding:6px 12px;font-size:14px;font-weight:800;color:#92400e;cursor:pointer;transition:all .2s;min-width:36px;text-align:center}
.ks-age-btn:hover{border-color:#f59e0b;background:#fef3c7}
.ks-age-btn.active{background:linear-gradient(135deg,#f59e0b,#d97706);border-color:#d97706;color:#fff}

/* Theme Grid */
.ks-theme-grid{display:grid;grid-template-columns:repeat(2,1fr);gap:6px}
.ks-theme-btn{background:#fef9c3;border:2px solid #fde68a;border-radius:10px;padding:8px 6px;font-size:13px;font-weight:700;color:#92400e;cursor:pointer;transition:all .2s;text-align:center;display:flex;flex-direction:column;align-items:center;gap:2px}
.ks-theme-btn span{font-size:11px;font-weight:600}
.ks-theme-btn:hover{border-color:#f59e0b;background:#fef3c7;transform:scale(1.02)}
.ks-theme-btn.active{background:linear-gradient(135deg,#f59e0b,#d97706);border-color:#d97706;color:#fff}
.ks-theme-btn.active span{color:#fff}

/* Length Buttons */
.ks-length-btns{display:flex;gap:6px}
.ks-len-btn{flex:1;background:#fef9c3;border:2px solid #fde68a;border-radius:9px;padding:8px 4px;font-size:11px;font-weight:700;color:#92400e;cursor:pointer;transition:all .2s;text-align:center;display:flex;flex-direction:column;align-items:center;gap:2px}
.ks-len-btn small{font-size:9px;color:#a16207;font-weight:400}
.ks-len-btn:hover{border-color:#f59e0b}
.ks-len-btn.active{background:linear-gradient(135deg,#f59e0b,#d97706);border-color:#d97706;color:#fff}
.ks-len-btn.active small{color:#fef3c7}

/* Lang Buttons */
.ks-lang-btns{display:flex;gap:6px}
.ks-lang-btn{flex:1;background:#fef9c3;border:2px solid #fde68a;border-radius:9px;padding:9px;font-size:12px;font-weight:700;color:#92400e;cursor:pointer;transition:all .2s;text-align:center}
.ks-lang-btn:hover{border-color:#f59e0b}
.ks-lang-btn.active{background:linear-gradient(135deg,#f59e0b,#d97706);border-color:#d97706;color:#fff}

/* Generate Button */
.ks-generate-btn{width:100%;background:linear-gradient(135deg,#f59e0b,#ef4444,#8b5cf6);color:#fff;border:none;border-radius:14px;padding:16px;font-size:18px;font-weight:900;cursor:pointer;transition:all .3s;box-shadow:0 4px 20px rgba(245,158,11,.4);display:flex;align-items:center;justify-content:center;gap:10px;animation:ks-glow 2s ease-in-out infinite alternate}
@keyframes ks-glow{from{box-shadow:0 4px 20px rgba(245,158,11,.4)}to{box-shadow:0 6px 28px rgba(139,92,246,.5)}}
.ks-generate-btn:hover:not(:disabled){transform:translateY(-2px) scale(1.02)}
.ks-generate-btn:disabled{opacity:.7;cursor:not-allowed;animation:none}

/* Audio Box */
.ks-audio-box{background:linear-gradient(135deg,#f0fdf4,#dcfce7);border:2px solid #86efac;border-radius:14px;padding:14px;margin-top:14px}
.ks-audio-title{font-size:12px;font-weight:800;color:#166534;margin-bottom:10px}
.ks-audio-controls{display:flex;gap:8px;margin-bottom:10px}
.ks-audio-btn{flex:1;background:#22c55e;color:#fff;border:none;border-radius:9px;padding:9px;font-size:13px;font-weight:700;cursor:pointer;transition:all .2s}
.ks-audio-btn:hover{transform:translateY(-1px);box-shadow:0 3px 10px rgba(34,197,94,.4)}
.ks-speed-row,.ks-voice-row{display:flex;align-items:center;gap:8px;font-size:11px;color:#166534;font-weight:600;margin-top:6px}
.ks-speed-row label,.ks-voice-row label{min-width:45px}
.ks-speed-row input{flex:1}
.ks-voice-select{flex:1;border:1.5px solid #86efac;border-radius:7px;padding:5px 8px;font-size:11px;outline:none;background:#fff;color:#166534;cursor:pointer;width:100%;max-width:180px}

/* Story paragraph animation */
@keyframes ks-fadein{from{opacity:0;transform:translateY(12px)}to{opacity:1;transform:translateY(0)}}
.ks-story-text p{animation:ks-fadein .5s ease forwards;opacity:0}
.ks-story-text p:nth-child(1){animation-delay:.1s}
.ks-story-text p:nth-child(2){animation-delay:.3s}
.ks-story-text p:nth-child(3){animation-delay:.5s}
.ks-story-text p:nth-child(4){animation-delay:.7s}
.ks-story-text p:nth-child(5){animation-delay:.9s}
.ks-story-text p:nth-child(6){animation-delay:1.1s}
.ks-story-text p:nth-child(7){animation-delay:1.3s}
.ks-story-text p:nth-child(n+8){animation-delay:1.5s}

/* Word highlight during TTS */
.ks-word{display:inline;transition:background .15s,color .15s}
.ks-word.active{background:#fef08a;color:#92400e;border-radius:4px;padding:1px 3px;font-weight:700}

/* Moral animation */
@keyframes ks-moral-pop{0%{transform:scale(0.8);opacity:0}60%{transform:scale(1.05)}100%{transform:scale(1);opacity:1}}
.ks-moral{animation:ks-moral-pop .6s ease 1.6s both}

/* Floating emojis in story header */
.ks-story-header{padding:28px 30px 20px;background:linear-gradient(135deg,#fef3c7,#fde68a);text-align:center;position:relative;overflow:hidden}
.ks-story-header h2{font-size:24px;font-weight:900;color:#92400e;margin:0 0 6px;position:relative;z-index:1}
.ks-story-header p{font-size:13px;color:#a16207;margin:0;position:relative;z-index:1}
.ks-float-emoji{position:absolute;font-size:22px;opacity:0.2;animation:ks-float-around 6s ease-in-out infinite}
.ks-float-emoji:nth-child(1){top:10%;left:5%;animation-delay:0s}
.ks-float-emoji:nth-child(2){top:20%;right:8%;animation-delay:1s}
.ks-float-emoji:nth-child(3){bottom:15%;left:12%;animation-delay:2s}
.ks-float-emoji:nth-child(4){bottom:10%;right:6%;animation-delay:3s}
@keyframes ks-float-around{0%,100%{transform:translateY(0) rotate(0deg)}50%{transform:translateY(-8px) rotate(10deg)}}

/* Story Panel */
.ks-story-panel{display:flex;flex-direction:column}

/* Placeholder */
.ks-placeholder{background:linear-gradient(135deg,#fffbeb,#fef3c7);border:3px dashed #fde68a;border-radius:20px;padding:50px 30px;display:flex;flex-direction:column;align-items:center;gap:16px;text-align:center;min-height:400px;justify-content:center}
.ks-ph-emojis{display:flex;gap:12px;font-size:36px;animation:ks-bounce 2s ease-in-out infinite}
.ks-ph-title{font-size:22px;font-weight:800;color:#92400e}
.ks-ph-sub{font-size:14px;color:#a16207;max-width:380px}
.ks-example-themes{display:flex;flex-direction:column;gap:8px;width:100%;max-width:360px;margin-top:8px}
.ks-ex-card{background:#fff;border:2px solid #fde68a;border-radius:10px;padding:10px 14px;font-size:13px;font-weight:700;color:#92400e;cursor:pointer;transition:all .2s;text-align:left}
.ks-ex-card:hover{border-color:#f59e0b;background:#fef3c7;transform:translateX(4px)}

/* Loading */
.ks-loading{background:linear-gradient(135deg,#fffbeb,#fef3c7);border:3px solid #fde68a;border-radius:20px;padding:60px 30px;display:flex;flex-direction:column;align-items:center;gap:16px;text-align:center;min-height:400px;justify-content:center}
.ks-loading-chars{display:flex;gap:16px;font-size:40px}
.ks-loading-chars .ks-lc{animation:ks-bounce 1s ease-in-out infinite}
.ks-loading-chars .ks-lc:nth-child(1){animation-delay:0s}
.ks-loading-chars .ks-lc:nth-child(2){animation-delay:.33s}
.ks-loading-chars .ks-lc:nth-child(3){animation-delay:.66s}
.ks-loading-text{font-size:20px;font-weight:800;color:#92400e}
.ks-loading-sub{font-size:13px;color:#a16207}
.ks-loading-bar{width:200px;height:8px;background:#fde68a;border-radius:10px;overflow:hidden}
.ks-loading-fill{height:100%;background:linear-gradient(135deg,#f59e0b,#ef4444);border-radius:10px;animation:ks-fill 3s ease-in-out infinite}
@keyframes ks-fill{0%{width:0%}50%{width:80%}100%{width:95%}}

/* Story Content */
.ks-story-content{background:#fff;border:3px solid #fde68a;border-radius:20px;overflow:hidden}
.ks-story-header{padding:28px 30px 20px;background:linear-gradient(135deg,#fef3c7,#fde68a);text-align:center}
.ks-story-header h2{font-size:24px;font-weight:900;color:#92400e;margin:0 0 6px}
.ks-story-header p{font-size:13px;color:#a16207;margin:0}
.ks-story-text{padding:28px 32px;font-size:17px;line-height:1.9;color:#1f2937;font-family:Georgia, serif}
.ks-story-text p{margin:0 0 18px}
.ks-story-text p:last-child{margin:0}

/* Highlighted word during TTS */
.ks-word-highlight{background:#fef3c7;border-radius:3px;padding:1px 2px;transition:background .1s}

/* Story Footer */
.ks-story-footer{padding:20px 30px;background:#fef9c3;border-top:2px solid #fde68a}
.ks-moral{background:#fff;border:2px solid #fde68a;border-radius:10px;padding:14px;font-size:14px;color:#92400e;font-weight:600;margin-bottom:14px;text-align:center}
.ks-moral::before{content:'💡 Moral: ';font-weight:800}
.ks-story-actions{display:flex;flex-wrap:wrap;gap:8px}
.ks-action-btn{background:#f9fafb;border:2px solid #e5e7eb;border-radius:9px;padding:9px 16px;font-size:13px;font-weight:700;color:#374151;cursor:pointer;transition:all .2s}
.ks-action-btn:hover{border-color:#f59e0b;color:#92400e}
.ks-action-btn.primary{background:linear-gradient(135deg,#f59e0b,#d97706);border-color:#d97706;color:#fff}
.ks-action-btn.green{background:#22c55e;border-color:#22c55e;color:#fff}

/* Error */
.ks-error{display:flex;align-items:center;gap:10px;padding:20px;background:#fef2f2;border:2px solid #fecaca;border-radius:14px;color:#dc2626;font-size:14px}

/* Info Box */
.info-box{background:linear-gradient(135deg,#fffbeb,#fef3c7);border-radius:16px;padding:24px;border:2px solid #fde68a}
.info-box h4{color:#92400e;font-size:20px;margin-bottom:14px}
.info-grid{display:grid;grid-template-columns:repeat(auto-fit,minmax(190px,1fr));gap:10px}
.info-item{background:#fff;border-radius:11px;padding:13px;font-size:13px;color:#374151;line-height:1.6;border:2px solid #fde68a}
.info-item strong{display:block;color:#d97706;font-size:13px;font-weight:700;margin-bottom:3px}

@media(max-width:900px){.ks-layout{grid-template-columns:1fr}.ks-controls{position:static;max-height:none}}
@media(max-width:500px){.ks-characters{gap:8px}.ks-char{font-size:22px}.ks-theme-grid{grid-template-columns:repeat(2,1fr)}}
