* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body { margin: 0; background: var(--color-background); color: var(--color-text); font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", sans-serif; -webkit-font-smoothing: antialiased; }
h1, h2, h3, p { margin-top: 0; }
button { font: inherit; }
[hidden] { display: none !important; }
code { background: var(--color-surface-strong); border-radius: 5px; font-size: 0.9em; padding: 1px 5px; }

/* ─── Шапка ─────────────────────────────────────────────────────────── */
.site-header { backdrop-filter: saturate(180%) blur(20px); -webkit-backdrop-filter: saturate(180%) blur(20px); background: var(--color-toolbar); border-bottom: 1px solid var(--color-border); position: sticky; top: 0; z-index: 20; }
.site-header-inner { align-items: center; display: flex; height: 52px; justify-content: space-between; margin: 0 auto; max-width: 880px; padding: 0 24px; }
.brand { align-items: baseline; color: var(--color-text); display: flex; font-size: 17px; gap: 5px; letter-spacing: -0.01em; text-decoration: none; }
.brand-mark { color: var(--color-accent); font-family: ui-rounded, "SF Pro Rounded", -apple-system, BlinkMacSystemFont, sans-serif; font-size: 19px; font-weight: 700; letter-spacing: -0.02em; }
.brand-rest { color: var(--color-text-secondary); font-weight: 400; }
.header-actions { align-items: center; display: flex; gap: 8px; }
.segmented { background: var(--color-surface-strong); border-radius: 8px; display: inline-flex; gap: 2px; margin-right: 4px; padding: 2px; }
.segmented button { background: transparent; border: 0; border-radius: 6px; color: var(--color-text-secondary); cursor: pointer; font-size: 12px; font-weight: 600; letter-spacing: .02em; padding: 4px 9px; transition: background .15s ease, color .15s ease; }
.segmented button:hover { color: var(--color-text); }
.segmented button[aria-pressed="true"] { background: var(--color-segment-active); box-shadow: 0 1px 2px var(--color-segment-shadow); color: var(--color-text); }
.profile { align-items: center; background: var(--color-surface); border-radius: 980px; display: inline-flex; flex-shrink: 0; gap: 9px; padding: 3px; }
.avatar { align-items: center; background: var(--color-accent); border-radius: 50%; color: var(--color-on-accent); display: inline-flex; flex-shrink: 0; font-size: 13px; font-weight: 600; height: 30px; justify-content: center; overflow: hidden; width: 30px; }
.avatar img { height: 100%; object-fit: cover; width: 100%; }
.profile-text { display: flex; flex-direction: column; line-height: 1.2; max-width: 200px; min-width: 0; }
.profile-name, .profile-meta { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.profile-name { color: var(--color-text); font-size: 13px; font-weight: 600; }
.profile-meta { align-items: center; color: var(--color-text-secondary); display: flex; font-size: 11px; gap: 5px; }
.status-dot { background: var(--color-success); border-radius: 50%; flex-shrink: 0; height: 6px; width: 6px; }

/* ─── Кнопки ────────────────────────────────────────────────────────── */
.button { align-items: center; border: 0; border-radius: 980px; cursor: pointer; display: inline-flex; font-size: 15px; font-weight: 500; gap: 8px; justify-content: center; padding: 10px 20px; text-decoration: none; transition: background .2s ease, transform .2s ease, opacity .2s ease; white-space: nowrap; }
.button:hover:not(:disabled) { transform: translateY(-1px); }
.button:disabled { cursor: default; opacity: .45; }
.button-primary { background: var(--color-accent); color: var(--color-on-accent); }
.button-primary:hover:not(:disabled) { background: var(--color-accent-hover); }
.button-plain { background: transparent; color: var(--color-accent); }
.button-small { font-size: 13px; padding: 6px 14px; }
.button-large { font-size: 17px; padding: 13px 28px; }
.text-button { background: none; border: 0; color: var(--color-accent); cursor: pointer; font-size: 14px; padding: 4px 6px; }
.text-button:hover { text-decoration: underline; }

/* ─── Баннер ошибок ─────────────────────────────────────────────────── */
.banner { align-items: flex-start; background: var(--color-surface); border: 1px solid var(--color-border); border-left: 3px solid var(--color-danger); border-radius: 12px; box-shadow: 0 10px 30px var(--color-shadow); display: flex; font-size: 14px; gap: 12px; left: 50%; line-height: 1.45; max-width: min(640px, calc(100% - 32px)); padding: 12px 14px 12px 16px; position: fixed; top: 64px; transform: translateX(-50%); width: max-content; z-index: 30; }
.banner.is-info { border-left-color: var(--color-accent); }
.banner.is-success { border-left-color: var(--color-success); }
.banner.is-warning { border-left-color: var(--color-warning); }
.banner-close { background: none; border: 0; color: var(--color-text-secondary); cursor: pointer; font-size: 18px; line-height: 1; padding: 0 2px; }

/* ─── Раскладка ─────────────────────────────────────────────────────── */
.app { margin: 0 auto; max-width: 880px; padding: 0 24px 64px; }
.hero { padding: 72px 0 40px; text-align: center; }
.hero h1 { font-size: clamp(36px, 6vw, 56px); letter-spacing: -0.045em; line-height: 1.05; margin-bottom: 14px; }
.hero-copy { color: var(--color-text-secondary); font-size: clamp(18px, 2.6vw, 22px); letter-spacing: -0.02em; line-height: 1.3; margin: 0 auto; max-width: 560px; }

.card { background: var(--color-surface); border: 1px solid var(--color-border); border-radius: 18px; margin-bottom: 16px; padding: 22px 24px 24px; }
.card-header { align-items: center; display: flex; gap: 12px; justify-content: space-between; margin-bottom: 16px; }
.card h2 { align-items: center; display: flex; flex-wrap: wrap; font-size: 19px; gap: 10px; letter-spacing: -0.02em; margin: 0; }
.step { align-items: center; background: var(--color-accent); border-radius: 50%; color: var(--color-on-accent); display: inline-flex; font-size: 12px; font-weight: 600; height: 22px; justify-content: center; width: 22px; }
.count, .hint { color: var(--color-text-secondary); font-size: 14px; font-weight: 400; }
.setup { border-left: 3px solid var(--color-warning); }
.setup h2 { margin-bottom: 8px; }
.setup p { color: var(--color-text-secondary); line-height: 1.5; margin: 0; }
.setup strong { color: var(--color-text); }

/* ─── Поля ──────────────────────────────────────────────────────────── */
.input { background: var(--color-input); border: 1px solid var(--color-border); border-radius: 10px; color: var(--color-text); font: inherit; font-size: 15px; outline: none; padding: 10px 12px; transition: border-color .15s ease, box-shadow .15s ease; width: 100%; }
.input:focus { border-color: var(--color-accent); box-shadow: 0 0 0 3px var(--color-selection); }
.textarea { line-height: 1.45; min-height: 140px; resize: vertical; }
.url-row { display: flex; gap: 10px; }
.url-field { flex: 1; min-width: 0; position: relative; }
.url-field .input:disabled { color: var(--color-text-secondary); cursor: default; opacity: 1; padding-right: 44px; }
.url-clear { align-items: center; animation: fade .2s ease both; background: var(--color-surface-strong); border: 0; border-radius: 50%; color: var(--color-text-secondary); cursor: pointer; display: inline-flex; font-size: 18px; height: 26px; justify-content: center; line-height: 1; padding: 0 0 2px; position: absolute; right: 8px; top: 50%; transform: translateY(-50%); transition: background .15s ease, color .15s ease; width: 26px; }
.url-clear:hover:not(:disabled) { background: var(--color-selection); color: var(--color-accent); }
.url-clear:disabled { cursor: default; opacity: .45; }
.field { display: block; margin-bottom: 14px; }
.field-label { color: var(--color-text-secondary); display: flex; font-size: 13px; font-weight: 500; justify-content: space-between; margin-bottom: 6px; }
.counter { font-variant-numeric: tabular-nums; font-weight: 400; }
.counter.is-full { color: var(--color-warning); }

.switch { align-items: center; cursor: pointer; display: inline-flex; font-size: 15px; gap: 10px; user-select: none; }
.switch input { height: 0; opacity: 0; position: absolute; width: 0; }
.switch-track { background: var(--color-surface-strong); border-radius: 980px; flex: none; height: 24px; position: relative; transition: background .2s ease; width: 40px; }
.switch-track::after { background: var(--color-knob); border-radius: 50%; box-shadow: 0 1px 3px var(--color-knob-shadow); content: ""; height: 20px; left: 2px; position: absolute; top: 2px; transition: transform .2s ease; width: 20px; }
.switch input:checked + .switch-track { background: var(--color-success); }
.switch input:checked + .switch-track::after { transform: translateX(16px); }
.switch input:focus-visible + .switch-track { box-shadow: 0 0 0 3px var(--color-selection); }

/* ─── Видео ─────────────────────────────────────────────────────────── */
.video { align-items: flex-start; display: flex; gap: 14px; margin-top: 16px; }
.video-thumb { aspect-ratio: 16 / 9; background: var(--color-surface-strong); border-radius: 8px; flex: none; object-fit: cover; width: 120px; }
.video-title { font-size: 15px; font-weight: 600; line-height: 1.35; }
.video-meta { color: var(--color-text-secondary); font-size: 13px; margin-top: 3px; }
.video-langs { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 8px; }
.video-lang { align-items: center; background: var(--color-surface-strong); border-radius: 980px; color: var(--color-text-secondary); cursor: default; display: inline-flex; font-size: 12px; gap: 4px; padding: 2px 8px; }

/* ─── Языки ─────────────────────────────────────────────────────────── */
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { align-items: center; background: var(--color-background); border: 1px solid var(--color-border); border-radius: 980px; color: var(--color-text-secondary); cursor: pointer; display: inline-flex; font-size: 13px; gap: 6px; padding: 6px 12px; transition: background .15s ease, color .15s ease, border-color .15s ease; user-select: none; }
.chip:hover { color: var(--color-text); }
.chip[aria-pressed="true"] { background: var(--color-selection); border-color: transparent; color: var(--color-accent); font-weight: 500; }
.chip-flag { font-size: 15px; line-height: 1; }

.actions { align-items: center; display: flex; flex-wrap: wrap; gap: 16px; margin-top: 22px; }
.engine-note { color: var(--color-text-secondary); font-size: 13px; }
.progress { align-items: center; display: flex; gap: 12px; margin-top: 16px; }
.progress-track { background: var(--color-surface-strong); border-radius: 980px; flex: 1; height: 6px; overflow: hidden; }
.progress-bar { background: var(--color-accent); border-radius: 980px; height: 100%; transition: width .3s ease; width: 0; }
.progress-text { color: var(--color-text-secondary); font-size: 13px; font-variant-numeric: tabular-nums; min-width: 64px; text-align: right; }

/* ─── Мои видео ─────────────────────────────────────────────────────── */
.my-videos { border-top: 1px solid var(--color-border); margin-top: 18px; padding-top: 16px; }
.my-videos-header { align-items: center; background: none; border: 0; border-radius: 8px; color: var(--color-text); cursor: pointer; display: flex; font: inherit; gap: 10px; justify-content: space-between; margin: -6px -8px; padding: 6px 8px; text-align: left; width: calc(100% + 16px); }
.my-videos-header:hover { background: var(--color-selection); }
.my-videos-title { align-items: center; display: inline-flex; font-size: 15px; font-weight: 600; gap: 8px; }
.chevron { border-bottom: 2px solid var(--color-text-secondary); border-right: 2px solid var(--color-text-secondary); height: 7px; transform: rotate(-45deg); transition: transform .2s ease; width: 7px; }
.my-videos-header[aria-expanded="true"] .chevron { transform: rotate(45deg) translate(-2px, -2px); }
/* Плавно раскрывается по высоте: 0fr → 1fr. */
.my-videos-body { display: grid; grid-template-rows: 0fr; opacity: 0; transition: grid-template-rows .35s cubic-bezier(.2, .8, .2, 1), opacity .25s ease; }
.my-videos-body.is-open { grid-template-rows: 1fr; opacity: 1; }
.my-videos-inner { min-height: 0; overflow: hidden; }
.my-videos-inner::before { content: ""; display: block; height: 14px; }
.my-videos-grid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); }
.video-card { background: none; border: 0; border-radius: 12px; color: var(--color-text); cursor: pointer; display: flex; flex-direction: column; font: inherit; gap: 6px; padding: 6px; text-align: left; transition: background .15s ease; }
.video-card:hover:not(:disabled) { background: var(--color-selection); }
.video-card:disabled { cursor: default; opacity: .55; }
.video-card[aria-current="true"] { background: var(--color-selection); box-shadow: inset 0 0 0 2px var(--color-accent); }
.video-card-media { display: block; position: relative; }
.video-card-duration { background: rgba(0, 0, 0, .75); border-radius: 4px; bottom: 6px; color: #fff; font-size: 11px; font-weight: 500; line-height: 1; padding: 3px 5px; position: absolute; right: 6px; }
.video-card-duration.is-short { background: var(--color-danger); }
.video-card-thumb { aspect-ratio: 16 / 9; background: var(--color-surface-strong); border-radius: 8px; display: block; object-fit: cover; width: 100%; }
.video-card-title { -webkit-box-orient: vertical; -webkit-line-clamp: 2; display: -webkit-box; font-size: 13px; font-weight: 500; line-height: 1.35; overflow: hidden; }
.video-card-meta { color: var(--color-text-secondary); font-size: 11px; }
.video-card-badge { color: var(--color-warning); }
.my-videos-paging { display: flex; gap: 16px; justify-content: center; margin-top: 10px; }

/* ─── Результаты ────────────────────────────────────────────────────── */
.results-card { padding-bottom: 8px; }
.results { list-style: none; margin: 0 -12px; padding: 0; }
.result { border-radius: 12px; display: grid; gap: 4px 14px; grid-template-columns: 28px 1fr auto; padding: 12px; }
.result:hover { background: var(--color-selection); }
.result + .result { border-top: 1px solid var(--color-border); }
.result:hover, .result:hover + .result { border-top-color: transparent; }
.result-flag { font-size: 20px; grid-row: span 3; line-height: 1.2; }
.result-lang { color: var(--color-text-secondary); font-size: 12px; font-weight: 500; letter-spacing: .02em; text-transform: uppercase; }
.result-title { font-size: 15px; font-weight: 500; line-height: 1.35; }
.result-desc { color: var(--color-text-secondary); font-size: 13px; grid-column: 2; line-height: 1.45; white-space: pre-line; }
.result-engine { color: var(--color-text-secondary); font-size: 10px; grid-column: 2; letter-spacing: .02em; margin-top: 2px; opacity: .75; }
.result-copy { align-self: start; grid-column: 3; grid-row: 1 / span 2; }
.result.is-error .result-title { color: var(--color-danger); font-weight: 400; }

/* ─── Отправка ──────────────────────────────────────────────────────── */
.send-row { align-items: center; border-top: 1px solid var(--color-border); display: flex; gap: 16px; justify-content: space-between; margin: 8px 0 0; padding: 18px 0 10px; }
.send-row-text { color: var(--color-text-secondary); font-size: 14px; }

.site-footer { color: var(--color-text-secondary); font-size: 12px; margin: 0 auto; max-width: 880px; padding: 0 24px 40px; text-align: center; }

@media (max-width: 700px) {
  .site-header-inner, .app, .site-footer { padding-left: 16px; padding-right: 16px; }
  .brand-rest, .profile-text { display: none; }
  .hero { padding: 44px 0 28px; }
  .card { padding: 18px 16px 20px; }
  .url-row { flex-direction: column; }
  .my-videos-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .card-header { align-items: flex-start; flex-direction: column; gap: 6px; }
  .send-row { flex-direction: column; align-items: stretch; text-align: center; }
}

/* ─── Анимации ──────────────────────────────────────────────────────── */
/* Секции и блоки анимируются, когда показываются (снят [hidden]);
   элементы списков — только новые (класс .enter, см. dom.js). */
@keyframes rise { from { opacity: 0; transform: translateY(14px); } }
@keyframes pop { from { opacity: 0; transform: translateY(8px) scale(.97); } }
@keyframes fade { from { opacity: 0; } }
@keyframes banner-in { from { opacity: 0; transform: translate(-50%, -14px); } }

:root { --ease-out: cubic-bezier(.2, .8, .2, 1); }
.hero { animation: rise .6s var(--ease-out) both; }
.card { animation: rise .5s var(--ease-out) both; }
.app > .card:nth-of-type(2) { animation-delay: .08s; }
.video, .progress, .send-row, .profile, .results-card .card-header .button { animation: fade .35s ease both; }
.banner { animation: banner-in .35s var(--ease-out) both; }
.avatar img { animation: fade .3s ease both; }
.enter { animation: pop .4s var(--ease-out) both; animation-delay: calc(var(--i, 0) * 35ms); }
.video.enter { animation: pop .4s var(--ease-out) both; }

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation-delay: 0s !important; animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
