/* =====================================================================
   Duobot mods inside Duolingo's own screens. Every class is dbm-*.
   Duolingo's theme colours are RGB triplets ("19, 31, 36"), so they are
   read through rgb(); light and dark both hold. Accents come from the
   brand kit.
   ===================================================================== */

:root {
    --dbm-green: #58cc02;
    --dbm-green-edge: #58a700;
    --dbm-blue: #1cb0f6;
    --dbm-blue-edge: #1899d6;
    --dbm-red: #ff4b4b;
    --dbm-red-edge: #ea2b2b;
    --dbm-surface: rgb(var(--color-snow, 255, 255, 255));
    --dbm-soft: rgb(var(--color-polar, 247, 247, 247));
    --dbm-line: rgb(var(--color-swan, 229, 229, 229));
    --dbm-ink: rgb(var(--color-eel, 75, 75, 75));
    --dbm-muted: rgb(var(--color-hare, 175, 175, 175));
    --dbm-thumb: 18px;
    --dbm-font: "din-round", "Nunito", ui-rounded, sans-serif;
    --dbm-ease-out: cubic-bezier(.22, 1, .36, 1);
    --dbm-ease-spring: cubic-bezier(.34, 1.56, .64, 1);
}

.dbm-audio svg,
.dbm-btn svg { display: block; width: 100%; height: 100%; }

/* ---------- pressable base, the 4px depth edge ---------- */

.dbm-btn,
.dbm-audio-play,
.dbm-audio-chip {
    font-family: var(--dbm-font);
    border: 2px solid var(--dbm-line);
    border-bottom-width: 4px;
    background: var(--dbm-surface);
    color: var(--dbm-ink);
    cursor: pointer;
    transition: transform 80ms ease, border-bottom-width 80ms ease, background 160ms var(--dbm-ease-out);
}

.dbm-btn:active,
.dbm-audio-play:active,
.dbm-audio-chip:active {
    transform: translateY(2px);
    border-bottom-width: 2px;
}

.dbm-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 9px 16px;
    border-radius: 14px;
    font-size: 14px;
    font-weight: 700;
    letter-spacing: .6px;
    text-transform: uppercase;
}

.dbm-btn > svg { width: 18px; height: 18px; flex: none; }
.dbm-btn:hover { filter: brightness(1.04); }

.dbm-btn.is-blue {
    background: var(--dbm-blue);
    border-color: var(--dbm-blue-edge);
    color: #fff;
}

.dbm-btn.is-green {
    background: var(--dbm-green);
    border-color: var(--dbm-green-edge);
    color: #fff;
}

.dbm-btn[disabled] { opacity: .5; cursor: default; transform: none; border-bottom-width: 4px; }

/* ---------- brand slider: same rail, fill and square thumb as the panel ---------- */

.dbm-range-wrap {
    position: relative;
    height: var(--dbm-thumb);
    display: flex;
    align-items: center;
}

.dbm-range-rail,
.dbm-range-fill {
    position: absolute;
    top: 50%;
    left: 0;
    height: 6px;
    margin-top: -3px;
    border-radius: 999px;
    pointer-events: none;
}

.dbm-range-rail { right: 0; background: var(--dbm-line); }
.dbm-range-fill { background: var(--dbm-blue); }

.dbm-range {
    -webkit-appearance: none;
    appearance: none;
    position: relative;
    z-index: 1;
    width: 100%;
    height: var(--dbm-thumb);
    margin: 0;
    background: transparent;
    outline: none;
    cursor: pointer;
}

.dbm-range::-webkit-slider-runnable-track { height: var(--dbm-thumb); background: transparent; border: none; }

.dbm-range::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: var(--dbm-thumb);
    height: var(--dbm-thumb);
    border-radius: 7px;
    background: var(--dbm-surface);
    border: 2.5px solid var(--dbm-blue);
    box-shadow: 0 2px 4px rgba(0, 0, 0, .25);
    transition: transform .12s ease;
}

.dbm-range::-webkit-slider-thumb:hover { transform: scale(1.12); }
.dbm-range:focus-visible::-webkit-slider-thumb { box-shadow: 0 0 0 3px rgba(28, 176, 246, .35); }

.dbm-range::-moz-range-track { height: var(--dbm-thumb); background: transparent; }

.dbm-range::-moz-range-thumb {
    width: var(--dbm-thumb);
    height: var(--dbm-thumb);
    border-radius: 7px;
    background: var(--dbm-surface);
    border: 2.5px solid var(--dbm-blue);
    box-shadow: 0 2px 4px rgba(0, 0, 0, .25);
}

/* ---------- tools row under the answer box: mic and typing check ---------- */

.dbm-tools {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px 10px;
    margin-top: 10px;
    font-family: var(--dbm-font);
}

.dbm-tools-note {
    font-size: 14px;
    font-weight: 600;
    color: var(--dbm-muted);
}

.dbm-tools-note.is-bad { color: var(--dbm-red); }

/* ---------- 2. mic ---------- */

.dbm-mic { padding: 7px 14px; color: var(--dbm-blue); }
.dbm-mic > svg { width: 16px; height: 16px; }

.dbm-mic.is-listening {
    background: var(--dbm-red);
    border-color: var(--dbm-red-edge);
    color: #fff;
    animation: dbm-pulse 1.1s var(--dbm-ease-out) infinite;
}

@keyframes dbm-pulse {
    0% { box-shadow: 0 0 0 0 rgba(255, 75, 75, .5); }
    100% { box-shadow: 0 0 0 12px rgba(255, 75, 75, 0); }
}

/* ---------- 3. hidden sentence ---------- */

.dbm-veiled {
    filter: blur(7px);
    cursor: pointer;
    user-select: none;
    transition: filter 240ms var(--dbm-ease-out);
}

.dbm-veiled.is-revealed { filter: none; user-select: auto; }

/* ---------- 5. audio bar ---------- */

.dbm-audio {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px 12px;
    margin: 12px 0 4px;
    padding: 8px 14px 8px 8px;
    max-width: 560px;
    border: 2px solid var(--dbm-line);
    border-radius: 16px;
    background: var(--dbm-surface);
    color: var(--dbm-ink);
    font-family: var(--dbm-font);
    animation: dbm-pop 260ms var(--dbm-ease-spring) both;
}

.dbm-audio-play {
    flex: none;
    width: 44px;
    height: 44px;
    padding: 11px;
    border-radius: 12px;
    background: var(--dbm-blue);
    border-color: var(--dbm-blue-edge);
    color: #fff;
}

.dbm-audio-seek { flex: 1 1 120px; min-width: 100px; }

.dbm-audio-time {
    flex: none;
    min-width: 76px;
    font-size: 13px;
    font-weight: 700;
    color: var(--dbm-muted);
    font-variant-numeric: tabular-nums;
}

.dbm-audio-chip {
    flex: none;
    min-width: 54px;
    height: 34px;
    padding: 0 10px;
    border-radius: 10px;
    font-size: 14px;
    font-weight: 700;
    color: var(--dbm-blue);
}

.dbm-audio-vol {
    display: flex;
    align-items: center;
    gap: 6px;
    flex: none;
    color: var(--dbm-muted);
}

.dbm-audio-vol > svg { width: 20px; height: 20px; flex: none; }
.dbm-audio-vol > .dbm-range-wrap { width: 80px; }

.dbm-audio-note {
    flex-basis: 100%;
    margin: 0 0 2px 4px;
    font-size: 13px;
    font-weight: 600;
    color: var(--dbm-red);
}

@keyframes dbm-pop {
    0% { opacity: 0; transform: scale(.96); }
    100% { opacity: 1; transform: none; }
}

/* ---------- 10. mistakes export on the practice hub ---------- */

.dbm-hub-row { display: flex; flex-wrap: wrap; gap: 12px; margin: 16px 0 20px; }
.dbm-hub-row .dbm-btn { flex: 1 1 180px; justify-content: center; }

/* ---------- 11. study hints and live typing check ---------- */

/* the right answer's own border turns green; Duolingo draws some borders on ::before/::after */
.dbm-hint,
.dbm-hint::before,
.dbm-hint::after {
    --web-ui_button-border-color: var(--dbm-green);
    border-color: var(--dbm-green) !important;
}
.dbm-hint { transition: border-color 160ms var(--dbm-ease-out); }

/* arrow keys: the word under the focus */
[data-test="word-bank"] button:focus-visible,
[data-test$="challenge-tap-token"]:focus-visible {
    outline: 3px solid var(--dbm-blue) !important;
    outline-offset: 2px;
    border-radius: 12px;
}

.dbm-typing {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 12px;
    border-radius: 999px;
    font-size: 13px;
    font-weight: 700;
    color: var(--dbm-green-edge);
    background: rgba(88, 204, 2, .14);
}

.dbm-typing::before {
    content: "";
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: currentColor;
}

.dbm-typing.is-bad { color: var(--dbm-red); background: rgba(255, 75, 75, .13); }

/* ---------- 12. all solutions after the check ---------- */

/* a display rule must never beat the hidden attribute */
[class*="dbm-"][hidden] { display: none !important; }

/* the feedback box is a flex row: take a full line under it instead of a squeezed column */
[data-test*="blame"]:has(> .dbm-solutions) { flex-wrap: wrap; }
.dbm-solutions { flex: 1 0 100%; order: 99; min-width: 0; margin-top: 12px; font-family: var(--dbm-font); }

.dbm-solutions-list {
    margin: 10px 0 0;
    padding: 6px;
    list-style: none;
    border: 2px solid var(--dbm-line);
    border-radius: 14px;
    background: var(--dbm-surface);
    color: var(--dbm-ink);
    font-size: 15px;
    line-height: 1.45;
    max-height: 240px;
    overflow: auto;
}

.dbm-solutions-list li { padding: 7px 10px; border-radius: 10px; }
.dbm-solutions-list li + li { border-top: 2px solid var(--dbm-soft); }

.dbm-solutions-list li.is-closest {
    background: rgba(28, 176, 246, .1);
    border-top-color: transparent;
}

.dbm-solutions-tag {
    display: inline-block;
    margin-left: 8px;
    padding: 1px 8px;
    border-radius: 999px;
    background: var(--dbm-blue);
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: .4px;
    text-transform: uppercase;
    vertical-align: 2px;
}

/* ---------- 13. hard mode ---------- */

/* as wide as the answer lines above it: a centred bank column would shrink it to the text */
.dbm-hard {
    display: flex;
    flex-direction: column;
    align-self: stretch;
    width: 100%;
    box-sizing: border-box;
    gap: 8px;
    margin: -6px 0 12px;
    font-family: var(--dbm-font);
    color: var(--dbm-ink);
}

.dbm-hard-hint { margin: 0; font-size: 14px; font-weight: 600; color: var(--dbm-muted); }

.dbm-hard-field {
    width: 100%;
    box-sizing: border-box;
    min-height: 96px;
    padding: 12px 14px;
    border: 2px solid var(--dbm-line);
    border-radius: 14px;
    background: var(--dbm-soft);
    color: var(--dbm-ink);
    font: inherit;
    font-size: 19px;
    resize: vertical;
    transition: border-color 160ms var(--dbm-ease-out);
}

.dbm-hard-field:focus { outline: none; border-color: var(--dbm-blue); }
.dbm-hard-field.is-bad { border-color: var(--dbm-red); }
.dbm-hard-field:disabled { opacity: .6; }

.dbm-hard-status { margin: 0; font-size: 14px; font-weight: 600; color: var(--dbm-muted); }
.dbm-hard-status.is-bad { color: var(--dbm-red); }

.dbm-hard-actions { display: flex; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.dbm-hard-hidden { display: none !important; }

/* the switch next to Skip: blue, sunk in while typing */
.dbm-hard-switch {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: none;
    width: auto;
    min-width: 50px;
    height: auto;
    min-height: 50px;
    aspect-ratio: 1;
    margin: 0;
    padding: 12px;
    border: 0;
    border-radius: 14px;
    background: var(--dbm-blue);
    color: #fff;
    box-shadow: 0 4px 0 var(--dbm-blue-edge);
    vertical-align: middle;
    cursor: pointer;
    transition: transform 120ms var(--dbm-ease-out), box-shadow 120ms var(--dbm-ease-out), background 120ms var(--dbm-ease-out);
}
.dbm-hard-switch svg { width: 24px; height: 24px; }
/* Skip's own wrapper, turned into a row: the switch stretches to Skip's height */
.dbm-hard-switch-host { display: flex !important; align-items: stretch; gap: 12px; }
.dbm-hard-switch-host > [data-test="player-skip"] { margin: 0; }
.dbm-hard-switch:hover { filter: brightness(1.06); }
.dbm-hard-switch.is-down { transform: translateY(4px); box-shadow: none; background: var(--dbm-line); color: var(--dbm-muted); }
.dbm-hard-switch:focus-visible { outline: 3px solid var(--dbm-blue); outline-offset: 3px; }

/* ---------- 13. solutions panel: tools, pager, typo, reference ---------- */

.dbm-solutions-panel { margin-top: 10px; display: grid; gap: 8px; max-height: 40vh; overflow: auto; }
.dbm-solutions-tools,
.dbm-solutions-pager,
.dbm-solutions-foot,
.dbm-solutions-tags { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.dbm-solutions-pager { justify-content: space-between; }
.dbm-solutions-filter,
.dbm-solutions-sort {
    flex: 1 1 140px;
    min-width: 0;
    padding: 8px 12px;
    border: 2px solid var(--dbm-line);
    border-radius: 12px;
    background: var(--dbm-surface);
    color: var(--dbm-ink);
    font: 600 14px var(--dbm-font);
}
.dbm-solutions-sort { flex: 0 1 auto; }
.dbm-solutions-tools {
    /* the shared dropdown reads these, so it follows Duolingo's light or dark */
    --db-surface: var(--dbm-surface);
    --db-surface-2: var(--dbm-surface);
    --db-text: var(--dbm-ink);
    --db-muted: var(--dbm-muted);
    --db-blue: var(--dbm-blue);
}
.dbm-solutions-tools .db-select-btn {
    height: auto;
    padding: 8px 12px;
    border: 2px solid var(--dbm-line);
    border-radius: 12px;
    box-shadow: 0 2px 0 var(--dbm-line);
    font: 700 14px var(--dbm-font);
}
.dbm-solutions-panel .dbm-solutions-list { margin: 0; }
.dbm-solutions-tag-btn {
    padding: 3px 10px;
    border: 2px solid var(--dbm-line);
    border-radius: 999px;
    background: var(--dbm-surface);
    color: var(--dbm-ink);
    font: 700 13px var(--dbm-font);
    cursor: pointer;
}
.dbm-solutions-tag-btn.is-on { border-color: var(--dbm-blue); background: rgba(28, 176, 246, .12); color: var(--dbm-blue-edge); }
.dbm-solutions-count { font-size: 13px; font-weight: 700; color: var(--dbm-muted); }
.dbm-solutions-link { margin-left: 8px; font-size: 12px; font-weight: 700; color: var(--dbm-blue); }
.dbm-solutions-panel.is-compact .dbm-solutions-list { font-size: 13px; line-height: 1.25; }
.dbm-solutions-panel.is-compact .dbm-solutions-list li { padding: 3px 8px; }
.dbm-solutions-panel.is-compact .dbm-solutions-link { display: none; }
.dbm-solutions-ref,
.dbm-solutions-typo { margin: 0 0 8px; font-size: 15px; color: var(--dbm-ink); }
.dbm-solutions-typo mark,
.dbm-typing-mirror mark { padding: 0 2px; border-radius: 4px; background: rgba(255, 75, 75, .2); color: var(--dbm-red-edge); }

/* ---------- 14. typing mirror, memo, chips ---------- */

.dbm-typing-mirror { font: 600 14px var(--dbm-font); color: var(--dbm-ink); white-space: pre-wrap; }

.dbm-memo { margin: 8px 0; font-size: 14px; }
.dbm-memo.is-open { border-color: var(--dbm-green); color: var(--dbm-green-edge); text-transform: none; }

.dbm-chips {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
    margin-bottom: 8px;
    font-family: var(--dbm-font);
}
/* switches in Duobot's button style: green and raised when on, grey and pressed in when off */
.dbm-chip {
    margin-bottom: 3px;
    padding: 5px 14px;
    border: 0;
    border-radius: 12px;
    background: var(--dbm-green);
    color: #fff;
    box-shadow: 0 3px 0 var(--dbm-green-edge);
    font: 800 12px var(--dbm-font);
    letter-spacing: .4px;
    text-transform: uppercase;
    cursor: pointer;
    transition: transform 100ms var(--dbm-ease-out), box-shadow 100ms var(--dbm-ease-out), background 160ms var(--dbm-ease-out);
}
.dbm-chip:hover { filter: brightness(1.05); }
.dbm-chip:not(.is-on) { transform: translateY(3px); box-shadow: none; background: var(--dbm-line); color: var(--dbm-muted); }
.dbm-chip:focus-visible { outline: 3px solid var(--dbm-blue); outline-offset: 2px; }
.dbm-chips-status { font-size: 12px; font-weight: 700; color: var(--dbm-muted); }

/* ---------- 15. around Duolingo ---------- */

/* an outline ring, since the path buttons draw their 3D edge with box-shadow */
@keyframes dbm-pulse {
    0%, 100% { outline-color: rgba(28, 176, 246, .9); outline-offset: 4px; }
    50% { outline-color: rgba(28, 176, 246, .15); outline-offset: 10px; }
}
.dbm-next-node { outline: 4px solid var(--dbm-blue); animation: dbm-pulse 1.6s var(--dbm-ease-out) infinite; border-radius: 50%; }

[data-dbm-new] { position: relative; }
[data-dbm-new]::after {
    content: attr(data-dbm-new);
    display: block;
    font: 700 11px var(--dbm-font);
    color: var(--dbm-blue);
    text-align: center;
    white-space: nowrap;
}

.dbm-guide { display: flex; flex-wrap: wrap; gap: 8px; margin: 10px 0; font-family: var(--dbm-font); }
.dbm-guide .dbm-btn { text-decoration: none; }

/* ---------- 16. audio bar inside the speech bubble ---------- */

/* a row bubble wraps, so the bar takes a line of its own */
.dbm-audio-host { flex-wrap: wrap; }

.dbm-audio.is-compact {
    flex-basis: 100%;
    width: 100%;
    max-width: none;
    box-sizing: border-box;
    gap: 6px 8px;
    margin: 8px 0 0;
    padding: 8px 0 0;
    border: 0;
    border-top: 2px solid var(--dbm-line);
    border-radius: 0;
    background: transparent;
}
.dbm-audio.is-compact .dbm-audio-play { width: 32px; height: 32px; padding: 8px; border-radius: 10px; }
.dbm-audio.is-compact .dbm-audio-chip { min-width: 44px; height: 28px; padding: 0 8px; font-size: 12px; }
.dbm-audio.is-compact .dbm-audio-time { min-width: 64px; font-size: 12px; }
.dbm-audio.is-compact .dbm-audio-vol > svg { width: 16px; height: 16px; }
.dbm-audio.is-compact .dbm-audio-vol > .dbm-range-wrap { width: 60px; }

/* ---------- reduced motion ---------- */

@media (prefers-reduced-motion: reduce) {
    .dbm-mic.is-listening,
    .dbm-audio,
    .dbm-next-node { animation: none; }
    .dbm-veiled,
    .dbm-hint,
    .dbm-btn,
    .dbm-audio-play,
    .dbm-audio-chip,
    .dbm-hard-field { transition: none; }
    .dbm-range::-webkit-slider-thumb { transition: none; }
}
