:root {
    --accent: #2563eb;
    --bg: #f6f7fb;
    --surface: #ffffff;
    --surface-2: #eef0f6;
    --text: #12141c;
    --muted: #5d6475;
    --border: #dfe2ea;
    --danger: #dc2626;
    --ok: #16a34a;
    --radius: 14px;
    --shadow: 0 1px 2px rgba(16, 24, 40, .05), 0 8px 24px rgba(16, 24, 40, .06);
    color-scheme: light dark;
}

/* theme: follows the device unless the visitor picked one in settings */
@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        --bg: #0d0f14;
        --surface: #161a22;
        --surface-2: #1f2430;
        --text: #eef0f5;
        --muted: #9aa2b4;
        --border: #2a303d;
        --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px rgba(0, 0, 0, .3);
        color-scheme: dark;
    }
}
:root[data-theme="dark"] {
    --bg: #0d0f14;
    --surface: #161a22;
    --surface-2: #1f2430;
    --text: #eef0f5;
    --muted: #9aa2b4;
    --border: #2a303d;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px rgba(0, 0, 0, .3);
    color-scheme: dark;
}
:root[data-theme="light"] { color-scheme: light; }

/* reduce motion: from the device setting or the site setting */
:root[data-motion="reduce"] *, :root[data-motion="reduce"] *::before, :root[data-motion="reduce"] *::after {
    animation-duration: 0s !important; animation-iteration-count: 1 !important; transition: none !important; scroll-behavior: auto !important;
}
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation-duration: 0s !important; animation-iteration-count: 1 !important; transition: none !important; }
}

* { box-sizing: border-box; }

html, body { margin: 0; }

body {
    font-family: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.55;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); }

svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex-shrink: 0; }
svg.logo { fill: currentColor; stroke: none; }

.sr, .hp { position: absolute; inset-inline-start: 0; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip:not(:focus) { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip:focus { position: absolute; inset-inline-start: 16px; top: 16px; z-index: 10; background: var(--surface); padding: 8px 12px; border-radius: 8px; }
.muted { color: var(--muted); }

/* header */
.top {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 14px clamp(16px, 4vw, 40px);
    max-width: 1200px;
    width: 100%;
    margin: 0 auto;
}
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--text); font-weight: 700; font-size: 1.15rem; letter-spacing: -.01em; }
.brand .logo { width: 30px; height: 20px; color: var(--accent); }
.menu { display: flex; gap: 4px; margin-inline-start: 12px; flex: 1; flex-wrap: wrap; }
.menu a { color: var(--muted); text-decoration: none; padding: 6px 10px; border-radius: 8px; font-size: .95rem; }
.menu a:hover, .menu a[aria-current="page"] { color: var(--text); background: var(--surface-2); }
.top-actions { display: flex; gap: 8px; margin-inline-start: auto; align-items: center; }
.chip {
    display: inline-flex; align-items: center; gap: 8px;
    border: 1px solid var(--border); background: var(--surface); color: var(--text);
    padding: 8px 14px; border-radius: 999px; font: inherit; font-size: .92rem; cursor: pointer;
}
.chip:hover { border-color: var(--accent); }
.chip svg { width: 18px; height: 18px; }
.chip img { width: 22px; height: 22px; border-radius: 50%; margin-block: -3px; margin-inline-start: -6px; }
.lang { position: relative; }
.lang summary { list-style: none; }
.lang summary::-webkit-details-marker { display: none; }
.lang-list {
    position: absolute; inset-inline-end: 0; top: calc(100% + 6px); z-index: 20; min-width: 190px;
    background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 6px;
    box-shadow: var(--shadow); display: grid; max-height: 70vh; overflow: auto;
}
.lang-list a { color: var(--text); text-decoration: none; padding: 8px 12px; border-radius: 9px; font-size: .95rem; }
.lang-list a:hover { background: var(--surface-2); }
.lang-list a[aria-current] { color: var(--accent); font-weight: 600; background: color-mix(in srgb, var(--accent) 10%, transparent); }
.top-actions { position: relative; }
.acc-menu {
    position: absolute; inset-inline-end: 0; top: calc(100% + 6px); z-index: 30; width: min(280px, calc(100vw - 32px));
    background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 6px;
    box-shadow: var(--shadow); display: grid;
}
.acc-who { display: flex; gap: 10px; align-items: center; padding: 10px 10px 12px; border-bottom: 1px solid var(--border); margin-bottom: 6px; min-width: 0; }
.acc-who img { width: 36px; height: 36px; border-radius: 50%; flex: none; }
.acc-who div { display: grid; min-width: 0; }
.acc-who strong { font-size: .95rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.acc-who span { font-size: .82rem; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.acc-menu a, .acc-menu button { color: var(--text); text-decoration: none; padding: 9px 12px; border-radius: 9px; font: inherit; font-size: .95rem; text-align: start; background: none; border: 0; cursor: pointer; }
.acc-menu a:hover, .acc-menu button:hover { background: var(--surface-2); }
.acc-menu .acc-out { color: #dc2626; font-weight: 600; }
.icon-btn { display: none; border: 1px solid var(--border); background: var(--surface); color: var(--text); border-radius: 10px; padding: 7px; cursor: pointer; }

.announcement { background: var(--accent); color: #fff; text-align: center; padding: 8px 16px; font-size: .92rem; }

/* main */
main { flex: 1; width: 100%; max-width: 760px; margin: 0 auto; padding: 24px 16px 48px; }
.hero { text-align: center; padding-top: clamp(8px, 5vh, 56px); }
.hero-mark {
    width: 84px; height: 84px; margin: 0 auto 18px; border-radius: 24px;
    background: var(--accent); color: #fff; display: grid; place-items: center;
    box-shadow: 0 10px 30px color-mix(in srgb, var(--accent) 35%, transparent);
}
.hero-mark .logo { width: 48px; height: 32px; }
.hero h1 { margin: 0; font-size: clamp(2rem, 6vw, 2.8rem); letter-spacing: -.03em; line-height: 1.1; }
.tagline { margin: 8px 0 28px; color: var(--muted); font-size: 1.08rem; }

.dl { background: var(--surface); border: 1px solid var(--border); border-radius: 20px; padding: 14px; box-shadow: var(--shadow); text-align: start; }
.input-row { display: flex; gap: 8px; }
.input-wrap {
    flex: 1; display: flex; align-items: center; gap: 10px;
    background: var(--bg); border: 1.5px solid var(--border); border-radius: 12px; padding: 0 14px;
}
.input-wrap:focus-within { border-color: var(--accent); }
.input-wrap svg { color: var(--muted); }
.input-wrap input { flex: 1; min-width: 0; border: 0; outline: 0; background: transparent; color: var(--text); font: inherit; font-size: 1rem; padding: 14px 0; }
.row-between { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-top: 10px; flex-wrap: wrap; }
.modes { display: inline-flex; background: var(--bg); border: 1px solid var(--border); border-radius: 12px; padding: 3px; }
.modes button { border: 0; background: transparent; color: var(--muted); font: inherit; font-size: .92rem; padding: 7px 12px; border-radius: 9px; cursor: pointer; }
.modes button[aria-checked="true"] { background: var(--surface); color: var(--text); box-shadow: 0 1px 3px rgba(0,0,0,.12); font-weight: 600; }

.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    border-radius: 12px; border: 1px solid transparent; font: inherit; font-weight: 600;
    padding: 11px 18px; cursor: pointer; text-decoration: none; white-space: nowrap;
}
.btn.primary { background: var(--accent); color: #fff; }
.btn.primary:hover { filter: brightness(1.08); }
.btn.primary[disabled] { opacity: .6; cursor: progress; }
.btn.ghost { background: var(--surface-2); color: var(--text); border-color: var(--border); }
.btn.danger { background: transparent; color: var(--danger); border-color: var(--border); }
.btn.small { padding: 6px 12px; font-size: .88rem; border-radius: 9px; }

.opts { margin-top: 10px; font-size: .92rem; color: var(--muted); }
.opts summary { cursor: pointer; padding: 4px 2px; }
.opts-body { display: grid; gap: 12px; margin-top: 8px; }
.home-opts { border-top: 1px solid var(--border); margin-top: 12px; padding-top: 10px; }
.home-opts summary { display: inline-flex; align-items: center; gap: 8px; list-style: none; font-weight: 600; color: var(--text); border: 1px solid var(--border); border-radius: 999px; padding: 6px 14px; }
.home-opts summary::-webkit-details-marker { display: none; }
.home-opts summary::after { content: ""; width: 7px; height: 7px; border-right: 2px solid currentColor; border-bottom: 2px solid currentColor; transform: rotate(45deg); margin: -3px 0 0 4px; transition: transform .15s; }
.home-opts[open] summary::after { transform: rotate(-135deg); margin-top: 3px; }
.home-opts summary:hover { background: var(--bg); }
.home-opts summary svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.home-opts .opts-body { grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); align-items: start; }
.opts-group { border: 1px solid var(--border); border-radius: 12px; padding: 10px 12px 12px; margin: 0; min-width: 0; display: grid; gap: 10px; }
.opts-group[hidden] { display: none; }
.opts-group legend { padding: 0 6px; font-weight: 600; color: var(--text); font-size: .88rem; }
.opts-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.opts label.check { display: flex; align-items: center; gap: 8px; cursor: pointer; }
.opts label.check input { width: 18px; height: 18px; accent-color: var(--accent); margin: 0; }
.link-btn { justify-self: start; background: none; border: 0; padding: 2px; font: inherit; font-size: .86rem; color: var(--muted); text-decoration: underline; cursor: pointer; }
.opts label, .sheet label { display: grid; gap: 4px; font-size: .88rem; color: var(--muted); }
select, .sheet input, .sheet textarea {
    font: inherit; color: var(--text); background: var(--bg); border: 1px solid var(--border);
    border-radius: 10px; padding: 9px 10px; width: 100%;
}

.result:not(:empty) { margin-top: 16px; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; text-align: start; box-shadow: var(--shadow); }
.card.error { border-color: color-mix(in srgb, var(--danger) 45%, var(--border)); }
.card .title { font-weight: 600; margin: 0 0 4px; word-break: break-word; }
.card .actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; }
.picker { display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 10px; margin-top: 12px; }
.picker a { display: block; aspect-ratio: 1; border-radius: 10px; overflow: hidden; background: var(--surface-2); border: 1px solid var(--border); position: relative; color: var(--text); text-decoration: none; font-size: .8rem; }
.picker img { width: 100%; height: 100%; object-fit: cover; }
.picker span { position: absolute; bottom: 6px; inset-inline-end: 6px; background: rgba(0,0,0,.65); color: #fff; padding: 2px 8px; border-radius: 6px; }
.spinner { width: 18px; height: 18px; border: 2px solid rgba(255,255,255,.5); border-top-color: #fff; border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.note { color: var(--muted); font-size: .92rem; margin: 18px 0 0; }
.services { margin-top: 10px; color: var(--muted); font-size: .92rem; }
.services summary { cursor: pointer; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; margin-top: 10px; }
.chips span { background: var(--surface); border: 1px solid var(--border); border-radius: 999px; padding: 3px 10px; font-size: .85rem; color: var(--text); }

.donate {
    margin: 40px auto 0; max-width: 560px; text-align: center;
    background: var(--surface); border: 1px solid var(--border); border-radius: 20px; padding: 24px; box-shadow: var(--shadow);
}
.donate h2 { margin: 0 0 6px; font-size: 1.2rem; }
.donate p { margin: 0 0 16px; color: var(--muted); }
.share {
    margin: 32px auto 0; max-width: 560px; text-align: center;
    background: var(--surface); border: 1px solid var(--border); border-radius: 20px; padding: 24px; box-shadow: var(--shadow);
}
.share h2 { margin: 0 0 6px; font-size: 1.2rem; }
.share p { margin: 0 0 16px; color: var(--muted); }
.share-actions { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; }
.share-actions .btn svg { width: 18px; height: 18px; }
.share-nets { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; margin-top: 14px; }
.share-nets a { border: 1px solid var(--border); border-radius: 999px; padding: 4px 12px; font-size: .88rem; color: var(--text); text-decoration: none; }
.share-nets a:hover { background: var(--bg); }
.share .share-status { margin: 10px 0 0; min-height: 1.2em; font-size: .9rem; }
.btn.coffee { background: #ffdd00; color: #1a1a1a; }
.btn.coffee:hover { filter: brightness(.96); }

/* ads */
.ad-slot { margin: 12px max(16px, calc((100% - 938px) / 2)); text-align: center; overflow: hidden; }
.ad-placeholder {
    display: grid; place-items: center; min-height: 90px; border: 2px dashed var(--border); border-radius: 12px;
    color: var(--muted); font-size: .85rem; background: var(--surface);
}
main .ad-slot { margin: 32px 0 0; }

/* side ads: fixed rails left and right of the page, only on wide screens */
.ad-slot.ad-left, .ad-slot.ad-right { position: fixed; top: 96px; width: 160px; max-height: calc(100vh - 112px); margin: 0; z-index: 5; }
.ad-slot.ad-left { left: 16px; }
.ad-slot.ad-right { right: 16px; }
.ad-left.ad-placeholder, .ad-right.ad-placeholder { height: 600px; }
@media (min-width: 1640px) {
    .ad-slot.ad-left, .ad-slot.ad-right { width: 300px; }
    .ad-left.ad-placeholder, .ad-right.ad-placeholder { width: 300px; }
}
@media (max-width: 1299px) {
    .ad-slot.ad-left, .ad-slot.ad-right { display: none; }
}
/* phones: ads only in the download window when the admin setting is on */
@media (max-width: 720px) {
    body.ads-mobile-window .ad-slot { display: none; }
}

/* pages */
.page { background: var(--surface); border: 1px solid var(--border); border-radius: 20px; padding: clamp(20px, 4vw, 36px); box-shadow: var(--shadow); }
.page h2 { margin-top: 0; letter-spacing: -.01em; }
.page h2:not(:first-child) { margin-top: 28px; }
.page.center { text-align: center; }

.account-head { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; }
.account-head img { width: 48px; height: 48px; border-radius: 50%; }
.history { list-style: none; padding: 0; margin: 0; display: grid; gap: 8px; }
.history li { display: flex; gap: 12px; align-items: center; border: 1px solid var(--border); border-radius: 12px; padding: 10px 12px; background: var(--bg); }
.history .info { flex: 1; min-width: 0; }
.history .info b { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.history .info a, .history .info small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); font-size: .85rem; }
.row-gap { display: flex; gap: 8px; flex-wrap: wrap; margin: 16px 0; }

/* footer */
.foot { text-align: center; color: var(--muted); font-size: .88rem; padding: 24px 16px 32px; }
.foot nav { display: flex; gap: 16px; justify-content: center; flex-wrap: wrap; }
.foot a { color: var(--muted); }
.foot p { margin: 8px 0 0; }

/* dialogs */
.sheet { border: 0; padding: 0; border-radius: 20px; background: var(--surface); color: var(--text); width: min(460px, calc(100vw - 32px)); box-shadow: 0 24px 60px rgba(0,0,0,.25); }
.sheet::backdrop { background: rgba(10, 12, 20, .45); backdrop-filter: blur(2px); }
.sheet-body { padding: 24px; display: grid; gap: 12px; }
.sheet h2 { margin: 0; font-size: 1.2rem; }
.sheet p { margin: 0; }
.sheet-actions { display: flex; justify-content: flex-end; gap: 8px; }
.save-head { display: flex; gap: 12px; align-items: center; }
.save-icon { flex: none; display: grid; place-items: center; width: 44px; height: 44px; border-radius: 12px; background: color-mix(in srgb, var(--accent) 14%, transparent); color: var(--accent); }
.save-icon svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.save-file { font-size: .88rem; word-break: break-all; }
.save-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(0, 1fr)); grid-auto-flow: column; gap: 8px; margin-top: 4px; }
.save-tile { display: grid; justify-items: center; gap: 8px; padding: 16px 8px; border: 1px solid var(--border); border-radius: 14px; background: var(--bg); color: var(--text); font: inherit; font-weight: 600; cursor: pointer; transition: background .15s, border-color .15s, transform .1s; }
.save-tile[hidden] { display: none; }
.save-tile:hover { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 8%, var(--bg)); }
.save-tile:active { transform: scale(.97); }
.save-tile svg { width: 26px; height: 26px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.save-hint { font-size: .88rem; }
.save-status { font-size: .88rem; color: var(--accent); min-height: 1.2em; }
.save-done { width: 100%; justify-content: center; }
.form-status:empty { display: none; }
.form-status.err { color: var(--danger); }
.form-status.ok { color: var(--ok); }
.ad-sheet { width: min(760px, calc(100vw - 24px)); }
.ad-label { font-size: .75rem; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); margin: 0; }
.ad-gate-slot { min-height: 250px; display: grid; place-items: center; overflow: auto; }
.ad-gate-slot .ad-placeholder { width: 100%; min-height: 250px; }
.ad-sheet .sheet-actions { align-items: center; justify-content: space-between; }
.gsi { display: flex; justify-content: center; min-height: 44px; }

@media (max-width: 720px) {
    .top { flex-wrap: wrap; gap: 10px; }
    .icon-btn { display: inline-flex; }
    .menu { display: none; order: 3; flex-basis: 100%; margin: 0; flex-direction: column; }
    .menu.open { display: flex; }
    .chip span { display: none; }
    .lang .chip span { display: inline; font-size: .8rem; font-weight: 600; }
    .chip { padding: 8px; }
    .account-chip.signed span { display: none; }
    .input-row { flex-direction: column; }
    .row-between { flex-direction: column; align-items: stretch; }
    .modes { display: flex; }
    .modes button { flex: 1; white-space: nowrap; padding: 7px 6px; }
    .opts-grid { grid-template-columns: 1fr; }
}

/* ---------- remux ---------- */
.remux-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 28px; align-items: start; margin-top: 18px; }
.dropzone {
    display: grid; justify-items: center; gap: 8px; text-align: center; padding: 40px 20px; cursor: pointer;
    border: 2px dashed var(--border); border-radius: var(--radius); background: var(--surface); transition: border-color .15s, background .15s;
}
.dropzone svg { width: 40px; height: 40px; fill: none; stroke: var(--accent); stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.dropzone:hover, .dropzone.over, .dropzone:focus-within { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 6%, var(--surface)); }
.dropzone[hidden], .remux-panel[hidden] { display: none; }
.remux-panel { display: grid; gap: 10px; }
.remux-panel .title { margin: 0; font-weight: 600; overflow-wrap: anywhere; }
.remux-panel .muted { margin: 0; }
.remux-to { display: grid; gap: 4px; font-size: .88rem; color: var(--muted); }
.progress { height: 8px; border-radius: 99px; background: var(--surface-2); overflow: hidden; }
.progress[hidden] { display: none; }
.progress span { display: block; height: 100%; width: 0; background: var(--accent); transition: width .2s; }
.remux-info { display: grid; gap: 18px; }
.remux-info h2 { font-size: 1rem; margin: 0 0 4px; }
.remux-info p { margin: 0; }
.small { font-size: .86rem; }

/* ---------- settings ---------- */
.settings { display: grid; gap: 16px; }
.settings h1, .settings h2 { margin: 0; }
.settings h2 { font-size: 1.05rem; margin-top: 8px; }
.settings .opts { margin-top: 0; }
.settings label.check { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: .9rem; cursor: pointer; }
.settings label.check input { width: 18px; height: 18px; accent-color: var(--accent); margin: 0; }
.settings label:not(.check):not(.file-btn) { display: grid; gap: 4px; font-size: .88rem; color: var(--muted); }
.settings-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.file-btn { cursor: pointer; }
#set-status.err { color: var(--danger); }

/* ---------- updates ---------- */
.release { border-top: 1px solid var(--border); padding-top: 14px; margin-top: 14px; }
.release h2 { font-size: 1.1rem; margin: 0 0 6px; display: flex; gap: 10px; align-items: baseline; flex-wrap: wrap; }
.release time { font-size: .85rem; font-weight: 400; color: var(--muted); }
.release ul { margin: 0; padding-inline-start: 20px; }

@media (max-width: 720px) {
    .remux-grid { grid-template-columns: 1fr; }
}
.btn[hidden] { display: none; }

/* in-browser translation: hide the translator's own bar and tooltips */
.goog-te-banner-frame, iframe.skiptranslate, .goog-te-balloon-frame, #goog-gt-tt, .goog-te-spinner-pos { display: none !important; }
body { top: 0 !important; position: static !important; }
.goog-text-highlight { background: none !important; box-shadow: none !important; }
#gt-el { display: none; }
