:root{
  --bg:#000;
  --fg:#fff;
  --muted:rgba(255,255,255,.65);
  --border:rgba(255,255,255,.14);
  --accent:#FFD400;
  --danger:#ff4f6d;
  --radius:14px;
}

*{ box-sizing:border-box; }
html, body{ height:100%; }
body{
  margin:0;
  background:var(--bg);
  color:var(--fg);
  font-family:system-ui,-apple-system,Segoe UI,Roboto,Helvetica,Arial;
}
.hidden{ display:none !important; }

/* TOPBAR */
.topbar{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:12px;
  padding:12px 14px;
  border-bottom:1px solid var(--border);
  position:relative;
  z-index:10;
  background:#000;
}
.brand{ display:flex; align-items:center; }
.brand-logo{ width:40px; height:40px; }

.actions{ display:flex; gap:10px; align-items:center; }
.right{ display:flex; align-items:center; gap:12px; }
.meta{
  display:flex;
  align-items:center;
  gap:12px;
  font-size:12px;
  color:var(--muted);
  white-space:nowrap;
}
.link{
  border:none;
  background:none;
  color:var(--accent);
  font-weight:900;
  cursor:pointer;
  padding:6px 8px;
}
.link:hover{ text-decoration:underline; }

/* Buttons */
.btn{
  border:1px solid var(--border);
  background:rgba(255,255,255,.05);
  color:var(--accent);
  padding:10px 14px;
  border-radius:999px;
  font-weight:900;
  cursor:pointer;
}
.btn:hover{ filter:brightness(1.12); }
.btn-primary{
  border-color:rgba(255,212,0,.55);
  background:linear-gradient(90deg, rgba(255,212,0,.18), rgba(255,184,0,.14));
}
.btn.danger{
  border-color:rgba(255,79,109,.5);
  background:rgba(255,79,109,.16);
  color:#fff;
}
.btn.secondary{
  color:#fff;
  background:rgba(255,255,255,.04);
}
.btn.tiny{ padding:8px 10px; border-radius:12px; font-size:12px; }
.btn.chip{ background:rgba(255,255,255,.06); color:#fff; }

/* Mobile menu */
.menu-btn{
  display:none;
  border:1px solid var(--border);
  background:rgba(255,255,255,.05);
  color:var(--accent);
  padding:10px 12px;
  border-radius:12px;
  font-weight:900;
  cursor:pointer;
}
.menu-panel{
  position:absolute;
  top:60px;
  right:14px;
  width:min(280px, calc(100vw - 28px));
  border:1px solid var(--border);
  background:#000;
  border-radius:14px;
  padding:8px;
  display:flex;
  flex-direction:column;
  gap:8px;
  z-index:20;
}
.menu-item{
  width:100%;
  text-align:left;
  border:1px solid var(--border);
  background:rgba(255,255,255,.05);
  color:#fff;
  padding:10px 12px;
  border-radius:12px;
  font-weight:900;
  cursor:pointer;
}
.menu-item.btn-primary{ color:var(--accent); }
.menu-sep{ height:1px; background:rgba(255,255,255,.10); margin:4px 2px; }

/* Main */
.main{
  padding:14px;
  display:flex;
  flex-direction:column;
  gap:12px;
  min-height:calc(100vh - 70px);
}
.controls{
  display:flex;
  flex-wrap:wrap;
  gap:12px;
  align-items:center;
}
.ctrl{
  display:flex;
  align-items:center;
  gap:8px;
  border:1px solid var(--border);
  border-radius:14px;
  padding:8px 10px;
  background:rgba(255,255,255,.03);
}
.ctrl span{ font-size:12px; color:var(--muted); }
.ctrl input[type="range"]{ width:160px; }
.ctrl select{
  background:#000;
  color:#fff;
  border:1px solid rgba(255,255,255,.18);
  border-radius:10px;
  padding:6px 8px;
}
.val{
  font-size:12px;
  color:rgba(255,255,255,.8);
  min-width:24px;
  text-align:right;
}

/* Formatting bar */
.formatbar{
  display:flex;
  flex-wrap:wrap;
  gap:10px;
  align-items:center;
  border:1px solid var(--border);
  border-radius:14px;
  padding:10px;
  background:rgba(255,255,255,.03);
}
.fmt-group{ display:flex; gap:8px; align-items:center; flex-wrap:wrap; }
.fmt-label{ font-size:12px; color:var(--muted); margin-right:4px; }

.hint{ font-size:12px; color:var(--muted); }
.hint-link{
  color:var(--accent);
  font-weight:900;
  text-decoration:none;
}
.hint-link:hover{ text-decoration:underline; }

/* Guide card */
.guide-card{
  border:1px solid rgba(255,255,255,.12);
  border-radius:18px;
  background:rgba(255,255,255,.04);
  padding:20px 22px;
  display:flex;
  flex-direction:column;
  gap:14px;
  overflow:hidden;
}
.guide-card.hidden-guide{ display:none; }
.guide-step{
  display:flex;
  align-items:flex-start;
  gap:14px;
  font-size:15px;
  color:rgba(255,255,255,.75);
  line-height:1.4;
}
.guide-num{
  flex-shrink:0;
  width:26px;
  height:26px;
  border-radius:50%;
  background:rgba(255,212,0,.15);
  border:1px solid rgba(255,212,0,.35);
  color:var(--accent);
  font-weight:900;
  font-size:13px;
  display:flex;
  align-items:center;
  justify-content:center;
}

/* Viewer */
.viewer{
  flex:1 1 auto;
  min-height:40vh;
  border:1px solid var(--border);
  border-radius:var(--radius);
  overflow:hidden;
  position:relative;
  background:#000;
  transition: border-color .3s ease;
}
.viewer.is-playing{
  border-color: rgba(255,212,0,.5);
}

/* Play indicator */
.play-indicator{
  position:absolute;
  top:12px;
  right:14px;
  z-index:10;
  display:flex;
  align-items:center;
  gap:6px;
  font-size:11px;
  font-weight:900;
  color:var(--accent);
  letter-spacing:.08em;
  pointer-events:none;
}
.play-dot{
  width:8px;
  height:8px;
  border-radius:50%;
  background:var(--accent);
  animation: blink 1s ease-in-out infinite;
}
@keyframes blink{
  0%,100%{ opacity:1; }
  50%{ opacity:0.2; }
}

/* Editor scrollable */
.editor, .player{
  position:absolute;
  inset:0;
}
.editor{
  z-index:2;
  overflow:auto;
  -webkit-overflow-scrolling:touch;
  padding:0;
}
.player{ z-index:3; }

.editor-script{
  min-height:100%;
  padding:36px 22px 220px;
  font-size:40px;
  line-height:1.35;
  text-align:center;
  outline:none;
  color:#fff;
  white-space:pre-wrap;
  overflow-wrap:anywhere;
  word-break:break-word;
}

/* Player scroll */
.scroll-layer{
  position:absolute;
  inset:0;
  will-change:transform;
}
.mirror-layer{
  position:absolute;
  inset:0;
}
.viewer.mirrored .mirror-layer,
.present-viewer.mirrored .mirror-layer{
  transform:scaleX(-1);
  transform-origin:center;
}

.player-script{
  position:absolute;
  inset:0;
  padding:36px 22px 220px;
  font-size:40px;
  line-height:1.35;
  text-align:center;
  white-space:pre-wrap;
  overflow-wrap:anywhere;
  word-break:break-word;
  color:#fff;
}

/* SEO section */
.seo-section{
  margin-top:8px;
  padding:18px 20px;
  border:1px solid rgba(255,255,255,.07);
  border-radius:14px;
  background:rgba(255,255,255,.02);
}
.seo-title{
  font-size:14px;
  font-weight:900;
  color:rgba(255,255,255,.4);
  margin:0 0 6px;
}
.seo-text{
  font-size:13px;
  color:rgba(255,255,255,.3);
  line-height:1.6;
  margin:0;
}

/* About */
.modal{
  position:fixed;
  inset:0;
  background:rgba(0,0,0,.7);
  display:flex;
  align-items:center;
  justify-content:center;
  padding:16px;
  z-index:2000;
}
.modal-box{
  width:min(780px, 100%);
  max-height:82vh;
  overflow:auto;
  border:1px solid var(--border);
  border-radius:16px;
  background:#000;
  padding:14px;
}
.modal-head{
  display:flex;
  justify-content:space-between;
  align-items:center;
  gap:10px;
  padding-bottom:10px;
  border-bottom:1px solid rgba(255,255,255,.12);
}
.modal-title{ color:var(--accent); font-weight:900; }
.modal-body{ padding-top:10px; color:rgba(255,255,255,.9); line-height:1.5; }
.modal-body hr{ border:0; border-top:1px solid rgba(255,255,255,.12); margin:14px 0; }
.about-link{ color:var(--accent); font-weight:900; text-decoration:none; }
.about-link:hover{ text-decoration:underline; }

.about-hero{
  display:flex;
  gap:12px;
  align-items:center;
  margin-bottom:10px;
  padding:10px;
  border:1px solid rgba(255,255,255,.12);
  border-radius:14px;
  background:rgba(255,255,255,.03);
}
.about-photo{
  width:64px;
  height:64px;
  border-radius:16px;
  object-fit:cover;
  border:1px solid rgba(255,255,255,.14);
}
.about-name .name{ font-weight:900; color:var(--accent); }
.about-name .role{ font-size:12px; color:var(--muted); margin-top:2px; }

/* Accordion (Terms) */
.accordion{ margin:4px 0; }
.accordion-btn{
  width:100%;
  text-align:left;
  background:rgba(255,255,255,.04);
  border:1px solid rgba(255,255,255,.12);
  border-radius:12px;
  color:var(--accent);
  font-weight:900;
  font-size:14px;
  padding:12px 14px;
  cursor:pointer;
  display:flex;
  justify-content:space-between;
  align-items:center;
}
.accordion-btn:hover{ filter:brightness(1.1); }
.accordion-arrow{ transition: transform .2s ease; }
.accordion-btn[aria-expanded="true"] .accordion-arrow{ transform:rotate(180deg); }
.accordion-body{
  padding:14px 4px 4px;
  font-size:14px;
  color:rgba(255,255,255,.75);
  line-height:1.6;
}
.accordion-body ul{ padding-left:18px; margin:8px 0; }
.accordion-body li{ margin-bottom:4px; }

/* Share buttons */
.share-row{
  display:flex;
  flex-wrap:wrap;
  gap:8px;
  margin-top:10px;
}
.share-btn{
  font-size:13px;
  padding:8px 14px;
  border-radius:999px;
  color:#fff;
  border-color:rgba(255,255,255,.2);
}

/* Present mode */
.present{
  position:fixed;
  inset:0;
  background:#000;
  z-index:1500;
  display:flex;
  flex-direction:column;
}
.present-bar{
  display:flex;
  align-items:center;
  gap:10px;
  flex-wrap:wrap;
  padding:12px;
  border-bottom:1px solid rgba(255,255,255,.12);
}
.p-ctrl{
  display:flex;
  align-items:center;
  gap:8px;
  border:1px solid rgba(255,255,255,.14);
  border-radius:14px;
  padding:8px 10px;
  background:rgba(255,255,255,.03);
}
.p-ctrl span{ font-size:12px; color:var(--muted); }
.p-ctrl input[type="range"]{ width:160px; }

.present-viewer{
  flex:1 1 auto;
  position:relative;
  overflow:hidden;
  background:#000;
}
.present-script{
  position:absolute;
  inset:0;
  padding:60px 50px 260px;
  font-size:56px;
  line-height:1.3;
  text-align:center;
  white-space:pre-wrap;
  overflow-wrap:anywhere;
  word-break:break-word;
  color:#fff;
}

/* Responsive */
@media (max-width: 980px){
  .desktop-actions{ display:none; }
  .menu-btn{ display:inline-flex; }
  .viewer{ min-height:35vh; }
  .editor-script, .player-script{ font-size:34px; }
  .guide-step{ font-size:14px; }
  .ctrl input[type="range"]{ width:120px; }
}

/* About modal titles & links */
.modal-body h3{
  color:var(--accent);
  font-weight:900;
  margin-top:18px;
  margin-bottom:8px;
}
.modal-body a.about-link{
  color:#ffffff;
  text-decoration:none;
  font-weight:500;
}
.modal-body a.about-link:hover{ text-decoration:underline; }

/* Import button */
#importBtn{
  background:transparent;
  border:1px solid var(--accent);
  color:var(--accent);
}
#importBtn:hover{ filter:brightness(1.05); }
#importBtn:focus-visible{
  outline:2px solid var(--accent);
  outline-offset:2px;
}
