.tpg-frontend{--tpg-text:#172033;--tpg-muted:#667085;--tpg-border:#d9dee8;--tpg-bg:#f6f8fb;--tpg-card:#fff;--tpg-accent:#2563eb;--tpg-accent2:#0f766e;max-width:1180px;margin:30px auto;padding:0 16px;color:var(--tpg-text);font-family:inherit;transition:color .2s ease,background .2s ease}.tpg-frontend[data-tpg-theme="dark"]{--tpg-text:#f4f7fb;--tpg-muted:#aab4c3;--tpg-border:#394454;--tpg-bg:#101722;--tpg-card:#18212d}.tpg-frontend[data-tpg-theme="light"]{--tpg-text:#172033;--tpg-muted:#667085;--tpg-border:#d9dee8;--tpg-bg:#f6f8fb;--tpg-card:#fff}.tpg-frontend *{box-sizing:border-box}.tpg-theme-bar{display:flex;align-items:center;justify-content:flex-end;gap:6px;margin-bottom:12px}.tpg-theme-label{font-size:12px;font-weight:800;color:var(--tpg-muted);margin-right:4px}.tpg-theme-btn{min-height:34px;padding:6px 10px;border:1px solid var(--tpg-border);border-radius:9px;background:var(--tpg-card);color:var(--tpg-text);font:inherit;font-size:12px;font-weight:700;cursor:pointer;transition:.18s ease}.tpg-theme-btn:hover,.tpg-theme-btn.is-active{border-color:var(--tpg-accent);color:var(--tpg-accent);transform:translateY(-1px)}.tpg-hero{padding:28px;border:1px solid var(--tpg-border);border-radius:20px;background:linear-gradient(135deg,var(--tpg-card),var(--tpg-bg));margin-bottom:20px}.tpg-kicker{display:inline-block;font-size:12px;font-weight:800;letter-spacing:.08em;text-transform:uppercase;color:var(--tpg-accent);margin-bottom:8px}.tpg-hero h2{margin:0 0 8px;font-size:clamp(28px,4vw,42px);line-height:1.08}.tpg-hero p{margin:0;color:var(--tpg-muted);max-width:760px;line-height:1.65}.tpg-grid{display:grid;grid-template-columns:minmax(290px,390px) minmax(0,1fr);gap:20px;align-items:start}.tpg-card{background:var(--tpg-card);border:1px solid var(--tpg-border);border-radius:18px;padding:22px;box-shadow:0 8px 30px rgba(16,24,40,.06)}.tpg-step{display:flex;gap:12px;align-items:center;margin:0 0 18px}.tpg-step>span{width:32px;height:32px;display:grid;place-items:center;border:1px solid currentColor;border-radius:50%;font-weight:800;color:var(--tpg-accent)}.tpg-step strong{display:block;font-size:15px}.tpg-step small{display:block;color:var(--tpg-muted);margin-top:2px}.tpg-controls form label{display:block;font-size:13px;font-weight:700;margin:0 0 14px}.tpg-controls input,.tpg-controls select{display:block;width:100%;margin-top:7px;min-height:44px;padding:10px 12px;border:1px solid var(--tpg-border);border-radius:10px;background:var(--tpg-card);color:var(--tpg-text);font:inherit;outline:none}.tpg-controls input:focus,.tpg-controls select:focus{border-color:var(--tpg-accent);box-shadow:0 0 0 3px rgba(37,99,235,.12)}.tpg-controls select:disabled{opacity:.55;cursor:not-allowed}.tpg-cols{display:grid;grid-template-columns:1fr 1fr;gap:12px}.tpg-cols label{min-width:0}.tpg-session{padding:10px 12px;border:1px dashed var(--tpg-border);border-radius:10px;background:var(--tpg-bg);font-size:12px;color:var(--tpg-muted);margin:2px 0 20px}.tpg-session strong{color:var(--tpg-text)}.tpg-btn{display:inline-flex;align-items:center;justify-content:center;gap:8px;min-height:44px;padding:10px 16px;border:1px solid currentColor;border-radius:10px;background:transparent;color:var(--tpg-accent);font-weight:800;text-decoration:none;cursor:pointer;transition:transform .15s ease,background .2s ease,color .2s ease,box-shadow .2s ease}.tpg-btn:hover{background:var(--tpg-accent);color:#fff;box-shadow:0 8px 20px rgba(37,99,235,.18)}.tpg-btn:active{transform:scale(.97)}.tpg-btn-primary{width:100%;background:var(--tpg-accent);color:#fff;border-color:var(--tpg-accent);margin-top:4px}.tpg-btn-primary:hover{background:transparent;color:var(--tpg-accent)}.tpg-btn:disabled{opacity:.55;cursor:not-allowed;transform:none}.tpg-btn-small{min-height:38px;padding:7px 12px;font-size:12px}.tpg-preview-card{min-width:0}.tpg-preview-head{display:flex;justify-content:space-between;gap:15px;align-items:center;margin-bottom:12px}.tpg-preview-head .tpg-step{margin:0}.tpg-empty{min-height:430px;display:grid;place-items:center;text-align:center;padding:30px;border:1px dashed var(--tpg-border);border-radius:14px;background:var(--tpg-bg);color:var(--tpg-muted)}.tpg-empty-icon{width:52px;height:52px;border:1px solid var(--tpg-border);border-radius:50%;display:grid;place-items:center;margin:0 auto 10px;font-size:24px}.tpg-empty h3{margin:0 0 6px;color:var(--tpg-text)}.tpg-paper-preview{border:1px solid #222;border-radius:12px;background:#fff;color:#111;padding:24px;overflow:auto}.tpg-paper-head{text-align:center;margin-bottom:16px}.tpg-paper-head h3{margin:0;font-size:21px}.tpg-paper-head p{margin:4px 0;font-size:13px}.tpg-info{width:100%;border-collapse:collapse;margin-bottom:15px;font-size:12px}.tpg-info td{border:1px solid #222;padding:6px}.tpg-section-title{font-weight:800;margin:13px 0 7px;border-bottom:1px solid #222;padding-bottom:4px}.tpg-mcq-table{width:100%;border-collapse:collapse;font-size:11px}.tpg-mcq-table th,.tpg-mcq-table td{border:1px solid #222;padding:5px;vertical-align:top}.tpg-mcq-table th{background:#f1f1f1;text-align:center}.tpg-q{min-width:190px}.tpg-paper-preview ol{padding-left:25px;margin:6px 0}.tpg-paper-preview li{margin-bottom:7px;line-height:1.45}.tpg-notice{padding:10px 12px;border-radius:10px;margin-top:10px;font-size:13px}.tpg-notice.error{border:1px solid #ef4444;color:#b91c1c;background:#fef2f2}.tpg-notice.success{border:1px solid #16a34a;color:#166534;background:#f0fdf4}.tpg-loading{display:inline-flex;align-items:center;gap:8px}.tpg-spinner{width:16px;height:16px;border:2px solid currentColor;border-right-color:transparent;border-radius:50%;animation:tpgspin .7s linear infinite}@keyframes tpgspin{to{transform:rotate(360deg)}}.tpg-scan-note{padding:10px 12px;border:1px dashed var(--tpg-border);border-radius:10px;background:var(--tpg-bg);color:var(--tpg-muted);font-size:12px;line-height:1.5;margin:-2px 0 20px}.tpg-source-count{font-size:12px;color:var(--tpg-muted);margin:0 0 8px}.tpg-source-list{display:flex;gap:7px;flex-wrap:wrap;margin:0 0 12px}.tpg-source-list a{font-size:11px;border:1px solid var(--tpg-border);border-radius:999px;padding:5px 9px;color:var(--tpg-accent);text-decoration:none}.tpg-source-list a:hover{text-decoration:underline}.tpg-wrap .tpg-frontend{margin-left:0;margin-right:0}.tpg-wrap p{max-width:1000px}
@media(prefers-color-scheme:dark){.tpg-frontend:not([data-tpg-theme="light"]){--tpg-text:#f4f7fb;--tpg-muted:#aab4c3;--tpg-border:#394454;--tpg-bg:#101722;--tpg-card:#18212d}}
@media(max-width:850px){.tpg-grid{grid-template-columns:1fr}.tpg-preview-card{order:2}}@media(max-width:520px){.tpg-frontend{padding:0 10px;margin:15px auto}.tpg-theme-bar{justify-content:flex-start;overflow:auto}.tpg-hero,.tpg-card{padding:16px;border-radius:14px}.tpg-cols{grid-template-columns:1fr}.tpg-preview-head{align-items:flex-start;flex-direction:column}.tpg-preview-head .tpg-btn{width:100%}.tpg-mcq-table{font-size:10px}.tpg-mcq-table th,.tpg-mcq-table td{padding:4px}.tpg-paper-preview{padding:14px}}

.tpg-edit-toolbar{display:flex;align-items:center;gap:8px;flex-wrap:wrap;margin-bottom:12px;padding:8px;border:1px dashed var(--tpg-border);border-radius:10px;background:var(--tpg-bg)}.tpg-edit-hint{font-size:11px;color:var(--tpg-muted)}.tpg-paper-preview[data-editable="1"] .tpg-editable{outline:1px dashed var(--tpg-accent);outline-offset:2px;cursor:text}.tpg-fraction{display:inline-flex;flex-direction:column;vertical-align:middle;text-align:center;line-height:1.05;margin:0 .12em}.tpg-fraction .tpg-num{border-bottom:1px solid currentColor;padding:0 .15em}.tpg-fraction .tpg-den{padding:0 .15em}.tpg-paper-preview sup{font-size:.72em;vertical-align:super}.tpg-paper-preview sub{font-size:.72em;vertical-align:sub}

/* v3.3 preview/editor improvements */
.tpg-preview-card{overflow:hidden}
.tpg-preview-card #tpg-preview{width:100%;overflow:visible}
.tpg-paper-preview{width:100%;max-width:900px;margin:0 auto;min-height:1120px;padding:34px;background:#fff;color:#111;border:1px solid #b8bec8;border-radius:4px;box-shadow:0 12px 35px rgba(15,23,42,.12);overflow:visible;font-family:Arial,Helvetica,sans-serif;line-height:1.5}
.tpg-paper-preview *{max-width:100%}
.tpg-paper-preview .tpg-edit-toolbar{font-family:inherit}
.tpg-paper-preview[data-editable="1"] .tpg-editable{min-height:1.2em;background:rgba(37,99,235,.035);border-radius:3px}
.tpg-paper-preview[data-editable="1"] .tpg-editable:focus{outline:2px solid var(--tpg-accent);outline-offset:1px;background:#fff}
.tpg-paper-preview .tpg-paper-head h3{font-size:26px;line-height:1.2}
.tpg-paper-preview .tpg-paper-head p{font-size:14px;line-height:1.4}
.tpg-paper-preview .tpg-info{font-size:13px;table-layout:fixed}
.tpg-paper-preview .tpg-info td{word-break:normal;overflow-wrap:anywhere}
.tpg-paper-preview .tpg-section-title{font-size:16px;line-height:1.35;margin-top:20px}
.tpg-paper-preview .tpg-mcq-table{font-size:13px;table-layout:fixed}
.tpg-paper-preview .tpg-mcq-table th:first-child,.tpg-paper-preview .tpg-mcq-table td:first-child{width:44px;text-align:center}
.tpg-paper-preview .tpg-mcq-table th:nth-child(2),.tpg-paper-preview .tpg-mcq-table td:nth-child(2){width:42%}
.tpg-paper-preview .tpg-mcq-table th:not(:nth-child(1)):not(:nth-child(2)),.tpg-paper-preview .tpg-mcq-table td:not(:nth-child(1)):not(:nth-child(2)){width:14%}
.tpg-paper-preview .tpg-mcq-table td{word-break:normal;overflow-wrap:anywhere}
.tpg-paper-preview .tpg-q{min-width:0}
.tpg-paper-preview ol{line-height:1.55}
.tpg-paper-preview li{overflow-wrap:anywhere}
.tpg-fraction{font-size:1em}
.tpg-fraction .tpg-num,.tpg-fraction .tpg-den{white-space:nowrap}
@media (min-width:851px){
 .tpg-preview-card{min-width:0}
 .tpg-paper-preview{font-size:14px}
}
@media (max-width:850px){
 .tpg-paper-preview{min-height:auto;padding:22px;box-shadow:none}
 .tpg-paper-preview .tpg-info{font-size:11px}
 .tpg-paper-preview .tpg-mcq-table{font-size:11px}
 .tpg-paper-preview .tpg-mcq-table th,.tpg-paper-preview .tpg-mcq-table td{padding:5px 4px}
}
@media (max-width:520px){
 .tpg-paper-preview{padding:13px;border-radius:8px;font-size:13px}
 .tpg-paper-preview .tpg-paper-head h3{font-size:20px}
 .tpg-paper-preview .tpg-paper-head p{font-size:12px}
 .tpg-paper-preview .tpg-info{display:block;font-size:10px;overflow-x:auto}
 .tpg-paper-preview .tpg-info tr{display:grid;grid-template-columns:1fr 1fr}
 .tpg-paper-preview .tpg-info td{display:block;min-width:0}
 .tpg-paper-preview .tpg-mcq-table{font-size:9px}
 .tpg-paper-preview .tpg-mcq-table th:first-child,.tpg-paper-preview .tpg-mcq-table td:first-child{width:28px}
 .tpg-paper-preview .tpg-mcq-table th:nth-child(2),.tpg-paper-preview .tpg-mcq-table td:nth-child(2){width:40%}
 .tpg-paper-preview .tpg-mcq-table th:not(:nth-child(1)):not(:nth-child(2)),.tpg-paper-preview .tpg-mcq-table td:not(:nth-child(1)):not(:nth-child(2)){width:auto}
 .tpg-edit-toolbar{position:sticky;top:6px;z-index:3}
 .tpg-edit-hint{flex-basis:100%}
}

/* v3.4 sequential steps and user font size */
.tpg-step-flow{display:grid;grid-template-columns:1fr;gap:20px}
.tpg-step-card{width:100%;box-sizing:border-box}
.tpg-step-two{margin-top:2px}
.tpg-step-two .tpg-cols{grid-template-columns:repeat(2,minmax(0,1fr))}
.tpg-field-help{display:block;color:var(--tpg-muted);font-size:11px;font-weight:400;margin-top:5px;line-height:1.4}
.tpg-preview-font{display:inline-flex;align-items:center;gap:5px;font-size:12px;font-weight:700;color:var(--tpg-text);margin-left:auto}
.tpg-preview-font-input{width:58px;min-height:34px;padding:5px 7px;border:1px solid var(--tpg-border);border-radius:8px;background:var(--tpg-card);color:var(--tpg-text);font:inherit;font-size:12px}
.tpg-paper-preview{font-size:var(--tpg-paper-font-size,12px)}
.tpg-paper-preview .tpg-mcq-table{font-size:var(--tpg-paper-font-size,12px)}
.tpg-paper-preview .tpg-info{font-size:calc(var(--tpg-paper-font-size,12px) - 1px)}
.tpg-paper-preview .tpg-paper-head p{font-size:calc(var(--tpg-paper-font-size,12px) + 1px)}
.tpg-paper-preview .tpg-section-title{font-size:calc(var(--tpg-paper-font-size,12px) + 2px)}
@media(max-width:850px){.tpg-step-two .tpg-cols{grid-template-columns:1fr}.tpg-preview-font{margin-left:0}}
@media(max-width:520px){.tpg-step-flow{gap:14px}.tpg-preview-font{width:100%;justify-content:flex-start}.tpg-preview-font-input{width:64px}}

.tpg-key-option{margin:10px 0;padding:10px 12px;border:1px solid var(--tpg-border);border-radius:10px;background:var(--tpg-soft)}.tpg-key-option label{display:flex;align-items:center;gap:8px;font-weight:700}.tpg-key-option input{width:auto}.tpg-key-option .tpg-field-help{display:block;margin-top:5px}.tpg-answer-key{margin-left:6px}

/* v3.11 user-controlled paper sections */
.tpg-section-builder{margin:14px 0;padding:12px;border:1px solid var(--tpg-border);border-radius:12px;background:var(--tpg-bg)}
.tpg-builder-head{display:flex;align-items:center;justify-content:space-between;gap:12px;margin-bottom:10px}
.tpg-builder-head strong{display:block;color:var(--tpg-text);font-size:13px}
.tpg-section-list{display:grid;gap:8px}
.tpg-section-row{display:flex;align-items:center;gap:8px;padding:9px;border:1px solid var(--tpg-border);border-radius:10px;background:var(--tpg-card)}
.tpg-section-row-main{display:grid;grid-template-columns:minmax(0,1fr) 110px minmax(150px,.8fr);gap:9px;align-items:end;flex:1;min-width:0}
.tpg-section-row label{font-size:11px;font-weight:800;color:var(--tpg-text)}
.tpg-section-row input[type=text],.tpg-section-row input[type=number]{width:100%;box-sizing:border-box;margin-top:5px;min-height:38px;padding:8px 10px;border:1px solid var(--tpg-border);border-radius:8px;background:var(--tpg-card);color:var(--tpg-text)}
.tpg-ab-check{display:flex;flex-direction:column;gap:5px;min-height:38px;justify-content:flex-end}.tpg-ab-check span:last-child{display:flex;align-items:center;gap:6px;font-weight:600}.tpg-ab-check input{width:auto;margin:0}
.tpg-remove-section{width:34px;height:34px;flex:0 0 34px;border:1px solid #ef4444;border-radius:8px;background:transparent;color:#ef4444;font-size:20px;line-height:1;cursor:pointer}.tpg-remove-section:hover{background:#ef4444;color:#fff}
.tpg-paper-preview .tpg-question-section{margin-top:18px}.tpg-paper-preview .tpg-subsection-title{margin-top:10px}.tpg-paper-preview[data-editable="1"] .tpg-section-title[data-section-title]{cursor:text}
.tpg-paper-preview[data-editable="1"] .tpg-section-title[data-section-title]:focus{outline:2px solid var(--tpg-accent);background:#fff}
.tpg-paper-preview .tpg-long-part{margin:4px 0 8px}.tpg-paper-preview .tpg-long-part strong{white-space:nowrap}
@media(max-width:650px){.tpg-section-row-main{grid-template-columns:1fr 90px}.tpg-ab-check{grid-column:1/-1}.tpg-builder-head{align-items:flex-start;flex-direction:column}.tpg-builder-head .tpg-btn{width:100%}}
