/* ============================================================
   TimofeevVideo — Material Design 3 · 7 акцентов × 2 темы
   Токены M3 (material-web): --md-ref-*, --md-sys-*
   Кнопка «Тема» — переключатель light/dark; цвет — в настройках.
   ============================================================ */

/* ---------------- Reference (атомы) ---------------- */
:root {
    --md-ref-typeface-brand: "Inter", "Roboto", "Segoe UI", system-ui, sans-serif;
    --md-ref-typeface-plain: "Inter", "Roboto", "Segoe UI", system-ui, sans-serif;
    --md-ref-weight-regular: 400;
    --md-ref-weight-medium: 500;
    --md-ref-weight-bold: 700;
    --md-ease-standard: cubic-bezier(0.2, 0, 0.38, 0.9);
}

/* ---------------- Акцент-палитры: 7 цветов × light/dark ---------------- */
/* Сгенерировано: пары ролей M3 для red/orange/yellow/green/cyan/blue/violet. */

html[data-theme="light"][data-accent="red"] {

    --md-sys-color-primary: #B3261E;
    --md-sys-color-on-primary: #FFFFFF;
    --md-sys-color-primary-container: #FFDAD6;
    --md-sys-color-on-primary-container: #410E0B;
    --md-sys-color-secondary: #6E5D5C;
    --md-sys-color-on-secondary: #FFFFFF;
    --md-sys-color-secondary-container: #E9E0DE;
    --md-sys-color-on-secondary-container: #24201F;
    --md-sys-color-tertiary: #8A5A1F;
    --md-sys-color-on-tertiary: #FFFFFF;
    --md-sys-color-tertiary-container: #F4DFAE;
    --md-sys-color-on-tertiary-container: #3B2D05;
    --md-sys-color-error: #B3261E;
    --md-sys-color-error-container: #FFDAD6;
    --md-sys-color-surface: #FFF9F8;
    --md-sys-color-on-surface: #1D1B1B;
    --md-sys-color-surface-container: #F3EDEB;
    --md-sys-color-surface-container-high: #E9E0DE;
    --md-sys-color-surface-container-highest: #DAD1CE;
    --md-sys-color-on-surface-variant: #5D5452;
    --md-sys-color-outline: #7D7471;
    --md-sys-color-outline-variant: #CCC4C0;

}

html[data-theme="dark"][data-accent="red"] {

    --md-sys-color-primary: #FF8A80;
    --md-sys-color-on-primary: #410E0B;
    --md-sys-color-primary-container: #6E2422;
    --md-sys-color-on-primary-container: #FFDAD6;
    --md-sys-color-secondary: #E0BDB9;
    --md-sys-color-on-secondary: #3A2F23;
    --md-sys-color-secondary-container: #54423C;
    --md-sys-color-on-secondary-container: #F6E8E4;
    --md-sys-color-tertiary: #E7B968;
    --md-sys-color-on-tertiary: #402E00;
    --md-sys-color-tertiary-container: #5E4A15;
    --md-sys-color-on-tertiary-container: #F9E4B5;
    --md-sys-color-error: #FFB4AB;
    --md-sys-color-error-container: #93000A;
    --md-sys-color-surface: #1C1917;
    --md-sys-color-on-surface: #F2EEE8;
    --md-sys-color-surface-container: #2A2624;
    --md-sys-color-surface-container-high: #2B2624;
    --md-sys-color-surface-container-highest: #35302E;
    --md-sys-color-on-surface-variant: #B9B0AA;
    --md-sys-color-outline: #91837D;
    --md-sys-color-outline-variant: #4B4442;

}

html[data-theme="light"][data-accent="orange"] {

    --md-sys-color-primary: #C65C1E;
    --md-sys-color-on-primary: #FFFFFF;
    --md-sys-color-primary-container: #FFDBC2;
    --md-sys-color-on-primary-container: #3A1F00;
    --md-sys-color-secondary: #795B4E;
    --md-sys-color-on-secondary: #FFFFFF;
    --md-sys-color-secondary-container: #EEDBD1;
    --md-sys-color-on-secondary-container: #2D241E;
    --md-sys-color-tertiary: #8A6A1F;
    --md-sys-color-on-tertiary: #FFFFFF;
    --md-sys-color-tertiary-container: #F4DFAE;
    --md-sys-color-on-tertiary-container: #3B2D05;
    --md-sys-color-error: #B3261E;
    --md-sys-color-error-container: #FFDAD6;
    --md-sys-color-surface: #FFF9F4;
    --md-sys-color-on-surface: #201B17;
    --md-sys-color-surface-container: #F4ECE6;
    --md-sys-color-surface-container-high: #E9DDD6;
    --md-sys-color-surface-container-highest: #DACFC7;
    --md-sys-color-on-surface-variant: #66594F;
    --md-sys-color-outline: #887566;
    --md-sys-color-outline-variant: #D3C5AF;

}

html[data-theme="dark"][data-accent="orange"] {

    --md-sys-color-primary: #FF9E6F;
    --md-sys-color-on-primary: #3A1F00;
    --md-sys-color-primary-container: #7A4020;
    --md-sys-color-on-primary-container: #FFDBC2;
    --md-sys-color-secondary: #DCB9A8;
    --md-sys-color-on-secondary: #37271E;
    --md-sys-color-secondary-container: #594433;
    --md-sys-color-on-secondary-container: #F6E8E1;
    --md-sys-color-tertiary: #E7B968;
    --md-sys-color-on-tertiary: #402E00;
    --md-sys-color-tertiary-container: #5E4A15;
    --md-sys-color-on-tertiary-container: #F9E4B5;
    --md-sys-color-error: #FFB4AB;
    --md-sys-color-error-container: #93000A;
    --md-sys-color-surface: #211B16;
    --md-sys-color-on-surface: #F5F0E8;
    --md-sys-color-surface-container: #2F2A23;
    --md-sys-color-surface-container-high: #322C25;
    --md-sys-color-surface-container-highest: #3C362E;
    --md-sys-color-on-surface-variant: #C0B4A9;
    --md-sys-color-outline: #96836F;
    --md-sys-color-outline-variant: #4F4539;

}

html[data-theme="light"][data-accent="yellow"] {

    --md-sys-color-primary: #A55F1F;
    --md-sys-color-on-primary: #FFFFFF;
    --md-sys-color-primary-container: #FFE8B0;
    --md-sys-color-on-primary-container: #3C2400;
    --md-sys-color-secondary: #7A6B63;
    --md-sys-color-on-secondary: #FFFFFF;
    --md-sys-color-secondary-container: #EDE0D6;
    --md-sys-color-on-secondary-container: #302723;
    --md-sys-color-tertiary: #8A6A1F;
    --md-sys-color-on-tertiary: #FFFFFF;
    --md-sys-color-tertiary-container: #F4DFAE;
    --md-sys-color-on-tertiary-container: #3B2D05;
    --md-sys-color-error: #B3261E;
    --md-sys-color-error-container: #FFDAD6;
    --md-sys-color-surface: #FFFAF1;
    --md-sys-color-on-surface: #211B14;
    --md-sys-color-surface-container: #F6ECDD;
    --md-sys-color-surface-container-high: #ECE0CE;
    --md-sys-color-surface-container-highest: #DDD2BF;
    --md-sys-color-on-surface-variant: #6D6154;
    --md-sys-color-outline: #8E7D70;
    --md-sys-color-outline-variant: #DBCCBC;

}

html[data-theme="dark"][data-accent="yellow"] {

    --md-sys-color-primary: #E6B548;
    --md-sys-color-on-primary: #452C00;
    --md-sys-color-primary-container: #8A6318;
    --md-sys-color-on-primary-container: #FFE8B0;
    --md-sys-color-secondary: #E3D0B4;
    --md-sys-color-on-secondary: #3A2E20;
    --md-sys-color-secondary-container: #5E4D37;
    --md-sys-color-on-secondary-container: #F6ECE4;
    --md-sys-color-tertiary: #E7B968;
    --md-sys-color-on-tertiary: #402E00;
    --md-sys-color-tertiary-container: #5E4A15;
    --md-sys-color-on-tertiary-container: #F9E4B5;
    --md-sys-color-error: #FFB4AB;
    --md-sys-color-error-container: #93000A;
    --md-sys-color-surface: #1E1B14;
    --md-sys-color-on-surface: #F6F1E6;
    --md-sys-color-surface-container: #2D2B24;
    --md-sys-color-surface-container-high: #322F27;
    --md-sys-color-surface-container-highest: #3D3930;
    --md-sys-color-on-surface-variant: #C4BAAC;
    --md-sys-color-outline: #998A78;
    --md-sys-color-outline-variant: #4E4538;

}

html[data-theme="light"][data-accent="green"] {

    --md-sys-color-primary: #2E6B3E;
    --md-sys-color-on-primary: #FFFFFF;
    --md-sys-color-primary-container: #A7D6A0;
    --md-sys-color-on-primary-container: #0B3D1F;
    --md-sys-color-secondary: #5B6A52;
    --md-sys-color-on-secondary: #FFFFFF;
    --md-sys-color-secondary-container: #DDE7D2;
    --md-sys-color-on-secondary-container: #2C3B2B;
    --md-sys-color-tertiary: #8A6A1F;
    --md-sys-color-on-tertiary: #FFFFFF;
    --md-sys-color-tertiary-container: #EBD9A5;
    --md-sys-color-on-tertiary-container: #3B2D05;
    --md-sys-color-error: #BA3226;
    --md-sys-color-error-container: #FFDAD2;
    --md-sys-color-surface: #F5F6F1;
    --md-sys-color-on-surface: #1A211A;
    --md-sys-color-surface-container: #EBEDE5;
    --md-sys-color-surface-container-high: #E1E4DB;
    --md-sys-color-surface-container-highest: #D6DACF;
    --md-sys-color-on-surface-variant: #5A6553;
    --md-sys-color-outline: #747C70;
    --md-sys-color-outline-variant: #C0C6B8;

}

html[data-theme="dark"][data-accent="green"] {

    --md-sys-color-primary: #9BC17A;
    --md-sys-color-on-primary: #12260F;
    --md-sys-color-primary-container: #1F4A2F;
    --md-sys-color-on-primary-container: #D3E8C6;
    --md-sys-color-secondary: #BFCDB8;
    --md-sys-color-on-secondary: #101410;
    --md-sys-color-secondary-container: #2E3D2F;
    --md-sys-color-on-secondary-container: #DDEBDC;
    --md-sys-color-tertiary: #D0B066;
    --md-sys-color-on-tertiary: #211B04;
    --md-sys-color-tertiary-container: #3A3114;
    --md-sys-color-on-tertiary-container: #F0E0B0;
    --md-sys-color-error: #FFB4AB;
    --md-sys-color-error-container: #93000A;
    --md-sys-color-surface: #121812;
    --md-sys-color-on-surface: #E5E9E0;
    --md-sys-color-surface-container: #1B211A;
    --md-sys-color-surface-container-high: #1F261E;
    --md-sys-color-surface-container-highest: #232B22;
    --md-sys-color-on-surface-variant: #A6ABA2;
    --md-sys-color-outline: #909990;
    --md-sys-color-outline-variant: #3F463D;

}

html[data-theme="light"][data-accent="cyan"] {

    --md-sys-color-primary: #00727A;
    --md-sys-color-on-primary: #FFFFFF;
    --md-sys-color-primary-container: #9FECE1;
    --md-sys-color-on-primary-container: #03262A;
    --md-sys-color-secondary: #5B6B75;
    --md-sys-color-on-secondary: #FFFFFF;
    --md-sys-color-secondary-container: #DCE8EF;
    --md-sys-color-on-secondary-container: #2D3A45;
    --md-sys-color-tertiary: #8A6A1F;
    --md-sys-color-on-tertiary: #FFFFFF;
    --md-sys-color-tertiary-container: #F4DFAE;
    --md-sys-color-on-tertiary-container: #3B2D05;
    --md-sys-color-error: #BA3727;
    --md-sys-color-error-container: #FFDAD4;
    --md-sys-color-surface: #F4FBFC;
    --md-sys-color-on-surface: #1B1E21;
    --md-sys-color-surface-container: #E8F1F3;
    --md-sys-color-surface-container-high: #DDE9EB;
    --md-sys-color-surface-container-highest: #CDDADF;
    --md-sys-color-on-surface-variant: #5E666B;
    --md-sys-color-outline: #6F7B82;
    --md-sys-color-outline-variant: #BFCCD2;

}

html[data-theme="dark"][data-accent="cyan"] {

    --md-sys-color-primary: #7CE0D5;
    --md-sys-color-on-primary: #002F31;
    --md-sys-color-primary-container: #005E63;
    --md-sys-color-on-primary-container: #9FECE1;
    --md-sys-color-secondary: #C5D2E0;
    --md-sys-color-on-secondary: #1F3350;
    --md-sys-color-secondary-container: #3A4A63;
    --md-sys-color-on-secondary-container: #DCE8EF;
    --md-sys-color-tertiary: #E7B968;
    --md-sys-color-on-tertiary: #402E00;
    --md-sys-color-tertiary-container: #5E4A15;
    --md-sys-color-on-tertiary-container: #F9E4B5;
    --md-sys-color-error: #FFB4AB;
    --md-sys-color-error-container: #93000A;
    --md-sys-color-surface: #101A1C;
    --md-sys-color-on-surface: #E8F0F2;
    --md-sys-color-surface-container: #1E2B2E;
    --md-sys-color-surface-container-high: #243136;
    --md-sys-color-surface-container-highest: #2E3A40;
    --md-sys-color-on-surface-variant: #A8B2B8;
    --md-sys-color-outline: #7F8D94;
    --md-sys-color-outline-variant: #3E4A50;

}

html[data-theme="light"][data-accent="blue"] {

    --md-sys-color-primary: #0061B8;
    --md-sys-color-on-primary: #FFFFFF;
    --md-sys-color-primary-container: #CFE1FA;
    --md-sys-color-on-primary-container: #03205E;
    --md-sys-color-secondary: #5D6E86;
    --md-sys-color-on-secondary: #FFFFFF;
    --md-sys-color-secondary-container: #DDE8F6;
    --md-sys-color-on-secondary-container: #2E3C53;
    --md-sys-color-tertiary: #8A6A1F;
    --md-sys-color-on-tertiary: #FFFFFF;
    --md-sys-color-tertiary-container: #F4DFAE;
    --md-sys-color-on-tertiary-container: #3B2D05;
    --md-sys-color-error: #B3261E;
    --md-sys-color-error-container: #FFDAD6;
    --md-sys-color-surface: #F6F9FC;
    --md-sys-color-on-surface: #1B1D20;
    --md-sys-color-surface-container: #EDF2F8;
    --md-sys-color-surface-container-high: #E0E7EF;
    --md-sys-color-surface-container-highest: #CED7E3;
    --md-sys-color-on-surface-variant: #5A6673;
    --md-sys-color-outline: #738095;
    --md-sys-color-outline-variant: #C4CDD9;

}

html[data-theme="dark"][data-accent="blue"] {

    --md-sys-color-primary: #8EC2F8;
    --md-sys-color-on-primary: #002E6B;
    --md-sys-color-primary-container: #0048A8;
    --md-sys-color-on-primary-container: #CFE1FA;
    --md-sys-color-secondary: #BDD2E6;
    --md-sys-color-on-secondary: #23384F;
    --md-sys-color-secondary-container: #3C4F66;
    --md-sys-color-on-secondary-container: #DDE8F6;
    --md-sys-color-tertiary: #E7B968;
    --md-sys-color-on-tertiary: #402E00;
    --md-sys-color-tertiary-container: #5E4A15;
    --md-sys-color-on-tertiary-container: #F9E4B5;
    --md-sys-color-error: #FFB4AB;
    --md-sys-color-error-container: #93000A;
    --md-sys-color-surface: #0F1419;
    --md-sys-color-on-surface: #E8EEF3;
    --md-sys-color-surface-container: #1D2328;
    --md-sys-color-surface-container-high: #242B31;
    --md-sys-color-surface-container-highest: #2D353D;
    --md-sys-color-on-surface-variant: #AAB4BC;
    --md-sys-color-outline: #83919E;
    --md-sys-color-outline-variant: #414A53;

}

html[data-theme="light"][data-accent="violet"] {

    --md-sys-color-primary: #6750A4;
    --md-sys-color-on-primary: #FFFFFF;
    --md-sys-color-primary-container: #EADDFF;
    --md-sys-color-on-primary-container: #21104D;
    --md-sys-color-secondary: #625B71;
    --md-sys-color-on-secondary: #FFFFFF;
    --md-sys-color-secondary-container: #E8DEF8;
    --md-sys-color-on-secondary-container: #211B28;
    --md-sys-color-tertiary: #7E5260;
    --md-sys-color-on-tertiary: #FFFFFF;
    --md-sys-color-tertiary-container: #FFD9E2;
    --md-sys-color-on-tertiary-container: #3B0A1D;
    --md-sys-color-error: #B3261E;
    --md-sys-color-error-container: #FFDAD6;
    --md-sys-color-surface: #FAF8FC;
    --md-sys-color-on-surface: #1C1B1F;
    --md-sys-color-surface-container: #ECEAF1;
    --md-sys-color-surface-container-high: #E7E4EB;
    --md-sys-color-surface-container-highest: #E1DFE6;
    --md-sys-color-on-surface-variant: #49454F;
    --md-sys-color-outline: #79747E;
    --md-sys-color-outline-variant: #CAC4CE;

}

html[data-theme="dark"][data-accent="violet"] {

    --md-sys-color-primary: #D0BCFF;
    --md-sys-color-on-primary: #38166D;
    --md-sys-color-primary-container: #4F378B;
    --md-sys-color-on-primary-container: #EADDFF;
    --md-sys-color-secondary: #CAC4D0;
    --md-sys-color-on-secondary: #332D38;
    --md-sys-color-secondary-container: #4A4556;
    --md-sys-color-on-secondary-container: #E8DEF8;
    --md-sys-color-tertiary: #E8B0C2;
    --md-sys-color-on-tertiary: #35121D;
    --md-sys-color-tertiary-container: #483042;
    --md-sys-color-on-tertiary-container: #FFD9E2;
    --md-sys-color-error: #FFB4AB;
    --md-sys-color-error-container: #93000A;
    --md-sys-color-surface: #141218;
    --md-sys-color-on-surface: #E6E1E9;
    --md-sys-color-surface-container: #1E1B22;
    --md-sys-color-surface-container-high: #24212A;
    --md-sys-color-surface-container-highest: #2B2833;
    --md-sys-color-on-surface-variant: #A6A2AC;
    --md-sys-color-outline: #948D9E;
    --md-sys-color-outline-variant: #41404A;

}


/* ---------------- Общие роли (не зависят от акцента) ---------------- */

html[data-theme="light"] {
    --md-sys-color-inverse-surface: #2E2A35;
    --md-sys-color-inverse-on-surface: #F0EDF7;
    --md-sys-color-inverse-primary: #6750A4;
    --md-sys-color-scrim: #000000;
    --md-elevation-1: 0 3px 6px rgba(30,26,60,.12), 0 1px 2px rgba(30,26,60,.08);
    --md-elevation-2: 0 6px 12px rgba(30,26,60,.14), 0 2px 3px rgba(30,26,60,.10);
    --md-elevation-3: 0 10px 20px rgba(30,26,60,.16), 0 4px 6px rgba(30,26,60,.12);
}

html[data-theme="dark"] {
    --md-sys-color-inverse-surface: #E1DEE6;
    --md-sys-color-inverse-on-surface: #2E2A35;
    --md-sys-color-inverse-primary: #6750A4;
    --md-sys-color-scrim: #000000;
    --md-elevation-1: 0 3px 6px rgba(0,0,0,.30), 0 1px 2px rgba(0,0,0,.20);
    --md-elevation-2: 0 6px 12px rgba(0,0,0,.35), 0 2px 3px rgba(0,0,0,.24);
    --md-elevation-3: 0 10px 20px rgba(0,0,0,.40), 0 4px 6px rgba(0,0,0,.30);
}

/* legacy fallback: если акцент не указан — фиолетовый */
html[data-theme="light"] {
    --md-sys-color-primary: #6750A4;
    --md-sys-color-on-primary: #FFFFFF;
    --md-sys-color-primary-container: #EADDFF;
    --md-sys-color-on-primary-container: #21104D;
    --md-sys-color-secondary: #625B71;
    --md-sys-color-secondary-container: #E8DEF8;
    --md-sys-color-tertiary: #7E5260;
    --md-sys-color-tertiary-container: #FFD9E2;
    --md-sys-color-error: #B3261E;
    --md-sys-color-error-container: #FFDAD6;
    --md-sys-color-background: #FAF8FC;
    --md-sys-color-on-background: #1C1B1F;
    --md-sys-color-surface: #FAF8FC;
    --md-sys-color-on-surface: #1C1B1F;
    --md-sys-color-surface-variant: #E7E4EB;
    --md-sys-color-on-surface-variant: #49454F;
    --md-sys-color-surface-container-lowest: #FFFFFF;
    --md-sys-color-surface-container-low: #F2EFF5;
    --md-sys-color-surface-container: #ECEAF1;
    --md-sys-color-surface-container-high: #E7E4EB;
    --md-sys-color-surface-container-highest: #E1DFE6;
    --md-sys-color-outline: #79747E;
    --md-sys-color-outline-variant: #CAC4CE;
}
html[data-theme="dark"] {
    --md-sys-color-primary: #D0BCFF;
    --md-sys-color-on-primary: #38166D;
    --md-sys-color-primary-container: #4F378B;
    --md-sys-color-on-primary-container: #EADDFF;
    --md-sys-color-secondary: #CAC4D0;
    --md-sys-color-secondary-container: #4A4556;
    --md-sys-color-tertiary: #E8B0C2;
    --md-sys-color-tertiary-container: #483042;
    --md-sys-color-error: #FFB4AB;
    --md-sys-color-error-container: #93000A;
    --md-sys-color-background: #141218;
    --md-sys-color-on-background: #E6E1E9;
    --md-sys-color-surface: #141218;
    --md-sys-color-on-surface: #E6E1E9;
    --md-sys-color-surface-variant: #2B2833;
    --md-sys-color-on-surface-variant: #A6A2AC;
    --md-sys-color-surface-container-lowest: #0B090F;
    --md-sys-color-surface-container-low: #1A171F;
    --md-sys-color-surface-container: #1E1B22;
    --md-sys-color-surface-container-high: #24212A;
    --md-sys-color-surface-container-highest: #2B2833;
    --md-sys-color-outline: #948D9E;
    --md-sys-color-outline-variant: #41404A;
}

/* ---------------- Форма и типографика ---------------- */
:root {
    --md-sys-shape-corner-none: 0px;
    --md-sys-shape-corner-extra-small: 4px;
    --md-sys-shape-corner-small: 8px;
    --md-sys-shape-corner-medium: 12px;
    --md-sys-shape-corner-large: 16px;
    --md-sys-shape-corner-extra-large: 28px;
    --md-sys-shape-corner-full: 999px;

    --md-sys-typescale-display-medium-size: 45px;
    --md-sys-typescale-display-medium-line-height: 48px;
    --md-sys-typescale-headline-small-size: 24px;
    --md-sys-typescale-headline-small-line-height: 32px;
    --md-sys-typescale-title-large-size: 22px;
    --md-sys-typescale-title-large-line-height: 28px;
    --md-sys-typescale-title-medium-size: 16px;
    --md-sys-typescale-title-medium-line-height: 24px;
    --md-sys-typescale-body-large-size: 16px;
    --md-sys-typescale-body-large-line-height: 24px;
    --md-sys-typescale-label-large-size: 14px;
    --md-sys-typescale-label-large-line-height: 20px;
    --md-sys-typescale-label-medium-size: 12px;
    --md-sys-typescale-label-medium-line-height: 16px;
    --md-font: var(--md-ref-typeface-plain);
}

/* ---------------- Статусы (семантика) ---------------- */
html[data-theme="light"] {
    --status-draft: #79747E;
    --status-pending: #625B71;
    --status-ready: #6750A4;
    --status-sending: #6750A4;
    --status-sent: #6750A4;
    --status-processing: #7E5260;
    --status-completed: #6750A4;
    --status-failed: #B3261E;
    --status-done: #6750A4;
    --status-cancelled: #79747E;
}
html[data-theme="dark"] {
    --status-draft: #948D9E;
    --status-pending: #CAC4D0;
    --status-ready: #D0BCFF;
    --status-sending: #D0BCFF;
    --status-sent: #D0BCFF;
    --status-processing: #E8B0C2;
    --status-completed: #D0BCFF;
    --status-failed: #FFB4AB;
    --status-done: #D0BCFF;
    --status-cancelled: #948D9E;
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    font-family: var(--md-ref-typeface-plain);
    font-size: var(--md-sys-typescale-body-large-size);
    line-height: var(--md-sys-typescale-body-large-line-height);
    font-weight: var(--md-ref-weight-regular);
    color: var(--md-sys-color-on-surface);
    background: var(--md-sys-color-surface);
    height: 100%;
}

::selection {
    background: var(--md-sys-color-primary);
    color: var(--md-sys-color-on-primary);
}

/* ---------------- каркас ---------------- */
.app-shell { display: flex; min-height: 100vh; }

/* ---------------- Navigation Rail (M3), collapsed / expanded ---------------- */
.sidebar {
    width: 224px;
    background: var(--md-sys-color-surface-container);
    padding: 16px 32px;
    position: sticky;
    top: 0;
    height: 100vh;
    display: flex;
    flex-direction: column;
    gap: 16px;
    transition: width .25s var(--md-ease-standard), padding .25s var(--md-ease-standard);
}

/* свёрнутое состояние: ширина под иконки, отступы по центру */
.sidebar.rail-collapsed { width: 64px; padding: 16px 4px; }

.rail-brand {
    display: flex; align-items: center; gap: 10px;
    justify-content: flex-start;
    width: 100%;
    padding: 0;
    min-height: 44px;
    color: var(--md-sys-color-on-surface);
}
.brand-icon { width: 26px; height: 26px; color: var(--md-sys-color-primary); flex-shrink: 0; }
.rail-brand-label { font-size: var(--md-sys-typescale-title-medium-size); font-weight: var(--md-ref-weight-medium); color: var(--md-sys-color-primary); }

.rail-nav { display: flex; flex-direction: column; gap: 8px; align-items: stretch; }

/* expanded: иконка + подпись в одну строку */
.rail-item {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 12px;
    padding: 0 14px;
    min-height: 48px;
    border-radius: var(--md-sys-shape-corner-small);
    color: var(--md-sys-color-on-surface);
    text-decoration: none;
    font-size: var(--md-sys-typescale-label-large-size);
    font-weight: var(--md-ref-weight-medium);
    transition: background-color .15s var(--md-ease-standard), padding .25s var(--md-ease-standard);
}
.rail-item .rail-icon { display: flex; width: 26px; height: 26px; align-items: center; justify-content: center; flex-shrink: 0; }
.rail-item .rail-icon svg { color: currentColor; }
.rail-item .rail-label { font-size: var(--md-sys-typescale-label-large-size); font-weight: var(--md-ref-weight-medium); }
.rail-item:hover { background: var(--md-sys-color-surface-container-high); }
.rail-item.active {
    background: var(--md-sys-color-primary-container);
    color: var(--md-sys-color-on-primary-container);
    font-weight: var(--md-ref-weight-medium);
}

/* collapsed: иконки по центру, скрываем подписи и лого-текст */
.sidebar.rail-collapsed .rail-brand { justify-content: center; padding: 0; }
.sidebar.rail-collapsed .rail-brand-label { display: none; }
.sidebar.rail-collapsed .rail-item .rail-label { display: none; }
/* в свёрнутом виде оставляем только кнопку свернуть/развернуть */
.sidebar.rail-collapsed #themeToggle,
.sidebar.rail-collapsed #settingsToggle,
.sidebar.rail-collapsed #logoutToggle { display: none; }
.sidebar.rail-collapsed .rail-item {
    justify-content: center;
    padding: 0;
    min-height: 52px;
}

.rail-footer {
    margin-top: auto;
    display: flex;
    flex-direction: row;
    gap: 12px;
    align-items: center;
    justify-content: center;
}

/* круглые иконки-кнопки: Свернуть, Тема, Настройки */
.rail-action-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    padding: 0;
    border: none;
    border-radius: var(--md-sys-shape-corner-full);
    background: var(--md-sys-color-surface-container-high);
    color: var(--md-sys-color-on-surface);
    cursor: pointer;
    transition: background-color .15s var(--md-ease-standard), color .15s var(--md-ease-standard);
}
.rail-action-icon:hover {
    background: var(--md-sys-color-primary-container);
    color: var(--md-sys-color-on-primary-container);
}
.rail-action-icon.active {
    background: var(--md-sys-color-primary-container);
    color: var(--md-sys-color-on-primary-container);
}
.rail-action-icon svg { display: block; }
/* видимость иконок по состоянию */
html[data-rail="expanded"] .ico-chevron-left { display: block; }
html[data-rail="expanded"] .ico-chevron-right { display: none; }
html[data-rail="collapsed"] .ico-chevron-left { display: none; }
html[data-rail="collapsed"] .ico-chevron-right { display: block; }
html[data-theme="dark"] .ico-moon { display: none; }
html[data-theme="light"] .ico-sun { display: none; }

/* ---------------- ??????????? ????????????? ???? ---------------- */
.view { flex: 1; padding: 21px 32px 24px; min-width: 0; }

/* ---------------- заголовки ---------------- */
h1.page-title {
    font-size: var(--md-sys-typescale-headline-small-size);
    line-height: var(--md-sys-typescale-headline-small-line-height);
    font-weight: var(--md-ref-weight-regular);
    margin: 0 0 24px;
    color: var(--md-sys-color-on-surface);
}
.page-sub {
    color: var(--md-sys-color-on-surface-variant);
    margin: 0 0 24px;
    font-size: var(--md-sys-typescale-label-large-size);
}

/* ---------------- кнопки ---------------- */
.btn-filled {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--md-sys-color-primary);
    color: var(--md-sys-color-on-primary);
    border: none;
    border-radius: var(--md-sys-shape-corner-small);
    padding: 0 24px;
    min-height: 48px;
    font-size: var(--md-sys-typescale-label-large-size);
    font-weight: var(--md-ref-weight-medium);
    cursor: pointer;
    box-shadow: var(--md-elevation-1);
    transition: background-color .15s var(--md-ease-standard);
}
.btn-filled:hover { background: var(--md-sys-color-primary-container); color: var(--md-sys-color-on-primary-container); }
.btn-filled:active { box-shadow: none; }
.btn-filled:disabled { opacity: .5; cursor: not-allowed; box-shadow: none; }

.btn-text {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--md-sys-color-surface-container);
    color: var(--md-sys-color-on-surface);
    border: none;
    border-radius: var(--md-sys-shape-corner-small);
    padding: 0 18px;
    min-height: 48px;
    font-size: var(--md-sys-typescale-label-large-size);
    font-weight: var(--md-ref-weight-medium);
    cursor: pointer;
    transition: background-color .15s var(--md-ease-standard);
}
.btn-text:hover { background: var(--md-sys-color-surface-container-high); color: var(--md-sys-color-on-surface); }
.btn-text.active { background: var(--md-sys-color-primary-container); color: var(--md-sys-color-on-primary-container); }

/* кнопки «Авто» — плоские, без рамки и без теней */
.v-auto-btn {
    background: var(--md-sys-color-surface-container-highest);
    color: var(--md-sys-color-on-surface);
    border: none;
    border-radius: var(--md-sys-shape-corner-medium);
    transition: background-color .15s var(--md-ease-standard), color .15s var(--md-ease-standard);
}
.v-auto-btn.active {
    background: var(--md-sys-color-primary-container);
    color: var(--md-sys-color-on-primary-container);
}

.btn-danger {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--md-sys-color-error-container);
    color: var(--md-sys-color-on-error-container);
    border: none;
    border-radius: var(--md-sys-shape-corner-small);
    padding: 0 16px;
    min-height: 40px;
    font-size: var(--md-sys-typescale-label-large-size);
    font-weight: var(--md-ref-weight-medium);
    cursor: pointer;
    transition: background-color .15s var(--md-ease-standard);
}
.btn-danger:hover { background: var(--md-sys-color-error); color: var(--md-sys-color-on-error); }

/* ---------------- карточки ---------------- */
.card {
    background: var(--md-sys-color-surface-container);
    color: var(--md-sys-color-on-surface);
    border-radius: var(--md-sys-shape-corner-large);
    box-shadow: var(--md-elevation-1);
    padding: 16px 20px;
}
.card.card-pad { padding: 24px 28px; }
.card-title {
    font-size: var(--md-sys-typescale-title-medium-size);
    line-height: var(--md-sys-typescale-title-medium-line-height);
    font-weight: var(--md-ref-weight-medium);
    margin: 0 0 8px;
    color: var(--md-sys-color-on-surface);
}
.card-sub { color: var(--md-sys-color-on-surface-variant); font-size: var(--md-sys-typescale-label-large-size); margin: 0 0 16px; }

/* ---------------- формы ---------------- */
.field { display: flex; flex-direction: column; gap: 8px; margin-bottom: 16px; }
.field label { font-size: var(--md-sys-typescale-label-medium-size); font-weight: var(--md-ref-weight-medium); color: var(--md-sys-color-on-surface-variant); }
.field label.checkbox-row { display: flex; align-items: center; gap: 8px; font-size: var(--md-sys-typescale-label-large-size); color: var(--md-sys-color-on-surface); cursor: pointer; }

.input, .textarea, select.input {
    width: 100%;
    padding: 12px 14px;
    border-radius: var(--md-sys-shape-corner-small);
    background: var(--md-sys-color-surface-container-highest);
    border: none;
    color: var(--md-sys-color-on-surface);
    font-size: var(--md-sys-typescale-body-large-size);
}
select.input {
    appearance: none;
    -webkit-appearance: none;
    padding-right: 44px;
    background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 16 16'%3E%3Cpath d='M8 4L13 4 10.5 10Z' fill='none' stroke='%238A878E' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 14px center;
    background-size: 16px 16px;
}
.input::placeholder, .textarea::placeholder { color: var(--md-sys-color-on-surface-variant); }

/* убираем «болотную» заливку автозаполнения браузера — в цвет темы */
.input:-webkit-autofill,
.input:-webkit-autofill:hover,
.input:-webkit-autofill:focus,
.input:-webkit-autofill:active {
    -webkit-text-fill-color: var(--md-sys-color-on-surface);
    -webkit-box-shadow: 0 0 0 1000px var(--md-sys-color-surface-container-highest) inset;
    outline: none;
}
.input:focus, .textarea:focus {
    outline: none;
    border: none;
    background: var(--md-sys-color-primary-container);
    color: var(--md-sys-color-on-primary-container);
}
.input:focus-visible, .textarea:focus-visible { outline: none; }
.textarea { min-height: 96px; resize: vertical; }

/* Поле промпта с подсветкой полей [в квадратных скобках] */
.prompt-wrap {
    position: relative;
    display: flex;
    border-radius: var(--md-sys-shape-corner-small);
    overflow: hidden;
    overflow-anchor: none;
    background: var(--md-sys-color-surface-container-highest);
}
.prompt-wrap .prompt-input {
    position: relative;
    flex: 1;
    padding: 12px 14px;
    border: none;
    resize: none;
    overflow: hidden;
    font-family: inherit;
    font-size: var(--md-sys-typescale-body-large-size);
    line-height: 1.6;
    background: transparent;
    color: transparent;
    caret-color: var(--md-sys-color-on-surface);
    overflow-anchor: none;
}
.prompt-wrap .prompt-input::placeholder { color: var(--md-sys-color-on-surface-variant); }
.prompt-wrap .prompt-highlight {
    position: absolute; inset: 0;
    padding: 12px 14px;
    font-family: inherit;
    font-size: var(--md-sys-typescale-body-large-size);
    line-height: 1.6;
    color: var(--md-sys-color-on-surface);
    white-space: pre-wrap;
    overflow-wrap: break-word;
    pointer-events: none;
}
.prompt-wrap:focus-within { background: var(--md-sys-color-primary-container); }
.prompt-wrap:focus-within .prompt-highlight { color: var(--md-sys-color-on-primary-container); }
.prompt-wrap .ph {
    background: var(--md-sys-color-tertiary-container);
    color: var(--md-sys-color-on-tertiary-container);
    border-radius: 4px;
    padding: 0 3px;
    font-weight: 500;
}
.field-error { color: var(--md-sys-color-error); font-size: var(--md-sys-typescale-label-medium-size); }
.field-error:empty { display: none; }

/* ---------------- чипы / статусы ---------------- */
.chip {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 6px 12px;
    border-radius: var(--md-sys-shape-corner-small);
    background: var(--md-sys-color-surface-container-highest);
    color: var(--md-sys-color-on-surface);
    font-size: var(--md-sys-typescale-label-medium-size);
    font-weight: var(--md-ref-weight-medium);
}
.chip i { width: 8px; height: 8px; border-radius: 50%; display: inline-block; background: var(--status-pending); }
.chip[data-status="completed"], .chip[data-status="done"], .chip[data-status="ready"], .chip[data-status="sent"] {
    background: var(--md-sys-color-primary-container);
    color: var(--md-sys-color-on-primary-container);
}
.chip[data-status="failed"] { background: var(--md-sys-color-error-container); color: var(--md-sys-color-on-error-container); }
.chip[data-status="pending"], .chip[data-status="processing"] { background: var(--md-sys-color-tertiary-container); color: var(--md-sys-color-on-tertiary-container); }
.chip[data-status="draft"], .chip[data-status="cancelled"] { background: var(--md-sys-color-surface-container-highest); color: var(--md-sys-color-on-surface-variant); }

/* ---------------- теги разделов медиатеки ---------------- */
.tagchips { display: inline-flex; flex-wrap: wrap; gap: 4px; margin: 4px 0; }
.tagchip {
    display: inline-flex; align-items: center;
    padding: 2px 8px;
    border-radius: 999px;
    background: var(--md-sys-color-secondary-container);
    color: var(--md-sys-color-on-secondary-container);
    font-size: var(--md-sys-typescale-label-small-size);
    font-weight: var(--md-ref-weight-medium);
}

/* ---------------- списки / строки ---------------- */
.row-list { display: flex; flex-direction: column; gap: 16px; }
.row {
    display: flex; align-items: center; justify-content: space-between; gap: 16px;
    padding: 16px 20px;
    background: var(--md-sys-color-surface-container);
    border-radius: var(--md-sys-shape-corner-large);
    box-shadow: var(--md-elevation-1);
    cursor: pointer;
    transition: background-color .15s var(--md-ease-standard);
}
.row:hover { background: var(--md-sys-color-surface-container-high); }
.row .row-title { font-size: var(--md-sys-typescale-title-large-size); font-weight: var(--md-ref-weight-medium); color: var(--md-sys-color-on-surface); }
.row .row-sub { margin-top: 4px; color: var(--md-sys-color-on-surface-variant); font-size: var(--md-sys-typescale-label-medium-size); }

table.tbl { width: 100%; border-collapse: collapse; font-size: var(--md-sys-typescale-label-large-size); }
.tbl th, .tbl td { padding: 10px 14px; text-align: left; }
.tbl th { color: var(--md-sys-color-on-surface-variant); font-weight: var(--md-ref-weight-medium); background: var(--md-sys-color-surface-container-high); }
.tbl tr:nth-child(even) td { background: var(--md-sys-color-surface-container-low); }
.tbl td { color: var(--md-sys-color-on-surface); }

/* ---------------- прогресс ---------------- */
.progress {
    height: 6px;
    border-radius: var(--md-sys-shape-corner-extra-small);
    background: var(--md-sys-color-surface-container-highest);
    overflow: hidden;
}
.progress > i { display: block; height: 100%; width: 0%; background: var(--md-sys-color-primary); transition: width .4s; }

/* ---------------- пусто ---------------- */
.empty-state {
    padding: 32px;
    text-align: left;
    color: var(--md-sys-color-on-surface-variant);
    background: var(--md-sys-color-surface-container);
    border-radius: var(--md-sys-shape-corner-medium);
    border: none;
    font-size: var(--md-sys-typescale-label-large-size);
}

/* ---------------- медиа ---------------- */
.media-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(204px, 1fr)); gap: 16px; }
.media-card {
    position: relative;
    background: var(--md-sys-color-surface-container);
    border-radius: var(--md-sys-shape-corner-large);
    box-shadow: var(--md-elevation-1);
    overflow: hidden;
}
.media-card img, .media-card video { width: 100%; aspect-ratio: 16/10; object-fit: contain; background: var(--md-sys-color-surface-container-low); display: block; }
.media-card .mc-body { padding: 10px 12px; font-size: var(--md-sys-typescale-label-medium-size); color: var(--md-sys-color-on-surface); }
.media-card .mc-body b { display: block; font-size: var(--md-sys-typescale-label-large-size); }

/* Галерея выбора материалов в пакетах */
.g-item {
    background: var(--md-sys-color-surface-container);
    border: 2px solid transparent;
    border-radius: var(--md-sys-shape-corner-large);
    overflow: hidden;
    cursor: pointer;
    transition: border-color .15s var(--md-ease-standard);
}
.g-item:hover { border-color: var(--md-sys-color-primary); }
.g-item.g-sel { border-color: var(--md-sys-color-primary); }
.g-item img, .g-item video { width: 100%; aspect-ratio: 16/10; object-fit: contain; background: #000; display: block; }
.g-item .g-name {
    padding: 4px 6px;
    font-size: var(--md-sys-typescale-label-medium-size);
    color: var(--md-sys-color-on-surface-variant);
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

/* ссылка «Сбросить» в карточках выбора */
a.pick-clear {
    color: var(--md-sys-color-on-surface-variant);
    text-decoration: underline;
    cursor: pointer;
    line-height: 1;
}
a.pick-clear:hover { color: var(--md-sys-color-primary); }
.preview-img, .preview-video { max-width: 100%; border-radius: var(--md-sys-shape-corner-large); box-shadow: var(--md-elevation-1); }
.picker-preview { max-width: 300px; max-height: 220px; object-fit: contain; background: #000; }

/* ---------------- угловые иконки карточек ---------------- */
.card-act {
    position: absolute;
    width: 26px; height: 26px;
    display: inline-flex; align-items: center; justify-content: center;
    border: none; background: none; padding: 0;
    color: var(--md-sys-color-on-surface-variant);
    cursor: pointer;
    opacity: .8;
    transition: opacity .15s var(--md-ease-standard), color .15s var(--md-ease-standard);
}
.card-act:hover { opacity: 1; }
.card-act.danger:hover { color: var(--md-sys-color-error); }
.card-act.top-left { left: 6px; top: 6px; }
.card-act.top-right { right: 6px; top: 6px; }

/* ---------------- теги медиатеки ---------------- */
.pm-tags-row { margin-top: 18px; margin-bottom: 26px; display: flex; flex-wrap: wrap; gap: 8px; }
.tpl-kind {
    display: inline-flex; align-items: center;
    padding: 0 7px;
    border-radius: 999px;
    background: var(--md-sys-color-secondary-container);
    color: var(--md-sys-color-on-secondary-container);
    font-size: var(--md-sys-typescale-label-small-size);
    font-weight: var(--md-ref-weight-medium);
    margin-right: 6px;
}
.utagchip {
    display: inline-flex; align-items: center;
    padding: 2px 9px;
    border-radius: 999px;
    background: var(--md-sys-color-secondary-container);
    color: var(--md-sys-color-on-secondary-container);
    font-size: var(--md-sys-typescale-label-small-size);
    margin: 2px 0;
}
.utagchip .et-x {
    border: none; background: none; cursor: pointer;
    color: var(--md-sys-color-on-secondary-container);
    padding: 0 3px; font-size: 12px; line-height: 1;
}
.utag-chip {
    display: inline-flex; align-items: center;
    padding: 6px 12px;
    border-radius: 999px;
    border: none;
    background: var(--md-sys-color-surface-container-highest);
    color: var(--md-sys-color-on-surface-variant);
    font-size: var(--md-sys-typescale-label-medium-size);
    cursor: pointer;
    transition: background-color .15s var(--md-ease-standard);
}
.utag-chip:hover { background: var(--md-sys-color-surface-container); }
.utag-chip.active {
    background: var(--md-sys-color-primary-container);
    color: var(--md-sys-color-on-primary-container);
}
.utag-chip .u-count {
    display: inline-flex; align-items: center; justify-content: center;
    min-width: 18px; height: 18px; margin-left: 6px;
    border-radius: 999px;
    font-size: var(--md-sys-typescale-label-small-size);
    background: var(--md-sys-color-surface-container-high);
    color: var(--md-sys-color-on-surface-variant);
}
.utag-chip.active .u-count { background: var(--md-sys-color-primary); color: var(--md-sys-color-on-primary); }

/* ---------------- экран входа ---------------- */
body.login-mode .sidebar { display: none; }
body.login-mode .help-toggle { display: none; }
body.login-mode #view { padding: 0; }

.login-screen {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 28px;
    background:
        radial-gradient(circle at 15% 20%, var(--md-sys-color-primary-container) 0%, transparent 45%),
        radial-gradient(circle at 85% 30%, var(--md-sys-color-tertiary-container) 0%, transparent 40%),
        radial-gradient(circle at 50% 90%, var(--md-sys-color-secondary-container) 0%, transparent 45%),
        var(--md-sys-color-surface);
    padding: 24px;
}
.login-logo {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    color: var(--md-sys-color-primary);
}
.login-logo .brand-icon { width: 52px; height: 52px; }
.login-logo-name {
    font-size: 30px;
    font-weight: var(--md-ref-weight-medium);
    color: var(--md-sys-color-primary);
    letter-spacing: .2px;
}
.login-card {
    width: 100%;
    max-width: 380px;
    background: var(--md-sys-color-surface-container-high);
    border-radius: var(--md-sys-shape-corner-extra-large);
    box-shadow: var(--md-elevation-3);
    padding: 28px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}
.login-card .field { margin-bottom: 0; }
.login-card .field label { font-size: var(--md-sys-typescale-label-large-size); }
.login-card .input {
    background: var(--md-sys-color-surface-container-highest);
    color: var(--md-sys-color-on-surface);
}
html[data-theme="dark"] .login-card .input { color-scheme: dark; }
html[data-theme="light"] .login-card .input { color-scheme: light; }
.login-btn {
    width: 100%;
    margin: 0;
}
.login-theme {
    position: fixed;
    right: 18px;
    bottom: 18px;
    width: 44px;
    height: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: var(--md-sys-color-surface-container-high);
    color: var(--md-sys-color-on-surface);
    border: none;
    cursor: pointer;
    box-shadow: var(--md-elevation-2);
    z-index: 230;
    transition: background-color .15s var(--md-ease-standard), color .15s var(--md-ease-standard);
}
.login-theme:hover { background: var(--md-sys-color-primary-container); color: var(--md-sys-color-on-primary-container); }
.login-theme .ico-sun { display: none; }
html[data-theme="dark"] .login-theme .ico-sun { display: block; }
html[data-theme="dark"] .login-theme .ico-moon { display: none; }

/* ---------------- dialog / snackbar ---------------- */
.dialog {
    border: none;
    border-radius: var(--md-sys-shape-corner-medium);
    background: var(--md-sys-color-surface-container-high);
    box-shadow: var(--md-elevation-3);
padding: 24px;
    min-width: 380px;
    max-width: 96vw;
}
.dialog::backdrop { background: rgba(0,0,0,.4); }
.dialog-close {
    position: absolute; top: 8px; right: 8px;
    width: 32px; height: 32px;
    display: inline-flex; align-items: center; justify-content: center;
    border: none; background: none; padding: 0;
    color: var(--md-sys-color-on-surface-variant);
    cursor: pointer;
    border-radius: 50%;
    z-index: 10;
    transition: color .15s var(--md-ease-standard), background-color .15s var(--md-ease-standard);
}
.dialog-close:hover { color: var(--md-sys-color-error); background: var(--md-sys-color-error-container); }

/* ---------------- настройка 2FA ---------------- */
.mfa-setup .mono { font-family: ui-monospace, SFMono-Regular, Consolas, "Courier New", monospace; }
.mfa-qr { display: flex; justify-content: center; padding: 8px 0; }
.mfa-qr img {
    width: 200px; height: 200px;
    image-rendering: pixelated;
    border: 1px solid var(--md-sys-color-outline-variant);
    border-radius: var(--md-sys-shape-corner-medium);
    background: #fff;
}
.mfa-recovery {
    display: flex; flex-wrap: wrap; gap: 8px;
    margin-top: 8px; padding: 12px;
    background: var(--md-sys-color-surface-container-low);
    border-radius: var(--md-sys-shape-corner-medium);
}
.mfa-recovery code {
    padding: 4px 8px;
    background: var(--md-sys-color-surface-container-high);
    border-radius: var(--md-sys-shape-corner-small);
    font-family: ui-monospace, SFMono-Regular, Consolas, "Courier New", monospace;
    font-size: var(--md-sys-typescale-label-large-size);
}


/* ---------------- выделение выбранного в окне выбора ---------------- */
.sel-badge {
    position: absolute; top: 6px; right: 6px;
    width: 26px; height: 26px;
    display: inline-flex; align-items: center; justify-content: center;
    border-radius: 50%;
    background: var(--md-sys-color-primary);
    color: var(--md-sys-color-on-primary);
    font-size: 15px; font-weight: 700; line-height: 1;
    box-shadow: var(--md-elevation-2);
    z-index: 3;
}

/* ---------------- оверлей ожидания (прогресс) ---------------- */
.app-overlay {
    position: fixed; inset: 0; z-index: 300;
    background: rgba(0,0,0,.45);
    display: flex; align-items: center; justify-content: center;
}
.app-overlay-box {
    background: var(--md-sys-color-surface-container-high);
    border-radius: var(--md-sys-shape-corner-large);
    box-shadow: var(--md-elevation-3);
    padding: 24px 32px;
    min-width: 360px;
}
.app-overlay-title {
    font-size: var(--md-sys-typescale-title-medium-size);
    font-weight: var(--md-ref-weight-medium);
    color: var(--md-sys-color-on-surface);
}
.pbox { position: relative; height: 6px; border-radius: 4px; background: var(--md-sys-color-surface-container-highest); overflow: hidden; margin-top: 16px; }
.pbar-fill {
    position: absolute; left: 0; top: 0; height: 100%; width: 0%;
    background: var(--md-sys-color-primary);
    transition: width .3s ease;
}
.pbar-indet {
    position: absolute; left: 0; top: 0; height: 100%; width: 22%;
    background: var(--md-sys-color-primary-container);
    animation: pbarMove 1.6s linear infinite;
}
@keyframes pbarMove { 0% { transform: translateX(-40%); } 100% { transform: translateX(560%); } }

/* ---------------- лайтбокс (просмотр крупно) ---------------- */
.app-lightbox {
    position: fixed; inset: 0; z-index: 400;
    background: rgba(0,0,0,.82);
    display: flex; align-items: center; justify-content: center;
}
.app-lightbox .lb-close {
    position: absolute; top: 16px; right: 20px;
    width: 40px; height: 40px;
    display: inline-flex; align-items: center; justify-content: center;
    background: rgba(0,0,0,.55);
    border: none; border-radius: 50%;
    color: #fff; cursor: pointer;
}
.app-lightbox .lb-close:hover { background: rgba(255,255,255,.15); }
.app-lightbox img, .app-lightbox video { max-width: 94vw; max-height: 90vh; object-fit: contain; }

/* ---------------- модалка готового видео ---------------- */
.result-modal {
    background: var(--md-sys-color-surface-container-high);
    border-radius: var(--md-sys-shape-corner-large);
    box-shadow: var(--md-elevation-3);
    padding: 20px 28px;
    max-width: min(94vw, 900px);
    max-height: 92vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 14px;
    overflow: auto;
}
.result-modal video {
    display: block;
    width: auto;
    height: auto;
    max-width: min(88vw, 900px);
    max-height: 62vh;
    object-fit: contain;
    background: #000;
    border-radius: var(--md-sys-shape-corner-medium);
}
.result-modal .rm-actions { display: flex; gap: 16px; align-items: center; flex-wrap: wrap; }

/* ---------------- субтитры ---------------- */
.subs-list { display: flex; flex-direction: column; gap: 6px; max-height: 220px; overflow: auto; }
.sub-item { display: flex; gap: 10px; align-items: baseline; padding: 6px 10px; border-radius: var(--md-sys-shape-corner-small); background: var(--md-sys-color-surface-container); font-size: var(--md-sys-typescale-label-large-size); }
.sub-t { flex: 0 0 auto; white-space: nowrap; color: var(--md-sys-color-on-surface-variant); font-family: var(--md-ref-typeface-mono, monospace); }
.sub-text { word-break: break-word; }

/* ---------------- ссылка скачивания ---------------- */
.download-link {
    color: var(--md-sys-color-primary);
    font-size: var(--md-sys-typescale-label-medium-size);
    text-decoration: none;
}
.download-link:hover { text-decoration: underline; }

/* ---------------- правая панель подсказки ---------------- */
.help-toggle {
    position: fixed; right: 21px; top: 21px;
    width: 40px; height: 40px;
    border-radius: 50%;
    background: var(--md-sys-color-primary-container);
    color: var(--md-sys-color-on-primary-container);
    border: none; cursor: pointer;
    font-size: 18px; font-weight: 700;
    box-shadow: var(--md-elevation-2);
    z-index: 230;
    transition: background-color .15s var(--md-ease-standard);
}
.help-toggle:hover { background: var(--md-sys-color-primary); }
.help-toggle[hidden] { display: none; }
.help-panel {
    position: fixed; top: 0; right: 0; height: 100%;
    width: 340px; max-width: calc(100% - 48px);
    background: var(--md-sys-color-surface-container-high);
    box-shadow: var(--md-elevation-3);
    transform: translateX(105%);
    transition: transform .22s var(--md-ease-standard);
    display: flex; flex-direction: column;
    z-index: 250;
}
.help-panel[data-open="1"] { transform: translateX(0); }
.help-head {
    display: flex; align-items: center; justify-content: space-between;
    padding: 14px 16px;
    background: var(--md-sys-color-surface-container);
}
.help-title { font-weight: var(--md-ref-weight-medium); color: var(--md-sys-color-on-surface); }
.help-close {
    width: 32px; height: 32px;
    display: inline-flex; align-items: center; justify-content: center;
    border: none; background: none; cursor: pointer;
    color: var(--md-sys-color-on-surface-variant);
    border-radius: 50%;
}
.help-close:hover { color: var(--md-sys-color-error); }
.help-content { flex: 1; overflow: auto; padding: 18px 16px; }
.help-section { margin: 4px 0 16px; }
.help-h { font-weight: var(--md-ref-weight-medium); color: var(--md-sys-color-primary); margin-bottom: 6px; }
.help-line { font-size: var(--md-sys-typescale-label-large-size); color: var(--md-sys-color-on-surface-variant); line-height: 1.45; }

/* ---------------- редактор видео ---------------- */
.v-range { width: 100%; accent-color: var(--md-sys-color-primary); }
.trim-timeline {
    position: relative;
    height: 132px;
    user-select: none;
    cursor: pointer;
    border-radius: 8px;
    background: var(--md-sys-color-surface-container-high);
    overflow: hidden;
}
.trim-timeline canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.trim-zone { position: absolute; top: 0; bottom: 0; background: rgba(0,0,0,.38); pointer-events: none; }
.trim-frame {
    position: absolute; top: 0; bottom: 0;
    border-left: 2px solid var(--md-sys-color-primary);
    border-right: 2px solid var(--md-sys-color-primary);
    background: rgba(0,0,0,.18);
    pointer-events: none;
}
.trim-playhead { position: absolute; top: 0; bottom: 0; width: 2px; background: var(--md-sys-color-error); opacity: .9; pointer-events: none; }
.trim-handle {
    position: absolute; top: 0; bottom: 0;
    width: 16px; margin-left: -8px;
    cursor: ew-resize;
    background: var(--md-sys-color-primary);
    opacity: .9;
    pointer-events: none;
}
/* ---------------- раскладка «Видео»: слева плеер, справа авто ---------------- */
.v-split { display: flex; gap: 16px; align-items: flex-start; }
.v-split-left { flex: 1; min-width: 0; }
.v-split-right { width: 260px; flex-shrink: 0; }

/* панель управления плеером */
.v-compare { display: flex; gap: 12px; align-items: flex-start; }
.v-compare .v-compare-pane { flex: 1; min-width: 0; }
.v-pctrl { display: flex; align-items: center; gap: 10px; margin-top: 12px; }
.v-player-play {
    width: 40px; height: 40px; flex: 0 0 auto;
    border-radius: 50%;
    display: inline-flex; align-items: center; justify-content: center;
    background: var(--md-sys-color-primary);
    color: var(--md-sys-color-on-primary);
    border: none; cursor: pointer;
    font-size: 16px; padding: 0;
    box-shadow: var(--md-elevation-1);
    transition: background-color .15s var(--md-ease-standard);
}
.v-player-play:hover { background: var(--md-sys-color-primary-container); }
.vp-vol { display: inline-flex; align-items: center; gap: 6px; color: var(--md-sys-color-on-surface-variant); }
.vp-vol input { min-width: 60px; }

/* оверлей кадрирования на плеере */
/* оверлей/зум кадрирования на плеере */
.v-player-box {
    position: relative;
    overflow: hidden;
    text-align: center;
    width: 100%;
    max-height: 340px;
    aspect-ratio: 16 / 9;
    background: var(--md-sys-color-surface-container-low);
    border-radius: var(--md-sys-shape-corner-large);
}

/* предпросмотр кадра (canvas) для кропа — окно как у исходного видео */
.cr-canvas-wrap {
    position: relative;
    display: block;
    width: 100%;
    max-width: 100%;
    max-height: 340px;
    aspect-ratio: 16 / 9;
    border-radius: var(--md-sys-shape-corner-large);
    overflow: hidden;
    background: var(--md-sys-color-surface-container-low);
    min-width: 200px;
    min-height: 120px;
}.cr-canvas-wrap canvas { display: block; width: 100%; height: 100%; cursor: move; }
.cr-canvas-wrap .cr-ph {
    position: absolute; inset: 0;
    display: flex; align-items: center; justify-content: center;
    color: var(--md-sys-color-on-surface-variant);
    font-size: var(--md-sys-typescale-label-large-size);
    pointer-events: none;
}
/* пустое место вместо панели управления плеером — чтобы раскладка совпадала с исходным видео */
.v-pctrl-spacer {
    height: 40px;
    min-height: 40px;
    box-sizing: border-box;
    margin-top: 12px;
}
.v-player-box .crop-shade {
    position: absolute;
    background: rgba(0,0,0,.55);
    pointer-events: none;
    display: none;
}
.v-player-box .crop-window {
    position: absolute;
    border: 2px solid var(--md-sys-color-primary);
    pointer-events: none;
    display: none;
}
/* видео заполняет окно (contain), не растягиваясь */
.v-player-box video { display: block; width: 100%; height: 100%; object-fit: contain; background: transparent; }

/* в тёмной теме окна видео остаются чёрными, в светлой — светлыми */
html[data-theme="dark"] .v-player-box video,
html[data-theme="dark"] .cr-canvas-wrap { background: #000; }

/* ---------------- свёртываемые панели ручных настроек ---------------- */
.v-collapse > summary {
    list-style: none;
    cursor: pointer;
    user-select: none;
    padding: 14px 16px;
    font-size: var(--md-sys-typescale-title-medium-size);
    font-weight: var(--md-ref-weight-medium);
    color: var(--md-sys-color-on-surface);
    display: flex; align-items: center; gap: 8px;
}
.v-collapse > summary::-webkit-details-marker { display: none; }
.v-collapse > summary::after { content: '▾'; margin-left: auto; opacity: .7; }
.v-collapse:not([open]) > summary::after { content: '▸'; }
.v-collapse > summary:hover { color: var(--md-sys-color-primary); }
.v-collapse .v-collapse-body { padding: 6px 16px 16px; }
.snackbar {
    position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%);
    background: var(--md-sys-color-inverse-surface);
    color: var(--md-sys-color-inverse-on-surface);
    padding: 12px 20px;
    border-radius: var(--md-sys-shape-corner-full);
    font-size: var(--md-sys-typescale-label-large-size);
    box-shadow: var(--md-elevation-3);
    opacity: 0; pointer-events: none; transition: opacity .25s; z-index: 50;
    display: flex; align-items: center; gap: 10px; max-width: 80vw;
}
.snackbar.show { opacity: 1; pointer-events: auto; }

/* ошибки не исчезают сами — закрываются крестиком */
.snackbar .snack-close {
    flex: 0 0 auto; width: 26px; height: 26px;
    border: none; background: rgba(255,255,255,.12); border-radius: 50%;
    cursor: pointer; font-size: 14px; line-height: 1;
    color: var(--md-sys-color-inverse-on-surface);
    transition: background-color .15s var(--md-ease-standard);
}
.snackbar .snack-close:hover { background: rgba(255,255,255,.22); }

/* ---------------- вкладки настроек ---------------- */
.settings-tabs .btn-text.active { background: var(--md-sys-color-primary-container); color: var(--md-sys-color-on-primary-container); }

/* ---------------- M3 Segmented Buttons (без линий — фоном) ---------------- */
.segmented {
    display: inline-flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 2px;
    padding: 2px;
    border: none;
    border-radius: var(--md-sys-shape-corner-small);
    background: var(--md-sys-color-surface-container-high);
    width: fit-content;
}
.segmented-item {
    flex: 0 0 auto;
    background: transparent;
    color: var(--md-sys-color-on-surface);
    border: none;
    padding: 8px 18px;
    border-radius: var(--md-sys-shape-corner-small);
    font-size: var(--md-sys-typescale-label-large-size);
    font-weight: var(--md-ref-weight-medium);
    cursor: pointer;
    transition: background-color .15s var(--md-ease-standard), color .15s var(--md-ease-standard);
}
.segmented-item:hover { background: var(--md-sys-color-surface-container); }
.segmented-item.selected {
    background: var(--md-sys-color-secondary-container);
    color: var(--md-sys-color-on-secondary-container);
}

/* ---------------- выбор формата (карточки с силуэтом кадра) ---------------- */
.ratio-group { display: flex; flex-wrap: wrap; gap: 8px; }
.ratio-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 7px;
    min-width: 64px;
    padding: 8px 12px 10px;
    border: none;
    border-radius: var(--md-sys-shape-corner-medium);
    background: var(--md-sys-color-surface-container-high);
    color: var(--md-sys-color-on-surface);
    cursor: pointer;
    transition: background-color .15s var(--md-ease-standard), color .15s var(--md-ease-standard), box-shadow .15s var(--md-ease-standard);
}
.ratio-btn:hover { background: var(--md-sys-color-surface-container); }
.ratio-btn.selected {
    background: var(--md-sys-color-secondary-container);
    color: var(--md-sys-color-on-secondary-container);
    box-shadow: var(--md-elevation-1);
}
.ratio-screen {
    height: 28px;
    aspect-ratio: var(--ar, 16 / 9);
    border: 2px solid currentColor;
    border-radius: 4px;
    opacity: .55;
    transition: opacity .15s, transform .15s var(--md-ease-standard);
}
.ratio-btn.selected .ratio-screen {
    opacity: 1;
    transform: scale(1.12);
    background: currentColor;
}
.ratio-txt {
    font-size: var(--md-sys-typescale-label-large-size);
    font-weight: var(--md-ref-weight-medium);
    line-height: 1;
}

/* ---------------- выбор акцента ---------------- */
.accent-row { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; }
.accent-swatch {
    width: 40px; height: 40px;
    position: relative;
    border-radius: var(--md-sys-shape-corner-full);
    border: none;
    cursor: pointer;
    transition: transform .15s var(--md-ease-standard);
}
.accent-swatch:hover { transform: scale(1.08); }
.accent-swatch.active { transform: scale(1.15); }
.accent-swatch.active::before {
    content: "";
    position: absolute;
    top: 50%; left: 50%;
    width: 14px; height: 14px;
    transform: translate(-50%, -50%);
    border-radius: 50%;
    background: var(--md-sys-color-on-primary);
    border: none;
}

/* ---------------- выбор цвета субтитров ---------------- */
.sub-color-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.sub-color-swatch {
    width: 30px; height: 30px;
    position: relative;
    border-radius: 50%;
    border: 2px solid transparent;
    cursor: pointer;
    padding: 0;
    flex: none;
    transition: transform .15s var(--md-ease-standard), border-color .15s;
    box-shadow: 0 1px 3px rgba(0,0,0,.35);
}
.sub-color-swatch:hover { transform: scale(1.12); }
.sub-color-swatch.active { border-color: var(--md-sys-color-on-surface); }
.sub-color-swatch.active::after {
    content: "";
    position: absolute;
    inset: 4px;
    border-radius: 50%;
    box-shadow: inset 0 0 0 2px rgba(255,255,255,.65);
}
.sub-color-custom {
    width: 34px; height: 34px;
    border-radius: 50%;
    cursor: pointer;
    flex: none;
    display: inline-flex; align-items: center; justify-content: center;
    font-size: 15px; font-weight: 600;
    color: var(--md-sys-color-on-surface);
    background: conic-gradient(#f00,#ff8000,#ffe600,#0e0,#00e6ff,#0080ff,#8000ff,#f0f,#f00);
    border: 2px solid var(--md-sys-color-on-surface);
    padding: 0;
    transition: transform .15s var(--md-ease-standard);
}
.sub-color-custom:hover { transform: scale(1.12); }
.sub-color-picker {
    position: fixed;
    z-index: 100;
    background: var(--md-sys-color-surface-container-high);
    border-radius: var(--md-sys-shape-corner-large);
    box-shadow: var(--md-elevation-3);
    padding: 14px;
    width: 250px;
    display: none;
}
.sub-color-picker.open { display: block; }
.sub-color-picker canvas {
    width: 100%; height: 150px;
    border-radius: var(--md-sys-shape-corner-medium);
    cursor: crosshair;
    touch-action: none;
    display: block;
}
.sub-color-picker-row { display: flex; gap: 8px; align-items: center; margin-top: 10px; }
.sub-color-picker-row input[type="text"] {
    flex: 1;
    font-family: var(--md-ref-typeface-mono, monospace);
    text-transform: uppercase;
}
.sub-color-picker-prev {
    width: 28px; height: 28px;
    border-radius: 50%;
    border: 2px solid rgba(0,0,0,.2);
    flex: none;
}
.sub-color-picker-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 10px; }

/* ---------------- адаптив ---------------- */
@media (max-width: 900px) {
    .view { padding: 16px 20px; }
}
@media (max-width: 600px) { .sidebar { display: none; } }

@media (prefers-reduced-motion: reduce) {
    .btn-filled, .btn-text, .btn-danger, .icon-btn { transition: none; }
    .progress > i { transition: none; }
}

/* ---------------- утилиты ---------------- */
.flex { display: flex; gap: 16px; align-items: center; }
.spacer { flex: 1; }
.muted { color: var(--md-sys-color-on-surface-variant); }
.mt-12 { margin-top: 16px; } .mt-20 { margin-top: 32px; }
.small { font-size: var(--md-sys-typescale-label-medium-size); }
.mono { font-family: var(--md-ref-typeface-plain); letter-spacing: 0; }