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

:root {
    --bg: #0f1117;
    --surface: #1a1d27;
    --surface2: #242736;
    --border: #2e3144;
    --text: #e4e4e7;
    --text-dim: #9395a5;
    --accent: #6366f1;
    --accent-hover: #818cf8;
    --user-bg: #1e3a5f;
    --ai-bg: #1a1d27;
    --success: #22c55e;
    --warning: #f59e0b;
    --danger: #ef4444;
    --sidebar-w: 220px;
}

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

/* ─── Layout ─── */
.app {
    display: flex;
    height: 100vh;
}

/* ─── Sidebar ─── */
.sidebar {
    width: var(--sidebar-w);
    background: var(--surface);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
}

.sidebar-header {
    padding: 20px 16px 16px;
    border-bottom: 1px solid var(--border);
}

.sidebar-header .logo {
    display: flex;
    align-items: center;
    gap: 8px;
}

.sidebar-header .logo-icon {
    font-size: 24px;
    color: var(--accent);
}

.sidebar-header h1 {
    font-size: 18px;
    font-weight: 700;
}

.sidebar-nav {
    flex: 1;
    padding: 12px 8px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.nav-btn {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border: none;
    background: none;
    color: var(--text-dim);
    font-size: 14px;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.15s;
    text-align: left;
    width: 100%;
}

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

.nav-btn.active {
    background: var(--accent);
    color: white;
}

.nav-btn .nav-icon {
    font-size: 18px;
    width: 24px;
    text-align: center;
    flex-shrink: 0;
}

.sidebar-footer {
    padding: 12px;
    border-top: 1px solid var(--border);
}

.usage-info {
    font-size: 12px;
    color: var(--text-dim);
    text-align: center;
    padding: 6px;
}

/* ─── Main Content ─── */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

/* ─── Top Bar ─── */
.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 20px;
    border-bottom: 1px solid var(--border);
    gap: 12px;
}

.topbar-title {
    font-size: 15px;
    font-weight: 600;
    color: var(--text);
}

.topbar-right {
    display: flex;
    align-items: center;
    gap: 10px;
}

.hamburger {
    display: none;
    background: none;
    border: none;
    color: var(--text);
    font-size: 22px;
    cursor: pointer;
    padding: 4px;
}

.auth-btn {
    padding: 6px 14px;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text);
    font-size: 13px;
    cursor: pointer;
    transition: all 0.15s;
}

.auth-btn:hover {
    border-color: var(--accent);
    color: var(--accent);
}

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

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

.user-badge {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: var(--text-dim);
}

.user-badge .tier {
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
}

.tier-free { background: var(--surface2); color: var(--text-dim); }
.tier-pro { background: #422006; color: var(--warning); }

/* ─── Tool Panels ─── */
.tool-panel {
    display: none;
    flex: 1;
    flex-direction: column;
    overflow: hidden;
}

.tool-panel.active {
    display: flex;
}

/* ─── Chat Panel ─── */
.chat-area {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    scroll-behavior: smooth;
}

.welcome {
    text-align: center;
    padding: 60px 20px 20px;
}

.welcome h2 {
    font-size: 24px;
    margin-bottom: 8px;
}

.welcome p {
    color: var(--text-dim);
    font-size: 15px;
    max-width: 500px;
    margin: 0 auto 28px;
    line-height: 1.5;
}

.examples {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    justify-content: center;
    max-width: 600px;
    margin: 0 auto;
}

.example-btn {
    background: var(--surface2);
    border: 1px solid var(--border);
    color: var(--text-dim);
    padding: 10px 16px;
    border-radius: 10px;
    cursor: pointer;
    font-size: 13px;
    transition: all 0.2s;
    text-align: left;
    max-width: 280px;
}

.example-btn:hover {
    border-color: var(--accent);
    color: var(--text);
    background: var(--surface);
}

/* ─── Messages ─── */
.message {
    margin-bottom: 20px;
    animation: fadeIn 0.3s ease;
}

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

.message-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 6px;
    font-size: 13px;
    font-weight: 600;
}

.message-header .icon {
    width: 26px;
    height: 26px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
}

.message.user .icon { background: var(--user-bg); }
.message.ai .icon { background: var(--accent); color: white; }

.message-body {
    padding: 14px 18px;
    border-radius: 12px;
    font-size: 14px;
    line-height: 1.7;
    word-wrap: break-word;
}

.message-body p { margin-bottom: 8px; }
.message-body p:last-child { margin-bottom: 0; }
.message-body h1, .message-body h2, .message-body h3 {
    margin: 16px 0 8px;
    color: var(--accent-hover);
}
.message-body h1 { font-size: 18px; }
.message-body h2 { font-size: 16px; }
.message-body h3 { font-size: 15px; }
.message-body ul, .message-body ol {
    margin: 8px 0;
    padding-left: 24px;
}
.message-body li { margin-bottom: 4px; }
.message-body strong { color: var(--accent-hover); }

.message.user .message-body {
    background: var(--user-bg);
    border: 1px solid #2a4a6f;
}

.message.ai .message-body {
    background: var(--surface);
    border: 1px solid var(--border);
}

.sources {
    margin-top: 10px;
    padding: 10px 14px;
    background: var(--surface2);
    border-radius: 8px;
    border: 1px solid var(--border);
}

.sources-title {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-dim);
    margin-bottom: 6px;
}

.sources ul { list-style: none; padding: 0; }
.sources li { font-size: 12px; color: var(--text-dim); padding: 2px 0; }
.sources li::before { content: "\00a7 "; color: var(--accent); font-weight: 700; }

.meta {
    font-size: 11px;
    color: var(--text-dim);
    margin-top: 8px;
    opacity: 0.7;
}

/* ─── Loading ─── */
.loading {
    display: flex;
    gap: 6px;
    padding: 14px 18px;
}

.loading .dot {
    width: 8px;
    height: 8px;
    background: var(--accent);
    border-radius: 50%;
    animation: bounce 1.4s infinite ease-in-out;
}

.loading .dot:nth-child(1) { animation-delay: -0.32s; }
.loading .dot:nth-child(2) { animation-delay: -0.16s; }

@keyframes bounce {
    0%, 80%, 100% { transform: scale(0.6); opacity: 0.4; }
    40% { transform: scale(1); opacity: 1; }
}

/* ─── Input Options (Self-Critique Toggle) ─── */
.input-options {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 8px;
}

.toggle-label {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    user-select: none;
    font-size: 13px;
    color: var(--text-dim);
}

.toggle-label input[type="checkbox"] {
    display: none;
}

.toggle-slider {
    width: 34px;
    height: 18px;
    background: var(--surface2);
    border: 1px solid var(--border);
    border-radius: 9px;
    position: relative;
    transition: all 0.2s;
    flex-shrink: 0;
}

.toggle-slider::after {
    content: "";
    position: absolute;
    top: 2px;
    left: 2px;
    width: 12px;
    height: 12px;
    background: var(--text-dim);
    border-radius: 50%;
    transition: all 0.2s;
}

.toggle-label input:checked + .toggle-slider {
    background: var(--accent);
    border-color: var(--accent);
}

.toggle-label input:checked + .toggle-slider::after {
    left: 18px;
    background: white;
}

.toggle-text {
    transition: color 0.2s;
}

.toggle-label input:checked ~ .toggle-text {
    color: var(--accent-hover);
}

/* ─── Input Footer ─── */
.input-footer {
    padding: 12px 20px 16px;
    border-top: 1px solid var(--border);
}

.input-group {
    display: flex;
    gap: 10px;
    align-items: flex-end;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 8px 8px 8px 16px;
    transition: border-color 0.2s;
}

.input-group:focus-within {
    border-color: var(--accent);
}

.tool-textarea {
    flex: 1;
    background: none;
    border: none;
    color: var(--text);
    font-size: 14px;
    resize: none;
    outline: none;
    font-family: inherit;
    line-height: 1.5;
    max-height: 120px;
}

.tool-textarea::placeholder { color: var(--text-dim); }

.send-btn {
    background: var(--accent);
    border: none;
    border-radius: 10px;
    padding: 8px 12px;
    cursor: pointer;
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
    flex-shrink: 0;
}

.send-btn:hover { background: var(--accent-hover); }
.send-btn:disabled { opacity: 0.4; cursor: not-allowed; }

.disclaimer {
    text-align: center;
    font-size: 11px;
    color: var(--text-dim);
    margin-top: 8px;
    opacity: 0.6;
}

/* ─── Tool Input Panels ─── */
.tool-form {
    padding: 24px;
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.tool-form h2 {
    font-size: 18px;
    margin-bottom: 4px;
}

.tool-form .tool-desc {
    font-size: 13px;
    color: var(--text-dim);
    margin-bottom: 8px;
    line-height: 1.5;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.form-group label {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-dim);
}

.form-group textarea,
.form-group select {
    background: var(--surface);
    border: 1px solid var(--border);
    color: var(--text);
    border-radius: 10px;
    padding: 12px 14px;
    font-size: 14px;
    font-family: inherit;
    resize: vertical;
    outline: none;
    transition: border-color 0.2s;
}

.form-group textarea:focus,
.form-group select:focus {
    border-color: var(--accent);
}

.form-group select {
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%239395a5' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 36px;
}

.form-group select option {
    background: var(--surface);
    color: var(--text);
}

.submit-btn {
    align-self: flex-start;
    background: var(--accent);
    border: none;
    border-radius: 10px;
    padding: 10px 24px;
    color: white;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
}

.submit-btn:hover { background: var(--accent-hover); }
.submit-btn:disabled { opacity: 0.4; cursor: not-allowed; }

/* ─── Tool Output ─── */
.tool-output {
    margin-top: 16px;
    padding: 16px 18px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    font-size: 14px;
    line-height: 1.7;
    word-wrap: break-word;
    display: none;
}

.tool-output.visible { display: block; }

.tool-output h1, .tool-output h2, .tool-output h3 {
    margin: 16px 0 8px;
    color: var(--accent-hover);
}
.tool-output h1 { font-size: 18px; }
.tool-output h2 { font-size: 16px; }
.tool-output h3 { font-size: 15px; }
.tool-output p { margin-bottom: 8px; }
.tool-output p:last-child { margin-bottom: 0; }
.tool-output ul, .tool-output ol { margin: 8px 0; padding-left: 24px; }
.tool-output li { margin-bottom: 4px; }
.tool-output strong { color: var(--accent-hover); }

/* ─── Risk Score Bar ─── */
.risk-score-bar {
    margin-top: 12px;
    padding: 12px 16px;
    background: var(--surface2);
    border-radius: 10px;
    border: 1px solid var(--border);
    display: none;
}

.risk-score-bar.visible { display: block; }

.risk-score-label {
    font-size: 13px;
    color: var(--text-dim);
    margin-bottom: 8px;
    display: flex;
    justify-content: space-between;
}

.risk-score-track {
    height: 8px;
    background: var(--surface);
    border-radius: 4px;
    overflow: hidden;
}

.risk-score-fill {
    height: 100%;
    border-radius: 4px;
    transition: width 0.6s ease;
}

.risk-low { background: var(--success); }
.risk-mid { background: var(--warning); }
.risk-high { background: var(--danger); }

/* ─── Auth Modal ─── */
.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    z-index: 100;
    align-items: center;
    justify-content: center;
}

.modal-overlay.open { display: flex; }

.modal {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 32px;
    width: 100%;
    max-width: 400px;
    margin: 20px;
}

.modal h2 {
    font-size: 20px;
    margin-bottom: 8px;
    text-align: center;
}

.modal-tabs {
    display: flex;
    gap: 4px;
    margin-bottom: 20px;
    background: var(--surface2);
    border-radius: 8px;
    padding: 4px;
}

.modal-tab {
    flex: 1;
    padding: 8px;
    border: none;
    background: none;
    color: var(--text-dim);
    font-size: 14px;
    font-weight: 600;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.15s;
}

.modal-tab.active {
    background: var(--accent);
    color: white;
}

.modal-form {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.modal-form.hidden { display: none; }

.modal-form input {
    background: var(--surface2);
    border: 1px solid var(--border);
    color: var(--text);
    border-radius: 10px;
    padding: 10px 14px;
    font-size: 14px;
    outline: none;
    font-family: inherit;
    transition: border-color 0.2s;
}

.modal-form input:focus { border-color: var(--accent); }

.modal-submit {
    background: var(--accent);
    border: none;
    border-radius: 10px;
    padding: 10px;
    color: white;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
}

.modal-submit:hover { background: var(--accent-hover); }
.modal-submit:disabled { opacity: 0.4; cursor: not-allowed; }

.modal-error {
    color: var(--danger);
    font-size: 13px;
    text-align: center;
    min-height: 18px;
}

.modal-close {
    position: absolute;
    top: 16px;
    right: 16px;
    background: none;
    border: none;
    color: var(--text-dim);
    font-size: 20px;
    cursor: pointer;
}

/* ─── Scrollbar ─── */
.chat-area::-webkit-scrollbar,
.tool-form::-webkit-scrollbar {
    width: 6px;
}

.chat-area::-webkit-scrollbar-track,
.tool-form::-webkit-scrollbar-track {
    background: transparent;
}

.chat-area::-webkit-scrollbar-thumb,
.tool-form::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 3px;
}

.chat-area::-webkit-scrollbar-thumb:hover,
.tool-form::-webkit-scrollbar-thumb:hover {
    background: var(--text-dim);
}

/* ─── Responsive ─── */
@media (max-width: 768px) {
    .sidebar {
        position: fixed;
        left: -260px;
        top: 0;
        bottom: 0;
        z-index: 50;
        transition: left 0.25s ease;
        width: 260px;
    }

    .sidebar.open { left: 0; }

    .sidebar-backdrop {
        display: none;
        position: fixed;
        inset: 0;
        background: rgba(0, 0, 0, 0.4);
        z-index: 49;
    }

    .sidebar-backdrop.open { display: block; }

    .hamburger { display: block; }

    .chat-area { padding: 16px; }
    .input-footer { padding: 10px 16px 14px; }
    .tool-form { padding: 16px; }
    .welcome { padding-top: 40px; }
    .examples { flex-direction: column; align-items: center; }
    .example-btn { max-width: 100%; }
}

/* ─── Sub-tabs (Contract module) ─── */
.sub-tabs {
    display: flex;
    gap: 4px;
    margin-bottom: 20px;
    background: var(--bg);
    border-radius: 8px;
    padding: 4px;
}

.sub-tab {
    flex: 1;
    padding: 8px 12px;
    border: none;
    border-radius: 6px;
    background: transparent;
    color: var(--text-dim);
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.2s;
}

.sub-tab:hover {
    color: var(--text);
    background: var(--surface2);
}

.sub-tab.active {
    background: var(--accent);
    color: white;
}

.sub-panel {
    display: none;
}

.sub-panel.active {
    display: block;
}

/* Form row (side-by-side inputs) */
.form-row {
    display: flex;
    gap: 12px;
}

.form-group.half {
    flex: 1;
}

/* File upload area */
.file-upload-area {
    border: 2px dashed var(--border);
    border-radius: 8px;
    padding: 24px;
    text-align: center;
    transition: border-color 0.2s, background 0.2s;
    cursor: pointer;
}

.file-upload-area:hover,
.file-upload-area.dragover {
    border-color: var(--accent);
    background: rgba(99, 102, 241, 0.05);
}

.file-upload-icon {
    font-size: 2rem;
    display: block;
    margin-bottom: 8px;
}

.file-upload-area p {
    color: var(--text-dim);
    font-size: 0.9rem;
    margin-bottom: 10px;
}

.file-upload-btn {
    padding: 6px 16px;
    border: 1px solid var(--accent);
    border-radius: 6px;
    background: transparent;
    color: var(--accent);
    cursor: pointer;
    font-size: 0.85rem;
    transition: all 0.2s;
}

.file-upload-btn:hover {
    background: var(--accent);
    color: white;
}

.file-upload-info {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 0;
}

.file-upload-info span {
    color: var(--text);
    font-size: 0.9rem;
}

.file-remove-btn {
    background: none;
    border: none;
    color: var(--danger);
    font-size: 1.2rem;
    cursor: pointer;
    padding: 0 4px;
}

.file-upload-content.hidden,
.file-upload-info.hidden {
    display: none;
}

@media (max-width: 768px) {
    .form-row {
        flex-direction: column;
        gap: 0;
    }
}

/* ─── Search Module (Faz 10) ─── */
.search-bar {
    display: flex;
    gap: 10px;
    margin-bottom: 12px;
}

.search-text-input {
    flex: 1;
    background: var(--surface);
    border: 1px solid var(--border);
    color: var(--text);
    border-radius: 10px;
    padding: 10px 14px;
    font-size: 14px;
    font-family: inherit;
    outline: none;
    transition: border-color 0.2s;
}

.search-text-input:focus {
    border-color: var(--accent);
}

.search-filters {
    display: flex;
    gap: 12px;
    margin-bottom: 16px;
    flex-wrap: wrap;
}

.search-filters .filter-group {
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 140px;
}

.search-filters .filter-group label {
    font-size: 0.75rem;
    color: var(--text-dim);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.search-filters .filter-group select {
    background: var(--surface);
    border: 1px solid var(--border);
    color: var(--text);
    border-radius: 6px;
    padding: 6px 10px;
    font-size: 0.85rem;
    outline: none;
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='10' viewBox='0 0 24 24' fill='none' stroke='%239395a5' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 8px center;
    padding-right: 28px;
}

.search-stats {
    font-size: 0.85rem;
    color: var(--text-dim);
    margin-bottom: 12px;
}

.search-results {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.search-section-title {
    font-size: 0.9rem;
    color: var(--accent-hover);
    margin: 16px 0 8px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.search-card {
    padding: 14px 16px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.2s;
}

.search-card:hover {
    border-color: var(--accent);
    background: var(--surface2);
}

.search-card-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 8px;
    flex-wrap: wrap;
}

.search-card-badge {
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    flex-shrink: 0;
}

.search-card-badge.mevzuat {
    background: rgba(99, 102, 241, 0.2);
    color: var(--accent-hover);
}

.search-card-badge.ictihat {
    background: rgba(34, 197, 94, 0.15);
    color: var(--success);
}

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

.search-card-date {
    font-size: 0.75rem;
    color: var(--text-dim);
}

.search-score-bar {
    width: 60px;
    height: 4px;
    background: var(--surface2);
    border-radius: 2px;
    overflow: hidden;
    margin-left: auto;
    flex-shrink: 0;
}

.search-score-fill {
    height: 100%;
    background: var(--accent);
    border-radius: 2px;
    transition: width 0.3s;
}

.search-card-snippet {
    font-size: 0.85rem;
    color: var(--text-dim);
    line-height: 1.5;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.no-results {
    text-align: center;
    color: var(--text-dim);
    padding: 40px 20px;
    font-size: 0.95rem;
}

/* Search Detail Modal */
.search-detail-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: center;
}

.search-detail-overlay.hidden {
    display: none;
}

.search-detail-modal {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 16px;
    width: 90%;
    max-width: 800px;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
}

.search-detail-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
}

.search-detail-header h3 {
    font-size: 1rem;
    color: var(--accent-hover);
}

.search-detail-close {
    background: none;
    border: none;
    color: var(--text-dim);
    font-size: 1.5rem;
    cursor: pointer;
    padding: 0 4px;
}

.search-detail-close:hover {
    color: var(--text);
}

.search-detail-body {
    padding: 20px;
    overflow-y: auto;
    flex: 1;
}

.search-detail-content {
    white-space: pre-wrap;
    word-wrap: break-word;
    font-family: inherit;
    font-size: 0.9rem;
    line-height: 1.7;
    color: var(--text);
}

@media (max-width: 768px) {
    .search-filters {
        flex-direction: column;
    }
    .search-detail-modal {
        width: 95%;
        max-height: 90vh;
    }
}

/* ─── Research Module ─── */
.research-phases {
    margin-top: 16px;
}

.research-phase {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 0;
    color: var(--text-dim);
    font-size: 0.9rem;
    animation: fadeIn 0.3s ease;
}

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

.phase-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--accent);
    animation: pulse 1.5s infinite;
    flex-shrink: 0;
}

@keyframes pulse {
    0%, 100% { opacity: 0.4; }
    50% { opacity: 1; }
}

.research-plan-summary {
    margin-top: 10px;
}

.plan-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 6px;
}

.plan-tag {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 12px;
    font-size: 0.8rem;
}

.plan-tag.branch {
    background: rgba(99, 102, 241, 0.2);
    color: var(--accent-hover);
    border: 1px solid rgba(99, 102, 241, 0.3);
}

.plan-tag.keyword {
    background: rgba(34, 197, 94, 0.15);
    color: var(--success);
    border: 1px solid rgba(34, 197, 94, 0.25);
}

.research-sources, .research-source-group, .research-verified-sources {
    margin-top: 12px;
}

.source-group-title {
    font-weight: 600;
    font-size: 0.85rem;
    color: var(--text-dim);
    margin-bottom: 6px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.research-source-group ul,
.research-verified-sources ul {
    list-style: none;
    padding: 0;
}

.research-source-group li,
.research-verified-sources li {
    padding: 4px 0;
    font-size: 0.85rem;
    color: var(--text-dim);
    border-bottom: 1px solid var(--border);
}

.research-verified-sources li.verified {
    color: var(--success);
}

.research-verified-sources li.unverified {
    color: var(--danger);
    opacity: 0.7;
}

.source-type {
    font-size: 0.75rem;
    text-transform: uppercase;
    opacity: 0.7;
}

#research-output.visible {
    margin-top: 20px;
    padding-top: 20px;
    border-top: 1px solid var(--border);
}

/* ─── Petition Editor (Faz 9) ─── */
.petition-editor-wrapper {
    margin-top: 16px;
}

.petition-editor-wrapper.hidden {
    display: none;
}

.editor-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 12px;
    background: var(--surface2);
    border: 1px solid var(--border);
    border-bottom: none;
    border-radius: 10px 10px 0 0;
}

.editor-label {
    font-size: 0.8rem;
    color: var(--text-dim);
}

.editor-actions {
    display: flex;
    gap: 6px;
}

.editor-btn {
    padding: 4px 12px;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--surface);
    color: var(--text-dim);
    font-size: 0.8rem;
    cursor: pointer;
    transition: all 0.15s;
}

.editor-btn:hover {
    border-color: var(--accent);
    color: var(--accent);
}

.petition-editor {
    min-height: 200px;
    max-height: 500px;
    overflow-y: auto;
    padding: 16px 18px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 0 0 10px 10px;
    font-size: 14px;
    line-height: 1.7;
    color: var(--text);
    outline: none;
    word-wrap: break-word;
}

.petition-editor:focus {
    border-color: var(--accent);
}

.petition-editor h1, .petition-editor h2, .petition-editor h3 {
    color: var(--accent-hover);
    margin: 12px 0 6px;
}

.petition-editor p { margin-bottom: 8px; }
.petition-editor ul, .petition-editor ol { margin: 8px 0; padding-left: 24px; }
.petition-editor strong { color: var(--accent-hover); }

/* ─── Petition Analyze ─── */
.analyze-or-upload {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.or-divider {
    color: var(--text-dim);
    font-size: 0.85rem;
}

.file-upload-inline {
    display: flex;
    align-items: center;
    gap: 8px;
}

.submit-btn.secondary {
    background: var(--surface2);
    border: 1px solid var(--border);
    color: var(--text);
}

.submit-btn.secondary:hover {
    border-color: var(--accent);
    color: var(--accent);
}

.file-name-display {
    font-size: 0.8rem;
    color: var(--text-dim);
}

/* ─── Petition Templates ─── */
.templates-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 12px;
}

.templates-grid.hidden {
    display: none;
}

.template-card {
    padding: 16px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.2s;
}

.template-card:hover {
    border-color: var(--accent);
    background: var(--surface2);
}

.template-card-type {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--accent);
    margin-bottom: 6px;
    font-weight: 600;
}

.template-card-title {
    font-size: 0.95rem;
    font-weight: 600;
    margin-bottom: 4px;
}

.template-card-desc {
    font-size: 0.8rem;
    color: var(--text-dim);
    line-height: 1.4;
}

.template-form.hidden {
    display: none;
}

.template-form h3 {
    font-size: 1.1rem;
    margin-bottom: 4px;
}

.template-form .form-group input {
    background: var(--surface);
    border: 1px solid var(--border);
    color: var(--text);
    border-radius: 10px;
    padding: 10px 14px;
    font-size: 14px;
    font-family: inherit;
    outline: none;
    width: 100%;
    transition: border-color 0.2s;
}

.template-form .form-group input:focus {
    border-color: var(--accent);
}

.template-form-actions {
    display: flex;
    gap: 10px;
    margin-top: 8px;
}

@media (max-width: 768px) {
    .templates-grid {
        grid-template-columns: 1fr;
    }
    .analyze-or-upload {
        flex-direction: column;
        align-items: flex-start;
    }
}

/* ─── Output Actions (Copy/Export) ─── */
.output-actions {
    display: flex;
    gap: 8px;
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px solid var(--border);
}
.output-actions.hidden { display: none; }
.action-btn {
    padding: 5px 12px;
    font-size: 0.78rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--card-bg);
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.2s;
}
.action-btn:hover {
    background: var(--primary);
    color: #fff;
    border-color: var(--primary);
}
.message-actions {
    display: flex;
    gap: 6px;
    margin-top: 8px;
    opacity: 0;
    transition: opacity 0.2s;
}
.message:hover .message-actions,
.message .message-actions:focus-within {
    opacity: 1;
}
