:root {
  color-scheme: light;
  --bg: #f7f8fb;
  --surface: #ffffff;
  --surface-soft: #f0f4f8;
  --text: #17202a;
  --muted: #5f6f82;
  --border: #d8e0ea;
  --accent: #e8334f;
  --accent-dark: #c91f3a;
  --focus: #1677ff;
  --success: #117a54;
  --danger: #b3261e;
  --shadow: 0 18px 55px rgb(20 31 48 / 10%);
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--text);
  background:
    linear-gradient(135deg, rgb(232 51 79 / 8%), transparent 34%),
    linear-gradient(315deg, rgb(22 119 255 / 9%), transparent 32%),
    var(--bg);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  line-height: 1.5;
}

button,
input,
textarea {
  font: inherit;
}

button {
  border: 0;
  cursor: pointer;
}

img {
  display: block;
  max-width: 100%;
}

.site-header,
.site-footer {
  width: min(1120px, calc(100% - 32px));
  margin: 0 auto;
}

.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 18px 0 0;
}

.brand,
.site-nav {
  display: inline-flex;
  align-items: center;
}

.brand {
  gap: 10px;
  color: var(--text);
  font-weight: 850;
  text-decoration: none;
}

.brand-mark {
  width: 30px;
  height: 22px;
  background: var(--accent);
  border-radius: 6px;
  position: relative;
}

.brand-mark::after {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 0;
  height: 0;
  border-top: 5px solid transparent;
  border-bottom: 5px solid transparent;
  border-left: 8px solid #fff;
  content: "";
  transform: translate(-35%, -50%);
}

.tools-mark {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 4px;
  padding: 4px;
  background: var(--text);
}

.tools-mark::after {
  position: static;
  width: auto;
  height: auto;
  border: 0;
  background:
    linear-gradient(#fff 0 0) left top / 7px 5px no-repeat,
    linear-gradient(#fff 0 0) right top / 7px 5px no-repeat,
    linear-gradient(#fff 0 0) left bottom / 7px 5px no-repeat,
    linear-gradient(#fff 0 0) right bottom / 7px 5px no-repeat;
  content: "";
  transform: none;
}

.site-nav {
  gap: 6px;
}

.site-nav a {
  padding: 8px 10px;
  color: var(--muted);
  border-radius: 8px;
  font-size: 0.94rem;
  font-weight: 750;
  text-decoration: none;
}

.site-nav a:hover {
  color: var(--text);
  background: rgb(255 255 255 / 68%);
}

.app-shell {
  width: min(1120px, calc(100% - 32px));
  margin: 0 auto;
  padding: 38px 0;
}

.home-intro {
  padding: clamp(12px, 3vw, 28px) 0 10px;
}

.tool,
.results {
  background: rgb(255 255 255 / 86%);
  border: 1px solid rgb(216 224 234 / 86%);
  border-radius: 8px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(16px);
}

.tool {
  padding: clamp(24px, 5vw, 48px);
}

.intro {
  max-width: 760px;
}

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

h1,
h2 {
  margin: 0;
  line-height: 1.08;
  letter-spacing: 0;
}

h1 {
  max-width: 760px;
  font-size: clamp(2rem, 6vw, 4.25rem);
}

h2 {
  font-size: clamp(1.35rem, 3vw, 2rem);
}

.lede {
  max-width: 640px;
  margin: 16px 0 0;
  color: var(--muted);
  font-size: clamp(1rem, 2vw, 1.18rem);
}

.tool-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 280px), 1fr));
  gap: 16px;
  margin-top: 28px;
}

.tool-link {
  display: grid;
  grid-template-columns: 52px minmax(0, 1fr);
  gap: 16px;
  align-items: center;
  min-height: 104px;
  padding: 18px;
  color: var(--text);
  background: rgb(255 255 255 / 86%);
  border: 1px solid rgb(216 224 234 / 86%);
  border-radius: 8px;
  box-shadow: var(--shadow);
  text-decoration: none;
  transition: border-color 160ms ease, box-shadow 160ms ease, transform 160ms ease;
}

.tool-link:hover {
  border-color: #aeb9c7;
  box-shadow: 0 22px 60px rgb(20 31 48 / 14%);
  transform: translateY(-2px);
}

.tool-icon {
  width: 52px;
  height: 52px;
  border-radius: 8px;
}

.youtube-icon {
  position: relative;
  background: var(--accent);
}

.youtube-icon::after {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 0;
  height: 0;
  border-top: 8px solid transparent;
  border-bottom: 8px solid transparent;
  border-left: 13px solid #fff;
  content: "";
  transform: translate(-35%, -50%);
}

.tag-icon::before {
  position: absolute;
  right: 8px;
  bottom: 8px;
  width: 12px;
  height: 12px;
  background: #fff;
  border-radius: 50%;
  content: "";
}

.json-icon {
  position: relative;
  display: grid;
  place-items: center;
  background: var(--text);
}

.json-icon::before,
.json-icon::after {
  color: #fff;
  font-size: 1.28rem;
  font-weight: 900;
  line-height: 1;
}

.json-icon::before {
  content: "{";
  transform: translateX(-5px);
}

.json-icon::after {
  position: absolute;
  content: "}";
  transform: translateX(5px);
}

.webp-icon {
  position: relative;
  display: grid;
  place-items: center;
  background: #117a54;
}

.webp-icon::before {
  width: 28px;
  height: 22px;
  background:
    linear-gradient(135deg, transparent 0 52%, #117a54 53%) right bottom / 12px 10px no-repeat,
    #fff;
  border-radius: 4px;
  content: "";
}

.webp-icon::after {
  position: absolute;
  bottom: 14px;
  width: 18px;
  height: 7px;
  background:
    radial-gradient(circle at 4px 4px, #117a54 0 3px, transparent 3.5px),
    linear-gradient(135deg, transparent 0 42%, #117a54 43% 58%, transparent 59%);
  content: "";
}

.tool-title,
.tool-summary {
  display: block;
}

.tool-title {
  font-size: 1.05rem;
  font-weight: 850;
}

.tool-summary {
  margin-top: 4px;
  color: var(--muted);
  font-size: 0.94rem;
}

.search-form {
  margin-top: 34px;
}

.search-form label {
  display: inline-block;
  margin-bottom: 10px;
  font-weight: 750;
}

.input-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
}

input {
  width: 100%;
  min-height: 56px;
  padding: 0 16px;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  outline: none;
  transition: border-color 160ms ease, box-shadow 160ms ease;
}

input:focus {
  border-color: var(--focus);
  box-shadow: 0 0 0 4px rgb(22 119 255 / 14%);
}

.json-tool {
  padding-bottom: clamp(18px, 4vw, 36px);
}

.tool-command-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-top: 30px;
  padding: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
}

.tool-command-bar[hidden],
.output-actions[hidden] {
  display: none;
}

.tool-command-bar .message {
  min-width: min(100%, 260px);
  margin: 0;
  text-align: right;
}

.json-workspace {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 18px;
  margin-top: 18px;
}

.json-panel {
  display: grid;
  gap: 12px;
  min-width: 0;
  padding: 14px;
  background: rgb(255 255 255 / 74%);
  border: 1px solid var(--border);
  border-radius: 8px;
}

.panel-heading {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 14px;
}

.panel-heading h2 {
  font-size: clamp(1.2rem, 2vw, 1.55rem);
}

.json-textarea,
.json-code {
  width: 100%;
  min-height: 680px;
  margin: 0;
  padding: 16px;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  font-family: ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", monospace;
  font-size: 0.94rem;
  line-height: 1.58;
  outline: none;
  overflow: auto;
  tab-size: 2;
}

.json-textarea {
  resize: vertical;
}

.json-textarea:focus,
.json-code:focus {
  border-color: var(--focus);
  box-shadow: 0 0 0 4px rgb(22 119 255 / 14%);
}

.json-code {
  white-space: pre;
}

.json-code code {
  font: inherit;
}

.json-actions,
.output-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.json-actions {
  align-items: center;
}

.json-actions .primary-button,
.json-actions .action-button,
.output-actions .action-button {
  min-height: 42px;
}

.json-actions .primary-button {
  min-width: 124px;
}

.json-stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin: 0;
}

.json-stats div {
  padding: 10px;
  background: var(--surface-soft);
  border: 1px solid var(--border);
  border-radius: 8px;
}

.json-stats dt {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
}

.json-stats dd {
  margin: 3px 0 0;
  font-weight: 850;
}

.json-results {
  overflow: hidden;
}

.json-tree {
  min-height: 220px;
  max-height: 560px;
  padding: 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  font-family: ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", monospace;
  font-size: 0.92rem;
  overflow: auto;
}

.tree-node,
.tree-leaf {
  margin: 4px 0;
}

.tree-node summary {
  cursor: pointer;
  list-style-position: outside;
}

.tree-children {
  margin-left: 18px;
  padding-left: 12px;
  border-left: 1px solid var(--border);
}

.tree-key {
  margin-right: 8px;
  color: var(--accent-dark);
  font-weight: 850;
}

.tree-meta,
.tree-empty {
  color: var(--muted);
}

.tree-leaf {
  display: flex;
  gap: 2px;
  padding-left: 18px;
}

.tree-value {
  color: #235a35;
  overflow-wrap: anywhere;
}

.tree-leaf.number .tree-value,
.tree-leaf.boolean .tree-value {
  color: #165fad;
}

.tree-leaf.null .tree-value {
  color: var(--muted);
}

.empty-state {
  margin: 0;
  color: var(--muted);
}

.converter-tool {
  display: grid;
  gap: 24px;
}

.format-strip {
  display: inline-grid;
  grid-template-columns: auto auto auto;
  align-items: center;
  gap: 10px;
  justify-self: start;
  padding: 8px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
}

.format-strip span {
  padding: 8px 12px;
  color: var(--muted);
  font-weight: 850;
}

.format-strip span:first-child,
.format-strip span:last-child {
  color: var(--text);
  background: var(--surface-soft);
  border-radius: 8px;
}

.converter-form {
  display: grid;
  gap: 18px;
}

.drop-zone {
  display: grid;
  place-items: center;
  min-height: 280px;
  padding: clamp(24px, 5vw, 48px);
  text-align: center;
  background:
    linear-gradient(135deg, rgb(17 122 84 / 8%), transparent 42%),
    var(--surface);
  border: 2px dashed #b6c4d4;
  border-radius: 8px;
  cursor: pointer;
  transition: border-color 160ms ease, background 160ms ease, box-shadow 160ms ease;
}

.drop-zone:hover,
.drop-zone.is-dragging {
  background:
    linear-gradient(135deg, rgb(17 122 84 / 12%), transparent 46%),
    var(--surface);
  border-color: var(--success);
  box-shadow: 0 0 0 4px rgb(17 122 84 / 10%);
}

.drop-zone input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.drop-icon {
  width: 64px;
  height: 64px;
  margin-bottom: 14px;
  border-radius: 8px;
}

.image-icon {
  position: relative;
  background: var(--text);
}

.image-icon::before {
  position: absolute;
  inset: 15px;
  background:
    radial-gradient(circle at 10px 10px, #17202a 0 4px, transparent 4.5px),
    linear-gradient(135deg, transparent 0 40%, #17202a 41% 58%, transparent 59%),
    #fff;
  border-radius: 5px;
  content: "";
}

.drop-title,
.drop-copy {
  display: block;
}

.drop-title {
  font-size: clamp(1.35rem, 3vw, 2rem);
  font-weight: 850;
}

.drop-copy {
  margin-top: 6px;
  color: var(--muted);
  font-weight: 700;
}

.converter-controls {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) auto auto;
  gap: 12px;
  align-items: end;
}

.quality-control {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px 14px;
  padding: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  font-weight: 800;
}

.quality-control input {
  grid-column: 1 / -1;
  min-height: auto;
  padding: 0;
  accent-color: var(--accent);
}

.converted-list {
  display: grid;
  gap: 12px;
}

.converted-row {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) auto minmax(180px, 0.8fr) auto;
  gap: 16px;
  align-items: center;
  padding: 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
}

.file-cell {
  display: grid;
  grid-template-columns: 48px minmax(0, 1fr);
  gap: 14px;
  align-items: center;
  min-width: 0;
}

.file-icon {
  width: 48px;
  height: 48px;
  border-radius: 6px;
}

.file-cell h3 {
  margin: 0;
  font-size: 1.02rem;
  line-height: 1.3;
  overflow-wrap: anywhere;
}

.file-cell p,
.status-cell {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.format-cell {
  display: inline-grid;
  grid-template-columns: auto auto auto;
  gap: 8px;
  align-items: center;
  color: var(--muted);
  white-space: nowrap;
}

.format-cell span:first-child,
.format-cell span:last-child {
  padding: 7px 10px;
  color: var(--text);
  background: var(--surface-soft);
  border: 1px solid var(--border);
  border-radius: 6px;
  font-weight: 850;
}

.status-cell {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  min-width: 0;
}

.status-badge {
  padding: 5px 9px;
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--muted);
  background: var(--surface-soft);
  font-size: 0.78rem;
  font-weight: 850;
  text-transform: uppercase;
}

.status-badge.finished {
  color: #07883f;
  background: rgb(19 201 92 / 12%);
  border-color: rgb(19 201 92 / 35%);
}

.status-badge.converting {
  color: #165fad;
  background: rgb(22 119 255 / 10%);
  border-color: rgb(22 119 255 / 25%);
}

.status-badge.error {
  color: var(--danger);
  background: rgb(179 38 30 / 10%);
  border-color: rgb(179 38 30 / 25%);
}

.row-actions {
  display: flex;
  justify-content: flex-end;
}

.download-button {
  min-width: 132px;
  background: #05b84f;
  border-color: #05b84f;
}

.download-button:hover {
  background: #079844;
  border-color: #079844;
}

.tag-tool {
  padding-bottom: clamp(24px, 5vw, 44px);
}

.tag-video-card {
  display: grid;
  grid-template-columns: 160px minmax(0, 1fr);
  gap: 16px;
  align-items: center;
  margin-bottom: 18px;
  padding: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
}

.tag-video-card img {
  width: 160px;
  height: 90px;
  object-fit: cover;
  border-radius: 6px;
}

.tag-video-card h3 {
  margin: 0;
  font-size: 1.05rem;
  line-height: 1.3;
}

.tag-video-card p {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 0.92rem;
}

.tag-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 18px;
}

.tag-list {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.tag-chip {
  max-width: 100%;
  min-height: 38px;
  padding: 8px 11px;
  color: var(--text);
  background: var(--surface-soft);
  border: 1px solid var(--border);
  border-radius: 8px;
  font-weight: 750;
  overflow-wrap: anywhere;
}

.tag-chip:hover {
  border-color: #aeb9c7;
  background: #fff;
}

.primary-button,
.action-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  border-radius: 8px;
  font-weight: 800;
  transition: transform 160ms ease, background 160ms ease, border-color 160ms ease;
}

.primary-button {
  min-width: 174px;
  padding: 0 22px;
  color: #fff;
  background: var(--accent);
}

.primary-button:hover {
  background: var(--accent-dark);
}

.primary-button:disabled {
  cursor: wait;
  opacity: 0.86;
}

.button-text {
  white-space: nowrap;
}

.loader {
  display: none;
  width: 18px;
  height: 18px;
  margin-left: 10px;
  border: 2px solid rgb(255 255 255 / 45%);
  border-top-color: #fff;
  border-radius: 999px;
  animation: spin 700ms linear infinite;
}

.is-loading .loader {
  display: inline-block;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.message {
  min-height: 24px;
  margin: 12px 0 0;
  color: var(--muted);
  font-weight: 650;
}

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

.message.success {
  color: var(--success);
}

.results {
  margin-top: 24px;
  padding: clamp(20px, 4vw, 32px);
}

.results-header {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 22px;
}

.video-id {
  max-width: 100%;
  margin: 0;
  padding: 8px 10px;
  color: var(--muted);
  background: var(--surface-soft);
  border: 1px solid var(--border);
  border-radius: 8px;
  font-family: ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", monospace;
  font-size: 0.88rem;
  overflow-wrap: anywhere;
}

.thumbnail-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 20px;
  max-width: 860px;
  margin: 0 auto;
}

.thumbnail-card {
  display: block;
  overflow: hidden;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
}

.preview-wrap {
  display: grid;
  place-items: center;
  aspect-ratio: 16 / 9;
  background: #e8edf3;
}

.preview-wrap img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.card-body {
  display: grid;
  gap: 14px;
  padding: 16px;
  border-top: 1px solid var(--border);
}

.quality-row {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 12px;
}

.quality-row h3 {
  margin: 0;
  font-size: 1.05rem;
  letter-spacing: 0;
}

.quality-row p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 0.92rem;
}

.quality-badge {
  flex: 0 0 auto;
  padding: 5px 8px;
  color: var(--accent-dark);
  background: rgb(232 51 79 / 10%);
  border-radius: 8px;
  font-size: 0.78rem;
  font-weight: 850;
}

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

.action-button {
  padding: 0 12px;
  color: var(--text);
  background: var(--surface-soft);
  border: 1px solid var(--border);
  text-decoration: none;
}

.action-button.primary {
  color: #fff;
  background: var(--text);
  border-color: var(--text);
}

.action-button:hover {
  transform: translateY(-1px);
  border-color: #aeb9c7;
}

.action-button.primary:hover {
  background: #2a3542;
}

.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;
}

.site-footer {
  padding: 0 0 24px;
  color: var(--muted);
  text-align: center;
}

.site-footer p {
  margin: 0;
  font-size: 0.92rem;
}

@media (max-width: 760px) {
  .site-header,
  .site-footer {
    width: min(100% - 20px, 640px);
  }

  .site-header {
    align-items: flex-start;
    flex-direction: column;
    padding-top: 14px;
  }

  .app-shell {
    width: min(100% - 20px, 640px);
    padding: 24px 0;
  }

  .input-row,
  .actions,
  .json-stats,
  .converter-controls {
    grid-template-columns: 1fr;
  }

  .json-workspace {
    grid-template-columns: 1fr;
  }

  .primary-button,
  .json-actions .action-button,
  .output-actions .action-button,
  .converter-controls .action-button {
    width: 100%;
  }

  .results-header,
  .panel-heading,
  .tool-command-bar {
    align-items: stretch;
    flex-direction: column;
  }

  .tool-command-bar .message {
    text-align: left;
  }

  .json-textarea,
  .json-code {
    min-height: 520px;
  }

  .converted-row {
    grid-template-columns: 1fr;
    align-items: stretch;
  }

  .format-cell,
  .status-cell,
  .row-actions {
    justify-content: flex-start;
  }

  .tag-video-card {
    grid-template-columns: 1fr;
  }

  .tag-video-card img {
    width: 100%;
    height: auto;
    aspect-ratio: 16 / 9;
  }

  .row-actions .action-button {
    width: 100%;
  }

  .drop-zone {
    min-height: 230px;
  }

  .format-strip {
    justify-self: stretch;
  }
}
