:root {
  color-scheme: light;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  background: #f5f7fa;
  color: #17191d;
  margin: 0;
  min-height: 100vh;
}

button,
textarea {
  font: inherit;
}

.app {
  margin: 0 auto;
  max-width: 820px;
  padding: max(18px, env(safe-area-inset-top)) 14px max(28px, env(safe-area-inset-bottom));
}

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

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

.brand-icon {
  align-items: center;
  background: #111827;
  border-radius: 8px;
  color: #fff;
  display: flex;
  flex: 0 0 auto;
  font-size: 24px;
  font-weight: 900;
  height: 48px;
  justify-content: center;
  width: 48px;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 24px;
  line-height: 1.2;
}

h2 {
  font-size: 19px;
  line-height: 1.3;
  margin-top: 8px;
}

.brand p,
.hint {
  color: #697280;
  font-size: 14px;
  line-height: 1.45;
  margin-top: 5px;
}

.nav-link {
  align-items: center;
  background: #fff;
  border: 1px solid #d8dee8;
  border-radius: 8px;
  color: #1f2937;
  display: inline-flex;
  font-size: 14px;
  font-weight: 800;
  min-height: 40px;
  padding: 0 12px;
  text-decoration: none;
  white-space: nowrap;
}

.panel {
  background: #fff;
  border: 1px solid #e1e6ef;
  border-radius: 8px;
  box-shadow: 0 12px 34px rgba(24, 30, 41, 0.06);
  margin-bottom: 14px;
  padding: 18px;
}

.parse-form,
.result,
.field {
  display: grid;
  gap: 12px;
}

label {
  color: #374151;
  font-size: 14px;
  font-weight: 800;
}

textarea {
  background: #fff;
  border: 1px solid #d9e0ea;
  border-radius: 8px;
  color: #17191d;
  line-height: 1.5;
  outline: none;
  padding: 12px;
  resize: vertical;
  width: 100%;
}

textarea:focus {
  border-color: #111827;
  box-shadow: 0 0 0 3px rgba(17, 24, 39, 0.08);
}

textarea[readonly] {
  background: #f8fafc;
  color: #334155;
  font-family: ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", monospace;
  font-size: 12px;
  word-break: break-all;
}

button {
  background: #111827;
  border: 0;
  border-radius: 8px;
  color: #fff;
  cursor: pointer;
  font-weight: 850;
  min-height: 44px;
  padding: 0 14px;
}

button.secondary {
  background: #eef2f7;
  color: #1f2937;
}

button:active {
  transform: translateY(1px);
}

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

.form-actions,
.downloads {
  display: grid;
  gap: 10px;
}

.form-actions {
  grid-template-columns: minmax(0, 1fr) 110px;
}

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

.status {
  color: #4b5563;
  font-size: 14px;
  line-height: 1.45;
  min-height: 20px;
}

.status[data-kind="ok"] {
  color: #15803d;
}

.status[data-kind="error"] {
  color: #b42318;
}

.result-head {
  align-items: start;
  display: grid;
  gap: 12px;
  grid-template-columns: 1fr 124px;
}

.badge {
  background: #dcfce7;
  border-radius: 999px;
  color: #15803d;
  display: inline-flex;
  font-size: 12px;
  font-weight: 900;
  padding: 6px 9px;
}

.cover {
  background: #eef2f7;
  border-radius: 8px;
  display: none;
  height: 124px;
  object-fit: cover;
  width: 124px;
}

.cover[src] {
  display: block;
}

.preview {
  background: #111827;
  border-radius: 8px;
  display: block;
  max-height: 520px;
  width: 100%;
}

.preview[hidden] {
  display: none;
}

#download-video {
  background: #0f766e;
}

#download-full {
  background: #16a34a;
}

#download-cover {
  background: #7c3aed;
}

@media (max-width: 620px) {
  .topbar {
    align-items: stretch;
    flex-direction: column;
  }

  .nav-link {
    justify-content: center;
  }

  .panel {
    padding: 15px;
  }

  .result-head {
    grid-template-columns: 1fr 96px;
  }

  .cover {
    height: 96px;
    width: 96px;
  }

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