/* Ce piesă e? — recognise a song from humming (js/gaseste-piesa.js). Theme-aware like the other tool pages: tokens on
   :root, redefined under body.dark-theme. Fuchsia is the page's own colour; the piano roll reads its colours from the
   same tokens, so it follows the theme too. */
:root {
    --cpe-bg: #f8f4fb;
    --cpe-surface: #ffffff;
    --cpe-surface-2: #f4eef8;
    --cpe-ink: #23142e;
    --cpe-muted: #645870;
    --cpe-line: #e7ddef;
    --cpe-accent: #a21caf;
    --cpe-accent-ink: #ffffff;
    --cpe-accent-soft: rgba(162, 28, 175, .10);
    --cpe-rec: #e11d48;
    --cpe-rec-soft: rgba(225, 29, 72, .14);
    --cpe-good: #15803d;
    --cpe-good-soft: rgba(21, 128, 61, .10);
    --cpe-mid: #b45309;
    --cpe-bad: #b91c1c;
    --cpe-roll-bg: #fdfbff;
    --cpe-roll-lane: #f3edf8;
    --cpe-dot: rgba(162, 28, 175, .40);
    --cpe-shadow: 0 10px 30px rgba(35, 20, 46, .08);
}

body.dark-theme {
    --cpe-bg: #140d1a;
    --cpe-surface: #1e1426;
    --cpe-surface-2: #291d33;
    --cpe-ink: #f3eaf8;
    --cpe-muted: #b3a5be;
    --cpe-line: #3a2c46;
    --cpe-accent: #e879f9;
    --cpe-accent-ink: #1e1426;
    --cpe-accent-soft: rgba(232, 121, 249, .14);
    --cpe-rec: #fb7185;
    --cpe-rec-soft: rgba(251, 113, 133, .16);
    --cpe-good: #4ade80;
    --cpe-good-soft: rgba(74, 222, 128, .12);
    --cpe-mid: #fbbf24;
    --cpe-bad: #f87171;
    --cpe-roll-bg: #180f1f;
    --cpe-roll-lane: #21162a;
    --cpe-dot: rgba(232, 121, 249, .45);
    --cpe-shadow: 0 10px 30px rgba(0, 0, 0, .45);
}

/* clip, not hidden: the site-wide `body { overflow-x: hidden }` makes <body> a scroll container that never scrolls. */
.cpe-body, body.cpe-body#page-top {
    font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
    background: var(--cpe-bg);
    color: var(--cpe-ink);
    min-height: 100vh;
    overflow-x: clip;
}
.cpe-main { padding-top: 100px; padding-bottom: 40px; }
.cpe-main a { color: var(--cpe-accent); }
.cpe-wrap { max-width: 860px; display: grid; gap: 16px; }

/* ---- hero ---- */
.cpe-hero { text-align: center; padding: 4px 0 18px; }
.cpe-hero-icon { width: 56px; height: 56px; margin: 0 auto 10px; border-radius: 16px; display: grid; place-items: center; font-size: 24px; color: #fff; background: linear-gradient(135deg, #f472b6, #a21caf 55%, #6d28d9); box-shadow: var(--cpe-shadow); }
.cpe-hero h1 { font-weight: 800; font-size: clamp(1.8rem, 7vw, 2.6rem); letter-spacing: -.02em; margin: 0 0 10px; }
.cpe-lead { max-width: 680px; margin: 0 auto; color: var(--cpe-muted); line-height: 1.6; }
.cpe-lead strong { color: var(--cpe-ink); }

/* ---- cards & basics ---- */
.cpe-card { background: var(--cpe-surface); border: 1px solid var(--cpe-line); border-radius: 18px; padding: 18px; box-shadow: var(--cpe-shadow); min-width: 0; }
.cpe-card h2 { font-size: 1.1rem; font-weight: 700; margin: 0 0 12px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.cpe-card h3 { font-size: 1.05rem; font-weight: 700; margin: 0; }
.cpe-small { font-size: .86rem; color: var(--cpe-muted); margin: 6px 0 0; line-height: 1.5; }
.cpe-label { font-weight: 600; font-size: .9rem; margin-bottom: 6px; display: block; }
.cpe-opt { font-size: .72rem; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; color: var(--cpe-muted); background: var(--cpe-surface-2); border-radius: 999px; padding: 2px 8px; }
.cpe-row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.cpe-input { background: var(--cpe-surface-2); color: var(--cpe-ink); border-color: var(--cpe-line); border-radius: 12px; min-height: 46px; flex: 1 1 200px; min-width: 0; }
.cpe-input:focus { background: var(--cpe-surface-2); color: var(--cpe-ink); border-color: var(--cpe-accent); box-shadow: 0 0 0 3px var(--cpe-accent-soft); }
.cpe-input::placeholder { color: var(--cpe-muted); opacity: .8; }

.cpe-btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; border-radius: 12px; padding: 9px 16px; font-weight: 600; border: 1px solid var(--cpe-line); background: var(--cpe-surface-2); color: var(--cpe-ink); min-height: 46px; text-decoration: none; }
.cpe-btn:hover, .cpe-btn:focus-visible { border-color: var(--cpe-accent); color: var(--cpe-ink); background: var(--cpe-surface-2); }
.cpe-btn-primary { background: var(--cpe-accent); border-color: var(--cpe-accent); color: var(--cpe-accent-ink); }
.cpe-btn-primary:hover, .cpe-btn-primary:focus-visible { background: var(--cpe-accent); color: var(--cpe-accent-ink); filter: brightness(1.08); }
.cpe-btn:disabled { opacity: .5; cursor: not-allowed; }
.cpe-btn-small { min-height: 38px; padding: 6px 12px; font-size: .85rem; }
.cpe-main .cpe-btn-primary, .cpe-main a.cpe-btn { color: var(--cpe-ink); }
.cpe-main .cpe-btn-primary { color: var(--cpe-accent-ink); }

/* ---- chips ---- */
.cpe-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.cpe-chip { display: inline-flex; align-items: center; gap: 7px; min-height: 42px; padding: 8px 14px; border-radius: 999px; border: 1px solid var(--cpe-line); background: var(--cpe-surface-2); color: var(--cpe-ink); font-weight: 600; font-size: .92rem; cursor: pointer; }
.cpe-chip:hover { border-color: var(--cpe-accent); }
.cpe-chip:focus-visible { outline: 3px solid var(--cpe-accent-soft); outline-offset: 2px; border-color: var(--cpe-accent); }
.cpe-chip[aria-pressed="true"] { background: var(--cpe-accent); border-color: var(--cpe-accent); color: var(--cpe-accent-ink); }
.cpe-chip:disabled { opacity: .55; cursor: not-allowed; }
.cpe-recorder > .cpe-chips { justify-content: center; }
.cpe-hint-group { margin-top: 14px; }
.cpe-hint-group .cpe-chip { min-height: 40px; padding: 7px 13px; font-weight: 500; }
.cpe-lyrics-wrap.is-wanted .cpe-label::after { content: " — recomandat când cânți cu versuri"; font-weight: 500; color: var(--cpe-accent); font-size: .82rem; }

/* ---- record button ---- */
.cpe-rec-area { display: flex; align-items: center; justify-content: center; gap: 22px; margin: 18px 0 14px; flex-wrap: wrap; }
.cpe-rec { position: relative; width: 132px; height: 132px; border: 0; padding: 0; border-radius: 50%; background: transparent; cursor: pointer; flex: 0 0 auto; -webkit-tap-highlight-color: transparent; }
.cpe-rec:focus-visible { outline: 3px solid var(--cpe-rec-soft); outline-offset: 4px; }
.cpe-rec:disabled { cursor: progress; opacity: .7; }
.cpe-ring { position: absolute; inset: 0; width: 100%; height: 100%; transform: rotate(-90deg); }
.cpe-ring circle { fill: none; stroke-width: 7; }
.cpe-ring-bg { stroke: var(--cpe-line); }
.cpe-ring-fg { stroke: var(--cpe-rec); stroke-linecap: round; transition: stroke-dashoffset .1s linear; }
.cpe-rec-core { position: absolute; inset: 14px; border-radius: 50%; display: grid; place-items: center; font-size: 38px; color: #fff; background: radial-gradient(circle at 35% 30%, #fb7185, #e11d48 60%, #be123c); box-shadow: 0 8px 24px rgba(225, 29, 72, .35); transition: transform .15s ease; }
.cpe-rec:hover .cpe-rec-core { transform: scale(1.03); }
.cpe-rec:active .cpe-rec-core { transform: scale(.97); }
.cpe-rec.is-recording .cpe-rec-core { animation: cpe-pulse 1.4s ease-in-out infinite; }
@keyframes cpe-pulse { 0%, 100% { box-shadow: 0 0 0 0 rgba(225, 29, 72, .45); } 50% { box-shadow: 0 0 0 14px rgba(225, 29, 72, 0); } }
@media (prefers-reduced-motion: reduce) { .cpe-rec.is-recording .cpe-rec-core { animation: none; } }
.cpe-rec-side { min-width: 0; flex: 0 1 230px; text-align: left; }
.cpe-rec-label { font-weight: 700; font-size: 1.08rem; margin: 0; }
.cpe-rec.is-short ~ .cpe-rec-side .cpe-rec-label { color: var(--cpe-muted); }
.cpe-time { font-variant-numeric: tabular-nums; color: var(--cpe-muted); margin: 2px 0 8px; font-size: .92rem; }
.cpe-level { height: 6px; border-radius: 999px; background: var(--cpe-surface-2); overflow: hidden; max-width: 230px; }
.cpe-level span { display: block; height: 100%; width: 0; background: linear-gradient(90deg, #22c55e, #eab308 70%, #ef4444); transition: width .08s linear; }
.cpe-live-note { margin: 10px 0 0; font-size: 1.6rem; font-weight: 800; line-height: 1; opacity: .35; transition: opacity .1s; }
.cpe-live-note.is-on { opacity: 1; color: var(--cpe-accent); }
.cpe-live-note small { font-size: .9rem; font-weight: 600; color: var(--cpe-muted); }

/* ---- piano roll ---- */
.cpe-roll-wrap { position: relative; border: 1px solid var(--cpe-line); border-radius: 14px; overflow: hidden; background: var(--cpe-roll-bg); }
.cpe-roll-wrap.is-live { border-color: var(--cpe-rec); }
.cpe-roll { display: block; width: 100%; height: 220px; }
.cpe-roll-empty { position: absolute; inset: 0; display: grid; place-items: center; margin: 0; padding: 0 20px 0 56px; text-align: center; color: var(--cpe-muted); font-size: .9rem; pointer-events: none; }

/* ---- review ---- */
.cpe-review { margin-top: 12px; }
.cpe-notes-summary { margin: 0 0 8px; }
.cpe-notes { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px; max-height: 190px; overflow-y: auto; }
.cpe-note { display: inline-flex; flex-direction: column; align-items: flex-start; gap: 2px; padding: 5px 8px 6px; border-radius: 10px; background: var(--cpe-accent-soft); min-width: 46px; }
.cpe-note b { font-size: .9rem; line-height: 1.1; }
.cpe-note small { font-size: .7rem; color: var(--cpe-muted); line-height: 1.1; }
.cpe-note-sub { display: flex; align-items: center; gap: 5px; }
.cpe-note em { font-style: normal; font-size: .66rem; font-weight: 700; line-height: 1.3; background: var(--cpe-surface); border: 1px solid var(--cpe-line); border-radius: 999px; padding: 0 5px; color: var(--cpe-muted); }
.cpe-dur { display: block; height: 3px; border-radius: 2px; background: var(--cpe-accent); margin-top: 3px; max-width: 100%; }

/* ---- ask ---- */
.cpe-ask-wrap { text-align: center; }
.cpe-ask { width: 100%; max-width: 420px; min-height: 58px; font-size: 1.15rem; border-radius: 16px; }
.cpe-ask.is-busy { opacity: .7; }
.cpe-bar { height: 8px; border-radius: 999px; background: var(--cpe-surface-2); overflow: hidden; }
.cpe-bar span { display: block; height: 100%; width: 0; background: var(--cpe-accent); border-radius: inherit; transition: width .3s linear; }
.cpe-work p { margin: 0 0 10px; font-weight: 600; }

/* ---- messages ---- */
.cpe-msg { border-radius: 14px; padding: 14px 16px; background: rgba(225, 29, 72, .08); border: 1px solid rgba(225, 29, 72, .35); color: var(--cpe-ink); line-height: 1.5; }
.cpe-msg.is-info { background: var(--cpe-accent-soft); border-color: var(--cpe-line); }
.cpe-msg ul { margin: 8px 0 0; padding-left: 20px; }
.cpe-msg li { margin: 4px 0; }

/* ---- results ---- */
.cpe-results { display: grid; gap: 12px; }
.cpe-results-title { font-size: 1.15rem; font-weight: 800; margin: 4px 0 0; display: flex; align-items: center; gap: 8px; }
.cpe-obs { margin: 0; padding: 10px 14px; border-radius: 12px; background: var(--cpe-accent-soft); color: var(--cpe-ink); }
.cpe-cards { display: grid; gap: 12px; }
.cpe-song { transition: opacity .2s, border-color .2s; }
.cpe-song.is-yes { border-color: var(--cpe-good); box-shadow: 0 0 0 2px var(--cpe-good-soft), var(--cpe-shadow); }
.cpe-song.is-no { opacity: .55; }
.cpe-song-head { display: flex; gap: 12px; align-items: flex-start; }
.cpe-rank { flex: 0 0 auto; width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; font-weight: 800; background: var(--cpe-accent-soft); color: var(--cpe-accent); }
.cpe-song-title { min-width: 0; }
.cpe-song-title h3 { font-size: 1.15rem; overflow-wrap: anywhere; }
.cpe-song-meta { margin: 2px 0 0; color: var(--cpe-muted); overflow-wrap: anywhere; }
.cpe-conf { margin: 12px 0 0; }
.cpe-conf-top { display: flex; justify-content: space-between; font-size: .85rem; color: var(--cpe-muted); margin-bottom: 4px; }
.cpe-conf-top b { color: var(--cpe-ink); }
.cpe-conf.is-high .cpe-bar span { background: var(--cpe-good); }
.cpe-conf.is-mid .cpe-bar span { background: var(--cpe-mid); }
.cpe-conf.is-low .cpe-bar span { background: var(--cpe-muted); }
.cpe-reason { margin: 10px 0 0; line-height: 1.5; }
.cpe-links, .cpe-verdict { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; align-items: center; }
.cpe-links .cpe-btn { flex: 1 1 200px; white-space: nowrap; }
.cpe-btn-yt svg { color: #ff0000; }
.cpe-btn-sp svg { color: #1db954; }
.cpe-yes:hover, .cpe-song.is-yes .cpe-yes { border-color: var(--cpe-good); color: var(--cpe-good); }
.cpe-no:hover, .cpe-song.is-no .cpe-no { border-color: var(--cpe-bad); color: var(--cpe-bad); }
.cpe-verdict-text { font-size: .85rem; color: var(--cpe-muted); }
.cpe-empty h3, .cpe-retry h3 { display: flex; gap: 8px; align-items: center; margin-bottom: 8px; }
.cpe-empty p { margin: 0; color: var(--cpe-muted); line-height: 1.5; }
.cpe-tips { list-style: none; padding: 0; margin: 10px 0 12px; display: grid; gap: 8px; }
.cpe-tips li { display: flex; gap: 10px; align-items: baseline; line-height: 1.45; }
.cpe-tips svg, .cpe-tips i { color: var(--cpe-accent); width: 1.1em; flex: 0 0 auto; }

/* ---- note, history, key ---- */
.cpe-note p { margin: 0 0 8px; line-height: 1.6; }
.cpe-note p:last-child { margin-bottom: 0; }
.cpe-hist-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; flex-wrap: wrap; }
.cpe-hist-head h2 { margin: 0; }
.cpe-hist-list { list-style: none; padding: 0; margin: 10px 0 0; display: grid; gap: 6px; }
.cpe-hist-item { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 9px 12px; border-radius: 12px; background: var(--cpe-surface-2); }
.cpe-hist-main { min-width: 0; display: flex; flex-direction: column; }
.cpe-hist-main b { overflow-wrap: anywhere; font-weight: 600; }
.cpe-hist-main small { color: var(--cpe-muted); }
.cpe-tag { flex: 0 0 auto; font-size: .75rem; font-weight: 700; padding: 3px 9px; border-radius: 999px; background: var(--cpe-surface); color: var(--cpe-muted); border: 1px solid var(--cpe-line); white-space: nowrap; }
.cpe-tag.is-yes { color: var(--cpe-good); border-color: var(--cpe-good); }
.cpe-tag.is-no { color: var(--cpe-bad); border-color: var(--cpe-bad); }
.cpe-key summary { cursor: pointer; font-weight: 600; display: flex; align-items: center; gap: 8px; }
.cpe-key .cpe-row { margin-top: 10px; }
.cpe-powered { text-align: center; margin: 24px 0 0; font-size: .85rem; color: var(--cpe-muted); }

@media (max-width: 520px) {
    .cpe-main { padding-top: 88px; }
    .cpe-card { padding: 14px; border-radius: 16px; }
    .cpe-rec-area { gap: 16px; }
    .cpe-rec { width: 120px; height: 120px; }
    .cpe-rec-side { flex: 1 1 140px; }
    .cpe-roll { height: 200px; }
    .cpe-recorder > .cpe-chips .cpe-chip { flex: 1 1 auto; justify-content: center; padding: 8px 10px; }
}
