:root{
  --bg:#0b0e14;
  --panel:#121826;
  --muted:#9aa3b2;
  --text:#e6edf3;
  --accent:#4fb3ff;
  --accent-2:#9bffb0;
  --danger:#ff6b6b;
  --border:#1f2937;
  --highlight:#1f3a5a;
  --render-fs: 1rem; /* adjustable rendered section font-size */
}

*{box-sizing:border-box}
html,body{height:100%}
body{
  margin:0;
  font:16px/1.5 system-ui, -apple-system, Segoe UI, Roboto, "Noto Sans", "Helvetica Neue", Arial, "Apple Color Emoji","Segoe UI Emoji";
  color:var(--text);
  background:linear-gradient(180deg, #0b0e14 0%, #0d1220 100%);
}

/* Content column stays within the left 80vw so it never sits under the toolbar lane */
.content-wrap{
  width:80vw;
  max-width:80vw;
  /* keep it flush to the left; remaining 20vw is free (15vw toolbar + ~5vw gutter) */
  margin:0;
}

.topbar{
  position:sticky; top:0; z-index:5;
  background:rgba(11,14,20,0.8); backdrop-filter: blur(8px);
  border-bottom:1px solid var(--border);
  padding:16px 20px;
}
.topbar h1{margin:0 0 6px 0; font-weight:700; font-size:20px}
.topbar .sub{margin:0; color:var(--muted); font-size:14px}

.layout{display:grid; grid-template-columns: 1fr; gap:16px; padding:16px 20px}

.editor textarea{
  width:100%; min-height:180px; resize:vertical;
  border:1px solid var(--border); border-radius:12px;
  background:var(--panel); color:var(--text);
  padding:14px; outline:none;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,0.02);
}
.hint{color:var(--muted); font-size:12px; margin-top:8px}

.render .render-head{display:flex; align-items:baseline; gap:12px}
.render h2{margin:0 0 4px 0; font-size:18px}
.meta{color:var(--muted); font-size:12px}
.rendered{
  margin-top:10px; padding:14px;
  border:1px dashed var(--border); border-radius:12px;
  background:rgba(18,24,38,0.6);
  min-height:140px;
  font-size: var(--render-fs);
  transition: font-size 120ms ease;
}

/* Sections */
.section{
  padding:2px 4px; border-radius:8px;
  display:inline-block; margin:2px 4px 6px 0;
  transition: background 120ms ease, outline-color 120ms ease, box-shadow 120ms ease;
  box-shadow: 0 0 0 0 rgba(79,179,255,0);
}
.section[data-lang^="zh"], .section[data-lang^="ja"], .section[data-lang^="ko"]{
  letter-spacing: .02em;
}
.section:hover{
  background:rgba(79,179,255,0.08);
}

/* Speak state */
.speakable .section{
  outline:2px dashed rgba(79,179,255,.6);
  cursor:pointer;
}
.section.speaking{
  background:rgba(79,179,255,.14);
  outline:2px solid var(--accent);
  box-shadow: 0 0 0 6px rgba(79,179,255,0.12);
}

/* Toolbar */
.toolbar{
  position:fixed; right:0; top:5vh; z-index:9;
  width:15vw;
  display:flex; flex-direction:column; gap:8px;
  background:rgba(18,24,38,0.9); border:1px solid var(--border);
  border-radius:14px; padding:10px;
  box-shadow: 0 10px 30px rgba(0,0,0,.35);
}
.toolbar hr{
  border:none; height:1px; background:var(--border); margin:6px 0;
}
.tool-btn{
  appearance:none; border:none; border-radius:10px;
  padding:10px 12px; font-size:24px; line-height:1; color:var(--text);
  background:#101625; cursor:pointer;
  transition: transform 80ms ease, background 120ms ease, box-shadow 120ms ease;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,0.03);
}
.tool-btn:hover{ background:#142038 }
.tool-btn:active{ transform: translateY(1px) }
.tool-btn.primary{ background:#0f1f36 }
.tool-btn.primary:hover{ background:#122544 }
.tool-btn.rate-toggle.active{
  outline:2px solid var(--accent);
  box-shadow: 0 0 0 6px rgba(79,179,255,0.12);
}

/* Utilities */
.sr-only{
  position:absolute !important; width:1px; height:1px;
  padding:0; margin:-1px; overflow:hidden; clip:rect(0,0,0,0);
  white-space:nowrap; border:0;
}

/* Modal */
.modal-backdrop{
  position:fixed; inset:0; display:none; place-items:center;
  background:rgba(0,0,0,0.55); z-index:20; padding:16px;
}
.modal-backdrop.open{ display:grid }
.modal{
  width:min(720px, 100%); background:var(--panel); border:1px solid var(--border);
  border-radius:16px; box-shadow: 0 20px 60px rgba(0,0,0,.45); padding:16px;
}
.modal-head{ display:flex; justify-content:space-between; align-items:center; margin-bottom:8px}
.settings-grid{
  display:grid; grid-template-columns: 1fr 2fr auto; gap:10px 12px; margin-top:8px;
}
.settings-grid label{ align-self:center; color:var(--muted) }
.settings-grid select{
  width:100%; padding:8px; border-radius:10px; border:1px solid var(--border);
  background:#101625; color:var(--text);
}
.settings-grid .play-sample{
  align-self:center;
  padding:8px 10px;
  min-width:44px;
}
.modal-actions{ margin-top:14px; display:flex; justify-content:flex-end; gap:8px }

