/* File actions follow the existing site palette. Native links remain the
   primary download path; this sheet explains the phone's file controls. */
.mobile-file-options { display: none; }
.phone-download-backdrop { position: fixed; inset: 0; z-index: 100000; background: rgba(4,5,7,.75); backdrop-filter: blur(5px); }
.phone-download-backdrop[hidden] { display: none !important; }
.phone-download-dialog {
    width: min(540px, calc(100% - 32px)); max-width: 540px;
    max-height: calc(100vh - 32px); max-height: calc(100dvh - 32px);
    margin: auto; padding: 0; color: #f4f4f5; background: #131316;
    border: 1px solid rgba(255,255,255,.15); border-radius: 18px;
    box-shadow: 0 24px 100px rgba(0,0,0,.55); overflow: auto;
    overscroll-behavior: contain; font-family: var(--font,system-ui,sans-serif);
    text-align: start; line-height: 1.6;
}
.phone-download-dialog:not([open]) { display: none; }
.phone-download-dialog.is-fallback { position: fixed; inset: 16px; z-index: 100001; }
.phone-download-dialog::backdrop { background: rgba(4,5,7,.75); backdrop-filter: blur(5px); }
.phone-download-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; padding: 20px 20px 16px; border-bottom: 1px solid rgba(255,255,255,.1); position: sticky; top: 0; z-index: 1; background: #131316; }
.phone-download-header h2 { margin: 0; font-size: 20px; line-height: 1.4; letter-spacing: -.02em; }
.phone-download-close { flex: 0 0 44px; width: 44px; min-height: 44px; display: grid; place-items: center; margin: -6px -6px -6px 0; padding: 0; background: #202025; border: 1px solid rgba(255,255,255,.12); border-radius: 10px; color: #f4f4f5; font: 28px/1 system-ui; cursor: pointer; }
.phone-download-body { padding: 20px; min-width: 0; }
.phone-download-filename { display: block; margin: 0 0 16px; color: #f4f4f5; font: 600 15px/1.55 ui-monospace,Consolas,monospace; overflow-wrap: anywhere; user-select: text; }
.phone-download-note { margin: 12px 0; color: #b6b6c0; font-size: 14px; line-height: 1.7; overflow-wrap: anywhere; }
.phone-download-note a { color: #a7eacb; text-decoration: underline; text-underline-offset: 3px; }
.phone-download-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-block: 16px; }
.phone-download-dialog :is(button,a) { touch-action: manipulation; }
.phone-download-actions :is(button,a) { flex: 1 1 180px; display: inline-flex; align-items: center; justify-content: center; min-width: 0; min-height: 48px; max-width: 100%; padding: 12px 16px; border: 1px solid rgba(255,255,255,.2); border-radius: 11px; background: #1d1d23; color: #f4f4f5; font: 600 14px/1.45 var(--font,system-ui,sans-serif); text-align: center; white-space: normal; overflow-wrap: anywhere; text-decoration: none; cursor: pointer; }
.phone-download-actions .phone-download-link { border-color: #facc15; color: #facc15; background: #17171b; }
.phone-download-actions :is(button,a):active { background: #282830; }
.phone-download-dialog :is(button,a):focus-visible { outline: 2px solid #a7f3d0; outline-offset: 3px; }
.phone-download-dialog button:disabled { opacity: .55; cursor: wait; }
.phone-download-dialog input, .phone-download-dialog textarea { display: block; width: 100%; min-width: 0; padding: 12px; border: 1px solid rgba(255,255,255,.2); border-radius: 9px; background: #0a0a0c; color: #ededf0; font: 16px/1.55 ui-monospace,Consolas,monospace; user-select: text; }
.phone-download-status { min-height: 1.6em; margin-block: 12px 0; color: #b8f2d8; font-size: 14px; overflow-wrap: anywhere; }
.phone-download-status[data-state="error"] { color: #ffb4b4; }
.phone-download-dialog [hidden] { display: none !important; }
.phone-download-dialog progress { width: 100%; height: 10px; accent-color: #6ee7b7; }
.phone-download-help { display: inline-flex; align-items: center; min-height: 44px; color: #a7eacb; text-decoration: underline; text-underline-offset: 3px; }
@media (max-width: 1024px), (pointer: coarse) {
    .mobile-file-options { display: inline-flex; align-items: center; justify-content: center; min-width: 44px; min-height: 44px; max-width: 100%; gap: 6px; margin-block: 4px; margin-inline-start: 6px; padding: 10px 13px; border: 1px solid rgba(255,255,255,.17); border-radius: 10px; background: rgba(255,255,255,.025); color: #bec7c2; font: 500 13px/1.45 var(--font,system-ui,sans-serif); text-align: center; white-space: normal; cursor: pointer; touch-action: manipulation; }
    .mobile-file-options:focus-visible { outline: 2px solid #a7f3d0; outline-offset: 3px; }
    .mobile-file-options:active { background: rgba(110,231,183,.1); }
    .guide-links > .mobile-file-options, .cheat-actions > .mobile-file-options { flex: 0 1 auto; margin: 0; }
}
@media (max-width: 600px) {
    .phone-download-dialog { width: 100%; max-width: none; margin: auto 0 0; max-height: calc(100dvh - 16px - env(safe-area-inset-top)); border-bottom: 0; border-radius: 18px 18px 0 0; padding-bottom: env(safe-area-inset-bottom); }
    .phone-download-dialog.is-fallback { inset: auto 0 0; margin: 0; }
    .phone-download-header { position: sticky; top: 0; background: #131316; z-index: 1; padding-inline: max(20px,env(safe-area-inset-left)) max(20px,env(safe-area-inset-right)); }
    .phone-download-body { padding-inline: max(20px,env(safe-area-inset-left)) max(20px,env(safe-area-inset-right)); }
    .phone-download-actions :is(button,a) { flex-basis: 100%; }
}
@media (max-height: 480px) and (orientation: landscape) {
    .phone-download-dialog { max-height: calc(100dvh - 16px); margin: auto; width: min(680px,calc(100% - 32px)); max-width: 680px; border-radius: 14px; }
    .phone-download-actions :is(button,a) { flex-basis: 180px; }
    .phone-download-header, .phone-download-body { padding-block: 12px; }
}
@media (prefers-reduced-motion: reduce) { .phone-download-dialog, .mobile-file-options { scroll-behavior: auto; transition: none; } }
