:root {
  --primary-color: #ff0000;
  --primary-dark: #cc0000;
  --secondary-color: #282828;
  --accent-color: #00d4aa;
  --background: #0f0f23;
  --surface: #1a1a2e;
  --surface-light: #16213e;
  --text-primary: #ffffff;
  --text-secondary: #aaaaaa;
  --text-muted: #666666;
  --border: #333333;
  --border-light: #444444;
  --shadow: 0 4px 6px rgba(0, 0, 0, 0.3);
  --shadow-large: 0 10px 25px rgba(0, 0, 0, 0.4);
  --border-radius: 8px;
  --border-radius-small: 4px;
  --transition: all 0.3s ease;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

.is-hidden {
  display: none !important;
}

body {
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  background: var(--background);
  color: var(--text-primary);
  font-size: 15px;
  line-height: 1.55;
  min-height: 100vh;
}

.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 20px;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 30px;
}

.app[data-connection='offline'] .video-input__btn {
  opacity: 0.7;
  cursor: not-allowed;
}

.header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px 30px;
  background: linear-gradient(
    135deg,
    var(--surface) 0%,
    var(--surface-light) 100%
  );
  border-radius: var(--border-radius);
  box-shadow: var(--shadow);
}
.header__title {
  font-size: 1.95rem;
  font-weight: 700;
  color: var(--primary-color);
  margin: 0;
  text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.5);
}
.header__controls {
  display: flex;
  gap: 10px;
  align-items: center;
}
.header-btn {
  padding: 8px 16px;
  border: none;
  border-radius: 6px;
  font-size: 0.86rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  text-transform: uppercase;
  letter-spacing: 0.3px;
  white-space: nowrap;
}
.header-btn--primary {
  background: var(--primary-color);
  color: white;
}
.header-btn--primary:hover {
  background: var(--primary-dark);
}
.header-btn--secondary {
  background: var(--text-muted);
  color: white;
}
.header-btn--secondary:hover {
  background: var(--text-secondary);
}
.header-btn--accent {
  background: var(--accent-color);
  color: var(--background);
}
.header-btn--accent:hover {
  background: #00b894;
}
.header-btn--accent.is-loop-off {
  background: #666666;
  color: #ffffff;
}
.header-btn--accent.is-loop-off:hover {
  background: #555555;
}
.header__subtitle {
  font-size: 1.05rem;
  color: var(--text-secondary);
  font-weight: 300;
}

.main {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 30px;
}
.main__content-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 30px;
  align-items: start;
}
@media (max-width: 1024px) {
  .main__content-grid {
    grid-template-columns: 1fr;
  }
}

.video-input {
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  gap: 10px;
  background:
    linear-gradient(
      135deg,
      rgba(255, 255, 255, 0.015) 0%,
      rgba(255, 0, 0, 0.06) 100%
    ),
    var(--surface);
  padding: 22px;
  border-radius: calc(var(--border-radius) + 2px);
  box-shadow: var(--shadow);
  border: 1px solid rgba(255, 255, 255, 0.1);
}
.video-input::before {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(
    circle at 100% 0%,
    rgba(255, 0, 0, 0.14) 0%,
    transparent 45%
  );
  pointer-events: none;
}
.video-input__meta {
  position: relative;
  z-index: 1;
  max-width: none;
  margin: 0 0 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
@media (max-width: 768px) {
  .video-input__meta {
    flex-wrap: wrap;
    gap: 8px;
  }
}
.video-input__label {
  font-size: 0.86rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #e9e9f8;
}
.video-input__tag {
  font-size: 0.68rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: #ffe8e8;
  background: rgba(255, 0, 0, 0.14);
  border: 1px solid rgba(255, 0, 0, 0.3);
  padding: 4px 8px;
  border-radius: 999px;
  white-space: nowrap;
}
.video-input__container {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: start;
  gap: 10px;
  max-width: none;
  margin: 0;
}
@media (max-width: 768px) {
  .video-input__container {
    grid-template-columns: 1fr;
  }
}
.video-input__field-wrap {
  position: relative;
}
.video-input__sr-label {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}
.video-input__icon {
  position: absolute;
  left: 16px;
  top: 16px;
  width: 22px;
  height: 22px;
  fill: var(--text-muted);
  transition: var(--transition);
  pointer-events: none;
}
.video-input__field-wrap:focus-within .video-input__icon {
  fill: var(--primary-color);
  transform: scale(1.05);
}
.video-input__field {
  width: 100%;
  padding: 16px 18px 16px 50px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 14px;
  background: rgba(15, 15, 35, 0.8);
  color: var(--text-primary);
  font-size: 0.95rem;
  transition: var(--transition);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08);
}
.video-input__field:focus {
  outline: none;
  border-color: rgba(255, 0, 0, 0.8);
  box-shadow:
    0 0 0 4px rgba(255, 0, 0, 0.15),
    inset 0 1px 0 rgba(255, 255, 255, 0.12);
}
.video-input__field::placeholder {
  color: #7f8599;
}
.video-input__field:disabled {
  opacity: 0.65;
  cursor: not-allowed;
}
.video-input__hint {
  margin-top: 6px;
  margin-left: 2px;
  font-size: 0.75rem;
  line-height: 1.35;
  color: #959bb0;
}
.video-input__btn {
  height: 56px;
  padding: 0 22px;
  background: linear-gradient(135deg, #ff2c2c 0%, #cc0000 100%);
  color: white;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 14px;
  font-size: 0.92rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  cursor: pointer;
  transition: var(--transition);
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  box-shadow: 0 10px 18px rgba(204, 0, 0, 0.3);
}
.video-input__btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 14px 24px rgba(204, 0, 0, 0.4);
  filter: saturate(1.1);
}
.video-input__btn:active {
  transform: translateY(0);
  box-shadow: 0 8px 16px rgba(204, 0, 0, 0.3);
}
.video-input__btn:disabled {
  opacity: 0.7;
  cursor: not-allowed;
  transform: none;
  filter: none;
  box-shadow: none;
}
@media (max-width: 768px) {
  .video-input__btn {
    width: 100%;
  }
}
.video-input__btn-icon {
  width: 18px;
  height: 18px;
  stroke: currentColor;
  stroke-width: 2.4;
  stroke-linecap: round;
  stroke-linejoin: round;
  fill: none;
}

.video-player {
  background: var(--surface);
  border-radius: var(--border-radius);
  overflow: hidden;
  box-shadow: var(--shadow-large);
  border: 1px solid var(--border);
}
.video-player__container {
  position: relative;
  width: 100%;
  height: 360px;
  background: var(--background);
  display: flex;
  align-items: center;
  justify-content: center;
}
.video-player__container iframe {
  width: 100%;
  height: 100%;
}
.video-player__placeholder {
  text-align: center;
  color: var(--text-muted);
}
.video-player__placeholder p {
  margin-top: 20px;
  font-size: 1.05rem;
}
.video-player__icon {
  width: 80px;
  height: 80px;
  fill: var(--text-muted);
  opacity: 0.5;
}

.video-controls {
  padding: 25px;
  background: var(--surface-light);
  border-top: 1px solid var(--border);
}
.video-controls__info {
  margin-bottom: 20px;
}
.video-controls__title {
  font-size: 1.2rem;
  color: var(--text-primary);
  margin-bottom: 8px;
  font-weight: 600;
}
.video-controls__title:focus-visible {
  outline: 2px solid var(--primary-color);
  outline-offset: 4px;
}
.video-controls__loops {
  font-size: 0.92rem;
  color: var(--accent-color);
  font-weight: 500;
}
.video-controls__loops span {
  font-weight: 700;
  font-size: 1rem;
}
.video-controls__buttons {
  display: flex;
  gap: 15px;
  flex-wrap: wrap;
}
@media (max-width: 768px) {
  .video-controls__buttons {
    flex-direction: column;
  }
}

.btn {
  padding: 11px 20px;
  border: none;
  border-radius: var(--border-radius);
  font-size: 0.92rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.btn--primary {
  background: var(--primary-color);
  color: white;
}
.btn--primary:hover {
  background: var(--primary-dark);
  transform: translateY(-2px);
  box-shadow: var(--shadow);
}
.btn--secondary {
  background: var(--text-muted);
  color: white;
}
.btn--secondary:hover {
  background: var(--text-secondary);
  transform: translateY(-2px);
}
.btn--accent {
  background: var(--accent-color);
  color: var(--background);
}
.btn--accent:hover {
  background: #00b894;
  transform: translateY(-2px);
}
.btn--accent.is-loop-off {
  background: #666666;
  color: #ffffff;
}
.btn--accent.is-loop-off:hover {
  background: #555555;
}
.btn:active {
  transform: translateY(0);
}

.history {
  background: var(--surface);
  padding: 24px;
  border-radius: var(--border-radius);
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.history__title {
  font-size: 1.35rem;
  color: var(--text-primary);
  margin-bottom: 0;
  font-weight: 600;
  text-align: left;
  letter-spacing: 0.01em;
}
.history__list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-height: 360px;
  overflow-y: auto;
  padding-right: 6px;
}
.history__list::-webkit-scrollbar {
  width: 6px;
}
.history__list::-webkit-scrollbar-track {
  background: var(--background);
  border-radius: 3px;
}
.history__list::-webkit-scrollbar-thumb {
  background: var(--border-light);
  border-radius: 3px;
}
.history__list::-webkit-scrollbar-thumb:hover {
  background: var(--text-muted);
}
.history__empty {
  text-align: center;
  color: var(--text-muted);
  font-style: italic;
  padding: 24px;
  font-size: 0.96rem;
}
.history__item {
  display: flex;
  flex-direction: column;
  gap: 6px;
  width: 100%;
  text-align: left;
  font: inherit;
  color: inherit;
  appearance: none;
  background:
    linear-gradient(
      180deg,
      rgba(255, 255, 255, 0.03) 0%,
      rgba(255, 255, 255, 0) 100%
    ),
    var(--background);
  padding: 13px 14px;
  border-radius: calc(var(--border-radius) + 1px);
  border: 1px solid var(--border);
  border-inline-start: 3px solid transparent;
  transition: var(--transition);
  cursor: pointer;
}
.history__item:hover {
  border-color: rgba(255, 0, 0, 0.55);
  border-inline-start-color: var(--primary-color);
  box-shadow: var(--shadow);
  transform: translateY(-1px);
}
.history__item:focus-visible {
  outline: 2px solid var(--primary-color);
  outline-offset: 2px;
}
.history__item:disabled {
  opacity: 0.55;
  cursor: wait;
}
.history__item:disabled:hover {
  border-color: var(--border);
  border-inline-start-color: transparent;
  box-shadow: none;
  transform: none;
}
.history__item.is-current {
  border-color: var(--accent-color);
  border-inline-start-color: var(--accent-color);
  background:
    linear-gradient(
      180deg,
      rgba(0, 212, 170, 0.14) 0%,
      rgba(255, 255, 255, 0) 100%
    ),
    var(--background);
}
.history__item-title {
  font-size: 0.98rem;
  color: var(--text-primary);
  margin-bottom: 2px;
  line-height: 1.35;
  font-weight: 600;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.history__item-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.82rem;
  color: var(--text-secondary);
}
@media (max-width: 768px) {
  .history__item-meta {
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
  }
}
.history__item-loops {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 999px;
  border: 1px solid rgba(0, 212, 170, 0.3);
  background: rgba(0, 212, 170, 0.14);
  color: var(--accent-color);
  font-weight: 700;
  letter-spacing: 0.03em;
}
.history__item-date {
  color: var(--text-muted);
  font-size: 0.78rem;
}

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

.toast-region {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-width: min(320px, calc(100vw - 32px));
}

.toast {
  border-radius: 8px;
  padding: 12px 16px;
  box-shadow: var(--shadow);
  font-weight: 600;
  border: 1px solid transparent;
}

.toast--error {
  background: #ff4444;
  color: #ffffff;
  border-color: rgba(255, 255, 255, 0.25);
}

.toast--info {
  background: #2f5fff;
  color: #ffffff;
  border-color: rgba(255, 255, 255, 0.2);
}

.toast--warning {
  background: #ffb020;
  color: #111111;
  border-color: rgba(0, 0, 0, 0.2);
}

@media (max-width: 768px) {
  .container {
    padding: 15px;
    gap: 20px;
  }
  .header {
    flex-direction: column;
    gap: 15px;
    padding: 20px;
  }
  .header__title {
    font-size: 1.55rem;
  }
  .header__controls {
    flex-wrap: wrap;
    justify-content: center;
  }
  .header__subtitle {
    font-size: 0.92rem;
  }
  .video-input {
    padding: 16px;
    gap: 8px;
  }
  .video-player__container {
    height: 300px;
  }
  .video-controls {
    padding: 20px;
  }
  .history {
    padding: 18px;
  }
}
