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

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: #0f1419;
  color: #e7ecf3;
  line-height: 1.5;
}

.page {
  max-width: 960px;
  margin: 0 auto;
  padding: 24px 16px 48px;
}

.header {
  margin-bottom: 24px;
}

.header h1 {
  margin: 0 0 8px;
  font-size: 1.75rem;
}

.subtitle {
  margin: 0;
  color: #9aa7b8;
}

.card {
  background: #1a2332;
  border: 1px solid #2a3648;
  border-radius: 12px;
  padding: 20px;
  margin-bottom: 16px;
}

.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

.section-header h2 {
  margin: 0;
  font-size: 1.1rem;
}

.label {
  display: block;
  margin-bottom: 8px;
  font-size: 0.875rem;
  color: #9aa7b8;
}

.input-mode-fieldset {
  border: none;
  margin: 0 0 16px;
  padding: 0;
}

.input-mode-fieldset .label {
  margin-bottom: 10px;
}

.input-mode-options {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
}

.mode-option {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.9rem;
  cursor: pointer;
  color: #cbd5e1;
}

.mode-option input {
  accent-color: #4a90d9;
}

.input-row {
  display: flex;
  gap: 12px;
}

input[type='text'] {
  flex: 1;
  width: 100%;
  padding: 10px 12px;
  border: 1px solid #3a4a60;
  border-radius: 8px;
  background: #0f1419;
  color: #e7ecf3;
  font-size: 0.95rem;
}

input[type='text']:focus {
  outline: 2px solid #4a90d9;
  border-color: #4a90d9;
}

button {
  padding: 10px 18px;
  border: none;
  border-radius: 8px;
  background: #4a90d9;
  color: #fff;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}

button:hover {
  background: #3a7bc8;
}

button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.error {
  margin: 10px 0 0;
  color: #f87171;
  font-size: 0.875rem;
}

.hidden {
  display: none;
}

.section-hint {
  margin: -8px 0 16px;
}

.hint {
  margin: 8px 0 0;
  font-size: 0.8rem;
  color: #9aa7b8;
}

.hint a {
  color: #93c5fd;
}

.hint code {
  font-size: 0.85em;
  background: #0f1419;
  padding: 1px 4px;
  border-radius: 4px;
}

.params-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.param-item {
  background: #0f1419;
  border: 1px solid #2a3648;
  border-radius: 8px;
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.param-item.param-invalid {
  border-color: #7f1d1d;
}

.param-key {
  display: block;
  font-size: 0.75rem;
  color: #9aa7b8;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.param-value {
  display: block;
  font-size: 0.875rem;
  word-break: break-all;
}

.param-control {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid #3a4a60;
  border-radius: 6px;
  background: #1a2332;
  color: #e7ecf3;
  font-size: 0.85rem;
}

.param-control:focus {
  outline: 2px solid #4a90d9;
  border-color: #4a90d9;
}

select.param-control {
  cursor: pointer;
}

.param-input-row {
  display: flex;
  gap: 8px;
  align-items: center;
}

.param-input-row .param-control {
  flex: 1;
}

.param-action-btn {
  padding: 8px 12px;
  font-size: 0.8rem;
  background: #2a3648;
}

.param-action-btn:hover {
  background: #3a4a60;
}

.param-hint {
  font-size: 0.72rem;
  color: #7a8799;
  line-height: 1.35;
}

.param-error {
  font-size: 0.72rem;
  color: #f87171;
}

.param-readonly .param-value {
  color: #cbd5e1;
}

.extra-params-wrap {
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid #2a3648;
  grid-column: 1 / -1;
}

.extra-params-wrap.hidden {
  display: none;
}

.extra-params-title {
  margin: 0 0 12px;
  font-size: 0.9rem;
  font-weight: 600;
  color: #9aa7b8;
}

.extra-params-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 12px;
}

.params-known {
  display: contents;
}

.url-row {
  margin-top: 8px;
}

.copy-row {
  display: flex;
  gap: 8px;
}

.copy-btn {
  padding: 10px 14px;
  background: #2a3648;
  font-size: 0.85rem;
}

.copy-btn:hover {
  background: #3a4a60;
}

.status-badge {
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.status-idle {
  background: #2a3648;
  color: #9aa7b8;
}

.status-loading {
  background: #3d4f6a;
  color: #93c5fd;
}

.status-success {
  background: #14532d;
  color: #86efac;
}

.status-error {
  background: #7f1d1d;
  color: #fca5a5;
}

.status-nofill {
  background: #713f12;
  color: #fcd34d;
}

.status-message {
  margin: 0 0 16px;
  color: #9aa7b8;
  font-size: 0.9rem;
}

.player-wrapper {
  position: relative;
  width: 640px;
  max-width: 100%;
  height: 360px;
  background: #000;
  border-radius: 8px;
  overflow: hidden;
  margin: 0 auto;
}

#content-video,
#ad-container {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
}

#content-video {
  z-index: 0;
}

#ad-container {
  z-index: 1;
}

.url-list {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.url-item {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.url-label {
  font-size: 0.8rem;
  color: #9aa7b8;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.wrapper-urls {
  font-size: 0.875rem;
  word-break: break-all;
  color: #cbd5e1;
}

.wrapper-urls ol {
  margin: 0;
  padding-left: 20px;
}

.debug-summary {
  margin-bottom: 12px;
  font-size: 0.9rem;
  color: #cbd5e1;
}

.debug-summary dl {
  margin: 0;
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 6px 16px;
}

.debug-summary dt {
  color: #9aa7b8;
}

.debug-summary dd {
  margin: 0;
  word-break: break-all;
}

.xml-details {
  margin-top: 12px;
}

.xml-details summary {
  cursor: pointer;
  color: #93c5fd;
  font-size: 0.9rem;
}

.debug-xml {
  margin: 12px 0 0;
  padding: 12px;
  background: #0f1419;
  border: 1px solid #2a3648;
  border-radius: 8px;
  overflow-x: auto;
  font-size: 0.75rem;
  line-height: 1.4;
  max-height: 320px;
  white-space: pre-wrap;
  word-break: break-all;
}

@media (max-width: 680px) {
  .input-row {
    flex-direction: column;
  }

  .player-wrapper {
    height: 240px;
  }
}
