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

:root {
    --bg-primary: #0f1117;
    --bg-secondary: #1a1b26;
    --bg-tertiary: #24253a;
    --bg-hover: #2a2b3d;
    --text-primary: #e1e2e8;
    --text-secondary: #9ca0b0;
    --text-muted: #6b6f82;
    --accent: #5b8af5;
    --accent-hover: #7ba3f7;
    --accent-glow: rgba(91, 138, 245, 0.15);
    --accent-subtle: rgba(91, 138, 245, 0.08);
    --border: #2d2e3f;
    --border-light: #363849;
    --success: #4ade80;
    --error: #f87171;
    --error-bg: rgba(248, 113, 113, 0.1);
    --user-bubble: #2a3a5c;
    --assistant-bubble: #1e2035;
    --shadow: 0 4px 24px rgba(0, 0, 0, 0.3);
    --radius: 12px;
    --radius-sm: 8px;
    --transition: 0.2s ease;
    --top-bar-h: 76px;
    --bottom-bar-h: 76px;
}

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

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    overflow: hidden;
    height: 100vh;
    height: 100dvh;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
}

/* === Login page === */
.login-body {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: var(--bg-primary);
    overflow: auto;
    position: relative;
}

#login-canvas {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 0;
    pointer-events: none;
}

.login-container {
    width: 100%;
    max-width: 420px;
    padding: 1.5rem;
    animation: slideUp 0.6s ease;
    position: relative;
    z-index: 1;
}

.login-card {
    background: rgba(26, 27, 38, 0.85);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(91, 138, 245, 0.15);
    border-radius: 20px;
    padding: 2.5rem;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4), 0 0 80px rgba(91, 138, 245, 0.05);
}

.login-header {
    text-align: center;
    margin-bottom: 2rem;
}

.logo-icon {
    width: 60px;
    height: 60px;
    margin: 0 auto 1.25rem;
    color: var(--accent);
    background: var(--accent-subtle);
    border-radius: 16px;
    padding: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: pulse-glow 3s ease-in-out infinite;
}

.logo-icon svg {
    width: 100%;
    height: 100%;
}

.login-header h1 {
    font-size: 1.6rem;
    font-weight: 700;
    letter-spacing: -0.03em;
    margin-bottom: 0.3rem;
}

.subtitle {
    color: var(--text-secondary);
    font-size: 0.85rem;
    font-weight: 400;
    letter-spacing: 0.01em;
}

.error-message {
    background: var(--error-bg);
    border: 1px solid rgba(248, 113, 113, 0.2);
    color: var(--error);
    padding: 0.75rem 1rem;
    border-radius: var(--radius-sm);
    font-size: 0.875rem;
    margin-bottom: 1.25rem;
    animation: shake 0.4s ease;
}

.login-form {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

.form-group label {
    display: block;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 0.4rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

.form-group input {
    width: 100%;
    padding: 0.8rem 1rem;
    background: rgba(36, 37, 58, 0.8);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: max(0.95rem, 16px);
    font-family: inherit;
    transition: border-color var(--transition), box-shadow var(--transition);
    outline: none;
}

.form-group input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-glow);
}

.form-group input::placeholder {
    color: var(--text-muted);
}

.btn-login {
    width: 100%;
    padding: 0.85rem;
    background: var(--accent);
    color: #fff;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 0.95rem;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: background var(--transition), transform var(--transition), box-shadow var(--transition);
    margin-top: 0.25rem;
}

.btn-login:hover {
    background: var(--accent-hover);
    transform: translateY(-1px);
    box-shadow: 0 4px 16px rgba(91, 138, 245, 0.3);
}

.btn-login:active {
    transform: translateY(0);
}

.login-footer {
    text-align: center;
    margin-top: 1.5rem;
    padding-top: 1.25rem;
    border-top: 1px solid var(--border);
}

.login-footer p {
    color: var(--text-muted);
    font-size: 0.8rem;
}

/* === Chat layout === */
.chat-body {
    overflow: hidden;
    position: relative;
}

#chat-canvas {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 0;
    pointer-events: none;
    opacity: 0.4;
}

.app-container {
    display: flex;
    height: 100vh;
    height: 100dvh;
    width: 100%;
    overflow: hidden;
    position: relative;
    z-index: 1;
}

/* --- Sidebar --- */
.sidebar {
    width: 260px;
    min-width: 260px;
    background: rgba(26, 27, 38, 0.92);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    animation: slideRight 0.4s ease;
}

.sidebar-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0 1.25rem;
    border-bottom: 1px solid var(--border);
    height: var(--top-bar-h);
    flex-shrink: 0;
}

.sidebar-logo {
    width: 36px;
    height: 36px;
    color: var(--accent);
    flex-shrink: 0;
}

.sidebar-logo svg {
    width: 100%;
    height: 100%;
}

.sidebar-header h2 {
    font-size: 1.05rem;
    font-weight: 700;
    letter-spacing: -0.01em;
}

.sidebar-nav {
    padding: 0.75rem;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.nav-btn {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    width: 100%;
    padding: 0.7rem 0.9rem;
    background: transparent;
    border: none;
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-size: 0.9rem;
    font-family: inherit;
    cursor: pointer;
    transition: all var(--transition);
}

.nav-btn svg {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
}

.nav-btn:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.nav-btn.active {
    background: var(--accent-subtle);
    color: var(--accent);
    font-weight: 500;
}

/* --- Chat history in sidebar --- */
.sidebar-section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 1rem 0.4rem;
}

.sidebar-section-label {
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

.history-actions {
    display: flex;
    align-items: center;
    gap: 0.35rem;
}

.clear-history-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 0.2rem;
    border-radius: 4px;
    display: flex;
    align-items: center;
    transition: all var(--transition);
}

.clear-history-btn svg {
    width: 14px;
    height: 14px;
}

.clear-history-btn:hover {
    color: var(--error);
    background: rgba(248, 113, 113, 0.1);
}

.info-tip-wrapper {
    position: relative;
}

.info-tip-btn {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    border: 1px solid var(--text-muted);
    background: none;
    color: var(--text-muted);
    font-size: 0.6rem;
    font-style: italic;
    font-family: Georgia, serif;
    font-weight: 700;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition);
    padding: 0;
    line-height: 1;
}

.info-tip-btn:hover {
    color: var(--text-secondary);
    border-color: var(--text-secondary);
}

.info-tip-tooltip {
    display: none;
    position: absolute;
    left: calc(100% + 8px);
    top: 50%;
    transform: translateY(-50%);
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 0.5rem 0.7rem;
    font-size: 0.72rem;
    color: var(--text-secondary);
    white-space: nowrap;
    z-index: 10;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

/* Hover on desktop */
.info-tip-wrapper:hover .info-tip-tooltip {
    display: block;
    animation: fadeIn 0.15s ease;
}

/* Tap toggle on mobile */
.info-tip-wrapper.show .info-tip-tooltip {
    display: block;
    animation: fadeIn 0.15s ease;
}

.chat-history-list {
    flex: 1;
    overflow-y: auto;
    padding: 0 0.5rem;
}

.chat-history-list::-webkit-scrollbar {
    width: 4px;
}

.chat-history-list::-webkit-scrollbar-track {
    background: transparent;
}

.chat-history-list::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 2px;
}

.history-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    width: 100%;
    padding: 0.5rem 0.65rem;
    background: transparent;
    border: none;
    border-radius: 6px;
    color: var(--text-secondary);
    font-size: 0.82rem;
    font-family: inherit;
    cursor: pointer;
    transition: all var(--transition);
    text-align: left;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-bottom: 1px;
}

.history-item svg {
    width: 14px;
    height: 14px;
    flex-shrink: 0;
    opacity: 0.5;
}

.history-item:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.history-item.active {
    background: var(--accent-subtle);
    color: var(--accent);
}

.history-item-text {
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar-footer {
    padding: 0 1.25rem;
    border-top: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 0.75rem;
    justify-content: space-between;
    height: var(--bottom-bar-h);
    flex-shrink: 0;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--text-secondary);
    font-size: 0.85rem;
}

.user-info svg {
    width: 16px;
    height: 16px;
}

.logout-link {
    color: var(--text-muted);
    font-size: 0.8rem;
    text-decoration: none;
    transition: color var(--transition);
}

.logout-link:hover {
    color: var(--error);
}

/* --- Main panel --- */
.panel {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.panel.hidden {
    display: none;
}

.chat-header {
    padding: 0 2rem;
    border-bottom: 1px solid var(--border);
    background: rgba(26, 27, 38, 0.8);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    height: var(--top-bar-h);
    flex-shrink: 0;
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 0.75rem;
}

.chat-header h1 {
    font-size: 1.15rem;
    font-weight: 700;
    letter-spacing: -0.01em;
}

.header-tag {
    font-size: 0.7rem;
    font-weight: 500;
    color: var(--accent);
    background: var(--accent-subtle);
    padding: 0.15rem 0.5rem;
    border-radius: 4px;
    vertical-align: middle;
    margin-left: 0.25rem;
}

.chat-header p {
    color: var(--text-muted);
    font-size: 0.8rem;
    margin-top: 0.15rem;
}

/* --- Messages --- */
.messages {
    flex: 1;
    overflow-y: auto;
    padding: 1.5rem 2rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    scroll-behavior: smooth;
}

.messages::-webkit-scrollbar {
    width: 6px;
}

.messages::-webkit-scrollbar-track {
    background: transparent;
}

.messages::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 3px;
}

.message {
    display: flex;
    animation: fadeSlideUp 0.35s ease;
}

.message.user {
    justify-content: flex-end;
}

.message-content {
    max-width: 75%;
    padding: 1.1rem 1.4rem;
    border-radius: var(--radius);
    font-size: 0.95rem;
    line-height: 1.75;
    word-break: break-word;
}

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

.message.assistant .message-content {
    background: rgba(30, 32, 53, 0.8);
    border: 1px solid var(--border);
    border-bottom-left-radius: 4px;
}

.message-content p {
    margin-bottom: 0.65rem;
}

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

.message-content strong {
    color: var(--accent-hover);
    font-weight: 600;
}

.message-content code {
    font-family: 'JetBrains Mono', 'Fira Code', monospace;
    font-size: 0.85em;
    background: var(--bg-tertiary);
    padding: 0.15rem 0.4rem;
    border-radius: 4px;
}

.message-content h2, .message-content h3, .message-content h4, .message-content h5 {
    color: var(--accent-hover);
    font-weight: 600;
    letter-spacing: 0.01em;
}
.message-content h2 {
    font-size: 1.35em;
    margin: 1.3rem 0 0.5rem 0;
    padding-bottom: 0.3rem;
    border-bottom: 1px solid var(--border);
}
.message-content h3 {
    font-size: 1.15em;
    margin: 1.1rem 0 0.4rem 0;
}
.message-content h4, .message-content h5 {
    font-size: 1.0em;
    margin: 0.9rem 0 0.35rem 0;
    color: var(--text-primary);
}
.message-content h2:first-child, .message-content h3:first-child,
.message-content h4:first-child, .message-content h5:first-child {
    margin-top: 0;
}

.message-content ul, .message-content ol {
    margin: 0.5rem 0 0.75rem 1.5rem;
}
.message-content li {
    margin-bottom: 0.35rem;
}
.message-content li::marker {
    color: var(--accent);
}

/* Sources badge */
.sources-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    margin-top: 0.75rem;
    padding: 0.35rem 0.65rem;
    background: var(--accent-subtle);
    border: 1px solid rgba(91, 138, 245, 0.15);
    border-radius: 6px;
    font-size: 0.75rem;
    color: var(--accent);
    cursor: pointer;
    transition: all var(--transition);
}

.sources-badge:hover {
    background: var(--accent-glow);
}

.sources-badge svg {
    width: 12px;
    height: 12px;
}

.sources-list {
    display: none;
    margin-top: 0.5rem;
    padding: 0.5rem 0.75rem;
    background: var(--bg-tertiary);
    border-radius: var(--radius-sm);
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.sources-list.show {
    display: block;
    animation: fadeIn 0.2s ease;
}

.source-row {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.15rem 0;
}

.sources-list span,
.sources-list a {
    display: block;
    padding: 0.15rem 0;
    color: var(--accent);
    text-decoration: none;
}

.sources-list a:hover {
    text-decoration: underline;
    color: var(--accent-hover);
}

/* Source type tags in chat sources */
.source-tag {
    font-size: 0.65rem;
    font-weight: 600;
    padding: 0.1rem 0.4rem;
    border-radius: 3px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    flex-shrink: 0;
}

.source-tag-proposal {
    color: #fbbf24;
    background: rgba(251, 191, 36, 0.12);
}

.source-tag-extern {
    color: var(--success);
    background: rgba(74, 222, 128, 0.12);
}

.source-proposal {
    border-left: 2px solid #fbbf24;
    padding-left: 0.4rem;
}

.source-extern {
    border-left: 2px solid var(--success);
    padding-left: 0.4rem;
}

.extern-type {
    color: var(--text-muted);
    font-size: 0.8rem;
}

.card-desc {
    margin-top: 0.25rem;
}

.ext-link {
    display: inline-flex;
    align-items: center;
    flex-shrink: 0;
    color: var(--text-muted);
    transition: color var(--transition);
}

.ext-link:hover {
    color: var(--accent-hover);
    text-decoration: none !important;
}

.ext-link svg {
    width: 13px;
    height: 13px;
}

/* Typing indicator */
.typing-indicator {
    display: flex;
    gap: 4px;
    padding: 0.5rem 0;
}

.typing-indicator span {
    width: 7px;
    height: 7px;
    background: var(--text-muted);
    border-radius: 50%;
    animation: bounce 1.2s ease-in-out infinite;
}

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

/* --- Input area --- */
.input-area {
    padding: 0 2rem;
    border-top: 1px solid var(--border);
    background: rgba(26, 27, 38, 0.9);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    height: var(--bottom-bar-h);
    flex-shrink: 0;
    display: flex;
    align-items: center;
}

.input-area form {
    width: 100%;
}

.search-area {
    padding: 1.5rem 2rem;
}

.input-wrapper {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background: rgba(36, 37, 58, 0.8);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 0.5rem 0.5rem 0.5rem 1rem;
    transition: border-color var(--transition), box-shadow var(--transition);
}

.input-wrapper:focus-within {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-glow);
}

.input-wrapper textarea,
.input-wrapper input {
    flex: 1;
    background: transparent;
    border: none;
    color: var(--text-primary);
    font-size: max(0.92rem, 16px);
    font-family: inherit;
    line-height: 1.5;
    resize: none;
    outline: none;
    max-height: 120px;
    padding: 0.25rem 0;
}

.input-wrapper textarea::placeholder,
.input-wrapper input::placeholder {
    color: var(--text-muted);
}

.input-wrapper button {
    width: 36px;
    height: 36px;
    background: var(--accent);
    border: none;
    border-radius: var(--radius-sm);
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background var(--transition), transform var(--transition);
    flex-shrink: 0;
}

.input-wrapper button:hover {
    background: var(--accent-hover);
    transform: scale(1.05);
}

.input-wrapper button:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    transform: none;
}

.input-wrapper button svg {
    width: 16px;
    height: 16px;
}

/* --- Search results --- */
.search-results {
    padding: 0 2rem;
    overflow-y: auto;
    flex: 1;
}

.search-result {
    display: block;
    padding: 1rem 1.25rem;
    background: rgba(26, 27, 38, 0.8);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin-bottom: 0.75rem;
    animation: fadeSlideUp 0.3s ease;
    transition: border-color var(--transition);
    text-decoration: none;
    color: inherit;
    cursor: pointer;
}

.search-result:hover {
    border-color: var(--accent);
    background: var(--bg-hover);
}

.search-result-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.4rem;
}

.search-result-ref {
    color: var(--accent);
    font-weight: 600;
    font-size: 0.9rem;
}

.search-result-rubrik {
    color: var(--text-muted);
    font-size: 0.8rem;
}

.search-result-kap {
    color: var(--text-muted);
    font-size: 0.75rem;
    font-style: italic;
}

.search-result-preview {
    color: var(--text-secondary);
    font-size: 0.85rem;
    margin-top: 0.35rem;
    line-height: 1.5;
}

.search-result-wrapper {
    display: flex;
    align-items: stretch;
    gap: 0;
    margin-bottom: 0.75rem;
    animation: fadeSlideUp 0.3s ease;
}

.search-result-wrapper .search-result {
    flex: 1;
    margin-bottom: 0;
    border-top-right-radius: 0;
    border-bottom-right-radius: 0;
}

.search-ext-link {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 42px;
    background: rgba(26, 27, 38, 0.8);
    border: 1px solid var(--border);
    border-left: none;
    border-radius: 0 var(--radius) var(--radius) 0;
    color: var(--text-muted);
    transition: all var(--transition);
    text-decoration: none;
}

.search-ext-link:hover {
    color: var(--accent);
    background: var(--bg-hover);
}

.search-ext-link svg {
    width: 16px;
    height: 16px;
}

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

.search-section-label {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 1rem 0 0.5rem;
    margin-bottom: 0.25rem;
}

.search-section-label:first-child {
    padding-top: 0;
}

.proposal-result {
    border-left: 3px solid #fbbf24;
    cursor: default;
}

.proposal-result:hover {
    border-color: #fbbf24;
}

.proposal-tag {
    color: #fbbf24 !important;
    font-size: 0.72rem !important;
    background: rgba(251, 191, 36, 0.1);
    padding: 0.1rem 0.45rem;
    border-radius: 4px;
}

.search-result-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-top: 0.4rem;
}

.search-result-meta span {
    font-size: 0.75rem;
    color: var(--text-muted);
}

/* --- Paragraph reference links in chat --- */
.par-link {
    color: var(--accent);
    text-decoration: none;
    border-bottom: 1px dotted rgba(91, 138, 245, 0.4);
    transition: all var(--transition);
    white-space: nowrap;
}
.par-link:hover {
    color: #7ba4f7;
    border-bottom-color: #7ba4f7;
    border-bottom-style: solid;
}

/* --- Juno search chips --- */
.juno-chip {
    display: inline-block;
    margin: 0.2rem 0;
    padding: 0.3rem 0.7rem;
    background: rgba(74, 222, 128, 0.08);
    border: 1px solid rgba(74, 222, 128, 0.2);
    border-radius: 6px;
    font-size: 0.82rem;
    color: var(--success);
    cursor: pointer;
    transition: all var(--transition);
    user-select: all;
}

.juno-chip:hover {
    background: rgba(74, 222, 128, 0.15);
    border-color: rgba(74, 222, 128, 0.35);
    transform: translateY(-1px);
}

.juno-chip.copied {
    background: rgba(74, 222, 128, 0.2);
    color: #fff;
}

/* === Paragraf detail page === */
.paragraf-body {
    overflow: auto;
    background: var(--bg-primary);
    background-image:
        radial-gradient(ellipse at 30% 20%, rgba(91, 138, 245, 0.04) 0%, transparent 50%);
}

.paragraf-container {
    max-width: 800px;
    margin: 0 auto;
    padding: 2rem 1.5rem;
    animation: slideUp 0.4s ease;
}

.paragraf-nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

.back-link, .riksdagen-link {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    color: var(--accent);
    text-decoration: none;
    font-size: 0.85rem;
    transition: color var(--transition);
}

.back-link:hover, .riksdagen-link:hover {
    color: var(--accent-hover);
}

.back-link svg, .riksdagen-link svg {
    width: 16px;
    height: 16px;
}

.paragraf-article {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 16px;
    overflow: hidden;
}

.paragraf-header {
    padding: 2rem 2rem 1.5rem;
    border-bottom: 1px solid var(--border);
}

.paragraf-badge {
    display: inline-block;
    font-size: 0.72rem;
    font-weight: 500;
    color: var(--accent);
    background: var(--accent-subtle);
    padding: 0.2rem 0.6rem;
    border-radius: 4px;
    margin-bottom: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.paragraf-header h1 {
    font-size: 1.4rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    margin-bottom: 0.25rem;
}

.paragraf-rubrik {
    font-weight: 400;
    color: var(--text-secondary);
}

.paragraf-kap {
    color: var(--text-muted);
    font-size: 0.85rem;
    font-style: italic;
}

.paragraf-andrad {
    color: var(--text-muted);
    font-size: 0.8rem;
    margin-top: 0.5rem;
}

.paragraf-text {
    padding: 1.5rem 2rem;
    line-height: 1.8;
    font-size: 0.95rem;
}

.paragraf-text p {
    margin-bottom: 0.6rem;
}

.paragraf-section {
    padding: 1.25rem 2rem;
    border-top: 1px solid var(--border);
}

.paragraf-section h2 {
    font-size: 0.95rem;
    font-weight: 600;
    margin-bottom: 0.75rem;
}

.warning-tag {
    font-size: 0.7rem;
    font-weight: 500;
    color: #fbbf24;
    background: rgba(251, 191, 36, 0.1);
    padding: 0.15rem 0.5rem;
    border-radius: 4px;
    vertical-align: middle;
    margin-left: 0.25rem;
}

.info-card {
    padding: 0.75rem 1rem;
    background: var(--bg-tertiary);
    border-radius: var(--radius-sm);
    margin-bottom: 0.5rem;
    font-size: 0.85rem;
    line-height: 1.55;
}

.info-meta {
    display: block;
    color: var(--text-muted);
    font-size: 0.78rem;
    margin-top: 0.3rem;
}

.amendment-card { border-left: 3px solid var(--accent); }
.proposal-card { border-left: 3px solid #fbbf24; }
.extern-card { border-left: 3px solid var(--success); }

.ny-lydelse {
    margin-top: 0.5rem;
}

.ny-lydelse summary {
    color: var(--accent);
    cursor: pointer;
    font-size: 0.8rem;
}

.ny-lydelse-text {
    margin-top: 0.5rem;
    padding: 0.75rem;
    background: var(--bg-primary);
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    white-space: pre-wrap;
    line-height: 1.6;
}

/* === Animations === */
@keyframes slideUp {
    from { opacity: 0; transform: translateY(30px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes slideRight {
    from { opacity: 0; transform: translateX(-20px); }
    to { opacity: 1; transform: translateX(0); }
}

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

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-6px); }
    75% { transform: translateX(6px); }
}

@keyframes bounce {
    0%, 60%, 100% { transform: translateY(0); }
    30% { transform: translateY(-6px); }
}

@keyframes pulse-glow {
    0%, 100% { box-shadow: 0 0 0 0 var(--accent-glow); }
    50% { box-shadow: 0 0 20px 4px var(--accent-glow); }
}

.fade-in {
    animation: fadeSlideUp 0.5s ease;
}

/* === New conversation button === */
.new-chat-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    width: calc(100% - 1rem);
    margin: 0.5rem;
    padding: 0.6rem;
    background: var(--accent-subtle);
    border: 1px dashed rgba(91, 138, 245, 0.25);
    border-radius: var(--radius-sm);
    color: var(--accent);
    font-size: 0.82rem;
    font-family: inherit;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition);
}

.new-chat-btn:hover {
    background: var(--accent-glow);
    border-style: solid;
}

.new-chat-btn svg {
    width: 14px;
    height: 14px;
}

/* === Mobile menu button (hidden on desktop) === */
.chat-header-text {
    flex: 1;
    min-width: 0;
}

.header-search-btn {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    background: none;
    border: 1px solid var(--border);
    color: var(--text-muted);
    cursor: pointer;
    padding: 0.4rem 0.75rem;
    border-radius: 6px;
    transition: all var(--transition);
    flex-shrink: 0;
    font-family: inherit;
    font-size: 0.8rem;
    margin-left: auto;
}

.header-search-btn svg {
    width: 15px;
    height: 15px;
}

.header-search-btn:hover {
    color: var(--accent);
    border-color: var(--accent);
    background: var(--accent-subtle);
}

.mobile-menu-btn {
    display: none;
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 0.4rem;
    border-radius: 6px;
    transition: all var(--transition);
    flex-shrink: 0;
}

.mobile-menu-btn svg {
    width: 22px;
    height: 22px;
}

.mobile-menu-btn:hover {
    color: var(--text-primary);
    background: var(--bg-hover);
}

/* Sidebar overlay (hidden on desktop) */
.sidebar-overlay {
    display: none;
}

/* === Responsive === */
@media (max-width: 768px) {
    /* Sidebar: hidden by default, slides in as overlay */
    .sidebar {
        position: fixed;
        left: -280px;
        top: 0;
        bottom: 0;
        width: 280px;
        min-width: 280px;
        z-index: 100;
        transition: left 0.25s ease;
        box-shadow: none;
    }

    .sidebar.open {
        left: 0;
        box-shadow: 4px 0 24px rgba(0, 0, 0, 0.4);
    }

    .sidebar-overlay {
        display: block;
        position: fixed;
        inset: 0;
        background: rgba(0, 0, 0, 0.5);
        z-index: 99;
        opacity: 0;
        pointer-events: none;
        transition: opacity 0.25s ease;
    }

    .sidebar-overlay.open {
        opacity: 1;
        pointer-events: auto;
    }

    /* Show hamburger */
    .mobile-menu-btn {
        display: flex;
        align-items: center;
    }

    /* Hide label on search button, icon only */
    .header-search-btn span {
        display: none;
    }

    .header-search-btn {
        padding: 0.4rem;
        border: none;
    }

    /* Chat header: row layout with hamburger */
    .chat-header {
        flex-direction: row;
        align-items: center;
        gap: 0.75rem;
        padding: 0 1rem;
    }

    .chat-header h1 {
        font-size: 1rem;
    }

    .chat-header p {
        display: none;
    }

    /* Messages */
    .messages {
        padding: 0.75rem;
    }

    .message-content {
        max-width: 95%;
        font-size: 0.88rem;
        overflow-wrap: break-word;
    }

    .message-content h2 {
        font-size: 1.1em;
    }

    .message-content h3 {
        font-size: 1.0em;
    }

    .sources-list {
        max-width: 85vw;
    }

    .source-row {
        font-size: 0.8rem;
    }

    /* Input area */
    .input-area {
        padding: 0 0.75rem;
        padding-bottom: calc(env(safe-area-inset-bottom, 0px) + 0.75rem);
        height: auto;
        min-height: var(--bottom-bar-h);
    }

    .input-wrapper {
        padding: 0.4rem 0.4rem 0.4rem 0.75rem;
    }

    /* Search */
    .search-area {
        padding: 1rem;
    }

    .search-results {
        padding: 0 1rem;
    }

    .search-result-wrapper {
        max-width: 100%;
        overflow: hidden;
    }

    /* Tooltip: show below on mobile */
    .info-tip-tooltip {
        left: auto;
        right: 0;
        top: calc(100% + 6px);
        transform: none;
        white-space: normal;
        width: 220px;
    }

    /* Paragraf page */
    .paragraf-container {
        padding: 1rem;
    }

    .paragraf-header {
        padding: 1.25rem 1rem 1rem;
    }

    .paragraf-header h1 {
        font-size: 1.1rem;
    }

    .paragraf-text {
        padding: 1rem;
    }

    .paragraf-section {
        padding: 1rem;
    }

    .paragraf-nav {
        flex-direction: column;
        gap: 0.5rem;
        align-items: flex-start;
    }

    /* Login */
    .login-container {
        padding: 1rem;
    }

    .login-card {
        padding: 2rem 1.5rem;
    }
}
