

@import url('https://fonts.googleapis.com/css2?family=Poppins:wght@300;400;500;600;700&display=swap');
@import url('https://fonts.googleapis.com/css2?family=Baloo+2:wght@400;500;600;700&display=swap');

:root {
  --bg: #0a1122;
  --bg-gradient-end: #050b17;
  --panel-bg: linear-gradient(160deg, rgba(255, 255, 255, 0.04), rgba(255, 255, 255, 0.02));
  --accent: #6db3ff;
  --accent-gradient: linear-gradient(135deg, var(--accent), #8ac2ff);
  --muted: rgba(230, 240, 255, 0.7);
  --text-primary: #f0f7ff;
  --glass-border: rgba(255, 255, 255, 0.08);
  --input-bg: rgba(0, 5, 15, 0.3);
  --card-bg: rgba(10, 25, 47, 0.25);
  
  --radius-lg: 20px;
  --radius-md: 14px;
  --radius-sm: 8px;
  --max-width: 1100px;
  --card-padding: 28px;
  --shadow-soft: 0 10px 30px rgba(2, 8, 20, 0.4);
  --shadow-strong: 0 20px 50px rgba(2, 8, 20, 0.6);
  --glow: 0 0 30px rgba(109, 179, 255, 0.15);
  --transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
}

/*Global Styles*/
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  scroll-behavior: smooth;
}

body {
  min-height: 100vh;
  margin: 0;
  font-family: "Poppins", system-ui, -apple-system, sans-serif;
  background: linear-gradient(180deg, var(--bg) 0%, var(--bg-gradient-end) 100%);
  color: var(--text-primary);
  -webkit-font-smoothing: antialiased;
  line-height: 1.6;
  overflow-x: hidden;
}

.app {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 40px 32px;
  position: relative;
}

/* Background Elts */
.app::before {
  content: "";
  position: fixed;
  top: -50vh;
  left: -50vw;
  width: 200vw;
  height: 200vh;
  background: radial-gradient(circle at 70% 30%, rgba(109, 179, 255, 0.03) 0%, transparent 50%);
  z-index: -1;
  pointer-events: none;
}

/* Header and brand*/
.header {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  margin-bottom: 48px;
  position: relative;
}

.brand {
  display: flex;
  gap: 24px;
  align-items: center;
  position: relative;
  z-index: 2;
}

.logo-image {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid rgba(255, 255, 255, 0.1);
  box-shadow: var(--shadow-soft);
  transition: var(--transition);
}

.logo-image:hover {
  transform: rotate(5deg) scale(1.05);
  box-shadow: 0 15px 35px rgba(50, 110, 160, 0.4);
}

.app-title {
  margin: 0;
  font-size: 2.4rem;
  font-weight: 700;
  letter-spacing: 0.5px;
  font-family: "Baloo 2", cursive;
  background: linear-gradient(to right, #f0f7ff, #c2e1ff);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  text-shadow: 0 2px 10px rgba(109, 179, 255, 0.2);
}

.app-sub {
  margin: 6px 0 0 0;
  color: var(--muted);
  font-size: 1.1rem;
  font-weight: 300;
  letter-spacing: 0.5px;
}


/* main layout */
.main {
  display: grid;
  grid-template-columns: 380px 1fr;
  gap: 32px;
  align-items: start;
}

/*cards*/
.card {
  background: var(--card-bg);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-radius: var(--radius-lg);
  padding: var(--card-padding);
  border: 1px solid var(--glass-border);
  box-shadow: var(--shadow-strong);
  transition: var(--transition);
  position: relative;
  overflow: hidden;
}

.card::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(109, 179, 255, 0.4), transparent);
}

.card:hover {
  transform: translateY(-5px);
  box-shadow: 0 25px 60px rgba(2, 8, 20, 0.7);
}

.controls .label {
  display: block;
  margin-bottom: 12px;
  color: var(--muted);
  font-weight: 500;
  font-size: 1.05rem;
  letter-spacing: 0.3px;
}

/* input and control styles */
.input {
  width: 100%;
  padding: 16px 18px;
  border-radius: var(--radius-md);
  border: 1px solid var(--glass-border);
  background: var(--input-bg);
  color: inherit;
  font-size: 1rem;
  font-family: "Poppins", sans-serif;
  outline: none;
  transition: var(--transition);
}

.input:focus {
  border-color: var(--accent);
  box-shadow: var(--glow);
  background: rgba(0, 10, 25, 0.4);
}

.input::placeholder {
  color: rgba(230, 240, 255, 0.5);
  font-weight: 300;
}

.row {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-top: 20px;
}

/* story Type Cards*/
.types {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  margin: 20px 0;
}

.type-card {
  background: rgba(15, 35, 65, 0.3);
  border: 1px solid rgba(255, 255, 255, 0.05);
  width: 100%;
  padding: 16px;
  border-radius: var(--radius-md);
  text-align: center;
  color: var(--muted);
  cursor: pointer;
  transition: var(--transition);
  display: flex;
  flex-direction: column;
  gap: 14px;
  align-items: center;
  justify-content: flex-start;
  position: relative;
  overflow: hidden;
}

.type-card::after {
  content: "";
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: var(--accent-gradient);
  transform: scaleX(0);
  transform-origin: left;
  transition: transform 0.4s ease;
}

.type-card:hover::after {
  transform: scaleX(1);
}

.type-card img {
  width: 100%;
  aspect-ratio: 1 / 1;
  object-fit: cover;
  object-position: center;
  border-radius: var(--radius-sm);
  transition: var(--transition);
  filter: drop-shadow(0 5px 15px rgba(0, 0, 0, 0.3));
}


.type-card span {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--muted);
  transition: var(--transition);
  letter-spacing: 0.3px;
}

.type-card:hover {
  background: rgba(25, 55, 95, 0.3);
  border-color: rgba(109, 179, 255, 0.2);
  transform: translateY(-3px);
}

.type-card:hover img {
  transform: scale(1.05);
}

.type-card:hover span {
  color: var(--text-primary);
}

.type-card[aria-pressed="true"] {
  background: rgba(109, 179, 255, 0.08);
  border-color: rgba(109, 179, 255, 0.3);
  box-shadow: var(--glow);
}

.type-card[aria-pressed="true"] img {
  transform: scale(1.08);
  filter: drop-shadow(0 0 15px rgba(109, 179, 255, 0.3));
}

.type-card[aria-pressed="true"] span {
  color: var(--accent);
  font-weight: 700;
}

/* -generate button styling*/
.primary-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-top: 28px;
  width: 100%;
  padding: 18px;
  border-radius: var(--radius-md);
  background: var(--accent-gradient);
  color: #0a1122;
  border: none;
  font-weight: 600;
  font-size: 1.1rem;
  cursor: pointer;
  box-shadow: 0 15px 35px rgba(12, 30, 60, 0.4);
  transition: var(--transition);
  position: relative;
  overflow: hidden;
  letter-spacing: 0.5px;
}

.primary-btn::before {
  content: "";
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
  transition: 0.5s;
}

.primary-btn:hover {
  transform: translateY(-3px);
  box-shadow: 0 20px 45px rgba(50, 110, 160, 0.5);
}

.primary-btn:hover::before {
  left: 100%;
}

.primary-btn:active {
  transform: translateY(1px);
}

/* story display panel*/
.story {
  position: relative;
}

.story::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(109, 179, 255, 0.4), transparent);
}

.story-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--glass-border);
}

.story-header h2 {
  margin: 0;
  font-size: 1.4rem;
  font-weight: 600;
  color: var(--text-primary);
  font-family: "Baloo 2", cursive;
  letter-spacing: 0.3px;
}

.player {
  display: flex;
  gap: 10px;
}

.icon-btn {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--glass-border);
  color: var(--muted);
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: var(--transition);
}

.icon-btn:hover {
  background: var(--accent);
  color: var(--bg);
  transform: scale(1.1);
}

.story-body {
  margin-top: 20px;
  min-height: 250px;
  max-height: 65vh;
  overflow: auto;
  padding: 8px 4px;
  font-size: 1.1rem;
  line-height: 1.8;
  font-weight: 300;
}

.story-body p {
  margin-bottom: 1.2em;
}

.story-body::-webkit-scrollbar {
  width: 6px;
}

.story-body::-webkit-scrollbar-track {
  background: rgba(0, 0, 0, 0.1);
  border-radius: 3px;
}

.story-body::-webkit-scrollbar-thumb {
  background: rgba(109, 179, 255, 0.4);
  border-radius: 3px;
}

.story-body::-webkit-scrollbar-thumb:hover {
  background: var(--accent);
}

/* sleep overlay goodnight screen and timer*/
.sleep-overlay { 
  position: fixed; 
  inset: 0; 
  background: rgba(0, 0, 0, 0); 
  display: flex; 
  align-items: center; 
  justify-content: center; 
  pointer-events: none; 
  transition: background-color 2s ease-in-out; 
  z-index: 100; 
  opacity: 0; 
  visibility: hidden; 
}

.sleep-overlay.active { 
  pointer-events: auto; 
  opacity: 1; 
  visibility: visible; 
  background-color: rgba(6, 12, 22, 0.98); 
}

.sleep-centre { 
  text-align: center; 
  color: #fff; 
  opacity: 0; 
  transform: scale(0.9); 
  transition: opacity 1.5s ease-in-out 1s, transform 1.5s ease-in-out 1s; 
}

.sleep-overlay.active .sleep-centre { 
  opacity: 1; 
  transform: scale(1); 
}

.moon-large { 
  width: 160px; 
  height: 160px; 
  border-radius: 50%; 
  background: linear-gradient(180deg, #e6f2ff, #b3d9ff); 
  margin: 0 auto 20px; 
  box-shadow: 0 0 80px rgba(109, 179, 255, 0.4); 
  animation: gentlePulse 4s infinite alternate;
}

@keyframes gentlePulse {
  0% { transform: scale(1); box-shadow: 0 0 80px rgba(109, 179, 255, 0.4); }
  100% { transform: scale(1.05); box-shadow: 0 0 100px rgba(109, 179, 255, 0.6); }
}

/* timer buttons */
.timer-row { 
  flex-direction: column; 
  align-items: flex-start; 
  gap: 12px; 
  margin-top: 28px; 
}

.timer-options { 
  display: flex; 
  gap: 10px; 
  width: 100%; 
}

.timer-btn { 
  flex-grow: 1; 
  padding: 12px; 
  border-radius: var(--radius-sm); 
  border: 1px solid var(--glass-border); 
  background: var(--input-bg); 
  color: var(--muted); 
  font-size: 0.95rem; 
  font-family: inherit; 
  cursor: pointer; 
  transition: var(--transition); 
}

.timer-btn:hover { 
  background: rgba(255, 255, 255, 0.1); 
  transform: translateY(-2px);
}

.timer-btn.active-timer { 
  background: var(--accent); 
  color: var(--bg); 
  font-weight: 600; 
  border-color: var(--accent); 
  box-shadow: 0 5px 15px rgba(109, 179, 255, 0.3);
}

/* countdown display */
.timer-display { 
  font-size: 0.95rem; 
  color: var(--muted); 
  background-color: rgba(0, 0, 0, 0.3); 
  padding: 6px 12px; 
  border-radius: var(--radius-sm); 
  font-family: monospace; 
  visibility: hidden; 
  opacity: 0; 
  transition: var(--transition); 
  border: 1px solid var(--glass-border);
}

.timer-display.visible { 
  visibility: visible; 
  opacity: 1; 
}

/* voice dropdown */
.voice-row { 
  margin-top: 28px; 
  flex-direction: column; 
  align-items: flex-start; 
  gap: 12px; 
}

.custom-select-wrapper { 
  position: relative; 
  width: 100%; 
}

#voiceSelect { 
  display: none; 
}

.custom-select-display { 
  display: flex; 
  justify-content: space-between; 
  align-items: center; 
  padding: 16px 18px; 
  border-radius: var(--radius-md); 
  border: 1px solid var(--glass-border); 
  background: var(--input-bg); 
  color: var(--muted); 
  font-size: 1rem; 
  cursor: pointer; 
  user-select: none; 
  transition: var(--transition);
}

.custom-select-display:hover {
  background: rgba(0, 10, 25, 0.4);
}

.custom-arrow { 
  width: 0; 
  height: 0; 
  border-left: 6px solid transparent; 
  border-right: 6px solid transparent; 
  border-top: 6px solid var(--muted); 
  transition: var(--transition); 
}

.voice-row.open .custom-arrow { 
  transform: rotate(180deg); 
}

.custom-select-options { 
  position: absolute; 
  bottom: 100%; 
  left: 0; 
  right: 0; 
  margin-bottom: 8px; 
  padding: 8px; 
  list-style: none; 
  background: #0c1f3d; 
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-radius: var(--radius-md); 
  border: 1px solid var(--glass-border); 
  z-index: 20; 
  max-height: 250px; 
  overflow-y: auto; 
  opacity: 0; 
  visibility: hidden; 
  transform: translateY(10px); 
  transition: var(--transition); 
  box-shadow: var(--shadow-strong); 
}

.voice-row.open .custom-select-options { 
  opacity: 1; 
  visibility: visible; 
  transform: translateY(0); 
}

.custom-select-options li { 
  padding: 12px; 
  border-radius: var(--radius-sm); 
  cursor: pointer; 
  color: var(--muted); 
  font-size: 0.95rem; 
  white-space: nowrap; 
  overflow: hidden; 
  text-overflow: ellipsis; 
  transition: var(--transition);
}

.custom-select-options li:hover, 
.custom-select-options li.selected { 
  background-color: var(--accent); 
  color: var(--bg); 
  font-weight: 600; 
}

/* --- Footer Styles --- */

footer {
  text-align: center;
  margin-top: 1px;
  padding: 10px;
  color: #888;
  border-top: 1px solid #333;
}

footer a {
  color: #58a6ff; 
  font-weight: bold; 
  text-decoration: none;
  transition: color 0.3s ease;
}

footer a:hover {
  color: #fff; 
  text-decoration: underline;
}

/* make site responsive */
@media (max-width: 900px) {
  .app {
    padding: 32px 24px;
  }
  
  .main {
    grid-template-columns: 1fr;
    gap: 28px;
  }
  
  .types {
    grid-template-columns: repeat(3, 1fr);
  }
  
  .header {
    justify-content: center;
    text-align: center;
    flex-direction: column;
    gap: 20px;
  }
  
  .brand {
    flex-direction: column;
    gap: 16px;
    text-align: center;
  }
  
}

@media (max-width: 600px) {
  .app {
    padding: 28px 20px;
  }
  
  .types {
    grid-template-columns: repeat(2, 1fr);
  }
  
  .app-title {
    font-size: 2rem;
  }
  
  .logo-image {
    width: 70px;
    height: 70px;
  }
  
  .card {
    padding: 24px 20px;
  }
  
  .timer-options {
    flex-wrap: wrap;
  }
  
  .timer-btn {
    flex: 1 0 calc(50% - 10px);
  }
}

@media (max-width: 400px) {
  .types {
    grid-template-columns: 1fr;
  }
  
  .app-title {
    font-size: 1.8rem;
  }
  
  .logo-image {
    width: 60px;
    height: 60px;
  }
}