/* ============================================================
   grAAAAde.com -- Iowa Black & Gold Theme
   ============================================================ */

/* -- Reset & Base ------------------------------------------- */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

:root {
    --gold: #FFCD00;
    --gold-light: #FFF8E1;
    --gold-medium: #FFE082;
    --gold-dark: #E6B800;
    --black: #000000;
    --bg: #1a1a1a;
    --bg-card: #2a2a2a;
    --bg-input: #333;
    --text: #f0f0f0;
    --text-muted: #999;
    --green: #28a745;
    --green-hover: #218838;
    --red: #dc3545;
    --red-hover: #c82333;
    --blue-info: #17a2b8;
    --radius: 8px;
    --shadow: 0 2px 8px rgba(0,0,0,0.3);
    --sidebar-width: 260px;
}

html {
    font-size: 16px;
    scroll-behavior: smooth;
}

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

a { color: var(--gold); text-decoration: none; }
a:hover { text-decoration: underline; }

h1, h2, h3, h4 { font-weight: 700; }

hr {
    border: none;
    border-top: 1px solid #444;
    margin: 16px 0;
}

/* -- Utility ------------------------------------------------ */
.gold-text { color: var(--gold); }

.alert {
    padding: 12px 16px;
    border-radius: var(--radius);
    margin: 12px 0;
    font-size: 0.9rem;
}
.alert-error { background: var(--red); color: #fff; }
.alert-success { background: var(--green); color: #fff; }
.alert-info { background: #2c3e50; color: #ddd; border: 1px solid #3c5a73; }

/* -- Buttons ------------------------------------------------ */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 10px 20px;
    border: 2px solid transparent;
    border-radius: var(--radius);
    font-weight: 700;
    font-size: 1rem;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s, opacity 0.15s;
    text-decoration: none;
    line-height: 1.4;
}
.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-primary {
    background: var(--green);
    color: #fff;
    border-color: var(--green-hover);
}
.btn-primary:hover:not(:disabled) { background: var(--green-hover); }

.btn-danger {
    background: var(--red);
    color: #fff;
    border-color: var(--red-hover);
}
.btn-danger:hover:not(:disabled) { background: var(--red-hover); }

.btn-iowa {
    background: var(--black);
    color: var(--gold);
    border-color: var(--gold);
}
.btn-iowa:hover:not(:disabled) { background: #222; }

.btn-sm { padding: 6px 14px; font-size: 0.85rem; }
.btn-lg { padding: 14px 28px; font-size: 1.05rem; min-width: 160px; }
.btn-full { width: 100%; }

/* -- Forms -------------------------------------------------- */
.form-group {
    margin-bottom: 14px;
}
.form-group label {
    display: block;
    font-weight: 600;
    margin-bottom: 4px;
    font-size: 0.9rem;
    color: var(--text-muted);
}
.form-group input[type="text"],
.form-group input[type="email"],
.form-group input[type="password"],
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 10px 12px;
    border: 2px solid #555;
    border-radius: var(--radius);
    background: var(--bg-input);
    color: var(--text);
    font-size: 1rem;
    transition: border-color 0.15s;
}
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--gold);
}

/* -- Login Page --------------------------------------------- */
.login-page {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background: linear-gradient(135deg, #111 0%, #1a1a1a 50%, #222 100%);
}
.login-container {
    width: 100%;
    max-width: 480px;
    background: var(--bg-card);
    border-radius: 12px;
    padding: 20px 28px 24px;
    box-shadow: var(--shadow);
    border: 2px solid #333;
}
.login-header {
    text-align: center;
    margin-bottom: 6px;
}
.login-logo {
    max-width: 420px;
    width: 100%;
    height: auto;
    margin-bottom: 0;
}
.login-header h1 {
    font-size: 2.2rem;
    color: var(--text);
}
.login-header .tagline {
    color: var(--text-muted);
    font-style: italic;
    margin-top: 4px;
}

.tabs {
    display: flex;
    gap: 0;
    margin-bottom: 20px;
    border-bottom: 2px solid #444;
}
.tab-btn {
    flex: 1;
    background: none;
    border: none;
    padding: 10px 8px;
    color: var(--text-muted);
    font-weight: 600;
    font-size: 0.9rem;
    cursor: pointer;
    border-bottom: 3px solid transparent;
    transition: color 0.15s, border-color 0.15s;
}
.tab-btn:hover { color: var(--text); }
.tab-btn.active {
    color: var(--gold);
    border-bottom-color: var(--gold);
}
.tab-content { display: none; }
.tab-content.active { display: block; }

.back-link {
    display: block;
    text-align: center;
    margin-top: 12px;
    font-size: 0.85rem;
}

/* -- App Layout --------------------------------------------- */
.app-layout {
    display: flex;
    min-height: 100vh;
}

/* -- Sidebar ------------------------------------------------ */
.sidebar {
    width: var(--sidebar-width);
    min-width: var(--sidebar-width);
    background: #111;
    border-right: 2px solid #333;
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 100;
    transition: transform 0.25s ease;
}
.sidebar-content {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
}
.sidebar-toggle {
    display: none;
    position: absolute;
    top: 28px;
    right: -52px;
    width: 44px;
    height: 44px;
    background: #111;
    border: 2px solid #333;
    border-left: none;
    border-radius: 0 var(--radius) var(--radius) 0;
    color: var(--gold);
    font-size: 1.5rem;
    cursor: pointer;
    align-items: center;
    justify-content: center;
    z-index: 101;
}
.sidebar-section {
    padding: 12px 0;
    border-bottom: 1px solid #333;
}
.account-section {
    text-align: center;
}
.account-name {
    font-weight: 700;
    font-size: 1rem;
    color: var(--text);
}
.account-email {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin: 2px 0 6px;
}
.usage-counter {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-bottom: 10px;
    padding: 4px 8px;
    background: rgba(255,255,255,0.05);
    border-radius: 4px;
}
.usage-counter.low {
    color: var(--gold);
}
.usage-counter.empty {
    color: var(--red);
    font-weight: 600;
}

.sidebar-expander {
    background: none;
    border: none;
    color: var(--text-muted);
    font-weight: 600;
    font-size: 0.85rem;
    cursor: pointer;
    width: 100%;
    text-align: left;
    padding: 6px 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.sidebar-expander:hover { color: var(--text); }

.expander-arrow {
    font-size: 0.65rem;
    transition: transform 0.2s;
}
.expander-body {
    display: none;
    padding-top: 10px;
}
.expander-body.open { display: block; }
.expander-body.open + .sidebar-expander .expander-arrow,
.sidebar-expander.open .expander-arrow {
    transform: rotate(180deg);
}

/* -- Sidebar Notifications ---------------------------------- */
.notifications-header {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.85rem;
    font-weight: 600;
    color: #f0ad4e;
    margin-bottom: 8px;
}
.notifications-icon {
    font-size: 1rem;
}
.notifications-clear {
    margin-left: auto;
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 1.1rem;
    cursor: pointer;
    padding: 0 4px;
    line-height: 1;
}
.notifications-clear:hover {
    color: var(--text);
}
.notification-item {
    background: rgba(240, 173, 78, 0.1);
    border: 1px solid rgba(240, 173, 78, 0.3);
    border-radius: 6px;
    padding: 10px;
    margin-bottom: 6px;
    font-size: 0.78rem;
    line-height: 1.45;
    color: #ddd;
}
.notification-item .notif-filename {
    font-weight: 700;
    color: var(--gold);
    display: block;
    margin-bottom: 4px;
}
.notification-item .notif-pages {
    color: #f0ad4e;
    font-weight: 600;
}
.notification-item .notif-action {
    display: block;
    margin-top: 6px;
    color: var(--text-muted);
    font-style: italic;
}

/* -- Subscription UI --------------------------------------- */
.subscription-badge {
    display: inline-block;
    background: var(--gold);
    color: var(--black);
    font-weight: 800;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 3px 12px;
    border-radius: 12px;
    margin: 6px 0;
}

.trial-counter {
    font-size: 0.8rem;
    color: var(--gold);
    margin: 6px 0;
    padding: 6px 10px;
    background: rgba(255,205,0,0.08);
    border: 1px solid rgba(255,205,0,0.25);
    border-radius: 6px;
}

.btn-subscribe {
    background: var(--gold);
    color: var(--black);
    border-color: var(--gold-dark);
    font-weight: 800;
}
.btn-subscribe:hover:not(:disabled) {
    background: var(--gold-dark);
}

.paywall-banner {
    background: var(--bg-card);
    border: 2px solid var(--gold);
    border-radius: 12px;
    padding: 32px 24px;
    text-align: center;
    margin: 16px 0;
}
.paywall-banner h3 {
    color: var(--gold);
    font-size: 1.3rem;
    margin-bottom: 12px;
}
.paywall-banner p {
    color: #ccc;
    margin-bottom: 20px;
    font-size: 0.95rem;
}
.paywall-banner .btn-subscribe {
    padding: 12px 32px;
    font-size: 1.05rem;
}

.inline-message {
    font-size: 0.8rem;
    margin-top: 6px;
}
.inline-message.success { color: var(--green); }
.inline-message.error { color: var(--red); }

.toggle-label {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    font-weight: 600;
    color: var(--text);
}
.toggle-label input[type="checkbox"] {
    width: 18px;
    height: 18px;
    accent-color: var(--gold);
}

/* -- Main Content ------------------------------------------- */
.main-content {
    flex: 1;
    margin-left: var(--sidebar-width);
    padding: 12px 32px 24px;
    max-width: 1100px;
}

.app-header {
    margin-bottom: 0;
    text-align: center;
}
.app-logo {
    max-width: 640px;
    width: 100%;
    height: auto;
    display: block;
    margin: 0 auto;
}
.app-header h1 {
    font-size: 2rem;
    color: var(--text);
}
.app-header .tagline {
    font-style: italic;
    color: var(--text-muted);
    font-size: 0.95rem;
}

/* -- Guide Section ------------------------------------------ */
.guide-section {
    margin-bottom: 10px;
}
.guide-toggle {
    background: none;
    border: none;
    color: var(--gold);
    font-weight: 600;
    font-size: 0.95rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 0;
}
.guide-toggle:hover { color: var(--gold-dark); }
.guide-body {
    display: none;
    background: var(--bg-card);
    border: 1px solid #444;
    border-radius: var(--radius);
    padding: 20px 24px;
    margin-top: 8px;
}
.guide-body.open { display: block; }
.guide-content h3 {
    color: var(--gold);
    margin-bottom: 6px;
    font-size: 1rem;
}
.guide-content p, .guide-content li {
    font-size: 0.9rem;
    color: #ccc;
}
.guide-content ul { padding-left: 20px; }

/* -- Step Boxes --------------------------------------------- */
.step-box {
    background: var(--bg-card);
    border-radius: 12px;
    margin-bottom: 16px;
    overflow: hidden;
    border: 2px solid #444;
    transition: border-color 0.2s;
}

.step-box.step-1 { border-color: #b8a040; border-width: 3px; }
.step-box.step-2 { border-color: #c5a930; border-width: 3px; }
.step-box.step-3 { border-color: var(--gold); border-width: 3px; }

.step-box.disabled {
    opacity: 0.5;
    pointer-events: none;
}

.step-header {
    display: flex;
    align-items: flex-start;
    padding: 16px 20px;
    min-height: 76px;
    cursor: pointer;
    user-select: none;
    gap: 16px;
    transition: background 0.15s;
}
.step-header:hover {
    background: rgba(255,205,0,0.05);
}

.step-number {
    width: 44px;
    height: 44px;
    min-width: 44px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    font-size: 1.3rem;
    color: var(--black);
}
.step-1 .step-number { background: var(--gold-light); color: #8B7500; }
.step-2 .step-number { background: var(--gold-medium); color: #6B5A00; }
.step-3 .step-number { background: var(--gold); color: var(--black); }

.step-title {
    flex: 1;
}
.step-title h2 {
    font-size: 1.15rem;
    color: var(--gold);
    margin-bottom: 2px;
}
.step-title h2 .gold-text {
    color: #fff;
}
.step-time-badge {
    font-size: 0.65rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #f0ad4e;
    background: rgba(240, 173, 78, 0.12);
    border: 1px solid rgba(240, 173, 78, 0.3);
    border-radius: 4px;
    padding: 2px 7px;
    margin-left: 8px;
    vertical-align: middle;
    white-space: nowrap;
}
.step-summary {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.step-chevron {
    color: var(--text-muted);
    font-size: 0.8rem;
    transition: transform 0.2s;
    margin-top: 12px;
}
.step-box.collapsed .step-chevron {
    transform: rotate(-90deg);
}

.step-body {
    padding: 0 20px 20px;
}
.step-box.collapsed .step-body {
    display: none;
}

/* -- Step 1: Class List ------------------------------------- */
.class-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-bottom: 16px;
}
.class-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 14px;
    border-radius: var(--radius);
    border: 2px solid #555;
    cursor: pointer;
    transition: border-color 0.15s, background 0.15s;
}
.class-item:hover { border-color: var(--gold); background: rgba(255,205,0,0.06); }
.class-item.active {
    border-color: var(--gold);
    background: rgba(255,205,0,0.1);
}
.class-name {
    font-weight: 600;
    font-size: 0.95rem;
}
.delete-class-btn {
    background: none;
    border: none;
    color: #888;
    font-size: 1.3rem;
    cursor: pointer;
    padding: 0 4px;
    line-height: 1;
    opacity: 0;
    transition: opacity 0.15s, color 0.15s;
}
.class-item:hover .delete-class-btn { opacity: 1; }
.delete-class-btn:hover { color: var(--red); }

.add-class-inline {
    display: flex;
    gap: 8px;
    margin-left: auto;
}
.add-class-inline input {
    padding: 6px 12px;
    border: 2px solid #555;
    border-radius: var(--radius);
    background: var(--bg-input);
    color: var(--text);
    font-size: 0.85rem;
    width: 180px;
}
.add-class-inline input:focus { outline: none; border-color: var(--gold); }

.empty-message {
    color: var(--text-muted);
    font-size: 0.9rem;
    margin-bottom: 12px;
}

/* -- Step 2: Upload ----------------------------------------- */
.active-class-label {
    font-size: 0.9rem;
    color: var(--text-muted);
    margin-bottom: 12px;
}
.active-class-label strong { color: var(--gold); }

.upload-zone {
    margin-bottom: 16px;
}
.upload-timing-note {
    font-size: 0.78rem;
    color: var(--text-muted);
    margin-top: 10px;
    line-height: 1.45;
    padding: 0 4px;
}

.upload-dropzone, .image-dropzone {
    border: 2px dashed #666;
    border-radius: var(--radius);
    padding: 32px;
    text-align: center;
    cursor: pointer;
    transition: border-color 0.2s, background 0.2s;
    position: relative;
}
.upload-dropzone:hover, .image-dropzone:hover {
    border-color: var(--gold);
    background: rgba(255,205,0,0.04);
}
.upload-dropzone.dragover, .image-dropzone.dragover {
    border-color: var(--gold);
    background: rgba(255,205,0,0.08);
}
.dropzone-icon {
    font-size: 2.5rem;
    margin-bottom: 8px;
}
.dropzone-content p {
    font-weight: 600;
    color: var(--text);
}
.dropzone-content small {
    color: var(--text-muted);
}

.file-input-hidden {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    cursor: pointer;
}

.file-list {
    margin: 10px 0;
}
.file-list-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 12px;
    background: #333;
    border-radius: 6px;
    margin-bottom: 4px;
    font-size: 0.85rem;
}
.file-list-item .remove-file {
    background: none;
    border: none;
    color: #888;
    cursor: pointer;
    font-size: 1.1rem;
}
.file-list-item .remove-file:hover { color: var(--red); }

.upload-progress {
    margin-top: 12px;
}
.progress-bar {
    height: 6px;
    background: #444;
    border-radius: 3px;
    overflow: hidden;
    margin-bottom: 6px;
}
.progress-fill {
    height: 100%;
    background: var(--gold);
    border-radius: 3px;
    width: 0%;
    transition: width 0.3s ease;
}
#progress-text {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.document-list {
    margin-top: 16px;
}
.document-list h4 {
    color: var(--text);
    font-size: 0.9rem;
    margin-bottom: 8px;
}
.document-list h4 small {
    color: var(--text-muted);
    font-weight: 400;
}
.document-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 12px;
    border-bottom: 1px solid #444;
    font-size: 0.85rem;
}
.doc-name { color: var(--text); }
.delete-doc-btn {
    background: none;
    border: none;
    color: #888;
    cursor: pointer;
    font-size: 1.2rem;
    opacity: 0;
    transition: opacity 0.15s;
}
.document-item:hover .delete-doc-btn { opacity: 1; }
.delete-doc-btn:hover { color: var(--red); }

/* -- Step 3: Questions -------------------------------------- */
.question-area {
    margin-top: 4px;
}
.question-row {
    display: flex;
    gap: 16px;
    margin-bottom: 16px;
    align-items: stretch;
}
.question-col, .image-col {
    flex: 1;
    display: flex;
    flex-direction: column;
}
.question-col label, .image-col label {
    display: block;
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--text-muted);
    margin-bottom: 6px;
}
#question-input {
    width: 100%;
    padding: 12px;
    border: 2px solid #555;
    border-radius: var(--radius);
    background: var(--bg-input);
    color: var(--text);
    font-size: 1rem;
    resize: vertical;
    flex: 1;
    min-height: 160px;
    font-family: inherit;
    line-height: 1.5;
}
#question-input:focus { outline: none; border-color: var(--gold); }

.image-dropzone {
    flex: 1;
    min-height: 160px;
    display: flex;
    align-items: center;
    justify-content: center;
}
.image-preview {
    position: relative;
    border-radius: var(--radius);
    overflow: hidden;
    border: 2px solid #555;
}
.image-preview img {
    max-width: 100%;
    max-height: 250px;
    display: block;
}
.remove-image-btn {
    position: absolute;
    top: 6px;
    right: 6px;
    width: 28px;
    height: 28px;
    background: rgba(0,0,0,0.7);
    border: none;
    color: #fff;
    border-radius: 50%;
    cursor: pointer;
    font-size: 1.1rem;
    display: flex;
    align-items: center;
    justify-content: center;
}
.remove-image-btn:hover { background: var(--red); }

.image-note {
    display: block;
    color: var(--text-muted);
    margin-top: 6px;
    font-size: 0.75rem;
}

.question-actions {
    display: flex;
    gap: 12px;
    margin-bottom: 16px;
}

/* -- Answer Area -------------------------------------------- */
.answer-area {
    margin-top: 20px;
}

.loading-spinner {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 20px;
    color: var(--text-muted);
}
.spinner {
    width: 28px;
    height: 28px;
    border: 3px solid #444;
    border-top-color: var(--gold);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}
@keyframes spin {
    to { transform: rotate(360deg); }
}

.result-block {
    margin-bottom: 24px;
}
.result-question {
    font-weight: 700;
    color: var(--text);
    margin-bottom: 8px;
    font-size: 1rem;
}

.uncertainty-warning {
    background: var(--red);
    color: #fff;
    padding: 10px 16px;
    border-radius: 6px;
    font-weight: 700;
    margin-bottom: 10px;
    text-align: center;
}

.answer-box {
    background: var(--gold);
    border: 3px solid var(--black);
    border-radius: var(--radius);
    padding: 20px 24px;
    color: var(--black);
    margin: 10px 0;
    font-weight: 700;
    font-size: 1.1rem;
    line-height: 1.5;
}

.explanation-text {
    padding: 12px 0;
    line-height: 1.7;
    color: #ddd;
    font-size: 0.95rem;
    white-space: pre-wrap;
}

.sources-toggle {
    background: none;
    border: none;
    color: var(--gold);
    cursor: pointer;
    font-weight: 600;
    font-size: 0.9rem;
    padding: 8px 0;
    display: flex;
    align-items: center;
    gap: 6px;
}
.sources-toggle:hover { color: var(--gold-dark); }

.sources-body {
    display: none;
    background: #222;
    border: 1px solid #444;
    border-radius: var(--radius);
    padding: 16px;
    margin-top: 8px;
}
.sources-body.open { display: block; }

.source-item {
    margin-bottom: 12px;
    padding-bottom: 12px;
    border-bottom: 1px solid #444;
}
.source-item:last-child { border-bottom: none; margin-bottom: 0; padding-bottom: 0; }
.source-ref {
    font-weight: 700;
    color: var(--gold);
    font-size: 0.85rem;
}
.source-preview {
    font-size: 0.8rem;
    color: #999;
    margin-top: 4px;
    white-space: pre-wrap;
    word-break: break-word;
}
.model-label {
    text-align: right;
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 12px;
    font-style: italic;
}

/* -- Modal -------------------------------------------------- */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.6);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
}
.modal-box {
    background: var(--bg-card);
    border: 2px solid #555;
    border-radius: 12px;
    padding: 24px;
    max-width: 420px;
    width: 90%;
    box-shadow: 0 4px 20px rgba(0,0,0,0.5);
}
.modal-box h3 { color: var(--text); margin-bottom: 10px; }
.modal-box p { color: #ccc; font-size: 0.9rem; margin-bottom: 16px; }
.modal-actions {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
}

/* -- Responsive --------------------------------------------- */
@media (max-width: 900px) {
    .sidebar {
        transform: translateX(-100%);
    }
    .sidebar.open {
        transform: translateX(0);
    }
    .sidebar-toggle {
        display: flex;
    }
    .main-content {
        margin-left: 0;
        padding: 16px;
        overflow-x: hidden;
    }
    .app-header {
        text-align: center;
    }
    .app-logo {
        max-width: 75%;
        margin-left: 40px;
    }
    .sidebar-toggle {
        border: 2px solid var(--gold);
        border-left: none;
    }
    .app-header h1 { font-size: 1.6rem; }
    .question-row {
        flex-direction: column;
    }
    .step-header {
        flex-wrap: wrap;
    }
    .add-class-inline {
        width: 100%;
        margin-left: 60px;
        margin-top: 8px;
    }
    .add-class-inline input {
        flex: 1;
        min-width: 0;
    }
}

@media (max-width: 500px) {
    .login-container { padding: 20px; }
    .login-header h1 { font-size: 1.6rem; }
    .question-actions { flex-direction: column; }
    .question-actions .btn { width: 100%; }
    .step-header { padding: 12px 14px; }
    .step-number { width: 36px; height: 36px; min-width: 36px; font-size: 1.1rem; }
    .step-title h2 { font-size: 1rem; }
}

/* Scrollbar styling */
::-webkit-scrollbar { width: 8px; }
::-webkit-scrollbar-track { background: #222; }
::-webkit-scrollbar-thumb { background: #555; border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: #777; }

/* Select styling */
select {
    appearance: auto;
    background: var(--bg-input);
    color: var(--text);
    border: 2px solid #555;
    border-radius: var(--radius);
    padding: 8px 10px;
    font-size: 0.9rem;
    cursor: pointer;
}
select:focus { outline: none; border-color: var(--gold); }

/* Range slider */
input[type="range"] {
    width: 100%;
    accent-color: var(--gold);
}

/* Upload results list */
.upload-results {
    margin-top: 12px;
}
.upload-result-item {
    padding: 8px 12px;
    border-radius: 6px;
    margin-bottom: 4px;
    font-size: 0.85rem;
}
.upload-result-item.ok { background: rgba(40,167,69,0.15); color: var(--green); }
.upload-result-item.error { background: rgba(220,53,69,0.15); color: var(--red); }
.upload-result-item.skipped { background: rgba(23,162,184,0.15); color: var(--blue-info); }

/* Processing queue */
.processing-queue {
    margin: 16px 0;
    background: rgba(255,215,0,0.08);
    border: 1px solid rgba(255,215,0,0.25);
    border-radius: var(--radius);
    padding: 14px 16px;
    transition: opacity 0.5s ease;
}
.processing-queue.fade-out { opacity: 0; }

.processing-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 12px;
    font-size: 0.9rem;
    color: var(--gold);
}
.processing-icon {
    font-size: 1.2rem;
    animation: spin 2s linear infinite;
}
@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

.processing-estimate {
    display: none;
    text-align: center;
    padding: 14px 0;
    margin-bottom: 10px;
    border-bottom: 1px solid rgba(255,215,0,0.2);
}
.estimate-time {
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--gold);
    letter-spacing: 0.01em;
}
.estimate-progress {
    font-size: 0.9rem;
    color: var(--muted);
    margin-top: 4px;
}

.processing-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 0;
    border-top: 1px solid rgba(255,255,255,0.06);
    font-size: 0.85rem;
}
.processing-item:first-child { border-top: none; }

.processing-spinner {
    width: 16px;
    height: 16px;
    min-width: 16px;
    border: 2px solid rgba(255,215,0,0.3);
    border-top-color: var(--gold);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}
.processing-item.done .processing-spinner {
    border: none;
    animation: none;
}
.processing-item.done .processing-spinner::after {
    content: "\2713";
    color: var(--green);
    font-size: 14px;
    font-weight: bold;
}
.processing-item.error .processing-spinner {
    border: none;
    animation: none;
}
.processing-item.error .processing-spinner::after {
    content: "\2717";
    color: var(--red);
    font-size: 14px;
    font-weight: bold;
}

.processing-name {
    flex: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.processing-status {
    color: var(--muted);
    font-size: 0.8rem;
    white-space: nowrap;
}
.processing-item.done .processing-status { color: var(--green); }
.processing-item.error .processing-status { color: var(--red); }

.processing-failure-summary {
    padding: 12px 16px;
    background: rgba(231, 76, 60, 0.12);
    border: 1px solid rgba(231, 76, 60, 0.3);
    border-radius: 8px;
    margin-bottom: 10px;
    color: #e0e0e0;
    font-size: 0.9rem;
    line-height: 1.5;
}
.retry-dismiss-btn {
    display: block;
    margin-top: 8px;
    background: transparent;
    border: 1px solid #888;
    color: #ccc;
    padding: 4px 14px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.82rem;
}
.retry-dismiss-btn:hover { border-color: #ccc; color: #fff; }

/* ============================================================
   Landing Page
   ============================================================ */
.landing-page {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    background: linear-gradient(135deg, #111 0%, #1a1a1a 50%, #222 100%);
    padding: 0 20px;
}

.landing-hero {
    text-align: center;
    padding: 20px 20px 40px;
    max-width: 700px;
}
.landing-logo {
    max-width: 660px;
    width: 100%;
    height: auto;
    margin-bottom: 8px;
}
.landing-hero h1 {
    font-size: 3.2rem;
    color: var(--text);
    margin-bottom: 12px;
}
.landing-tagline {
    font-size: 1.3rem;
    color: var(--gold);
    font-weight: 600;
    margin-bottom: 12px;
}
.landing-value {
    font-size: 1.05rem;
    color: var(--text-muted);
    line-height: 1.6;
}

.landing-video {
    width: 100%;
    max-width: 800px;
    margin: 0 auto 48px;
}
.landing-video video {
    width: 100%;
    border-radius: 12px;
    border: 2px solid #333;
    box-shadow: 0 4px 24px rgba(0,0,0,0.5);
}

.landing-features {
    display: flex;
    gap: 24px;
    max-width: 900px;
    width: 100%;
    margin-bottom: 48px;
}
.feature-card {
    flex: 1;
    background: var(--bg-card);
    border: 2px solid #333;
    border-radius: 12px;
    padding: 28px 24px;
    text-align: center;
}
.feature-icon {
    width: 48px;
    height: 48px;
    margin: 0 auto 14px;
    background: var(--gold);
    color: var(--black);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    font-size: 1.3rem;
}
.feature-card h3 {
    color: var(--text);
    font-size: 1.1rem;
    margin-bottom: 8px;
}
.feature-card p {
    color: var(--text-muted);
    font-size: 0.9rem;
    line-height: 1.5;
}

.landing-cta, .landing-cta-inline {
    display: flex;
    gap: 16px;
    margin-bottom: 60px;
}
.landing-cta-inline {
    margin-top: 28px;
    margin-bottom: 0;
    justify-content: center;
}
.landing-btn-signup {
    background: var(--gold);
    color: var(--black);
    border-color: var(--gold-dark);
    font-weight: 800;
}
.landing-btn-signup:hover {
    background: var(--gold-dark);
    text-decoration: none;
}

.landing-carousel {
    max-width: 700px;
    width: 100%;
    margin-bottom: 48px;
    padding: 0 20px;
    position: relative;
    height: 130px;
}
.carousel-slide {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    opacity: 0;
    transition: opacity 1.2s ease-in-out;
    text-align: center;
    padding: 0 20px;
    box-sizing: border-box;
    pointer-events: none;
}
.carousel-slide.active {
    opacity: 1;
    pointer-events: auto;
}
@media (max-width: 700px) {
    .landing-carousel { height: 150px; }
}
.carousel-quote {
    font-style: italic;
    color: var(--text);
    font-size: 1.2rem;
    line-height: 1.7;
    margin-bottom: 12px;
}
.carousel-author {
    color: var(--gold);
    font-size: 0.95rem;
    font-weight: 700;
}

.landing-why, .landing-integrity, .landing-final-cta {
    max-width: 900px;
    width: 100%;
    margin-bottom: 48px;
    padding: 0 20px;
}
.landing-why h2, .landing-integrity h2, .landing-final-cta h2 {
    color: var(--gold);
    font-size: 1.5rem;
    text-align: center;
    margin-bottom: 24px;
}
.why-grid {
    display: flex;
    gap: 20px;
}
.why-card h3 {
    color: var(--text);
    font-size: 1rem;
    margin-bottom: 8px;
}
.why-card p {
    color: var(--text-muted);
    font-size: 0.9rem;
    line-height: 1.5;
}
.landing-integrity {
    text-align: center;
}
.landing-integrity p {
    color: var(--text-muted);
    font-size: 0.95rem;
    line-height: 1.7;
    max-width: 700px;
    margin: 0 auto;
}
.landing-final-cta {
    text-align: center;
}
.landing-final-cta p {
    color: var(--text-muted);
    font-size: 1rem;
    margin-bottom: 20px;
}

.landing-footer {
    padding: 24px 0;
    color: var(--text-muted);
    font-size: 0.8rem;
    text-align: center;
}

@media (max-width: 700px) {
    .landing-hero { padding: 48px 12px 28px; }
    .landing-hero h1 { font-size: 2.2rem; }
    .landing-tagline { font-size: 1.1rem; }
    .landing-features { flex-direction: column; }
    .why-grid { flex-direction: column; }
    .carousel-quote { font-size: 1rem; }
    .landing-cta, .landing-cta-inline { flex-direction: column; width: 100%; max-width: 320px; margin-left: auto; margin-right: auto; }
    .landing-cta .btn, .landing-cta-inline .btn { width: 100%; }
}

/* ============================================================
   Admin Dashboard
   ============================================================ */
.admin-page {
    min-height: 100vh;
    padding: 4px 24px 24px;
    background: var(--bg);
}
.admin-container {
    max-width: 1100px;
    margin: 0 auto;
}
.admin-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 4px;
}
.admin-header h1 {
    font-size: 1.8rem;
}
.admin-section {
    background: var(--bg-card);
    border: 2px solid #444;
    border-radius: 12px;
    padding: 20px 24px;
    margin-bottom: 20px;
}
.admin-section h2 {
    color: var(--gold);
    font-size: 1.1rem;
    margin-bottom: 16px;
}
.admin-form-row {
    display: flex;
    gap: 12px;
    align-items: flex-end;
    flex-wrap: wrap;
}
.admin-form-row .form-group {
    flex: 1;
    min-width: 140px;
}
.admin-table-wrap {
    overflow-x: auto;
}
.admin-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
}
.admin-table th {
    text-align: left;
    padding: 10px 12px;
    border-bottom: 2px solid #555;
    color: var(--gold);
    font-weight: 700;
    white-space: nowrap;
}
.admin-table td {
    padding: 10px 12px;
    border-bottom: 1px solid #333;
    color: var(--text);
}
.admin-table tr:hover td {
    background: rgba(255,205,0,0.04);
}
.amb-code-display {
    background: rgba(255,205,0,0.1);
    color: var(--gold);
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 0.9rem;
    font-weight: 700;
    letter-spacing: 1px;
}
.status-badge {
    display: inline-block;
    padding: 2px 10px;
    border-radius: 10px;
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.status-badge.active {
    background: rgba(40,167,69,0.15);
    color: var(--green);
}
.status-badge.revoked {
    background: rgba(220,53,69,0.15);
    color: var(--red);
}
.admin-stats-bar {
    display: flex;
    gap: 12px;
    margin-bottom: 12px;
}
.admin-stat-box {
    flex: 1;
    background: var(--bg-card);
    border: 2px solid #444;
    border-radius: 10px;
    padding: 16px 14px;
    text-align: center;
}
.admin-stat-value {
    font-size: 1.6rem;
    font-weight: 800;
    color: var(--gold);
    line-height: 1.2;
}
.admin-stat-label {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 4px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-weight: 600;
}
@media (max-width: 700px) {
    .admin-form-row { flex-direction: column; }
    .admin-table { font-size: 0.78rem; }
    .admin-table th, .admin-table td { padding: 8px 6px; }
    .admin-stats-bar { flex-wrap: wrap; }
    .admin-stat-box { min-width: calc(50% - 6px); }
    .admin-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
    }
    .admin-header h1 { font-size: 1.4rem; }
}

/* ============================================================
   Mobile Responsiveness Polish
   ============================================================ */

/* -- Sidebar overlay backdrop on mobile ---------------------- */
.sidebar-backdrop {
    display: none;
}
@media (max-width: 900px) {
    .sidebar-backdrop {
        display: none;
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: rgba(0,0,0,0.5);
        z-index: 99;
    }
    .sidebar.open ~ .sidebar-backdrop,
    .sidebar.open + .main-content .sidebar-backdrop {
        display: block;
    }
}

/* -- Touch targets: ensure minimum 44x44px tap area ---------- */
.delete-class-btn {
    min-width: 44px;
    min-height: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
.delete-doc-btn {
    min-width: 44px;
    min-height: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
.notifications-clear {
    min-width: 44px;
    min-height: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
.remove-image-btn {
    width: 36px;
    height: 36px;
}

/* -- Ensure no horizontal overflow from long text ------------ */
.explanation-text {
    word-break: break-word;
    overflow-wrap: break-word;
}
.answer-box {
    word-break: break-word;
    overflow-wrap: break-word;
}
.source-preview {
    word-break: break-word;
}
.result-question {
    word-break: break-word;
    overflow-wrap: break-word;
}

/* -- Login page: small-screen refinements -------------------- */
@media (max-width: 600px) {
    .login-page {
        padding: 16px 8px;
    }
    .login-container {
        padding: 20px 16px;
        border-radius: 8px;
        margin: 0 4px;
    }
    .tabs {
        gap: 0;
    }
    .tab-btn {
        padding: 10px 4px;
        font-size: 0.8rem;
    }
}

/* -- App page: mobile refinements ---------------------------- */
@media (max-width: 600px) {
    .main-content {
        padding: 12px;
    }
    .app-header h1 {
        font-size: 1.4rem;
    }
    .step-body {
        padding: 0 12px 16px;
    }
    .step-header {
        padding: 12px;
        gap: 10px;
    }
    .upload-dropzone, .image-dropzone {
        padding: 20px 12px;
    }
    .answer-box {
        padding: 16px;
        font-size: 1rem;
    }
    .guide-body {
        padding: 16px;
    }
    .paywall-banner {
        padding: 24px 16px;
    }
    .add-class-inline {
        margin-left: 0;
        width: 100%;
    }
    .add-class-inline input {
        width: auto;
        flex: 1;
        min-width: 0;
    }
    .step-time-badge {
        display: none;
    }
    /* Make question actions stack on smaller mobile */
    .question-actions {
        flex-direction: column;
    }
    .question-actions .btn {
        width: 100%;
    }
    /* File list items should wrap if filenames are long */
    .file-list-item {
        word-break: break-all;
    }
    .document-item {
        word-break: break-all;
    }
    .doc-name {
        word-break: break-word;
        overflow-wrap: break-word;
        min-width: 0;
    }
    .processing-name {
        min-width: 0;
    }
}

/* -- Admin page: very small screens (320px-480px) ------------ */
@media (max-width: 480px) {
    .admin-page {
        padding: 12px;
    }
    .admin-section {
        padding: 14px 12px;
    }
    .admin-stats-bar {
        gap: 8px;
    }
    .admin-stat-box {
        padding: 12px 8px;
        min-width: calc(50% - 4px);
    }
    .admin-stat-value {
        font-size: 1.3rem;
    }
    .admin-stat-label {
        font-size: 0.65rem;
    }
    .admin-header h1 {
        font-size: 1.2rem;
    }
}

/* -- Prevent iOS zoom on focused inputs (already 1rem=16px) -- */
/* Input font-size is already 1rem via .form-group rules, but
   ensure standalone inputs (sidebar password fields etc.) also
   meet the 16px threshold on iOS */
@media (max-width: 600px) {
    input[type="text"],
    input[type="email"],
    input[type="password"],
    input[type="tel"],
    input[type="number"],
    textarea,
    select {
        font-size: 16px;
    }
}

/* -- 320px emergency overrides ------------------------------- */
@media (max-width: 360px) {
    .login-container {
        padding: 16px 12px;
    }
    .login-header h1 {
        font-size: 1.5rem;
    }
    .step-number {
        width: 32px;
        height: 32px;
        min-width: 32px;
        font-size: 0.95rem;
    }
    .step-title h2 {
        font-size: 0.9rem;
    }
    .main-content {
        padding: 8px;
    }
    .step-body {
        padding: 0 8px 12px;
    }
    .modal-box {
        padding: 16px;
        width: 95%;
    }
    .admin-stat-box {
        min-width: 100%;
    }
}
