/* ===================================================================
   YouTube Thumbnail Downloader (/youtube-thumbnail-downloader)

   Built on the Backlink Maker design system: the page root carries both
   .bm and .ytd, backlink-maker.css supplies the hero, workbench, input,
   buttons, toast and info cards, and this file adds
     1. the letter-Y accent (az-color-palette.js primaryForLetter("Y") =
        #f79250), matching /youtube-backlinks-generator;
     2. the video card, the sizes list, batch cards, crop tool and the
        YouTube mock-ups.

   --bm-accent-strong (#97552a) is the accent darkened for text: 5.9:1 on
   white. The accent itself is decoration only.
   =================================================================== */

.bm.ytd {
    --bm-accent: #f79250;
    --bm-accent-strong: #97552a;
    --bm-accent-soft: #fef4ee;
    --bm-accent-ring: rgba(247, 146, 80, .38);
    --ytd-tint: #fff9f5;
    --ytd-tint-line: #fbe2d2;
    --ytd-red: #e62117;
}

.ytd .bm-input > i { color: var(--ytd-red); }
.ytd .bm-note { border-color: var(--ytd-tint-line); }
.ytd .bm-bar { background: #f6e6dc; }
.ytd h2, .ytd h3 { color: var(--bm-ink); }

/* ---------------------------------------------------------------
   Input
   --------------------------------------------------------------- */
.ytd-labelrow { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 4px 12px; }
.ytd-count { font-size: .8rem; font-weight: 700; color: var(--bm-accent-strong); font-variant-numeric: tabular-nums; }
.ytd-count:empty { display: none; }

.ytd-input { align-items: flex-start; }
.ytd-input > i { top: 18px; }
.ytd-input textarea {
    display: block; width: 100%; min-height: 52px; max-height: 220px; padding: 13px 44px 13px 42px;
    border: 0; background: transparent; border-radius: 12px; resize: none; overflow-y: auto;
    font: inherit; font-size: 1.02rem; line-height: 1.5; color: var(--bm-ink);
}
.ytd-input textarea:focus { outline: none; }
.ytd-input textarea::placeholder { color: #9aa0ae; }
.ytd-input .bm-clear { top: 10px; }
.ytd-inputbtns { display: flex; gap: 10px; align-items: flex-start; }
.ytd-paste { min-height: 52px; }

.ytd .bm-error.is-warning { color: var(--bm-prot); background: var(--bm-prot-soft); border-color: rgba(143, 86, 0, .22); }

.ytd .bm-recent button.ytd-recent-item { display: inline-flex; align-items: center; gap: 8px; max-width: 260px; min-height: 35px; padding: 3px 12px 3px 3px; }
.ytd .bm-recent img { width: 48px; height: 27px; border-radius: 999px 6px 6px 999px; object-fit: cover; flex: none; background: #e9e5e1; }
.ytd .bm-recent button span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ytd .bm-link-btn.ytd-clear-history { font-size: .78rem; margin-left: 4px; color: var(--bm-ink-3); }

/* ---- Empty state ---- */
.ytd-empty {
    display: flex; align-items: center; gap: 18px; margin-top: 16px; padding: 16px;
    border: 1.5px dashed var(--ytd-tint-line); border-radius: var(--bm-r); background: var(--ytd-tint);
}
.ytd-empty-art { position: relative; flex: none; width: 132px; aspect-ratio: 16 / 9; }
.ytd-empty-art span {
    position: absolute; inset: 0; border-radius: 10px; background: linear-gradient(135deg, #ffd9c2, #f79250);
    box-shadow: 0 8px 18px -10px rgba(151, 85, 42, .6);
}
.ytd-empty-art span:nth-child(1) { transform: rotate(-9deg) translate(-10px, 4px) scale(.86); opacity: .45; }
.ytd-empty-art span:nth-child(2) { transform: rotate(7deg) translate(10px, 2px) scale(.9); opacity: .7; background: linear-gradient(135deg, #ffe9dc, #f0655f); }
.ytd-empty-art span:nth-child(3) { background: linear-gradient(135deg, #2a2a30, #4a4a55); }
.ytd-empty-art i {
    position: absolute; left: 50%; top: 50%; width: 38px; height: 27px; margin: -13.5px 0 0 -19px;
    display: grid; place-items: center; border-radius: 8px; color: #fff; background: var(--ytd-red); font-size: .8rem;
}
.ytd-empty-title { margin: 0; font-weight: 800; color: var(--bm-ink); }
.ytd-empty-text { margin: 2px 0 0; font-size: .9rem; color: var(--bm-ink-3); }

/* ---------------------------------------------------------------
   Buttons shared by the tool
   --------------------------------------------------------------- */
.ytd .bm-btn-soft.is-busy .bm-spinner { display: inline-block; border-color: rgba(151, 85, 42, .25); border-top-color: var(--bm-accent-strong); }
.ytd .bm-btn-soft.is-busy .bm-spinner + i { display: none; }
.ytd .bm-icon-btn:disabled { opacity: .45; cursor: not-allowed; transform: none; }
.ytd .bm-icon-btn:hover:not(:disabled) { border-color: var(--bm-accent); }
.ytd .bm-btn-soft:hover:not(:disabled) { border-color: var(--bm-accent); }

/* ---------------------------------------------------------------
   Batch
   --------------------------------------------------------------- */
.ytd-batch { margin-top: 18px; animation: bm-rise .4s var(--bm-ease) both; }
.ytd-batch-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 10px; margin-bottom: 10px; }
.ytd-batch-head h2 { display: flex; align-items: center; gap: 8px; margin: 0; font-size: 1.2rem; font-weight: 800; }
.ytd-batch-list { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 10px; }
.ytd-bcard {
    position: relative; display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: start; gap: 6px;
    padding: 8px; border-radius: var(--bm-r); background: var(--bm-surface); border: 1.5px solid var(--bm-line);
    transition: border-color .18s, box-shadow .18s, transform .18s var(--bm-ease);
    animation: bm-rise .35s var(--bm-ease) both; animation-delay: calc(min(var(--i, 0), 12) * 35ms);
}
.ytd-bcard:hover { border-color: var(--ytd-tint-line); box-shadow: var(--bm-shadow); transform: translateY(-1px); }
.ytd-bcard.is-active { border-color: var(--bm-accent); box-shadow: 0 0 0 3px var(--bm-accent-ring); }
.ytd-bcard-main {
    display: grid; grid-template-columns: 96px minmax(0, 1fr); gap: 10px; align-items: center; min-width: 0;
    padding: 0; border: 0; background: none; text-align: left; font: inherit; cursor: pointer; color: inherit;
}
.ytd-bthumb { position: relative; display: block; overflow: hidden; aspect-ratio: 16 / 9; border-radius: 8px; background: #26262b; }
.ytd-bthumb img { display: block; width: 100%; height: 100%; object-fit: cover; }
.ytd-bthumb.is-loading img { opacity: .55; }
.ytd-bprogress { position: absolute; left: 0; bottom: 0; height: 3px; width: 0; background: var(--bm-accent); transition: width .3s var(--bm-ease), opacity .4s .3s; }
.ytd-bcard:not([data-status="probing"]) .ytd-bprogress { opacity: 0; }
.ytd-bmeta { min-width: 0; display: grid; gap: 2px; }
.ytd-btitle { font-size: .86rem; font-weight: 700; line-height: 1.25; color: var(--bm-ink); overflow-wrap: anywhere; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.ytd-bsub { font-size: .76rem; color: var(--bm-ink-3); font-variant-numeric: tabular-nums; }
.ytd-bcard[data-status="missing"] .ytd-bsub { color: var(--bm-prot); font-weight: 700; }
.ytd-bcard[data-status="ready"] .ytd-bsub { color: var(--bm-live); font-weight: 600; }

/* ---------------------------------------------------------------
   Active video
   --------------------------------------------------------------- */
.ytd-work { margin-top: 18px; display: grid; gap: 16px; }
.ytd-work.is-enter .ytd-video { animation: bm-rise .35s var(--bm-ease) both; }

.ytd-video {
    display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); gap: 22px; align-items: start;
    padding: 16px; border-radius: var(--bm-r-lg);
    background: linear-gradient(135deg, var(--ytd-tint) 0%, var(--bm-surface) 70%);
    border: 1px solid var(--ytd-tint-line);
    box-shadow: 0 14px 34px -22px rgba(151, 85, 42, .45);
}
.ytd-media { min-width: 0; }
.ytd-hero {
    position: relative; overflow: hidden; width: 100%; aspect-ratio: 16 / 9; border-radius: 14px;
    background: #1b1b1f linear-gradient(110deg, #232328 30%, #33333a 50%, #232328 70%); background-size: 200% 100%;
    box-shadow: 0 18px 36px -18px rgba(16, 22, 43, .55), 0 0 0 1px rgba(16, 22, 43, .06);
}
.ytd-hero.is-loading { animation: bm-shimmer 1.2s linear infinite; }
.ytd-hero img { display: block; width: 100%; height: 100%; object-fit: cover; }
.ytd-hero img:not([hidden]) { animation: ytd-fade .4s ease-out both; }
.ytd-hero::after { content: ""; position: absolute; inset: 0; pointer-events: none; background: linear-gradient(180deg, rgba(0, 0, 0, 0) 60%, rgba(0, 0, 0, .3) 100%); }
.ytd-hero.is-missing::before {
    content: "\f03e"; font-family: "Font Awesome 6 Free"; font-weight: 400; position: absolute; inset: 0;
    display: grid; place-items: center; font-size: 2.4rem; color: #6d6d78;
}
.ytd-hero-res {
    position: absolute; right: 10px; bottom: 10px; z-index: 1; padding: 3px 8px; border-radius: 6px;
    font-size: .76rem; font-weight: 700; font-variant-numeric: tabular-nums; color: #fff; background: rgba(0, 0, 0, .75);
}
.ytd .ytd-hero-play {
    position: absolute; left: 12px; bottom: 10px; z-index: 1; width: 44px; height: 31px;
    display: grid; place-items: center; border-radius: 9px; font-size: .85rem;
    color: #fff !important; background: rgba(230, 33, 23, .94); text-decoration: none;
    box-shadow: 0 8px 18px -8px rgba(0, 0, 0, .6); transition: transform .2s var(--bm-ease);
}
.ytd .ytd-hero-play:hover { transform: scale(1.08); }
.ytd-hero.is-loading .ytd-hero-play, .ytd-hero.is-missing .ytd-hero-play { display: none; }

.ytd-meta { min-width: 0; }
.ytd-kicker {
    display: inline-flex; align-items: center; gap: 6px; margin: 2px 0 6px;
    font-size: .72rem; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; color: var(--bm-accent-strong);
}
.ytd-kicker.is-found { color: var(--bm-live); }
.ytd-kicker.is-found i { animation: bm-pop .38s var(--bm-ease); }
.ytd-kicker.is-missing { color: var(--bm-prot); }
.ytd-title {
    margin: 0; font-size: 1.18rem; font-weight: 800; line-height: 1.3; color: var(--bm-ink); overflow-wrap: anywhere;
    display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden;
}
.ytd-title[hidden] { display: none; }
.ytd-channel { margin: 4px 0 0; font-size: .9rem; }
.ytd .ytd-channel a { color: var(--bm-ink-3) !important; text-decoration: none; font-weight: 600; }
.ytd .ytd-channel a[href]:hover { color: var(--bm-accent-strong) !important; text-decoration: underline; }
.ytd-channel a::before { content: "by "; font-weight: 400; }

.ytd-idrow { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; margin-top: 10px; }
.ytd-id {
    display: inline-flex; align-items: center; gap: 6px; padding: 3px 4px 3px 10px; border-radius: 999px;
    font: 700 .84rem/1.2 ui-monospace, SFMono-Regular, Consolas, monospace; color: var(--bm-ink);
    background: var(--bm-surface); border: 1px solid var(--bm-line);
}
.ytd-id button { display: grid; place-items: center; width: 28px; height: 28px; border: 0; border-radius: 50%; background: var(--bm-line-2); color: var(--bm-ink-2); cursor: pointer; }
.ytd-id button:hover, .ytd-id button.is-copied { background: var(--bm-accent-soft); color: var(--bm-accent-strong); }
.ytd .ytd-watch { display: inline-flex; align-items: center; gap: 6px; font-size: .86rem; font-weight: 700; color: var(--bm-accent-strong) !important; text-decoration: none; }
.ytd .ytd-watch i { color: var(--ytd-red); }
.ytd .ytd-watch:hover { text-decoration: underline; }

.ytd-main-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
.ytd-main-actions .bm-btn { min-height: 46px; }
.ytd-main-actions .bm-btn-primary { font-size: .95rem; }

.ytd-mini-head {
    display: flex; align-items: center; gap: 6px; margin: 0 0 8px;
    font-size: .74rem; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; color: var(--bm-ink-3);
}
.ytd-mini-head span { font-weight: 600; letter-spacing: 0; text-transform: none; opacity: .85; }
.ytd-mini-head span::before { content: "\00b7"; margin-right: 6px; }

.ytd-palette { margin-top: 14px; }
.ytd-palette ul { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 6px; }
.ytd-swatch {
    display: grid; width: 100%; padding: 0; overflow: hidden; border-radius: 10px; cursor: pointer;
    border: 1px solid var(--bm-line); background: var(--bm-surface); font: inherit;
    transition: transform .16s var(--bm-ease), box-shadow .16s;
    animation: bm-rise .3s var(--bm-ease) both; animation-delay: calc(var(--i, 0) * 50ms);
}
.ytd-swatch:hover { transform: translateY(-2px); box-shadow: var(--bm-shadow); }
.ytd-swatch-chip { display: block; height: 34px; background: var(--c); }
.ytd-swatch-hex { display: block; padding: 4px 2px; font: 700 .7rem/1.2 ui-monospace, SFMono-Regular, Consolas, monospace; color: var(--bm-ink-2); text-align: center; }
.ytd-swatch.is-copied .ytd-swatch-hex { color: var(--bm-live); }
.ytd-swatch.is-copied .ytd-swatch-chip { animation: bm-bump .3s var(--bm-ease); }

.ytd-honest {
    display: flex; gap: 8px; margin: 14px 0 0; padding: 9px 11px; border-radius: 10px;
    font-size: .82rem; line-height: 1.45; color: var(--bm-ink-3); background: var(--bm-surface); border: 1px solid var(--bm-line-2);
}
.ytd-honest i { margin-top: 3px; color: var(--bm-ink-3); }

/* ---------------------------------------------------------------
   Panels
   --------------------------------------------------------------- */
.ytd-panel {
    padding: 16px; border-radius: var(--bm-r-lg); background: var(--bm-surface); border: 1px solid var(--bm-line);
    box-shadow: var(--bm-shadow);
}
.ytd-panel-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 6px; }
.ytd-h2 { display: flex; align-items: center; gap: 8px; margin: 0; font-size: 1.12rem; font-weight: 800; }
.ytd-h2 > i { color: var(--bm-accent); }

.ytd-format { display: inline-flex; flex-wrap: wrap; align-items: center; gap: 4px; padding: 4px; border-radius: 12px; background: var(--bm-bg); border: 1px solid var(--bm-line-2); }
.ytd-format-label { padding: 0 6px 0 8px; font-size: .74rem; font-weight: 800; letter-spacing: .05em; text-transform: uppercase; color: var(--bm-ink-3); }
.ytd-format button, .ytd-seg button {
    display: inline-flex; align-items: center; gap: 6px; min-height: 34px; padding: 0 12px; border: 0; border-radius: 9px;
    font: inherit; font-size: .86rem; font-weight: 700; color: var(--bm-ink-3); background: transparent; cursor: pointer;
    transition: background-color .16s, color .16s, box-shadow .16s;
}
.ytd-format button:hover, .ytd-seg button:hover { color: var(--bm-ink); }
.ytd-format button[aria-checked="true"], .ytd-seg button[aria-checked="true"] { color: var(--bm-ink); background: var(--bm-surface); box-shadow: 0 1px 3px rgba(16, 22, 43, .12); }

.ytd-probe { display: flex; align-items: center; gap: 12px; margin: 10px 0 4px; }
.ytd-probe .bm-bar { flex: 1; position: relative; }
.ytd-probe .bm-bar::after { content: ""; position: absolute; inset: 0; background: linear-gradient(90deg, transparent 0%, rgba(255, 255, 255, .6) 50%, transparent 100%); transform: translateX(-100%); animation: bm-sweep 1.4s infinite; }
.ytd-probe-seg { background: linear-gradient(90deg, #f0655f, #f79250, #f8b04d); }
.ytd-probe-text { font-size: .8rem; color: var(--bm-ink-3); font-variant-numeric: tabular-nums; white-space: nowrap; }

.ytd-group-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 8px; margin: 14px 0 8px; font-size: .78rem; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; color: var(--bm-ink-3); }
.ytd-group-head span { font-weight: 500; letter-spacing: 0; text-transform: none; font-size: .82rem; }
.ytd-group-head[hidden] { display: none; }

.ytd-variants { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.ytd-var {
    display: grid; grid-template-columns: 96px minmax(0, 1fr); grid-template-rows: auto auto; gap: 8px 12px; align-items: center;
    padding: 8px; border-radius: 12px; background: var(--bm-surface); border: 1px solid var(--bm-line);
    transition: border-color .16s, box-shadow .16s;
    animation: bm-rise .32s var(--bm-ease) both; animation-delay: calc(min(var(--i, 0), 20) * 25ms);
}
.ytd-var:hover { border-color: var(--ytd-tint-line); box-shadow: var(--bm-shadow); }
.ytd-var-thumb { position: relative; grid-row: 1 / 3; align-self: center; display: block; overflow: hidden; aspect-ratio: 16 / 9; border-radius: 8px; background: #e9e5e1; }

/* Frames: collapsed behind a strip of the three stills */
.ytd-frames { margin-top: 14px; border: 1px solid var(--bm-line); border-radius: 12px; background: var(--bm-bg); }
.ytd-frames[hidden] { display: none; }
.ytd-frames summary {
    display: flex; align-items: center; gap: 12px; min-height: 60px; padding: 8px 14px 8px 8px;
    list-style: none; cursor: pointer; border-radius: 12px; transition: background-color .16s;
}
.ytd-frames summary::-webkit-details-marker { display: none; }
.ytd-frames summary:hover { background: var(--ytd-tint); }
.ytd-frames summary:focus-visible { outline: 3px solid var(--bm-accent-ring); outline-offset: 2px; }
.ytd-frames-strip { display: flex; flex: none; }
.ytd-frames-strip img { width: 64px; height: 36px; object-fit: cover; border-radius: 6px; border: 2px solid var(--bm-surface); box-shadow: 0 2px 6px rgba(16, 22, 43, .18); background: #ddd; }
.ytd-frames-strip img + img { margin-left: -18px; }
.ytd-frames summary:hover .ytd-frames-strip img + img { margin-left: -6px; }
.ytd-frames-strip img { transition: margin .2s var(--bm-ease); }
.ytd-frames-text { flex: 1; min-width: 0; display: grid; gap: 1px; }
.ytd-frames-text b { display: flex; align-items: center; gap: 6px; font-size: .92rem; color: var(--bm-ink); }
.ytd-frames-text small { font-size: .8rem; color: var(--bm-ink-3); }
.ytd-frames summary > i { color: var(--bm-ink-3); transition: transform .2s var(--bm-ease); }
.ytd-frames[open] summary > i { transform: rotate(180deg); }
.ytd-frames .ytd-variants { padding: 0 8px 8px; }

.ytd-work.is-missing > .ytd-panel:last-child, .ytd-work.is-missing .ytd-format { display: none; }
.ytd-bcard[data-status="missing"] .ytd-bthumb img { opacity: .4; filter: grayscale(1); }
.ytd-var-thumb img { display: block; width: 100%; height: 100%; object-fit: cover; }
.ytd-var-best { position: absolute; left: 4px; top: 4px; padding: 1px 6px; border-radius: 999px; font-size: .64rem; font-weight: 800; letter-spacing: .04em; text-transform: uppercase; color: #fff; background: var(--bm-live); }
.ytd-var-text { min-width: 0; display: grid; gap: 1px; }
.ytd-var-name { font-size: .9rem; font-weight: 700; color: var(--bm-ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ytd-var-dims { font-size: .8rem; color: var(--bm-ink-3); font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ytd-var-dims b { color: var(--bm-ink-2); font-weight: 700; }
.ytd-var-size.is-in { animation: ytd-fade .3s ease-out; }
.ytd-var-file { font: 600 .72rem/1.3 ui-monospace, SFMono-Regular, Consolas, monospace; color: #8a90a0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ytd-var-actions { display: flex; flex-wrap: wrap; gap: 4px; min-width: 0; }
.ytd .ytd-var-actions .bm-icon-btn { width: 36px; height: 36px; }
.ytd .ytd-var-dl { min-height: 36px; padding: 0 12px; font-size: .84rem; border-radius: 10px; }
.ytd .ytd-var-dl.is-working i { animation: ytd-bob .6s ease-in-out infinite; }
.ytd .ytd-var-dl.is-copied { color: var(--bm-live); border-color: var(--bm-live); background: var(--bm-live-soft); }
.ytd .bm-icon-btn.ytd-var-webp { width: auto; padding: 0 9px; font-size: .74rem; font-weight: 800; letter-spacing: .02em; }
.ytd-var.is-skeleton { animation: none; border-style: dashed; }
.ytd-sk-thumb, .ytd-sk-lines {
    display: block; border-radius: 8px;
    background: linear-gradient(90deg, #f1ede9 0%, #faf7f4 50%, #f1ede9 100%); background-size: 200% 100%; animation: bm-shimmer 1.2s linear infinite;
}
.ytd-sk-thumb { grid-row: 1 / 3; height: 54px; }
.ytd-sk-lines { height: 36px; grid-column: 2; grid-row: 1 / 3; }
.ytd-note { margin: 10px 0 0; padding: 10px 12px; border-radius: 10px; font-size: .88rem; font-weight: 600; color: var(--bm-prot); background: var(--bm-prot-soft); }

/* ---------------------------------------------------------------
   Tabs
   --------------------------------------------------------------- */
.ytd-tabs { display: inline-flex; margin-bottom: 14px; }
.ytd-tabs button { min-height: 40px; }
.ytd-tabs button i { color: var(--bm-accent); }
.ytd-tabpanel { animation: ytd-fade .25s ease-out both; }

/* ---------------------------------------------------------------
   Crop
   --------------------------------------------------------------- */
.ytd-presets { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 8px; margin-bottom: 14px; }
.ytd-presets button {
    display: grid; justify-items: center; align-content: center; gap: 3px; min-height: 84px; padding: 8px 4px;
    border: 1.5px solid var(--bm-line); border-radius: 12px; background: var(--bm-surface); font: inherit; cursor: pointer; color: var(--bm-ink-2);
    transition: border-color .16s, background-color .16s, transform .16s var(--bm-ease), box-shadow .16s;
}
.ytd-presets button:hover { border-color: var(--bm-accent); transform: translateY(-1px); }
.ytd-presets button[aria-checked="true"] { border-color: var(--bm-accent); background: var(--bm-accent-soft); box-shadow: 0 0 0 3px var(--bm-accent-ring); color: var(--bm-ink); }
.ytd-presets b { font-size: .9rem; line-height: 1.1; }
.ytd-presets small { font-size: .72rem; color: var(--bm-ink-3); line-height: 1.1; }
.ytd-shape {
    display: block; height: 26px; width: calc(26px * var(--r)); max-width: 50px; max-height: 26px;
    border-radius: 4px; border: 2px solid currentColor; opacity: .55;
}
.ytd-presets button[aria-checked="true"] .ytd-shape { opacity: 1; color: var(--bm-accent-strong); background: rgba(247, 146, 80, .2); }

.ytd-crop { display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr); gap: 18px; align-items: start; }
.ytd-crop-stage-wrap { min-width: 0; }
.ytd-crop-stage {
    --ar: 16 / 9;
    position: relative; overflow: hidden; width: 100%; aspect-ratio: var(--ar); border-radius: 12px;
    background: #1b1b1f; touch-action: none; user-select: none; -webkit-user-select: none; cursor: crosshair;
}
.ytd-crop-stage img { display: block; width: 100%; height: 100%; object-fit: fill; pointer-events: none; }
.ytd-crop-stage.is-empty { background: #1b1b1f linear-gradient(110deg, #232328 30%, #33333a 50%, #232328 70%); background-size: 200% 100%; animation: bm-shimmer 1.2s linear infinite; cursor: default; }
.ytd-crop-stage.is-empty img, .ytd-crop-stage.is-empty .ytd-crop-box { display: none; }
.ytd-crop-box {
    position: absolute; left: 0; top: 0; width: 100%; height: 100%;
    border: 2px solid #fff; border-radius: 3px; cursor: grab;
    box-shadow: 0 0 0 9999px rgba(10, 10, 14, .58), 0 0 0 1px rgba(0, 0, 0, .35) inset;
    transition: left .22s var(--bm-ease), top .22s var(--bm-ease), width .22s var(--bm-ease), height .22s var(--bm-ease);
    background-image:
        linear-gradient(rgba(255, 255, 255, .35), rgba(255, 255, 255, .35)), linear-gradient(rgba(255, 255, 255, .35), rgba(255, 255, 255, .35)),
        linear-gradient(90deg, rgba(255, 255, 255, .35), rgba(255, 255, 255, .35)), linear-gradient(90deg, rgba(255, 255, 255, .35), rgba(255, 255, 255, .35));
    background-size: 1px 100%, 1px 100%, 100% 1px, 100% 1px;
    background-position: 33.33% 0, 66.66% 0, 0 33.33%, 0 66.66%;
    background-repeat: no-repeat;
}
.ytd-crop-box:focus-visible { outline: 3px solid var(--bm-accent); outline-offset: 2px; }
.ytd-crop-stage.is-dragging .ytd-crop-box { cursor: grabbing; transition: none; }
.ytd-crop-grip {
    position: absolute; left: 50%; top: 50%; width: 40px; height: 40px; margin: -20px 0 0 -20px;
    display: grid; place-items: center; border-radius: 50%; color: var(--bm-ink); background: rgba(255, 255, 255, .92);
    box-shadow: 0 6px 16px -6px rgba(0, 0, 0, .6); font-size: .9rem; transition: transform .18s var(--bm-ease);
}
.ytd-crop-stage.is-dragging .ytd-crop-grip { transform: scale(.9); }
.ytd-crop-hint, .ytd-crop-bars { display: flex; align-items: center; gap: 6px; margin: 8px 0 0; font-size: .82rem; color: var(--bm-ink-3); }
.ytd-crop-bars { color: var(--bm-live); font-weight: 600; }

.ytd-crop-side { min-width: 0; }
.ytd-crop-preview {
    display: grid; place-items: center; min-height: 190px; padding: 10px; border-radius: 12px;
    background: repeating-conic-gradient(#f1ede9 0% 25%, #faf8f6 0% 50%) 0 0 / 16px 16px; border: 1px solid var(--bm-line);
}
.ytd-crop-preview canvas { display: block; max-width: 100%; max-height: 300px; width: auto; height: auto; border-radius: 6px; box-shadow: 0 10px 24px -12px rgba(16, 22, 43, .5); }
.ytd-crop-facts { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; margin: 10px 0; }
.ytd-crop-facts div { padding: 7px 10px; border-radius: 10px; background: var(--bm-bg); border: 1px solid var(--bm-line-2); min-width: 0; }
.ytd-crop-facts dt { font-size: .7rem; font-weight: 800; letter-spacing: .05em; text-transform: uppercase; color: var(--bm-ink-3); }
.ytd-crop-facts dd { margin: 0; font-size: .86rem; font-weight: 700; color: var(--bm-ink); font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.ytd-crop-format { display: grid; gap: 4px; margin: 0 0 10px; }
.ytd-mini-label { font-size: .74rem; font-weight: 800; letter-spacing: .05em; text-transform: uppercase; color: var(--bm-ink-3); }
.ytd .ytd-crop-format select { width: 100%; max-width: none; min-height: 42px; border: 1px solid var(--bm-line); border-radius: 10px; background: var(--bm-surface); font: inherit; font-size: .92rem; color: var(--bm-ink); padding: 0 10px; }
.ytd .ytd-crop-format select:focus { outline: none; border-color: var(--bm-accent); box-shadow: 0 0 0 3px var(--bm-accent-ring); }
.ytd-crop-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.ytd-crop-actions .bm-btn-primary { flex: 1 1 auto; min-height: 46px; font-size: .95rem; }
.ytd-crop-actions .bm-btn-ghost { min-height: 46px; }

/* ---------------------------------------------------------------
   Mock-ups (YouTube's own light and dark palettes)
   --------------------------------------------------------------- */
.ytd-mock-controls { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 18px; margin-bottom: 14px; }
.ytd-seg { display: inline-flex; gap: 4px; padding: 4px; border-radius: 12px; background: var(--bm-bg); border: 1px solid var(--bm-line-2); }

.ytd-switch { position: relative; display: inline-flex; align-items: center; gap: 10px; margin: 0; min-height: 40px; font-size: .9rem; font-weight: 700; color: var(--bm-ink-2); cursor: pointer; }
.ytd-switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.ytd-switch-ui { position: relative; width: 42px; height: 24px; border-radius: 999px; background: #d9d4cf; transition: background-color .2s; }
.ytd-switch-ui::after { content: ""; position: absolute; left: 3px; top: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, .3); transition: transform .2s var(--bm-ease); }
.ytd-switch input:checked + .ytd-switch-ui { background: var(--bm-accent-strong); }
.ytd-switch input:checked + .ytd-switch-ui::after { transform: translateX(18px); }
.ytd-switch input:focus-visible + .ytd-switch-ui { outline: 3px solid var(--bm-accent-ring); outline-offset: 2px; }

.ytd-duration { display: inline-flex; align-items: center; gap: 8px; margin: 0; font-size: .9rem; font-weight: 700; color: var(--bm-ink-2); }
.ytd-duration input { width: 84px; min-height: 40px; padding: 0 10px; border: 1px solid var(--bm-line); border-radius: 10px; font: 700 .9rem/1 ui-monospace, SFMono-Regular, Consolas, monospace; color: var(--bm-ink); background: var(--bm-surface); }
.ytd-duration input:focus { outline: none; border-color: var(--bm-accent); box-shadow: 0 0 0 3px var(--bm-accent-ring); }

.ytd-mocks {
    --yt-bg: #ffffff; --yt-text: #0f0f0f; --yt-sub: #606060; --yt-ghost: #f2f2f2; --yt-line: #e5e5e5;
    display: grid; gap: 14px; padding: 18px; border-radius: 14px; background: var(--yt-bg); border: 1px solid var(--bm-line);
    font-family: Roboto, Arial, system-ui, sans-serif; transition: background-color .3s;
}
.ytd-mocks.is-dark { --yt-bg: #0f0f0f; --yt-text: #f1f1f1; --yt-sub: #aaaaaa; --yt-ghost: #272727; --yt-line: #303030; border-color: #0f0f0f; }
.ytd-mock { margin: 0; min-width: 0; }
.ytd-mock figcaption { margin: 0 0 8px; font-family: inherit; font-size: .72rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--yt-sub); }
.ytd-mock figcaption span { text-transform: none; letter-spacing: 0; font-weight: 400; }
.ytd-mocks .ytd-card-title { margin: 0; font-size: 16px; font-weight: 500; line-height: 22px; color: var(--yt-text); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; overflow-wrap: anywhere; }
.ytd-mocks .ytd-card-sub { margin: 0; font-size: 14px; line-height: 20px; color: var(--yt-sub); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ytd-line { height: 12px; margin: 6px 0 0; border-radius: 6px; background: var(--yt-ghost); }
.ytd-line.is-short { width: 60%; }

.ytd-mthumb { position: relative; overflow: hidden; aspect-ratio: 16 / 9; border-radius: 12px; background: var(--yt-ghost); }
.ytd-mthumb img { display: block; width: 100%; height: 100%; object-fit: cover; }
.ytd-mthumb.is-flat { border-radius: 0; }
.ytd-mthumb.is-tiny { border-radius: 8px; width: 168px; flex: none; }
.ytd-badge {
    position: absolute; right: 8px; bottom: 8px; z-index: 1; padding: 1px 4px; border-radius: 4px;
    font-size: 12px; font-weight: 500; line-height: 18px; color: #fff; background: rgba(0, 0, 0, .8); letter-spacing: .3px;
}
.ytd-badge[hidden] { display: none; }
.ytd-mthumb.is-tiny .ytd-badge { right: 4px; bottom: 4px; }

.ytd-avatar {
    flex: none; display: grid; place-items: center; width: 36px; height: 36px; border-radius: 50%;
    font-size: 15px; font-weight: 500; color: #fff; background: linear-gradient(135deg, #f79250, #e62117);
}
.ytd-avatar.is-sm { width: 24px; height: 24px; font-size: 11px; }
.ytd-card-ghost .ytd-avatar, .is-ghost .ytd-avatar { background: var(--yt-ghost); }

.ytd-mock-home { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
.ytd-card-meta { display: flex; gap: 12px; margin-top: 12px; min-width: 0; }
.ytd-card-meta > div { min-width: 0; flex: 1; }

.ytd-mock-search { display: grid; grid-template-columns: minmax(0, 360px) minmax(0, 1fr); gap: 16px; }
.ytd-search-meta { min-width: 0; }
.ytd-mocks .ytd-search-meta .ytd-card-title { font-size: 18px; line-height: 26px; font-weight: 400; }
.ytd-search-ch { display: flex; align-items: center; gap: 8px; margin: 10px 0 !important; }

.ytd-mock-row { display: grid; grid-template-columns: minmax(0, 340px) minmax(0, 1fr); gap: 24px; align-items: start; }
.ytd-phone { width: 100%; max-width: 340px; overflow: hidden; border-radius: 26px; border: 8px solid #1b1b1f; background: var(--yt-bg); box-shadow: 0 18px 34px -20px rgba(0, 0, 0, .55); }
.ytd-phone-bar { display: flex; align-items: center; gap: 8px; height: 40px; padding: 0 12px; color: var(--ytd-red); font-size: 18px; }
.ytd-phone-bar span { height: 10px; width: 64px; border-radius: 5px; background: var(--yt-ghost); }
.ytd-phone .ytd-card-meta { padding: 0 12px 14px; }
.ytd-phone .ytd-card-title { font-size: 14px; line-height: 20px; }
.ytd-phone .ytd-card-sub { font-size: 12px; line-height: 18px; }
.ytd-ghost-thumb { height: 60px; aspect-ratio: auto; }

.ytd-mock-side { display: grid; gap: 8px; max-width: 420px; }
.ytd-side-item { display: flex; gap: 8px; min-width: 0; }
.ytd-side-item > div:last-child { min-width: 0; flex: 1; }
.ytd-mocks .ytd-side-item .ytd-card-title { font-size: 14px; line-height: 20px; }
.ytd-mocks .ytd-side-item .ytd-card-sub { font-size: 12px; line-height: 18px; }
.ytd-side-item.is-ghost .ytd-mthumb { aspect-ratio: 16 / 9; }

/* Text safe area: centre zone for words and faces, and the badge corner. */
.ytd-safe { position: absolute; inset: 0; z-index: 2; pointer-events: none; opacity: 0; transition: opacity .2s; }
.ytd-mocks.show-safe .ytd-safe { opacity: 1; }
.ytd-safe-inner { position: absolute; left: 6%; right: 6%; top: 8%; bottom: 8%; border: 2px dashed rgba(52, 211, 153, .95); border-radius: 6px; background: rgba(52, 211, 153, .12); }
.ytd-safe-badge {
    position: absolute; right: 0; bottom: 0; width: 70px; height: 34px; border-top-left-radius: 8px;
    background: repeating-linear-gradient(135deg, rgba(239, 68, 68, .55) 0 6px, rgba(239, 68, 68, .2) 6px 12px);
    outline: 2px solid rgba(239, 68, 68, .9); outline-offset: -2px;
}
.ytd-mthumb.is-tiny .ytd-safe-badge { width: 52px; height: 28px; }
.ytd-safe-legend { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px; margin: 12px 0 0; font-size: 12px; color: var(--yt-sub); }
.ytd-legend-inner, .ytd-legend-badge { display: inline-block; width: 16px; height: 12px; border-radius: 3px; }
.ytd-legend-inner { border: 2px dashed rgba(52, 211, 153, .95); background: rgba(52, 211, 153, .15); }
.ytd-legend-badge { margin-left: 8px; background: repeating-linear-gradient(135deg, rgba(239, 68, 68, .6) 0 3px, rgba(239, 68, 68, .2) 3px 6px); }

/* ---------------------------------------------------------------
   Responsive
   --------------------------------------------------------------- */
@media (max-width: 1000px) {
    .ytd-variants { grid-template-columns: 1fr; }
    .ytd-mock-home { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .ytd-mock-home .ytd-card-ghost:last-child { display: none; }
}

@media (max-width: 860px) {
    .ytd-video { grid-template-columns: 1fr; }
    .ytd-crop { grid-template-columns: 1fr; }
    .ytd-mock-row { grid-template-columns: 1fr; }
    .ytd-mock-search { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
}

@media (max-width: 640px) {
    .ytd-inputbtns { width: 100%; }
    .ytd-inputbtns .bm-btn-primary { flex: 1; }
    .ytd-empty { flex-direction: column; text-align: center; }
    .ytd-empty-art { width: 112px; }
    .ytd-video { padding: 10px; gap: 14px; }
    .ytd-media { margin: -10px -10px 0; }
    .ytd-hero { border-radius: 17px 17px 10px 10px; box-shadow: none; }
    .ytd-main-actions .bm-btn { flex: 1 1 100%; }
    .ytd-panel { padding: 12px; }
    .ytd-panel-head { align-items: stretch; }
    .ytd-format { width: 100%; }
    .ytd-format button { flex: 1 1 auto; justify-content: center; padding: 0 6px; }
    .ytd-format-label { width: 100%; padding: 2px 6px 0; }
    .ytd-var { grid-template-columns: 84px minmax(0, 1fr); gap: 8px 10px; }
    .ytd-var-thumb { grid-row: 1; }
    .ytd-id button { width: 36px; height: 36px; }
    .ytd-var-actions { grid-column: 1 / -1; flex-wrap: nowrap; }
    .ytd .ytd-var-dl { flex: 1 1 auto; min-width: 0; padding: 0 6px; }
    .ytd .bm-icon-btn.ytd-var-webp { padding: 0 5px; flex: none; }
    .ytd .ytd-var-actions .bm-icon-btn { flex: none; }
    .ytd-tabs { display: flex; width: 100%; }
    .ytd-tabs button { flex: 1 1 0; justify-content: center; padding: 0 6px; font-size: .82rem; }
    .ytd-presets { gap: 5px; }
    .ytd-presets button { min-height: 64px; padding: 6px 2px; }
    .ytd-presets small { display: none; }
    .ytd-presets b { font-size: .78rem; }
    .ytd-shape { height: 20px; width: calc(20px * var(--r)); max-width: 36px; max-height: 20px; }
    .ytd-long { display: none; }
    .ytd-frames-text small { display: none; }
    .ytd-frames-strip img { width: 52px; height: 29px; }
    .ytd-mocks { padding: 12px; }
    .ytd-mock-home { grid-template-columns: 1fr; }
    .ytd-mock-home .ytd-card-ghost { display: none; }
    .ytd-mock-search { grid-template-columns: 1fr; }
    .ytd-mthumb.is-tiny { width: 140px; }
    .ytd-batch-list { grid-template-columns: 1fr; }
    .ytd-palette ul { gap: 4px; }
    .ytd-swatch-hex { font-size: .62rem; }
}

@media (max-width: 360px) {
    .ytd-frames-strip img:nth-child(3) { display: none; }
    .ytd-var-actions { flex-wrap: wrap; }
    .ytd .ytd-var-dl { flex: 1 1 100%; }
    .ytd .ytd-var-actions .bm-icon-btn { flex: 1 1 0; }
    .ytd-mthumb.is-tiny { width: 120px; }
    .ytd .bm-recent button.ytd-recent-item { max-width: 100%; }
}

@media (pointer: coarse) {
    .ytd .bm-icon-btn, .ytd .ytd-var-actions .bm-icon-btn { min-width: 44px; min-height: 44px; }
    .ytd .ytd-var-dl, .ytd-format button, .ytd-seg button, .ytd-tabs button, .ytd-id button { min-height: 44px; }
    .ytd-id button { min-width: 44px; }
    .ytd .bm-recent button.ytd-recent-item { min-height: 44px; }
    .ytd-switch { min-height: 44px; }
    .ytd-duration input { min-height: 44px; }
    .ytd .bm-clear { width: 44px; height: 44px; top: 4px; right: 4px; }
    .ytd .bm-link-btn.ytd-clear-history { min-height: 44px; }
}

@keyframes ytd-fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes ytd-bob { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(2px); } }

@media (prefers-reduced-motion: reduce) {
    .ytd-hero.is-loading, .ytd-crop-stage.is-empty, .ytd-sk-thumb, .ytd-sk-lines, .ytd-probe .bm-bar::after { animation: none; }
    .ytd-crop-box { transition: none; }
    .ytd-bcard:hover, .ytd-swatch:hover, .ytd-presets button:hover { transform: none; }
}
