:root {
    --tblr-font-sans-serif: "Trebuchet MS", "Verdana", sans-serif;
    --tblr-primary: #397251;
    --sidebar-width: 238px;
    --cell-size: 6.78mm;
    --grid-width: 189.84mm;
}
body { background: #f3f2ed; color: #393f36; }
.navbar.sidebar {
    width: var(--sidebar-width);
    background: linear-gradient(165deg, #fdfcf7, #eaece1);
    border-right: 1px solid #dbded0;
    padding: 24px 16px;
}
.sidebar-heading { width: 100%; display: flex; align-items: center; justify-content: space-between; }
.brand { display: flex; gap: 10px; align-items: center; color: #4f473d; text-decoration: none; font-size: 15px; line-height: 1.3; }
.brand:hover { color: #397251; text-decoration: none; }
.brand strong { display: block; font-size: 22px; font-weight: 700; letter-spacing: -.5px; }
.brand-mark { width: 48px; height: 48px; flex-shrink: 0; }
.sidebar .navbar-collapse { width: 100%; flex-direction: column; align-items: stretch; }
.menu-caption { margin: 42px 12px 12px; font-size: 10px; font-weight: 700; letter-spacing: 1.8px; color: #777e68; }
.sidebar .nav { gap: 6px; }
.sidebar .nav-link { color: #525b49; border-radius: 8px; padding: 12px 9px; font-size: 13px; display: flex; gap: 10px; align-items: center; }
.sidebar .nav-link:hover { background: #e2e8d9; }
.sidebar .nav-link.active { color: #fff; background: #397251; }
.exercise-mark { min-width: 27px; font-size: 15px; font-weight: 700; text-align: center; }
.sidebar-note { color: #818674; font-size: 12px; line-height: 1.7; margin: 36px 12px 0; }
.app-main { margin-left: var(--sidebar-width); padding: 28px 32px 40px; min-width: 0; }
.exercise-heading { margin-bottom: 20px; }
.exercise-heading .page-pretitle { color: #73816a; font-size: 10px; letter-spacing: 1.7px; }
.exercise-heading h1 { font-size: 28px; letter-spacing: -.6px; margin: 6px 0; }
.exercise-heading p { color: #6a7063; font-size: 13px; margin: 0; }
.settings-card { border-color: #dcded3; background: #fffefb; box-shadow: 0 2px 6px #38432d06; margin-bottom: 24px; }
.settings-fields { display: flex; flex-wrap: wrap; gap: 14px 18px; align-items: flex-end; padding: 16px 18px 12px; }
.setting { margin: 0; padding: 0; border: 0; min-width: 0; }
.setting .form-label { font-size: 11px; font-weight: 600; margin-bottom: 6px; width: auto; }
.setting legend { float: none; display: block; }
.setting .form-control { width: 76px; }
.setting .form-select { width: 65px; }
.setting .form-control, .setting .form-select { font-size: 13px; min-height: 32px; border-color: #cfd4c5; background-color: #fff; }
.setting .form-check { margin: 0; font-size: 13px; }
.sign-options { display: flex; gap: 12px; align-items: center; height: 32px; }
.tens-check { display: flex; gap: 7px; align-items: center; height: 32px; }
.setting .form-check-input { accent-color: #397251; }
.settings-actions { display: flex; gap: 8px; margin-left: auto; flex-wrap: nowrap; }
.settings-actions .btn { min-height: 32px; padding: 6px 12px; font-size: 12px; }
.btn-success { --tblr-btn-bg: #397251; --tblr-btn-border-color: #397251; }
.settings-footer { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 4px; border-top: 1px solid #e9eadf; padding: 5px 18px; color: #828677; font-size: 10px; }
.settings-footer .btn { color: #68755b; font-size: 11px; padding: 4px 0; text-decoration: underline; text-underline-offset: 3px; }
.notice { font-size: 13px; }
.sheet-scroll { overflow-x: auto; padding: 2px 2px 14px; }
.worksheet-page { width: 210mm; min-height: 297mm; padding: 10mm; box-sizing: border-box; margin: 0 auto; background: #fff; box-shadow: 0 3px 16px #3b432515; }
.worksheet { width: var(--grid-width); table-layout: fixed; border-collapse: collapse; border-spacing: 0; color: #252525; }
.worksheet td { box-sizing: border-box; width: var(--cell-size); height: var(--cell-size); border: .2mm solid #999; text-align: center; vertical-align: middle; padding: 0; font-size: 4.7mm; line-height: 1; font-family: "Trebuchet MS", sans-serif; }
.answer-slot { display: block; width: 4.9mm; height: 4.9mm; margin: auto; border: .25mm dashed #777; border-radius: .5mm; }
@media (min-width: 992px) {
    .navbar.sidebar { position: fixed; inset: 0 auto 0 0; display: flex; flex-direction: column; align-items: stretch; overflow-y: auto; }
    .sidebar .navbar-collapse { display: flex !important; flex-grow: 0; }
}
@media (max-width: 991.98px) {
    .navbar.sidebar { width: 100%; padding: 12px 18px; border-right: 0; border-bottom: 1px solid #dbded0; }
    .sidebar .navbar-collapse { padding-bottom: 8px; }
    .menu-caption { margin-top: 20px; }
    .sidebar-note { display: none; }
    .app-main { margin-left: 0; padding: 20px 14px; }
    .exercise-heading h1 { font-size: 24px; }
}
@page { size: A4 portrait; margin: 10mm; }
@media print {
    html, body { margin: 0 !important; padding: 0 !important; background: #fff !important; }
    .d-print-none { display: none !important; }
    .app-main, .sheet-scroll { margin: 0 !important; padding: 0 !important; overflow: visible; }
    .worksheet-page { width: 190mm; min-height: 0; margin: 0; padding: 0; box-shadow: none; }
    .worksheet { margin: 0; }
    .exercise-row { break-inside: avoid; }
}
