:root {
    --ink: #27233a;
    --muted: #716b83;
    --purple: #7257d9;
    --purple-dark: #5b40c2;
    --purple-soft: #eee9ff;
    --green: #268a62;
    --green-soft: #e3f8ef;
    --red: #bd4f55;
    --red-soft: #fff0f0;
    --orange: #ed8f43;
    --line: #e6e0ee;
    --surface: rgba(255, 255, 255, 0.94);
    --shadow: 0 20px 55px rgba(52, 41, 91, 0.13);
}

* { box-sizing: border-box; }

body {
    margin: 0;
    min-height: 100vh;
    color: var(--ink);
    background: linear-gradient(145deg, #fbfaff 0%, #f4f1fc 55%, #f8faf7 100%);
    font-family: "Outfit", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    overflow-x: hidden;
}

body.embedded-mode {
    min-height: 100%;
    background: #f8f7fc;
}

body.embedded-mode .page-glow,
body.embedded-mode .activity-header,
body.embedded-mode .intro-row,
body.embedded-mode .accessibility-note { display: none; }

body.embedded-mode .activity-shell { width: 100%; margin: 0; padding: 0; }
body.embedded-mode .level-picker { margin: 0 0 10px; padding: 2px; }
body.embedded-mode .exercise-card { padding: clamp(16px, 2.4vw, 26px); border-radius: 18px; box-shadow: none; }
body.embedded-mode .exercise-topline .score-card { margin-left: auto; padding: 8px 13px; gap: 12px; border-radius: 13px; box-shadow: none; }
body.embedded-mode .exercise-topline .score-card div:not(.score-divider) { min-width: 52px; }
body.embedded-mode .exercise-topline .score-card span { font-size: .64rem; }
body.embedded-mode .exercise-topline .score-card strong { font-size: 1.05rem; }
body.embedded-mode .exercise-topline .score-divider { height: 27px; }
body.embedded-mode .sentence-area { min-height: 110px; padding: 18px 8px; }
body.embedded-mode .visual-clue { width: 100px; height: 100px; margin-top: 16px; font-size: 3.8rem; }
body.embedded-mode .exercise-actions { margin-top: 20px; }

button, a { font: inherit; }
button { color: inherit; }

.page-glow {
    position: fixed;
    width: 430px;
    height: 430px;
    border-radius: 50%;
    filter: blur(4px);
    opacity: .45;
    pointer-events: none;
}

.glow-one { background: #e1d7ff; top: -230px; right: -100px; }
.glow-two { background: #d9f4e8; bottom: -270px; left: -120px; }

.activity-shell {
    position: relative;
    width: min(1120px, calc(100% - 32px));
    margin: 20px auto 36px;
}

.activity-header {
    display: flex;
    align-items: center;
    gap: 16px;
    min-height: 72px;
    padding: 12px 16px;
    background: var(--surface);
    border: 1px solid rgba(230, 224, 238, .85);
    border-radius: 22px;
    box-shadow: 0 10px 30px rgba(52, 41, 91, .07);
}

.back-link, .sound-toggle, .manage-button, .listen-button, .secondary-button, .primary-button {
    border: 0;
    cursor: pointer;
    transition: transform .18s ease, box-shadow .18s ease, background .18s ease;
}

.back-link {
    display: grid;
    place-items: center;
    width: 46px;
    height: 46px;
    flex: 0 0 auto;
    color: var(--purple-dark);
    background: var(--purple-soft);
    border-radius: 15px;
    text-decoration: none;
}

.brand-block { display: flex; align-items: center; gap: 12px; }
.brand-block img { width: 44px; height: 44px; object-fit: contain; }
.brand-block div { display: flex; flex-direction: column; line-height: 1.12; }
.brand-block span { color: var(--muted); font-size: .85rem; font-weight: 600; }
.brand-block strong { font-size: 1.12rem; }

.manage-button {
    display: flex;
    align-items: center;
    gap: 9px;
    margin-left: auto;
    min-height: 46px;
    padding: 0 16px;
    color: var(--purple-dark);
    background: var(--purple-soft);
    border-radius: 14px;
    font-weight: 700;
}

.sound-toggle {
    display: flex;
    align-items: center;
    gap: 9px;
    min-height: 46px;
    padding: 0 16px;
    color: var(--green);
    background: var(--green-soft);
    border-radius: 14px;
    font-weight: 700;
}

.intro-row {
    display: flex;
    justify-content: space-between;
    align-items: end;
    gap: 28px;
    margin: 42px 4px 24px;
}

.eyebrow {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    margin: 0 0 8px;
    color: var(--purple-dark);
    font-weight: 750;
}

h1 { margin: 0; font-size: clamp(2rem, 4vw, 3.45rem); line-height: 1.04; letter-spacing: -.04em; }
.intro-copy { margin: 12px 0 0; color: var(--muted); font-size: 1.08rem; }

.score-card {
    display: flex;
    align-items: center;
    gap: 20px;
    flex: 0 0 auto;
    padding: 15px 20px;
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 18px;
    box-shadow: 0 8px 20px rgba(52, 41, 91, .06);
}

.score-card div:not(.score-divider) { display: flex; flex-direction: column; align-items: center; min-width: 64px; }
.score-card span { color: var(--muted); font-size: .78rem; font-weight: 650; text-transform: uppercase; letter-spacing: .06em; }
.score-card strong { margin-top: 2px; font-size: 1.45rem; }
.score-divider { width: 1px; height: 34px; background: var(--line); }

.level-picker {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 10px;
    margin-bottom: 18px;
}

.level-button {
    position: relative;
    display: grid;
    grid-template-columns: 34px 1fr;
    grid-template-rows: 1fr 1fr;
    column-gap: 9px;
    padding: 12px;
    text-align: left;
    background: rgba(255, 255, 255, .7);
    border: 1px solid var(--line);
    border-radius: 16px;
    cursor: pointer;
}

.level-button > span {
    grid-row: 1 / 3;
    display: grid;
    place-items: center;
    width: 34px;
    height: 34px;
    align-self: center;
    color: var(--purple-dark);
    background: var(--purple-soft);
    border-radius: 11px;
    font-weight: 800;
}

.level-button strong { align-self: end; font-size: .94rem; }
.level-button small { align-self: start; color: var(--muted); font-size: .75rem; }
.level-button.active { background: var(--purple); color: #fff; border-color: var(--purple); box-shadow: 0 10px 25px rgba(114, 87, 217, .24); cursor: default; }
.level-button.active > span { color: var(--purple-dark); background: #fff; }
.level-button.active small { color: #e8e1ff; }

.exercise-card {
    padding: clamp(20px, 4vw, 40px);
    background: var(--surface);
    border: 1px solid rgba(230, 224, 238, .95);
    border-radius: 28px;
    box-shadow: var(--shadow);
}

.exercise-topline { display: flex; justify-content: space-between; align-items: center; gap: 18px; }
.instruction { margin: 0; color: var(--muted); font-size: 1.05rem; font-weight: 650; }
.listen-button {
    display: inline-flex;
    align-items: center;
    gap: 9px;
    min-height: 46px;
    padding: 0 16px;
    color: var(--purple-dark);
    background: var(--purple-soft);
    border-radius: 14px;
    font-weight: 750;
}

.visual-clue { display: none; margin: 28px auto 0; width: 140px; height: 140px; place-items: center; font-size: 5.4rem; background: #f8f5ff; border: 2px solid var(--line); border-radius: 28px; }
.visual-clue.visible { display: grid; }

.sentence-area {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: 12px;
    min-height: 146px;
    padding: 32px 10px;
    font-size: clamp(1.65rem, 4vw, 2.75rem);
    font-weight: 750;
    line-height: 1.25;
    text-align: center;
}

.sentence-word { white-space: nowrap; }

.drop-zone {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 145px;
    min-height: 60px;
    padding: 5px 18px;
    color: var(--purple-dark);
    background: #faf8ff;
    border: 3px dashed #b9a8ee;
    border-radius: 15px;
    cursor: pointer;
    vertical-align: middle;
}

.drop-zone:empty::after { content: "solte aqui"; color: #9686c7; font-size: .9rem; font-weight: 650; }
.drop-zone.drag-over, .drop-zone.selected-target { background: #eee9ff; border-color: var(--purple); transform: scale(1.03); }
.drop-zone.filled { min-width: 110px; background: var(--purple-soft); border-style: solid; }
.drop-zone.dragging-out { opacity: .45; transform: scale(.96); }
.drop-zone.filled:not(.correct):hover { color: var(--red); background: var(--red-soft); border-color: var(--red); }
.drop-zone.correct { color: var(--green); background: var(--green-soft); border-color: var(--green); }
.drop-zone.wrong { color: var(--red); background: var(--red-soft); border-color: var(--red); animation: shake .32s ease; }

.feedback {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 9px;
    min-height: 46px;
    padding: 10px 14px;
    color: #625c72;
    background: #f7f5fa;
    border-radius: 13px;
    text-align: center;
}

.feedback.success { color: var(--green); background: var(--green-soft); }
.feedback.retry { color: #9a5a24; background: #fff3e8; }
.options-label { display: flex; justify-content: space-between; gap: 12px; margin: 28px 2px 12px; }
.options-label span { font-weight: 750; }
.options-label small { color: var(--muted); }

.word-bank { display: flex; flex-wrap: wrap; justify-content: center; gap: 12px; min-height: 80px; }
.word-bank.return-target { background: var(--red-soft); outline: 3px dashed #d8797e; outline-offset: 7px; border-radius: 12px; }
.word-bank.return-target::before { content: "Solte aqui para remover"; width: 100%; color: var(--red); text-align: center; font-size: .82rem; font-weight: 750; }

.word-option {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    min-width: 145px;
    min-height: 66px;
    padding: 10px 22px;
    color: var(--ink);
    background: #fff;
    border: 2px solid var(--line);
    border-bottom: 5px solid #cfc5e9;
    border-radius: 17px;
    font-size: 1.22rem;
    font-weight: 750;
    cursor: grab;
    user-select: none;
    touch-action: manipulation;
    transition: transform .16s ease, border-color .16s ease, box-shadow .16s ease;
}

.word-option:hover { transform: translateY(-2px); border-color: #b9a8ee; box-shadow: 0 8px 18px rgba(67, 48, 124, .1); }
.word-option.selected { color: var(--purple-dark); background: var(--purple-soft); border-color: var(--purple); box-shadow: 0 0 0 4px rgba(114, 87, 217, .12); }
.word-option.used { visibility: hidden; pointer-events: none; }
.word-option.image-only { min-width: 118px; min-height: 112px; padding: 8px 18px; font-size: 3.5rem; }
.word-option:focus-visible, .drop-zone:focus-visible, button:focus-visible, a:focus-visible { outline: 4px solid rgba(237, 143, 67, .5); outline-offset: 3px; }

.exercise-actions { display: flex; justify-content: space-between; gap: 14px; margin-top: 30px; }
.secondary-button, .primary-button { min-height: 50px; padding: 0 20px; border-radius: 14px; font-weight: 750; }
.secondary-button { color: #625c72; background: #f1eef5; }
#reset-round {
    color: #5235bd;
    background: #e9e1ff;
    border: 2px solid #7257d9;
    box-shadow: 0 6px 14px rgba(91, 64, 194, .16);
}
#reset-round i { color: #5235bd; }
#reset-round:hover { color: #fff; background: #7257d9; box-shadow: 0 8px 18px rgba(91, 64, 194, .28); }
#reset-round:hover i { color: #fff; }
.primary-button { color: #fff; background: var(--purple); box-shadow: 0 8px 18px rgba(114, 87, 217, .22); }
.primary-button:disabled { color: #aaa4b4; background: #e9e6ed; box-shadow: none; cursor: not-allowed; }
.back-link:hover, button:not(:disabled):hover { transform: translateY(-1px); }

.accessibility-note { margin: 18px 0 0; color: var(--muted); text-align: center; font-size: .91rem; }
.accessibility-note i { color: var(--purple); margin-right: 5px; }

.manager-overlay {
    position: fixed;
    inset: 0;
    z-index: 50;
    display: flex;
    justify-content: flex-end;
    background: rgba(31, 25, 49, .42);
    opacity: 0;
    visibility: hidden;
    transition: opacity .22s ease, visibility .22s ease;
}

.manager-overlay.open { opacity: 1; visibility: visible; }

.manager-panel {
    width: min(760px, 100%);
    height: 100%;
    overflow: auto;
    background: #f8f7fb;
    box-shadow: -20px 0 60px rgba(26, 20, 49, .2);
    transform: translateX(40px);
    transition: transform .24s ease;
}

.manager-overlay.open .manager-panel { transform: translateX(0); }
.manager-header { position: sticky; top: 0; z-index: 2; display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; padding: 28px 32px 22px; background: rgba(255, 255, 255, .96); border-bottom: 1px solid var(--line); backdrop-filter: blur(12px); }
.manager-header h2 { margin: 4px 0 3px; font-size: 1.8rem; letter-spacing: -.025em; }
.manager-header p { margin: 0; color: var(--muted); }
.manager-kicker { color: var(--purple-dark) !important; font-size: .82rem; font-weight: 750; text-transform: uppercase; letter-spacing: .06em; }
.manager-close { display: grid; place-items: center; width: 44px; height: 44px; flex: 0 0 auto; color: #625c72; background: #f1eef5; border: 0; border-radius: 14px; cursor: pointer; font-size: 1.15rem; }
.manager-body { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(250px, .75fr); gap: 20px; padding: 24px; }
.manager-form-section, .question-library { padding: 22px; background: #fff; border: 1px solid var(--line); border-radius: 22px; box-shadow: 0 8px 24px rgba(49, 39, 79, .06); }
.manager-section-heading { display: flex; align-items: center; gap: 12px; margin-bottom: 22px; }
.manager-section-heading h3 { margin: 0; font-size: 1.15rem; }
.manager-section-heading p { margin: 2px 0 0; color: var(--muted); font-size: .84rem; }
.heading-icon { display: grid; place-items: center; width: 38px; height: 38px; flex: 0 0 auto; color: var(--green); background: var(--green-soft); border-radius: 12px; }
.heading-icon.purple { color: var(--purple-dark); background: var(--purple-soft); }
.form-row { display: grid; gap: 14px; }
.form-row.two-columns { grid-template-columns: 1.4fr .6fr; }
.field-label { display: block; margin-bottom: 16px; }
.field-label > span { display: block; margin: 0 0 7px; font-size: .88rem; font-weight: 750; }
.field-label > span:has(.field-step) { display: flex; align-items: center; gap: 8px; }
.field-step { display: inline-grid; place-items: center; width: 25px; height: 25px; flex: 0 0 auto; color: var(--purple-dark); background: var(--purple-soft); border-radius: 8px; font-size: .76rem; }
.field-step.correct { color: var(--green); background: var(--green-soft); }
.field-step.wrong { color: #a35c24; background: #fff0df; }
.field-label input, .field-label select, .field-label textarea { width: 100%; min-height: 47px; padding: 11px 13px; color: var(--ink); background: #fbfafd; border: 1.5px solid #dcd6e7; border-radius: 12px; outline: none; resize: vertical; }
.field-label textarea { min-height: 96px; }
.field-label input:focus, .field-label select:focus, .field-label textarea:focus { border-color: var(--purple); box-shadow: 0 0 0 4px rgba(114, 87, 217, .1); }
.field-label small { display: block; margin-top: 6px; color: var(--muted); font-size: .76rem; line-height: 1.35; }
.sentence-input-group { display: flex; gap: 8px; }
.sentence-input-group input { min-width: 0; flex: 1; }
.insert-blank-button { display: inline-flex; align-items: center; justify-content: center; gap: 7px; flex: 0 0 auto; min-height: 47px; padding: 0 13px; color: var(--purple-dark); background: var(--purple-soft); border: 1.5px solid #cfc3f1; border-radius: 12px; cursor: pointer; font-size: .82rem; font-weight: 750; }
.insert-blank-button:hover { background: #e5ddff; }
.options-progress { display: flex !important; align-items: center; gap: 6px; margin-top: 8px !important; padding: 8px 10px; color: #8b572f; background: #fff5e9; border-radius: 9px; font-size: .76rem !important; font-weight: 650 !important; }
.options-progress.complete { color: var(--green); background: var(--green-soft); }
.form-error { display: none; margin: -3px 0 14px; padding: 10px 12px; color: var(--red); background: var(--red-soft); border-radius: 10px; font-size: .84rem; font-weight: 650; }
.form-error.visible { display: block; }
.question-preview { margin: 4px 0 18px; padding: 14px; background: #f8f6fd; border: 1px solid #e4def0; border-radius: 15px; }
.question-preview > span { color: var(--muted); font-size: .72rem; font-weight: 750; text-transform: uppercase; letter-spacing: .07em; }
.preview-content { display: flex; align-items: center; gap: 10px; margin: 10px 0; }
.preview-content strong { display: grid; place-items: center; width: 42px; height: 42px; flex: 0 0 auto; background: #fff; border-radius: 11px; font-size: 1.6rem; }
.preview-content p { margin: 0; font-size: 1.02rem; font-weight: 700; }
.preview-content em { padding: 1px 6px; color: var(--purple-dark); background: var(--purple-soft); border-radius: 6px; font-style: normal; }
.preview-options { display: flex; flex-wrap: wrap; gap: 6px; }
.preview-options span { padding: 5px 9px; color: #655b7c; background: #fff; border: 1px solid #ded7ec; border-radius: 8px; font-size: .78rem; font-weight: 650; }
.preview-options span.correct-preview { color: var(--green); background: var(--green-soft); border-color: #b9e6d2; }
.preview-note { display: flex; align-items: flex-start; gap: 6px; margin: 10px 0 0; color: var(--purple-dark); font-size: .73rem; line-height: 1.35; }
.save-question-button { width: 100%; min-height: 49px; color: #fff; background: var(--purple); border: 0; border-radius: 13px; cursor: pointer; font-weight: 750; }
.save-question-button i { margin-right: 7px; }
.question-library { align-self: start; }
.library-heading { align-items: center; }
.question-count { display: grid; place-items: center; min-width: 30px; height: 30px; margin-left: auto; color: var(--purple-dark); background: var(--purple-soft); border-radius: 10px; font-weight: 800; }
.standard-question-summary { display: flex; align-items: center; gap: 10px; margin: -6px 0 12px; padding: 11px; color: var(--green); background: var(--green-soft); border: 1px solid #c6ead9; border-radius: 12px; }
.standard-question-summary > span { display: grid; place-items: center; width: 30px; height: 30px; flex: 0 0 auto; color: #fff; background: var(--green); border-radius: 9px; }
.standard-question-summary div { display: flex; flex-direction: column; }
.standard-question-summary strong { color: #246e52; font-size: .85rem; }
.standard-question-summary small { color: #4f806d; font-size: .72rem; }
.question-list { display: grid; gap: 10px; }
.question-empty { padding: 26px 10px; color: var(--muted); text-align: center; border: 2px dashed var(--line); border-radius: 14px; }
.question-empty i { display: block; margin-bottom: 9px; color: #b5acc4; font-size: 1.7rem; }
.question-empty strong { display: block; margin-bottom: 3px; color: #625c72; }
.question-item { padding: 12px; background: #fbfafd; border: 1px solid var(--line); border-radius: 13px; }
.question-item-top { display: flex; align-items: flex-start; gap: 9px; }
.question-item-icon { font-size: 1.35rem; }
.question-item-copy { min-width: 0; flex: 1; }
.question-item-copy strong { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: .88rem; }
.question-item-copy small { color: var(--muted); }
.delete-question { display: grid; place-items: center; width: 32px; height: 32px; flex: 0 0 auto; color: var(--red); background: var(--red-soft); border: 0; border-radius: 9px; cursor: pointer; }
.saved-toast { position: fixed; right: 24px; bottom: 24px; z-index: 60; display: flex; align-items: center; gap: 10px; padding: 13px 17px; color: #fff; background: var(--green); border-radius: 13px; box-shadow: 0 12px 30px rgba(22, 100, 68, .24); animation: toast-in .22s ease; }

@keyframes toast-in { from { opacity: 0; transform: translateY(10px); } }

@keyframes shake { 0%, 100% { transform: translateX(0); } 30% { transform: translateX(-6px); } 70% { transform: translateX(6px); } }

@media (max-width: 820px) {
    .level-picker { display: flex; overflow-x: auto; padding: 2px 2px 8px; }
    .level-button { min-width: 155px; }
    .intro-row { align-items: center; }
    .manager-body { grid-template-columns: 1fr; }
}

@media (max-width: 620px) {
    .activity-shell { width: min(100% - 20px, 1120px); margin-top: 10px; }
    .activity-header { border-radius: 18px; }
    .brand-block span { display: none; }
    .manage-button span { display: none; }
    .manage-button { width: 46px; margin-left: auto; justify-content: center; padding: 0; }
    .sound-toggle span { display: none; }
    .sound-toggle { width: 46px; justify-content: center; padding: 0; }
    .intro-row { display: block; margin-top: 28px; }
    .score-card { margin-top: 20px; width: 100%; justify-content: center; }
    .exercise-card { border-radius: 22px; }
    .exercise-topline { align-items: flex-start; }
    body.embedded-mode .exercise-topline { flex-wrap: wrap; }
    body.embedded-mode .exercise-topline .score-card { order: 3; width: 100%; margin: 4px 0 0; }
    .listen-button { flex: 0 0 auto; }
    .listen-button { width: 46px; padding: 0; justify-content: center; font-size: 0; }
    .listen-button i { font-size: 1rem; }
    .sentence-area { min-height: 130px; padding: 26px 0; }
    .drop-zone { min-width: 118px; min-height: 54px; }
    .word-option { flex: 1 1 42%; min-width: 125px; }
    .options-label small { text-align: right; }
    .manager-header { padding: 20px; }
    .manager-body { padding: 14px; }
    .manager-form-section, .question-library { padding: 18px; }
    .form-row.two-columns { grid-template-columns: 1fr; gap: 0; }
    .sentence-input-group { align-items: stretch; flex-direction: column; }
    .insert-blank-button { align-self: flex-start; padding: 0 16px; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; animation: none !important; }
}
