/* Shell fonts: Nunito for headings/logo, Plus Jakarta Sans for body/labels.
   Worksheet-content fonts (Fredoka, Comic Neue) stay on Google Fonts in index.html. */
@font-face {
    font-family: 'Nunito';
    src: url("/fonts/nunito-latin.woff2") format("woff2");
    font-style: normal;
    font-weight: 400 900;
    font-display: swap;
}

@font-face {
    font-family: 'Plus Jakarta Sans';
    src: url("/fonts/jakarta-latin.woff2") format("woff2");
    font-style: normal;
    font-weight: 400 800;
    font-display: swap;
}

/* Base Colors and Theme Variables: shared PandaiHitung light palette mapped
   onto the existing token names so downstream selectors keep working. */
:root {
    --bg-dark: var(--ph-bg);
    --bg-card: var(--ph-surface);
    --border-color: var(--ph-line);
    --text-light: var(--ph-ink);
    --text-muted: var(--ph-muted);

    --primary: var(--ph-action);
    --primary-hover: var(--ph-action-hover);
    --primary-pressed: var(--ph-action-active);
    --success: var(--ph-green);
    --success-hover: #265e41;
    --accent: var(--ph-blue);
    --blue-soft: var(--ph-blue-soft);
    --focus-ring: var(--ph-focus);

    /* Font styles */
    --font-outfit: 'Nunito', sans-serif;
    --font-inter: 'Plus Jakarta Sans', sans-serif;
    --font-fredoka: 'Fredoka', sans-serif;
    --font-comic: 'Comic Neue', cursive, sans-serif;
}

/* CSS Resets & General Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
}

body {
    background-color: var(--bg-dark);
    color: var(--text-light);
    font-family: var(--font-inter);
    overflow: hidden;
    height: 100vh;
}

/* App Container Layout */
.app-container {
    display: flex;
    height: 100vh;
    width: 100vw;
}

/* Sidebar Styling */
.sidebar {
    width: 380px;
    background: var(--bg-card);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    height: 100%;
    z-index: 10;
    flex-shrink: 0;
}

.sidebar-header {
    padding: 20px 24px;
    border-bottom: 1px solid var(--border-color);
    background: var(--bg-card);
}

.product-heading {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-top: 14px;
}

.logo {
    width: 40px;
    height: 40px;
    flex: 0 0 40px;
    color: var(--primary);
}

.logo svg {
    display: block;
    width: 100%;
    height: 100%;
}

.product-name {
    font-family: var(--font-outfit);
    font-size: 24px;
    line-height: 1.2;
    font-weight: 800;
    letter-spacing: -0.6px;
    color: var(--text-light);
}

.subtitle {
    font-size: 12px;
    line-height: 1.6;
    color: var(--text-muted);
    margin-top: 3px;
    font-weight: 500;
}

/* Control Settings Cards */
.control-sections {
    padding: 16px;
    overflow-y: auto;
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.control-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 20px;
    min-width: 0;
}

/* Section headings: Nunito 700, with the identity hand-drawn underline in the
   action orange instead of a colored left stripe. */
.section-title {
    display: inline-block;
    font-family: var(--font-outfit);
    font-size: 15px;
    font-weight: 700;
    color: var(--text-light);
    margin-bottom: 14px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 120 9'%3E%3Cpath d='M2.5 5.6c9.4-2.2 19.2-2.5 28.6-1.5 9 .9 17.9 2.4 26.9 2.6 9.7.3 19.5-.6 29.2-1.5 10-1 20.3-.9 30.3.8' fill='none' stroke='%23ffb54a' stroke-width='2.6' stroke-linecap='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: left calc(100% - 1px);
    background-size: 100% 7px;
    padding-bottom: 9px;
}

/* Frozen at the bottom of the preview so the explanation stays visible while pages scroll.
   Surface, not an overlay: it takes its own row and does not cover the sidebar actions. */
.module-guide {
    flex: 0 0 auto;
    display: grid;
    grid-template-columns: minmax(140px, 200px) minmax(0, 1fr) auto;
    grid-template-areas:
        "head short play"
        "details details details"
        "status status status";
    gap: 2px 16px;
    align-items: center;
    max-height: 42vh;
    overflow: auto;
    padding: 12px 24px 14px;
    border-top: 1px solid var(--border-color);
    background: var(--blue-soft);
    z-index: 4;
}

.guide-topline {
    grid-area: head;
    min-width: 0;
}

.guide-heading {
    font-family: var(--font-outfit);
    font-size: 17px;
    line-height: 1.4;
    font-weight: 800;
    color: var(--text-light);
}

.guide-play {
    grid-area: play;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    min-width: 44px;
    min-height: 44px;
    padding: 9px 12px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    background: var(--bg-card);
    color: var(--accent);
    font-family: var(--font-inter);
    font-size: 11px;
    font-weight: 700;
    line-height: 1.4;
    cursor: pointer;
}

.guide-play:hover {
    border-color: var(--accent);
    background: #ffffff;
}

.guide-play:active {
    background: var(--blue-soft);
}

.guide-play svg {
    flex: 0 0 18px;
    width: 18px;
    height: 18px;
    fill: currentColor;
}

.guide-stop-icon,
.guide-play.is-playing .guide-play-icon {
    display: none;
}

.guide-play.is-playing .guide-stop-icon {
    display: block;
}

.guide-play-label {
    display: inline;
}

.guide-short {
    grid-area: short;
    margin-top: 0;
    font-size: 13px;
    line-height: 1.55;
    color: var(--text-light);
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.guide-details {
    grid-area: details;
    margin-top: 2px;
    border-top: 1px solid var(--border-color);
}

.guide-details summary {
    min-height: 44px;
    padding: 13px 0 6px;
    color: var(--accent);
    font-size: 12px;
    font-weight: 700;
    cursor: pointer;
}

.guide-long-list {
    display: grid;
    gap: 10px;
    padding: 8px 0 2px 20px;
    color: var(--text-light);
    font-size: 12px;
    line-height: 1.75;
}

.guide-audio-status {
    grid-area: status;
    font-size: 11px;
    line-height: 1.6;
    color: var(--text-muted);
}

.guide-audio-status:not(:empty) {
    margin-top: 10px;
}

/* Forms and Inputs Styling */
.control-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-bottom: 14px;
}

.control-group:last-child {
    margin-bottom: 0;
}

.control-group-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-bottom: 14px;
}

.control-group-grid:last-child {
    margin-bottom: 0;
}

label {
    font-size: 12px;
    color: var(--text-muted);
    font-weight: 600;
}

input[type="text"],
input[type="number"],
select {
    width: 100%;
    min-width: 0;
    min-height: 44px;
    background: #ffffff;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 10px 12px;
    color: var(--text-light);
    font-size: 13px;
    font-family: var(--font-inter);
    outline: none;
    transition: border-color 160ms ease, box-shadow 160ms ease;
}

input:focus,
select:focus {
    border-color: var(--focus-ring);
    box-shadow: 0 0 0 3px rgba(43, 109, 136, 0.18);
}

/* Worksheet choices: full-width rows keep long Indonesian labels readable.
   Small group headings divide the list without hiding options behind menus. */
.radio-group-tabs {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 4px;
}

.type-group-title {
    margin: 16px 4px 6px;
    font-size: 11px;
    font-weight: 700;
    line-height: 1.5;
    color: var(--text-muted);
}

.type-group-title:first-child {
    margin-top: 0;
}

.tab-btn {
    position: relative;
    min-width: 0;
    cursor: pointer;
}

.tab-btn input {
    position: absolute;
    width: 1px;
    height: 1px;
    opacity: 0;
}

.tab-label {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 12px;
    min-height: 44px;
    padding: 10px 12px;
    border: 1px solid transparent;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 600;
    line-height: 1.5;
    color: var(--text-muted);
    text-align: left;
    transition: background-color 160ms ease, border-color 160ms ease;
}

.tab-label svg {
    flex: 0 0 18px;
    width: 18px;
    height: 18px;
}

.tab-label:hover {
    background: var(--blue-soft);
    color: var(--text-light);
}

.tab-btn input:focus-visible + .tab-label {
    outline: 3px solid var(--focus-ring);
    outline-offset: 2px;
}

.tab-btn input:checked + .tab-label {
    background: var(--primary);
    border-color: var(--primary-hover);
    color: var(--text-light);
}

/* Checkbox Styles */
.checkbox-options {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-top: 12px;
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 10px;
    min-height: 44px;
    cursor: pointer;
    font-size: 12px;
    color: var(--text-muted);
    line-height: 1.4;
}

.checkbox-label input[type="checkbox"] {
    accent-color: var(--primary);
    margin: 0;
    width: 20px;
    height: 20px;
    flex: none;
}

/* Sidebar Buttons & Footer */
.sidebar-footer {
    padding: 16px 24px;
    border-top: 1px solid var(--border-color);
    background: var(--bg-card);
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.primary-btn,
.success-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    width: 100%;
    padding: 12px;
    border: none;
    border-radius: 10px;
    font-family: var(--font-outfit);
    font-size: 15px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s ease;
}

.primary-btn {
    background: var(--primary);
    color: var(--text-light);
}

.primary-btn:hover {
    background: var(--primary-hover);
}

.primary-btn:active {
    background: var(--primary-pressed);
    transform: translateY(1px);
}

.success-btn {
    background: var(--success);
    color: #ffffff;
}

.success-btn:hover {
    background: var(--success-hover);
}

.success-btn:active {
    transform: translateY(1px);
}

.credit {
    font-size: 11px;
    color: var(--text-muted);
    text-align: center;
    margin-top: 4px;
}

/* Learning resources are secondary navigation, separate from the two actions. */
.resource-links {
    margin-top: 8px;
    padding-top: 16px;
    border-top: 1px solid var(--border-color);
    font-size: 12px;
    line-height: 1.6;
}

.resource-heading {
    margin-bottom: 8px;
    font-family: var(--font-outfit);
    font-size: 13px;
    font-weight: 700;
    color: var(--text-light);
}

.resource-links a {
    display: inline-flex;
    align-items: center;
    min-height: 44px;
    color: var(--accent);
    font-weight: 600;
    text-decoration: none;
}

.resource-links a:hover {
    color: var(--text-light);
    text-decoration: underline;
    text-underline-offset: 3px;
}

.resource-featured {
    gap: 10px;
    justify-content: space-between;
    width: 100%;
    padding: 4px 0;
}

.resource-featured span {
    font-size: 16px;
}

.resource-row {
    display: flex;
    flex-wrap: wrap;
    gap: 0 16px;
}

.pdf-examples {
    margin-top: 4px;
}

.pdf-examples summary {
    min-height: 44px;
    padding: 12px 0;
    cursor: pointer;
    font-weight: 600;
    color: var(--text-muted);
}

.pdf-examples > div {
    display: grid;
    grid-template-columns: 1fr;
    padding: 0 0 8px 12px;
}

.pdf-examples a {
    font-size: 12px;
    font-weight: 600;
}

/* Preview Area Panel Styling */
.preview-workspace {
    flex: 1;
    min-width: 0;
    background: var(--bg-dark);
    display: flex;
    flex-direction: column;
    height: 100%;
}

.preview-header {
    padding: 18px 30px;
    background: var(--bg-card);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.preview-header h2 {
    font-family: var(--font-outfit);
    font-size: 18px;
    font-weight: 700;
    color: var(--text-light);
}

.page-counter-badge {
    background: var(--blue-soft);
    border: 1px solid var(--border-color);
    color: var(--accent);
    padding: 4px 12px;
    border-radius: 99px;
    font-size: 12px;
    font-weight: 600;
}

.pages-container {
    flex-grow: 1;
    min-width: 0;
    overflow: auto;
    padding: 40px 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
    scroll-behavior: smooth;
}

/* Page Typography Font Mappings */
.font-fredoka { font-family: var(--font-fredoka); }
.font-comic { font-family: var(--font-comic); }
.font-outfit { font-family: var(--font-outfit); }
.font-inter { font-family: var(--font-inter); }

/* --- A5 PHYSICAL PAGE SHEET STYLING (Screen Mockup) --- */
.a5-page {
    width: 148mm;
    height: 210mm;
    min-height: 210mm;
    background-color: #ffffff;
    color: #1e293b;
    padding: 12mm 10mm 10mm 10mm; /* standard learning page margins */
    margin-bottom: 25px;
    box-shadow: 0 10px 24px rgba(33, 59, 69, 0.10), 0 3px 8px rgba(33, 59, 69, 0.06);
    border-radius: 6px;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    position: relative;
    overflow: hidden;
}

/* Margins adjustments */
.margin-compact .a5-page { padding: 8mm 8mm 8mm 8mm; }
.margin-normal .a5-page { padding: 12mm 10mm 10mm 10mm; }
.margin-wide .a5-page { padding: 16mm 14mm 14mm 14mm; }

/* Page Header Structure */
.worksheet-header {
    display: flex;
    flex-direction: column;
    gap: 20px; /* Increased gap between title and info */
    margin-bottom: 16px;
    border-bottom: 2px dashed #cbd5e1;
    padding-bottom: 12px;
}

.worksheet-title-row {
    display: flex;
    justify-content: center;
    position: relative;
}

.worksheet-title {
    font-size: 18px;
    font-weight: 700;
    text-align: center;
    color: #0f172a;
    letter-spacing: 1px;
    text-transform: uppercase;
}

/* Student Information Header Card */
.student-info-bar {
    display: flex;
    justify-content: space-between;
    font-size: 11px;
    color: #475569;
    font-weight: 600;
    margin-top: 6px;
}

.info-field {
    display: flex;
    gap: 4px;
}

.info-line {
    border-bottom: 1px dotted #64748b;
    width: 80px;
    display: inline-block;
}

.info-line.wide {
    width: 110px;
}

.info-line.short {
    width: 50px;
}

/* Page Footer Elements */
.worksheet-footer {
    position: absolute;
    bottom: 8mm;
    left: 10mm;
    right: 10mm;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 10px;
    color: #64748b;
    border-top: 1px solid #e2e8f0;
    padding-top: 6px;
    pointer-events: none;
}

/* --- CONTOH SOAL & KUNCI JAWABAN (gaya lembar pecahan) --- */
.worksheet-subtitle {
    text-align: center;
    font-size: 11px;
    font-weight: 700;
    color: #f97316;
    letter-spacing: .4px;
    text-transform: uppercase;
    margin-top: -10px;
}

.worked-example {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    background-color: #fff7ed;
    border: 1.5px dashed #fdba74;
    border-radius: 8px;
    padding: 6px 10px;
    margin-bottom: 10px;
    font-size: 12px;
    font-weight: 700;
    color: #9a3412;
    line-height: 1.35;
}

.worked-example .ex-label {
    flex: 0 0 auto;
    font-size: 9.5px;
    font-weight: 900;
    letter-spacing: .6px;
    text-transform: uppercase;
    background-color: #f97316;
    color: #ffffff;
    border-radius: 4px;
    padding: 2px 6px;
}

.worked-example .ex-eq {
    font-variant-numeric: tabular-nums;
    letter-spacing: 2px;
}

.worked-example b {
    font-weight: 900;
}

.key-instruction {
    font-size: 11px;
    font-weight: 700;
    color: #475569;
    margin-bottom: 8px;
}

.key-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    column-gap: 10mm;
    row-gap: 4px;
    align-content: flex-start;
    flex-grow: 1;
    margin-bottom: 8mm;
}

.key-grid.key-grid-single {
    grid-template-columns: 1fr;
}

.key-item {
    display: flex;
    align-items: flex-start;
    gap: 6px;
    font-size: 13px;
    font-weight: 600;
    color: #0f172a;
    padding: 3px 0;
    border-bottom: 1px dotted #e2e8f0;
    line-height: 1.3;
}

.key-item .q-index {
    flex: 0 0 auto;
    min-width: 18px;
    font-size: 11.5px;
    font-weight: 800;
    color: #94a3b8;
    text-align: right;
    padding-top: 1px;
}

.key-item .key-answer {
    flex: 1 1 auto;
}

.key-item .key-row-label {
    font-weight: 800;
    color: #475569;
}

.key-grid.key-grid-single .key-item {
    font-size: 12px;
    padding: 2px 0;
}

.color-mode-grayscale .worked-example {
    background-color: #ffffff;
    border-color: #64748b;
    color: #0f172a;
}

.color-mode-grayscale .worked-example .ex-label {
    background-color: #ffffff;
    color: #0f172a;
    border: 1px solid #475569;
}

/* Tata letak yang kaku diberi sedikit ruang tambahan saat kotak contoh tampil. */
.has-example .clock-body {
    row-gap: 8px;
}

.has-example .clock-problem {
    padding-top: 2px;
    padding-bottom: 2px;
}

.has-example .place-value-body {
    row-gap: 6px;
    padding-top: 8px;
}

.has-example .place-value-body.pv-count-6 {
    row-gap: 14px;
    padding-top: 12px;
}

.has-example .integer-story-body {
    gap: 5px;
}

/* --- TIPE 1: ANGKA HILANG LAYOUT (Missing Numbers Grid) --- */
.missing-numbers-body {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    flex-grow: 1;
    margin-bottom: 8mm; /* leave room for footer */
}

.number-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
}

.number-cell {
    flex: 1;
    aspect-ratio: 1 / 1;
    border: 2px solid #0f172a;
    margin: 2px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 15px;
    font-weight: 700;
    border-radius: 4px;
    color: #0f172a;
    transition: all 0.2s ease;
    background-color: #ffffff;
}

/* Make numbers slightly bigger for short ranges */
.cell-count-small .number-cell {
    font-size: 18px;
    border-radius: 6px;
    border-width: 2.5px;
}

.number-cell.blank-cell {
    background-color: #fafafa;
    border-style: solid;
    border-color: #0f172a;
}

/* Highlight blank cells subtly in preview mode */
body:not(.printing) .number-cell.blank-cell {
    background-color: rgba(255, 181, 74, 0.06);
    border-color: var(--primary);
}

/* Tracing & Dotted style for blank cells */
.number-cell.cell-trace {
    color: #cbd5e1 !important; /* light gray for tracing */
    font-weight: 400;
}
.color-mode-grayscale .number-cell.cell-trace {
    color: #d1d5db !important;
}
.number-cell.cell-dots {
    color: #64748b;
    font-size: 12px;
    letter-spacing: 0.5px;
}

/* Colors for missing number grid cells */
.color-mode-color.type-missing-numbers .number-cell:not(.blank-cell),
.color-mode-color.type-simple-addition .number-cell {
    background-color: #f8fafc;
}

/* --- TIPE 2: PENJUMLAHAN BERGAMBAR LAYOUT (Pictorial Addition) --- */
.pictorial-addition-body {
    display: flex;
    flex-direction: column;
    justify-content: space-evenly; /* Evenly distributes problems to fill the A5 page */
    flex-grow: 1;
    margin-bottom: 8mm;
}

.problem-wrapper {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 10px 0;
    border-bottom: 1px dotted #cbd5e1;
}

.problem-wrapper:last-child {
    border-bottom: none;
}

/* Spacing adjusting depending on problem counts to fill the page perfectly */
.problems-count-1 .problem-wrapper { padding: 40px 0; }
.problems-count-2 .problem-wrapper { padding: 25px 0; }
.problems-count-3 .problem-wrapper { padding: 10px 0; }
.problems-count-4 .problem-wrapper { padding: 4px 0; }

.equation-row {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    gap: 8px;
}

.item-group {
    display: flex;
    flex-wrap: wrap;
    align-content: center;
    justify-content: center;
    align-items: center;
    gap: 4px;
    border-radius: 8px;
    padding: 8px;
    border: 1.5px dashed transparent;
    transition: all 0.2s ease;
    
    /* Calculate size dynamically */
    width: 32%;
    min-height: 50px;
}

.color-mode-color .item-group {
    background-color: #f8fafc;
    border-color: #e2e8f0;
}

.math-operator {
    font-size: 24px;
    font-weight: 700;
    color: #1e293b;
    width: 24px;
    text-align: center;
    user-select: none;
}

/* SVG Icon Styling */
.svg-icon {
    width: 22px;
    height: 22px;
    object-fit: contain;
    transition: transform 0.2s ease;
}

/* Icon scaling depending on quantity on page to keep neat */
.problems-count-1 .svg-icon { width: 34px; height: 34px; }
.problems-count-2 .svg-icon { width: 28px; height: 28px; }
.problems-count-3 .svg-icon { width: 22px; height: 22px; }
.problems-count-4 .svg-icon { width: 18px; height: 18px; }

/* The numbers row underneath images */
.numbers-row {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    margin-top: 8px;
    gap: 8px;
}

.number-label {
    width: 32%;
    text-align: center;
    font-size: 15px;
    font-weight: 700;
    color: #0f172a;
}

.problems-count-1 .number-label { font-size: 22px; }
.problems-count-2 .number-label { font-size: 18px; }
.problems-count-3 .number-label { font-size: 15px; }

/* Empty input box style */
.number-box-placeholder {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border: 2px dashed #64748b;
    border-radius: 6px;
    background-color: #f8fafc;
    color: transparent;
}

.problems-count-1 .number-box-placeholder { width: 36px; height: 36px; border-radius: 8px; }
.problems-count-2 .number-box-placeholder { width: 32px; height: 32px; }

/* Preview placeholder styling */
body:not(.printing) .number-box-placeholder {
    border-color: var(--accent);
}

/* Color Mode Styling */
.color-mode-color .number-box-placeholder {
    background-color: #f0fdf4;
    border-color: #86efac;
}

.color-mode-grayscale .svg-icon {
    /* Apply filter to make SVGs look monochrome gray */
    filter: grayscale(1) contrast(1.1);
}

/* Grayscale Borders */
.color-mode-grayscale .item-group {
    background-color: #ffffff;
    border-color: #cbd5e1;
}
.color-mode-grayscale .number-box-placeholder {
    background-color: #ffffff;
    border-color: #94a3b8;
}

/* --- TIPE 3: PENJUMLAHAN ANGKA (Simple Addition) --- */
.simple-addition-body {
    display: grid;
    grid-template-columns: 1fr 1fr; /* 2 columns as requested */
    column-gap: 20px;
    row-gap: 22px; /* Slightly reduced to fit number lines */
    flex-grow: 1;
    align-content: start;
    padding-top: 15px;
}

.simple-equation-wrapper {
    display: flex;
    align-items: center;
    justify-content: center; /* Center the equation within the column */
    font-size: 18px;
    font-weight: 600;
    color: #0f172a;
}

.simple-equation-text {
    letter-spacing: 2px;
}

.simple-equation-answer {
    display: inline-block;
    width: 35px; /* Shorter line as requested */
    border-bottom: 1.5px solid #0f172a;
    height: 20px;
    margin-left: 6px;
}

/* Adjust font size and spacing based on number of questions */
.problems-count-6 .simple-addition-body { row-gap: 55px; padding-top: 40px; }
.problems-count-6 .simple-equation-wrapper { font-size: 28px; }
.problems-count-8 .simple-addition-body { row-gap: 45px; padding-top: 35px; }
.problems-count-8 .simple-equation-wrapper { font-size: 24px; }
.problems-count-10 .simple-addition-body:not([style*="grid-template-columns: 1fr"]) { row-gap: 35px; padding-top: 25px; }
.problems-count-10 .simple-addition-body:not([style*="grid-template-columns: 1fr"]) .simple-equation-wrapper { font-size: 20px; }
.problems-count-10 .simple-addition-body[style*="grid-template-columns: 1fr"] { row-gap: 40px; padding-top: 30px; }
.problems-count-10 .simple-addition-body[style*="grid-template-columns: 1fr"] .simple-equation-wrapper { font-size: 24px; }
.problems-count-12 .simple-addition-body { row-gap: 30px; padding-top: 20px; }
.problems-count-12 .simple-equation-wrapper { font-size: 20px; }
.problems-count-14 .simple-addition-body { row-gap: 25px; padding-top: 20px; }
.problems-count-14 .simple-equation-wrapper { font-size: 20px; }
.problems-count-30 .simple-addition-body { row-gap: 10px; }
.problems-count-30 .simple-equation-wrapper { font-size: 16px; }
.problems-count-24 .simple-addition-body { row-gap: 16px; }
.problems-count-14 .simple-addition-body { row-gap: 35px; padding-top: 25px; }
.problems-count-14 .simple-equation-wrapper { font-size: 20px; }
.problems-count-10 .simple-addition-body { row-gap: 45px; padding-top: 35px; }
.problems-count-10 .simple-equation-wrapper { font-size: 24px; }

/* Number line at the bottom styling */
.simple-addition-number-line .number-cell {
    aspect-ratio: auto; /* Remove square constraint */
    height: 24px; /* Fixed height to prevent overlapping footer */
    font-size: 14px;
    border-radius: 4px;
    border-width: 1.5px;
}

/* --- TIPE 6: NUMBER BOND LAYOUT --- */
.number-bond-body {
    display: grid;
    grid-template-columns: 1fr 1fr;
    column-gap: 12px;
    row-gap: 0;
    flex-grow: 1;
    align-content: space-between;
    padding-top: 10px;
    margin-bottom: 8mm;
}

.nb-equation-wrapper {
    display: flex;
    align-items: baseline;
    justify-content: center;
    gap: 4px;
    font-size: 20px;
    font-weight: 700;
    color: #0f172a;
    padding: 4px 0;
}

.nb-number-idx {
    font-size: 13px;
    font-weight: 600;
    color: #64748b;
    min-width: 22px;
    text-align: right;
    margin-right: 2px;
}

.nb-number {
    font-size: 20px;
    font-weight: 700;
    min-width: 18px;
    text-align: center;
}

.nb-operator {
    font-size: 20px;
    font-weight: 700;
    margin: 0 2px;
}

.nb-blank {
    display: inline-block;
    width: 32px;
    border-bottom: 2.5px solid #0f172a;
    height: 18px;
    margin: 0 2px;
}

/* --- TIPE: PASANGAN BILANGAN (Diagram Lingkaran, ala ikatan-bilangan-*-cara3) --- */
.pasangan-bilangan-body {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    row-gap: 6px;
    column-gap: 0;
    justify-items: center;
    flex-grow: 1;
    align-content: center;
    margin-bottom: 8mm;
}

.pb-card {
    position: relative;
    width: 130px;
    height: 140px;
}

.pb-lines {
    position: absolute;
    top: 0;
    left: 0;
    width: 130px;
    height: 140px;
    z-index: 1;
    pointer-events: none;
}

.pb-lines line {
    stroke: #94a3b8;
    stroke-width: 3;
    stroke-dasharray: 6 4;
}

.color-mode-grayscale .pb-lines line {
    stroke: #000000;
}

.pb-circle {
    position: absolute;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2;
    background: #ffffff;
    border: 2.5px solid #0f172a;
    color: #0f172a;
    font-weight: 700;
}

/* Lingkaran yang dicolok: border solid (sama dengan lingkaran lain) + tanda ... abu-abu */
.pb-blank {
    color: #64748b;
}

.pb-total {
    top: 0;
    left: 39px;
    width: 52px;
    height: 52px;
    font-size: 24px;
}

.pb-part-a {
    top: 88px;
    left: 4px;
    width: 50px;
    height: 50px;
    font-size: 22px;
}

.pb-part-b {
    top: 88px;
    right: 4px;
    width: 50px;
    height: 50px;
    font-size: 22px;
}

/* --- TIPE 7: MEMBACA JAM (Clock Worksheet) --- */
.clock-body {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    grid-template-rows: repeat(3, 1fr);
    row-gap: 20px;
    column-gap: 0;
    flex-grow: 1;
    margin-bottom: 8mm;
    align-content: stretch;
}

.clock-problem {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 8px 6px;
    box-sizing: border-box;
    position: relative;
}

/* Border putus-putus vertikal antar kolom */
.clock-problem:not(:nth-child(3n)) {
    border-right: 1.5px dotted #cbd5e1;
}

/* Grayscale border */
.color-mode-grayscale .clock-problem:not(:nth-child(3n)) {
    border-right: 1.5px dotted #000000;
}

/* Clock SVG wrapper */
.clock-svg {
    max-width: 86px;
    max-height: 86px;
    margin-bottom: 6px;
}

/* Digital Time row below SVG */
.clock-info-row {
    font-size: 13px;
    font-weight: 700;
    color: #0f172a;
    margin-bottom: 6px;
    text-align: center;
    width: 100%;
}

.clock-info-row.digital-blank {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 4px;
}

.clock-digital-line {
    display: inline-block;
    width: 45px;
    border-bottom: 1.8px solid #0f172a;
    height: 14px;
}

/* Written words section for Column 1 & 2 (with lines) */
.clock-text-lines {
    display: flex;
    flex-direction: column;
    width: 100%;
    margin-top: 2px;
}

.clock-line-first {
    display: flex;
    align-items: flex-end;
    width: 100%;
    gap: 4px;
}

.clock-prefix {
    font-size: 11px;
    font-weight: 600;
    color: #475569;
    line-height: 1.1;
}

.clock-line-dots {
    flex-grow: 1;
    border-bottom: 1.5px dotted #94a3b8;
    height: 14px;
}

.clock-line-full {
    width: 100%;
    border-bottom: 1.5px dotted #94a3b8;
    height: 14px;
    margin-top: 5px;
}

/* Written words section for Column 3 (text is given) */
.clock-text-words-given {
    font-size: 10.5px;
    font-weight: 600;
    color: #0f172a;
    line-height: 1.35;
    margin-top: 4px;
    text-align: center;
    width: 100%;
    padding: 0 4px;
    box-sizing: border-box;
}

/* --- TIPE 8: KONSEP PERKALIAN (Multiplication Concept) --- */
.concept-body {
    display: flex;
    flex-direction: column;
    justify-content: space-evenly;
    flex-grow: 1;
    margin-bottom: 8mm;
}

/* Outer card for Contoh or Soal */
.concept-card-wrapper {
    border: 2px solid #0f172a;
    border-radius: 8px;
    padding: 8px 12px;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    background-color: #ffffff;
}

/* Contoh card highlight */
body:not(.printing) .concept-card-wrapper.example-box {
    border-color: var(--primary);
    background-color: rgba(255, 181, 74, 0.05);
}

.concept-header-label {
    font-size: 13px;
    font-weight: 700;
    color: #0f172a;
    margin-bottom: 4px;
    text-transform: uppercase;
}

.concept-story-text {
    font-size: 12px;
    font-weight: 600;
    color: #1e293b;
    line-height: 1.4;
    margin-bottom: 6px;
}

.concept-sub-question {
    font-size: 11.5px;
    font-weight: 600;
    color: #334155;
    margin-bottom: 4px;
}

/* Containers SVG row (in Contoh box) */
.concept-containers-row {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
    margin: 4px 0;
    flex-wrap: wrap;
}

/* Blank box for drawing */
.concept-drawing-box {
    border: 1.8px dashed #64748b;
    border-radius: 8px;
    height: 110px;
    width: 100%;
    margin: 4px 0 8px 0;
    background-color: #fafafa;
}

body:not(.printing) .concept-drawing-box {
    border-color: var(--accent);
    background-color: rgba(43, 109, 136, 0.05);
}

/* Mathematical Sentence line underneath drawing */
.concept-math-sentence {
    font-size: 12px;
    font-weight: 700;
    color: #0f172a;
    display: flex;
    align-items: center;
    gap: 4px;
    margin-top: 4px;
}

.concept-conclusion {
    font-size: 12px;
    font-weight: 700;
    color: #0f172a;
    display: flex;
    align-items: center;
    gap: 4px;
    margin-top: 6px;
}

/* Underline placeholder lines */
.concept-blank-line {
    display: inline-block;
    width: 25px;
    border-bottom: 1.8px solid #0f172a;
    height: 12px;
    margin: 0 2px;
}

.concept-blank-line.wide {
    width: 35px;
}

.concept-math-val {
    font-weight: 700;
    color: #2563eb;
    margin: 0 2px;
    font-size: 13px;
    border-bottom: 1.8px solid transparent;
}

.color-mode-grayscale .concept-math-val {
    color: #000000;
}

/* Adjust size of boxes depending on count */
.concept-body.count-2 .concept-card-wrapper {
    padding: 10px 14px;
}
.concept-body.count-2 .concept-drawing-box {
    height: 135px;
}
.concept-body.count-3 .concept-card-wrapper {
    padding: 6px 10px;
}
.concept-body.count-3 .concept-drawing-box {
    height: 80px;
}

/* Container SVG dimensions and grayscale print overrides */
.concept-container-svg {
    max-width: 65px;
    max-height: 65px;
}
.concept-body.count-3 .concept-container-svg {
    max-width: 50px;
    max-height: 50px;
}

/* --- TIPE 9: PENJUMLAHAN KOLOM (Column Addition) --- */
.column-addition-body {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    column-gap: 12px;
    row-gap: 28px;
    flex-grow: 1;
    align-content: space-evenly;
    padding: 10px 5px;
    margin-bottom: 8mm;
}

/* Adjust row gap based on problem count */
.column-addition-body.count-8 { row-gap: 40px; padding-top: 15px; }
.column-addition-body.count-16 { row-gap: 22px; padding-top: 5px; }
.column-addition-body.count-20 { row-gap: 18px; padding-top: 0px; }

/* Instruction text spanning the grid */
.col-instructions {
    grid-column: 1 / -1;
    font-size: 13px;
    font-weight: 600;
    color: #475569;
    margin-bottom: 10px;
    text-align: left;
}

/* Flex container for index number and equation stack */
.col-problem-container {
    display: flex;
    align-items: flex-start;
    justify-content: center;
    min-width: 0;
    margin: 0 auto;
    width: 100%;
}

.col-problem-index {
    font-size: 20px;
    font-weight: 700;
    color: #0f172a;
    margin-right: 6px;
    line-height: 1.2;
}

/* Equation stack with fixed proportional width to align digits */
.col-problem-equation {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    width: 2.2em;
}

.col-number {
    font-size: 20px;
    font-weight: 700;
    color: #0f172a;
    line-height: 1.2;
    text-align: right;
    width: 100%;
    display: block;
}

.col-operator-row {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    width: 100%;
    line-height: 1.2;
}

.col-plus-sign {
    font-size: 20px;
    font-weight: 700;
    color: #0f172a;
    line-height: 1.2;
}

/* Divisor horizontal line under bottom number */
.col-line {
    width: 100%;
    border-bottom: 2.2px solid #0f172a;
    margin-top: 1px;
}

/* Answer space where student writes */
.col-answer-space {
    height: 26px;
    width: 100%;
}

/* Student guide underline at bottom */
.col-line-bottom {
    width: 100%;
    border-bottom: 1.5px solid #0f172a;
}

/* Adjust font sizes and answer spaces based on problem counts */
.column-addition-body.count-8 .col-number,
.column-addition-body.count-8 .col-plus-sign,
.column-addition-body.count-8 .col-problem-index {
    font-size: 22px;
}
.column-addition-body.count-8 .col-answer-space {
    height: 32px;
}

.column-addition-body.count-16 .col-number,
.column-addition-body.count-16 .col-plus-sign,
.column-addition-body.count-16 .col-problem-index {
    font-size: 18px;
}
.column-addition-body.count-16 .col-answer-space {
    height: 22px;
}

.column-addition-body.count-20 .col-number,
.column-addition-body.count-20 .col-plus-sign,
.column-addition-body.count-20 .col-problem-index {
    font-size: 17px;
}
.column-addition-body.count-20 .col-answer-space {
    height: 20px;
}

/* Print overrides for column addition */
@media print {
    .col-line {
        border-bottom-color: #000000 !important;
    }
    .col-line-bottom {
        border-bottom-color: #000000 !important;
    }
    .col-number, 
    .col-plus-sign, 
    .col-problem-index, 
    .col-instructions {
        color: #000000 !important;
    }
}

/* --- TIPE 11: OPERASI BILANGAN BULAT (Integer Operations) --- */
/* Persamaan bilangan bulat lebih panjang (kurung & minus), font sedikit dikecilkan */
.integer-ops-body .simple-equation-wrapper {
    font-size: 16px;
    justify-content: flex-end; /* Rata kanan tiap kolom soal */
    padding-right: 12px;
}
.integer-ops-body .simple-equation-text {
    letter-spacing: 1px;
}
.integer-ops-body .simple-equation-answer {
    width: 42px;
}
.integer-ops-body.problems-count-10 .simple-equation-wrapper { font-size: 20px; }
.integer-ops-body.problems-count-10 .simple-equation-answer { width: 48px; }
.integer-ops-body.problems-count-14 .simple-equation-wrapper { font-size: 18px; }
.integer-ops-body.problems-count-20 .simple-equation-wrapper { font-size: 15px; }
.integer-ops-body.problems-count-24 .simple-equation-wrapper { font-size: 14px; }
.integer-ops-body.problems-count-30 .simple-equation-wrapper { font-size: 13px; }

/* --- TIPE 12: SOAL CERITA BILANGAN BULAT (Integer Stories) --- */
.integer-story-body {
    display: flex;
    flex-direction: column;
    flex-grow: 1;
    justify-content: space-between;
    gap: 8px;
    padding-top: 6px;
    margin-bottom: 8mm;
}

.story-card {
    display: flex;
    gap: 8px;
    border-bottom: 1px dotted #cbd5e1;
    padding-bottom: 8px;
}

.story-card:last-child {
    border-bottom: none;
}

.color-mode-grayscale .story-card {
    border-bottom-color: #000000;
}

.story-num {
    font-size: 15px;
    font-weight: 700;
    color: #2563eb;
    min-width: 20px;
    line-height: 1.4;
}

.color-mode-grayscale .story-num {
    color: #000000;
}

.story-content {
    flex: 1;
}

.story-text {
    font-size: 13px;
    font-weight: 600;
    color: #1e293b;
    line-height: 1.5;
    margin-bottom: 6px;
}

.story-equation {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 16px;
    font-weight: 700;
    color: #0f172a;
}

.se-num {
    min-width: 20px;
    text-align: center;
}

.se-op,
.se-eq {
    font-weight: 700;
    color: #0f172a;
}

.story-answer-blank {
    display: inline-block;
    width: 46px;
    border-bottom: 1.8px solid #0f172a;
    height: 20px;
}

.story-answer-blank.wide {
    width: 38px;
}

.story-answer-blank.extrawide {
    width: 80px;
}

.story-prefix {
    font-size: 13px;
    font-weight: 600;
    color: #475569;
}

/* Mode kolom jawaban kosong (anak berpikir sendiri) */
.story-equation.story-answer-only {
    margin-top: 4px;
}
.story-answer-only .story-answer-blank.extrawide {
    width: 140px;
    height: 24px;
    border-bottom: 1.8px solid #0f172a;
}

/* Penyesuaian ukuran berdasarkan jumlah soal */
.story-count-5 .story-text { font-size: 14.5px; line-height: 1.6; }
.story-count-5 .story-equation { font-size: 18px; }
.story-count-5 .story-num { font-size: 16px; }

.story-count-8 .story-text { font-size: 12px; line-height: 1.4; }
.story-count-8 .story-equation { font-size: 14px; }
.story-count-8 .story-num { font-size: 13px; }
.story-count-8 .story-card { padding-bottom: 5px; }

.story-count-10 .story-text { font-size: 11px; line-height: 1.35; }
.story-count-10 .story-equation { font-size: 13px; }
.story-count-10 .story-num { font-size: 12px; }
.story-count-10 .story-card { padding-bottom: 4px; gap: 6px; }

/* --- TIPE 13: NILAI TEMPAT (Place Value) --- */
.place-value-body {
    display: grid;
    grid-template-columns: 1fr;
    row-gap: 10px;
    flex-grow: 1;
    align-content: start;
    padding: 14px 8px 0;
    margin-bottom: 22mm; /* ruang aman di atas footer */
}

/* Soal Jenis 2 (expand) ditampilkan 2 kolom */
.place-value-body.pv-layout-two-col {
    grid-template-columns: 1fr 1fr;
    column-gap: 24px;
    row-gap: 14px;
}

/* Untuk 6 soal, spasi lebih lega */
.place-value-body.pv-count-6 {
    row-gap: 26px;
    padding: 20px 8px 0;
}

.pv-card {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 4px 6px;
    background-color: transparent;
}

/* Tanpa box border */
.pv-card,
body:not(.printing) .pv-card {
    border: none;
    border-radius: 0;
}

/* Kartu decompose: N = __ puluhan + __ satuan (menyambung horizontal) */
.pv-decompose {
    justify-content: center;
    padding: 6px 6px;
}

/* Label inline (puluhan / satuan) setelah isian */
.pv-label-inline {
    font-size: 13px;
    font-weight: 600;
    color: #475569;
}

/* Kartu expand: persamaan N = __ + __ */
.pv-expand {
    justify-content: center;
    padding: 6px 6px;
}

.pv-eq {
    display: flex;
    align-items: center;
    gap: 7px;
    font-size: 21px;
    font-weight: 800;
    color: #0f172a;
}

.pv-number-small {
    font-size: 24px;
    font-weight: 800;
    color: #000000;
}

.pv-eq-sign {
    font-weight: 700;
}

.pv-plus {
    font-weight: 700;
}

.pv-part {
    font-size: 21px;
    font-weight: 800;
    color: #0f172a;
    min-width: 28px;
    text-align: center;
}

.pv-blank-wide {
    display: inline-block;
    width: 46px;
    border-bottom: 2px solid #0f172a;
    height: 20px;
}

/* Penyesuaian ukuran berdasarkan jumlah soal */
.place-value-body.pv-count-8 .pv-eq { font-size: 20px; }
.place-value-body.pv-count-8 .pv-number-small { font-size: 23px; }

.place-value-body.pv-count-10 .pv-eq { font-size: 19px; }
.place-value-body.pv-count-10 .pv-number-small { font-size: 22px; }

.place-value-body.pv-count-12 .pv-eq { font-size: 17px; }
.place-value-body.pv-count-12 .pv-number-small { font-size: 20px; }

/* --- TIPE 14: NILAI TEMPAT LANJUT (Ratusan & Ribuan) --- */
/* Satu soal per baris (1 kolom) */
.place-value-body.pv-ext-body {
    grid-template-columns: 1fr;
    row-gap: 14px;
    padding: 14px 10px 0;
}

/* Persamaan dalam satu baris (tidak bungkus) */
.pv-ext-eq {
    flex-wrap: nowrap;
    justify-content: flex-start;
    gap: 4px; /* Lebih kecil */
    font-size: 15px; /* Font dasar lebih kecil */
}
.pv-ext-card {
    justify-content: flex-start;
    padding: 4px 6px;
}
.pv-ext-eq .pv-number-small { font-size: 18px; } /* Angka utama lebih kecil */
.pv-ext-eq .pv-part { font-size: 15px; } /* Suku-suku lebih kecil */
.pv-ext-eq .pv-blank-wide { width: 32px; height: 16px; } /* Isian lebih sempit */

/* Isian angka utama untuk Variasi 2 (___ = 300 + 60 + 5) */
.pv-ext-eq .pv-blank-number {
    display: inline-block;
    min-width: 50px; /* Isian angka utama lebih sempit */
    border-bottom: 2px solid #0f172a;
    height: 18px;
}

/* Untuk 6 soal, font lebih besar & spasi lega */
.place-value-body.pv-ext-body.pv-count-6 {
    row-gap: 26px;
    padding: 20px 10px 0;
}
.pv-count-6 .pv-ext-eq { font-size: 20px; gap: 6px; }
.pv-count-6 .pv-ext-eq .pv-number-small { font-size: 24px; }
.pv-count-6 .pv-ext-eq .pv-part { font-size: 20px; }
.pv-count-6 .pv-ext-eq .pv-blank-wide { width: 40px; height: 20px; }
.pv-count-6 .pv-ext-eq .pv-blank-number { min-width: 65px; height: 22px; }

/* Untuk 10 soal, perkecil lagi */
.place-value-body.pv-ext-body.pv-count-10 { row-gap: 10px; }
.place-value-body.pv-ext-body.pv-count-10 .pv-ext-eq { font-size: 14px; gap: 3px; }
.place-value-body.pv-ext-body.pv-count-10 .pv-ext-eq .pv-number-small { font-size: 16px; }
.place-value-body.pv-ext-body.pv-count-10 .pv-ext-eq .pv-part { font-size: 14px; }
.place-value-body.pv-ext-body.pv-count-10 .pv-ext-eq .pv-blank-wide { width: 28px; height: 14px; }
.place-value-body.pv-ext-body.pv-count-10 .pv-ext-eq .pv-blank-number { min-width: 45px; height: 16px; }

/* Untuk 12 soal, paling kecil */
.place-value-body.pv-ext-body.pv-count-12 { row-gap: 8px; }
.place-value-body.pv-ext-body.pv-count-12 .pv-ext-eq { font-size: 13px; gap: 3px; }
.pv-ext-body.pv-ext-body.pv-count-12 .pv-ext-eq .pv-number-small { font-size: 15px; }
.place-value-body.pv-ext-body.pv-count-12 .pv-ext-eq .pv-part { font-size: 13px; }
.place-value-body.pv-ext-body.pv-count-12 .pv-ext-eq .pv-blank-wide { width: 25px; height: 13px; }
.place-value-body.pv-ext-body.pv-count-12 .pv-ext-eq .pv-blank-number { min-width: 40px; height: 14px; }

/* --- TIPE 15: PERBANDINGAN BILANGAN (Number Comparison) --- */
/* Format: A ___ B (isi >, <, atau =) */
.comparison-body {
    grid-template-columns: 1fr 1fr;
    column-gap: 20px;
    row-gap: 22px;
    padding-top: 20px;
}

/* Untuk 10 soal, 1 kolom */
.comparison-body.cmp-count-10 {
    grid-template-columns: 1fr;
    row-gap: 35px;
    padding-top: 30px;
}

.comparison-wrapper {
    justify-content: center;
    gap: 14px;
    font-size: 20px;
    font-weight: 700;
    color: #0f172a;
}

.comparison-num {
    font-size: 22px;
    font-weight: 800;
    color: #000000;
}

.comparison-blank {
    width: 40px;
    height: 26px;
    border-bottom: 2px solid #0f172a;
    text-align: center;
}

/* Penyesuaian ukuran berdasarkan jumlah soal */
.cmp-count-14 .comparison-wrapper { font-size: 20px; }
.cmp-count-14 .comparison-num { font-size: 22px; }

.cmp-count-20 .comparison-wrapper { font-size: 18px; gap: 10px; }
.cmp-count-20 .comparison-num { font-size: 20px; }
.cmp-count-20 .comparison-blank { width: 34px; height: 22px; }

.cmp-count-24 .comparison-wrapper { font-size: 16px; gap: 8px; }
.cmp-count-24 .comparison-num { font-size: 18px; }
.cmp-count-24 .comparison-blank { width: 30px; height: 20px; }

/* --- TIPE 16: PENJUMLAHAN RIBUAN KOLOM --- */
.col-thousand-body {
    grid-template-columns: repeat(3, 1fr);
    column-gap: 15px;
    row-gap: 30px;
    align-content: space-evenly;
    padding: 10px 5px;
    margin-bottom: 8mm;
}

.col-thousand-body.col-thousand-count-4 {
    grid-template-columns: repeat(2, 1fr);
    row-gap: 40px;
}
.col-thousand-body.col-thousand-count-4 .col-number {
    font-size: 26px;
}
.col-thousand-body.col-thousand-count-4 .col-plus-sign {
    font-size: 26px;
}
.col-thousand-body.col-thousand-count-4 .col-answer-space {
    height: 38px;
}

.col-thousand-body.col-thousand-count-6 {
    grid-template-columns: repeat(3, 1fr);
    row-gap: 30px;
}
.col-thousand-body.col-thousand-count-6 .col-number {
    font-size: 24px;
}
.col-thousand-body.col-thousand-count-6 .col-plus-sign {
    font-size: 24px;
}
.col-thousand-body.col-thousand-count-6 .col-answer-space {
    height: 34px;
}

.col-thousand-body.col-thousand-count-8 {
    grid-template-columns: repeat(4, 1fr);
    row-gap: 25px;
}
.col-thousand-body.col-thousand-count-8 .col-number {
    font-size: 20px;
}
.col-thousand-body.col-thousand-count-8 .col-plus-sign {
    font-size: 20px;
}
.col-thousand-body.col-thousand-count-8 .col-answer-space {
    height: 28px;
}

/* Override base column addition, karena ini ribuan butuh lebar */
.col-problem-equation {
    width: 3.5em; /* Lebih lebar untuk 4 digit */
    font-family: monospace; /* Tambahkan untuk perataan digit */
    font-size: 20px;
}

/* --- TIPE 17: MENULIS ANGKA (Number To Words) --- */
.number-to-words-body {
    grid-template-columns: 1fr;
    row-gap: 12px;
    padding: 15px 10px;
    align-content: start;
}

.ntw-problem-wrapper {
    display: flex;
    align-items: baseline;
    justify-content: flex-start;
    gap: 8px;
    font-size: 16px;
    color: #0f172a;
}

.ntw-words {
    font-weight: 600;
    line-height: 1.5;
    flex-shrink: 0;
}

.ntw-blank {
    flex-grow: 1;
    border-bottom: 1.5px solid #0f172a;
    height: 18px;
}

/* Penyesuaian ukuran berdasarkan jumlah soal */
.ntw-count-6 .ntw-problem-wrapper { font-size: 18px; row-gap: 16px; }
.ntw-count-6 .ntw-words { font-size: 18px; }
.ntw-count-6 .ntw-blank { height: 22px; }

.ntw-count-10 .ntw-problem-wrapper { font-size: 14px; row-gap: 10px; }
.ntw-count-10 .ntw-words { font-size: 14px; }
.ntw-count-10 .ntw-blank { height: 16px; }

.ntw-count-12 .ntw-problem-wrapper { font-size: 13px; row-gap: 8px; }
.ntw-count-12 .ntw-words { font-size: 13px; }
.ntw-count-12 .ntw-blank { height: 15px; }

/* --- TIPE 18: OPERASI CAMPURAN BILANGAN BULAT (Mixed Operations) --- */
.mixed-ops-body {
    grid-template-columns: 1fr;
    row-gap: 14px;
    padding: 15px 10px;
    align-content: start;
}

.mixed-ops-wrapper {
    justify-content: flex-start;
    font-size: 17px;
    gap: 8px;
}

.mixed-ops-wrapper .simple-equation-text {
    letter-spacing: 1px;
}

/* Penyesuaian ukuran berdasarkan jumlah soal */
.mix-count-6 .mixed-ops-wrapper { font-size: 20px; }
.mix-count-8 .mixed-ops-wrapper { font-size: 18px; }
.mix-count-10 .mixed-ops-wrapper { font-size: 16px; }
.mix-count-12 .mixed-ops-wrapper { font-size: 14px; }

/* --- TIPE 19: PENGURANGAN BERSUSUN --- */
.column-subtraction-body .col-problem-equation {
    width: 3.2em;
    font-variant-numeric: tabular-nums;
}

.column-subtraction-body.count-8 .col-problem-equation {
    width: 3.6em;
}

.column-subtraction-body .col-minus-sign {
    margin-right: 2px;
}

/* --- TIPE 20 & 21: FPB DAN KPK --- */
.gk-body {
    display: flex;
    flex-direction: column;
    flex-grow: 1;
    margin-bottom: 8mm;
    padding-top: 4px;
}

.gk-list {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    flex-grow: 1;
}

.gk-problem {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    padding: 4px 0;
    border-bottom: 1px dotted #cbd5e1;
}

.gk-problem:last-child {
    border-bottom: none;
}

.color-mode-grayscale .gk-problem {
    border-bottom-color: #000000;
}

.gk-index {
    flex: 0 0 auto;
    min-width: 20px;
    font-size: 13px;
    font-weight: 800;
    color: #2563eb;
    padding-top: 3px;
}

.color-mode-grayscale .gk-index {
    color: #000000;
}

.gk-content {
    flex: 1 1 auto;
}

.gk-equation {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    font-size: 15px;
    font-weight: 700;
    color: #0f172a;
}

.gk-equation b {
    font-weight: 800;
}

.gk-answer-line {
    display: inline-block;
    min-width: 60px;
    height: 18px;
    border-bottom: 1.8px solid #0f172a;
}

.gk-work {
    height: 26px;
}

.gk-count-6 .gk-work {
    height: 40px;
}

.gk-count-10 .gk-work {
    height: 14px;
}

@media print {
    .gk-answer-line {
        border-bottom-color: #000000 !important;
    }
    .gk-problem {
        border-bottom-color: #000000 !important;
    }
}

/* --- TIPE 22: OPERASI DESIMAL --- */
.decimal-body .simple-equation-wrapper {
    justify-content: flex-start;
    gap: 4px;
    font-size: 18px;
    font-variant-numeric: tabular-nums;
}

.decimal-body .simple-equation-text {
    letter-spacing: .5px;
}

.decimal-body .simple-equation-answer {
    width: 86px;
    margin-left: 8px;
}

.decimal-body.problems-count-8 .simple-equation-wrapper { font-size: 22px; }
.decimal-body.problems-count-8 .simple-equation-answer { width: 104px; height: 24px; }

.decimal-body.problems-count-16 .simple-equation-wrapper { font-size: 16px; }
.decimal-body.problems-count-16 .simple-equation-answer { width: 80px; }

.decimal-body.problems-count-20 .simple-equation-wrapper { font-size: 15px; }
.decimal-body.problems-count-20 .simple-equation-answer { width: 74px; }

/* --- PRINT RULES (THE MOST CRITICAL SECTION) --- */
@media print {
    /* Hide scrollbars & body BG on physical print */
    body {
        background-color: #ffffff !important;
        color: #000000 !important;
        overflow: visible !important;
        height: auto !important;
        width: auto !important;
    }
    
    .app-container {
        display: block !important;
        height: auto !important;
        width: auto !important;
    }

    .sidebar,
    .preview-header,
    .module-guide {
        display: none !important;
    }

    .preview-workspace {
        background: transparent !important;
        padding: 0 !important;
        margin: 0 !important;
        display: block !important;
        height: auto !important;
        width: auto !important;
    }

    .pages-container {
        padding: 0 !important;
        margin: 0 !important;
        display: block !important;
        overflow: visible !important;
        height: auto !important;
        width: auto !important;
    }

    /* Print settings for sheet cards */
    .a5-page {
        margin: 0 !important;
        box-shadow: none !important;
        border-radius: 0 !important;
        background-color: #ffffff !important;
        border: none !important;
        
        /* Force page dimensions */
        width: 148mm !important;
        height: 210mm !important;
        min-height: 210mm !important;
        
        /* Force printing engine page break rules */
        page-break-after: always !important;
        page-break-inside: avoid !important;
        break-after: page !important;
        break-inside: avoid !important;
        position: relative !important;
        zoom: 1 !important;
    }

    /* Reset print styling for worksheets */
    .number-cell.blank-cell {
        background-color: #ffffff !important;
        border-color: #000000 !important;
    }

    /* Contoh soal & kunci jawaban hitam putih saat dicetak */
    .worked-example {
        background-color: #ffffff !important;
        border-color: #000000 !important;
        color: #000000 !important;
    }

    .worked-example .ex-label {
        background-color: #ffffff !important;
        color: #000000 !important;
        border: 1px solid #000000 !important;
    }

    .worked-example b,
    .key-item,
    .key-item .q-index,
    .key-item .key-row-label,
    .key-instruction,
    .worksheet-subtitle {
        color: #000000 !important;
    }

    .concept-card-wrapper {
        border-color: #000000 !important;
        background-color: #ffffff !important;
    }
    .concept-drawing-box {
        border-color: #000000 !important;
        background-color: #ffffff !important;
    }
    .concept-blank-line {
        border-bottom-color: #000000 !important;
    }
}

/* Page configurations */
@page {
    size: A5 portrait;
    margin: 0;
}

.ph-back {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    min-height: 44px;
    font-size: 12px;
    font-weight: 700;
    color: var(--accent);
    text-decoration: none;
}

.ph-back:hover {
    text-decoration: underline;
    text-underline-offset: 3px;
}

.ph-back span {
    font-size: 18px;
}

.control-group,
.control-group-grid > * {
    min-width: 0;
}

/* Give the two related settings enough room on a wider phone or tablet. */
@media (min-width: 600px) and (max-width: 860px) {
    .radio-group-tabs {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        column-gap: 8px;
    }

    .type-group-title {
        grid-column: 1 / -1;
    }

    .general-settings {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        column-gap: 20px;
    }

    .general-settings > .section-title,
    .general-settings > .checkbox-options {
        grid-column: 1 / -1;
    }
}

/* Stack the tool and preview; remove the source of the horizontal page scroll. */
@media (max-width: 860px) {
    body {
        overflow: auto;
        height: auto;
    }

    .app-container {
        flex-direction: column;
        height: auto;
        min-height: 100vh;
        width: 100%;
    }

    .sidebar {
        width: 100%;
        border-right: none;
        border-bottom: 1px solid var(--border-color);
    }

    .sidebar-header,
    .sidebar-footer {
        padding-inline: 20px;
    }

    .control-sections {
        overflow: visible;
    }

    .sidebar,
    .control-sections,
    .sidebar-footer {
        min-width: 0;
        max-width: 100%;
    }

    .preview-workspace {
        min-height: 60vh;
        width: 100%;
    }

    .preview-header {
        padding: 14px 16px;
        flex-wrap: wrap;
        gap: 8px;
    }

    .pages-container {
        padding: 24px 12px;
        align-items: center;
        overflow-x: hidden;
    }

    /* Phone and tablet stack into one scroll. Pin the guide to the viewport bottom
       and reserve its height so the print button and last sheet can scroll clear. */
    .app-container {
        padding-bottom: calc(11.5rem + env(safe-area-inset-bottom));
    }

    .module-guide {
        position: fixed;
        left: 0;
        right: 0;
        bottom: 0;
        padding-bottom: max(14px, env(safe-area-inset-bottom));
    }

    /* Fit the paper into the phone without changing its A5 print dimensions. */
    .a5-page {
        zoom: calc((100vw - 48px) / 559.36px);
        flex-shrink: 0;
        margin-bottom: 16px;
    }
}

/* At the narrowest widths, paired fields become comfortable full-width rows. */
@media (max-width: 480px) {
    .sidebar-header {
        padding-top: 8px;
        padding-bottom: 12px;
    }

    .product-heading {
        margin-top: 4px;
    }

    .module-guide {
        grid-template-columns: minmax(0, 1fr) auto;
        grid-template-areas:
            "head play"
            "short short"
            "details details"
            "status status";
        padding: 12px 16px;
    }

    .guide-short {
        -webkit-line-clamp: 3;
    }

    .guide-play-label {
        display: none;
    }

    .guide-long-list {
        font-size: 13px;
    }

    .control-sections {
        padding: 12px;
        gap: 12px;
    }

    .control-card {
        padding: 16px;
    }

    .control-group-grid {
        grid-template-columns: minmax(0, 1fr);
        gap: 0;
    }

    .control-group-grid .control-group {
        margin-bottom: 14px;
    }

    .control-group-grid .control-group:last-child {
        margin-bottom: 0;
    }

    .sidebar-footer {
        padding: 16px 20px 20px;
    }

    .resource-row {
        gap: 0 12px;
    }
}

@media (prefers-reduced-motion: reduce) {
    .tab-label,
    input[type="text"],
    input[type="number"],
    select {
        transition: none;
    }
}

@media print{.ph-back{display:none}}
