:root {
  color-scheme: light;
  --bg: #fff;
  --text: #0d1119;
  --muted: #687181;
  --surface: #fff;
  --soft: #f5f5f8;
  --border: #e5e7ee;
  --accent: #791cef;
  --shadow: 0 12px 30px #2c246609;
  --gradient: linear-gradient(110deg, #b44af0, #5b13ed);
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0c0d13;
  --text: #f5f4fb;
  --muted: #afb0c1;
  --surface: #13151f;
  --soft: #1c1d29;
  --border: #30313f;
  --accent: #c594ff;
  --shadow: 0 12px 35px #0003;
  --gradient: linear-gradient(110deg, #af45ed, #6725ed);
}
* { box-sizing: border-box; }
body { margin: 0; min-height: 100svh; background: var(--bg); color: var(--text); font: 16px/1.5 "Segoe UI", system-ui, sans-serif; }
button, input, select { font: inherit; }
button, a, input, select, summary { touch-action: manipulation; }
button, summary { cursor: pointer; }
button:disabled, select:disabled { cursor: wait; opacity: .55; }
a { color: inherit; text-decoration: none; }
button, input, select { color: inherit; }
button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible, summary:focus-visible { outline: 3px solid var(--accent); outline-offset: 5px; }
.icon-definitions { position: absolute; width: 0; height: 0; overflow: hidden; }
.icon { width: 28px; height: 28px; flex-shrink: 0; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.header { display: flex; align-items: center; justify-content: space-between; padding: 18px 5.2%; height: 86px; }
.brand { display: block; }
.brand img { display: block; width: 100%; height: auto; object-fit: contain; }
.header-brand { width: 158px; }
.logo-dark, [data-theme="dark"] .logo-light { display: none !important; }
[data-theme="dark"] .logo-dark { display: block !important; }
.header-actions { display: flex; align-items: center; gap: 24px; }
.icon-button { display: inline-flex; justify-content: center; align-items: center; border: 0; background: none; padding: 10px; min-width: 44px; min-height: 44px; color: var(--muted); }
.icon-button:hover { color: var(--accent); }
.theme-toggle { border: 2px solid var(--border); border-radius: 999px; width: 66px; height: 44px; background: var(--surface); box-shadow: 0 3px 7px #14152b05; }
.theme-toggle .icon { width: 24px; height: 24px; }
.theme-toggle .moon, [data-theme="dark"] .theme-toggle .sun { display: none; }
[data-theme="dark"] .theme-toggle .moon { display: block; }
.settings-button .icon { width: 27px; height: 27px; }
main { width: min(900px, calc(100% - 48px)); margin: 0 auto; padding: 48px 0 40px; }
.hero { text-align: center; }
.hero-brand { width: min(335px, 80%); margin: 0 auto; }
.hero p { margin: 8px 0 42px; color: var(--muted); font-size: clamp(17px, 1.6vw, 23px); letter-spacing: 2px; font-weight: 450; }
.workspace { width: 100%; }
.url-field { display: flex; align-items: center; gap: 12px; padding: 6px 7px 6px 19px; min-height: 76px; border: 2px solid var(--border); border-radius: 999px; background: var(--surface); box-shadow: var(--shadow); }
.url-field:focus-within { border-color: #b784f7; }
.paste-button { color: var(--text); padding: 9px; }
.paste-button .icon { width: 26px; height: 26px; }
.url-field input { flex: 1; min-width: 0; width: 100%; background: transparent; border: 0; padding: 12px 0; font-size: clamp(16px, 1.35vw, 20px); color: var(--text); }
.url-field input::placeholder { color: var(--text); opacity: .8; }
.url-field input:focus-visible { outline-offset: 2px; border-radius: 6px; }
.primary { display: inline-flex; justify-content: center; align-items: center; gap: 14px; border: 0; border-radius: 999px; background: var(--gradient); color: #fff; font-weight: 550; font-size: 18px; padding: 13px 28px; min-height: 58px; white-space: nowrap; }
.primary .icon { width: 25px; height: 25px; }
.primary:hover { filter: brightness(1.08); }
.url-field .primary { min-width: 206px; font-weight: 500; }
.primary:disabled { filter: none; }
.compact { font-size: 15px; min-height: 48px; padding: 12px 25px; gap: 10px; }
.compact .icon { width: 21px; height: 21px; }
fieldset { border: 0; padding: 0; margin: 0; min-width: 0; }
.mode-options { display: flex; justify-content: center; margin: 28px 0 0; }
.mode-selector { display: inline-flex; border-radius: 999px; background: var(--soft); padding: 6px; gap: 3px; }
.mode-selector label { position: relative; cursor: pointer; }
.mode-selector input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.mode-selector label > span { display: flex; align-items: center; justify-content: center; gap: 16px; padding: 14px 36px; min-height: 58px; border: 1.5px solid transparent; border-radius: 999px; font-size: 17px; font-weight: 550; color: var(--text); white-space: nowrap; }
.mode-selector .icon { color: var(--muted); width: 24px; height: 24px; }
.mode-selector input:checked + span { border-color: #a64bfa; color: var(--accent); background: var(--surface); box-shadow: 0 0 0 5px #b775fa06, 0 5px 15px #6739ab07; }
.mode-selector input:checked + span .icon { color: var(--accent); }
.mode-selector input:focus-visible + span { outline: 3px solid var(--accent); outline-offset: 3px; }
.mode-selector input:disabled + span { opacity: .5; cursor: wait; }
.waves { position: fixed; z-index: -1; pointer-events: none; bottom: 0; left: 0; width: 100%; height: clamp(140px, 25vh, 240px); }
.waves svg { display: block; width: 100%; height: 100%; }
[data-theme="dark"] .waves { opacity: .4; }
/* Isolate decorative waves behind content, above the body background. */
body { isolation: isolate; }
.alert { margin: 26px auto 0; padding: 13px 17px; border: 1px solid #e9b2c1; background: #fff0f4; color: #8c2146; border-radius: 12px; font-size: 14px; overflow-wrap: anywhere; }
[data-theme="dark"] .alert { background: #321a28; border-color: #733448; color: #ffbad0; }
.result-panel { width: min(670px, 100%); margin: 32px auto 0; padding: 24px; background: var(--surface); border: 1px solid var(--border); border-radius: 20px; box-shadow: var(--shadow); }
.preview-card { display: flex; align-items: center; gap: 18px; }
.preview-card img { width: 140px; aspect-ratio: 16/9; object-fit: cover; border-radius: 9px; }
.preview-card h2, .finished h2 { font-size: 17px; margin: 0 0 6px; line-height: 1.4; overflow-wrap: anywhere; }
.muted { color: var(--muted); }
.preview-card p, .finished p { font-size: 12px; margin: 0; }
#download-form { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 16px; margin-top: 22px; }
#options { flex: 1; }
.option-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; font-size: 14px; }
select, dialog input[type="password"] { background: var(--surface); color: var(--text); border: 1px solid var(--border); border-radius: 10px; padding: 10px 14px; max-width: 100%; }
summary { font-size: 13px; color: var(--accent); }
details .option-row { margin-top: 15px; }
.hint { font-size: 12px; line-height: 1.65; color: var(--muted); }
.progress-header { display: flex; justify-content: space-between; gap: 16px; font-size: 14px; }
#percent { font-variant-numeric: tabular-nums; }
progress { display: block; width: 100%; height: 8px; accent-color: var(--accent); margin: 18px 0; }
#detail { font-size: 12px; line-height: 1.6; }
.text-button { color: var(--accent); background: transparent; border: 0; font-size: 14px; padding: 10px 0; min-height: 44px; }
.finished { display: flex; justify-content: space-between; align-items: center; gap: 20px; }
dialog { position: fixed; width: min(440px, calc(100% - 32px)); max-height: calc(100svh - 40px); overflow-y: auto; padding: 32px; color: var(--text); background: var(--surface); border: 1px solid var(--border); border-radius: 22px; box-shadow: 0 25px 100px #14112a25; }
dialog::backdrop { background: #11101b70; backdrop-filter: blur(8px); }
dialog h2 { font-size: 23px; letter-spacing: -.5px; margin: 9px 0 12px; }
dialog .primary { width: 100%; margin-top: 18px; }
dialog input[type="password"] { width: 100%; margin-top: 8px; }
dialog label { font-size: 14px; }
.dialog-brand { width: 150px; margin-bottom: 24px; }
.dialog-close { position: absolute; right: 10px; top: 10px; }
.dialog-close .icon { width: 20px; height: 20px; }
.consent { display: flex; align-items: flex-start; gap: 10px; font-size: 14px; margin-top: 20px; }
.consent input { margin-top: 4px; accent-color: var(--accent); }
.setting { border-top: 1px solid var(--border); margin-top: 22px; padding-top: 20px; }
.setting label { display: block; margin-bottom: 10px; }
.setting select { width: 100%; }
.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; }
[hidden] { display: none !important; }
@media (max-width: 1100px) {
  .url-field .primary { min-width: auto; }
  main { width: min(900px, calc(100% - 48px)); padding-top: 44px; }
  .hero-brand { width: min(315px, 80%); }
  .hero p { font-size: 20px; margin-bottom: 38px; letter-spacing: 1.5px; }
  .url-field { min-height: 76px; padding-left: 18px; gap: 12px; }
  .primary { min-height: 58px; padding: 13px 26px; gap: 12px; font-size: 18px; }
  .compact { min-height: 48px; font-size: 15px; padding: 12px 22px; }
  .mode-selector label > span { padding: 14px 28px; min-height: 58px; font-size: 16px; gap: 14px; }
}
@media (max-width: 600px) {
  .header { height: 88px; padding: 18px 22px; }
  .header-brand { width: 133px; }
  .header-actions { gap: 10px; }
  .theme-toggle { width: 56px; height: 42px; min-height: 42px; }
  .theme-toggle .icon { width: 23px; height: 23px; }
  .settings-button { padding: 6px; }
  .settings-button .icon { width: 26px; height: 26px; }
  main { width: calc(100% - 36px); padding: 72px 0 155px; }
  .hero-brand { width: min(250px, 87%); }
  .hero p { margin: 14px auto 30px; max-width: 300px; font-size: 16px; letter-spacing: .7px; line-height: 1.6; }
  .url-field { min-height: 72px; gap: 5px; padding: 6px 6px 6px 10px; }
  .paste-button { min-width: 32px; padding: 4px; }
  .paste-button .icon { width: 23px; height: 23px; }
  .url-field input { font-size: 14px; padding: 10px 0; }
  .primary { min-height: 55px; padding: 13px 17px; gap: 7px; font-size: 14px; }
  .url-field .primary .icon { width: 19px; height: 19px; }
  .mode-options { margin-top: 28px; }
  .mode-selector { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); width: min(360px, 100%); padding: 5px; gap: 1px; max-width: 100%; }
  .mode-selector label { min-width: 0; }
  .mode-selector label > span { padding: 14px 18px; min-height: 57px; font-size: 14px; gap: 11px; }
  .mode-selector .icon { width: 23px; height: 23px; }
  .result-panel { padding: 19px; margin-top: 24px; }
  .preview-card { gap: 12px; }
  .preview-card img { width: 95px; }
  .preview-card h2 { font-size: 14px; }
  .option-row { font-size: 13px; }
  .finished { flex-direction: column; align-items: stretch; gap: 16px; }
  #download-form { align-items: stretch; }
  #start { width: 100%; }
  dialog { padding: 27px; }
}
@media (max-width: 360px) {
  main { width: calc(100% - 24px); }
  .url-field { flex-wrap: wrap; border-radius: 26px; padding: 10px; }
  .url-field input { width: calc(100% - 50px); }
  .url-field .primary { width: 100%; }
  .mode-selector label > span { padding: 13px 9px; font-size: 12px; gap: 7px; }
  .mode-selector .icon { width: 20px; height: 20px; }
}
@media (prefers-reduced-motion: no-preference) {
  button, a, .mode-selector label > span { transition: box-shadow .15s ease, filter .15s ease; }
}

/* 3.2: optional account controls; the approved converter layout is unchanged. */
.account-links { display: flex; align-items: center; gap: 20px; }
.account-links .text-button { color: var(--muted); font-size: 13px; white-space: nowrap; }
.account-links .text-button:hover { color: var(--accent); }
.profile-avatar { width: 38px; height: 38px; border: 1px solid var(--border); border-radius: 50%; background: var(--soft); color: var(--accent); font-size: 14px; font-weight: 600; cursor: pointer; }
.quota-info { text-align: center; font-size: 11px; color: var(--muted); margin: 14px 0 0; min-height: 17px; }
.main-audio-row { display: flex; justify-content: center; margin-top: 14px; }
.main-audio-row select { padding: 7px 22px 7px 12px; font-size: 13px; }
.advertisement { margin: 28px auto 0; max-width: 640px; text-align: center; }
.advertisement > span { display: block; color: var(--muted); font-size: 10px; margin-bottom: 4px; }
.advertisement img { display: block; width: 100%; max-height: 90px; height: auto; object-fit: contain; border-radius: 8px; }
#account-form, #profile-form, #delete-account-form { display: grid; gap: 9px; }
#account-form input, #profile-form input, #delete-account-form input { width: 100%; border: 1px solid var(--border); border-radius: 9px; padding: 11px 12px; background: var(--surface); color: var(--text); }
#account-form .primary { margin-top: 9px; }
.google-button { width: 100%; background: var(--soft); border: 1px solid var(--border); border-radius: 999px; min-height: 46px; margin-top: 12px; font-size: 14px; }
.profile-dialog { width: min(520px, calc(100% - 32px)); }
.profile-preferences { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 8px; }
.profile-preferences select { display: block; width: 100%; margin-top: 8px; }
.profile-dialog details { margin-top: 20px; border-top: 1px solid var(--border); padding-top: 17px; }
.history-list { padding: 0; list-style: none; }
.history-list li { border-top: 1px solid var(--border); padding: 12px 0; }
.history-title { display: block; font-size: 13px; overflow-wrap: anywhere; }
.history-meta { font-size: 11px; color: var(--muted); display: block; margin: 5px 0; }
.history-list .text-button { font-size: 12px; margin-right: 14px; }
.profile-actions { display: flex; justify-content: space-between; gap: 12px; margin-top: 15px; }
.danger-button { color: #9f2548; border: 1px solid #df8fa9; border-radius: 9px; background: transparent; padding: 11px; margin-top: 8px; cursor: pointer; }
[data-theme="dark"] .danger-button { color: #ffb0c8; }
@media (max-width: 780px) {
  .header { padding: 18px 22px; }
  .header-actions { gap: 12px; }
  .account-links { gap: 10px; }
  .account-links .text-button { font-size: 11px; }
}
@media (max-width: 600px) {
  .header { flex-wrap: wrap; height: 110px; align-content: center; row-gap: 3px; }
  .header-actions { flex-wrap: wrap; justify-content: flex-end; gap: 7px; max-width: calc(100% - 133px); }
  .account-links { width: 100%; order: 2; justify-content: flex-end; gap: 10px; }
  .account-links .text-button { min-height: 28px; padding: 2px 0; font-size: 10px; }
  .profile-avatar { width: 30px; height: 30px; }
  main { padding-top: 32px; }
  .quota-info { font-size: 10px; }
}
@media (max-width: 360px) {
  .header { padding: 16px 14px; }
  .header-brand { width: 118px; }
  .header-actions { max-width: calc(100% - 118px); }
  .profile-preferences { grid-template-columns: 1fr; }
}

main { padding-bottom: 40px; }
@media (max-width: 600px) { main { padding-bottom: 36px; } }

/* A real advertising slot remains compact, without covering or clipping controls. */
.advertisement { margin-top: 18px; }
.advertisement img { width: auto; max-width: 100%; height: 64px; max-height: 64px; margin: 0 auto; object-fit: contain; }
.with-ad main { padding-top: 28px; padding-bottom: 24px; }
.with-ad .hero-brand { width: min(280px, 80%); }
.with-ad .hero p { font-size: 20px; margin-bottom: 28px; }
.with-ad .mode-options { margin-top: 22px; }
.auth-status { display: block; color: var(--muted); font-size: 10px; text-align: right; }
.account-links button:disabled { cursor: not-allowed; opacity: .6; }
@media (max-width: 600px) {
 .with-ad main { padding-top: 24px; }
 .with-ad .hero-brand { width: min(230px, 80%); }
 .with-ad .hero p { font-size: 16px; margin-bottom: 24px; }
 .auth-status { width: 100%; font-size: 9px; }
}

.adblock-probe { display: block; position: fixed; top: 0; left: 0; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.support-message { position: relative; width: min(640px, 100%); margin: 22px auto 0; padding: 24px; border: 1px solid var(--border); border-radius: 18px; background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
.support-message h2 { font-size: 20px; margin: 0 36px 16px 0; }
.support-message p { color: var(--muted); font-size: 13px; line-height: 1.7; margin: 12px 0; }
.support-message strong { color: var(--text); }
.support-close { position: absolute; top: 7px; right: 7px; }
.support-close .icon { width: 20px; height: 20px; }
.support-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 20px; }
.support-button { flex: 1; min-height: 44px; padding: 10px 16px; border: 1px solid var(--border); border-radius: 999px; background: var(--soft); color: var(--text); cursor: pointer; font-size: 13px; }
.support-button:hover { border-color: var(--accent); }
.support-help { border-top: 1px solid var(--border); margin-top: 20px; padding-top: 12px; }
.support-help h3 { font-size: 15px; font-weight: 600; }
@media (max-width: 390px) { .support-actions { flex-direction: column; } .support-message { padding: 20px; } }
