:root {
  color-scheme: dark;
  --bg: #0c1115;
  --bg-soft: #111a20;
  --panel: #141f25;
  --line: #2b3c45;
  --text: #edf4f5;
  --muted: #9eb0b5;
  --accent: #38d4c9;
  --accent-strong: #16afa7;
  --danger: #ff8295;
  --shadow: 0 24px 70px rgba(0, 0, 0, .26);
}

html[data-theme="light"] {
  color-scheme: light;
  --bg: #f4f7f8;
  --bg-soft: #eaf0f2;
  --panel: #fff;
  --line: #d7e1e4;
  --text: #142228;
  --muted: #687b82;
  --accent: #078f8b;
  --accent-strong: #06736f;
  --danger: #d5536a;
  --shadow: 0 24px 70px rgba(31, 63, 72, .12);
}

* { box-sizing: border-box; }

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

body::before {
  content: "";
  display: block;
  height: 4px;
  background: var(--accent);
}

main {
  width: min(100% - 32px, 820px);
  margin: 0 auto;
  padding: 56px 0 34px;
}

.topbar { display: flex; justify-content: flex-end; gap: 8px; }

.control {
  height: 36px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel);
  color: var(--text);
  font-family: inherit;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
}

.control:hover { border-color: var(--accent); color: var(--accent); }
.control:focus-visible, .dropzone:focus-within, button:focus-visible, a:focus-visible { outline: 3px solid color-mix(in srgb, var(--accent) 32%, transparent); outline-offset: 2px; }

.hero { padding: 34px 0 30px; text-align: center; }
.brand { display: inline-flex; align-items: center; gap: 10px; color: var(--accent); font-size: 13px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; }
.brand-mark { display: grid; place-items: center; width: 25px; height: 25px; border: 1px solid var(--accent); border-radius: 50%; font-size: 12px; }
.hero h1 { margin: 18px 0 10px; font-size: clamp(34px, 6vw, 58px); font-weight: 800; line-height: 1.04; letter-spacing: -.03em; }
.hero h1 span { color: var(--accent); }
.hero p { margin: 0; color: var(--muted); font-size: 16px; }

.converter-card { padding: 30px; border: 1px solid var(--line); border-radius: 12px; background: var(--panel); box-shadow: var(--shadow); }
.dropzone { display: grid; place-items: center; min-height: 230px; padding: 28px; border: 1px dashed color-mix(in srgb, var(--accent) 58%, var(--line)); background: var(--bg-soft); text-align: center; cursor: pointer; transition: border-color .18s, background .18s; }
.dropzone:hover, .dropzone.dragging { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 8%, var(--bg-soft)); }
.upload-mark { display: grid; place-items: center; width: 54px; height: 54px; margin-bottom: 17px; border: 1px solid var(--accent); border-radius: 50%; color: var(--accent); font-size: 26px; }
.dropzone strong { font-size: 19px; }
.dropzone p { margin: 8px 0 14px; color: var(--muted); font-size: 14px; }
.browse { color: var(--accent); font-weight: 750; text-decoration: underline; text-underline-offset: 3px; }

.file-row { display: none; align-items: center; justify-content: space-between; gap: 16px; margin-top: 20px; padding: 13px 15px; border: 1px solid var(--line); background: var(--bg-soft); }
.file-row.show { display: flex; }
.file-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; }
.file-size { color: var(--muted); font-size: 12px; white-space: nowrap; }

.primary { width: 100%; margin-top: 20px; padding: 14px 18px; border: 0; border-radius: 6px; background: var(--accent); color: #062423; font-family: inherit; font-size: 15px; font-weight: 800; cursor: pointer; }
.primary:hover { background: var(--accent-strong); color: #fff; }
.primary:disabled { opacity: .55; cursor: wait; }
.message { min-height: 22px; margin: 16px 0 0; color: var(--muted); font-size: 13px; text-align: center; }
.message.error { color: var(--danger); }
.message.success { color: var(--accent); }

.processing { display: none; min-height: 340px; place-content: center; text-align: center; }
.converter-card.busy form { display: none; }
.converter-card.busy .processing { display: grid; }
.spinner { width: 52px; height: 52px; margin: 0 auto 20px; border: 4px solid var(--line); border-top-color: var(--accent); border-radius: 50%; animation: spin .8s linear infinite; }
.processing h2 { margin: 0; font-size: 25px; }
.processing p { margin: 9px 0 24px; color: var(--muted); }
.progress-track { width: min(100%, 610px); height: 9px; margin: 0 auto; overflow: hidden; border-radius: 10px; background: var(--bg-soft); }
.progress-bar { width: 0; height: 100%; background: var(--accent); transition: width .3s ease; }
.progress-label { display: block; margin-top: 10px; color: var(--muted); font-size: 13px; }
.cancel { margin-top: 22px; padding: 10px 18px; border: 1px solid var(--line); border-radius: 6px; background: transparent; color: var(--text); font-family: inherit; font-size: 13px; font-weight: 700; cursor: pointer; }
.cancel:hover { border-color: var(--danger); color: var(--danger); }

.result { text-align: center; }
.result-icon { display: grid; place-items: center; width: 54px; height: 54px; margin: 0 auto 17px; border-radius: 50%; background: color-mix(in srgb, var(--accent) 15%, transparent); color: var(--accent); font-size: 28px; }
.result h2 { margin: 0; font-size: 25px; }
.result p { margin: 9px 0 0; color: var(--muted); }
.result a { display: inline-block; margin-top: 22px; padding: 13px 24px; border-radius: 6px; background: var(--accent); color: #062423; font-weight: 800; text-decoration: none; }
.result a:hover { background: var(--accent-strong); color: #fff; }
.result .another { display: block; margin: 18px auto 0; padding: 0; background: transparent; color: var(--muted); font-size: 13px; font-weight: 400; text-decoration: underline; text-underline-offset: 3px; }
.result .another:hover { color: var(--accent); }

.footer { padding: 28px 0 0; color: var(--muted); font-size: 12px; text-align: center; }
.rating { color: var(--text); text-decoration: none; }
.rating:hover { color: var(--accent); }
.heart { display: inline-block; color: #f05c73; animation: heartbeat 1.15s ease-in-out infinite; }

@keyframes spin { to { transform: rotate(360deg); } }
@keyframes heartbeat { 0%, 100% { transform: scale(1); } 14% { transform: scale(1.18); } 28% { transform: scale(1); } 42% { transform: scale(1.12); } 56% { transform: scale(1); } }

@media (prefers-reduced-motion: reduce) {
  .spinner, .heart { animation: none; }
  .progress-bar { transition: none; }
}

@media (max-width: 600px) {
  main { padding-top: 24px; }
  .hero { padding-top: 28px; }
  .converter-card { padding: 18px; }
  .dropzone { min-height: 210px; }
  .file-row { align-items: flex-start; flex-direction: column; gap: 5px; }
}
