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

:root {
    --bg: #f5f5f7;
    --surface: #ffffff;
    --text: #1d1d1f;
    --muted: #86868b;
    --primary: #0071e3;
    --primary-hover: #0077ed;
    --danger: #ff3b30;
    --border: #d2d2d7;
    --radius: 8px;
    --shadow: 0 1px 3px rgba(0,0,0,.08);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
}

/* ---- Buttons ---- */
.btn {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 8px 16px; border: 1px solid var(--border);
    background: var(--surface); color: var(--text);
    border-radius: var(--radius); font-size: 14px; font-weight: 500;
    cursor: pointer; text-decoration: none; transition: all .15s;
}
.btn:hover { background: #e8e8ed; }
.btn-primary { background: var(--primary); color: #fff; border-color: var(--primary); }
.btn-primary:hover { background: var(--primary-hover); }
.btn-danger { color: var(--danger); border-color: var(--danger); }
.btn-danger:hover { background: var(--danger); color: #fff; }
.btn-ghost { border: none; background: transparent; }
.btn-sm { padding: 4px 10px; font-size: 13px; }
.btn-full { width: 100%; justify-content: center; }

/* ---- Forms ---- */
label { display: block; margin-bottom: 12px; font-size: 13px; font-weight: 500; color: var(--muted); }
label input, label textarea, label select {
    display: block; width: 100%; margin-top: 4px;
    padding: 8px 12px; border: 1px solid var(--border);
    border-radius: var(--radius); font-size: 14px; font-family: inherit;
}
label input:focus, label textarea:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(0,113,227,.15); }

/* ---- Alerts ---- */
.alert { padding: 10px 14px; border-radius: var(--radius); font-size: 13px; margin-bottom: 16px; }
.alert-error { background: #fff2f0; color: var(--danger); border: 1px solid #ffccc7; }

.muted { color: var(--muted); font-size: 13px; }

/* ---- Login ---- */
.login-container { display: flex; align-items: center; justify-content: center; min-height: 100vh; }
.login-card { background: var(--surface); padding: 40px; border-radius: 12px; box-shadow: var(--shadow); width: 360px; max-width: 90vw; }
.login-card h1 { font-size: 24px; margin-bottom: 24px; }

.divider {
    display: flex; align-items: center; margin: 20px 0; color: var(--muted); font-size: 12px;
}
.divider::before, .divider::after { content: ""; flex: 1; border-top: 1px solid var(--border); }
.divider span { padding: 0 12px; }

.btn-google {
    background: #fff; color: #3c4043; border: 1px solid #dadce0;
    font-weight: 500; justify-content: center;
}
.btn-google:hover { background: #f8f9fa; }
.btn-google::before {
    content: ""; display: inline-block; width: 18px; height: 18px;
    background: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 48 48"><path fill="%23EA4335" d="M24 9.5c3.54 0 6.71 1.22 9.21 3.6l6.85-6.85C35.9 2.38 30.47 0 24 0 14.62 0 6.51 5.38 2.56 13.22l7.98 6.19C12.43 13.72 17.74 9.5 24 9.5z"/><path fill="%234285F4" d="M46.98 24.55c0-1.57-.15-3.09-.38-4.55H24v9.02h12.94c-.58 2.96-2.26 5.48-4.78 7.18l7.73 6c4.51-4.18 7.09-10.36 7.09-17.65z"/><path fill="%23FBBC05" d="M10.53 28.59c-.48-1.45-.76-2.99-.76-4.59s.27-3.14.76-4.59l-7.98-6.19C.92 16.46 0 20.12 0 24c0 3.88.92 7.54 2.56 10.78l7.97-6.19z"/><path fill="%2334A853" d="M24 48c6.48 0 11.93-2.13 15.89-5.81l-7.73-6c-2.15 1.45-4.92 2.3-8.16 2.3-6.26 0-11.57-4.22-13.47-9.91l-7.98 6.19C6.51 42.62 14.62 48 24 48z"/></svg>') no-repeat center;
    background-size: contain;
    margin-right: 8px;
}

/* ---- Topbar ---- */
.topbar {
    display: flex; align-items: center; justify-content: space-between;
    padding: 12px 24px; background: var(--surface); border-bottom: 1px solid var(--border);
}
.topbar h1 { font-size: 18px; font-weight: 600; }

/* ---- Dashboard ---- */
.dashboard { max-width: 900px; margin: 0 auto; padding: 24px; }
.dashboard section { margin-bottom: 32px; }
.dashboard h2 { font-size: 16px; margin-bottom: 12px; }

.upload-form {
    background: var(--surface); padding: 20px; border-radius: var(--radius);
    box-shadow: var(--shadow); margin-top: 12px;
}

.intake-row {
    display: flex; align-items: center; justify-content: space-between;
    padding: 12px 16px; background: var(--surface); border-radius: var(--radius);
    box-shadow: var(--shadow); margin-bottom: 8px;
}
.intake-info { display: flex; flex-direction: column; gap: 2px; }
.intake-actions { display: flex; gap: 8px; }

.upload-result {
    margin-top: 16px; padding: 16px;
    background: #e8f5e9; border-radius: var(--radius);
}
.result-heading { font-weight: 600; color: #2e7d32; }
.result-link { font-size: 13px; color: var(--muted); margin-top: 4px; }

.upload-progress { display: none; margin-top: 16px; }
.upload-progress.htmx-request { display: block; }
.progress-track {
    width: 100%; height: 10px; background: #e0e0e0;
    border-radius: 5px; overflow: hidden;
}
.progress-fill {
    height: 100%; width: 100%; background: var(--primary);
    animation: progress-pulse 1.2s ease-in-out infinite;
}
@keyframes progress-pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: .4; }
}
.upload-progress .muted { font-size: 12px; margin: 6px 0 0; }

.htmx-indicator { opacity: 0; transition: opacity .2s; font-size: 13px; color: var(--muted); }
.htmx-request .htmx-indicator { opacity: 1; }
.htmx-request.htmx-indicator { opacity: 1; }

/* ---- Viewer ---- */
.viewer-wrapper { display: flex; flex-direction: column; height: 100vh; background: #fff; }
.viewer-toolbar {
    display: flex; align-items: center; gap: 20px;
    padding: 10px 20px;
    background: rgba(22, 22, 30, .55);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    color: #fff;
    border-bottom: 1px solid rgba(255,255,255,.08);
    z-index: 10;
}
.viewer-toolbar .btn, .viewer-toolbar .btn-ghost { color: #fff; border-color: rgba(255,255,255,.2); }
.viewer-toolbar .btn:hover { background: rgba(255,255,255,.1); }
.viewer-meta { display: flex; align-items: center; gap: 10px; flex: 1; min-width: 0; }
.viewer-meta strong { font-size: 13px; font-weight: 600; letter-spacing: .2px; }
.viewer-meta .muted { color: rgba(255,255,255,.55); font-size: 12px; }
.viewer-controls { display: flex; align-items: center; gap: 16px; }
.slider-label { font-size: 12px; color: rgba(255,255,255,.7); display: flex; align-items: center; gap: 6px; }
.slider-label input[type=range] { width: 80px; accent-color: #fff; }
.slider-label select {
    background: rgba(255,255,255,.1); color: #fff;
    border: 1px solid rgba(255,255,255,.25); border-radius: 6px;
    padding: 3px 6px; font-size: 12px;
}
.slider-label select option { color: #000; }

#viewer-container {
    flex: 1; position: relative; overflow: hidden;
    background: #ffffff;
}

#loading-overlay {
    position: absolute; inset: 0; display: flex;
    flex-direction: column; align-items: center; justify-content: center;
    background: #ffffff; color: #333; z-index: 5;
    font-size: 16px; gap: 12px;
}
.spinner {
    width: 32px; height: 32px;
    border: 3px solid rgba(0,0,0,.2);
    border-top-color: #333; border-radius: 50%;
    animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

#info-panel {
    display: flex; justify-content: space-between; align-items: center;
    padding: 5px 20px;
    background: rgba(22, 22, 30, .55);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    color: rgba(255,255,255,.5);
    font-size: 11px;
}
#info-panel code { color: rgba(255,255,255,.8); font-size: 11px; }

/* ---- Landing ---- */
.landing {
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    min-height: 100vh; gap: 16px; text-align: center; padding: 24px;
}
.landing h1 { font-size: 36px; }
.landing p { color: var(--muted); font-size: 16px; max-width: 400px; }
