.image-widget {
    margin-top: 1.2rem;
    padding: 1.4rem;
    border: 1px solid #dbeafe;
    border-radius: 24px;
    background: linear-gradient(135deg, #f8fbff, #eef6ff);
    box-shadow: 0 14px 35px rgba(15, 23, 42, 0.08);
}

.image-widget-controls,
.bitmap-size-controls {
    display: flex;
    flex-wrap: wrap;
    align-items: end;
    gap: 0.9rem;
    margin-bottom: 1.2rem;
}

.image-widget-controls label,
.size-field label {
    display: block;
    margin-bottom: 0.35rem;
    font-weight: 800;
    color: #1e293b;
}

.image-widget-controls input,
.image-widget-controls select,
.bitmap-size-controls input,
.bitmap-size-controls select {
    padding: 0.7rem 0.85rem;
    border: 1px solid #cbd5e1;
    border-radius: 14px;
    background: #ffffff;
    font-size: 1rem;
}

.image-widget-controls input[type="range"] {
    width: 240px;
}

.image-widget-controls button {
    border: 0;
    border-radius: 999px;
    padding: 0.75rem 1rem;
    font-weight: 800;
    cursor: pointer;
    background: #2563eb;
    color: #ffffff;
    box-shadow: 0 8px 18px rgba(37, 99, 235, 0.22);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.image-widget-controls button:hover {
    transform: translateY(-1px);
    box-shadow: 0 12px 22px rgba(37, 99, 235, 0.28);
}

#scaleValue {
    font-weight: 900;
    color: #1d4ed8;
    min-width: 44px;
}

.comparison-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 1rem;
}

.comparison-card {
    padding: 1rem;
    border-radius: 22px;
    background: #ffffff;
    border: 1px solid #e2e8f0;
    box-shadow: 0 8px 18px rgba(15, 23, 42, 0.06);
}

.comparison-card h3 {
    margin-top: 0;
}

.vector-stage,
.bitmap-stage {
    height: 280px;
    display: grid;
    place-items: center;
    overflow: hidden;
    border-radius: 18px;
    background:
        linear-gradient(45deg, #f8fafc 25%, transparent 25%),
        linear-gradient(-45deg, #f8fafc 25%, transparent 25%),
        linear-gradient(45deg, transparent 75%, #f8fafc 75%),
        linear-gradient(-45deg, transparent 75%, #f8fafc 75%);
    background-size: 24px 24px;
    background-position: 0 0, 0 12px, 12px -12px, -12px 0px;
    border: 1px solid #e2e8f0;
}

#vectorLogo {
    width: 130px;
    height: 130px;
    transform-origin: center;
    transition: transform 0.35s ease;
}

#vectorLogo rect {
    fill: #dbeafe;
    stroke: #2563eb;
    stroke-width: 5;
}

#vectorLogo circle {
    fill: #fef3c7;
    stroke: #f59e0b;
    stroke-width: 5;
}

#vectorLogo path {
    fill: #bbf7d0;
    stroke: #16a34a;
    stroke-width: 5;
    stroke-linejoin: round;
}

.bitmap-zoom-grid {
    display: grid;
    grid-template-columns: repeat(8, 16px);
    grid-template-rows: repeat(8, 16px);
    transform-origin: center;
    transition: transform 0.35s ease;
    image-rendering: pixelated;
}

.bitmap-zoom-cell {
    width: 16px;
    height: 16px;
    box-sizing: border-box;
    border: 0.5px solid rgba(15, 23, 42, 0.12);
}

.image-widget-note {
    margin-top: 1rem;
    padding: 1rem;
    border-radius: 18px;
    background: #fff7ed;
    border: 1px solid #fed7aa;
    color: #7c2d12;
    font-weight: 700;
}

.pixel-painter-layout {
    display: grid;
    grid-template-columns: minmax(260px, 360px) 1fr;
    gap: 1rem;
    align-items: start;
}

.pixel-paint-grid {
    display: grid;
    grid-template-columns: repeat(8, 34px);
    grid-template-rows: repeat(8, 34px);
    gap: 4px;
    padding: 0.8rem;
    border-radius: 20px;
    background: #e2e8f0;
    width: max-content;
}

.pixel-paint-cell {
    width: 34px;
    height: 34px;
    border: 0;
    border-radius: 9px;
    cursor: pointer;
    box-shadow: inset 0 0 0 1px rgba(15, 23, 42, 0.14);
    transition: transform 0.12s ease, box-shadow 0.12s ease;
}

.pixel-paint-cell:hover {
    transform: scale(1.08);
    box-shadow: inset 0 0 0 2px rgba(37, 99, 235, 0.45);
}

.pixel-data-panel {
    padding: 1rem;
    border-radius: 20px;
    background: #ffffff;
    border: 1px solid #e2e8f0;
    box-shadow: 0 8px 18px rgba(15, 23, 42, 0.06);
}

.pixel-data-panel h3 {
    margin-top: 0;
}

.pixel-data-panel pre {
    overflow-x: auto;
    padding: 1rem;
    border-radius: 14px;
    background: #0f172a;
    color: #e2e8f0;
    font-size: 0.9rem;
    line-height: 1.5;
}

.bitmap-size-controls {
    align-items: stretch;
}

.size-field {
    display: flex;
    flex-direction: column;
    min-width: 170px;
    flex: 1;
}

.bitmap-size-results {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(155px, 1fr));
    gap: 0.9rem;
    margin: 1rem 0;
}

.size-result-card {
    padding: 1rem;
    border-radius: 18px;
    background: #ffffff;
    border: 1px solid #e2e8f0;
    box-shadow: 0 8px 18px rgba(15, 23, 42, 0.06);
}

.size-label {
    display: block;
    margin-bottom: 0.35rem;
    font-size: 0.78rem;
    font-weight: 900;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #64748b;
}

.size-result-card strong {
    font-size: 1.18rem;
    color: #0f172a;
    word-break: break-word;
}

.calculation-steps {
    margin-top: 1rem;
    padding: 1rem;
    border-radius: 18px;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
}

.calculation-step {
    display: flex;
    gap: 0.75rem;
    align-items: flex-start;
    padding: 0.75rem 0;
    border-bottom: 1px solid #e2e8f0;
}

.calculation-step:last-child {
    border-bottom: 0;
}

.step-badge {
    flex: 0 0 auto;
    width: 30px;
    height: 30px;
    display: grid;
    place-items: center;
    border-radius: 999px;
    background: #dbeafe;
    color: #1d4ed8;
    font-weight: 900;
}

.step-text strong {
    color: #0f172a;
}

.step-text code {
    background: #e2e8f0;
    padding: 0.12rem 0.35rem;
    border-radius: 6px;
}

.exam-tip-box,
.warning-box {
    margin: 1rem 0;
    padding: 1rem;
    border-radius: 18px;
}

.exam-tip-box {
    background: #ecfdf5;
    border: 1px solid #bbf7d0;
    color: #14532d;
}

.warning-box {
    background: #fff7ed;
    border: 1px solid #fed7aa;
    color: #7c2d12;
}

.formula-line {
    padding: 0.8rem 1rem;
    border-radius: 16px;
    background: #f1f5f9;
    border: 1px solid #e2e8f0;
}

@media (max-width: 760px) {
    .pixel-painter-layout {
        grid-template-columns: 1fr;
    }

    .pixel-paint-grid {
        grid-template-columns: repeat(8, 28px);
        grid-template-rows: repeat(8, 28px);
    }

    .pixel-paint-cell {
        width: 28px;
        height: 28px;
    }

    .image-widget-controls,
    .bitmap-size-controls {
        flex-direction: column;
        align-items: stretch;
    }

    .image-widget-controls input[type="range"] {
        width: 100%;
    }
}

#bitmapCanvas {
    display: block;
    width: 96px;
    height: 96px;
    image-rendering: pixelated;
    image-rendering: crisp-edges;
    border: 1px solid rgba(15, 23, 42, 0.12);
    background: white;
}

/* =========================================================
   Interactive Vector Storage Demonstration
   ========================================================= */

.vector-object-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.65rem;

    margin: 1rem 0;
}

.vector-toolbar-label {
    font-weight: 800;
    color: #334155;
}

.vector-object-select,
.vector-reset-button {
    border: 1px solid #cbd5e1;
    border-radius: 999px;

    padding: 0.65rem 1rem;

    background: #ffffff;
    color: #334155;

    font-size: 0.92rem;
    font-weight: 800;

    cursor: pointer;

    transition:
        background 0.2s ease,
        color 0.2s ease,
        border-color 0.2s ease,
        transform 0.2s ease;
}

.vector-object-select:hover,
.vector-reset-button:hover {
    transform: translateY(-1px);
    border-color: #2563eb;
}

.vector-object-select.active {
    background: #2563eb;
    border-color: #2563eb;
    color: #ffffff;
}

.vector-reset-button {
    margin-left: auto;
}


/* =========================================================
   Main two-column layout
   ========================================================= */

.vector-storage-layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 1.2rem;

    margin-top: 1rem;
}

.vector-storage-code,
.vector-storage-preview {
    min-width: 0;

    padding: 1rem;

    border-radius: 20px;
    background: #ffffff;
    border: 1px solid #e2e8f0;

    box-shadow: 0 8px 18px rgba(15, 23, 42, 0.05);
}

.vector-storage-code h4,
.vector-storage-preview h4 {
    margin-top: 0;
}


/* =========================================================
   Stored SVG code
   ========================================================= */

.vector-live-code {
    margin: 0 0 1rem;

    padding: 1rem;

    overflow-x: auto;

    border-radius: 16px;

    background: #0f172a;
    color: #cbd5e1;

    font-family:
        "SFMono-Regular",
        Consolas,
        "Liberation Mono",
        monospace;

    font-size: 0.86rem;
    line-height: 1.65;
}

.vector-code-line {
    display: block;

    padding: 0.15rem 0.35rem;

    border-radius: 7px;

    opacity: 0.48;

    transition:
        opacity 0.2s ease,
        background 0.2s ease,
        color 0.2s ease;
}

.vector-code-line.active {
    opacity: 1;

    background: rgba(96, 165, 250, 0.18);
    color: #ffffff;
}


/* =========================================================
   Property controls
   ========================================================= */

.vector-property-controls {
    margin-top: 1rem;

    padding: 1rem;

    border-radius: 16px;

    background: #f8fafc;
    border: 1px solid #e2e8f0;
}

.vector-property-controls.is-hidden {
    display: none;
}

.vector-property-controls h5 {
    margin: 0 0 0.9rem;

    color: #334155;

    font-size: 0.95rem;
    font-weight: 900;
}

.vector-property-control {
    display: grid;
    grid-template-columns: 70px minmax(0, 1fr) 52px;
    gap: 0.75rem;
    align-items: center;

    margin-bottom: 0.8rem;
}

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

.vector-property-control label {
    font-family: monospace;

    font-weight: 900;
    color: #334155;
}

.vector-property-control input[type="range"] {
    width: 100%;

    accent-color: #2563eb;

    cursor: pointer;
}

.vector-property-control output {
    display: inline-flex;
    align-items: center;
    justify-content: center;

    min-width: 42px;

    padding: 0.25rem 0.4rem;

    border-radius: 9px;

    background: #dbeafe;
    color: #1d4ed8;

    font-family: monospace;
    font-weight: 900;
}


/* =========================================================
   Rendered SVG
   ========================================================= */

.vector-storage-svg {
    display: block;

    width: 100%;
    max-width: 520px;
    height: 320px;

    margin: 0 auto;

    border-radius: 18px;

    background: #ffffff;
    border: 1px solid #e2e8f0;
}

.vector-coordinate-grid {
    opacity: 1 !important;
    stroke: none !important;
    pointer-events: none;
}


/* Rectangle */
#vectorStoredRectangle {
    fill: #dbeafe;
    stroke: #2563eb;
    stroke-width: 4;

    opacity: 0.3;

    transition:
        opacity 0.2s ease,
        stroke-width 0.2s ease;
}


/* Circle */
#vectorStoredCircle {
    fill: #fef3c7;
    stroke: #f59e0b;
    stroke-width: 4;

    opacity: 0.3;

    transition:
        opacity 0.2s ease,
        stroke-width 0.2s ease;
}


/* Currently selected object */
.vector-storage-svg .vector-object-highlight {
    opacity: 1 !important;
    stroke-width: 6;
}


#vectorStorageExplanation {
    margin-bottom: 0;

    padding: 0.8rem 1rem;

    border-radius: 16px;

    background: #f8fafc;
    border: 1px solid #e2e8f0;

    color: #334155;

    font-weight: 700;
}


/* =========================================================
   Responsive layout
   ========================================================= */

@media (max-width: 760px) {

    .vector-storage-layout {
        grid-template-columns: 1fr;
    }

    .vector-reset-button {
        margin-left: 0;
    }

    .vector-storage-svg {
        height: 260px;
    }

    .vector-property-control {
        grid-template-columns: 55px minmax(0, 1fr) 48px;
    }
}