:root{
  --bg:#0b1020; --card:#111a33; --muted:#9fb0d0; --text:#eaf0ff;
  --accent:#6ee7ff; --accent2:#a78bfa; --border:rgba(255,255,255,.10);
  --shadow:0 12px 40px rgba(0,0,0,.38);
  --radius:20px;
}
*{box-sizing:border-box}
html,body{height:100%}
body{
  margin:0;
  font-family: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Arial, "Apple Color Emoji","Segoe UI Emoji";
  background:
    radial-gradient(1200px 700px at 25% 10%, rgba(110,231,255,.16), transparent 60%),
    radial-gradient(900px 600px at 80% 30%, rgba(167,139,250,.14), transparent 55%),
    var(--bg);
  color:var(--text);
  overscroll-behavior:none;
}
a{color:var(--accent); text-decoration:none}
a:hover{text-decoration:underline}
#app{height:100%; min-height:100dvh; display:flex; flex-direction:column}
.topbar{
  position:sticky; top:0; z-index:5;
  backdrop-filter: blur(10px);
  background:rgba(11,16,32,.72);
  border-bottom:1px solid var(--border);
}
.topbar-inner{
  max-width:860px; margin:0 auto;
  padding:10px 12px 10px;
  display:flex; align-items:center; justify-content:space-between; gap:12px;
}
.brand{display:flex; flex-direction:column; gap:0px}
.brand .title{font-size:14px; font-weight:700}
.brand .sub{font-size:12px; color:var(--muted)}
.controls{display:flex; align-items:center; gap:8px; flex-wrap:wrap; justify-content:flex-end}
.pill{
  border:1px solid var(--border);
  background:rgba(27,42,85,.55);
  color:var(--text);
  padding:8px 10px;
  border-radius:999px;
  font-size:12px;
  cursor:pointer;
  user-select:none;
}
.pill:active{transform:translateY(1px)}
.pill.primary{border-color:rgba(110,231,255,.35); background:rgba(110,231,255,.14)}
.counter{
  font-size:12px; color:var(--muted);
  padding:8px 10px; border-radius:999px;
  border:1px solid var(--border); background:rgba(255,255,255,.03);
}
.stage{flex:1; display:flex; align-items:center; justify-content:center; padding:12px}
.card{
  width:min(860px, 100%);
  height:min(740px, calc(100dvh - 78px));
  border-radius:var(--radius);
  border:1px solid var(--border);
  background:linear-gradient(180deg, rgba(17,26,51,.92), rgba(17,26,51,.74));
  box-shadow:var(--shadow);
  padding:18px 18px 16px;
  display:flex; flex-direction:column; gap:12px;
  position:relative; overflow:hidden;
}
.card::before{
  content:"";
  position:absolute; inset:-2px;
  background:
    radial-gradient(700px 320px at 20% 10%, rgba(110,231,255,.14), transparent 55%),
    radial-gradient(650px 300px at 85% 20%, rgba(167,139,250,.12), transparent 55%);
  pointer-events:none;
}

.hero{
  width:100%;
  height:220px;
  border-radius:18px;
  overflow:hidden;
  border:1px solid rgba(255,255,255,.10);
  background:rgba(255,255,255,.03);
}
.hero img{
  width:100%;
  height:100%;
  display:block;
  object-fit:cover;
}
.card > *{position:relative}
.metaRow{display:flex; gap:8px; align-items:center; flex-wrap:wrap}
.badge{
  font-size:11px; padding:6px 10px; border-radius:999px;
  border:1px solid var(--border);
  background:rgba(255,255,255,.03);
  color:var(--muted);
}
.badge.type{
  color:var(--text);
  border-color:rgba(167,139,250,.30);
  background:rgba(167,139,250,.12);
}
.h1{margin:0; font-size:20px; line-height:1.25}
.hook{margin:0; font-size:14px; line-height:1.45}
.summary{
  margin:0;
  font-size:14px;
  color:var(--muted);
  line-height:1.55;
  white-space:pre-line;
}

.content{
  display:flex;
  flex-direction:column;
  gap:12px;
  overflow:auto;
  padding-right:6px;
}

.content::-webkit-scrollbar{width:8px}
.content::-webkit-scrollbar-thumb{background:rgba(255,255,255,.10); border-radius:999px}

.hook{font-weight:650; color:var(--text)}

.footer{
  margin-top:auto;
  display:flex;
  flex-direction:column;
  gap:10px;
  padding-top:6px;
}

.footerRow{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:10px;
  flex-wrap:wrap;
}

.metaBottom{opacity:0.95}

/* Modal sheet */
.sheet{
  position:fixed; inset:0;
  display:none;
  align-items:flex-end;
  justify-content:center;
  background:rgba(0,0,0,.55);
  z-index:40;
}
.sheet.show{display:flex}
.panel{
  width:min(860px, 100%);
  max-height:calc(100vh - 40px);
  border-radius:18px 18px 0 0;
  border:1px solid var(--border);
  background:linear-gradient(180deg, rgba(17,26,51,.98), rgba(17,26,51,.90));
  box-shadow:var(--shadow);
  padding:14px;
  overflow:auto;
}
.panelHead{display:flex; align-items:center; justify-content:space-between; gap:10px}
.panelTitle{font-size:14px; font-weight:800}
.panelClose{cursor:pointer; user-select:none; padding:6px 10px; border-radius:999px; border:1px solid var(--border); background:rgba(255,255,255,.03)}
.panelClose:active{transform:translateY(1px)}
.panelBody{margin-top:10px; display:grid; gap:12px}
.panelHint{font-size:12px; color:var(--muted); line-height:1.4}
.panelRow{display:grid; gap:6px}
.label{font-size:12px; color:var(--muted)}
.file{width:100%}
.textarea{
  width:100%;
  min-height:140px;
  resize:vertical;
  background:rgba(255,255,255,.04);
  border:1px solid var(--border);
  color:var(--text);
  border-radius:14px;
  padding:10px 12px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  font-size:12px;
  line-height:1.45;
  outline:none;
}
.panelActions{display:flex; gap:10px; flex-wrap:wrap; justify-content:flex-end}
.btn.danger{border-color:rgba(251,113,133,.35); background:rgba(251,113,133,.12)}
.btn{
  border:1px solid var(--border);
  background:rgba(27,42,85,.62);
  color:var(--text);
  padding:10px 12px;
  border-radius:14px;
  cursor:pointer;
  font-size:12px;
}
.btn.primary{border-color:rgba(110,231,255,.35); background:rgba(110,231,255,.14)}
.btn:active{transform:translateY(1px)}
.hint{font-size:12px; color:var(--muted)}
.toast{
  position:fixed; left:50%; transform:translateX(-50%);
  bottom:16px; z-index:50;
  background:rgba(0,0,0,.72);
  border:1px solid var(--border);
  color:var(--text);
  padding:10px 12px;
  border-radius:999px;
  font-size:12px;
  display:none;
  max-width:min(560px, calc(100vw - 20px));
  text-align:center;
}


.summary + .summary{ margin-top:10px; }


/* Mobile fit: one card per screen */
@media (max-width: 600px){
  /* Make one card fit the phone screen */
  .topbar-inner{padding:6px 8px;}
  .brand .title{font-size:12px; line-height:1.1;}
  .controls{gap:6px;}
  /* swipe is primary on mobile */
  #prevBtn,#nextBtn{display:none;}
  /* keep controls compact */
  .pill{padding:6px 8px; font-size:11px;}
  .pillText span{display:none;}
  .counter{display:none;}
  .stage{padding:6px;}
  .card{
    height:calc(100dvh - 52px);
    padding:12px 12px 10px;
    border-radius:18px;
    gap:10px;
  }
  .hero{height:125px; border-radius:16px;}
  .badge{font-size:10px; padding:5px 8px;}
  .h1{font-size:18px; line-height:1.18;}
  .hook{font-size:13px; line-height:1.35;}
  .summary{font-size:13px; line-height:1.45;}
  .content{gap:8px;}
  .btn{padding:8px 10px; font-size:12px;}
  .hint{display:none;}
}
