:root {
  --ink: #17243b;
  --muted: #7f8aa3;
  --line: #dce1eb;
  --soft: #eef1f7;
  --accent: #0076f4;
  --accent-dark: #0066f4;
  --danger: #dc4d5f;
  --success: #208353;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100%;
  font-family: Arial, Helvetica, sans-serif;
  background: #fff;
  color: var(--ink);
}

body {
  min-height: 100vh;
  padding: 20px 18px 50px;
}

.page {
  width: min(962px, 100%);
  margin: 0 auto;
}

.hero {
  text-align: center;
  padding-top: 0;
}

h1 {
  margin: 0;
  font-size: 50px;
  line-height: 1.08;
  letter-spacing: 0;
  font-weight: 800;
  color: var(--ink);
}

.subtitle {
  margin: 15px 0 0;
  font-size: 22px;
  line-height: 1.35;
  color: #101827;
}

.converter {
  width: 90%;
  margin: 20px auto 0;
}

.url-toolbar {
  min-height: 52px;
  display: flex;
  align-items: stretch;
  border: 1px solid var(--line);
  border-bottom: none;
  background: #fff;
}

.url-icon {
  width: 52px;
  display: grid;
  place-items: center;
  background: var(--soft);
  color: var(--accent);
  border-right: 1px solid var(--line);
}

.url-icon svg {
  width: 23px;
  height: 23px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.url-input {
  min-width: 0;
  flex: 1;
  border: 0;
  outline: 0;
  padding: 0 15px;
  font: inherit;
  font-size: 16px;
  color: #05070b;
  background: #fff;
}

.url-input::placeholder { color: #9aa3b5; }

.fetch-button {
  min-width: 138px;
  border: 0;
  border-left: 1px solid var(--line);
  background: var(--soft);
  color: var(--accent);
  font: inherit;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  padding: 0 18px;
}

.fetch-button:hover:not(:disabled) { background: #e7eaf1; }

.fetch-button:disabled,
.convert-button:disabled,
.setting-select-main:disabled,
.cookie-option input:disabled {
  opacity: .48;
  cursor: default;
}

.video-panel {
  border: 1px solid var(--line);
  background: #fff;
  overflow: hidden;
}

.empty-state {
  min-height: 118px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 22px;
  color: var(--muted);
  font-size: 17px;
}

.video-info {
  min-height: 118px;
  display: flex;
  align-items: center;
  padding: 12px 15px;
  gap: 17px;
}

.thumbnail-wrap {
  width: 160px;
  aspect-ratio: 16 / 9;
  background: var(--soft);
  flex: 0 0 auto;
  overflow: hidden;
}

.thumbnail-wrap img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.video-meta {
  min-width: 0;
  flex: 1;
}

.video-title {
  color: #05070b;
  font-size: 18px;
  font-weight: 600;
  line-height: 1.35;
  margin-bottom: 10px;
}

.video-submeta {
  display: flex;
  gap: 18px;
  flex-wrap: wrap;
  color: var(--muted);
  font-size: 14px;
}

.settings-panel-main {
  min-height: 58px;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-top: none;
  background: #fff;
}

.settings-grid-main {
  min-height: 40px;
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
}

.setting-block {
  display: flex;
  align-items: center;
  gap: 7px;
  color: var(--muted);
  font-size: 13px;
  white-space: nowrap;
}

.setting-select-main {
  appearance: none;
  -webkit-appearance: none;
  height: 36px;
  min-width: 125px;
  border: 1px solid var(--accent);
  border-radius: 0;
  background: #fff;
  color: var(--accent);
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  text-align: center;
  text-align-last: center;
  padding: 0 31px 0 12px;
  cursor: pointer;
  background-image:
    linear-gradient(45deg, transparent 50%, var(--accent) 50%),
    linear-gradient(135deg, var(--accent) 50%, transparent 50%);
  background-position:
    calc(100% - 15px) 16px,
    calc(100% - 10px) 16px;
  background-size: 6px 6px, 6px 6px;
  background-repeat: no-repeat;
}

.setting-select-main:focus,
.url-input:focus {
  outline: 1px solid var(--accent);
  outline-offset: -1px;
}

.cookie-option {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 7px;
  color: var(--muted);
  font-size: 13px;
  cursor: pointer;
  white-space: nowrap;
}

.cookie-option input {
  width: 16px;
  height: 16px;
  accent-color: var(--accent);
  cursor: pointer;
}

.progress-panel {
  min-height: 70px;
  border: 1px solid var(--line);
  border-top: none;
  padding: 13px 15px 10px;
  background: #fff;
}

.progress-row {
  display: flex;
  align-items: center;
  gap: 13px;
}

.progress-track {
  flex: 1;
  height: 9px;
  background: #e8eaf2;
  overflow: hidden;
}

.progress-fill {
  width: 0;
  height: 100%;
  background: #e58a00;
  transition: width .18s ease, background-color .18s ease;
}

.progress-fill.complete { background: var(--success); }
.progress-fill.error { background: var(--danger); }

.progress-percent {
  width: 46px;
  text-align: right;
  color: #65708a;
  font-size: 14px;
  font-variant-numeric: tabular-nums;
}

.progress-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 10px;
  color: var(--muted);
  font-size: 13px;
}

.footer-bar {
  min-height: 66px;
  background: var(--soft);
  display: flex;
  align-items: center;
  overflow: hidden;
}

.count {
  padding: 0 25px;
  font-size: 18px;
  color: #05070b;
  flex: 1;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.convert-button {
  align-self: stretch;
  min-width: 175px;
  border: 0;
  background: var(--accent);
  color: #fff;
  font: inherit;
  font-size: 22px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 25px;
}

.convert-button:hover:not(:disabled) { background: var(--accent-dark); }

.status-wrap {
  min-height: 38px;
  padding-top: 13px;
}

#status {
  font-size: 15px;
  color: #66718a;
}

#status.success { color: var(--success); }
#status.error { color: #b72e42; }

.details-button {
  border: 0;
  background: transparent;
  padding: 0;
  color: var(--accent);
  cursor: pointer;
  font: inherit;
  font-size: 13px;
}

pre {
  display: none;
  white-space: pre-wrap;
  word-break: break-word;
  margin: 12px 0 0;
  padding: 12px;
  background: #111827;
  color: #e5e7eb;
  max-height: 320px;
  overflow: auto;
  font-size: 12px;
}

pre.show { display: block; }

.runtime-info {
  margin-top: 14px;
  color: #9aa3b5;
  font-size: 11px;
  line-height: 1.55;
  word-break: break-word;
}

[hidden] { display: none !important; }

@media (max-width: 760px) {
  h1 { font-size: 42px; }
  .subtitle { font-size: 19px; }
  .converter { width: 100%; margin-top: 21px; }
  .cookie-option { margin-left: 0; }
  .settings-grid-main { align-items: flex-start; }
  .convert-button { min-width: 155px; font-size: 20px; }
}

@media (max-width: 560px) {
  body { padding-left: 10px; padding-right: 10px; }
  h1 { font-size: 34px; }
  .subtitle { font-size: 17px; }

  .url-toolbar { flex-wrap: wrap; }
  .url-icon { width: 46px; min-height: 48px; }
  .url-input { min-height: 48px; width: calc(100% - 46px); }
  .fetch-button {
    min-height: 46px;
    flex-basis: 100%;
    border-left: 0;
    border-top: 1px solid var(--line);
  }

  .video-info { align-items: flex-start; }
  .thumbnail-wrap { width: 122px; }
  .video-title { font-size: 16px; }

  .setting-block { width: 100%; justify-content: space-between; }
  .setting-select-main { min-width: 170px; }
  .cookie-option { width: 100%; }

  .footer-bar { min-height: 68px; }
  .count { padding-left: 16px; font-size: 15px; }
  .convert-button { min-width: 132px; padding: 0 18px; font-size: 18px; }
}
