@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800;900&display=swap');

*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }

:root {
    --bg: #09090b;
    --card: #18181b;
    --card-border: rgba(255,255,255,0.06);
    --surface: #27272a;
    --text: #fafafa;
    --text-muted: #a1a1aa;
    --text-dim: #71717a;
    --accent: #818cf8;
    --accent-glow: rgba(129,140,248,0.15);
    --accent-vivid: #6366f1;
    --danger: #f87171;
    --success: #34d399;
    --radius: 12px;
}

html { height: 100%; }

body {
    font-family: 'Inter', system-ui, sans-serif;
    background: var(--bg);
    color: var(--text);
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    overflow: hidden;
}

body::before {
    content: '';
    position: fixed; inset: 0;
    background:
        radial-gradient(ellipse 80% 60% at 50% -20%, rgba(99,102,241,0.08), transparent),
        radial-gradient(ellipse 60% 40% at 80% 100%, rgba(129,140,248,0.05), transparent);
    pointer-events: none; z-index: 0;
}

/* ── Layout ── */
.app-wrapper {
    position: relative; z-index: 1;
    display: flex; flex-direction: column; align-items: center;
    width: 100%; max-width: 460px;
    height: 100vh; max-height: 100vh;
    padding: 1.25rem 1rem;
    overflow: hidden;
}

/* ── Header ── */
header { text-align: center; margin-bottom: 1rem; flex-shrink: 0; }

.logo {
    font-size: 2.25rem; font-weight: 900; letter-spacing: -2px;
    background: linear-gradient(135deg, var(--accent) 0%, #c084fc 100%);
    -webkit-background-clip: text; -webkit-text-fill-color: transparent;
    background-clip: text; line-height: 1; margin: 0;
}

.logo-sub {
    font-size: 0.6rem; font-weight: 700; color: var(--text-dim);
    text-transform: uppercase; letter-spacing: 3px;
    margin-top: 3px; display: block;
}

/* ── Card ── */
.card {
    background: var(--card);
    border: 1px solid var(--card-border);
    border-radius: 16px;
    padding: 1.25rem;
    width: 100%;
    flex: 1 1 auto;
    overflow-y: auto;
    min-height: 0;
    scrollbar-width: thin;
    scrollbar-color: var(--surface) transparent;
}

.card::-webkit-scrollbar { width: 4px; }
.card::-webkit-scrollbar-track { background: transparent; }
.card::-webkit-scrollbar-thumb { background: var(--surface); border-radius: 4px; }

/* ── Upload Zone ── */
.upload-zone {
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    gap: 0.35rem; padding: 1rem;
    border: 2px dashed rgba(255,255,255,0.08);
    border-radius: var(--radius);
    background: rgba(255,255,255,0.02);
    cursor: pointer; transition: all 0.3s ease;
    margin-bottom: 1rem;
}

.upload-zone:hover, .upload-zone.drag-over {
    border-color: var(--accent); background: var(--accent-glow);
}

.upload-zone.has-file { border-color: var(--success); border-style: solid; }

.upload-icon { font-size: 1.5rem; }
.upload-text { font-size: 0.8rem; font-weight: 500; color: var(--text-muted); transition: color 0.3s; }
.upload-hint { font-size: 0.7rem; color: var(--text-dim); }
input[type="file"] { display: none; }

/* ── Mode Switch ── */
.mode-switch {
    position: relative; display: flex;
    background: var(--surface); border-radius: 8px;
    padding: 3px; margin-bottom: 1rem;
}

.mode-switch input[type="radio"] { display: none; }

.mode-switch label {
    flex: 1; text-align: center; padding: 7px 0;
    font-size: 0.78rem; font-weight: 600;
    color: var(--text-dim); cursor: pointer;
    border-radius: 6px; transition: all 0.25s ease;
    z-index: 1; margin: 0; display: block;
}

.mode-switch input[type="radio"]:checked + label {
    color: var(--text); background: rgba(129,140,248,0.12);
    box-shadow: 0 1px 4px rgba(0,0,0,0.3);
}

/* ── Control Groups ── */
.control-group { margin-bottom: 0.85rem; }
.control-group.hidden { display: none; }

.control-label {
    display: flex; justify-content: space-between; align-items: center;
    margin-bottom: 0.4rem;
}

.control-label span {
    font-size: 0.78rem; font-weight: 600; color: var(--text-muted);
}

.badge {
    font-size: 0.72rem; font-weight: 700; color: var(--accent);
    background: var(--accent-glow); padding: 2px 8px; border-radius: 4px;
}

/* ── Range Slider ── */
input[type="range"] {
    -webkit-appearance: none; appearance: none;
    width: 100%; height: 6px;
    background: var(--surface); border-radius: 3px;
    outline: none; cursor: pointer;
    border: none; padding: 0;
}

input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none; appearance: none;
    width: 18px; height: 18px;
    background: var(--accent); border-radius: 50%;
    cursor: pointer; box-shadow: 0 0 8px rgba(129,140,248,0.4);
    transition: transform 0.15s;
}

input[type="range"]::-webkit-slider-thumb:hover { transform: scale(1.15); }

input[type="range"]::-moz-range-thumb {
    width: 18px; height: 18px; border: none;
    background: var(--accent); border-radius: 50%;
    cursor: pointer; box-shadow: 0 0 8px rgba(129,140,248,0.4);
}

/* ── Control Meta ── */
.control-meta {
    display: flex; justify-content: space-between; align-items: center;
    margin-top: 0.35rem;
}

.hint { font-size: 0.68rem; color: var(--text-dim); }

.est-size {
    font-size: 0.7rem; font-weight: 600; color: var(--accent);
    background: rgba(129,140,248,0.08);
    padding: 2px 8px; border-radius: 4px;
}

/* ── Text / Number Inputs ── */
input[type="text"], input[type="number"] {
    width: 100%; padding: 0.6rem 0.75rem;
    background: var(--surface); border: 1px solid rgba(255,255,255,0.06);
    border-radius: 8px; color: var(--text);
    font-family: inherit; font-size: 0.85rem;
    outline: none; transition: border-color 0.2s, box-shadow 0.2s;
}

input[type="text"]:focus, input[type="number"]:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(129,140,248,0.1);
}

input[type="text"]::placeholder, input[type="number"]::placeholder {
    color: var(--text-dim);
}

.target-input-wrap {
    position: relative;
}

.target-input-wrap .input-suffix {
    position: absolute; right: 12px; top: 50%; transform: translateY(-50%);
    font-size: 0.75rem; font-weight: 700; color: var(--text-dim);
    pointer-events: none;
}

.target-input-wrap input { padding-right: 3rem; }

/* ── Toggle ── */
.toggle-row {
    display: flex; align-items: center; gap: 0.65rem;
    background: var(--surface); padding: 0.65rem 0.85rem;
    border-radius: 8px; margin-bottom: 1rem;
}

.toggle-switch { position: relative; width: 36px; height: 20px; flex-shrink: 0; margin: 0; }
.toggle-switch input { display: none; }

.toggle-track {
    position: absolute; inset: 0;
    background: rgba(255,255,255,0.1); border-radius: 10px;
    cursor: pointer; transition: background 0.25s;
}

.toggle-track::after {
    content: ''; position: absolute;
    top: 2px; left: 2px; width: 16px; height: 16px;
    background: var(--text-dim); border-radius: 50%;
    transition: transform 0.25s, background 0.25s;
}

.toggle-switch input:checked + .toggle-track { background: var(--accent-vivid); }
.toggle-switch input:checked + .toggle-track::after { transform: translateX(16px); background: #fff; }

.toggle-label { font-size: 0.78rem; font-weight: 500; color: var(--text-muted); cursor: pointer; }

/* ── Button ── */
button#compressBtn {
    width: 100%; padding: 0.7rem 1rem;
    background: linear-gradient(135deg, var(--accent-vivid), #7c3aed);
    color: #fff; border: none; border-radius: 8px;
    font-family: inherit; font-size: 0.88rem; font-weight: 700;
    cursor: pointer; transition: all 0.25s ease;
    display: flex; justify-content: center; align-items: center; gap: 0.5rem;
}

button#compressBtn:hover:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: 0 6px 20px rgba(99,102,241,0.3);
}

button#compressBtn:active:not(:disabled) { transform: scale(0.98); }

button#compressBtn:disabled {
    background: var(--surface); color: var(--text-dim);
    cursor: not-allowed; transform: none; box-shadow: none;
}

.btn-icon { font-size: 1rem; transition: transform 0.2s; }
button#compressBtn:hover:not(:disabled) .btn-icon { transform: translateX(3px); }

/* ── Progress ── */
.progress-container {
    width: 100%; height: 3px;
    background: var(--surface); border-radius: 2px;
    margin-top: 0.65rem; overflow: hidden;
    opacity: 0; transition: opacity 0.3s;
}

.progress-container.active { opacity: 1; }

.progress-bar {
    height: 100%; width: 0%;
    background: linear-gradient(90deg, var(--accent-vivid), #c084fc);
    border-radius: 2px; transition: width 0.4s ease;
}

/* ── Status ── */
#status {
    margin-top: 0.5rem; font-size: 0.78rem; font-weight: 500;
    text-align: center; color: var(--text-dim); min-height: 18px;
}

/* ── Footer ── */
footer {
    flex-shrink: 0; padding-top: 0.75rem;
    text-align: center; font-size: 0.68rem; color: var(--text-dim);
}

footer p { margin: 0.15rem 0; }

.wa-btn {
    display: inline-flex; align-items: center; gap: 4px;
    background: #25D366; color: #fff; text-decoration: none;
    padding: 4px 12px; border-radius: 14px; font-weight: 600;
    margin-top: 6px; transition: transform 0.2s; font-size: 0.68rem;
}

.wa-btn:hover { transform: scale(1.05); }

/* ── Modal ── */
.modal-overlay {
    position: fixed; inset: 0;
    background: rgba(0,0,0,0.7);
    backdrop-filter: blur(4px);
    display: none; justify-content: center; align-items: center;
    z-index: 1000; padding: 1rem;
}

.modal {
    background: var(--card); border: 1px solid var(--card-border);
    padding: 1.5rem; border-radius: 16px;
    width: 100%; max-width: 380px; text-align: left;
    box-shadow: 0 20px 60px rgba(0,0,0,0.5);
    animation: modalIn 0.25s ease;
}

@keyframes modalIn {
    from { opacity: 0; transform: scale(0.95) translateY(10px); }
    to { opacity: 1; transform: scale(1) translateY(0); }
}

.modal-icon { font-size: 2rem; margin-bottom: 0.5rem; }
.modal h3 { color: var(--danger); font-size: 1.05rem; margin-bottom: 0.5rem; }
.modal-desc { font-size: 0.82rem; color: var(--text-muted); line-height: 1.5; }

.modal-chart {
    background: var(--surface); padding: 0.85rem; border-radius: 8px;
    margin: 1rem 0; font-size: 0.82rem;
}

.chart-row {
    display: flex; justify-content: space-between;
    padding: 0.35rem 0; border-bottom: 1px dashed rgba(255,255,255,0.06);
    color: var(--text-muted);
}

.chart-row:last-child { border-bottom: none; }
.chart-row.warn { color: var(--danger); font-weight: 600; }
.chart-value { font-weight: 600; color: var(--text); }
.chart-row.warn .chart-value { color: var(--danger); }

.modal-prompt { font-size: 0.78rem; color: var(--text-dim); text-align: center; margin: 0.75rem 0 0; }

.modal-actions { display: flex; gap: 0.75rem; margin-top: 1rem; }
.modal-actions button { flex: 1; padding: 0.6rem; font-size: 0.82rem; border-radius: 8px; font-weight: 600; border: none; cursor: pointer; font-family: inherit; transition: all 0.2s; }
.btn-cancel { background: var(--surface); color: var(--text-muted); }
.btn-cancel:hover { background: #3f3f46; }
.btn-proceed { background: var(--danger); color: #fff; }
.btn-proceed:hover { background: #ef4444; }

/* ══════════════════ MOBILE ══════════════════ */
@media (max-width: 600px) {
    body { overflow: auto; align-items: flex-start; }

    .app-wrapper {
        max-height: none; height: auto;
        padding: 1rem 0.75rem 1.5rem;
    }

    header { margin-bottom: 0.75rem; }
    .logo { font-size: 2rem; }

    .card { padding: 1rem; border-radius: 14px; overflow: visible; }

    .upload-zone { padding: 0.85rem; }
    .upload-icon { font-size: 1.25rem; }

    .control-group { margin-bottom: 0.75rem; }

    .toggle-row { padding: 0.55rem 0.75rem; }

    button#compressBtn { padding: 0.65rem; }

    footer { padding-top: 0.6rem; font-size: 0.62rem; }
}

@media (max-width: 360px) {
    .app-wrapper { padding: 0.75rem 0.5rem 1rem; }
    .card { padding: 0.85rem; }
    .logo { font-size: 1.75rem; }
    .mode-switch label { font-size: 0.72rem; padding: 6px 0; }
}

/* ── Tall desktop screens ── */
@media (min-height: 800px) {
    .app-wrapper { padding: 2rem 1rem; }
    header { margin-bottom: 1.5rem; }
    .card { padding: 1.5rem; }
    .upload-zone { padding: 1.5rem; }
    .control-group { margin-bottom: 1rem; }
}