:root{
  --bg:#f5f1e6;
  --panel:rgba(255,255,255,.66);
  --panel-2:rgba(255,255,255,.92);
  --line:#ded6c4;
  --line-2:#c7bca3;
  --text:#201c13;
  --text-2:#4e4838;
  --text-3:#857b65;
  --accent:#4d6b1f;
  --accent-soft:#e9efdd;
  --accent-line:#c9d6ab;
  --gold:#d9a441;
  --good:#4f9d53;
  --mid:#d6a649;
  --bad:#c45a4a;
  --sans:'Inter',-apple-system,BlinkMacSystemFont,'Segoe UI',Roboto,sans-serif;
  --serif:'Instrument Serif',Georgia,'Times New Roman',serif;
  --mono:'IBM Plex Mono',ui-monospace,SFMono-Regular,Menlo,Consolas,monospace;
}
*{margin:0;padding:0;box-sizing:border-box}
[hidden]{display:none !important}
body.boot *{transition:none !important}
html,body{height:100%}
body{
  background:var(--bg); color:var(--text); font-family:var(--sans);
  -webkit-font-smoothing:antialiased;
  background-image:radial-gradient(125% 90% at 50% 0%, #fbf8f0 0%, #f5f1e6 55%, #e9e2d1 100%);
  background-attachment:fixed;
}
:focus-visible{outline:2px solid var(--accent); outline-offset:2px; border-radius:6px}
button{font-family:inherit; color:inherit; background:none; border:none}
.sr{position:absolute; width:1px; height:1px; overflow:hidden; clip:rect(0 0 0 0); white-space:nowrap}
.srlive{position:absolute; width:1px; height:1px; overflow:hidden; clip:rect(0 0 0 0); white-space:nowrap}

.page{display:flex; flex-direction:column; min-height:100vh}

/* ---------- top bar ---------- */
.bar{
  display:flex; justify-content:space-between; align-items:center; gap:12px;
  padding:max(14px, env(safe-area-inset-top)) 20px 0; flex:none;
}
.home,.icon{
  display:inline-flex; align-items:center; gap:7px; height:38px;
  color:var(--text); text-decoration:none; font:500 14px/1 var(--sans);
  background:var(--panel); border:1px solid var(--line); border-radius:999px;
  cursor:pointer; transition:background .15s, border-color .15s;
}
.home{padding:0 14px 0 10px}
.home span{font-family:var(--serif); font-size:18px; letter-spacing:.01em}
.icon{width:38px; justify-content:center; padding:0}
.home:hover,.icon:hover{background:#fff; border-color:var(--line-2)}

/* ---------- layout ---------- */
main{
  flex:1; display:grid; grid-template-columns:minmax(0,1fr) 322px;
  gap:24px; padding:10px 20px max(26px, env(safe-area-inset-bottom));
  align-items:start; max-width:1148px; margin:0 auto; width:100%;
}
.stage{display:flex; flex-direction:column; gap:16px; min-width:0}
.titleblock{max-width:700px; padding:6px 2px 0}
.kicker{font-size:11.5px; font-weight:600; letter-spacing:.15em; text-transform:uppercase; color:var(--text-3)}
h1{
  font-family:var(--serif); font-weight:400; font-size:clamp(32px, 4.3vw, 54px);
  line-height:1; letter-spacing:-.01em; margin:4px 0 8px;
}
.sub{font-size:14.5px; line-height:1.6; color:var(--text-2); max-width:68ch}
.sub b{font-weight:600; color:var(--text)}
.lbl{
  font-size:11px; font-weight:600; letter-spacing:.12em; text-transform:uppercase;
  color:var(--text-3); display:flex; justify-content:space-between; align-items:baseline; gap:8px;
}
.lbl .hint{font-weight:500; letter-spacing:0; text-transform:none; color:var(--text-3); font-size:11.5px}

/* ---------- composer ---------- */
.composer{
  background:var(--panel-2); border:1px solid var(--line); border-radius:16px;
  padding:12px 13px 11px; display:flex; flex-direction:column; gap:9px;
}
.chips{display:flex; flex-wrap:wrap; gap:6px}
.chip{
  padding:0 11px; height:30px; border-radius:999px; cursor:pointer; white-space:nowrap;
  background:#fff; border:1px solid var(--line); color:var(--text-2);
  font:500 12.5px/1 var(--sans); transition:background .14s, border-color .14s, color .14s;
}
.chip:hover{border-color:var(--line-2); color:var(--text)}
.chip.is-on{background:var(--text); border-color:var(--text); color:#f7f3ec}
#text{
  width:100%; resize:vertical; min-height:150px;
  font-family:var(--sans); font-size:16px; line-height:1.68; color:var(--text);
  background:#fffdf9; border:1px solid var(--line); border-radius:11px;
  padding:13px 15px; transition:border-color .14s;
}
#text:focus{outline:none; border-color:var(--accent-line); box-shadow:0 0 0 3px var(--accent-soft)}
#text::placeholder{color:#a79d87}
.crow{display:flex; justify-content:space-between; align-items:center; gap:12px; min-height:20px}
.src{font-size:12px; line-height:1.45; color:var(--text-3); min-width:0; font-variant-numeric:tabular-nums}
.link{
  color:var(--accent); cursor:pointer; font:600 12.5px/1 var(--sans);
  text-decoration:underline; text-underline-offset:3px; flex:none;
}
.link:hover{color:#36500f}

/* ---------- skyline ---------- */
.skygrp{display:flex; flex-direction:column; gap:7px}
.skywrap{
  position:relative; background:var(--panel-2); border:1px solid var(--line); border-radius:14px;
  padding:14px 14px 0;
}
.skyline{
  display:flex; align-items:flex-end; gap:4px; min-height:140px;
  overflow-x:auto; overflow-y:hidden; padding-bottom:10px; scroll-behavior:smooth;
  -webkit-overflow-scrolling:touch;
}
.skyline:empty::before{
  content:'Nothing to show yet — type a sentence or two above.';
  color:var(--text-3); font-size:13px; align-self:center; padding:0 2px 10px;
}
.bar{
  flex:none; width:12px; min-width:12px; border-radius:4px 4px 2px 2px; cursor:pointer;
  box-shadow:0 1px 0 rgba(0,0,0,.08) inset; transition:transform .12s, box-shadow .12s;
}
.bar:hover{transform:translateY(-2px)}
.bar.is-on{box-shadow:0 0 0 2px var(--text), 0 1px 0 rgba(0,0,0,.08) inset}
.baseline{height:1px; background:var(--line-2)}
.skyline + .baseline{margin:0 14px}

/* ---------- rendered text ---------- */
.readgrp{display:flex; flex-direction:column; gap:7px}
.rendered{
  background:var(--panel-2); border:1px solid var(--line); border-radius:14px;
  padding:16px 18px; font-size:15.5px; line-height:1.75; color:var(--text-2);
  white-space:pre-wrap; word-wrap:break-word; max-height:340px; overflow-y:auto;
}
.rendered:empty::before{content:'—'; color:var(--text-3)}
.rendered .sent{border-radius:3px; transition:background-color .5s}
.rendered .sent.flash{background-color:var(--accent-soft)}
.rendered mark.w{
  background:#f3dfa7; color:var(--text); padding:1px 2px; border-radius:3px;
  box-shadow:0 1px 0 var(--gold);
}

/* ---------- aside panel ---------- */
.panel{
  display:flex; flex-direction:column; gap:14px; position:sticky; top:12px;
  background:var(--panel); border:1px solid var(--line); border-radius:16px;
  padding:15px 15px 13px;
}
.grp{display:flex; flex-direction:column; gap:8px}
.note{font-size:11.5px; line-height:1.5; color:var(--text-3)}

.readout{
  border-radius:12px; padding:13px 14px; border:1px solid var(--accent-line);
  background:var(--accent-soft);
}
.readout .big{
  display:block; font:400 34px/1.05 var(--serif); color:var(--text); margin-bottom:4px;
  letter-spacing:.01em;
}
.readout .dim{color:var(--text-2); font-size:12.5px; font-weight:500}

.stats{display:grid; grid-template-columns:1fr auto; gap:5px 10px; font-size:12.5px}
.stats dt{color:var(--text-3)}
.stats dd{font:600 12.5px/1.3 var(--mono); color:var(--text); text-align:right; font-variant-numeric:tabular-nums}

input[type=range]{
  -webkit-appearance:none; appearance:none; width:100%; height:26px;
  background:transparent; cursor:pointer; display:block;
}
input[type=range]::-webkit-slider-runnable-track{height:5px; border-radius:99px; background:var(--line-2)}
input[type=range]::-moz-range-track{height:5px; border-radius:99px; background:var(--line-2)}
input[type=range]::-webkit-slider-thumb{
  -webkit-appearance:none; appearance:none; width:19px; height:19px; margin-top:-7px;
  border-radius:50%; background:var(--accent); border:2px solid #fff;
  box-shadow:0 1px 4px rgba(0,0,0,.28);
}
input[type=range]::-moz-range-thumb{
  width:16px; height:16px; border-radius:50%; background:var(--accent); border:2px solid #fff;
}

.foot{
  font-size:11.5px; line-height:1.6; color:var(--text-3);
  border-top:1px solid var(--line); padding-top:12px;
}

/* ---------- about dialog ---------- */
dialog{
  border:none; padding:0; background:transparent; max-width:min(700px, 92vw);
  max-height:86vh; margin:auto;
}
dialog::backdrop{background:rgba(32,28,19,.5); backdrop-filter:blur(3px)}
.about{
  position:relative; background:#fffdf9; border:1px solid var(--line);
  border-radius:18px; padding:26px 28px 24px; overflow-y:auto; max-height:86vh;
  box-shadow:0 30px 60px -28px rgba(0,0,0,.4);
}
.about h2{
  font-family:var(--serif); font-weight:400; font-size:30px; line-height:1.08;
  margin:4px 0 14px; color:var(--text);
}
.about p{font-size:14.5px; line-height:1.68; color:var(--text-2); margin-bottom:12px}
.about p b{color:var(--text); font-weight:600}
.about mark.w{
  background:#f3dfa7; color:var(--text); padding:1px 2px; border-radius:3px; box-shadow:0 1px 0 var(--gold);
}
.about .fine{
  font-size:12.5px; color:var(--text-3); border-top:1px solid var(--line);
  padding-top:12px; margin-top:4px; margin-bottom:0;
}
.x{
  position:absolute; top:14px; right:14px; width:32px; height:32px; cursor:pointer;
  display:flex; align-items:center; justify-content:center; color:var(--text-3);
  background:var(--panel-2); border:1px solid var(--line); border-radius:999px;
}
.x:hover{color:var(--text); border-color:var(--line-2)}

/* ---------- narrow ---------- */
@media (max-width:920px){
  main{grid-template-columns:minmax(0,1fr); gap:16px; padding:8px 14px max(24px, env(safe-area-inset-bottom))}
  .panel{position:static}
  h1{font-size:clamp(28px, 8vw, 40px)}
  .sub{font-size:14px}
  .skyline{min-height:120px}
  .rendered{max-height:260px; padding:14px 15px}
  .about{padding:22px 20px 20px; border-radius:15px}
  .about h2{font-size:25px}
}
@media (max-width:420px){
  #text{min-height:130px; font-size:15px}
  .skyline{min-height:104px}
  .readout .big{font-size:28px}
}
@media (prefers-reduced-motion:reduce){
  *{transition:none !important; animation:none !important}
}
