:root {
    --bg-main: #ffffff;
    --bg-sidebar: #f5f5f7;
    --bg-panel: #ffffff;
    --border-color: rgba(0, 0, 0, 0.08);

    --accent-primary: #9a3412;
    --accent-primary-hover: #c2410c;
    --accent-secondary: #ffedd5;

    --text-main: #1d1d1f;
    --text-muted: #86868b;
    --text-inverse: #ffffff;

    --danger: #ff3b30;
    --danger-hover: #ff453a;

    --sidebar-width: 320px;
    --sidebar-transition: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

body.dark-mode {
    --bg-main: #000000;
    --bg-sidebar: #1c1c1e;
    --bg-panel: #2c2c2e;
    --border-color: rgba(255, 255, 255, 0.1);

    --text-main: #f5f5f7;
    --text-muted: #86868b;
    --text-inverse: #000000;

    --accent-secondary: #451a03;
}

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

::selection {
    background: var(--accent-secondary);
    color: var(--accent-primary);
}

.redline-ins {
    background-color: rgba(59, 130, 246, 0.15);
    color: #60a5fa;
    text-decoration: underline;
    text-decoration-thickness: 2px;
    padding: 0 4px;
    margin: 0 1px;
    border-radius: 4px;
    font-weight: 500;
}

.redline-del {
    background-color: rgba(239, 68, 68, 0.15);
    color: #f87171;
    text-decoration: line-through;
    text-decoration-thickness: 2px;
    padding: 0 4px;
    margin: 0 1px;
    border-radius: 4px;
    opacity: 0.8;
}

.empty-redline {
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.info-alert {
    background: rgba(154, 52, 18, 0.1);
    border: 1px solid rgba(154, 52, 18, 0.2);
    padding: 12px 16px;
    border-radius: 8px;
    color: var(--text-muted);
    font-size: 14px;
    font-style: italic;
    display: flex;
    align-items: center;
    gap: 8px;
}

.info-alert::before {
    content: "ℹ️";
    font-style: normal;
}

body {
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    background-color: var(--bg-main);
    color: var(--text-main);
    height: 100vh;
    overflow: hidden;
    line-height: 1.6;
}

h1,
h2,
h3 {
    font-family: 'Outfit', sans-serif;
    font-weight: 600;
}

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

/* Sidebar Styling */
.sidebar {
    width: var(--sidebar-width);
    background-color: var(--bg-sidebar);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    padding: 24px;
    z-index: 1000;
    transition: transform var(--sidebar-transition);
}

.sidebar-header {
    margin-bottom: 32px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.logo {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 24px;
}

.logo-icon {
    width: 28px;
    height: 28px;
    background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary));
    border-radius: 6px;
    position: relative;
}

.logo h1 {
    font-size: 20px;
    letter-spacing: -0.5px;
    color: var(--text-main);
}

/* New Doc Button */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 16px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    border: none;
    outline: none;
    white-space: nowrap;
}

.btn-primary {
    background-color: var(--accent-primary);
    color: var(--text-inverse);
}

.btn-primary:hover {
    background-color: var(--accent-primary-hover);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(154, 52, 18, 0.3);
}

.btn-ghost {
    background: transparent;
    color: var(--text-main);
    border: 1px solid var(--border-color);
}

.btn-ghost:hover {
    background: var(--bg-panel);
}

.btn-ghost.danger:hover {
    border-color: var(--danger);
    color: var(--danger);
    background: rgba(255, 77, 77, 0.05);
}

.full-width {
    width: 100%;
}

/* Mobile & Tablet Responsive Styles */
@media (max-width: 1024px) {
    .view-body {
        grid-template-columns: 1fr;
        gap: 32px;
    }

    .tools-panel {
        order: -1;
    }

    .view {
        padding: 32px 24px;
    }
}

@media (max-width: 768px) {
    .app-container {
        flex-direction: column;
    }

    .sidebar {
        position: fixed;
        left: 0;
        top: 0;
        bottom: 0;
        transform: translateX(-100%);
        box-shadow: 24px 0 48px rgba(0, 0, 0, 0.2);
    }

    .sidebar.active {
        transform: translateX(0);
    }

    .mobile-nav {
        display: flex !important;
        align-items: center;
        justify-content: space-between;
        padding: 12px 20px;
        background: var(--bg-sidebar);
        border-bottom: 1px solid var(--border-color);
        position: sticky;
        top: 0;
        z-index: 500;
    }

    .view-header {
        flex-direction: column;
        gap: 20px;
    }

    .header-actions {
        width: 100%;
        justify-content: flex-start;
        display: flex;
        gap: 8px;
    }

    .title-section h2 {
        font-size: 24px;
    }

    .summary-section {
        padding: 16px;
    }

    .content-panel {
        padding: 20px;
        max-height: none;
        overflow-y: visible;
    }

    .document-text {
        font-size: 15px;
    }

    .modal-content {
        width: 100%;
        height: 100%;
        max-height: 100%;
        border-radius: 0;
    }
}

.mobile-nav {
    display: none;
}

.menu-toggle {
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.menu-icon {
    width: 24px;
    height: 24px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%231d1d1f'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M4 6h16M4 12h16m-7 6h7'%3E%3C/path%3E%3C/svg%3E");
    background-size: contain;
    background-repeat: no-repeat;
}

.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(2px);
    z-index: 900;
}

.sidebar-overlay.active {
    display: block;
}

/* AI Suggestion Styles */
.ai-result {
    margin-top: 16px;
    padding: 16px;
    background: rgba(154, 52, 18, 0.08);
    border: 1px solid rgba(154, 52, 18, 0.25);
    border-radius: 10px;
    animation: findSlideDown 0.2s ease-out;
}

.ai-result.hidden {
    display: none;
}

.ai-result-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
}

.ai-suggested-text {
    background: rgba(154, 52, 18, 0.1);
    border-left: 3px solid var(--accent-primary);
    padding: 12px;
    border-radius: 6px;
    font-family: 'Inter', monospace;
    font-size: 0.9rem;
    line-height: 1.6;
    margin-bottom: 8px;
    white-space: pre-wrap;
    color: var(--text);
}

/* ── AI mark ──────────────────────────────────────────────────
   Replaces the ✨ emoji: same "this is AI" signal, but drawn in the
   accent colour at text weight so it sits in the type rather than
   shouting over it. Emoji render full-colour and differ per platform;
   this scales with the label and inherits the tab's active state. */

.ai-mark {
    width: 12px;
    height: 12px;
    flex-shrink: 0;
    margin-right: 6px;
    vertical-align: -1px;
    fill: currentColor;
    opacity: 0.55;
    transition: opacity 0.2s ease;
}

.tab-btn.active .ai-mark {
    opacity: 1;
}

.ai-mark-spark {
    opacity: 0.6;
}

.tab-btn {
    display: inline-flex;
    align-items: center;
}

/* ── Scope toggle (document vs library) ───────────────────── */

.scope-toggle {
    display: flex;
    gap: 2px;
    padding: 2px;
    margin-bottom: 12px;
    background: var(--bg-sidebar);
    border: 1px solid var(--border-color);
    border-radius: 8px;
}

.scope-btn {
    flex: 1;
    padding: 6px 10px;
    border: none;
    border-radius: 6px;
    background: transparent;
    color: var(--text-muted);
    font-size: 0.8rem;
    font-family: inherit;
    cursor: pointer;
    transition: background 0.15s ease, color 0.15s ease;
}

.scope-btn:hover {
    color: var(--text-main);
}

.scope-btn.active {
    background: var(--bg-panel);
    color: var(--accent-primary);
    font-weight: 600;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.06);
}

/* ── Cited sources ────────────────────────────────────────── */

.sources {
    margin-top: 12px;
}

.sources.hidden {
    display: none;
}

.sources-header {
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--text-muted);
    margin-bottom: 8px;
}

.source {
    border: 1px solid var(--border-color);
    border-radius: 8px;
    background: var(--bg-panel);
    margin-bottom: 8px;
    overflow: hidden;
}

/* Highlighted when the answer's citation link is followed. */
.source.source-focused {
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 2px var(--accent-secondary);
}

.source-summary {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 10px;
    cursor: pointer;
    font-size: 0.85rem;
    list-style: none;
}

.source-summary::-webkit-details-marker {
    display: none;
}

.source-label {
    font-weight: 600;
    color: var(--accent-primary);
    white-space: nowrap;
}

.source-title {
    color: var(--text-main);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.source-score {
    margin-left: auto;
    font-size: 0.75rem;
    color: var(--text-muted);
    white-space: nowrap;
}

.source-excerpt {
    padding: 10px;
    border-top: 1px solid var(--border-color);
    font-size: 0.82rem;
    line-height: 1.6;
    white-space: pre-wrap;
    color: var(--text-muted);
}

.source-actions {
    padding: 0 10px 10px;
}

.source-open {
    border: 1px solid var(--border-color);
    border-radius: 6px;
    background: transparent;
    color: var(--accent-primary);
    font-family: inherit;
    font-size: 0.75rem;
    font-weight: 600;
    padding: 4px 10px;
    cursor: pointer;
    transition: background 0.15s ease, border-color 0.15s ease;
}

.source-open:hover {
    background: var(--accent-secondary);
    border-color: var(--accent-primary);
}

/* The cited clause, highlighted in the document body itself. */
.cited-passage {
    background: var(--accent-secondary);
    border-left: 3px solid var(--accent-primary);
    padding-left: 6px;
    border-radius: 2px;
}

/* Clickable DOCUMENT n reference inside the answer text. */
.citation-link {
    color: var(--accent-primary);
    font-weight: 600;
    cursor: pointer;
    text-decoration: underline dotted;
    text-underline-offset: 2px;
}

.source-badge {
    font-size: 0.7rem;
    font-weight: 600;
    letter-spacing: 0.03em;
    text-transform: uppercase;
    padding: 2px 8px;
    border-radius: 999px;
    background: var(--accent-secondary);
    color: var(--accent-primary);
}

.source-badge.hidden {
    display: none;
}

/* The model cited evidence it was never shown — a grounding failure. */
.citation-warning {
    margin-top: 10px;
    padding: 8px 10px;
    border-radius: 6px;
    border: 1px solid var(--danger);
    background: rgba(255, 59, 48, 0.08);
    color: var(--danger);
    font-size: 0.8rem;
    line-height: 1.5;
}

.citation-warning.hidden {
    display: none;
}

.ai-explanation {
    font-size: 0.85rem;
    color: var(--text-muted);
    font-style: italic;
    margin-bottom: 12px;
}

#ai-tone {
    width: 100%;
    background: var(--bg-sidebar);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 10px;
    color: var(--text-main);
    font-size: 0.9rem;
    outline: none;
    cursor: pointer;
}

#ai-tone:focus {
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 2px rgba(154, 52, 18, 0.2);
}

#ai-suggest-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

/* Search Box */
.search-container {
    position: relative;
    margin-bottom: 32px;
}

.search-container input {
    width: 100%;
    background: var(--bg-panel);
    border: 1px solid var(--border-color);
    padding: 12px 16px 12px 40px;
    border-radius: 10px;
    color: var(--text-main);
    font-size: 14px;
    transition: all 0.2s ease;
}

.search-container input:focus {
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 2px rgba(29, 185, 84, 0.1);
}

.search-icon {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    width: 16px;
    height: 16px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%23888888'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0z'%3E%3C/path%3E%3C/svg%3E");
    background-size: contain;
    background-repeat: no-repeat;
}

.doc-list-nav {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    margin-bottom: 24px;
}

.doc-list-nav h3 {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-muted);
    margin-bottom: 12px;
}

#doc-list {
    list-style: none;
    overflow-y: auto;
    flex: 1;
}

.doc-item {
    padding: 12px;
    border-radius: 8px;
    cursor: pointer;
    margin-bottom: 4px;
    transition: all 0.2s ease;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.doc-item:hover {
    background: var(--bg-panel);
}

.doc-item.active {
    background: rgba(154, 52, 18, 0.1);
    border-left: 3px solid var(--accent-primary);
    border-radius: 4px 8px 8px 4px;
}

.doc-item .doc-item-title {
    font-size: 14px;
    font-weight: 500;
}

.doc-item .doc-item-meta {
    font-size: 11px;
    color: var(--text-muted);
}

.doc-item-snippets {
    margin-top: 8px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.search-snippet {
    font-size: 12px;
    color: var(--text-main);
    background: rgba(154, 52, 18, 0.08);
    padding: 4px 8px;
    border-radius: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    border-left: 2px solid var(--accent-primary);
}

.sidebar-footer {
    padding-top: 24px;
    border-top: 1px solid var(--border-color);
    margin-top: auto;
}

.sidebar-footer p {
    font-size: 13px;
    color: var(--text-muted);
    margin-bottom: 4px;
}

.sidebar-footer a {
    color: var(--accent-primary);
    text-decoration: none;
    font-weight: 500;
    transition: color 0.2s;
}

.sidebar-footer a:hover {
    color: var(--accent-primary-hover);
}

.footer-meta {
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: rgba(var(--text-muted), 0.5);
    opacity: 0.5;
}

/* Main Content Area */
.main-content {
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    position: relative;
    background-image: radial-gradient(circle at 50% 50%, rgba(29, 185, 84, 0.05) 0%, transparent 80%);
}

.view {
    display: none;
    flex-direction: column;
    min-height: 100%;
    padding: 48px;
    max-width: 1200px;
    margin: 0 auto;
    width: 100%;
    animation: fadeIn 0.4s ease-out;
}

.view.active {
    display: flex;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Welcome View */
.welcome-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    text-align: center;
}

.welcome-icon {
    width: 64px;
    height: 64px;
    background: var(--bg-panel);
    border-radius: 16px;
    margin-bottom: 24px;
    position: relative;
}

.welcome-icon::after {
    content: "";
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 32px;
    height: 32px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%231db954'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M9 12h6m-6 4h6m2 5H7a2 2 0 01-2-2V5a2 2 0 012-2h5.586a1 1 0 01.707.293l5.414 5.414a1 1 0 01.293.707V19a2 2 0 01-2 2z'%3E%3C/path%3E%3C/svg%3E");
    background-size: contain;
    background-repeat: no-repeat;
}

.welcome-content p {
    color: var(--text-muted);
    max-width: 300px;
}

/* Doc View Header */
.view-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 32px;
    padding-bottom: 24px;
    border-bottom: 1px solid var(--border-color);
}

.title-section h2 {
    font-size: 32px;
    margin-bottom: 8px;
}

.meta {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 13px;
    color: var(--text-muted);
}

.badge {
    background: var(--bg-panel);
    padding: 2px 8px;
    border-radius: 4px;
    border: 1px solid var(--border-color);
    color: var(--accent-primary);
    font-weight: 600;
}

/* Toggle Switch */
.toggle-wrapper {
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--bg-panel);
    padding: 6px 12px;
    border-radius: 20px;
    border: 1px solid var(--border-color);
    cursor: pointer;
    user-select: none;
    transition: all 0.2s ease;
}

.toggle-wrapper:hover {
    border-color: var(--accent-primary);
}

.toggle-label {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
}

.switch {
    position: relative;
    display: inline-block;
    width: 32px;
    height: 18px;
}

.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: var(--text-muted);
    transition: .4s;
    border-radius: 34px;
}

.slider:before {
    position: absolute;
    content: "";
    height: 12px;
    width: 12px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: .4s;
    border-radius: 50%;
}

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

input:checked+.slider:before {
    transform: translateX(14px);
}

.summary-section {
    margin-bottom: 24px;
    background: linear-gradient(to right, rgba(154, 52, 18, 0.05), transparent);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 20px;
    position: relative;
    /* Removed overflow: hidden to prevent cutting off text */
    animation: fadeIn 0.4s ease-out;
}

.summary-section::before {
    content: "";
    position: absolute;
    left: 0;
    top: 0;
    width: 4px;
    height: 100%;
    background: var(--accent-primary);
}

.summary-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.summary-label {
    font-size: 14px;
    font-weight: 600;
    color: var(--accent-primary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    display: flex;
    align-items: center;
    gap: 8px;
}

.summary-label::before {
    content: "✨";
}

.summary-text {
    font-size: 15px;
    color: var(--text-main);
    line-height: 1.6;
    opacity: 0.85;
    white-space: pre-wrap;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

.summary-text:empty::after {
    content: "No summary available.";
    color: var(--text-muted);
    font-style: italic;
}

/* View Body */
.view-body {
    display: grid;
    grid-template-columns: 1fr 340px;
    gap: 48px;
    flex: 1;
}

.content-panel {
    background: var(--bg-panel);
    border-radius: 16px;
    padding: 32px;
    border: 1px solid var(--border-color);
    overflow-y: auto;
    max-height: calc(100vh - 250px);
}

.document-text {
    white-space: pre-wrap;
    font-family: 'Inter', monospace;
    font-size: 16px;
    color: var(--text-main);
    line-height: 1.8;
}

/* Tools Panel */
.tools-panel {
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.tools-panel h3 {
    font-size: 18px;
}

.tool-tabs {
    display: flex;
    gap: 4px;
    background: var(--bg-panel);
    padding: 4px;
    border-radius: 8px;
}

.tab-btn {
    flex: 1;
    border: none;
    background: transparent;
    color: var(--text-muted);
    padding: 8px;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.tab-btn.active {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-main);
}

.tab-content {
    display: none;
    flex-direction: column;
    gap: 20px;
    background: var(--bg-panel);
    padding: 24px;
    border-radius: 12px;
    border: 1px solid var(--border-color);
}

.tab-content.active {
    display: flex;
}

/* Form Styling */
.form-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.tool-hint {
    font-size: 11px;
    color: var(--text-muted);
    background: rgba(255, 255, 255, 0.03);
    padding: 8px;
    border-radius: 6px;
    border-left: 2px solid var(--accent-primary);
}

label {
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    color: var(--text-muted);
    letter-spacing: 0.5px;
}

input,
textarea {
    background: var(--bg-panel);
    border: 1px solid var(--border-color);
    padding: 12px;
    border-radius: 8px;
    color: var(--text-main);
    font-family: inherit;
    font-size: 14px;
    outline: none;
    transition: all 0.2s ease;
}

input:focus,
textarea:focus {
    border-color: var(--accent-primary);
}

textarea {
    resize: vertical;
    min-height: 80px;
}

/* Toast Notifications */
.toast-container {
    position: fixed;
    bottom: 24px;
    right: 24px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    z-index: 1000;
}

.toast {
    background: var(--bg-panel);
    color: var(--text-main);
    padding: 16px 24px;
    border-radius: 12px;
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.12);
    border-left: 4px solid var(--accent-primary);
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 300px;
    animation: slideIn 0.3s ease-out;
}

@keyframes slideIn {
    from {
        transform: translateX(100%);
        opacity: 0;
    }

    to {
        transform: translateX(0);
        opacity: 1;
    }
}

.toast.error {
    border-left-color: var(--danger);
}

/* Create View */
.create-form {
    background: var(--bg-panel);
    padding: 40px;
    border-radius: 16px;
    border: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.form-footer {
    display: flex;
    justify-content: flex-end;
    gap: 16px;
    margin-top: 24px;
}

.save-actions {
    display: flex;
    gap: 12px;
}

/* History Modal */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(4px);
    z-index: 2000;
    align-items: center;
    justify-content: center;
}

.modal.active {
    display: flex;
    animation: fadeIn 0.2s ease-out;
}

.modal-content {
    background: var(--bg-sidebar);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    width: 90%;
    max-width: 600px;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 24px 48px rgba(0, 0, 0, 0.5);
}

.modal-header {
    padding: 24px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h2 {
    font-size: 20px;
}

.close-btn {
    font-size: 24px;
    line-height: 1;
    padding: 4px 8px;
    border: none;
    border-radius: 4px;
}

.modal-body {
    padding: 24px;
    overflow-y: auto;
}

.history-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.history-item {
    background: var(--bg-panel);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 16px;
}

.history-item.empty {
    text-align: center;
    color: var(--text-muted);
    padding: 32px;
    background: transparent;
    border-style: dashed;
}

.history-meta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
}

.history-diff {
    font-family: 'Inter', monospace;
    font-size: 14px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.diff-removed {
    color: #ff6666;
    background: rgba(255, 77, 77, 0.1);
    padding: 8px;
    border-radius: 6px;
    text-decoration: line-through;
}

.diff-added {
    color: #1ed760;
    background: rgba(29, 185, 84, 0.1);
    padding: 8px;
    border-radius: 6px;
}

/* Find in Document Bar */
.find-bar {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.5rem 1.5rem;
    background: rgba(255, 255, 255, 0.03);
    border-bottom: 1px solid var(--border-color);
    animation: findSlideDown 0.2s ease-out;
}

.find-bar.hidden {
    display: none;
}

.find-input-wrapper {
    position: relative;
    flex: 1;
}

#find-input {
    width: 100%;
    background: var(--bg-sidebar);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    padding: 0.4rem 0.75rem 0.4rem 2.2rem;
    color: var(--text-main);
    font-size: 0.9rem;
    outline: none;
}

#find-input:focus {
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 2px rgba(154, 52, 18, 0.2);
}

.find-count {
    font-size: 0.85rem;
    color: var(--text-muted);
    min-width: 80px;
    text-align: right;
    font-variant-numeric: tabular-nums;
}

.btn-icon {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 1.1rem;
    cursor: pointer;
    padding: 0.25rem;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.btn-icon:hover {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-main);
}

@keyframes findSlideDown {
    from {
        transform: translateY(-5px);
        opacity: 0;
    }

    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.find-match {
    background-color: rgba(255, 226, 0, 0.4);
    border-bottom: 2px solid rgba(255, 226, 0, 1);
    color: inherit;
    border-radius: 2px;
    padding: 1px 0;
}

.find-match.current {
    background-color: #fbbf24;
    color: #000;
    border-bottom-color: #f59e0b;
}

.button-group {
    display: flex;
    gap: 12px;
}

.button-group>.btn {
    flex: 1;
}

.full-width {
    width: 100%;
}