/* KWMS Aurora — web interface */

:root {
  --bg: #0b1018;
  --surface: #121a26;
  --card: #182230;
  --card-hover: #1d2a3b;
  --border: rgba(255, 255, 255, 0.08);
  --border-strong: rgba(255, 255, 255, 0.14);
  --accent: #756cff;
  --accent-light: #9c8cff;
  --cyan: #45c8ff;
  --brand-pink: #ef68ce;
  --brand-violet: #b75cff;
  --brand-indigo: #715cff;
  --brand-blue: #258dff;
  --brand-cyan: #35d5ff;
  --success: #45d6a0;
  --error: #f58a82;
  --text: #f2f5fa;
  --text-muted: #9aa6b8;
  --text-dim: #6f7c90;
  --shadow: 0 18px 48px rgba(0, 0, 0, 0.35);
  --radius: 18px;
  --radius-sm: 12px;
  --radius-xs: 10px;
  --space: 16px;
  --space-lg: 24px;
  --nav-h: 72px;
  --topbar-h: 64px;
  --sidebar-w: 260px;
  --content-max: 1120px;
  --focus: 0 0 0 3px rgba(117, 108, 255, 0.45);
  --font: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, Arial, sans-serif;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html {
  height: 100%;
  -webkit-text-size-adjust: 100%;
  text-rendering: optimizeLegibility;
}

body {
  margin: 0;
  min-height: 100%;
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.45;
  color: var(--text);
  background:
    radial-gradient(1200px 600px at 80% -10%, rgba(117, 108, 255, 0.18), transparent 60%),
    radial-gradient(900px 500px at -10% 20%, rgba(69, 200, 255, 0.1), transparent 55%),
    var(--bg);
  overflow-x: hidden;
  font-synthesis: none;
}

img {
  max-width: 100%;
  display: block;
}

button,
input {
  font: inherit;
  color: inherit;
}

button {
  cursor: pointer;
  border: none;
  background: none;
  -webkit-tap-highlight-color: transparent;
  -webkit-touch-callout: none;
  touch-action: manipulation;
}

button,
.action-card,
.nav-item,
.bottom-item,
.chip,
.method-tab,
.segment,
.radio-card,
.track-item label,
.file-picker-btn {
  -webkit-user-select: none;
  user-select: none;
}

input,
textarea {
  -webkit-user-select: text;
  user-select: text;
}

a {
  color: var(--accent-light);
}

:focus-visible {
  outline: none;
  box-shadow: var(--focus);
}

button:focus:not(:focus-visible),
[role="tab"]:focus:not(:focus-visible) {
  outline: none;
  box-shadow: none;
}

.skip-link {
  position: absolute;
  left: 12px;
  top: -48px;
  z-index: 1000;
  padding: 10px 14px;
  border-radius: var(--radius-xs);
  background: var(--accent);
  color: #fff;
  text-decoration: none;
}

.skip-link:focus {
  top: 12px;
}

.visually-hidden {
  position: absolute !important;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* Shell */

.app-shell {
  min-height: 100dvh;
  display: flex;
}

.sidebar {
  display: none;
  width: var(--sidebar-w);
  flex-shrink: 0;
  padding: 24px 16px;
  border-right: 1px solid var(--border);
  background: var(--surface);
  position: sticky;
  top: 0;
  height: 100dvh;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 28px;
  padding: 0 8px;
}

.brand-mark {
  border-radius: 12px;
}

.brand-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.brand-name {
  font-weight: 700;
  font-size: 1.05rem;
  letter-spacing: -0.02em;
}

/* The title follows the violet-to-cyan ribbon in the KWMS mark. */
.brand-name,
#page-title,
.hero-copy h1 {
  background: linear-gradient(
    100deg,
    var(--brand-pink) 0%,
    var(--brand-violet) 24%,
    var(--brand-indigo) 49%,
    var(--brand-blue) 76%,
    var(--brand-cyan) 100%
  );
  width: fit-content;
  max-width: 100%;
  background-size: 100% 100%;
  background-position: center;
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  -webkit-text-fill-color: transparent;
}

.brand-badge,
.prototype-pill {
  display: inline-flex;
  align-items: center;
  width: fit-content;
  padding: 3px 8px;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.01em;
  color: var(--cyan);
  background: rgba(69, 200, 255, 0.12);
  border: 1px solid rgba(69, 200, 255, 0.22);
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 48px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  text-align: left;
  transition: background 0.2s var(--ease), color 0.2s var(--ease), transform 0.15s var(--ease);
}

.nav-item img {
  flex-shrink: 0;
  opacity: 0.9;
}

.nav-item:hover {
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
}

.nav-item:active {
  transform: scale(0.98);
}

.nav-item.is-active {
  background: linear-gradient(135deg, rgba(117, 108, 255, 0.22), rgba(69, 200, 255, 0.08));
  color: var(--text);
  border: 1px solid rgba(117, 108, 255, 0.28);
}

.nav-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 20px;
  height: 20px;
  margin-left: auto;
  padding: 0 6px;
  border-radius: 999px;
  color: #fff;
  background: var(--accent);
  box-shadow: 0 0 0 2px var(--surface);
  font-size: 0.72rem;
  font-weight: 800;
  line-height: 1;
}

.nav-badge.is-ready {
  background: var(--success);
  color: #07150f;
}

.nav-badge.is-error {
  background: var(--error);
}

.sidebar-note {
  margin-top: auto;
  padding: 16px 8px 0;
  font-size: 0.8rem;
  color: var(--text-dim);
}

.content-column {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: var(--topbar-h);
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
}

.service-status {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 34px;
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--text-muted);
  background: rgba(255, 255, 255, 0.035);
  font-size: 0.76rem;
  font-weight: 700;
  white-space: nowrap;
}

.service-status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--success);
  box-shadow: 0 0 12px rgba(69, 214, 160, 0.55);
}

.service-status.has-update {
  color: var(--text);
  border-color: rgba(156, 140, 255, 0.3);
}

.service-status.has-update .service-status-dot {
  background: var(--accent-light);
  box-shadow: 0 0 12px rgba(156, 140, 255, 0.55);
}

.service-status.is-offline .service-status-dot {
  background: var(--error);
  box-shadow: 0 0 12px rgba(245, 138, 130, 0.45);
}

@media (max-width: 390px) {
  .service-status {
    padding-inline: 8px;
  }

  #service-status-text {
    max-width: 92px;
    overflow: hidden;
    text-overflow: ellipsis;
  }
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.topbar-logo {
  border-radius: 10px;
}

.topbar-left strong {
  display: block;
  font-size: 1rem;
  letter-spacing: -0.02em;
}

.topbar-left .prototype-pill {
  margin-top: 4px;
}

.topbar-left .prototype-pill,
.brand-badge {
  color: var(--text-muted);
  border-color: rgba(255, 255, 255, 0.1);
  background: rgba(255, 255, 255, 0.04);
}

.main {
  width: min(100%, var(--content-max));
  margin: 0 auto;
  padding: 16px 16px calc(var(--nav-h) + 28px);
}

.view.is-active {
  animation: view-in 0.28s var(--ease);
}

.reveal-card:not([hidden]) {
  animation: card-in 0.32s var(--ease);
}

@keyframes view-in {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

@keyframes card-in {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

/* Typography blocks */

.section-head {
  margin: 8px 0 18px;
}

.section-head h1,
.section-head h2 {
  margin: 0 0 6px;
  font-size: clamp(1.35rem, 4vw, 1.75rem);
  letter-spacing: -0.03em;
  line-height: 1.2;
}

.section-head p,
.field-hint,
.ready-lead,
.attention-desc {
  margin: 0;
  color: var(--text-muted);
}

/* Hero */

.hero {
  position: relative;
  overflow: hidden;
  border-radius: 24px;
  min-height: 280px;
  margin-bottom: 16px;
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
}

.hero-media {
  position: absolute;
  inset: 0;
}

.hero-media img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
}

.hero-scrim {
  position: absolute;
  inset: 0;
  background:
    linear-gradient(180deg, rgba(11, 16, 24, 0.35) 0%, rgba(11, 16, 24, 0.82) 70%, rgba(11, 16, 24, 0.96) 100%),
    linear-gradient(90deg, rgba(11, 16, 24, 0.55), transparent 55%);
}

.hero-copy {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  min-height: 280px;
  padding: 24px 20px 22px;
}

.hero-logo {
  border-radius: 16px;
  margin-bottom: 14px;
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.35);
}

.hero-copy h1 {
  margin: 0;
  font-size: clamp(2rem, 8vw, 2.8rem);
  letter-spacing: -0.04em;
  line-height: 1.05;
}

.hero-tagline {
  margin: 8px 0 0;
  font-size: 1.15rem;
  font-weight: 600;
  color: var(--accent-light);
}

.hero-lead {
  margin: 10px 0 0;
  max-width: 36ch;
  color: var(--text-muted);
}

/* Panels & forms */

.panel {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  margin-bottom: 16px;
}

.home-link-panel {
  background:
    linear-gradient(180deg, rgba(117, 108, 255, 0.08), transparent 48%),
    var(--card);
}

.field-label {
  display: block;
  margin-bottom: 10px;
  font-weight: 600;
  font-size: 0.95rem;
}

.field-hint {
  margin-top: 10px;
  font-size: 0.85rem;
}

.input {
  width: 100%;
  min-height: 52px;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text);
  transition: border-color 0.2s var(--ease), background 0.2s var(--ease);
}

.input::placeholder {
  color: var(--text-dim);
}

.input:hover {
  border-color: rgba(156, 140, 255, 0.35);
}

.input:focus {
  border-color: var(--accent-light);
  background: #101826;
  box-shadow: 0 0 0 3px rgba(117, 108, 255, 0.18);
}

.link-row {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.link-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

/* Buttons */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 48px;
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  font-weight: 650;
  letter-spacing: -0.01em;
  text-align: center;
  white-space: normal;
  transition: transform 0.15s var(--ease), background 0.2s var(--ease), border-color 0.2s var(--ease), opacity 0.2s var(--ease);
  border: 1px solid transparent;
}

.btn:active:not(:disabled) {
  transform: scale(0.98);
}

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.btn-primary {
  position: relative;
  overflow: hidden;
  background: linear-gradient(135deg, var(--accent) 0%, #5f74ff 100%);
  color: #fff;
  box-shadow: 0 10px 24px rgba(117, 108, 255, 0.28);
}

.btn-primary::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(110deg, transparent 30%, rgba(69, 200, 255, 0.22) 50%, transparent 70%);
  opacity: 0;
  transform: translateX(-40%);
  transition: opacity 0.25s var(--ease), transform 0.35s var(--ease);
  pointer-events: none;
}

@media (hover: hover) and (pointer: fine) {
  .btn-primary:hover:not(:disabled)::after {
    opacity: 1;
    transform: translateX(20%);
  }
}

.btn-secondary {
  background: rgba(255, 255, 255, 0.04);
  border-color: var(--border-strong);
  color: var(--text);
}

.btn-secondary:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.07);
}

.btn-ghost {
  background: transparent;
  border-color: var(--border);
  color: var(--text-muted);
}

.btn-ghost:hover:not(:disabled) {
  color: var(--text);
  background: rgba(255, 255, 255, 0.03);
}

.btn-block {
  width: 100%;
}

.btn-sm {
  min-height: 42px;
  padding: 8px 12px;
  font-size: 0.92rem;
}

.btn-stack,
.btn-row {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.btn-row {
  margin-top: 12px;
}

/* Action cards */

.action-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
}

.action-card {
  display: grid;
  grid-template-columns: 48px 1fr;
  grid-template-rows: auto auto;
  column-gap: 14px;
  row-gap: 4px;
  align-items: center;
  min-height: 88px;
  padding: 16px;
  text-align: left;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--card);
  transition: background 0.2s var(--ease), border-color 0.2s var(--ease), transform 0.15s var(--ease);
}

.action-card img {
  grid-row: 1 / span 2;
}

.action-title {
  font-weight: 700;
  letter-spacing: -0.02em;
}

.action-desc {
  color: var(--text-muted);
  font-size: 0.9rem;
}

.action-card:hover {
  background: var(--card-hover);
  border-color: rgba(117, 108, 255, 0.3);
}

@media (hover: hover) and (pointer: fine) {
  .action-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 14px 30px rgba(0, 0, 0, 0.18);
  }
}

.action-card:active {
  transform: scale(0.985);
}

/* Media meta / options */

.media-meta {
  display: grid;
  gap: 14px;
}

.media-cover {
  overflow: hidden;
  border-radius: var(--radius-sm);
  aspect-ratio: 16 / 9;
  background: var(--surface);
}

.media-cover img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.status-chip {
  display: inline-flex;
  align-items: center;
  margin: 0 0 10px;
  padding: 5px 10px;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 700;
}

.status-chip--info {
  color: var(--cyan);
  background: rgba(69, 200, 255, 0.12);
}

.status-chip--success {
  color: var(--success);
  background: rgba(69, 214, 160, 0.12);
}

.status-chip--warn {
  color: #f0b45a;
  background: rgba(240, 180, 90, 0.12);
}

.status-chip--error {
  color: var(--error);
  background: rgba(245, 138, 130, 0.12);
}

.status-chip--working {
  color: var(--accent-light);
  background: rgba(117, 108, 255, 0.14);
}

.meta-list {
  margin: 0;
  display: grid;
  gap: 10px;
}

.meta-list > div {
  display: grid;
  gap: 2px;
}

.meta-list dt {
  font-size: 0.78rem;
  color: var(--text-dim);
}

.meta-list dd {
  margin: 0;
  font-weight: 600;
  overflow-wrap: anywhere;
}

.choice-fieldset {
  margin: 0 0 18px;
  padding: 0;
  border: 0;
}

.choice-fieldset legend {
  margin-bottom: 10px;
  font-weight: 700;
}

.option-checkbox {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  font-weight: 650;
  cursor: pointer;
}

.option-checkbox input {
  width: 22px;
  height: 22px;
  accent-color: var(--accent);
}

#subtitle-lang-options {
  margin-top: 10px;
}

/* Раунд 11.1: списки дорожек и субтитров прокручиваются внутри себя.
   overscroll-behavior обязателен — иначе на телефоне прокрутка списка
   «пробивается» на страницу (тот же приём, что и у .playlist-picker-list). */
#audio-track-options,
#subtitle-lang-options {
  max-height: 300px;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.segmented {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  padding: 6px;
  border-radius: var(--radius-sm);
  background: var(--surface);
  border: 1px solid var(--border);
}

.segmented--wrap {
  grid-template-columns: 1fr;
}

.segment {
  position: relative;
  display: flex;
  min-height: 48px;
}

.segment input {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

.segment span {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 10px 12px;
  border-radius: 10px;
  color: var(--text-muted);
  font-weight: 650;
  transition: background 0.2s var(--ease), color 0.2s var(--ease);
}

.segment input:checked + span {
  background: linear-gradient(135deg, rgba(117, 108, 255, 0.28), rgba(69, 200, 255, 0.12));
  color: var(--text);
}

.segment input:focus-visible + span {
  box-shadow: var(--focus);
}

.radio-cards {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
}

.radio-card {
  position: relative;
  display: grid;
  gap: 2px;
  min-height: 64px;
  padding: 14px 16px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface);
  cursor: pointer;
  transition: border-color 0.2s var(--ease), background 0.2s var(--ease);
}

.radio-card input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.radio-card-title {
  font-weight: 700;
}

.radio-card-sub {
  color: var(--text-muted);
  font-size: 0.9rem;
}

.radio-card:has(input:checked) {
  border-color: rgba(117, 108, 255, 0.55);
  background: linear-gradient(135deg, rgba(117, 108, 255, 0.16), rgba(69, 200, 255, 0.06));
}

.radio-card:has(input:focus-visible) {
  box-shadow: var(--focus);
}

/* Выбор элементов плейлиста */

.playlist-hint {
  display: grid;
  gap: 10px;
}

.playlist-picker {
  display: grid;
  gap: 12px;
}

.playlist-picker-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
}

.playlist-picker-title {
  font-size: 1.05rem;
  font-weight: 700;
}

.playlist-picker-limit {
  color: var(--text-muted);
  font-size: 0.9rem;
}

.playlist-picker-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.playlist-picker-list {
  display: grid;
  gap: 8px;
  max-height: 46vh;
  margin: 0;
  padding: 0;
  overflow-y: auto;
  /* Без этого прокрутка списка до края «пробивает» на страницу — на
     телефоне выглядит как рывок всего экрана. */
  overscroll-behavior: contain;
  list-style: none;
}

.playlist-item {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  transition: border-color 0.2s var(--ease), background 0.2s var(--ease), opacity 0.2s var(--ease);
}

.playlist-item label {
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: center;
  gap: 4px 12px;
  min-height: 56px;
  padding: 10px 14px;
  cursor: pointer;
}

.playlist-item-index {
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
  min-width: 2.2rem;
}

.playlist-item-title {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.playlist-item-duration {
  grid-column: 2;
  color: var(--text-muted);
  font-size: 0.9rem;
}

.playlist-item:has(input:checked) {
  border-color: rgba(117, 108, 255, 0.55);
  background: linear-gradient(135deg, rgba(117, 108, 255, 0.16), rgba(69, 200, 255, 0.06));
}

.playlist-item:has(input:focus-visible) {
  box-shadow: var(--focus);
}

/* Достигнут лимит: неотмеченное гасится прямо в списке — это честнее,
   чем позволить отметить лишнее и показать ошибку после нажатия. */
.playlist-item.is-disabled {
  opacity: 0.45;
}

.playlist-item.is-disabled label {
  cursor: not-allowed;
}

.playlist-picker-summary {
  position: sticky;
  bottom: 0;
  margin: 0;
  padding: 10px 12px;
  border-top: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  font-weight: 600;
}

/* Раунд 9: колокольчик уведомлений */

.topbar-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

.bell {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border: none;
  border-radius: 999px;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  transition: background 0.2s var(--ease), color 0.2s var(--ease);
}

.bell:hover {
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
}

.bell[aria-expanded="true"] {
  background: rgba(117, 108, 255, 0.16);
  color: var(--text);
}

.bell-badge {
  position: absolute;
  top: 2px;
  right: 2px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  border-radius: 999px;
  color: #fff;
  background: var(--error);
  /* Обводка под цвет фона топбара, а не .surface: на мобильном топбар
     полупрозрачный со своим backdrop-filter, и непрозрачный кружок под
     чужой цвет выделялся бы на глаз. */
  box-shadow: 0 0 0 2px var(--bg);
  font-size: 0.66rem;
  font-weight: 800;
  line-height: 1;
}

.notifications-panel {
  position: fixed;
  top: calc(var(--topbar-h) + 8px);
  right: 16px;
  z-index: 50;
  width: min(92vw, 380px);
  max-height: calc(100dvh - var(--topbar-h) - var(--nav-h) - 32px);
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 14px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  background: var(--card);
  box-shadow: var(--shadow);
  animation: notices-in 0.2s var(--ease);
}

@keyframes notices-in {
  from {
    opacity: 0;
    transform: translateY(-6px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

.notifications-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.notifications-head h2 {
  font-size: 1rem;
  font-weight: 700;
}

.notifications-list {
  display: grid;
  gap: 8px;
  margin: 0;
  padding: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  list-style: none;
}

.notice-item {
  display: grid;
  gap: 4px;
  position: relative;
  padding: 10px 32px 10px 12px;
  border-radius: var(--radius-sm);
  background: var(--surface);
  border-left: 3px solid var(--accent);
}

.notice-item.is-warning {
  border-left-color: var(--error);
}

.notice-item-title {
  font-weight: 700;
  font-size: 0.9rem;
}

.notice-item-detail {
  color: var(--text-muted);
  font-size: 0.85rem;
}

.notice-item-dismiss {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 24px;
  height: 24px;
  border: none;
  border-radius: 999px;
  background: transparent;
  color: var(--text-dim);
  cursor: pointer;
  font-size: 1rem;
  line-height: 1;
}

.notice-item-dismiss:hover {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text);
}

.notifications-empty {
  color: var(--text-muted);
  font-size: 0.9rem;
  text-align: center;
  padding: 8px 0;
}

/* Progress */

.progress-panel .progress-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.progress-panel h2,
.progress-title,
.ready-panel h2,
.attention-panel h2 {
  margin: 0;
}

.progress-percent {
  margin: 0;
  font-weight: 700;
  color: var(--accent-light);
}

.progress-track {
  height: 8px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.06);
  overflow: hidden;
  margin-bottom: 18px;
}

.progress-bar {
  position: relative;
  height: 100%;
  width: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--accent), var(--cyan));
  transform: scaleX(var(--progress, 0));
  transform-origin: left center;
  transition: transform 0.24s linear;
  will-change: transform;
}

.stage-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 12px;
}

.stage-detail {
  min-height: 1.5em;
  margin: -4px 0 16px;
  color: var(--text-dim);
  line-height: 1.5;
}

.stage {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--text-dim);
  font-weight: 550;
}

.stage em {
  font-style: normal;
  color: var(--accent-light);
}

.stage-icon {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.18);
  flex-shrink: 0;
  position: relative;
}

.stage.is-done {
  color: var(--success);
}

.stage.is-done .stage-icon {
  border-color: var(--success);
  background: rgba(69, 214, 160, 0.18);
}

.stage.is-done .stage-icon::after {
  content: "";
  position: absolute;
  left: 6px;
  top: 3px;
  width: 6px;
  height: 10px;
  border: solid var(--success);
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}

.stage.is-active {
  color: var(--text);
}

.stage.is-active .stage-icon {
  border-color: var(--accent-light);
  box-shadow: 0 0 0 4px rgba(117, 108, 255, 0.18);
}

.stage.is-active .stage-icon::after {
  content: "";
  position: absolute;
  inset: 4px;
  border-radius: 50%;
  background: var(--accent-light);
}

.stage.is-active span:last-child {
  color: var(--accent-light);
}

.ready-panel {
  text-align: center;
}

.ready-check {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  margin: 0 auto 12px;
  border-radius: 50%;
  background: rgba(69, 214, 160, 0.16);
  color: var(--success);
  font-size: 1.25rem;
  font-weight: 700;
  animation: check-pop 0.35s var(--ease);
}

@keyframes check-pop {
  from {
    opacity: 0;
    transform: scale(0.7);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

.ready-art {
  width: min(100%, 320px);
  margin: 0 auto 16px;
  border-radius: var(--radius-sm);
}

.ready-art:not([src]),
.media-cover img:not([src]) {
  display: none;
}

.zip-stats {
  margin: 14px auto 8px;
  padding: 0;
  display: grid;
  gap: 8px;
  max-width: 280px;
  text-align: left;
}

.zip-stats > div {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 12px;
  border-radius: var(--radius-xs);
  background: var(--surface);
  border: 1px solid var(--border);
}

.zip-stats dt {
  color: var(--text-dim);
}

.zip-stats dd {
  margin: 0;
  font-weight: 700;
}

.attention-intro {
  margin: 0 0 14px;
  color: var(--text-muted);
  font-size: 0.92rem;
}

.ttl-note {
  margin: 8px 0 18px;
  color: var(--text-muted);
}

/* Playlist */

.method-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 16px;
}

.method-tab {
  min-height: 48px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-muted);
  font-weight: 650;
}

.method-tab.is-active {
  color: var(--text);
  border-color: rgba(117, 108, 255, 0.45);
  background: rgba(117, 108, 255, 0.16);
}

.file-picker {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 14px;
  border-radius: var(--radius-sm);
  border: 1px dashed rgba(156, 140, 255, 0.35);
  background: rgba(117, 108, 255, 0.06);
  margin-bottom: 16px;
}

.file-picker input[type="file"] {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
}

.file-picker-info {
  display: grid;
  gap: 4px;
  min-width: 0;
}

.file-picker-name {
  font-weight: 700;
  overflow-wrap: anywhere;
}

.file-picker-hint {
  color: var(--text-dim);
  font-size: 0.85rem;
}

.file-picker-btn {
  cursor: pointer;
}

.playlist-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.playlist-summary h2 {
  margin: 0 0 4px;
}

.playlist-summary p {
  margin: 0;
  color: var(--text-muted);
}

.playlist-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.selection-count {
  margin: 0;
  color: var(--text-muted);
  font-weight: 600;
}

.track-list {
  list-style: none;
  margin: 0 0 18px;
  padding: 0;
  display: grid;
  gap: 8px;
}

.track-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  min-height: 52px;
  padding: 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface);
}

.track-item input {
  width: 20px;
  height: 20px;
  margin-top: 2px;
  accent-color: var(--accent);
  flex-shrink: 0;
}

.track-item label {
  flex: 1;
  min-width: 0;
  overflow-wrap: anywhere;
  word-break: break-word;
  font-weight: 550;
  line-height: 1.35;
}

.attention-item + .attention-item {
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
}

.attention-title {
  margin: 0 0 6px;
  font-weight: 700;
  color: var(--error);
}

.empty-history img {
  max-width: 280px;
  margin: 0 auto 12px;
}

/* History */

.chip-scroll {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 4px;
  margin-bottom: 14px;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}

.chip-scroll::-webkit-scrollbar {
  display: none;
}

.chip {
  flex: 0 0 auto;
  min-height: 42px;
  padding: 8px 14px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--text-muted);
  font-weight: 650;
  white-space: nowrap;
}

.chip.is-active {
  color: var(--text);
  border-color: rgba(117, 108, 255, 0.45);
  background: rgba(117, 108, 255, 0.18);
}

.history-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
}

.history-toolbar {
  display: grid;
  gap: 10px;
  margin-bottom: 14px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: rgba(18, 26, 38, 0.72);
}

.history-select-all,
.history-select-one {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  color: var(--text-muted);
  font-weight: 650;
}

.history-select-all input,
.history-select-one input {
  width: 22px;
  height: 22px;
  accent-color: var(--accent);
}

.history-bulk-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.history-bulk-actions .btn {
  min-height: 42px;
  padding: 8px 12px;
}

.history-card {
  display: grid;
  grid-template-columns: auto 72px 1fr;
  gap: 14px;
  padding: 14px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--card);
}

.history-card.is-selected {
  border-color: rgba(117, 108, 255, 0.72);
  box-shadow: 0 0 0 2px rgba(117, 108, 255, 0.14);
}

.history-select-one {
  align-self: start;
  min-height: 36px;
}

.history-thumb {
  width: 72px;
  height: 72px;
  border-radius: 12px;
  object-fit: cover;
  background: var(--surface);
}

.history-body {
  min-width: 0;
  display: grid;
  gap: 6px;
}

.history-title {
  margin: 0;
  font-weight: 700;
  letter-spacing: -0.02em;
  overflow-wrap: anywhere;
}

.history-meta {
  margin: 0;
  color: var(--text-muted);
  font-size: 0.88rem;
}

.history-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 4px;
}

.history-actions .btn {
  min-height: 42px;
  padding: 8px 12px;
  font-size: 0.88rem;
}

.history-card .progress-track {
  margin: 4px 0 0;
}

/* About */

.about-card {
  text-align: center;
  padding: 28px 20px;
}

.about-logo {
  margin: 0 auto 16px;
  border-radius: 18px;
}

.about-card h1 {
  margin: 0 0 10px;
  letter-spacing: -0.03em;
}

.about-card > p {
  margin: 0 auto;
  max-width: 36ch;
  color: var(--text-muted);
}

.prototype-banner {
  display: inline-flex;
  margin: 18px auto !important;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(69, 200, 255, 0.25);
  background: rgba(69, 200, 255, 0.1);
  color: var(--cyan) !important;
  font-weight: 700;
}

.about-list {
  list-style: none;
  margin: 18px 0 0;
  padding: 0;
  display: grid;
  gap: 10px;
  text-align: left;
}

.about-list li {
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text-muted);
}

.about-list li::before {
  content: "•";
  color: var(--accent-light);
  margin-right: 8px;
}

/* Bottom nav */

.bottom-nav {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 40;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 2px;
  min-height: var(--nav-h);
  padding: 8px 8px calc(8px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--border);
  background: rgba(12, 17, 26, 0.98);
  -webkit-tap-highlight-color: transparent;
}

.bottom-item {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  min-height: 52px;
  padding: 6px 4px;
  border-radius: 12px;
  color: var(--text-dim);
  font-size: 0.72rem;
  font-weight: 650;
}

.bottom-item img {
  opacity: 0.75;
}

.bottom-item.is-active {
  color: var(--text);
  background: linear-gradient(135deg, rgba(117, 108, 255, 0.2), rgba(69, 200, 255, 0.08));
}

.bottom-item.is-active img {
  opacity: 1;
}

.bottom-item .nav-badge {
  position: absolute;
  top: 3px;
  right: max(4px, calc(50% - 28px));
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  box-shadow: 0 0 0 2px rgba(12, 17, 26, 0.98);
}

/* Toasts */

.toast-region {
  position: fixed;
  left: 50%;
  bottom: calc(var(--nav-h) + 16px);
  transform: translateX(-50%);
  z-index: 60;
  width: min(92vw, 420px);
  display: grid;
  gap: 8px;
  pointer-events: none;
}

.toast {
  pointer-events: none;
  padding: 14px 16px;
  border-radius: var(--radius-sm);
  background: #1a2433;
  border: 1px solid rgba(156, 140, 255, 0.35);
  box-shadow: var(--shadow);
  color: var(--text);
  font-weight: 600;
  animation: toast-in 0.25s var(--ease);
}

.toast.is-leaving {
  animation: toast-out 0.2s var(--ease) forwards;
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

@keyframes toast-out {
  to {
    opacity: 0;
    transform: translateY(6px);
  }
}

/* Tablet */
@media (min-width: 768px) {
  .main {
    padding: 24px 24px calc(var(--nav-h) + 32px);
  }

  .hero {
    min-height: 340px;
  }

  .hero-copy {
    min-height: 340px;
    padding: 32px;
  }

  .action-grid {
    grid-template-columns: 1fr 1fr;
  }

  .link-row {
    display: grid;
    grid-template-columns: 1fr auto;
    align-items: stretch;
  }

  .link-actions {
    grid-template-columns: auto auto;
  }

  .media-meta {
    grid-template-columns: 220px 1fr;
    align-items: center;
  }

  .radio-cards {
    grid-template-columns: 1fr 1fr;
  }

  .playlist-item label {
    grid-template-columns: 2.5rem 1fr auto;
  }

  .playlist-item-duration {
    grid-column: auto;
  }

  /* На широком экране сводка помещается под списком целиком —
     липкая полоса нужна только там, где список прокручивается пальцем. */
  .playlist-picker-summary {
    position: static;
    border-top: 0;
    padding: 0;
    background: none;
  }

  .segmented--wrap {
    grid-template-columns: repeat(3, 1fr);
  }

  .file-picker {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
  }

  .topbar {
    background: rgba(11, 16, 24, 0.92);
    backdrop-filter: blur(12px);
  }

  .btn-row {
    flex-direction: row;
    flex-wrap: wrap;
  }

  .history-grid {
    grid-template-columns: 1fr 1fr;
  }

  .history-toolbar {
    grid-template-columns: auto 1fr;
    align-items: center;
  }

  .history-bulk-actions {
    justify-content: flex-end;
  }
}

/* Desktop */
@media (min-width: 1100px) {
  .sidebar {
    display: flex;
    flex-direction: column;
  }

  .bottom-nav {
    display: none;
  }

  .topbar-logo {
    display: none;
  }

  .sidebar {
    background: rgba(18, 26, 38, 0.96);
    backdrop-filter: blur(12px);
  }

  .main {
    padding: 28px 32px 40px;
  }

  .toast-region {
    bottom: 28px;
    left: calc(50% + var(--sidebar-w) / 2);
  }

  /* .bottom-nav уже не занимает низ экрана на этой ширине — панель
     уведомлений может использовать всю высоту под топбаром. */
  .notifications-panel {
    max-height: calc(100dvh - var(--topbar-h) - 32px);
  }

  .hero {
    min-height: 380px;
  }

  .hero-copy {
    min-height: 380px;
    max-width: 560px;
  }

  .action-grid {
    grid-template-columns: repeat(3, 1fr);
  }

  .action-card {
    grid-template-columns: 1fr;
    grid-template-rows: auto auto auto;
    align-content: start;
    min-height: 168px;
  }

  .action-card img {
    grid-row: auto;
    margin-bottom: 8px;
  }
}

/* Aurora Signal — calm, event-driven visual layer */

.home-command-deck {
  position: relative;
  margin-bottom: 22px;
}

.home-command-deck .hero {
  min-height: 230px;
  margin-bottom: 0;
}

.home-command-deck .hero-copy {
  min-height: 230px;
  width: 100%;
  max-width: none;
  align-items: center;
  text-align: center;
  padding: 18px 18px 48px;
}

.home-command-deck .hero-logo {
  width: 48px;
  height: 48px;
  margin-bottom: 10px;
  border-radius: 13px;
}

.home-command-deck .hero-copy h1 {
  font-size: clamp(2rem, 10vw, 2.5rem);
}

.home-command-deck .hero-tagline {
  margin-top: 6px;
  font-size: 1rem;
}

.home-command-deck .hero-lead {
  margin-top: 7px;
  max-width: 34ch;
  font-size: 0.9rem;
}

.home-command-deck .hero::after {
  content: "";
  position: absolute;
  z-index: 1;
  inset: -35% auto -35% -55%;
  width: 32%;
  pointer-events: none;
  opacity: 0;
  transform: translateX(0) skewX(-12deg);
  background: linear-gradient(90deg, transparent, rgba(156, 140, 255, 0.12), transparent);
  animation: hero-signal-in 0.58s var(--ease) 0.12s both;
}

.home-command-deck .home-link-panel {
  position: relative;
  z-index: 2;
  margin: 14px 0 0;
  border-color: rgba(156, 140, 255, 0.18);
  box-shadow: 0 18px 42px rgba(0, 0, 0, 0.3);
}

#view-home > .section-head,
#view-download > .section-head,
#view-playlist > .section-head,
#view-history > .section-head {
  text-align: center;
}

.home-command-deck .home-link-panel > .field-label,
.home-command-deck .home-link-panel > .field-hint {
  text-align: left;
}

@keyframes hero-signal-in {
  0% {
    opacity: 0;
    transform: translateX(0) skewX(-12deg);
  }
  28% {
    opacity: 1;
  }
  100% {
    opacity: 0;
    transform: translateX(520%) skewX(-12deg);
  }
}

.btn-spinner {
  width: 16px;
  height: 16px;
  flex: 0 0 16px;
  border: 2px solid rgba(255, 255, 255, 0.24);
  border-top-color: currentColor;
  border-radius: 50%;
  animation: signal-spin 0.8s linear infinite;
}

@keyframes signal-spin {
  to { transform: rotate(360deg); }
}

.inspect-state,
.progress-panel,
.ready-panel {
  position: relative;
  overflow: hidden;
}

.inspect-state::before,
.progress-panel::before,
.ready-panel::before,
.history-card::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 2px;
  background: linear-gradient(180deg, var(--brand-violet), var(--cyan));
  opacity: 0.9;
}

.ready-panel::before,
.history-card--done::before {
  background: var(--success);
}

.history-card--attention::before {
  background: var(--error);
}

.inspect-state {
  display: grid;
  gap: 16px;
  border-color: rgba(117, 108, 255, 0.26);
  background:
    radial-gradient(420px 180px at 20% 0%, rgba(117, 108, 255, 0.12), transparent 68%),
    var(--card);
}

.inspect-state.is-error {
  border-color: rgba(245, 138, 130, 0.3);
}

.inspect-state.is-error::before {
  background: var(--error);
}

.inspect-skeleton {
  position: relative;
  display: grid;
  gap: 10px;
  overflow: hidden;
}

.inspect-skeleton::after {
  content: "";
  position: absolute;
  inset: 0;
  width: 42%;
  pointer-events: none;
  transform: translateX(-130%);
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.075), transparent);
  animation: skeleton-signal 1.55s linear infinite;
}

.skeleton-block {
  display: block;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.055);
}

.skeleton-media {
  width: 100%;
  aspect-ratio: 16 / 7;
  min-height: 92px;
}

.skeleton-line {
  width: 76%;
  height: 12px;
}

.skeleton-line--wide {
  width: 92%;
}

.skeleton-line--short {
  width: 48%;
}

@keyframes skeleton-signal {
  to { transform: translateX(340%); }
}

.inspect-message {
  display: flex;
  align-items: flex-start;
  gap: 12px;
}

.inspect-message strong {
  display: block;
  margin-bottom: 4px;
}

.inspect-message p {
  margin: 0;
  color: var(--text-muted);
  font-size: 0.88rem;
}

.signal-orb {
  position: relative;
  width: 14px;
  height: 14px;
  margin-top: 4px;
  flex: 0 0 14px;
  border-radius: 50%;
  background: var(--accent-light);
  box-shadow: 0 0 0 0 rgba(156, 140, 255, 0.3);
  animation: signal-orb-pulse 1.6s var(--ease) infinite;
}

.inspect-state.is-error .signal-orb {
  background: var(--error);
  animation: none;
}

@keyframes signal-orb-pulse {
  50% {
    opacity: 0.72;
    transform: scale(0.86);
    box-shadow: 0 0 0 8px rgba(156, 140, 255, 0);
  }
}

.inspect-error-art {
  width: min(100%, 240px);
  margin: 0 auto;
  border-radius: var(--radius-sm);
}

.progress-bar {
  overflow: hidden;
}

.progress-bar::after {
  content: "";
  position: absolute;
  inset: 0;
  width: 34%;
  opacity: 0;
  transform: translateX(-130%);
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.54), transparent);
}

.progress-bar.is-active:not(.is-indeterminate)::after {
  opacity: 0.62;
  animation: progress-signal 1.55s linear infinite;
}

.progress-bar.is-indeterminate {
  transform-origin: center;
  animation: progress-indeterminate 1.35s var(--ease) infinite;
}

@keyframes progress-signal {
  to { transform: translateX(390%); }
}

@keyframes progress-indeterminate {
  0% { transform: translateX(-74%) scaleX(0.24); }
  52% { transform: translateX(0) scaleX(0.38); }
  100% { transform: translateX(74%) scaleX(0.24); }
}

.stage.is-active .stage-icon::before {
  content: "";
  position: absolute;
  inset: -2px;
  border: 2px solid transparent;
  border-top-color: var(--accent-light);
  border-right-color: rgba(69, 200, 255, 0.7);
  border-radius: 50%;
  animation: stage-signal-spin 0.9s linear infinite;
}

@keyframes stage-signal-spin {
  to { transform: rotate(360deg); }
}

.service-status.is-offline .service-status-dot {
  animation: status-alert 0.82s var(--ease) 2;
}

@keyframes status-alert {
  50% {
    opacity: 0.55;
    transform: scale(0.78);
  }
}

.radio-card {
  padding-right: 48px;
}

.radio-card::after {
  content: "";
  position: absolute;
  top: 50%;
  right: 16px;
  width: 18px;
  height: 18px;
  border: 1px solid var(--border-strong);
  border-radius: 50%;
  transform: translateY(-50%);
  background: var(--surface);
  transition: border-color 0.18s var(--ease), box-shadow 0.18s var(--ease), background 0.18s var(--ease);
}

.radio-card:has(input:checked)::after {
  border-color: var(--accent-light);
  background: var(--accent);
  box-shadow: inset 0 0 0 4px var(--surface), 0 0 0 3px rgba(117, 108, 255, 0.13);
}

.ready-check {
  display: block;
  object-fit: contain;
  margin-bottom: 10px;
  background: transparent;
}

.ready-art {
  opacity: 0.9;
  border: 1px solid var(--border);
}

.chip-scroll-wrapper {
  position: relative;
  margin-bottom: 14px;
}

.chip-scroll-wrapper::before,
.chip-scroll-wrapper::after {
  content: "";
  position: absolute;
  z-index: 2;
  top: 0;
  bottom: 4px;
  width: 42px;
  pointer-events: none;
  opacity: 1;
  transition: opacity 0.18s var(--ease);
}

.chip-scroll-wrapper::before {
  left: 0;
  background: linear-gradient(90deg, var(--bg), transparent);
}

.chip-scroll-wrapper::after {
  right: 0;
  background: linear-gradient(270deg, var(--bg), transparent);
}

.chip-scroll-wrapper.is-at-start::before,
.chip-scroll-wrapper.is-at-end::after {
  opacity: 0;
}

.chip-scroll {
  margin-bottom: 0;
}

.history-card {
  position: relative;
  overflow: hidden;
  content-visibility: auto;
  contain-intrinsic-size: auto 220px;
}

.history-thumb.is-broken,
.media-cover img.is-broken {
  object-fit: contain;
  padding: 10px;
  opacity: 0.78;
}

.confirm-dialog {
  width: min(calc(100% - 32px), 440px);
  margin: auto;
  padding: 24px;
  border: 1px solid var(--border-strong);
  border-radius: 22px;
  color: var(--text);
  background:
    radial-gradient(360px 180px at 20% 0%, rgba(117, 108, 255, 0.13), transparent 70%),
    #151e2b;
  box-shadow: 0 28px 80px rgba(0, 0, 0, 0.58);
}

.confirm-dialog[open] {
  animation: dialog-in 0.2s var(--ease);
}

.confirm-dialog::backdrop {
  background: rgba(6, 9, 14, 0.78);
  backdrop-filter: blur(4px);
}

.confirm-icon {
  margin-bottom: 14px;
}

.confirm-dialog h2 {
  margin: 0 0 8px;
  font-size: 1.28rem;
}

.confirm-dialog p {
  margin: 0;
  color: var(--text-muted);
}

.confirm-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 22px;
}

.confirm-dialog.is-destructive [data-confirm="ok"] {
  background: linear-gradient(135deg, #db7069, var(--error));
  box-shadow: 0 10px 24px rgba(245, 138, 130, 0.2);
}

@keyframes dialog-in {
  from {
    opacity: 0;
    transform: scale(0.96) translateY(6px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

.has-view-transitions .view.is-active {
  animation: none;
}

::view-transition-old(root) {
  animation: view-transition-out 0.14s ease both;
}

::view-transition-new(root) {
  animation: view-transition-in 0.2s var(--ease) both;
}

@keyframes view-transition-out {
  to {
    opacity: 0;
    transform: translateY(-3px);
  }
}

@keyframes view-transition-in {
  from {
    opacity: 0;
    transform: translateY(4px);
  }
}

@media (min-width: 768px) {
  .home-command-deck .hero,
  .home-command-deck .hero-copy {
    min-height: 340px;
  }

  .home-command-deck .hero-copy {
    width: min(100%, 620px);
    max-width: 620px;
    align-items: flex-start;
    text-align: left;
    padding: 32px 32px 64px;
  }

  .home-command-deck .hero-logo {
    width: 64px;
    height: 64px;
    margin-bottom: 14px;
    border-radius: 16px;
  }

  .home-command-deck .hero-copy h1 {
    font-size: clamp(2.2rem, 6vw, 3rem);
  }

  .home-command-deck .hero-tagline {
    font-size: 1.15rem;
  }

  .home-command-deck .hero-lead {
    display: block;
    max-width: 36ch;
    font-size: 1rem;
  }

  .home-command-deck .home-link-panel {
    margin-top: 18px;
  }

  .inspect-state {
    grid-template-columns: minmax(220px, 0.8fr) 1.2fr;
    align-items: center;
  }

  .inspect-error-art {
    grid-row: 1;
  }
}

@media (min-width: 1100px) {
  .home-command-deck .hero,
  .home-command-deck .hero-copy {
    min-height: 380px;
  }

  .home-command-deck .home-link-panel {
    margin-top: 20px;
  }
}

/* Mobile glass chrome: translucent at rest, slightly clearer over content on scroll. */
@media (max-width: 1099px) {
  .topbar,
  .bottom-nav {
    -webkit-backdrop-filter: blur(20px) saturate(150%);
    backdrop-filter: blur(20px) saturate(150%);
    transition:
      background-color 180ms var(--ease),
      border-color 180ms var(--ease),
      box-shadow 180ms var(--ease);
  }

  .topbar {
    border-bottom-color: rgba(255, 255, 255, 0.08);
    background: linear-gradient(
      180deg,
      rgba(20, 27, 39, 0.72),
      rgba(10, 15, 23, 0.62)
    );
    box-shadow:
      0 12px 34px rgba(0, 0, 0, 0.18),
      inset 0 -1px 0 rgba(255, 255, 255, 0.05);
  }

  .bottom-nav {
    border-top-color: rgba(255, 255, 255, 0.1);
    background: linear-gradient(
      180deg,
      rgba(25, 34, 48, 0.64),
      rgba(9, 14, 22, 0.72)
    );
    box-shadow:
      0 -14px 38px rgba(0, 0, 0, 0.22),
      inset 0 1px 0 rgba(255, 255, 255, 0.07);
  }

  .is-scrolled .topbar {
    border-bottom-color: rgba(255, 255, 255, 0.11);
    background: linear-gradient(
      180deg,
      rgba(20, 27, 39, 0.6),
      rgba(10, 15, 23, 0.48)
    );
  }

  .is-scrolled .bottom-nav {
    border-top-color: rgba(255, 255, 255, 0.13);
    background: linear-gradient(
      180deg,
      rgba(25, 34, 48, 0.52),
      rgba(9, 14, 22, 0.6)
    );
  }
}

@supports not ((-webkit-backdrop-filter: blur(1px)) or (backdrop-filter: blur(1px))) {
  @media (max-width: 1099px) {
    .topbar,
    .is-scrolled .topbar {
      background: rgba(11, 16, 24, 0.92);
    }

    .bottom-nav,
    .is-scrolled .bottom-nav {
      background: rgba(12, 17, 26, 0.94);
    }
  }
}

@media (prefers-reduced-transparency: reduce) {
  .topbar,
  .sidebar,
  .bottom-nav,
  .confirm-dialog::backdrop {
    -webkit-backdrop-filter: none;
    backdrop-filter: none;
  }

  .topbar,
  .sidebar,
  .bottom-nav {
    background: var(--bg);
  }
}

@media (update: slow) {
  .btn-spinner,
  .inspect-skeleton::after,
  .signal-orb,
  .progress-bar::after,
  .progress-bar.is-indeterminate,
  .stage.is-active .stage-icon::before,
  .service-status.is-offline .service-status-dot,
  .home-command-deck .hero::after {
    animation: none !important;
  }

  .progress-bar.is-indeterminate {
    transform: scaleX(0.28);
    transform-origin: left center;
  }
}

.is-page-hidden .btn-spinner,
.is-page-hidden .inspect-skeleton::after,
.is-page-hidden .signal-orb,
.is-page-hidden .progress-bar::after,
.is-page-hidden .progress-bar.is-indeterminate,
.is-page-hidden .stage.is-active .stage-icon::before {
  animation-play-state: paused !important;
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }

  .view.is-active,
  .reveal-card:not([hidden]),
  .toast,
  .ready-check,
  .btn-primary::after,
  .btn-spinner,
  .signal-orb,
  .stage.is-active .stage-icon::before,
  .service-status.is-offline .service-status-dot,
  .confirm-dialog[open],
  .notifications-panel,
  .notice-item,
  ::view-transition-old(root),
  ::view-transition-new(root) {
    animation: none !important;
    transition: none !important;
    opacity: 1 !important;
    transform: none !important;
  }

  .inspect-skeleton::after,
  .progress-bar::after,
  .home-command-deck .hero::after {
    display: none !important;
  }

  .progress-bar.is-indeterminate {
    animation: none !important;
    transition: none !important;
    transform: scaleX(0.28) !important;
    transform-origin: left center;
  }
}

/* Сворачиваемый выбор качества */

.options-toggle {
  display: none;
  width: 100%;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  margin-bottom: 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.03);
  color: var(--text);
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.options-card.is-collapsible .options-toggle {
  display: flex;
}

.options-toggle-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.options-toggle-label {
  font-size: 0.82rem;
  color: var(--text-muted);
}

.options-toggle-value {
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.options-toggle-chevron {
  flex-shrink: 0;
  width: 10px;
  height: 10px;
  border-right: 2px solid var(--text-muted);
  border-bottom: 2px solid var(--text-muted);
  transform: rotate(-135deg);
  transition: transform 0.28s var(--ease);
}

.options-card.is-collapsed .options-toggle-chevron {
  transform: rotate(45deg);
}

.options-body {
  overflow: hidden;
}

.progress-panel {
  scroll-margin-top: 80px;
}

.options-body-inner {
  max-height: 240vh;
  opacity: 1;
  transition: max-height 0.32s var(--ease), opacity 0.22s var(--ease);
}

.options-card.is-collapsed .options-body-inner {
  max-height: 0;
  opacity: 0;
}

@media (prefers-reduced-motion: reduce) {
  .options-body-inner,
  .options-toggle-chevron {
    transition: none !important;
  }
}

/* KWMS Media 1.0: compact phone-first surfaces and floating navigation. */
:root { --radius: 24px; --radius-sm: 16px; --border: rgba(191,203,238,.09); --sidebar-w: 232px; }
body { background: radial-gradient(ellipse at 95% 0,rgba(117,108,255,.10),transparent 48%),radial-gradient(ellipse at 0 45%,rgba(69,200,255,.05),transparent 45%),#0b1018; }
.topbar { margin: 8px 12px 0; top: calc(8px + env(safe-area-inset-top)); min-height: 60px; border: 1px solid var(--border); border-radius: 22px; background: rgba(18,25,38,.83); box-shadow: 0 8px 30px rgba(0,0,0,.16); backdrop-filter: blur(22px) saturate(135%); -webkit-backdrop-filter: blur(22px) saturate(135%); padding: 8px 12px; }
.topbar-left { min-width: 0; gap: 9px; }
.topbar-left strong { font-size: .93rem; white-space: nowrap; }
.topbar-right { gap: 5px; }
.chrome-button,.bell { display: inline-flex; align-items: center; justify-content: center; min-width: 44px; min-height: 44px; width: 44px; height: 44px; padding: 0; border-radius: 50%; border: 1px solid var(--border); background: rgba(255,255,255,.035); color: #c5cce0; }
.chrome-button:hover,.bell:hover { background: rgba(117,108,255,.13); }
.chrome-button[aria-busy=true] svg { animation: kwms-spin 1s linear infinite; }
@keyframes kwms-spin { to { transform: rotate(360deg); } }
.service-status { display: none; }
.main { padding: 24px 16px calc(108px + env(safe-area-inset-bottom)); }
.panel { background: linear-gradient(145deg,rgba(27,36,53,.96),rgba(18,26,39,.98)); border-color: var(--border); box-shadow: 0 10px 36px rgba(0,0,0,.14),inset 0 1px rgba(255,255,255,.025); }
.home-command-deck { display: block; padding: 0; border: 0; background: none; box-shadow: none; overflow: visible; }
.home-command-deck .hero { position: relative; display: flex; align-items: center; min-height: 0; height: auto; padding: 12px 6px 25px; border: 0; background: none; box-shadow: none; overflow: visible; border-radius: 0; }
.home-command-deck .hero-copy { display: block; position: static; min-height: 0; padding: 0; z-index: 1; max-width: 100%; }
.eyebrow { display: block; color: #939cbb; font-size: .66rem; font-weight: 700; letter-spacing: .17em; margin-bottom: 10px; }
.home-command-deck .hero-copy h1 { margin: 0; font-size: clamp(2rem,7.7vw,3.4rem); line-height: 1.12; letter-spacing: -.055em; background: none; color: var(--text); -webkit-text-fill-color: currentColor; }
.home-command-deck .hero-lead { display: block; margin: 14px 0; max-width: 32ch; font-size: .89rem; color: var(--text-muted); line-height: 1.55; }
.hero-orb { position: absolute; right: 0; top: 25px; width: 86px; height: 86px; opacity: .24; filter: drop-shadow(0 0 28px rgba(117,108,255,.18)); z-index: 0; }
.storage-pill { display: inline-flex; align-items: center; gap: 7px; padding: 7px 11px; border: 1px solid var(--border); border-radius: 999px; font-size: .71rem; color: #b2bdd3; background: rgba(255,255,255,.025); }
.home-command-deck .home-link-panel { margin: 0 0 28px; padding: 20px; border-radius: 26px; background: linear-gradient(135deg,rgba(43,43,77,.66),rgba(21,32,48,.97)); }
.home-link-panel .field-label { font-size: 1.06rem; font-weight: 650; margin-bottom: 14px; }
.home-link-panel .link-row { gap: 10px; }
.input { background: rgba(6,12,22,.6); min-height: 52px; border-radius: 16px; border: 1px solid rgba(183,195,227,.14); }
.input:focus { border-color: var(--accent-light); }
.btn { min-height: 48px; border-radius: 15px; font-weight: 650; }
.btn-primary { background: linear-gradient(110deg,#8074ff,#645de5); box-shadow: 0 4px 16px rgba(99,88,214,.17),inset 0 1px rgba(255,255,255,.16); }
.btn-secondary { background: rgba(255,255,255,.045); border-color: rgba(191,203,238,.13); }
.section-head { margin-bottom: 14px; }
.section-head h2 { font-size: 1.13rem; letter-spacing: -.025em; }
.section-head p { font-size: .81rem; }
.action-grid { gap: 10px; }
.action-card { display: grid; grid-template-columns: 46px minmax(0,1fr) 16px; column-gap: 13px; row-gap: 4px; align-items: center; padding: 17px; min-height: 92px; text-align: left; border-radius: 21px; background: linear-gradient(135deg,rgba(26,35,51,.92),rgba(18,27,41,.98)); box-shadow: inset 0 1px rgba(255,255,255,.025); }
.action-card img { grid-row: 1 / 3; width: 44px; height: 44px; }
.action-card .action-title { grid-column: 2; margin: 0; font-size: .99rem; font-weight: 650; }
.action-card .action-desc { grid-column: 2; margin: 0; font-size: .79rem; color: var(--text-muted); }
.action-card::after { content: '›'; grid-column: 3; grid-row: 1 / 3; color: #8390ae; font-size: 1.4rem; }
.bottom-nav { left: max(12px,env(safe-area-inset-left)); right: max(12px,env(safe-area-inset-right)); bottom: calc(10px + env(safe-area-inset-bottom)); min-height: 68px; padding: 6px; border: 1px solid rgba(181,196,227,.13); border-radius: 25px; background: rgba(21,28,42,.87); box-shadow: 0 8px 35px rgba(0,0,0,.42),inset 0 1px rgba(255,255,255,.035); }
.bottom-item { min-height: 54px; border-radius: 19px; gap: 3px; font-size: .64rem; }
.bottom-item.is-active { background: rgba(133,118,255,.13); box-shadow: inset 0 0 0 1px rgba(156,140,255,.12); }
.bottom-item img { width: 23px; height: 23px; }
.toast-region { bottom: calc(92px + env(safe-area-inset-bottom)); }
.history-card,.options-card,.progress-panel { border-radius: 22px; }
.app-settings { width: min(480px,calc(100% - 24px)); max-height: calc(100dvh - 40px - env(safe-area-inset-top) - env(safe-area-inset-bottom)); padding: 22px; border: 1px solid var(--border-strong); border-radius: 28px; background: #131b2a; color: var(--text); box-shadow: 0 25px 80px rgba(0,0,0,.55); overflow-y: auto; }
.app-settings::backdrop { background: rgba(4,8,16,.7); backdrop-filter: blur(5px); -webkit-backdrop-filter: blur(5px); }
.settings-heading { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; }
.settings-heading h2 { margin: 0; font-size: 1.55rem; letter-spacing: -.035em; }
.settings-heading .eyebrow { margin-bottom: 4px; }
.settings-card { padding: 18px; border: 1px solid var(--border); border-radius: 20px; margin-bottom: 12px; background: rgba(255,255,255,.025); }
.settings-card strong,.settings-label { display: block; }
.settings-label { font-size: .7rem; color: var(--text-muted); margin-bottom: 7px; }
.settings-card strong { font-size: 1rem; }
.settings-card p { font-size: .83rem; line-height: 1.6; color: var(--text-muted); margin: 10px 0 14px; }
.settings-card .btn { width: 100%; }
.settings-card .settings-footnote { font-size: .7rem; margin: 12px 0 0; }
.settings-footer { display: flex; align-items: center; flex-wrap: wrap; justify-content: space-between; gap: 8px; color: var(--text-muted); font-size: .75rem; }
.settings-footer .btn { min-height: 44px; }
.is-scrolled .topbar,.is-scrolled .bottom-nav { background: rgba(21,28,42,.91); }
@media (min-width: 600px) { .hero-orb { width: 130px; height: 130px; opacity: .55; right: 18px; } .main { padding-inline: 26px; } .home-command-deck .hero { padding: 22px 6px 30px; } .topbar { margin-inline: 22px; } }
@media (min-width: 768px) { .service-status { display: inline-flex; } .action-grid { grid-template-columns: repeat(3,minmax(0,1fr)); } .action-card { display: flex; flex-direction: column; align-items: flex-start; min-height: 180px; padding: 23px; } .action-card .action-title { margin-top: 14px; } .action-card::after { display: none; } .bottom-nav { max-width: 480px; margin: auto; } }
@media (min-width: 1100px) { .sidebar { border-right: 1px solid var(--border); background: rgba(15,22,34,.85); } .sidebar-nav { padding-inline: 14px; } .nav-item { border-radius: 16px; min-height: 52px; } .main { padding: 36px 38px 50px; } .topbar { margin: 16px 30px 0; top: 16px; } .home-command-deck .hero { padding: 12px 6px 28px; } .hero-orb { width: 145px; height: 145px; top: 0; right: 22px; opacity: .7; } .home-command-deck .hero-copy { min-height: 0; } }
@media (max-width: 350px) { .topbar { margin-inline: 8px; padding-inline: 8px; } .topbar-left .topbar-logo { display: none; } .topbar-left strong { font-size: .85rem; } .topbar-right { gap: 3px; } .chrome-button,.bell { min-width: 44px; width: 44px; } .main { padding-inline: 12px; } .home-command-deck .home-link-panel { padding: 16px; } .hero-orb { display: none; } }
@media (max-height: 500px) and (max-width: 1099px) { .topbar { position: relative; top: auto; } .bottom-nav { min-height: 54px; padding: 3px; } .bottom-item { min-height: 44px; flex-direction: row; gap: 6px; } .bottom-item img { width: 20px; height: 20px; } .main { padding-bottom: 82px; } }
@media (prefers-reduced-motion: reduce) { .chrome-button[aria-busy=true] svg { animation: none; } }
@media (prefers-reduced-transparency: reduce) { .topbar,.bottom-nav,.is-scrolled .topbar,.is-scrolled .bottom-nav { background: #182230; backdrop-filter: none; -webkit-backdrop-filter: none; } .app-settings::backdrop { backdrop-filter: none; -webkit-backdrop-filter: none; } }
.login-body { min-height: 100dvh; display: flex; align-items: center; justify-content: center; padding: max(28px,env(safe-area-inset-top)) 20px max(24px,env(safe-area-inset-bottom)); }
.login-shell { width: 100%; max-width: 390px; }
.login-brand { text-align: center; margin-bottom: 28px; }
.login-brand img { margin: 0 auto 14px; filter: drop-shadow(0 6px 24px rgba(117,108,255,.18)); }
.login-brand .eyebrow { font-size: .62rem; margin-bottom: 5px; }
.login-brand h1 { margin: 0; font-size: 1.8rem; letter-spacing: -.04em; }
.login-brand p { font-size: .89rem; color: var(--text-muted); margin: 7px 0 0; }
.login-card { padding: 26px; border: 1px solid rgba(191,203,238,.13); border-radius: 28px; background: linear-gradient(140deg,rgba(35,39,62,.87),rgba(18,27,42,.95)); box-shadow: 0 18px 60px rgba(0,0,0,.24),inset 0 1px rgba(255,255,255,.025); }
.login-card h2 { margin: 0; font-size: 1.25rem; letter-spacing: -.03em; }
.login-intro { margin: 7px 0 24px; color: var(--text-muted); font-size: .83rem; }
.login-card .field-label { margin: 17px 0 8px; font-size: .83rem; }
.login-card .input { width: 100%; min-height: 52px; font-size: 16px; }
.login-card .btn { width: 100%; margin-top: 24px; min-height: 52px; }
.login-footnote { text-align: center; font-size: .69rem; margin: 18px 0 0; color: var(--text-muted); }
.login-error { font-size: .83rem; color: var(--error); margin: 16px 0 -8px; }
.login-outro { text-align: center; font-size: .73rem; line-height: 1.6; margin: 22px 0 0; color: var(--text-dim); }
@media (max-height: 650px) { .login-body { align-items: flex-start; padding-top: 20px; } .login-brand { margin-bottom: 18px; } .login-brand img { width: 56px; height: 56px; margin-bottom: 8px; } .login-outro { margin-top: 16px; } }

.home-command-deck .hero-copy { text-align: left; }
#view-home .section-head { text-align: left; margin: 0 0 14px; }
.home-command-deck .home-link-panel .link-actions { display: grid; grid-template-columns: minmax(0,.8fr) minmax(0,1.2fr); gap: 10px; }
.home-command-deck .home-link-panel .link-actions .btn { min-height: 50px; padding: 12px 10px; font-size: .85rem; }
@media (max-width: 767px) { .home-command-deck .hero { padding-top: 4px; padding-bottom: 22px; } .home-command-deck .home-link-panel { margin-bottom: 22px; } .hero-orb { top: 12px; opacity: .16; } }

/* The legacy off-screen hero sweep must not enlarge the page. */
.home-command-deck .hero::after { content: none; }
