:root {
    --primary: #2563eb;
    --primary-hover: #1d4ed8;
    --bg: #f8fafc;
    --card-bg: #ffffff;
    --text: #1e293b;
    --text-muted: #64748b;
    --border: #e2e8f0;
    --success: #10b981;
    --error: #ef4444;
    --sidebar-width: 240px;
}

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

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

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

.sidebar {
    width: var(--sidebar-width);
    min-width: var(--sidebar-width);
    background: var(--card-bg);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    height: 100vh;
    position: sticky;
    top: 0;
}

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

.sidebar-header h1 {
    font-size: 1.25rem;
    font-weight: 600;
}

.sidebar-header h1 a {
    color: var(--primary);
    text-decoration: none;
}

.sidebar-close {
    display: none;
    background: none;
    border: none;
    font-size: 1.5rem;
    color: var(--text-muted);
    cursor: pointer;
    padding: 0.25rem;
    line-height: 1;
}

/* Sidebar nav */
.sidebar-nav {
    display: flex;
    flex-direction: column;
    padding: 0.5rem;
    gap: 2px;
}

.nav-link {
    display: block;
    padding: 0.5rem 0.75rem;
    border-radius: 0.5rem;
    color: var(--text-muted);
    text-decoration: none;
    font-size: 0.9rem;
    transition: all 0.2s;
}

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

.nav-link.active {
    background: var(--bg);
    color: var(--primary);
    font-weight: 600;
}

.nav-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 1.25rem;
    height: 1.25rem;
    padding: 0 0.375rem;
    border-radius: 10px;
    background: var(--primary);
    color: white;
    font-size: 0.6875rem;
    font-weight: 600;
    line-height: 1;
    margin-left: 0.25rem;
    vertical-align: middle;
}

/* Sidebar overlay for mobile */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.3);
    z-index: 99;
}

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

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

/* Topbar */
.topbar {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1.5rem;
    border-bottom: 1px solid var(--border);
    background: var(--card-bg);
    position: sticky;
    top: 0;
    z-index: 10;
}

.sidebar-toggle {
    display: none;
    background: none;
    border: none;
    font-size: 1.25rem;
    cursor: pointer;
    padding: 0.25rem;
    color: var(--text);
}

.topbar-title {
    font-weight: 600;
    font-size: 1rem;
}

.topbar-prompt {
    margin-left: auto;
}

.topbar-prompt select {
    width: auto;
    min-width: 180px;
    padding: 0.35rem 0.5rem;
    font-size: 0.85rem;
    border: 1px solid var(--border);
    border-radius: 0.5rem;
    background: var(--bg);
}

/* Toast container */
.toast-container {
    position: fixed;
    bottom: 1rem;
    right: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    z-index: 1000;
}

/* Prompts page */
.prompts-page {
    max-width: 700px;
}

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

.prompts-header h2 {
    font-size: 1.25rem;
}

.sidebar-section {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.sidebar-section label {
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-muted);
}

.sidebar-section select {
    width: 100%;
    padding: 0.5rem;
    border: 1px solid var(--border);
    border-radius: 0.5rem;
    font-size: 0.9rem;
    background: var(--bg);
}

.btn-full {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.main-content {
    flex: 1;
    padding: 1.5rem;
    max-width: 900px;
    margin: 0 auto;
    width: 100%;
}

h1 {
    font-size: 1.75rem;
    font-weight: 600;
}

.icon-btn {
    background: none;
    border: none;
    cursor: pointer;
    padding: 0.5rem;
    border-radius: 0.5rem;
    color: var(--text-muted);
    transition: all 0.2s;
}

.icon-btn:hover {
    background: var(--border);
    color: var(--text);
}

/* Responsive: mobile sidebar */
@media (max-width: 768px) {
    .sidebar {
        position: fixed;
        left: -280px;
        top: 0;
        z-index: 100;
        width: 280px;
        min-width: 280px;
        transition: left 0.25s ease;
        box-shadow: none;
    }

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

    .sidebar-toggle {
        display: block;
    }

    .sidebar-close {
        display: block;
    }

    .main-content {
        padding: 1rem;
    }
}

.drop-zone {
    border: 2px dashed var(--border);
    border-radius: 1rem;
    padding: 3rem;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s;
    background: var(--card-bg);
}

.drop-zone:hover, .drop-zone.drag-over {
    border-color: var(--primary);
    background: #f0f7ff;
}

.drop-zone-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
    color: var(--text-muted);
}

.drop-zone-content svg {
    opacity: 0.5;
}

.loading {
    text-align: center;
    padding: 3rem;
}

.spinner {
    width: 48px;
    height: 48px;
    border: 3px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 1rem;
}

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

.btn {
    padding: 0.5rem 1rem;
    border: none;
    border-radius: 0.5rem;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.2s;
}

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

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

.btn-secondary {
    background: var(--border);
    color: var(--text);
}

.btn-secondary:hover {
    background: #cbd5e1;
}

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

.btn-debug {
    background: #f59e0b;
    color: white;
}

.btn-debug:hover {
    background: #d97706;
}

.hidden {
    display: none !important;
}

/* Modal */
.modal {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}

.modal-content {
    background: var(--card-bg);
    border-radius: 1rem;
    width: 100%;
    max-width: 600px;
    max-height: 90vh;
    overflow-y: auto;
}

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

.modal-header h2 {
    font-size: 1.25rem;
}

.modal-body {
    padding: 1.5rem;
}

.prompt-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.prompt-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 1rem;
    background: var(--bg);
    border-radius: 0.5rem;
}

.prompt-item-actions {
    display: flex;
    gap: 0.5rem;
}

.prompt-editor {
    margin-top: 1.5rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--border);
}

.prompt-editor input,
.prompt-editor textarea {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid var(--border);
    border-radius: 0.5rem;
    font-size: 1rem;
    margin-bottom: 1rem;
    font-family: inherit;
}

.prompt-editor textarea {
    resize: vertical;
    min-height: 150px;
}

.editor-actions {
    display: flex;
    gap: 0.5rem;
}

/* Toast notification */
.toast {
    position: fixed;
    bottom: 2rem;
    left: 50%;
    transform: translateX(-50%);
    background: var(--text);
    color: white;
    padding: 1rem 2rem;
    border-radius: 0.5rem;
    animation: fadeIn 0.3s;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateX(-50%) translateY(1rem); }
    to { opacity: 1; transform: translateX(-50%) translateY(0); }
}

/* Sidebar footer with toggle */
.sidebar-footer {
    margin-top: auto;
    padding-top: 1rem;
    border-top: 1px solid var(--border);
}

.toggle-label {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.85rem;
    color: var(--text-muted);
    cursor: pointer;
}

.toggle-switch {
    position: relative;
    width: 44px;
    height: 24px;
}

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

.toggle-slider {
    position: absolute;
    cursor: pointer;
    inset: 0;
    background: var(--border);
    border-radius: 24px;
    transition: 0.3s;
}

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

.toggle-switch input:checked + .toggle-slider {
    background: var(--primary);
}

.toggle-switch input:checked + .toggle-slider:before {
    transform: translateX(20px);
}

.debug-section {
    transition: opacity 0.2s;
}

/* Drop zone hint */
.drop-zone-hint {
    font-size: 0.85rem;
    opacity: 0.7;
}

/* Batch results */
.results {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    margin-top: 1.5rem;
}

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

.results-header h2 {
    font-size: 1.25rem;
}

.results-actions {
    display: flex;
    gap: 0.5rem;
}

.result-card {
    background: var(--card-bg);
    border-radius: 0.75rem;
    padding: 1.25rem;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.result-card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 0.75rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid var(--border);
}

.result-card-title {
    font-weight: 600;
    font-size: 0.95rem;
    color: var(--text);
}

.result-card-actions {
    display: flex;
    gap: 0.25rem;
}

.result-card-actions .btn {
    padding: 0.25rem 0.5rem;
    font-size: 0.8rem;
}

.result-card-content {
    white-space: pre-wrap;
    font-size: 0.9rem;
    line-height: 1.7;
    color: var(--text);
}

.result-card-icd {
    margin-top: 0.75rem;
    padding: 0.5rem 0.75rem;
    background: var(--bg);
    border-radius: 0.5rem;
    font-size: 0.85rem;
    color: var(--text-muted);
}

.result-card-meta {
    margin-top: 0.75rem;
    padding-top: 0.75rem;
    border-top: 1px solid var(--border);
    font-size: 0.8rem;
    color: var(--text-muted);
}

.result-card.error {
    border-left: 3px solid var(--error);
}

.result-card.error .result-card-content {
    color: var(--error);
}

/* Progress indicator */
.progress-info {
    text-align: center;
    margin-top: 0.5rem;
    font-size: 0.9rem;
    color: var(--text-muted);
}

/* Per-file progress cards */
.progress-container {
    margin-top: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    max-width: 400px;
    margin-left: auto;
    margin-right: auto;
}

.progress-card {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 1rem;
    background: var(--card-bg);
    border-radius: 0.5rem;
    border: 1px solid var(--border);
}

.progress-filename {
    font-size: 0.9rem;
    font-weight: 500;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 200px;
}

.progress-status {
    font-size: 0.8rem;
    padding: 0.25rem 0.5rem;
    border-radius: 0.25rem;
    font-weight: 500;
}

.progress-status.waiting {
    background: var(--bg);
    color: var(--text-muted);
}

.progress-status.processing {
    background: #fef3c7;
    color: #d97706;
    animation: pulse 1.5s ease-in-out infinite;
}

.progress-status.complete {
    background: #d1fae5;
    color: #059669;
}

.progress-status.error {
    background: #fee2e2;
    color: #dc2626;
}

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

/* Processing placeholder card */
.result-card.processing-card {
    background: var(--bg);
    border: 1px dashed var(--border);
}

.result-card.processing-card .result-card-header {
    border-bottom: none;
    margin-bottom: 0;
    padding-bottom: 0;
}

/* ============== Flash Messages ============== */
.flash-messages {
    position: fixed;
    top: 1rem;
    right: 1rem;
    z-index: 1000;
    max-width: 400px;
}

.flash {
    padding: 1rem;
    border-radius: 8px;
    margin-bottom: 0.5rem;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    animation: flashFadeIn 0.3s ease;
}

.flash-error { background: #fee; border-left: 4px solid #c00; }
.flash-success { background: #efe; border-left: 4px solid #0a0; }
.flash-warning { background: #ffe; border-left: 4px solid #a80; }
.flash-info { background: #eef; border-left: 4px solid #06c; }

@keyframes flashFadeIn {
    from { opacity: 0; transform: translateY(-0.5rem); }
    to { opacity: 1; transform: translateY(0); }
}

/* ============== Login / Auth Pages ============== */
.login-container {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem;
    background: var(--bg);
}

.login-card {
    background: var(--card-bg);
    padding: 3rem;
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.1);
    text-align: center;
    max-width: 400px;
    width: 100%;
}

.login-card h1 {
    margin-bottom: 0.5rem;
    color: var(--primary);
}

.description {
    margin-bottom: 2rem;
    color: var(--text-muted);
}

.form-group {
    margin-bottom: 1.5rem;
    text-align: left;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
}

.form-group input {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 1rem;
}

.login-form {
    text-align: left;
}

.login-form .btn {
    width: 100%;
    margin-top: 0.5rem;
}

/* TOTP setup */
.totp-setup {
    margin: 2rem 0;
    text-align: center;
}

.totp-secret {
    background: var(--bg);
    padding: 1rem;
    border-radius: 8px;
    font-family: monospace;
    margin-bottom: 1rem;
    word-break: break-all;
}

.totp-qr {
    margin: 1rem 0;
}

/* ============== Email Dashboard ============== */
.email-list {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

.email-card {
    background: var(--card-bg);
    border-radius: 10px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.04);
    border: 1px solid #d1d5db;
    overflow: hidden;
}

.email-card.marked-for-deletion {
    opacity: 0.5;
    background: #f9fafb;
    border-color: #d1d5db;
}

/* Card header: checkbox + subject + sender/date */
.email-card-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.875rem 1.25rem;
    background: linear-gradient(to bottom, #f1f5f9, #f8fafc);
    border-bottom: 1px solid #e2e8f0;
}

.email-checkbox {
    width: 1.125rem;
    height: 1.125rem;
    cursor: pointer;
    flex-shrink: 0;
}

.email-meta {
    flex: 1;
    min-width: 0;
}

.email-subject {
    font-weight: 600;
    font-size: 0.9375rem;
    color: #1e293b;
    display: block;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.email-from-date {
    font-size: 0.8125rem;
    color: #64748b;
    display: block;
    margin-top: 0.125rem;
}

.email-badges {
    display: flex;
    gap: 0.5rem;
    flex-shrink: 0;
}

.badge {
    background: #dbeafe;
    color: #1d4ed8;
    padding: 0.2rem 0.5rem;
    border-radius: 4px;
    font-size: 0.6875rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.025em;
}

.badge-success {
    background: #d1fae5;
    color: #059669;
}

.badge-muted {
    background: #f3f4f6;
    color: #6b7280;
}

/* Card body - vertical stack */
.email-card-body {
    display: flex;
    flex-direction: column;
}

.email-card-body .patient-info {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.5rem 1.25rem;
    background: #fffbeb;
    border-bottom: 1px solid #fde68a;
    font-size: 0.8125rem;
    margin: 0;
    border-radius: 0;
    border-left: none;
}

.patient-label { font-weight: 600; color: #92400e; }
.patient-name { font-weight: 600; color: #78350f; }
.patient-dob { color: #92400e; }
.patient-insurance { color: #a16207; font-family: monospace; font-size: 0.8125rem; }

.email-card-body .email-summary {
    padding: 0.625rem 1.25rem;
    font-size: 0.8125rem;
    color: #475569;
    line-height: 1.5;
    margin: 0;
}

/* Attachments section */
.email-card-body .attachments-list {
    padding: 0.5rem 1.25rem 0.75rem;
    display: flex;
    flex-direction: column;
    gap: 0.375rem;
    border-top: 1px solid #f1f5f9;
}

.attachments-label {
    font-size: 0.6875rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #94a3b8;
    margin-bottom: 0.125rem;
}

/* Actions footer */
.email-card-body .email-actions {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.625rem 1.25rem;
    border-top: 1px solid #f1f5f9;
}

.status-text {
    font-size: 0.875rem;
    color: var(--success);
}

.status-text.error {
    color: var(--error);
}

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

.empty-state .hint {
    font-size: 0.875rem;
    color: #9ca3af;
    margin-top: 0.5rem;
}

/* Section headers */
.section {
    margin-bottom: 2rem;
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.section-header h2 {
    margin: 0;
    font-size: 1.25rem;
    color: #374151;
}

.bulk-actions {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.select-all-label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.875rem;
    cursor: pointer;
}

/* Content rows - for email body and attachments */
.content-row {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.5rem 0.75rem;
    background: #f9fafb;
    border-radius: 6px;
    font-size: 0.8125rem;
    min-width: 0;
}

.email-body-row { border-left: 3px solid var(--primary); }
.attachment-row { border-left: 3px solid var(--success); }

.row-filename {
    font-weight: 500;
    color: var(--primary);
    text-decoration: none;
    white-space: nowrap;
    flex-shrink: 0;
    max-width: 200px;
    overflow: hidden;
    text-overflow: ellipsis;
}

.row-filename:hover { text-decoration: underline; }

.row-summary {
    flex: 1;
    color: #6b7280;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 0.8125rem;
    min-width: 0;
}

.file-checkbox {
    width: 1rem;
    height: 1rem;
    cursor: pointer;
}

.btn-copy {
    padding: 0.25rem 0.5rem;
    font-size: 0.75rem;
    background: var(--primary);
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    transition: background 0.2s;
    white-space: nowrap;
    flex-shrink: 0;
}

.btn-copy:hover { background: var(--primary-hover); }
.btn-copy.copied { background: var(--success); }

/* Status card */
.status-section { margin-bottom: 2rem; }

.status-card {
    background: var(--card-bg);
    padding: 1.5rem;
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.status-card.status-test {
    border-left: 4px solid #f59e0b;
    background: #fffbeb;
}

.status-card.status-production {
    border-left: 4px solid var(--success);
    background: #ecfdf5;
}

.status-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
}

.status-info { flex: 1; }

.status-mode {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
}

.status-label { font-weight: 500; color: #6b7280; }
.status-value { font-weight: 600; color: #111827; }

.status-description {
    font-size: 0.875rem;
    color: #6b7280;
    margin: 0;
}

.status-times {
    display: flex;
    gap: 2rem;
    margin-top: 0.5rem;
}

.status-time {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.875rem;
}

/* ============== Settings ============== */
.settings-section {
    background: var(--card-bg);
    padding: 1.5rem;
    border-radius: 8px;
    margin-bottom: 1.5rem;
}

.settings-section h2 {
    margin-bottom: 1rem;
    font-size: 1.25rem;
}

.device-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.device-card {
    padding: 1rem;
    background: var(--bg);
    border-radius: 6px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.device-name { font-weight: 500; }

.device-info {
    font-size: 0.875rem;
    color: var(--text-muted);
    display: flex;
    gap: 1rem;
    flex: 1;
}

.device-meta {
    font-size: 0.75rem;
    color: #999;
}

.status-ok { color: var(--success); }
.status-warn { color: #d97706; }

/* Button variants */
.btn-outline {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text);
}

.btn-small {
    padding: 0.375rem 0.75rem;
    font-size: 0.875rem;
}

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

.btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.btn-danger:hover { background: #b91c1c; }
.btn-danger:disabled { background: #fca5a5; }

/* ============== Documents / Canvas Editor ============== */
.doc-input-card {
    background: var(--card-bg);
    border-radius: 0.75rem;
    padding: 1.5rem;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    max-width: 700px;
}

.doc-input-card h2 {
    font-size: 1.25rem;
    margin-bottom: 1.5rem;
}

.doc-input-card textarea {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid var(--border);
    border-radius: 0.5rem;
    font-size: 0.95rem;
    font-family: inherit;
    line-height: 1.6;
    resize: vertical;
}

.doc-input-card select {
    width: 100%;
    padding: 0.5rem;
    border: 1px solid var(--border);
    border-radius: 0.5rem;
    font-size: 0.95rem;
    background: var(--bg);
}

.canvas-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 1rem;
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 0.75rem 0.75rem 0 0;
    gap: 0.75rem;
}

.canvas-title {
    font-weight: 600;
    font-size: 1rem;
    color: var(--text);
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.canvas-toolbar-actions {
    display: flex;
    gap: 0.5rem;
    flex-shrink: 0;
}

.canvas-toolbar-actions .btn {
    padding: 0.35rem 0.75rem;
    font-size: 0.85rem;
}

.canvas-editor {
    min-height: 400px;
    max-height: 70vh;
    overflow-y: auto;
    padding: 1.5rem;
    background: white;
    border-left: 1px solid var(--border);
    border-right: 1px solid var(--border);
    font-family: 'Georgia', 'Times New Roman', serif;
    font-size: 0.95rem;
    line-height: 1.7;
    color: var(--text);
    outline: none;
}

.canvas-editor:focus {
    box-shadow: inset 0 0 0 2px rgba(37, 99, 235, 0.1);
}

.canvas-editor h2 {
    font-size: 1.2rem;
    margin-top: 1em;
    margin-bottom: 0.5em;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

.canvas-editor h3 {
    font-size: 1.05rem;
    margin-top: 0.8em;
    margin-bottom: 0.4em;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

.canvas-editor p {
    margin-bottom: 0.5em;
}

.canvas-editor ul {
    padding-left: 1.5em;
    margin-bottom: 0.5em;
}

.canvas-prompt-bar {
    display: flex;
    gap: 0.5rem;
    padding: 0.75rem 1rem;
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 0 0 0.75rem 0.75rem;
    border-top: none;
}

.canvas-prompt-bar input {
    flex: 1;
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--border);
    border-radius: 0.5rem;
    font-size: 0.9rem;
    font-family: inherit;
}

.canvas-prompt-bar input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.15);
}

.canvas-prompt-bar .btn {
    flex-shrink: 0;
}

@media (max-width: 768px) {
    .canvas-toolbar {
        flex-wrap: wrap;
    }

    .canvas-toolbar-actions {
        width: 100%;
        justify-content: flex-end;
    }

    .canvas-editor {
        min-height: 300px;
        padding: 1rem;
    }
}
