:root {
  color-scheme: dark;
  --bg: #000;
  --card: #111;
  --ink: #f5f5f5;
  --muted: #929292;
  --line: #292929;
  --accent: #8abfff;
  --red: #ff716b;
  --safe-top: var(--tg-content-safe-area-inset-top, 0px);
  --safe-bottom: max(env(safe-area-inset-bottom, 0px), var(--tg-content-safe-area-inset-bottom, 0px));
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", sans-serif;
  font-synthesis: none;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--ink); -webkit-font-smoothing: antialiased; }
button, input, textarea, a { -webkit-tap-highlight-color: transparent; }
button, input, textarea { font: inherit; }
button { touch-action: manipulation; cursor: pointer; }
button:disabled { cursor: default; }
button:focus-visible, a:focus-visible, input:focus-visible, textarea:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
[hidden] { display: none !important; }
.app { max-width: 560px; margin: auto; padding: calc(24px + var(--safe-top)) 20px calc(24px + var(--safe-bottom)); min-height: var(--tg-viewport-stable-height, 100dvh); }
.input-wrap { display: flex; align-items: center; gap: 8px; min-height: 54px; padding: 0 5px 0 16px; border: 1px solid #242424; border-radius: 14px; background: var(--card); }
.input-wrap textarea { border: 0; outline: none; background: none; color: var(--ink); width: 100%; min-width: 0; font-size: 16px; line-height: 1.4; padding: 15px 0; resize: vertical; min-height: 100px; max-height: 240px; }
.input-wrap textarea::placeholder { color: #858585; }
.input-wrap:focus-within { border-color: #555; }
.paste-button { display: flex; align-items: center; justify-content: center; border: 0; background: none; color: #bbb; font-size: 12px; padding: 0 11px; min-height: 44px; flex-shrink: 0; border-radius: 10px; }
.paste-button:active { background: #222; }
.paste-button:disabled { opacity: .4; }
.destination-picker { display: flex; gap: 3px; padding: 3px; margin-top: 10px; border-radius: 12px; background: #161616; }
.destination-picker button { flex: 1; min-width: 0; min-height: 38px; padding: 7px 12px; border: 0; border-radius: 9px; background: none; color: #929292; font-size: 13px; font-weight: 500; transition: background .15s, color .15s; }
.destination-picker button[aria-pressed="true"] { background: #343434; color: #f5f5f5; box-shadow: 0 1px 3px #0004; }
.download-button { display: flex; align-items: center; justify-content: center; gap: 8px; width: 100%; margin-top: 10px; min-height: 50px; border: 0; border-radius: 14px; color: #090909; background: #f1f1f1; font-size: 15px; font-weight: 600; letter-spacing: -.15px; transition: opacity .15s, transform .15s; }
.download-button:active { transform: scale(.985); opacity: .85; }
.download-button:disabled { opacity: .5; }
.download-button > span:first-child { display: flex; }
.download-button > span:first-child:empty { display: none; }
.icon { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.error { color: var(--red); font-size: 12px; line-height: 1.5; margin: 12px 0 0; }
.queue-section { margin-top: 24px; }
.queue-item { padding: 10px 12px 12px; margin-bottom: 8px; background: var(--card); border-radius: 14px; }
.queue-body { min-width: 0; }
.queue-main { display: flex; gap: 10px; align-items: center; }
.queue-thumb { width: 40px; height: 40px; border-radius: 8px; overflow: hidden; flex-shrink: 0; position: relative; display: flex; align-items: center; justify-content: center; background: #1d1d1d; color: #666; }
.queue-thumb img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.queue-thumb > .icon { width: 18px; height: 18px; }
.queue-info { flex: 1; min-width: 0; }
.queue-title { font-size: 12px; font-weight: 500; line-height: 1.5; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; margin: 0 0 3px; }
.queue-meta { color: var(--muted); font-size: 10px; line-height: 1.4; font-variant-numeric: tabular-nums; }
.queue-details { display: flex; align-items: baseline; gap: 7px; min-width: 0; }
.queue-destination { color: #aaa; font-size: 10px; line-height: 1.4; }
.queue-action { border: 0; padding: 0; width: 44px; height: 44px; margin-right: -8px; border-radius: 50%; background: none; color: #999; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.queue-action:active { color: white; }
.queue-action .icon { width: 14px; height: 14px; }
.queue-footer { display: flex; align-items: center; gap: 18px; margin-top: 8px; }
.stage-rail { display: flex; align-items: center; flex-shrink: 0; gap: 3px; height: 18px; }
.stage { display: flex; align-items: center; justify-content: center; width: 16px; height: 16px; color: #494949; }
.stage .icon { width: 13px; height: 13px; stroke-width: 1.5; }
.stage.complete { color: #969696; }
.stage.current { color: var(--accent); }
.stage.current .icon { stroke-width: 1.9; }
.stage-line { height: 1px; width: 6px; background: #303030; }
.stage-line.complete { background: #626262; }
.progress-wrap { display: flex; align-items: center; gap: 7px; flex: 1; min-width: 0; }
.progress-track { height: 2px; border-radius: 3px; background: #2a2a2a; flex: 1; overflow: hidden; }
.progress-fill { height: 100%; border-radius: 3px; background: #b3b3b3; transition: width .5s; }
.progress-fill.indeterminate { width: 30%; animation: slide 1.7s ease-in-out infinite; }
.progress-value { color: var(--muted); font-size: 9px; line-height: 1; text-align: right; font-variant-numeric: tabular-nums; }
.progress-value:empty { display: none; }
.gate { position: fixed; inset: 0; z-index: 40; background: var(--bg); display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; padding: 32px; }
.gate p { max-width: 310px; font-size: 14px; line-height: 1.6; color: var(--muted); }
.gate a { display: flex; align-items: center; justify-content: center; min-height: 48px; border-radius: 13px; background: #eee; color: #111; text-decoration: none; font-size: 14px; font-weight: 550; padding: 12px 22px; margin-top: 8px; }
.toast { position: fixed; z-index: 45; left: 50%; bottom: calc(22px + var(--safe-bottom)); transform: translateX(-50%); background: #242424; color: #eee; padding: 12px 16px; border-radius: 12px; font-size: 12px; line-height: 1.5; max-width: calc(100% - 36px); width: max-content; }
.loading-icon { animation: spin 1s linear infinite; }
.error-box { padding: 12px 0; font-size: 12px; line-height: 1.6; color: var(--red); }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes slide { 0%, 100% { transform: translateX(-30%); } 50% { transform: translateX(280%); } }
@keyframes shimmer { to { background-position: -220% 0; } }
@media (min-width: 520px) {
  .app { padding-top: calc(32px + var(--safe-top)); }
}
@media (max-width: 350px) {
  .app { padding-left: 16px; padding-right: 16px; }
  .queue-footer { gap: 12px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
