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

body {
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: #f8fafc;
    color: #1e293b;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* Navbar */
.navbar {
    background: linear-gradient(135deg, #0f172a 0%, #1e293b 100%);
    padding: 1rem 0;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    position: sticky;
    top: 0;
    z-index: 100;
}

.navbar-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 1.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.navbar-brand {
    flex: 1;
}

.nav-link {
    color: white;
    text-decoration: none;
    font-size: 0.95rem;
    transition: opacity 0.15s;
}

.nav-link:hover {
    opacity: 0.7;
}

.navbar-auth {
    display: flex;
    gap: 1rem;
    align-items: center;
}

.btn-nav-primary,
.btn-nav-secondary {
    padding: 0.5rem 1rem;
    border-radius: 6px;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s;
    text-decoration: none;
    display: inline-block;
}

.btn-nav-primary {
    background: #3b82f6;
    color: white;
}

.btn-nav-primary:hover {
    background: #2563eb;
}

.btn-nav-secondary {
    color: white;
    border: 1px solid #64748b;
}

.btn-nav-secondary:hover {
    background: rgba(255,255,255,0.1);
}

header {
    background: #0f172a;
    color: white;
    padding: 2rem;
    text-align: center;
}

header h1 {
    margin: 0 0 0.5rem;
    font-size: 2rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    text-wrap: balance;
}

header p {
    margin: 0;
    color: #94a3b8;
    font-size: 1rem;
}

main {
    max-width: 1200px;
    margin: 2rem auto;
    padding: 0 1.5rem;
}

/* Upload card */
.upload-card {
    background: white;
    border-radius: 12px;
    padding: 2rem;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    margin-bottom: 2rem;
}

.upload-card form {
    display: flex;
    gap: 1rem;
    align-items: center;
    flex-wrap: wrap;
}

.file-label {
    display: flex;
    align-items: center;
    flex: 1;
    min-width: 200px;
    cursor: pointer;
}

.file-label input[type="file"] {
    width: 0;
    height: 0;
    opacity: 0;
    position: absolute;
}

#file-name {
    display: block;
    padding: 0.65rem 1rem;
    border: 2px dashed #cbd5e1;
    border-radius: 8px;
    background: #f8fafc;
    color: #64748b;
    flex: 1;
    font-size: 0.9rem;
    transition: border-color 0.15s;
}

.file-label:hover #file-name {
    border-color: #3b82f6;
    color: #1e293b;
}

.btn-primary {
    background: #3b82f6;
    color: white;
    border: none;
    padding: 0.65rem 1.5rem;
    border-radius: 8px;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s, scale 0.15s;
    white-space: nowrap;
}

.btn-primary:hover { background: #2563eb; }
.btn-primary:active { background: #1d4ed8; scale: 0.96; }
.btn-primary:disabled { pointer-events: none; opacity: 0.6; }

/* Loading spinner */
.htmx-indicator {
    display: none;
    align-items: center;
    gap: 0.75rem;
    margin-top: 1.25rem;
    color: #64748b;
    font-size: 0.9rem;
}

.htmx-indicator.htmx-request {
    display: flex;
}

.spinner-ring {
    width: 22px;
    height: 22px;
    border: 3px solid #e2e8f0;
    border-top-color: #3b82f6;
    border-radius: 50%;
    animation: spin 0.75s linear infinite;
    flex-shrink: 0;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* Tabular numbers for dynamic counts */
#line-count {
    font-variant-numeric: tabular-nums;
}

/* Result section */
.result-section {
    background: white;
    border-radius: 12px;
    padding: 1.5rem;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    animation: resultEnter 300ms ease-out;
}

@keyframes resultEnter {
    from {
        opacity: 0;
        transform: translateY(12px);
        filter: blur(4px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
        filter: blur(0);
    }
}

.result-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    flex-wrap: wrap;
    gap: 0.75rem;
    font-size: 0.875rem;
    color: #475569;
}

.result-meta strong {
    color: #1e293b;
}

/* Side-by-side panels */
.dual-view {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

@media (max-width: 700px) {
    .dual-view { grid-template-columns: 1fr; }
}

.view-panel {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.view-panel > .image-container {
    flex: 1 1 auto;
}

.panel-label {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #64748b;
}

.image-container {
    border-radius: 8px;
    overflow: hidden;
    line-height: 0;
    box-shadow:
        0px 0px 0px 1px rgba(0, 0, 0, 0.06),
        0px 1px 2px -1px rgba(0, 0, 0, 0.06),
        0px 2px 4px 0px rgba(0, 0, 0, 0.04);
    transition: box-shadow 150ms ease-out;
}

.image-container:hover {
    box-shadow:
        0px 0px 0px 1px rgba(0, 0, 0, 0.08),
        0px 1px 2px -1px rgba(0, 0, 0, 0.08),
        0px 2px 4px 0px rgba(0, 0, 0, 0.06);
}

.image-container img {
    width: 100%;
    height: auto;
    display: block;
    outline: 1px solid rgba(0, 0, 0, 0.1);
    outline-offset: -1px;
}

/* Plain text output */
.plain-text {
    margin-top: 1.5rem;
    border-top: 1px solid #e2e8f0;
    padding-top: 1.5rem;
}

.plain-text h3 {
    margin: 0;
    font-size: 0.875rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #64748b;
}

.plain-text-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.75rem;
}

.plain-text-actions {
    display: flex;
    gap: 0.25rem;
}

.btn-icon {
    position: relative;
    width: 32px;
    height: 32px;
    border: none;
    background: transparent;
    border-radius: 6px;
    cursor: pointer;
    color: #94a3b8;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color 0.15s, background 0.15s, scale 0.15s;
}

.btn-icon::after {
    content: "";
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 40px;
    height: 40px;
}

.btn-icon:hover {
    background: #f1f5f9;
    color: #475569;
}

.btn-icon:active { scale: 0.96; }

.btn-icon i {
    font-size: 18px;
}

.btn-icon .icon-check {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    scale: 0.25;
    filter: blur(4px);
    transition: opacity 0.3s cubic-bezier(0.2, 0, 0, 1),
                scale 0.3s cubic-bezier(0.2, 0, 0, 1),
                filter 0.3s cubic-bezier(0.2, 0, 0, 1);
}

.btn-icon .icon-copy {
    transition: opacity 0.3s cubic-bezier(0.2, 0, 0, 1),
                scale 0.3s cubic-bezier(0.2, 0, 0, 1),
                filter 0.3s cubic-bezier(0.2, 0, 0, 1);
}

.btn-icon.copied .icon-copy {
    opacity: 0;
    scale: 0.25;
    filter: blur(4px);
}

.btn-icon.copied .icon-check {
    opacity: 1;
    scale: 1;
    filter: blur(0);
}

.plain-text pre {
    background: #f8fafc;
    border-radius: 8px;
    padding: 1rem 1.25rem;
    font-family: 'Georgia', serif;
    font-size: 0.95rem;
    line-height: 1.8;
    white-space: pre-wrap;
    word-break: break-word;
    margin: 0;
    color: #1e293b;
    max-height: 400px;
    overflow-y: auto;
    box-shadow:
        0px 0px 0px 1px rgba(0, 0, 0, 0.06),
        0px 1px 2px -1px rgba(0, 0, 0, 0.06),
        0px 2px 4px 0px rgba(0, 0, 0, 0.04);
}

/* Error */
.error-msg {
    background: #fee2e2;
    border: 1px solid #fca5a5;
    border-radius: 8px;
    padding: 1rem 1.25rem;
    color: #dc2626;
    font-size: 0.9rem;
}

/* Skeleton loading */
.skeleton-transcription {
    height: 100%;
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 0.85rem;
    background: white;
}

.skeleton-bar {
    height: 1rem;
    background: linear-gradient(90deg, #e2e8f0 25%, #f1f5f9 50%, #e2e8f0 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s ease-in-out infinite;
    border-radius: 4px;
}

@keyframes shimmer {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* Cancel button */
.btn-cancel {
    background: transparent;
    color: #dc2626;
    border: 1px solid #fca5a5;
    padding: 0.4rem 1rem;
    border-radius: 6px;
    font-size: 0.8rem;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.15s, scale 0.15s;
}

.btn-cancel:hover { background: #fef2f2; }
.btn-cancel:active { scale: 0.96; }

/* Cancelled message */
.cancelled-msg {
    background: #f0fdf4;
    border: 1px solid #86efac;
    border-radius: 8px;
    padding: 1rem 1.25rem;
    color: #16a34a;
    font-size: 0.9rem;
}

/* Donate section */
.donate-section {
    margin-top: 1.5rem;
    padding-top: 1.5rem;
    border-top: 1px solid #e2e8f0;
    text-align: center;
}

.donate-text {
    color: #64748b;
    font-size: 0.85rem;
    margin: 0 0 0.75rem;
}

.btn-donate {
    background: #0f172a;
    color: white;
    border: none;
    padding: 0.5rem 1.25rem;
    border-radius: 6px;
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.15s, scale 0.15s;
}

.btn-donate:hover { background: #1e293b; }
.btn-donate:active { scale: 0.96; }

.donate-thanks {
    color: #16a34a;
    font-size: 0.85rem;
    margin: 0;
}

/* Auto-donate notice */
.auto-donate-section {
    margin-top: 1.5rem;
    padding-top: 1.5rem;
    border-top: 1px solid #e2e8f0;
    text-align: center;
}

.auto-donate-section p {
    margin: 0;
    color: #16a34a;
    font-size: 0.9rem;
    line-height: 1.5;
}

.auto-donate-section a {
    color: #3b82f6;
    text-decoration: underline;
}

/* PDF page picker */
.pdf-picker {
    margin-top: 1rem;
    border-top: 1px solid #e2e8f0;
    padding-top: 1.25rem;
}

.pdf-picker-title {
    font-size: 0.85rem;
    font-weight: 600;
    color: #475569;
    margin: 0 0 0.75rem;
}

.pdf-picker-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
    gap: 0.75rem;
    margin-bottom: 1rem;
}

.pdf-page-option {
    position: relative;
    border: 2px solid #e2e8f0;
    border-radius: 8px;
    overflow: hidden;
    cursor: pointer;
    background: white;
    transition: border-color 0.15s, box-shadow 0.15s;
    padding: 0;
    display: flex;
    flex-direction: column;
    height: 160px;
}

.pdf-page-option:hover {
    border-color: #93c5fd;
}

.pdf-page-option.selected {
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.2);
}

.pdf-page-option img {
    width: 100%;
    flex: 1;
    object-fit: cover;
    display: block;
}

.pdf-page-option-label {
    font-size: 0.7rem;
    font-weight: 600;
    text-align: center;
    color: #64748b;
    padding: 0.3rem 0;
    letter-spacing: 0.02em;
    background: #f8fafc;
    border-top: 1px solid #e2e8f0;
    flex-shrink: 0;
}

.pdf-picker-actions {
    display: flex;
    gap: 0.75rem;
    align-items: center;
}

.pdf-picker-actions .btn-primary {
    margin-left: auto;
}

.pdf-picker-error {
    background: #fee2e2;
    border: 1px solid #fca5a5;
    border-radius: 8px;
    padding: 0.75rem 1rem;
    color: #dc2626;
    font-size: 0.85rem;
    margin-top: 0.75rem;
}

.pdf-picker-loading {
    text-align: center;
    padding: 2rem;
    color: #94a3b8;
    font-size: 0.9rem;
}

/* PDF pagination */
.pdf-pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 1rem;
    margin: 1rem 0;
    padding: 0.75rem 0;
}

.pdf-page-nav {
    background: white;
    border: 1px solid #cbd5e1;
    color: #475569;
    padding: 0.5rem 1rem;
    border-radius: 6px;
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s;
}

.pdf-page-nav:hover {
    border-color: #3b82f6;
    color: #3b82f6;
    background: #f8fafc;
}

.pdf-page-nav:active {
    scale: 0.96;
}

.pdf-page-info {
    font-size: 0.85rem;
    color: #64748b;
    font-weight: 500;
}

/* Feedback section */
.feedback-section {
    margin-top: 1.5rem;
    padding-top: 1.5rem;
    border-top: 1px solid #e2e8f0;
    text-align: center;
}

.feedback-label {
    margin: 0 0 0.75rem;
    color: #64748b;
    font-size: 0.9rem;
    font-weight: 500;
}

.feedback-buttons {
    display: flex;
    gap: 1rem;
    justify-content: center;
}

.btn-feedback {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.6rem 1.25rem;
    border: 2px solid #e2e8f0;
    border-radius: 8px;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s;
    background: white;
    color: #475569;
}

.btn-feedback i {
    font-size: 20px;
}

.btn-feedback-up:hover {
    border-color: #16a34a;
    background: #f0fdf4;
    color: #15803d;
}

.btn-feedback-down:hover {
    border-color: #dc2626;
    background: #fef2f2;
    color: #b91c1c;
}

.btn-feedback:active {
    scale: 0.96;
}

.feedback-thanks {
    color: #16a34a;
    font-size: 0.9rem;
    font-weight: 500;
    margin: 0.5rem 0 0;
}

/* Confidence badge */
.confidence-badge {
    display: inline-block;
    padding: 0.25rem 0.75rem;
    border-radius: 9999px;
    font-size: 0.8rem;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
}

.confidence-high {
    background: #f0fdf4;
    color: #15803d;
    border: 1px solid #86efac;
}

.confidence-medium {
    background: #fffbeb;
    color: #b45309;
    border: 1px solid #fde68a;
}

.confidence-low {
    background: #fef2f2;
    color: #b91c1c;
    border: 1px solid #fca5a5;
}

/* PDF limit dialog */
.pdf-limit-dialog {
    background: #f8fafc;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    padding: 1.5rem;
    margin-top: 1rem;
}

.pdf-limit-title {
    margin: 0 0 1rem;
    color: #475569;
    font-size: 0.9rem;
}

.pdf-limit-options {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.pdf-limit-btn {
    background: white;
    border: 1px solid #cbd5e1;
    color: #1e293b;
    padding: 0.65rem 1rem;
    border-radius: 6px;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s;
}

.pdf-limit-btn:hover {
    background: #f1f5f9;
    border-color: #3b82f6;
    color: #3b82f6;
}

.pdf-limit-btn:active {
    scale: 0.96;
}

/* Signup prompt widget */
.signup-prompt-widget {
    margin-top: 1.5rem;
    padding: 1.5rem;
    background: #f8fafc;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    text-align: center;
}

.signup-prompt-widget h3 {
    margin: 0 0 0.75rem;
    color: #1e293b;
    font-size: 0.95rem;
    font-weight: 600;
}

.signup-prompt-widget p {
    margin: 0 0 1rem;
    color: #64748b;
    font-size: 0.85rem;
}

.signup-prompt-widget .btn-nav-secondary {
    color: #1e293b;
    border-color: #cbd5e1;
}


