:root {
  --bg: #0b141a;
  --panel: #111b21;
  --panel-2: #1a2730;
  --line: #24343e;
  --text: #e9edef;
  --muted: #8696a0;
  --accent: #25d366;
  --accent-ink: #062b14;
  --danger: #f15c6d;
  --warn: #e8b84a;
  color-scheme: dark;
}
@media (prefers-color-scheme: light) {
  :root {
    --bg: #f0f2f5;
    --panel: #ffffff;
    --panel-2: #f0f2f5;
    --line: #d9dee2;
    --text: #111b21;
    --muted: #5b6b75;
    --accent: #1fa855;
    --accent-ink: #ffffff;
    --danger: #c9354a;
    --warn: #9a6b00;
    color-scheme: light;
  }
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  padding: 0 16px calc(32px + env(safe-area-inset-bottom));
  max-width: 560px;
  margin-inline: auto;
}
a { color: var(--accent); }
h1, h2 { margin: 0; }
.top h1 { min-width: 0; }
h2 { font-size: 1rem; margin-bottom: 10px; }

.top { display: flex; align-items: center; justify-content: space-between; padding: calc(16px + env(safe-area-inset-top)) 0 8px; }
.top h1 { font-size: 1.35rem; letter-spacing: -0.01em; }
.top h1 span { color: var(--accent); }
.pill {
  border: 1px solid var(--line); background: var(--panel); color: var(--muted);
  border-radius: 999px; padding: 6px 12px; font: inherit; font-size: .8rem; cursor: pointer;
  display: inline-flex; align-items: center; gap: 8px;
}
.pill::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--muted); }
.pill.ok { color: var(--text); }
.pill.ok::before { background: var(--accent); }
.pill.bad::before { background: var(--danger); }

.tabs { display: flex; gap: 4px; margin: 8px 0 16px; border-bottom: 1px solid var(--line); }
.tabs button {
  flex: 1; background: none; border: 0; color: var(--muted); font: inherit; padding: 12px 0; cursor: pointer;
  border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.tabs button.active { color: var(--text); border-color: var(--accent); }

button { font: inherit; -webkit-tap-highlight-color: transparent; }
button:focus-visible, input:focus-visible, .drop:focus-within { outline: 2px solid var(--accent); outline-offset: 2px; }

.card { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 14px; margin-bottom: 14px; }

.drop {
  display: flex; flex-direction: column; align-items: center; gap: 4px; text-align: center;
  border: 2px dashed var(--line); border-radius: 16px; padding: 40px 16px; color: var(--muted); cursor: pointer;
  background: var(--panel);
}
.drop svg { color: var(--accent); margin-bottom: 6px; }
.drop strong { color: var(--text); font-size: 1.05rem; }
.drop.over { border-color: var(--accent); }

#preview { width: 100%; max-height: 28vh; background: #000; border-radius: 10px; display: block; object-fit: contain; }
.fileRow { display: flex; gap: 12px; align-items: center; margin-top: 10px; }
.fileInfo { flex: 1; min-width: 0; font-size: .9rem; color: var(--muted); }
.fileInfo b { display: block; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }

fieldset { border: 0; padding: 0; margin: 0 0 14px; min-width: 0; }
#tabSeg { margin-bottom: 14px; }
legend { font-size: .8rem; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; margin-bottom: 6px; padding: 0; }
.seg { display: flex; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 3px; gap: 3px; }
.seg button {
  flex: 1; border: 0; background: none; color: var(--muted); padding: 10px 6px; border-radius: 9px; cursor: pointer; min-height: 44px; line-height: 1.2;
}
.seg button small { display: block; font-size: .7rem; opacity: .8; }
.seg button[aria-pressed="true"] { background: var(--accent); color: var(--accent-ink); font-weight: 600; }

.trim { margin: 0; }
.trimLen { text-transform: none; letter-spacing: 0; color: var(--text); font-weight: 600; margin-left: 6px; }
.trimRow { display: grid; grid-template-columns: 56px 1fr 74px; gap: 10px; align-items: center; margin-bottom: 10px; }
.trimRow label { font-size: .85rem; color: var(--muted); }
.trimRow input[type=range] { width: 100%; margin: 0; min-height: 32px; accent-color: var(--accent); }
.trimRow input.time { min-height: 38px; margin: 0; padding: 6px 8px; text-align: center; font-variant-numeric: tabular-nums; font-size: .9rem; }
.trimBtns { display: flex; gap: 8px; flex-wrap: wrap; }
.trimBtns .ghost { flex: 1 1 auto; min-height: 40px; padding: 8px 10px; font-size: .85rem; }
.editorTrack { padding-top: 12px; margin-top: 2px; border-top: 1px solid var(--line); }
.audioTimeline { margin-bottom: 10px; }
.audioRuler { position: relative; height: 16px; font-size: .7rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.audioRuler span { position: absolute; top: 0; white-space: nowrap; }
.audioTrack {
  position: relative; height: 56px; border-radius: 10px; background: var(--panel-2); border: 1px solid var(--line);
  overflow: hidden; touch-action: none;
}
.audioZero { position: absolute; top: 0; bottom: 0; left: 0; width: 0; border-left: 1px dashed var(--muted); opacity: .6; }
.audioClip {
  position: absolute; top: 4px; bottom: 4px; min-width: 6px; border-radius: 7px;
  background: var(--accent); opacity: .85; cursor: grab; touch-action: none;
}
.audioClip:active { cursor: grabbing; opacity: 1; }
.audioClip:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.apkHint { margin: 8px 0 24px; }
.targetHint { margin: -6px 0 14px; }
.hint.err { color: var(--danger); }
.hint.ok { color: var(--accent); }
.linkBtn.alt { background: none; color: var(--accent); border: 2px solid var(--accent); }
.fullBtn { flex: 1 1 auto !important; }
.appRow { margin-top: 12px; }
.linkBtn { display: flex; align-items: center; justify-content: center; text-align: center; text-decoration: none; padding: 8px 14px; line-height: 1.25; }
.actRow { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-top: 1px solid var(--line); }
.actRow .num { font-weight: 600; font-variant-numeric: tabular-nums; }
.actRow .when { flex: 1; min-width: 0; }
.actRow .ghost { min-height: 36px; padding: 6px 10px; font-size: .85rem; margin: 0; }

.logRow { display: flex; align-items: flex-start; gap: 10px; padding: 10px 0; border-top: 1px solid var(--line); }
.logRow .dot { flex: 0 0 auto; width: 9px; height: 9px; border-radius: 50%; margin-top: 6px; background: var(--accent); }
.logRow .dot.bad { background: var(--danger); }
.logRow .body { flex: 1; min-width: 0; }
.logRow .title { font-weight: 600; }
.logRow .title .tag { font-weight: 500; color: var(--muted); }
.logRow .err { color: var(--danger); }
.hint { color: var(--muted); font-size: .85rem; margin: 6px 0 0; }
.check { display: flex; gap: 10px; align-items: center; color: var(--muted); font-size: .9rem; margin: 0 0 14px; min-height: 32px; }
.check input { width: 20px; height: 20px; accent-color: var(--accent); }

.summary { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px 12px; }
.summary div { min-width: 0; }
.summary .k { font-size: .72rem; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
.summary .v { font-size: 1.05rem; font-weight: 600; font-variant-numeric: tabular-nums; }
.summary .warn { grid-column: 1 / -1; color: var(--warn); font-size: .85rem; }
.summary .q-good { color: var(--accent); }
.summary .q-low { color: var(--warn); }

.primary {
  width: 100%; min-height: 50px; border: 0; border-radius: 12px; background: var(--accent); color: var(--accent-ink);
  font-weight: 700; font-size: 1rem; cursor: pointer;
}
.primary:disabled { opacity: .5; cursor: not-allowed; }
.ghost { border: 1px solid var(--line); background: none; color: var(--text); border-radius: 10px; padding: 10px 14px; min-height: 44px; cursor: pointer; }
.fileBtn {
  display: flex; align-items: center; justify-content: center; gap: 6px; width: 100%;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.ghost.danger { color: var(--danger); margin-top: 10px; }
.row { display: flex; gap: 10px; margin-top: 12px; }
.row > * { flex: 1; }
.row .ghost { flex: 0 0 auto; }

.progTitle { font-weight: 600; margin-bottom: 10px; }
.bar { height: 10px; background: var(--panel-2); border-radius: 999px; overflow: hidden; }
.bar i { display: block; height: 100%; width: 0; background: var(--accent); border-radius: 999px; transition: width .3s; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 12px; }
.chip { min-width: 34px; text-align: center; padding: 4px 8px; border-radius: 8px; font-size: .8rem; background: var(--panel-2); color: var(--muted); font-variant-numeric: tabular-nums; }
.chip.enc { outline: 1px solid var(--accent); color: var(--text); }
.chip.up { background: color-mix(in srgb, var(--accent) 25%, var(--panel-2)); color: var(--text); }
.chip.sent { background: var(--accent); color: var(--accent-ink); font-weight: 600; }
.error { margin-top: 12px; color: var(--danger); background: color-mix(in srgb, var(--danger) 12%, transparent); border-radius: 10px; padding: 10px 12px; font-size: .9rem; overflow-wrap: anywhere; }

.doneCard { text-align: center; }
.doneCard .tick { width: 56px; height: 56px; margin: 4px auto 8px; border-radius: 50%; background: var(--accent); color: var(--accent-ink); font-size: 30px; line-height: 56px; font-weight: 700; }
.doneCard ol { text-align: left; color: var(--muted); font-size: .92rem; padding-left: 1.2em; margin: 12px 0 16px; }
.doneCard li { margin-bottom: 6px; }
.doneCard li b { color: var(--text); }

.field { display: block; font-size: .85rem; color: var(--muted); margin-bottom: 12px; }
.field small { opacity: .8; }
input:not([type=checkbox]):not([type=file]), select, textarea {
  display: block; width: 100%; margin-top: 4px; min-height: 46px; padding: 10px 12px; border-radius: 10px;
  border: 1px solid var(--line); background: var(--panel-2); color: var(--text); font: inherit;
}
textarea { resize: vertical; }
.row input { margin-top: 0; }
.qr { display: block; width: 240px; max-width: 100%; margin: 12px auto; border-radius: 10px; background: #fff; padding: 8px; }
.pairCode { font: 700 1.8rem/1 ui-monospace, Consolas, monospace; letter-spacing: .12em; text-align: center; margin-top: 14px; color: var(--accent); user-select: all; }

.pairCode.err { font: 500 .9rem/1.4 system-ui, sans-serif; letter-spacing: 0; color: var(--danger); user-select: text; }

@media (prefers-reduced-motion: reduce) { .bar i { transition: none; } }
