:root{
  --bg:#f6f8fc;
  --card:#ffffff;
  --card2:#fbfcff;
  --text:#1b2333;
  --muted:#5b6478;
  --line:#e4e8f1;
  --accent:#2a6df4;
  --accent2:#2e9d4d;
  --shadow: 0 12px 28px rgba(16,24,40,.10);
  --radius:18px;
}

*{box-sizing:border-box}
html,body{height:100%}
body{
  margin:0;
  font-family: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial;
  background:
    radial-gradient(1100px 560px at 20% 0%, rgba(42,109,244,.10), transparent 60%),
    radial-gradient(900px 520px at 85% 20%, rgba(46,157,77,.08), transparent 55%),
    var(--bg);
  color:var(--text);
}

.container{
  width:min(1000px, calc(100% - 36px));
  margin:0 auto;
}

.topbar{
  position: sticky;
  top: 0;
  backdrop-filter: blur(10px);
  background: rgba(246,248,252,.80);
  border-bottom: 1px solid rgba(228,232,241,.85);
  z-index: 10;
}
.topbar .container{
  display:flex;
  align-items:center;
  justify-content:space-between;
  padding:10px 0;
}
.brand{display:flex; gap:12px; align-items:center}
.logo{
  width:38px; height:38px; border-radius:12px;
  background: linear-gradient(135deg, rgba(42,109,244,.18), rgba(46,157,77,.12));
  display:grid; place-items:center;
  box-shadow: var(--shadow);
}
.brand-title{font-weight:700; letter-spacing:.2px}
.brand-subtitle{font-size:12px; color:var(--muted); margin-top:2px}
.nav{display:flex; gap:10px}
.pill{
  text-decoration:none; color:var(--muted);
  border:1px solid rgba(228,232,241,.95);
  background: rgba(255,255,255,.75);
  padding:6px 10px; border-radius:999px;
  transition: all .15s ease;
}
.pill:hover{color:var(--text); border-color: rgba(42,109,244,.35)}

.card{
  margin-top:0;
  padding:16px;
  background: linear-gradient(180deg, rgba(255,255,255,.98), rgba(251,252,255,.98));
  border:1px solid rgba(228,232,241,.95);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.h1{margin:0 0 4px 0; font-size:20px}
.h2{margin:0; font-size:18px}
.muted{color:var(--muted); margin:0}
.small{font-size:12px}

.controls{margin-top:6px}
.label{display:block; font-size:13px; color:var(--muted); margin:0 0 8px}

.prompt-row{
  display:flex;
  align-items:center;
  gap:10px;
  flex-wrap:wrap;
}

.prompt-label{
  font-size:13px;
  color:var(--muted);
  white-space:nowrap;
  /* Nudge the label a touch upward to avoid visually colliding with the input border */
  transform: translateY(-2px);
}

.prompt-row .input{
  flex:1;
  min-width: 260px;
}
.input{
  width:100%;
  padding:12px 12px;
  border-radius:14px;
  border:1px solid rgba(228,232,241,.95);
  background: rgba(255,255,255,.95);
  color:var(--text);
  outline:none;
}
.input:focus{border-color: rgba(42,109,244,.55); box-shadow: 0 0 0 3px rgba(42,109,244,.12)}
.buttons{display:flex; gap:10px; margin-top:12px; flex-wrap:wrap}
.btn{
  padding:11px 14px;
  border-radius:14px;
  border:1px solid rgba(228,232,241,.95);
  background: rgba(255,255,255,.95);
  color:var(--text);
  cursor:pointer;
  transition: all .15s ease;
}
.btn:hover{transform: translateY(-1px); border-color: rgba(42,109,244,.35)}
.btn:active{transform: translateY(0)}
.btn-primary{
  background: linear-gradient(135deg, rgba(42,109,244,.16), rgba(42,109,244,.07));
  border-color: rgba(42,109,244,.40);
}

.story-card{padding:0; display:flex; flex-direction:column; flex:1; min-height:0}
.story-header{
  padding:16px 18px;
  border-bottom:1px solid rgba(228,232,241,.95);
  display:flex;
  align-items:baseline;
  justify-content:space-between;
  gap:12px;
}

/* Scrollable story window */
.story-window{
  padding:18px;
  line-height:1.65;
  flex:1;
  min-height:0;
  overflow-y: auto;
  scroll-behavior: smooth;
  background: linear-gradient(180deg, rgba(255,255,255,.98), rgba(251,252,255,.98));
}

.story-paragraph{
  margin: 0 0 12px 0;
}

@keyframes paragraphFlash{
  0%{background: rgba(42,109,244,.12); box-shadow: 0 0 0 3px rgba(42,109,244,.10)}
  100%{background: transparent; box-shadow: none}
}

.story-paragraph.is-new{
  border-radius: 12px;
  padding: 6px 8px;
  margin-left: -8px;
  margin-right: -8px;
  animation: paragraphFlash 1.4s ease-out 1;
}

@media (prefers-reduced-motion: reduce){
  .story-paragraph.is-new{animation:none}
}

.empty{
  color:var(--muted);
  padding:14px;
  border:1px dashed rgba(228,232,241,.95);
  border-radius:16px;
  background: rgba(246,248,252,.75);
}

.footer{
  padding:24px 0 34px;
  color: rgba(91,100,120,.95);
  font-size:12px;
}


/* Layout: keep everything on one screen; scroll only inside the story window */
body{
  min-height:100vh;
  display:flex;
  flex-direction:column;
  overflow:hidden;
}

main.container{
  flex:1;
  display:flex;
  flex-direction:column;
  gap:8px;
  padding:8px 0;
  overflow:hidden;
}

.footer{
  flex:0 0 auto;
}

/* HTMX busy state */
body.htmx-request,
body.htmx-request *{
  cursor: wait !important;
}

.btn:disabled{
  opacity:.60;
  cursor:not-allowed !important;
}
