/* ── Albanian Law AI – Stylesheet ────────────────────────── */

:root {
    --primary: #1a365d;
    --primary-light: #2b6cb0;
    --primary-lighter: #ebf4ff;
    --accent: #c53030;
    --accent-light: #feb2b2;
    --bg: #f7fafc;
    --surface: #ffffff;
    --text: #1a202c;
    --text-secondary: #4a5568;
    --text-muted: #a0aec0;
    --border: #e2e8f0;
    --success: #38a169;
    --warning: #d69e2e;
    --error: #e53e3e;
    --radius: 12px;
    --shadow: 0 1px 3px rgba(0,0,0,.1), 0 1px 2px rgba(0,0,0,.06);
    --shadow-lg: 0 10px 15px -3px rgba(0,0,0,.1), 0 4px 6px -2px rgba(0,0,0,.05);
}

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

html {
    -webkit-text-size-adjust: 100%;
    scroll-behavior: smooth;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    min-height: 100vh;
    -webkit-tap-highlight-color: transparent;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-y: none;
}

button, a, input, textarea, select {
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}

/* ── ChatGPT-style app layout ────────────────────────────── */

.app-layout {
    display: flex;
    height: 100vh;
    overflow: hidden;
}

.sidebar {
    width: 260px;
    min-width: 260px;
    background: #1a1f36;
    color: rgba(255,255,255,.9);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
}

.sidebar-logo {
    padding: 1rem 1.25rem;
    display: flex;
    align-items: center;
    gap: .6rem;
    font-weight: 700;
    font-size: 1rem;
    color: white;
    text-decoration: none;
    border-bottom: 1px solid rgba(255,255,255,.08);
}

.sidebar-logo .icon { font-size: 1.35rem; }

.sidebar-new-chat {
    margin: .75rem;
    padding: .65rem 1rem;
    border: 1px solid rgba(255,255,255,.2);
    border-radius: 8px;
    background: transparent;
    color: white;
    font-size: .9rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: .5rem;
    width: calc(100% - 1.5rem);
    transition: background .2s;
}

.sidebar-new-chat:hover {
    background: rgba(255,255,255,.1);
}

.sidebar-scroll {
    flex: 1;
    overflow-y: auto;
    min-height: 0;
    scrollbar-width: thin;
    scrollbar-color: rgba(255,255,255,.15) transparent;
}
.sidebar-scroll::-webkit-scrollbar { width: 5px; }
.sidebar-scroll::-webkit-scrollbar-track { background: transparent; }
.sidebar-scroll::-webkit-scrollbar-thumb { background: rgba(255,255,255,.15); border-radius: 4px; }

.sidebar-chats {
    padding: .25rem 0;
}

.convo-list-title {
    font-size: .68rem;
    font-weight: 700;
    color: rgba(255,255,255,.4);
    text-transform: uppercase;
    letter-spacing: .8px;
    padding: .6rem .75rem .35rem;
}

.convo-item {
    display: flex;
    align-items: center;
    gap: .35rem;
    padding: .5rem .75rem;
    cursor: pointer;
    border-radius: 0;
    transition: background .15s;
    position: relative;
}

.convo-item:hover {
    background: rgba(255,255,255,.08);
}

.convo-item.convo-active {
    background: rgba(255,255,255,.12);
}

.convo-item-text {
    flex: 1;
    min-width: 0;
    overflow: hidden;
}

.convo-item-title {
    font-size: .82rem;
    color: rgba(255,255,255,.88);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.3;
}

.convo-active .convo-item-title {
    color: white;
    font-weight: 600;
}

.convo-item-preview {
    font-size: .7rem;
    color: rgba(255,255,255,.4);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.3;
    margin-top: .1rem;
}

.convo-item-meta {
    display: flex;
    align-items: center;
    gap: .4rem;
    margin-top: .15rem;
    font-size: .65rem;
    color: rgba(255,255,255,.35);
    line-height: 1.2;
}

.convo-item-date {
    white-space: nowrap;
}

.convo-item-count {
    white-space: nowrap;
}

.convo-item-meta .convo-item-count::before {
    content: "\00b7";
    margin-right: .4rem;
}

.convo-item-delete {
    flex-shrink: 0;
    background: none;
    border: none;
    color: rgba(255,255,255,.25);
    cursor: pointer;
    font-size: .75rem;
    padding: .2rem .3rem;
    border-radius: 4px;
    opacity: 0;
    transition: opacity .15s, color .15s, background .15s;
}

.convo-item:hover .convo-item-delete {
    opacity: 1;
}

.convo-item-delete:hover {
    color: #ff6b6b;
    background: rgba(255,107,107,.12);
}

.sidebar-footer {
    padding: 1rem 1.25rem;
    border-top: 1px solid rgba(255,255,255,.08);
    display: flex;
    flex-direction: column;
    gap: .5rem;
}

.sidebar-footer .user-email {
    font-size: .8rem;
    color: rgba(255,255,255,.7);
    word-break: break-all;
}

.sidebar-footer .btn {
    width: 100%;
    justify-content: center;
    font-size: .85rem;
}

.sidebar-footer .btn-outline-light {
    background: transparent;
    color: rgba(255,255,255,.9);
    border: 1px solid rgba(255,255,255,.25);
}

.sidebar-footer .btn-outline-light:hover {
    background: rgba(255,255,255,.1);
}

.main-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
    background: var(--bg);
    position: relative;
}

.main-area .chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 1.5rem 2rem;
    max-width: 800px;
    margin: 0 auto;
    width: 100%;
}

.main-area .chat-input-area {
    padding: 1rem 2rem 1.5rem;
    background: var(--surface);
    border-top: 1px solid var(--border);
}

.main-area .chat-input-wrapper {
    max-width: 800px;
    margin: 0 auto;
}

.trial-banner-warning {
    background: linear-gradient(90deg, #fef3c7 0%, #fde68a 100%);
    color: #92400e;
    border-bottom: 1px solid #f59e0b;
}

.paywall-overlay {
    position: absolute;
    inset: 0;
    background: rgba(247,250,252,.95);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 50;
    padding: 2rem;
}

.paywall-overlay .card {
    max-width: 420px;
    width: 100%;
    text-align: center;
}

.auth-modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.5);
    z-index: 300;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}

.auth-modal-backdrop .auth-card {
    width: 100%;
    max-width: 400px;
    margin: 0;
}

.auth-modal-backdrop .auth-tabs {
    margin-bottom: 1rem;
}

.link-admin {
    display: block;
    margin-top: .75rem;
    font-size: .8rem;
    color: rgba(255,255,255,.6);
    text-decoration: none;
}

.link-admin:hover { color: white; }

/* ── Navigation ─────────────────────────────────────────── */

.navbar {
    background: var(--primary);
    color: white;
    padding: 0 2rem;
    height: 64px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    box-shadow: var(--shadow-lg);
    position: sticky;
    top: 0;
    z-index: 100;
}

.navbar .logo {
    font-size: 1.25rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: .75rem;
    text-decoration: none;
    color: white;
}

.navbar .logo .icon {
    font-size: 1.5rem;
}

.navbar nav {
    display: flex;
    gap: .5rem;
}

.navbar nav a {
    color: rgba(255,255,255,.8);
    text-decoration: none;
    padding: .5rem 1rem;
    border-radius: 8px;
    font-size: .9rem;
    font-weight: 500;
    transition: all .2s;
}

.navbar nav a:hover,
.navbar nav a.active {
    color: white;
    background: rgba(255,255,255,.15);
}

/* ── Layout ─────────────────────────────────────────────── */

.container {
    max-width: 1100px;
    margin: 0 auto;
    padding: 2rem;
}

.page-title {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--primary);
    margin-bottom: 1.5rem;
}

.page-subtitle {
    color: var(--text-secondary);
    margin-bottom: 2rem;
    font-size: .95rem;
}

/* ── Cards ──────────────────────────────────────────────── */

.card {
    background: var(--surface);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
    padding: 1.5rem;
    margin-bottom: 1.5rem;
}

.card-header {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--primary);
    margin-bottom: 1rem;
    padding-bottom: .75rem;
    border-bottom: 1px solid var(--border);
}

/* ── Upload Form ────────────────────────────────────────── */

.upload-zone {
    border: 2px dashed var(--border);
    border-radius: var(--radius);
    padding: 2.5rem;
    text-align: center;
    cursor: pointer;
    transition: all .2s;
    background: var(--bg);
    margin-bottom: 1rem;
}

.upload-zone:hover,
.upload-zone.dragover {
    border-color: var(--primary-light);
    background: var(--primary-lighter);
}

.upload-zone .upload-icon {
    font-size: 3rem;
    margin-bottom: .75rem;
}

.upload-zone p {
    color: var(--text-secondary);
    font-size: .95rem;
}

.upload-zone .file-types {
    color: var(--text-muted);
    font-size: .8rem;
    margin-top: .5rem;
}

.form-group {
    margin-bottom: 1rem;
}

.form-group label {
    display: block;
    font-weight: 600;
    font-size: .85rem;
    color: var(--text-secondary);
    margin-bottom: .35rem;
    text-transform: uppercase;
    letter-spacing: .5px;
}

.form-group input,
.form-group select {
    width: 100%;
    padding: .65rem .85rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: .95rem;
    transition: border-color .2s;
    background: white;
}

.form-group input:focus,
.form-group select:focus {
    outline: none;
    border-color: var(--primary-light);
    box-shadow: 0 0 0 3px rgba(43, 108, 176, .1);
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 1rem;
}

/* ── Buttons ────────────────────────────────────────────── */

.btn {
    display: inline-flex;
    align-items: center;
    gap: .5rem;
    padding: .65rem 1.35rem;
    border: none;
    border-radius: 8px;
    font-size: .9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all .2s;
    text-decoration: none;
}

.btn-primary {
    background: var(--primary);
    color: white;
}

.btn-primary:hover {
    background: var(--primary-light);
}

.btn-primary:disabled {
    background: var(--text-muted);
    cursor: not-allowed;
}

.btn-danger {
    background: var(--error);
    color: white;
}

.btn-danger:hover {
    background: var(--accent);
}

.btn-sm {
    padding: .4rem .75rem;
    font-size: .8rem;
}

/* ── Status Badges ──────────────────────────────────────── */

.badge {
    display: inline-flex;
    align-items: center;
    gap: .3rem;
    padding: .25rem .65rem;
    border-radius: 20px;
    font-size: .75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .5px;
}

.badge-uploaded   { background: #ebf8ff; color: #2b6cb0; }
.badge-processing { background: #fefcbf; color: #975a16; }
.badge-processed  { background: #f0fff4; color: #276749; }
.badge-ready      { background: #f0fff4; color: #276749; }
.badge-error      { background: #fff5f5; color: #c53030; }
.badge-failed     { background: #fff5f5; color: #c53030; }

/* ── Documents Table ────────────────────────────────────── */

.doc-table {
    width: 100%;
    border-collapse: collapse;
}

.doc-table th {
    text-align: left;
    padding: .75rem;
    font-size: .8rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: .5px;
    border-bottom: 2px solid var(--border);
}

.doc-table td {
    padding: .75rem;
    border-bottom: 1px solid var(--border);
    font-size: .9rem;
    vertical-align: middle;
}

.doc-table tr:hover td {
    background: var(--bg);
}

.doc-name {
    font-weight: 600;
    color: var(--primary);
}

.doc-meta {
    font-size: .8rem;
    color: var(--text-muted);
}

.empty-state {
    text-align: center;
    padding: 3rem;
    color: var(--text-muted);
}

.empty-state .empty-icon {
    font-size: 3rem;
    margin-bottom: 1rem;
}

/* ── Document Toolbar (filter + upload) ────────────────── */

.doc-toolbar {
    display: flex;
    align-items: center;
    gap: .5rem;
    padding: .5rem 1rem;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}

.doc-toolbar select {
    flex: 1;
    padding: .45rem .65rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: .82rem;
    font-family: inherit;
    background: var(--bg);
    color: var(--text);
    max-width: 320px;
    cursor: pointer;
}

.doc-toolbar select:focus {
    outline: none;
    border-color: var(--primary-light);
}

.doc-toolbar .btn-upload-mini {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: .35rem;
    padding: .45rem .75rem;
    border: 1px solid var(--primary);
    border-radius: 8px;
    background: var(--primary);
    color: white;
    font-size: .78rem;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
    transition: background .2s;
}

.doc-toolbar .btn-upload-mini:hover {
    background: var(--primary-light);
}

.doc-toolbar .doc-status {
    font-size: .72rem;
    color: var(--text-muted);
    white-space: nowrap;
}

.doc-toolbar .doc-status .processing-dot {
    display: inline-block;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--warning);
    margin-right: 3px;
    animation: pulse-dot 1.4s infinite;
}

@keyframes pulse-dot {
    0%, 100% { opacity: .4; }
    50% { opacity: 1; }
}

/* Document list panel (mini sidebar panel) */
.doc-panel {
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    width: 300px;
    max-width: 80vw;
    background: var(--surface);
    border-left: 1px solid var(--border);
    box-shadow: -4px 0 16px rgba(0,0,0,.08);
    z-index: 60;
    display: flex;
    flex-direction: column;
    transform: translateX(100%);
    transition: transform .3s cubic-bezier(.4,0,.2,1);
}

.doc-panel.open {
    transform: translateX(0);
}

.doc-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: .75rem 1rem;
    border-bottom: 1px solid var(--border);
    font-weight: 600;
    font-size: .9rem;
    color: var(--primary);
}

.doc-panel-header .btn-close-panel {
    background: none;
    border: none;
    font-size: 1.1rem;
    cursor: pointer;
    color: var(--text-muted);
    padding: .25rem;
}

.doc-panel-body {
    flex: 1;
    overflow-y: auto;
    padding: .75rem;
}

.doc-panel-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: .6rem .75rem;
    border-radius: 8px;
    margin-bottom: .35rem;
    background: var(--bg);
    font-size: .82rem;
    gap: .5rem;
}

.doc-panel-item .doc-item-name {
    flex: 1;
    font-weight: 500;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.doc-panel-item .doc-item-status {
    font-size: .68rem;
    font-weight: 600;
    padding: .15rem .4rem;
    border-radius: 10px;
    flex-shrink: 0;
}

.doc-item-status.ready { background: #f0fff4; color: #276749; }
.doc-item-status.processing { background: #fefcbf; color: #975a16; }
.doc-item-status.failed { background: #fff5f5; color: #c53030; }

.doc-panel-item .btn-retry-mini {
    font-size: .68rem;
    padding: .2rem .5rem;
    border-radius: 6px;
    border: 1px solid var(--error);
    background: transparent;
    color: var(--error);
    cursor: pointer;
    flex-shrink: 0;
}

.doc-panel-item .btn-retry-mini:hover {
    background: #fff5f5;
}

.doc-panel-item .btn-delete-mini {
    font-size: .68rem;
    padding: .2rem .4rem;
    border-radius: 6px;
    border: none;
    background: transparent;
    color: var(--text-muted);
    cursor: pointer;
    flex-shrink: 0;
}

.doc-panel-item .btn-delete-mini:hover {
    color: var(--error);
}

/* Hidden file input */
.hidden-file-input {
    display: none;
}

/* ── Chat Interface ─────────────────────────────────────── */

.chat-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
    position: relative;
}

.chat-wrapper {
    display: flex;
    flex-direction: column;
    height: calc(100vh - 64px);
    max-width: 900px;
    margin: 0 auto;
}

.app-layout .chat-wrapper {
    height: 100%;
    max-width: none;
}

.chat-header {
    padding: 1.25rem 1.5rem;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.chat-header h2 {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--primary);
}

.chat-header .session-info {
    font-size: .8rem;
    color: var(--text-muted);
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.message {
    max-width: 85%;
    animation: fadeIn .3s ease;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

.message-user {
    align-self: flex-end;
}

.message-assistant {
    align-self: flex-start;
}

.message-bubble {
    padding: 1rem 1.25rem;
    border-radius: var(--radius);
    font-size: .95rem;
    line-height: 1.7;
}

.message-user .message-bubble {
    background: var(--primary);
    color: white;
    border-bottom-right-radius: 4px;
}

.message-assistant .message-bubble {
    background: var(--surface);
    border: 1px solid var(--border);
    border-bottom-left-radius: 4px;
    box-shadow: var(--shadow);
}

.message-assistant .message-bubble p {
    margin-bottom: .5rem;
}

.message-assistant .message-bubble p:last-child {
    margin-bottom: 0;
}

/* Welcome bubble */
.welcome-bubble {
    background: linear-gradient(135deg, #ffffff 0%, #f0f5ff 100%) !important;
    border: 1px solid #d4e4f7 !important;
}

.welcome-note {
    color: var(--text-muted);
    font-size: .82rem;
    margin-top: .4rem;
    padding-top: .4rem;
    border-top: 1px solid var(--border);
    line-height: 1.45;
}

/* ── Sources (clean grouped display) ───────────────────── */
.sources-clean {
    margin-top: .6rem;
    padding: .6rem .75rem;
    background: var(--primary-lighter);
    border-radius: 10px;
    border: 1px solid #bee3f8;
}

.sources-label {
    font-size: .7rem;
    font-weight: 700;
    color: var(--primary);
    text-transform: uppercase;
    letter-spacing: .6px;
    margin-bottom: .35rem;
}

.source-item-clean {
    font-size: .82rem;
    color: var(--text-secondary);
    padding: .4rem 0;
    line-height: 1.45;
    border-bottom: 1px solid var(--border);
}
.source-item-clean:last-child { border-bottom: none; }
.source-title-line {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: .35rem;
}
.source-item-clean strong {
    color: var(--text);
}

.source-details {
    font-size: .76rem;
    color: var(--text-muted);
    margin-top: .15rem;
    padding-left: .1rem;
}
.source-law-num {
    font-size: .75rem;
    color: var(--primary);
    font-weight: 500;
}
.source-law-date {
    font-size: .72rem;
    color: var(--text-muted);
}
.source-chunk-count {
    font-size: .65rem;
    color: var(--text-muted);
    background: var(--bg);
    padding: .1rem .35rem;
    border-radius: 6px;
    border: 1px solid var(--border);
}

/* "Shfaq më shumë burime" expand toggle */
.source-expand-wrap {
    margin-top: .4rem;
    border-top: 1px solid #d0e7f7;
    padding-top: .35rem;
}
.btn-source-expand {
    background: none;
    border: none;
    color: var(--primary);
    font-size: .72rem;
    font-weight: 600;
    cursor: pointer;
    padding: .15rem 0;
    opacity: .85;
    transition: opacity .15s;
}
.btn-source-expand:hover { opacity: 1; text-decoration: underline; }

.source-extra-list {
    margin-top: .3rem;
    padding-left: .1rem;
}
.source-extra-item {
    font-size: .72rem;
    color: var(--text-muted);
    padding: .15rem 0;
    border-bottom: 1px solid #edf5fc;
}
.source-extra-item:last-child { border-bottom: none; }

/* Legacy .sources (keep hidden if old markup appears) */
.sources { display: none; }

/* Chat Input */
.chat-input-area {
    padding: 1rem 1.5rem;
    background: var(--surface);
    border-top: 1px solid var(--border);
}

.chat-input-wrapper {
    display: flex;
    gap: .75rem;
    align-items: flex-end;
}

.chat-input-wrapper textarea {
    flex: 1;
    padding: .75rem 1rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: .95rem;
    font-family: inherit;
    resize: none;
    min-height: 48px;
    max-height: 150px;
    line-height: 1.5;
    transition: border-color .2s;
}

.chat-input-wrapper textarea:focus {
    outline: none;
    border-color: var(--primary-light);
    box-shadow: 0 0 0 3px rgba(43, 108, 176, .1);
}

.chat-input-wrapper .btn-send {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    padding: 0;
    flex-shrink: 0;
}

.chat-disclaimer {
    font-size: .75rem;
    color: var(--text-muted);
    text-align: center;
    padding-top: .5rem;
}

/* ── Smart Question Helper (Suggest Panel) ─────────────── */

.suggest-panel {
    max-width: 800px;
    margin: 0 auto .5rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: .5rem .7rem;
    position: relative;
    box-shadow: 0 -3px 12px rgba(0,0,0,.05);
    animation: sgSlide .15s ease-out;
}
@keyframes sgSlide {
    from { opacity: 0; transform: translateY(6px); }
    to   { opacity: 1; transform: translateY(0); }
}

.suggest-close {
    position: absolute;
    top: .3rem; right: .45rem;
    background: none;
    border: none;
    font-size: 1rem;
    color: var(--text-muted);
    cursor: pointer;
    line-height: 1;
    padding: .1rem .2rem;
    border-radius: 4px;
}
.suggest-close:hover { background: var(--bg); color: var(--text); }

/* Suggestion chip buttons (main suggestions) */
.suggest-chips-row {
    display: flex;
    flex-direction: column;
    gap: .3rem;
    margin-bottom: .4rem;
}

.suggest-chip-btn {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: .4rem;
    padding: .4rem .6rem;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text);
    font-size: .8rem;
    line-height: 1.3;
    cursor: pointer;
    text-align: left;
    transition: all .12s;
}
.suggest-chip-btn:hover {
    border-color: var(--primary);
    background: rgba(43,108,176,.05);
}
.suggest-chip-btn:active {
    transform: scale(.98);
}

.sg-use {
    flex-shrink: 0;
    font-size: .65rem;
    font-weight: 600;
    color: var(--primary);
    text-transform: uppercase;
    letter-spacing: .02em;
    opacity: .7;
}
.suggest-chip-btn:hover .sg-use { opacity: 1; }

/* Related topic chips */
.suggest-topics-row {
    display: flex;
    flex-wrap: wrap;
    gap: .3rem;
}

.suggest-topic-chip {
    font-size: .7rem;
    padding: .2rem .55rem;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 100px;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all .12s;
    white-space: nowrap;
}
.suggest-topic-chip:hover {
    border-color: var(--primary);
    color: var(--primary);
    background: rgba(43,108,176,.05);
}

/* Typing indicator */
.typing-indicator {
    display: flex;
    gap: 4px;
    padding: 1rem;
    align-self: flex-start;
}

.typing-indicator span {
    width: 8px;
    height: 8px;
    background: var(--text-muted);
    border-radius: 50%;
    animation: typing 1.4s infinite;
}

.typing-indicator span:nth-child(2) { animation-delay: .2s; }
.typing-indicator span:nth-child(3) { animation-delay: .4s; }

@keyframes typing {
    0%, 60%, 100% { transform: translateY(0); opacity: .4; }
    30% { transform: translateY(-8px); opacity: 1; }
}

/* ── Toast Notifications ────────────────────────────────── */

.toast-container {
    position: fixed;
    top: 80px;
    right: 1.5rem;
    z-index: 200;
    display: flex;
    flex-direction: column;
    gap: .5rem;
}

.toast {
    padding: .75rem 1.25rem;
    border-radius: 8px;
    font-size: .9rem;
    font-weight: 500;
    box-shadow: var(--shadow-lg);
    animation: slideIn .3s ease;
    max-width: 350px;
}

.toast-success { background: #f0fff4; color: #276749; border: 1px solid #c6f6d5; }
.toast-error   { background: #fff5f5; color: #c53030; border: 1px solid #fed7d7; }
.toast-info    { background: #ebf8ff; color: #2b6cb0; border: 1px solid #bee3f8; }

@keyframes slideIn {
    from { opacity: 0; transform: translateX(50px); }
    to { opacity: 1; transform: translateX(0); }
}

/* ── Loading Spinner ────────────────────────────────────── */

.spinner {
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin .6s linear infinite;
}

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

/* ── Auth / Login ────────────────────────────────────────── */

.auth-page {
    min-height: calc(100vh - 64px);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem;
}

.auth-card {
    width: 100%;
    max-width: 420px;
}

.auth-tabs {
    display: flex;
    gap: 0;
    margin-bottom: 1.5rem;
    border-bottom: 1px solid var(--border);
}

.auth-tab {
    flex: 1;
    padding: .75rem 1rem;
    border: none;
    background: none;
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-muted);
    cursor: pointer;
    border-bottom: 3px solid transparent;
    margin-bottom: -1px;
}

.auth-tab:hover { color: var(--text-secondary); }
.auth-tab.active { color: var(--primary); border-bottom-color: var(--primary); }

.auth-form h2 {
    font-size: 1.5rem;
    margin-bottom: .25rem;
    color: var(--primary);
}

.auth-subtitle {
    color: var(--text-secondary);
    font-size: .9rem;
    margin-bottom: 1.5rem;
}

.btn-block { width: 100%; justify-content: center; margin-top: .5rem; }

/* ── Paywall ────────────────────────────────────────────── */

.paywall {
    max-width: 480px;
    margin: 2rem auto;
    text-align: center;
    padding: 2rem;
}

.paywall h2 { font-size: 1.5rem; color: var(--primary); margin-bottom: 1rem; }
.paywall p { color: var(--text-secondary); margin-bottom: 1.5rem; }
.paywall .price { font-size: 2rem; font-weight: 700; color: var(--primary); }
.paywall .price span { font-size: 1rem; font-weight: 500; color: var(--text-muted); }

.trial-banner {
    background: linear-gradient(90deg, var(--primary-lighter) 0%, #c6f6d5 100%);
    color: var(--primary);
    text-align: center;
    padding: .5rem 1rem;
    font-size: .9rem;
    font-weight: 500;
    border-bottom: 1px solid #9ae6b4;
}

.paywall-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: .75rem;
    justify-content: center;
    margin-top: 1rem;
}

.btn-outline {
    background: transparent;
    color: var(--primary);
    border: 1.5px solid var(--primary);
}

.btn-outline:hover {
    background: rgba(43,108,176,.06);
}

.paywall-note {
    font-size: .75rem;
    color: var(--text-muted);
    margin-top: .75rem;
}

.user-menu {
    display: flex;
    align-items: center;
    gap: .75rem;
}

.user-menu .user-email {
    font-size: .85rem;
    color: rgba(255,255,255,.9);
}

.user-menu .btn-sm { padding: .4rem .75rem; }

/* ── Responsive ─────────────────────────────────────────── */

/* ── Mobile-native WebView refinements ─────────────────── */

/* Mobile: sidebar collapses to toggle button */
@media (max-width: 768px) {
    :root {
        --radius: 10px;
    }

    body {
        font-size: 14px;
        -webkit-text-size-adjust: 100%;
    }

    .container { padding: .75rem; }
    .form-row { grid-template-columns: 1fr; }
    .navbar { padding: 0 .75rem; height: 48px; }
    .navbar nav a { padding: .4rem .5rem; font-size: .75rem; }
    .message { max-width: 92%; }
    .doc-table th:nth-child(4),
    .doc-table td:nth-child(4) { display: none; }

    /* Sidebar: hidden by default on mobile */
    .sidebar {
        position: fixed;
        left: -260px;
        top: 0;
        bottom: 0;
        z-index: 200;
        transition: left .3s cubic-bezier(.4,0,.2,1);
        box-shadow: none;
    }
    .sidebar.open {
        left: 0;
        box-shadow: 4px 0 24px rgba(0,0,0,.25);
    }

    /* Sidebar overlay when open */
    .sidebar-overlay {
        display: none;
        position: fixed;
        inset: 0;
        background: rgba(0,0,0,.35);
        z-index: 199;
        backdrop-filter: blur(2px);
        -webkit-backdrop-filter: blur(2px);
    }
    .sidebar-overlay.active {
        display: block;
    }

    /* Mobile header bar */
    .mobile-menu-btn {
        display: flex;
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        z-index: 100;
        height: 44px;
        align-items: center;
        justify-content: flex-start;
        padding: 0 .85rem;
        background: var(--primary);
        color: white;
        border: none;
        border-radius: 0;
        font-size: 1.1rem;
        cursor: pointer;
        box-shadow: 0 1px 4px rgba(0,0,0,.12);
    }

    .mobile-menu-btn::after {
        content: 'Albanian Law AI';
        font-size: .85rem;
        font-weight: 600;
        margin-left: .6rem;
        letter-spacing: .3px;
    }

    /* Premium compact chat messages */
    .main-area .chat-messages {
        padding: 52px .85rem .75rem;
    }

    .message-bubble {
        padding: .7rem .9rem;
        font-size: .87rem;
        line-height: 1.55;
        border-radius: 14px;
    }

    .message-user .message-bubble {
        border-bottom-right-radius: 4px;
        background: var(--primary);
    }

    .message-assistant .message-bubble {
        border-bottom-left-radius: 4px;
        background: white;
    }

    .message-assistant .message-bubble p {
        margin-bottom: .35rem;
    }

    .message-assistant .message-bubble p strong {
        font-size: .9rem;
    }

    .message-assistant .message-bubble p:last-child {
        margin-bottom: 0;
    }

    .chat-messages {
        gap: .6rem;
        padding: .85rem;
    }

    /* Compact input area */
    .main-area .chat-input-area {
        padding: .5rem .75rem .6rem;
        border-top: 1px solid var(--border);
        background: white;
    }

    .chat-input-wrapper textarea {
        padding: .55rem .75rem;
        font-size: .85rem;
        min-height: 40px;
        max-height: 100px;
        border-radius: 20px;
        background: var(--bg);
    }

    .chat-input-wrapper .btn-send {
        width: 38px;
        height: 38px;
        font-size: 1rem;
        border-radius: 50%;
        flex-shrink: 0;
    }

    .chat-disclaimer {
        font-size: .65rem;
        padding-top: .3rem;
        line-height: 1.3;
    }

    .suggest-panel {
        margin: 0 0 .3rem;
        padding: .4rem .55rem;
        border-radius: 8px;
    }
    .suggest-chip-btn { font-size: .76rem; padding: .35rem .5rem; }
    .sg-use { font-size: .6rem; }
    .suggest-topic-chip { font-size: .65rem; padding: .18rem .45rem; }

    /* Compact trial banner */
    .trial-banner {
        font-size: .75rem;
        padding: .3rem .65rem;
        margin-top: 44px;
    }

    /* Paywall refinements */
    .paywall-overlay {
        padding: 1rem;
        padding-top: 52px;
    }

    .paywall-overlay .card {
        padding: 1.25rem;
        border-radius: 16px;
    }

    .paywall-overlay .card h2 {
        font-size: 1.15rem;
    }

    .paywall-overlay .card p {
        font-size: .85rem;
    }

    .paywall-overlay .card .price {
        font-size: 1.5rem;
    }

    .paywall-buttons {
        gap: .5rem;
    }

    .paywall-buttons .btn {
        font-size: .8rem;
        padding: .5rem 1rem;
    }

    /* Auth modal compact */
    .auth-modal-backdrop {
        padding: .75rem;
    }

    .auth-modal-backdrop .auth-card {
        padding: 1.25rem;
        border-radius: 16px;
    }

    .auth-form h2 {
        font-size: 1.15rem;
    }

    .auth-subtitle {
        font-size: .8rem;
        margin-bottom: 1rem;
    }

    .form-group input {
        padding: .55rem .75rem;
        font-size: .87rem;
        border-radius: 10px;
    }

    .form-group label {
        font-size: .75rem;
    }

    .btn-block {
        padding: .55rem 1rem;
        font-size: .87rem;
        border-radius: 10px;
    }

    /* Toast compact */
    .toast-container {
        top: 52px;
        right: .75rem;
        left: .75rem;
    }

    .toast {
        font-size: .8rem;
        padding: .6rem .85rem;
        max-width: none;
    }

    /* Sources compact */
    .sources-clean {
        padding: .5rem .6rem;
        margin-top: .4rem;
    }
    .sources-label {
        font-size: .65rem;
        margin-bottom: .25rem;
    }
    .source-item-clean {
        font-size: .75rem;
        padding: .2rem 0;
    }
    .btn-source-expand {
        font-size: .66rem;
    }

    /* Doc toolbar compact */
    .doc-toolbar {
        padding: .35rem .65rem;
        gap: .35rem;
        flex-wrap: wrap;
    }
    .doc-toolbar select {
        font-size: .78rem;
        padding: .35rem .5rem;
        max-width: 200px;
    }
    .doc-toolbar .btn-upload-mini {
        font-size: .72rem;
        padding: .35rem .6rem;
    }
}

/* ── Very small phones (320–480px) ──────────────────────── */
@media (max-width: 480px) {
    body { font-size: 13px; }

    /* Tighter mobile header */
    .mobile-menu-btn {
        height: 40px;
        font-size: 1rem;
        padding: 0 .65rem;
    }
    .mobile-menu-btn::after {
        font-size: .8rem;
        margin-left: .5rem;
    }

    /* Chat messages area */
    .main-area .chat-messages {
        padding: 44px .6rem .6rem;
    }

    .chat-messages {
        gap: .5rem;
        padding: .6rem;
    }

    .message { max-width: 95%; }

    .message-bubble {
        padding: .6rem .75rem;
        font-size: .84rem;
        line-height: 1.5;
        border-radius: 12px;
    }

    .message-user .message-bubble {
        border-bottom-right-radius: 3px;
    }
    .message-assistant .message-bubble {
        border-bottom-left-radius: 3px;
    }
    .message-assistant .message-bubble p { margin-bottom: .3rem; }
    .message-assistant .message-bubble p strong { font-size: .86rem; }

    .welcome-bubble { padding: .6rem .75rem !important; }
    .welcome-note { font-size: .76rem; }

    /* Input area – safe-area bottom for notched phones */
    .main-area .chat-input-area {
        padding: .4rem .6rem calc(.5rem + env(safe-area-inset-bottom, 0px));
    }

    .chat-input-wrapper textarea {
        padding: .5rem .65rem;
        font-size: .84rem;
        min-height: 36px;
        max-height: 88px;
        border-radius: 18px;
    }

    .chat-input-wrapper .btn-send {
        width: 36px;
        height: 36px;
        font-size: .9rem;
    }

    .chat-disclaimer {
        font-size: .6rem;
        padding-top: .2rem;
    }

    /* Suggestion panel compact */
    .suggest-panel {
        margin: 0 0 .25rem;
        padding: .35rem .45rem;
        border-radius: 8px;
    }
    .suggest-chip-btn { font-size: .72rem; padding: .3rem .45rem; border-radius: 6px; }
    .sg-use { font-size: .58rem; }
    .suggest-topic-chip { font-size: .62rem; padding: .15rem .4rem; }
    .suggest-close { font-size: .85rem; top: .2rem; right: .3rem; }

    /* Trial banner */
    .trial-banner {
        font-size: .7rem;
        padding: .25rem .5rem;
        margin-top: 40px;
    }

    /* Paywall */
    .paywall-overlay {
        padding: .75rem;
        padding-top: 44px;
    }
    .paywall-overlay .card {
        padding: 1rem;
        border-radius: 14px;
    }
    .paywall-overlay .card h2 { font-size: 1.05rem; }
    .paywall-overlay .card p { font-size: .82rem; }
    .paywall-overlay .card .price { font-size: 1.3rem; }
    .paywall-buttons .btn { font-size: .78rem; padding: .45rem .85rem; }

    /* Sources extra compact */
    .sources-clean { padding: .4rem .5rem; }
    .sources-label { font-size: .6rem; }
    .source-item-clean { font-size: .72rem; }
    .source-details { font-size: .68rem; }
    .source-law-num { font-size: .68rem; }
    .source-chunk-count { font-size: .6rem; padding: .05rem .25rem; }
    .btn-source-expand { font-size: .62rem; }

    /* Toast */
    .toast-container { top: 44px; right: .5rem; left: .5rem; }
    .toast { font-size: .76rem; padding: .5rem .7rem; }

    /* Sidebar – narrower on very small screens */
    .sidebar { width: 240px; min-width: 240px; left: -240px; }
    .sidebar-logo { padding: .75rem 1rem; font-size: .9rem; }
    .sidebar-new-chat { margin: .5rem; padding: .5rem .75rem; font-size: .82rem; width: calc(100% - 1rem); }
    .sidebar-footer { padding: .75rem 1rem; }
    .sidebar-footer .user-email { font-size: .74rem; }
    .sidebar-footer .btn { font-size: .8rem; padding: .4rem .65rem; }

    /* Conversation list compact */
    .convo-list-title { font-size: .62rem; padding: .5rem .6rem .25rem; }
    .convo-item { padding: .4rem .6rem; }
    .convo-item-title { font-size: .76rem; }
    .convo-item-preview { font-size: .66rem; }
    .convo-item-delete { opacity: 1; font-size: .7rem; }

    /* Sidebar SQ compact */
    .sidebar-sq-title { font-size: .62rem; padding: .5rem .6rem .25rem; }
    .sidebar-sq-cat-header { font-size: .74rem; padding: .35rem .6rem; }
    .sidebar-sq-q { font-size: .72rem; padding: .3rem .5rem; }
    .sidebar-sq-cat-body { padding-left: .6rem; }

    /* Doc toolbar */
    .doc-toolbar { padding: .3rem .5rem; gap: .3rem; }
    .doc-toolbar select { font-size: .74rem; padding: .3rem .4rem; max-width: 160px; }
}

/* Desktop: hide mobile-only elements */
@media (min-width: 769px) {
    .mobile-menu-btn { display: none; }
    .sidebar-overlay { display: none !important; }
}

/* ── Large desktop enhancements ──────────────────────── */
@media (min-width: 1200px) {
    .sidebar {
        width: 280px;
        min-width: 280px;
    }

    .chat-messages {
        max-width: 860px;
    }

    .chat-input-wrapper {
        max-width: 860px;
    }

    .message-bubble {
        max-width: 85%;
    }

    .paywall-overlay .card {
        max-width: 480px;
        padding: 3rem;
        border-radius: 20px;
    }
}

@media (min-width: 1600px) {
    .chat-messages {
        max-width: 920px;
    }
    .chat-input-wrapper {
        max-width: 920px;
    }
}

/* ── Login page — standalone centered card ───────────── */

.login-page-wrapper {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    background: #0a0f2c;
}

.login-nav {
    padding: 16px 32px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid rgba(255,255,255,.08);
}
.login-nav-logo {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 700;
    font-size: 1.1rem;
    color: #f0f0f5;
    text-decoration: none;
}
.login-nav-logo img {
    width: 32px;
    height: 32px;
    border-radius: 8px;
}
.login-nav-links {
    display: flex;
    gap: 20px;
    align-items: center;
}
.login-nav-links a {
    color: #9a9ab0;
    font-size: .9rem;
    font-weight: 500;
    text-decoration: none;
}
.login-nav-links a:hover { color: #fff; }

.login-center {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 40px 24px;
}

.login-card-modern {
    background: #1a1f36;
    border: 1px solid rgba(255,255,255,.08);
    border-radius: 20px;
    padding: 40px 36px;
    width: 100%;
    max-width: 420px;
    color: #f0f0f5;
}

.login-card-modern .auth-tabs {
    display: flex;
    gap: 0;
    margin-bottom: 24px;
    background: rgba(255,255,255,.06);
    border-radius: 10px;
    padding: 3px;
}

.login-card-modern .auth-tab {
    flex: 1;
    padding: 10px 0;
    border: none;
    background: transparent;
    color: #9a9ab0;
    font-weight: 600;
    font-size: .9rem;
    cursor: pointer;
    border-radius: 8px;
    transition: all .2s;
}

.login-card-modern .auth-tab.active {
    background: #6c63ff;
    color: #fff;
}

.login-card-modern h2 {
    font-size: 1.4rem;
    font-weight: 700;
    margin-bottom: 6px;
    color: #f0f0f5;
}

.login-card-modern .auth-subtitle {
    color: #9a9ab0;
    font-size: .88rem;
    margin-bottom: 24px;
}

.login-card-modern .form-group {
    margin-bottom: 16px;
}

.login-card-modern .form-group label {
    display: block;
    font-size: .82rem;
    font-weight: 500;
    color: #9a9ab0;
    margin-bottom: 6px;
}

.login-card-modern .form-group input {
    width: 100%;
    padding: 12px 14px;
    border: 1px solid rgba(255,255,255,.12);
    border-radius: 10px;
    background: rgba(255,255,255,.06);
    color: #f0f0f5;
    font-size: .95rem;
    font-family: inherit;
    outline: none;
    transition: border-color .2s;
}

.login-card-modern .form-group input:focus {
    border-color: #6c63ff;
}

.login-card-modern .form-group input::placeholder {
    color: #666;
}

.login-card-modern .btn-login-primary {
    width: 100%;
    padding: 13px;
    border: none;
    border-radius: 10px;
    background: #6c63ff;
    color: #fff;
    font-weight: 600;
    font-size: .95rem;
    cursor: pointer;
    transition: transform .15s, box-shadow .15s;
    margin-top: 4px;
}

.login-card-modern .btn-login-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 20px rgba(108,99,255,.3);
}

.login-card-modern .forgot-link {
    display: block;
    text-align: center;
    margin-top: 14px;
    color: #6c63ff;
    font-size: .84rem;
}

.login-card-modern .forgot-link:hover { text-decoration: underline; }

.login-toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 9999;
}

.login-toast {
    background: #1a1f36;
    color: #f0f0f5;
    padding: 12px 20px;
    border-radius: 10px;
    margin-bottom: 8px;
    font-size: .88rem;
    border-left: 3px solid #6c63ff;
    transition: opacity .3s;
}
.login-toast.toast-error { border-left-color: #e53e3e; }
.login-toast.toast-success { border-left-color: #22c55e; }

/* ── Login page – tablet ─────────────────────── */
@media (max-width: 768px) {
    .login-nav { padding: 12px 16px; }
    .login-nav-links { gap: 14px; }
    .login-nav-links a:first-child { display: none; }
    .login-center { padding: 24px 16px; }
    .login-card-modern { padding: 32px 24px; max-width: 400px; }
}

/* ── Login page – small phones ───────────────── */
@media (max-width: 480px) {
    .login-nav { padding: 10px 12px; }
    .login-nav-logo { font-size: .95rem; gap: 8px; }
    .login-nav-logo img { width: 28px; height: 28px; }
    .login-center { padding: 16px 12px; }
    .login-card-modern {
        padding: 24px 18px;
        border-radius: 16px;
        max-width: 100%;
    }
    .login-card-modern .auth-tabs { margin-bottom: 18px; }
    .login-card-modern .auth-tab { padding: 9px 0; font-size: .84rem; }
    .login-card-modern h2 { font-size: 1.2rem; }
    .login-card-modern .auth-subtitle { font-size: .82rem; margin-bottom: 18px; }
    .login-card-modern .form-group { margin-bottom: 12px; }
    .login-card-modern .form-group label { font-size: .76rem; margin-bottom: 4px; }
    .login-card-modern .form-group input { padding: 11px 12px; font-size: .9rem; border-radius: 8px; }
    .login-card-modern .btn-login-primary { padding: 12px; font-size: .9rem; border-radius: 8px; }
    .login-card-modern .forgot-link { font-size: .78rem; margin-top: 10px; }
    .login-toast-container { top: 12px; right: 12px; left: 12px; }
    .login-toast { font-size: .82rem; padding: 10px 14px; }
}

/* ── Citation Enhancements ─────────────────────────────── */

.sim-badge {
    display: inline-block;
    padding: .1rem .4rem;
    border-radius: 8px;
    font-size: .65rem;
    font-weight: 700;
    margin-left: .3rem;
    vertical-align: middle;
}
.sim-high { background: #c6f6d5; color: #22543d; }
.sim-mid { background: #fefcbf; color: #975a16; }
.sim-low { background: #fed7d7; color: #9b2c2c; }

.btn-view-source {
    display: inline-block;
    padding: .15rem .45rem;
    border: 1px solid var(--primary-light);
    border-radius: 6px;
    background: transparent;
    color: var(--primary);
    font-size: .65rem;
    font-weight: 600;
    cursor: pointer;
    margin-left: .4rem;
    vertical-align: middle;
    transition: background .15s;
}
.btn-view-source:hover { background: var(--primary-lighter); }

/* ── Debug Panel ──────────────────────────────────────── */

.debug-panel {
    margin-top: .5rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: #fafbfc;
    overflow: hidden;
    font-size: .75rem;
}
.debug-title {
    padding: .4rem .7rem;
    font-weight: 600;
    cursor: pointer;
    user-select: none;
    display: flex;
    align-items: center;
    gap: .3rem;
    color: var(--text-secondary);
    background: var(--bg);
    border-bottom: 1px solid var(--border);
}
.debug-body { display: none; padding: .6rem .7rem; }
.debug-panel.open .debug-body { display: block; }
.debug-panel p { margin: .15rem 0; }
.debug-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: .4rem;
    font-size: .68rem;
}
.debug-table th, .debug-table td {
    padding: .25rem .35rem;
    border: 1px solid var(--border);
    text-align: left;
}
.debug-table th { background: var(--bg); font-weight: 600; }
.debug-preview {
    max-width: 200px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: var(--text-muted);
}

/* Debug toggle button */
.btn-debug-toggle {
    padding: .25rem .4rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: transparent;
    cursor: pointer;
    font-size: .85rem;
    line-height: 1;
    transition: all .15s;
}
.btn-debug-toggle.active {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

/* ── Streaming ────────────────────────────────────────── */

.streaming-text { min-height: 1em; }
.streaming-text::after {
    content: '▊';
    animation: blink .8s step-start infinite;
    color: var(--primary);
}
@keyframes blink { 50% { opacity: 0; } }

.stream-status {
    display: block;
    font-size: .82rem;
    color: var(--text-muted);
    font-style: italic;
    padding: .3rem 0;
    animation: fadeInUp .3s ease;
}
@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(6px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ── Sidebar Suggested Questions ──────────────────────── */

.sidebar-sq {
    padding: .25rem 0;
    border-bottom: 1px solid rgba(255,255,255,.06);
}

.sidebar-sq-title {
    font-size: .68rem;
    font-weight: 700;
    color: rgba(255,255,255,.4);
    text-transform: uppercase;
    letter-spacing: .8px;
    padding: .6rem .75rem .35rem;
}

.sidebar-sq-cat {
    margin-bottom: .1rem;
}

.sidebar-sq-cat-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: .4rem .75rem;
    cursor: pointer;
    border-radius: 0;
    color: rgba(255,255,255,.75);
    font-size: .8rem;
    font-weight: 600;
    transition: background .15s, color .15s;
    user-select: none;
}

.sidebar-sq-cat-header:hover {
    background: rgba(255,255,255,.07);
    color: rgba(255,255,255,.95);
}

.sidebar-sq-cat-header .sq-arrow {
    font-size: .55rem;
    transition: transform .2s ease;
    color: rgba(255,255,255,.35);
}

.sidebar-sq-cat.open .sidebar-sq-cat-header {
    color: white;
}

.sidebar-sq-cat.open .sq-arrow {
    transform: rotate(90deg);
    color: rgba(255,255,255,.6);
}

.sidebar-sq-cat-body {
    display: none;
    padding: .15rem .5rem .4rem .75rem;
}

.sidebar-sq-cat.open .sidebar-sq-cat-body {
    display: block;
    animation: sqFadeIn .2s ease;
}

@keyframes sqFadeIn {
    from { opacity: 0; transform: translateY(-4px); }
    to { opacity: 1; transform: translateY(0); }
}

.sidebar-sq-q {
    display: block;
    width: 100%;
    text-align: left;
    padding: .35rem .6rem;
    margin-bottom: .2rem;
    background: rgba(255,255,255,.05);
    border: 1px solid rgba(255,255,255,.07);
    border-radius: 8px;
    color: rgba(255,255,255,.7);
    font-size: .76rem;
    font-family: inherit;
    line-height: 1.4;
    cursor: pointer;
    transition: all .15s;
}

.sidebar-sq-q:hover {
    background: rgba(255,255,255,.12);
    border-color: rgba(255,255,255,.2);
    color: white;
    transform: translateX(2px);
}

.sidebar-sq-q:active {
    transform: scale(.97);
}

/* ── Suggested Questions (legacy center, removed) ────── */

.sq-section {
    padding: .5rem 0;
    animation: fadeIn .4s ease;
}

.sq-header {
    font-size: .82rem;
    font-weight: 700;
    color: var(--primary);
    text-transform: uppercase;
    letter-spacing: .6px;
    margin-bottom: .75rem;
    padding-left: .15rem;
}

.sq-categories {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.sq-category {
    display: flex;
    flex-direction: column;
    gap: .4rem;
}

.sq-cat-name {
    font-size: .72rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: .5px;
    padding-left: .1rem;
}

.sq-chips {
    display: flex;
    flex-wrap: wrap;
    gap: .4rem;
}

.sq-chip {
    display: inline-flex;
    align-items: center;
    padding: .5rem .85rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 20px;
    color: var(--text);
    font-size: .82rem;
    font-family: inherit;
    line-height: 1.35;
    cursor: pointer;
    transition: all .15s;
    text-align: left;
    white-space: normal;
    word-break: break-word;
}

.sq-chip:hover {
    border-color: var(--primary);
    background: var(--primary-lighter);
    color: var(--primary);
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(26, 54, 93, .1);
}

.sq-chip:active {
    transform: scale(.97);
}

.sq-chip-hidden {
    display: none !important;
}

.sq-expand-btn {
    background: none;
    border: none;
    color: var(--primary);
    font-size: .76rem;
    font-weight: 600;
    cursor: pointer;
    padding: .25rem .1rem;
    margin-top: .15rem;
    font-family: inherit;
    transition: color .15s;
}
.sq-expand-btn:hover {
    color: var(--primary-light);
    text-decoration: underline;
}

/* Mobile: horizontal scroll per category */
@media (max-width: 768px) {
    .sq-chips {
        flex-wrap: nowrap;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
        padding-bottom: 4px;
    }
    .sq-chips::-webkit-scrollbar { display: none; }
    .sq-chip {
        flex-shrink: 0;
        max-width: 280px;
        font-size: .78rem;
        padding: .45rem .7rem;
    }
    .sq-header { font-size: .76rem; margin-bottom: .5rem; }
    .sq-cat-name { font-size: .66rem; }
    .sq-categories { gap: .75rem; }
    .sq-expand-btn { font-size: .72rem; }
}

@media (max-width: 480px) {
    .sq-chip {
        max-width: 240px;
        font-size: .74rem;
        padding: .4rem .6rem;
        border-radius: 16px;
    }
    .sq-header { font-size: .7rem; }
    .sq-cat-name { font-size: .62rem; }
    .sq-expand-btn { font-size: .68rem; }
}

/* ── Toast types ──────────────────────────────────────── */

.toast-info { border-left: 3px solid var(--primary); }
