/* Fraction Visualizer Template Styles — Responsive, Touch-Friendly, Legacy-Safe */
.fv-wrap {
    width: 100%;
    max-width: 820px;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    gap: 12px;
    user-select: none;
    -webkit-user-select: none;
    box-sizing: border-box;
}

.fv-prompt-card {
    background: linear-gradient(135deg, #fff7ed 0%, #eff6ff 100%);
    border: 1.5px solid #e2e8f0;
    border-radius: 16px;
    padding: 12px 16px;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}

.fv-prompt-row {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 1 1 240px;
    min-width: 0;
}

.fv-question-text {
    font-size: 1.08rem;
    font-weight: 800;
    color: var(--ink, #0f172a);
    line-height: 1.4;
    margin: 0;
}

.fv-target-pill {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: #0f172a;
    color: #ffffff;
    border-radius: 14px;
    padding: 6px 14px;
    font-weight: 800;
    font-size: 0.95rem;
    box-shadow: 0 4px 12px rgba(15, 23, 42, 0.16);
    flex-shrink: 0;
}

.fv-counter-pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: #eef2ff;
    color: #4338ca;
    border: 1px solid #c7d2fe;
    border-radius: 9999px;
    padding: 4px 12px;
    font-size: 0.84rem;
    font-weight: 800;
}

.fv-counter-pill.is-match {
    background: #ecfdf5;
    color: #047857;
    border-color: #6ee7b7;
}

/* Stacked Fraction Typography */
.fv-frac {
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    line-height: 1.05;
    font-weight: 900;
    direction: ltr !important;
    unicode-bidi: isolate;
    vertical-align: middle;
    min-width: 20px;
}

.fv-frac-num {
    padding: 0 4px 2px;
    border-bottom: 2px solid currentColor;
    font-size: 1.05em;
}

.fv-frac-den {
    padding: 2px 4px 0;
    font-size: 1.05em;
}

.fv-stage-card {
    background: #ffffff;
    border: 2px solid #e2e8f0;
    border-radius: 18px;
    padding: 16px 12px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 14px;
    box-shadow: 0 4px 16px rgba(15, 23, 42, 0.04);
}

.fv-hint-bar {
    font-size: 0.84rem;
    font-weight: 600;
    color: #64748b;
    text-align: center;
    margin: 0;
}

.fv-visual-row {
    width: 100%;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: 14px;
    direction: ltr;
}

.fv-model-box {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    padding: 10px 12px;
    border-radius: 14px;
    background: #f8fafc;
    border: 1.5px solid #e2e8f0;
    min-width: 180px;
    max-width: 100%;
    box-sizing: border-box;
}

.fv-model-box.is-interactive {
    background: #fffbeb;
    border-color: #fcd34d;
    box-shadow: 0 4px 14px rgba(245, 158, 11, 0.12);
}

.fv-model-box.is-bar-box {
    width: 100%;
    max-width: 440px;
}

.fv-model-label {
    font-size: 0.84rem;
    font-weight: 800;
    color: #334155;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.fv-op-symbol {
    font-size: 2rem;
    font-weight: 900;
    color: #4f46e5;
    line-height: 1;
    padding: 0 4px;
}

.fv-svg-host {
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
}

.fv-svg {
    display: block;
    max-width: 100%;
    height: auto;
    overflow: visible;
}

.fv-slice {
    cursor: pointer;
    transition: transform 0.18s ease, opacity 0.15s ease, fill 0.15s ease;
    touch-action: none;
}

.fv-slice:hover {
    opacity: 0.92;
}

.fv-slice.is-static {
    cursor: default;
}

.fv-slice.is-static:hover {
    opacity: 1;
}

.fv-whole-ref {
    width: 100%;
    max-width: 360px;
    height: 24px;
    border-radius: 8px;
    background: linear-gradient(90deg, #0f172a 0%, #334155 100%);
    color: #ffffff;
    font-size: 0.75rem;
    font-weight: 800;
    display: flex;
    align-items: center;
    justify-content: center;
    letter-spacing: 0.3px;
}

/* Tactile Stepper & Partition Controls (Weak devices & mobile friendly >=44px) */
.fv-controls-bar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: 10px;
    width: 100%;
}

.fv-ctrl-group {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: #f1f5f9;
    border: 1px solid #cbd5e1;
    border-radius: 9999px;
    padding: 4px 8px;
}

.fv-ctrl-btn {
    min-width: 44px;
    height: 44px;
    border-radius: 50%;
    border: 1.5px solid #cbd5e1;
    background: #ffffff;
    color: #0f172a;
    font-size: 1.25rem;
    font-weight: 900;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.12s ease, background 0.12s ease, border-color 0.12s ease;
}

.fv-ctrl-btn:hover:not(:disabled) {
    background: #eef2ff;
    border-color: #4f46e5;
    transform: scale(1.04);
}

.fv-ctrl-btn:active:not(:disabled) {
    transform: scale(0.95);
}

.fv-ctrl-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.fv-ctrl-label {
    font-size: 0.85rem;
    font-weight: 800;
    color: #334155;
    padding: 0 4px;
    white-space: nowrap;
}

/* Interactive Read-Fraction Input + Keypad */
.fv-input-fraction-wrap {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    width: 100%;
}

.fv-frac-editor {
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    background: #f8fafc;
    border: 2px solid #cbd5e1;
    border-radius: 16px;
    padding: 12px 22px;
    direction: ltr;
}

.fv-frac-input {
    width: 72px;
    height: 48px;
    text-align: center;
    font-size: 1.35rem;
    font-weight: 900;
    border: 2px solid #94a3b8;
    border-radius: 10px;
    background: #ffffff;
    color: #0f172a;
    outline: none;
    transition: border-color 0.15s, box-shadow 0.15s;
}

.fv-frac-input.is-active {
    border-color: #4f46e5;
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.2);
}

.fv-frac-line {
    width: 84px;
    height: 4px;
    border-radius: 2px;
    background: #0f172a;
}

.fv-keypad {
    display: grid;
    grid-template-columns: repeat(6, minmax(42px, 52px));
    gap: 6px;
    justify-content: center;
    direction: ltr;
}

.fv-key-btn {
    height: 44px;
    border-radius: 10px;
    border: 1.5px solid #cbd5e1;
    background: #ffffff;
    color: #0f172a;
    font-size: 1.05rem;
    font-weight: 800;
    cursor: pointer;
    transition: background 0.12s, transform 0.1s;
}

.fv-key-btn:hover {
    background: #eef2ff;
    border-color: #6366f1;
}

.fv-key-btn:active {
    transform: scale(0.94);
}

.fv-key-btn.is-back {
    background: #fef2f2;
    color: #b91c1c;
    border-color: #fecaca;
}

/* Multiple Choice Grid */
.fv-choices-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
    gap: 10px;
    width: 100%;
    max-width: 580px;
}

.fv-choice-btn {
    min-height: 62px;
    padding: 10px 14px;
    border-radius: 14px;
    border: 2px solid #cbd5e1;
    background: #ffffff;
    color: #0f172a;
    font-size: 1.12rem;
    font-weight: 800;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    transition: transform 0.14s ease, border-color 0.14s ease, background 0.14s ease, box-shadow 0.14s ease;
}

.fv-choice-btn:hover:not(:disabled) {
    border-color: #4f46e5;
    background: #f5f3ff;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(79, 70, 229, 0.12);
}

.fv-choice-btn.is-selected {
    border-color: #4f46e5;
    background: #eef2ff;
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.2);
}

.fv-choice-btn.is-correct {
    border-color: #16a34a;
    background: #dcfce7;
    color: #14532d;
}

.fv-choice-btn.is-incorrect {
    border-color: #dc2626;
    background: #fee2e2;
    color: #7f1d1d;
}

.fv-choice-letter {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: #e2e8f0;
    color: #334155;
    font-size: 0.85rem;
    font-weight: 800;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.fv-actions-row {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    flex-wrap: wrap;
}

.fv-check-btn {
    min-height: 44px;
    padding: 10px 26px;
    border-radius: 9999px;
    font-size: 1rem;
    font-weight: 800;
}

.fv-note-box {
    width: 100%;
    background: #fefce8;
    border: 1.5px solid #fde047;
    color: #713f12;
    border-radius: 12px;
    padding: 10px 14px;
    font-size: 0.9rem;
    font-weight: 700;
    line-height: 1.5;
    text-align: center;
}

@media (max-width: 560px) {
    .fv-prompt-card {
        padding: 10px 12px;
    }
    .fv-model-box {
        min-width: 140px;
        padding: 8px;
    }
    .fv-keypad {
        grid-template-columns: repeat(4, minmax(44px, 1fr));
        width: 100%;
        max-width: 260px;
    }
}
