:root {
  color-scheme: light;
  --bg: #f6f3ee;
  --ink: #1c2430;
  --muted: #637083;
  --line: #d9ded7;
  --panel: #fffdf8;
  --feedback-bg: #fffdf8;
  --feedback-border: #d9ded7;
  --media-bg: #232a34;
  --skeleton-start: #e7e2d8;
  --skeleton-mid: #f7f3ea;
  --skeleton-end: #e7e2d8;
  --accent: #0b6f62;
  --accent-strong: #084e47;
  --warm: #b87922;
  --danger: #a63446;
  --ok: #1c7c54;
  --warm-border: rgba(184, 121, 34, 0.28);
  --danger-border: rgba(166, 52, 70, 0.28);
  --ok-border: rgba(28, 124, 84, 0.28);
  --shadow: 0 16px 42px rgba(28, 36, 48, 0.12);
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #111418;
  --ink: #edf2f7;
  --muted: #a4afbd;
  --line: #303946;
  --panel: #191f27;
  --feedback-bg: #191f27;
  --feedback-border: #303946;
  --media-bg: #0f141b;
  --skeleton-start: #202833;
  --skeleton-mid: #303a47;
  --skeleton-end: #202833;
  --accent: #42b8a8;
  --accent-strong: #6bd6c7;
  --warm: #e5b15f;
  --danger: #ff7b91;
  --ok: #73d69b;
  --warm-border: rgba(229, 177, 95, 0.34);
  --danger-border: rgba(255, 123, 145, 0.34);
  --ok-border: rgba(115, 214, 155, 0.34);
  --shadow: 0 16px 42px rgba(0, 0, 0, 0.28);
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

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

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.app {
  width: min(100% - 24px, 680px);
  margin: 0 auto;
  padding: 14px 0 20px;
}

.topbar {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  min-height: 30px;
  margin-bottom: 6px;
}

.language-picker,
.theme-picker {
  width: auto;
}

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

select {
  appearance: none;
  width: auto;
  min-height: 30px;
  padding: 0 34px 0 9px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background:
    linear-gradient(45deg, transparent 50%, var(--muted) 50%) right 17px center / 5px 5px no-repeat,
    linear-gradient(135deg, var(--muted) 50%, transparent 50%) right 12px center / 5px 5px no-repeat,
    var(--panel);
  color: var(--ink);
  font: inherit;
  font-size: 0.82rem;
}

.panel {
  display: grid;
  gap: 22px;
  padding-bottom: 22px;
  border-bottom: 1px solid var(--line);
}

.eyebrow {
  margin: 0 0 10px;
  color: var(--accent);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1 {
  margin: 0;
  max-width: 760px;
  font-size: 2.55rem;
  line-height: 0.98;
}

.intro p:last-child {
  max-width: 560px;
  margin: 14px 0 0;
  color: var(--muted);
  font-size: 1rem;
  line-height: 1.55;
}

.text-action {
  display: inline;
  width: auto;
  min-height: 0;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--accent);
  font-size: inherit;
  font-weight: 650;
}

.text-action:hover {
  background: transparent;
  color: var(--accent-strong);
}

.form {
  display: grid;
  gap: 14px;
  padding: 16px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.credentials,
.actions {
  display: grid;
  gap: 14px;
}

label {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-size: 0.88rem;
  font-weight: 700;
}

.field-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

input {
  width: 100%;
  min-height: 48px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel);
  color: var(--ink);
  font: inherit;
  font-size: 16px;
}

textarea {
  width: 100%;
  min-height: 130px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel);
  color: var(--ink);
  font: inherit;
  font-size: 16px;
  resize: vertical;
}

input::placeholder {
  color: color-mix(in srgb, var(--muted) 58%, transparent);
  opacity: 1;
}

input:focus {
  outline: 3px solid rgba(11, 111, 98, 0.18);
  border-color: var(--accent);
}

.password-field {
  position: relative;
}

.password-field input {
  padding-right: 48px;
}

.password-toggle {
  position: absolute;
  top: 50%;
  right: 10px;
  display: grid;
  place-items: center;
  width: 32px;
  min-width: 32px;
  min-height: 32px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--muted);
  transform: translateY(-50%);
}

.password-toggle:hover {
  background: rgba(11, 111, 98, 0.08);
  color: var(--accent);
}

.password-toggle svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.9;
}

.password-toggle .eye-closed {
  display: none;
}

.password-toggle[aria-pressed="true"] .eye-open {
  display: none;
}

.password-toggle[aria-pressed="true"] .eye-closed {
  display: block;
}

.password-field.shared .password-toggle {
  display: none;
}

.password-field.shared input {
  padding-right: 12px;
}

button {
  min-height: 48px;
  width: 100%;
  border: 0;
  border-radius: 6px;
  background: var(--accent);
  color: #ffffff;
  font: inherit;
  font-weight: 650;
  cursor: pointer;
}

button:hover {
  background: var(--accent-strong);
}

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

button.secondary {
  border: 1px solid rgba(11, 111, 98, 0.32);
  background: var(--panel);
  color: var(--accent);
}

button.secondary:hover {
  background: rgba(11, 111, 98, 0.08);
}

button.inline-action {
  width: auto;
  min-height: 0;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 550;
}

button.inline-action:hover {
  background: transparent;
  color: var(--accent);
}

.results {
  padding: 22px 0 0;
}

.status {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  min-height: 54px;
  padding: 12px 14px;
  border: 1px solid var(--feedback-border);
  border-radius: 8px;
  background: var(--feedback-bg);
  color: var(--muted);
  line-height: 1.45;
}

.status::before {
  content: "";
  width: 10px;
  height: 10px;
  flex: 0 0 auto;
  margin-top: 6px;
  border-radius: 999px;
  background: currentColor;
}

.status.loading {
  border-color: var(--warm-border);
  color: var(--warm);
}

.status.loading::before {
  animation: pulse 1.15s ease-in-out infinite;
}

.status-title {
  display: block;
  color: var(--ink);
  font-weight: 650;
}

.status-detail {
  display: block;
  color: var(--muted);
  font-size: 0.92rem;
}

.status.success {
  border-color: var(--ok-border);
  color: var(--ok);
}

.status.error {
  border-color: var(--danger-border);
  color: var(--danger);
}

:root[data-theme="dark"] .status.loading,
:root[data-theme="dark"] .status.success,
:root[data-theme="dark"] .status.error {
  border-color: var(--feedback-border);
  background: var(--feedback-bg);
}

.metrics {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
  margin-top: 14px;
}

.metric {
  min-height: 68px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.metric span {
  display: block;
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 700;
  text-transform: uppercase;
}

.metric strong {
  display: block;
  margin-top: 6px;
  color: var(--ink);
  font-size: 1rem;
  font-weight: 650;
  overflow-wrap: anywhere;
}

.grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 14px;
  margin-top: 16px;
}

.proof-modal {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(17, 24, 39, 0.58);
}

.proof-dialog {
  display: grid;
  gap: 12px;
  width: min(100%, 560px);
  max-height: calc(100vh - 36px);
  overflow: auto;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.proof-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.proof-header h2 {
  margin: 0;
  font-size: 1.05rem;
  line-height: 1.2;
}

.icon-button {
  display: grid;
  place-items: center;
  width: 34px;
  min-height: 34px;
  padding: 0;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--ink);
  font-size: 1.35rem;
  line-height: 1;
}

.proof-dialog img {
  display: block;
  width: 100%;
  max-width: 480px;
  max-height: min(62vh, 680px);
  object-fit: contain;
  margin: 0 auto;
  border-radius: 6px;
  border: 1px solid var(--line);
}

.proof-actions {
  display: grid;
  gap: 10px;
  justify-self: center;
  width: min(100%, 420px);
}

.feedback-dialog {
  width: min(100%, 520px);
}

.feedback-form {
  display: grid;
  gap: 12px;
}

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

.footer {
  margin-top: 24px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.78rem;
  line-height: 1.45;
}

.footer p {
  margin: 0;
}

.footer-action {
  width: auto;
  min-height: 0;
  margin-top: 10px;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--accent);
  font-size: 0.82rem;
  font-weight: 600;
  text-align: left;
}

.footer-action:hover {
  background: transparent;
  color: var(--accent-strong);
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 18px;
  z-index: 40;
  width: max-content;
  max-width: calc(100vw - 32px);
  padding: 11px 14px;
  border: 1px solid var(--feedback-border);
  border-radius: 999px;
  background: var(--ink);
  color: var(--bg);
  font-size: 0.9rem;
  font-weight: 650;
  box-shadow: var(--shadow);
  transform: translateX(-50%);
}

:root[data-theme="dark"] .toast {
  background: #edf2f7;
  color: #111418;
}

.snapshot {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.snapshot img,
.snapshot .failed,
.snapshot .off-air {
  display: block;
  width: 100%;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  background: var(--media-bg);
}

.snapshot .failed {
  display: grid;
  place-items: center;
  padding: 18px;
  color: #ffffff;
  text-align: center;
  line-height: 1.4;
}

.snapshot .off-air {
  position: relative;
  display: grid;
  place-items: center;
  overflow: hidden;
  background: linear-gradient(
    90deg,
    #ffffff 0 14.28%,
    #f3e547 14.28% 28.56%,
    #00d0d0 28.56% 42.84%,
    #20d04f 42.84% 57.12%,
    #d329d3 57.12% 71.4%,
    #d32629 71.4% 85.68%,
    #2039d0 85.68% 100%
  );
}

.snapshot .off-air::after {
  content: "";
  position: absolute;
  inset: 68% 0 0;
  background: linear-gradient(90deg, #111827 0 24%, #f8fafc 24% 36%, #111827 36% 52%, #6b7280 52% 68%, #000000 68% 100%);
}

.snapshot .off-air span {
  position: relative;
  z-index: 1;
  max-width: calc(100% - 28px);
  padding: 8px 10px;
  border-radius: 6px;
  background: rgba(17, 24, 39, 0.82);
  color: #ffffff;
  font-size: 0.86rem;
  font-weight: 650;
  text-align: center;
}

.snapshot footer {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 12px;
  color: var(--muted);
  font-size: 0.9rem;
}

.snapshot strong {
  color: var(--ink);
  font-weight: 650;
  overflow-wrap: anywhere;
}

.skeleton .preview,
.skeleton .line {
  background: linear-gradient(90deg, var(--skeleton-start) 0%, var(--skeleton-mid) 45%, var(--skeleton-end) 90%);
  background-size: 220% 100%;
  animation: shimmer 1.35s linear infinite;
}

.skeleton .preview {
  width: 100%;
  aspect-ratio: 16 / 9;
}

.skeleton footer {
  display: grid;
  gap: 8px;
}

.skeleton .line {
  height: 12px;
  border-radius: 999px;
}

.skeleton .line.short {
  width: 42%;
}

@keyframes shimmer {
  from {
    background-position: 180% 0;
  }

  to {
    background-position: -60% 0;
  }
}

@keyframes pulse {
  0%,
  100% {
    opacity: 0.35;
    transform: scale(0.88);
  }

  50% {
    opacity: 1;
    transform: scale(1);
  }
}

@media (min-width: 560px) {
  .app {
    width: min(100% - 32px, 920px);
    padding: 18px 0 28px;
  }

  .credentials,
  .actions {
    grid-template-columns: 1fr 1fr;
  }

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

  .proof-actions {
    grid-template-columns: 1fr 1fr;
  }

  .metrics {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (min-width: 960px) {
  .app {
    width: min(1120px, calc(100% - 48px));
    padding: 20px 0 32px;
  }

  .panel {
    grid-template-columns: minmax(0, 0.9fr) minmax(360px, 1.1fr);
    gap: 32px;
    align-items: end;
    padding-bottom: 28px;
  }

  h1 {
    font-size: 4.8rem;
  }

  .form {
    padding: 20px;
  }

  .metrics {
    grid-template-columns: repeat(6, minmax(0, 1fr));
  }

  .grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 16px;
    margin-top: 18px;
  }
}
