:root{
  --bg:#0f1115; --panel:#161a22; --text:#e7ecf3; --muted:#9aa4b2; --accent:#4f8cff; --accent-2:#66ddb8;
  --border:#232a35; --dot:#4a5568; --dot-strong:#8da2fb; --warn:#ffcf66;
}
*{box-sizing:border-box}
html,body{height:100%}
body{margin:0;font-family:system-ui,-apple-system,Segoe UI,Roboto,Ubuntu,Cantarell,Noto Sans,sans-serif;background:var(--bg);color:var(--text)}
.app-header{padding:20px 16px;border-bottom:1px solid var(--border);background:linear-gradient(180deg,#10131a,#0f1115)}
.app-header h1{margin:0 0 6px 0;font-weight:700;font-size:22px}
.subtitle{margin:0;color:var(--muted);font-size:13px}
.container{max-width:1100px;margin:0 auto;padding:16px;display:grid;gap:16px}
.panel{background:var(--panel);border:1px solid var(--border);border-radius:10px;padding:14px}
.row{display:flex;gap:12px;align-items:center;flex-wrap:wrap}
.model-row{align-items:flex-end}
.input-row{margin-top:8px}
label{font-size:13px;color:var(--muted)}
input[type=number],select,textarea{background:#0b0e14;color:var(--text);border:1px solid var(--border);padding:8px;border-radius:8px}
select{min-width:260px}
input[type=number]{width:180px}
.model-info input{min-width:180px}
button.primary{background:var(--accent);border:0;padding:10px 14px;border-radius:8px;color:white;font-weight:600;cursor:pointer}
button.primary:hover{filter:brightness(1.05)}
.input-group{display:flex;flex-direction:column;gap:6px}
.radio-group{display:flex;gap:14px}
.context-note{margin-top:8px;color:var(--warn);font-size:13px}

.stats h2,.panel h2{margin:0 0 8px 0;font-size:16px}
.stats-grid{display:grid;grid-template-columns:repeat(auto-fit,minmax(150px,1fr));gap:12px}
.label{color:var(--muted);font-size:12px}
.value{font-weight:700;font-size:18px}

.scale-bar{position:relative;height:12px;background:#0b0e14;border:1px solid var(--border);border-radius:999px;margin-bottom:10px;overflow:hidden}
.scale-fill{height:100%;background:linear-gradient(90deg,var(--accent),var(--accent-2));width:0%}

.pages-count-block{margin-bottom:10px}

.context-bar{position:relative;height:10px;background:#0b0e14;border:1px solid var(--border);border-radius:999px;margin:6px 0 2px 0;overflow:hidden}
.context-fill{height:100%;width:0%;background:linear-gradient(90deg,#4caf50,#cddc39)}

.page-preview{display:flex;align-items:center;gap:14px;margin:10px 0}
.page-box{width:220px;height:300px;background:#f6f7fb;border:1px solid #d5d9e2;border-radius:6px;box-shadow:inset 0 0 0 1px rgba(0,0,0,0.02)}
.page-lines{padding:14px;height:100%;display:flex;flex-direction:column;gap:6px}
.page-line{height:6px;border-radius:3px;background:#cfd6e6;opacity:.35}
.page-line.filled{background:#aab6dd;opacity:1}
.page-badge{color:var(--muted);font-size:12px}

.pages-grid{display:grid;grid-template-columns:repeat(auto-fill, minmax(10px, 1fr));gap:4px;max-height:320px;overflow:auto;padding:8px;background:#0b0e14;border:1px solid var(--border);border-radius:8px}
.page-dot{width:10px;height:10px;background:var(--dot);border-radius:2px}
.page-dot.strong{background:var(--dot-strong)}
.group-note{margin-top:8px;color:var(--muted);font-size:12px}

.books-list{display:grid;grid-template-columns:repeat(auto-fit,minmax(220px,1fr));gap:8px}
.book-item{padding:10px;border:1px solid var(--border);border-radius:8px;background:#0b0e14}
.book-item .title{font-weight:600}
.book-item .ratio{color:var(--muted);font-size:12px}

#outputText{width:100%;min-height:220px;resize:vertical}
.text-note{margin-bottom:8px;color:var(--muted);font-size:12px}
.muted{color:var(--muted);font-size:12px}

.app-footer{padding:12px 16px;border-top:1px solid var(--border);color:var(--muted);font-size:12px;text-align:center}

@media (max-width: 800px){
  .stats-grid{grid-template-columns:repeat(2,1fr)}
}
