* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Yu Gothic", sans-serif;
  background: #0d1117;
  color: #c9d1d9;
  line-height: 1.6;
}

.topbar {
  padding: 24px 16px 16px;
  text-align: center;
  background: linear-gradient(135deg, #161b22 0%, #0d1117 100%);
  border-bottom: 1px solid #30363d;
}

.topbar h1 { margin: 0; font-size: 1.5rem; font-weight: 600; }
.topbar .sub { margin: 4px 0 0; font-size: 0.85rem; color: #8b949e; }

main {
  max-width: 980px;
  margin: 0 auto;
  padding: 16px;
}

.drop {
  border: 2px dashed #30363d;
  border-radius: 8px;
  background: #161b22;
  padding: 32px 16px;
  text-align: center;
  margin-bottom: 16px;
  transition: border-color 0.15s, background 0.15s;
}

.drop.over { border-color: #58a6ff; background: #1c2331; }

.drop p { margin: 4px 0; }

.drop button {
  background: #1f6feb;
  color: #fff;
  border: none;
  border-radius: 6px;
  padding: 6px 14px;
  cursor: pointer;
  font-family: inherit;
  font-size: 0.95rem;
}

.drop button:hover { background: #388bfd; }

.dim { color: #8b949e; font-size: 0.85rem; }

.controls {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px;
  background: #161b22;
  border: 1px solid #30363d;
  border-radius: 8px;
  padding: 16px;
  margin-bottom: 16px;
}

.control {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 0.85rem;
}

.control label {
  color: #8b949e;
  font-weight: 500;
}

.control input[type="range"] { accent-color: #1f6feb; }
.control select, .control input[type="color"] {
  background: #0d1117;
  border: 1px solid #30363d;
  color: #c9d1d9;
  border-radius: 4px;
  padding: 4px 8px;
  font-family: inherit;
}

.control button {
  background: #21262d;
  color: #c9d1d9;
  border: 1px solid #30363d;
  border-radius: 6px;
  padding: 6px 12px;
  cursor: pointer;
  font-family: inherit;
  margin-top: auto;
}

.control button:hover { background: #30363d; }

#quality-out {
  font-family: ui-monospace, monospace;
  color: #ffd33d;
  font-size: 0.9rem;
}

.results {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 12px;
  margin-bottom: 24px;
}

.result {
  background: #161b22;
  border: 1px solid #30363d;
  border-radius: 8px;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.result.unsupported {
  opacity: 0.5;
  background: #0d1117;
}

.result .head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
}

.result .head h3 {
  margin: 0;
  font-size: 0.95rem;
  font-weight: 600;
}

.result .head .badge {
  font-size: 0.7rem;
  padding: 2px 6px;
  border-radius: 3px;
  background: #21262d;
  color: #8b949e;
}

.result.lossless .head .badge { background: #1c3a4d; color: #79c0ff; }
.result.lossy .head .badge { background: #2d1c4d; color: #d2a8ff; }

.result .preview {
  background: #0d1117;
  border-radius: 4px;
  overflow: hidden;
  height: 140px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.result .preview img {
  max-width: 100%;
  max-height: 140px;
  object-fit: contain;
}

.result .preview.missing {
  color: #6e7681;
  font-size: 0.85rem;
}

.result .stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  font-size: 0.85rem;
}

.result .stats .label {
  color: #8b949e;
}

.result .size {
  font-family: ui-monospace, monospace;
  color: #c9d1d9;
}

.result .delta {
  font-family: ui-monospace, monospace;
}

.result .delta.smaller { color: #7cffa1; }
.result .delta.larger { color: #ff7b72; }

.result .download {
  background: #21262d;
  color: #c9d1d9;
  border: 1px solid #30363d;
  border-radius: 4px;
  padding: 4px 10px;
  cursor: pointer;
  font-family: inherit;
  font-size: 0.85rem;
  text-align: center;
}

.result .download:hover { background: #30363d; }

.result .notes {
  font-size: 0.75rem;
  color: #6e7681;
  font-style: italic;
  line-height: 1.4;
}

.about {
  background: #161b22;
  border: 1px solid #30363d;
  border-radius: 8px;
  padding: 16px 20px;
  margin-bottom: 24px;
}

.about h2 { margin-top: 0; font-size: 1.05rem; }
.about ul, .about p { font-size: 0.9rem; }
.about li { margin-bottom: 6px; }
.about code {
  font-family: ui-monospace, monospace;
  font-size: 0.85em;
  background: #21262d;
  padding: 1px 5px;
  border-radius: 3px;
}

footer {
  border-top: 1px solid #30363d;
  padding: 16px;
  text-align: center;
  font-size: 0.85rem;
  color: #8b949e;
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
  max-width: 980px;
  margin: 24px auto 0;
}

footer a, .about a { color: #58a6ff; }
