:root {
    color-scheme: light;
    --background: #f7f0eb;
    --surface: rgba(255, 255, 255, 0.92);
    --surface-strong: #ffffff;
    --text: #3c3033;
    --muted: #7d6e72;
    --accent: #a65068;
    --accent-dark: #813c51;
    --accent-soft: #f3dce3;
    --border: #ead8dd;
    --success: #287a58;
    --danger: #a83946;
    --shadow: 0 1.2rem 3rem rgba(76, 44, 54, 0.11);
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-height: 100vh;
    background:
        radial-gradient(circle at 10% 10%, #fde8ef 0, transparent 35%),
        radial-gradient(circle at 90% 90%, #eee1d5 0, transparent 34%),
        var(--background);
    color: var(--text);
    font-family:
        "Noto Sans Arabic",
        Tahoma,
        Arial,
        sans-serif;
}

button,
input {
    font: inherit;
}

button,
.download-button {
    border: 0;
    border-radius: 0.8rem;
    padding: 0.72rem 1.25rem;
    background: var(--accent);
    color: #fff;
    cursor: pointer;
    text-decoration: none;
    white-space: nowrap;
    transition:
        transform 160ms ease,
        opacity 160ms ease,
        background 160ms ease;
}

button:hover,
.download-button:hover {
    background: var(--accent-dark);
    transform: translateY(-0.08rem);
}

button:disabled {
    cursor: not-allowed;
    opacity: 0.48;
    transform: none;
}

.secondary-button {
    background: transparent;
    color: var(--accent-dark);
    border: 0.08rem solid var(--border);
}

.secondary-button:hover {
    background: var(--accent-soft);
}

.topbar {
    width: min(94%, 76rem);
    margin: 1.3rem auto 0;
    padding: 1rem 1.3rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    background: rgba(255, 255, 255, 0.72);
    border: 0.08rem solid rgba(255, 255, 255, 0.75);
    border-radius: 1.2rem;
    backdrop-filter: blur(1rem);
}

.topbar > div {
    display: flex;
    align-items: baseline;
    gap: 0.7rem;
}

.topbar strong {
    color: var(--accent-dark);
    font-size: 1.16rem;
}

.topbar span {
    color: var(--muted);
    font-size: 0.88rem;
}

.page-shell {
    width: min(94%, 76rem);
    margin: 1.3rem auto 3rem;
    display: grid;
    gap: 1.3rem;
}

.upload-card,
.files-card,
.login-card {
    background: var(--surface);
    border: 0.08rem solid rgba(255, 255, 255, 0.8);
    border-radius: 1.5rem;
    box-shadow: var(--shadow);
}

.upload-card,
.files-card {
    padding: clamp(1.1rem, 3vw, 2rem);
}

.section-heading {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1.2rem;
}

.section-heading h1,
.section-heading h2 {
    margin: 0;
}

.section-heading p {
    margin: 0.3rem 0 0;
    color: var(--muted);
    font-size: 0.9rem;
}

.count-badge {
    min-width: 2.2rem;
    height: 2.2rem;
    display: grid;
    place-items: center;
    background: var(--accent-soft);
    color: var(--accent-dark);
    border-radius: 999rem;
    font-weight: 700;
}

.drop-zone {
    min-height: 13rem;
    border: 0.13rem dashed #d7aeba;
    border-radius: 1.2rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.45rem;
    text-align: center;
    padding: 1.5rem;
    cursor: pointer;
    background: rgba(255, 250, 251, 0.72);
    transition:
        border-color 180ms ease,
        background 180ms ease,
        transform 180ms ease;
}

.drop-zone:hover,
.drop-zone:focus,
.drop-zone.drag-active {
    outline: none;
    border-color: var(--accent);
    background: var(--accent-soft);
    transform: translateY(-0.1rem);
}

.upload-icon {
    width: 3.2rem;
    height: 3.2rem;
    display: grid;
    place-items: center;
    border-radius: 50%;
    background: var(--accent);
    color: #fff;
    font-size: 1.6rem;
    margin-bottom: 0.25rem;
}

.drop-zone span {
    color: var(--muted);
    font-size: 0.9rem;
}

.upload-actions {
    margin-top: 1rem;
    display: flex;
    flex-wrap: wrap;
    gap: 0.7rem;
}

.upload-queue {
    margin-top: 1rem;
    display: grid;
    gap: 0.65rem;
}

.queue-row {
    display: grid;
    grid-template-columns:
        minmax(9rem, 1.4fr)
        minmax(7rem, 1fr)
        4.8rem
        2.3rem;
    align-items: center;
    gap: 0.75rem;
    padding: 0.8rem;
    background: #fff;
    border: 0.08rem solid var(--border);
    border-radius: 0.9rem;
}

.queue-file {
    min-width: 0;
}

.queue-file strong {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.queue-file span,
.progress-text {
    color: var(--muted);
    font-size: 0.8rem;
}

.progress-track {
    height: 0.55rem;
    overflow: hidden;
    background: #f0e6e8;
    border-radius: 999rem;
}

.progress-bar {
    width: 0;
    height: 100%;
    background: var(--accent);
    border-radius: inherit;
    transition: width 120ms linear;
}

.queue-row.success .progress-bar {
    background: var(--success);
}

.queue-row.failed .progress-bar {
    background: var(--danger);
}

.remove-file {
    width: 2.2rem;
    height: 2.2rem;
    padding: 0;
    border-radius: 50%;
    background: transparent;
    color: var(--danger);
    border: 0.08rem solid var(--border);
    font-size: 1.25rem;
}

.status-message {
    min-height: 1.6rem;
    margin-top: 0.8rem;
    font-size: 0.9rem;
}

.status-message.success {
    color: var(--success);
}

.status-message.error {
    color: var(--danger);
}

.file-list {
    display: grid;
    gap: 0.7rem;
}

.file-row {
    padding: 1rem;
    background: var(--surface-strong);
    border: 0.08rem solid var(--border);
    border-radius: 1rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}

.file-info {
    min-width: 0;
}

.file-info strong {
    display: block;
    overflow-wrap: anywhere;
}

.file-meta {
    margin-top: 0.35rem;
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem 0.8rem;
    color: var(--muted);
    font-size: 0.78rem;
    direction: ltr;
    justify-content: flex-end;
}

.file-actions {
    display: flex;
    align-items: center;
    gap: 0.55rem;
    flex-shrink: 0;
}

.file-actions form {
    margin: 0;
}

.download-button,
.delete-button {
    padding: 0.58rem 0.9rem;
    font-size: 0.86rem;
}

.delete-button {
    background: transparent;
    color: var(--danger);
    border: 0.08rem solid #e8c4c9;
}

.delete-button:hover {
    color: #fff;
    background: var(--danger);
}

.empty-state {
    padding: 2.4rem 1rem;
    text-align: center;
    color: var(--muted);
    background: rgba(255, 255, 255, 0.55);
    border-radius: 1rem;
}

.login-page {
    display: grid;
    place-items: center;
    padding: 5%;
}

.login-card {
    width: min(94%, 27rem);
    padding: clamp(1.5rem, 5vw, 2.4rem);
}

.brand-mark {
    display: inline-flex;
    padding: 0.4rem 0.8rem;
    border-radius: 999rem;
    background: var(--accent-soft);
    color: var(--accent-dark);
    font-weight: 700;
}

.login-card h1 {
    margin: 1rem 0 0.2rem;
}

.muted {
    color: var(--muted);
    margin-top: 0;
}

.login-form {
    display: grid;
    gap: 1rem;
    margin-top: 1.5rem;
}

.login-form label {
    display: grid;
    gap: 0.4rem;
    font-size: 0.9rem;
}

.login-form input {
    width: 100%;
    padding: 0.8rem 0.9rem;
    border: 0.08rem solid var(--border);
    border-radius: 0.8rem;
    background: #fff;
    color: var(--text);
}

.login-form input:focus {
    outline: 0.12rem solid rgba(166, 80, 104, 0.22);
    border-color: var(--accent);
}

.message {
    padding: 0.75rem 0.9rem;
    border-radius: 0.8rem;
    margin-top: 1rem;
}

.message.error {
    color: var(--danger);
    background: #fff0f2;
}

@media (max-width: 46rem) {
    .topbar {
        align-items: center;
    }

    .topbar span {
        display: none;
    }

    .queue-row {
        grid-template-columns: minmax(0, 1fr) 2.3rem;
    }

    .progress-track,
    .progress-text {
        grid-column: 1 / -1;
    }

    .remove-file {
        grid-column: 2;
        grid-row: 1;
    }

    .file-row {
        align-items: stretch;
        flex-direction: column;
    }

    .file-actions {
        justify-content: flex-start;
    }

    .file-meta {
        direction: rtl;
        justify-content: flex-start;
    }
}


/* Native file picker: reliable on Android, iPhone and desktop */
.drop-zone {
    position: relative;
    overflow: hidden;
    cursor: pointer;
}

.file-input-overlay {
    position: absolute;
    inset: 0;
    z-index: 5;
    width: 100%;
    height: 100%;
    margin: 0;
    padding: 0;
    opacity: 0;
    cursor: pointer;
}

.native-upload-form {
    display: grid;
    gap: 1rem;
    padding: clamp(1rem, 4vw, 1.6rem);
    border: 0.13rem dashed #d7aeba;
    border-radius: 1.2rem;
    background: rgba(255, 250, 251, 0.72);
}

.native-file-label {
    font-weight: 700;
    color: var(--accent-dark);
}

.native-file-input {
    display: block;
    width: 100%;
    padding: 0.8rem;
    border: 0.08rem solid var(--border);
    border-radius: 0.8rem;
    background: #fff;
    color: var(--text);
}

.native-submit-button {
    justify-self: start;
    width: fit-content;
    min-width: max-content;
}

.message.success {
    color: var(--success);
    background: #edf8f2;
}
.selected-file-info{
    min-height:1.4rem;
    color:var(--muted);
    font-size:.9rem;
    overflow-wrap:anywhere;
    margin-top:.3rem;
}

.native-progress-box{
    display:grid;
    gap:.6rem;
    margin-top:1rem;
    padding:.8rem;
    border:.08rem solid var(--border);
    border-radius:.8rem;
    background:#fff;
    align-items:start;
}

.native-progress-box[hidden]{
    display:none;
}

.native-progress-header{
    display:flex;
    justify-content:space-between;
    align-items:center;
    gap:1rem;
}

.native-progress-track{
    width:100%;
    height:.7rem;
    border-radius:999px;
    overflow:hidden;
    background:#ececec;
}

.native-progress-bar{
    width:0;
    height:100%;
    background:var(--accent);
    transition:width .15s linear;
}
.native-cancel-button{
    justify-self:start;
    width:fit-content;
    min-width:max-content;
    margin-top:.8rem;
    padding:.55rem .9rem;
    background:transparent;
    color:var(--danger);
    border:.08rem solid #e8c4c9;
}

.native-cancel-button:hover{
    background:var(--danger);
    color:#fff;
}

.native-cancel-button[hidden]{
    display:none;
}
