/* ─── Design Tokens ──────────────────────────────────────────────────────── */
:root {
    --bg: #060810;
    --bg-card: rgba(14, 16, 27, 0.8);
    --bg-card-hover: rgba(20, 23, 38, 0.9);
    --border: rgba(255,255,255,0.08);
    --border-bright: rgba(255,255,255,0.18);
    --text: #f1f5f9;
    --text-muted: rgba(241,245,249,0.5);
    --text-dim: rgba(241,245,249,0.35);

    --purple: #c084fc;
    --indigo: #818cf8;
    --cyan: #38bdf8;
    --green: #4ade80;
    --amber: #fbbf24;
    --red: #f87171;

    --grad: linear-gradient(135deg, var(--purple) 0%, var(--indigo) 50%, var(--cyan) 100%);
    --grad-subtle: linear-gradient(135deg, rgba(192,132,252,0.15), rgba(56,189,248,0.1));
}

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

body {
    font-family: 'Inter', system-ui, sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
    
    /* Native App Experience */
    overscroll-behavior: none; /* Disable pull-to-refresh & rubber banding */
    user-select: none;         /* Prevent accidental text selection */
    -webkit-user-select: none;
    -webkit-touch-callout: none; /* Disable native callout menu on long press */
}

/* Allow selection inside document area if needed (optional, or keep locked for drawing) */
#blocks-render-area {
    user-select: text;
    -webkit-user-select: text;
}

/* ─── Background ─────────────────────────────────────────────────────────── */
.bg-orb {
    position: fixed;
    border-radius: 50%;
    pointer-events: none;
    z-index: 0;
    filter: blur(100px);
    animation: drift 25s ease-in-out infinite alternate;
}
.bg-orb-1 { width:700px; height:700px; top:-15%; right:-10%; background:radial-gradient(circle, rgba(192,132,252,0.22) 0%, transparent 70%); }
.bg-orb-2 { width:600px; height:600px; bottom:-15%; left:-10%; background:radial-gradient(circle, rgba(56,189,248,0.18) 0%, transparent 70%); animation-delay:-8s; }
.bg-orb-3 { width:400px; height:400px; top:45%; left:45%; background:radial-gradient(circle, rgba(129,140,248,0.15) 0%, transparent 70%); animation-delay:-15s; }

@keyframes drift {
    0% { transform: translate(0,0) scale(1); }
    100% { transform: translate(40px,-60px) scale(1.15); }
}

.bg-grid {
    position: fixed;
    inset: 0;
    z-index: 0;
    background-image: linear-gradient(rgba(255,255,255,0.025) 1px, transparent 1px),
                      linear-gradient(90deg, rgba(255,255,255,0.025) 1px, transparent 1px);
    background-size: 60px 60px;
    pointer-events: none;
}

/* ─── Layout ─────────────────────────────────────────────────────────────── */
.app-container {
    max-width: 1200px; /* Increased for dashboard */
    margin: 0 auto;
    padding: 1.5rem 1.5rem 4rem;
    position: relative;
    z-index: 1;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.main-content {
    position: relative;
    flex: 1;
    display: flex;
    flex-direction: column;
}

/* ─── Header ─────────────────────────────────────────────────────────────── */
.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.25rem 0 1.5rem;
    border-bottom: 1px solid var(--border);
    margin-bottom: 5rem;
    position: relative;
    z-index: 200;
}

.logo {
    display: flex;
    align-items: center;
    gap: 0.6rem;
}

.logo-icon {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    background: var(--grad);
    display: grid;
    place-items: center;
    box-shadow: 0 0 20px rgba(192,132,252,0.4);
}

.logo-text {
    font-size: 1.1rem;
    font-weight: 700;
    letter-spacing: -0.4px;
}

.logo-badge {
    font-size: 0.6rem;
    font-weight: 700;
    letter-spacing: 0.5px;
    padding: 2px 6px;
    border-radius: 4px;
    background: var(--grad);
    color: white;
}

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

/* ─── Auth Section ───────────────────────────────────────────────────────── */
.auth-section {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.login-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.6rem 1.2rem;
    border-radius: 999px;
    border: 1px solid var(--border-bright);
    background: rgba(255,255,255,0.05);
    color: var(--text);
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}
.login-btn:hover { background: rgba(255,255,255,0.1); border-color: var(--purple); box-shadow: 0 0 15px rgba(192,132,252,0.3); }

.user-profile {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.user-email {
    font-size: 0.8rem;
    color: var(--text-muted);
    font-family: 'JetBrains Mono', monospace;
}

.logout-btn {
    padding: 0.4rem 0.8rem;
    border-radius: 6px;
    border: 1px solid var(--border);
    background: transparent;
    color: var(--text-dim);
    font-size: 0.75rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}
.logout-btn:hover { color: var(--red); border-color: var(--red); background: rgba(248,113,113,0.05); }

/* ─── Auth Guard ─────────────────────────────────────────────────────────── */
.auth-guard {
    position: absolute;
    inset: -2rem -1.5rem; /* Cover padding of app-container if needed, or just inset: 0 */
    inset: 0;
    z-index: 100;
    background: rgba(6, 8, 16, 0.7);
    backdrop-filter: blur(8px);
    display: grid;
    place-items: center;
    border-radius: 20px;
    animation: fade-in 0.4s ease;
}

@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }

.guard-content {
    text-align: center;
    background: var(--bg-card);
    border: 1px solid var(--border-bright);
    padding: 3rem 4rem;
    border-radius: 24px;
    box-shadow: 0 20px 50px rgba(0,0,0,0.5);
}

.guard-icon { font-size: 3.5rem; margin-bottom: 1.5rem; }
.guard-content h2 { font-size: 1.5rem; font-weight: 800; margin-bottom: 0.5rem; }
.guard-content p { color: var(--text-muted); font-size: 0.95rem; }

/* ─── Hero ───────────────────────────────────────────────────────────────── */
.hero {
    text-align: center;
    margin-bottom: 3.5rem;
}

.hero-pill {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.4rem 1.1rem;
    border-radius: 999px;
    border: 1px solid rgba(192,132,252,0.35);
    background: rgba(192,132,252,0.08);
    font-size: 0.8rem;
    color: var(--purple);
    font-weight: 500;
    margin-bottom: 1.5rem;
    letter-spacing: 0.2px;
}

.hero-title {
    font-size: clamp(2.2rem, 5vw, 3.5rem);
    font-weight: 800;
    line-height: 1.15;
    letter-spacing: -1.5px;
    margin-bottom: 1.2rem;
}

.gradient-text {
    background: var(--grad);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.hero-subtitle {
    color: var(--text-muted);
    font-size: 1.05rem;
    line-height: 1.7;
    max-width: 580px;
    margin: 0 auto 2rem;
}

.feature-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 0.6rem;
    justify-content: center;
}

.chip {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.45rem 1rem;
    border-radius: 999px;
    border: 1px solid var(--border-bright);
    background: rgba(255,255,255,0.04);
    font-size: 0.82rem;
    color: var(--text-muted);
    font-weight: 500;
    transition: all 0.2s;
}
.chip:hover { border-color: rgba(192,132,252,0.4); color: var(--purple); background: rgba(192,132,252,0.08); }
.chip-icon { font-size: 0.9rem; }

/* ─── Upload Zone ────────────────────────────────────────────────────────── */
.upload-section { margin-bottom: 2rem; }

.upload-zone {
    position: relative;
    border-radius: 20px;
    padding: 3px;
    background: var(--grad);
    cursor: pointer;
    transition: transform 0.3s cubic-bezier(0.2, 0.8, 0.2, 1), box-shadow 0.3s;
}
.upload-zone:hover, .upload-zone.dragover {
    transform: scale(1.012);
    box-shadow: 0 0 60px rgba(192,132,252,0.25);
}

.upload-glow {
    position: absolute;
    inset: -1px;
    border-radius: 22px;
    background: var(--grad);
    opacity: 0;
    filter: blur(20px);
    transition: opacity 0.4s;
    pointer-events: none;
    z-index: -1;
}
.upload-zone:hover .upload-glow, .upload-zone.dragover .upload-glow { opacity: 0.5; }

.upload-inner {
    background: var(--bg-card);
    backdrop-filter: blur(30px);
    border-radius: 18px;
    padding: 4rem 2rem;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.75rem;
}

.upload-icon-wrap {
    position: relative;
    width: 90px;
    height: 90px;
    display: grid;
    place-items: center;
    margin-bottom: 1rem;
}

.upload-icon-ring {
    position: absolute;
    inset: 0;
    border-radius: 50%;
    border: 2px solid transparent;
    background: var(--grad) border-box;
    -webkit-mask: linear-gradient(#fff 0 0) padding-box, linear-gradient(#fff 0 0);
    -webkit-mask-composite: xor;
    mask-composite: exclude;
    animation: spin-slow 8s linear infinite;
}
@keyframes spin-slow { to { transform: rotate(360deg); } }

.upload-icon-svg {
    position: relative;
    z-index: 1;
    animation: bob 3s ease-in-out infinite alternate;
}
@keyframes bob {
    0% { transform: translateY(0); }
    100% { transform: translateY(-8px); }
}

.upload-title {
    font-size: 1.4rem;
    font-weight: 700;
    letter-spacing: -0.5px;
}

.upload-sub {
    color: var(--text-muted);
    font-size: 0.9rem;
}

.browse-link {
    color: var(--cyan);
    font-weight: 600;
    cursor: pointer;
    transition: text-shadow 0.2s;
}
.browse-link:hover { text-shadow: 0 0 12px rgba(56,189,248,0.6); }

/* ─── Generic card section ───────────────────────────────────────────────── */
.card-section { margin-bottom: 2rem; }

.state-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 20px;
    padding: 2rem;
    backdrop-filter: blur(20px);
    box-shadow: 0 8px 40px rgba(0,0,0,0.3);
}

/* ─── File Ready Card ────────────────────────────────────────────────────── */
.state-card-header {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding-bottom: 1.5rem;
    border-bottom: 1px solid var(--border);
    margin-bottom: 1.5rem;
}

.file-icon-wrap {
    width: 44px;
    height: 44px;
    border-radius: 12px;
    background: var(--grad-subtle);
    border: 1px solid rgba(192,132,252,0.25);
    display: grid;
    place-items: center;
    color: var(--purple);
    flex-shrink: 0;
}

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

.file-name-text {
    display: block;
    font-size: 0.95rem;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.file-size-text {
    display: block;
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-top: 2px;
}

.icon-btn {
    background: transparent;
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text-muted);
    width: 32px;
    height: 32px;
    display: grid;
    place-items: center;
    cursor: pointer;
    transition: all 0.2s;
    flex-shrink: 0;
}
.icon-btn:hover { border-color: var(--red); color: var(--red); background: rgba(248,113,113,0.08); }

/* Pipeline info */
.pipeline-info {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.6rem;
    margin-bottom: 1.5rem;
}

.pipeline-step {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.6rem 0.9rem;
    border-radius: 10px;
    background: rgba(255,255,255,0.03);
    border: 1px solid var(--border);
    font-size: 0.8rem;
    color: var(--text-muted);
}

.ps-icon { font-size: 1rem; }

/* ─── Convert Button ─────────────────────────────────────────────────────── */
.convert-btn {
    width: 100%;
    padding: 1rem;
    border: none;
    border-radius: 12px;
    background: var(--grad);
    color: white;
    font-family: inherit;
    font-size: 1rem;
    font-weight: 700;
    letter-spacing: -0.2px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    box-shadow: 0 4px 20px rgba(129,140,248,0.4);
    transition: all 0.3s cubic-bezier(0.2, 0.8, 0.2, 1);
    position: relative;
    overflow: hidden;
}
.convert-btn::after {
    content: '';
    position: absolute;
    inset: 0;
    background: white;
    opacity: 0;
    transition: opacity 0.2s;
}
.convert-btn:hover::after { opacity: 0.08; }
.convert-btn:hover { transform: translateY(-2px); box-shadow: 0 8px 30px rgba(192,132,252,0.5); }
.convert-btn:active { transform: translateY(0); }
.btn-icon { font-size: 1.1rem; }

/* ─── Processing Card ────────────────────────────────────────────────────── */
.processing-card { }

.processing-header {
    display: flex;
    align-items: center;
    gap: 1.25rem;
    margin-bottom: 2rem;
}

.spinner-wrap {
    width: 48px;
    height: 48px;
    flex-shrink: 0;
}

.spinner {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    border: 3px solid rgba(192,132,252,0.2);
    border-top-color: var(--purple);
    animation: spin 0.9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.processing-title { font-size: 1.1rem; font-weight: 700; margin-bottom: 0.25rem; }
.processing-sub { font-size: 0.82rem; color: var(--text-muted); }

/* Progress steps list */
.progress-steps {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
    min-height: 80px;
}

.step-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.65rem 1rem;
    border-radius: 10px;
    font-size: 0.85rem;
    transition: all 0.3s ease;
    animation: step-in 0.35s ease;
}
@keyframes step-in {
    from { opacity: 0; transform: translateX(-10px); }
    to   { opacity: 1; transform: translateX(0); }
}

.step-item.done {
    background: rgba(74,222,128,0.06);
    border: 1px solid rgba(74,222,128,0.2);
    color: var(--text-muted);
}

.step-item.active {
    background: rgba(192,132,252,0.1);
    border: 1px solid rgba(192,132,252,0.3);
    color: var(--text);
}

.step-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}
.step-item.done .step-dot { background: var(--green); }
.step-item.active .step-dot {
    background: var(--purple);
    box-shadow: 0 0 8px var(--purple);
    animation: pulse-dot 1.2s infinite;
}
@keyframes pulse-dot {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.5; transform: scale(1.5); }
}

.step-sub {
    margin-left: auto;
    font-size: 0.75rem;
    color: var(--text-dim);
    font-family: 'JetBrains Mono', monospace;
}

/* Overall progress bar */
.overall-bar {
    height: 4px;
    border-radius: 999px;
    background: rgba(255,255,255,0.06);
    overflow: hidden;
    margin-bottom: 0.6rem;
}

.overall-bar-fill {
    height: 100%;
    background: var(--grad);
    border-radius: 999px;
    width: 0%;
    transition: width 0.5s ease;
}

.current-step-label {
    font-size: 0.78rem;
    color: var(--text-dim);
    text-align: center;
    font-family: 'JetBrains Mono', monospace;
}

/* ─── Result Card ────────────────────────────────────────────────────────── */
.result-card {
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.75rem;
}

.result-checkmark {
    animation: pop 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}
@keyframes pop {
    0% { transform: scale(0); }
    100% { transform: scale(1); }
}

.result-title { font-size: 1.6rem; font-weight: 700; letter-spacing: -0.5px; }
.result-sub { font-size: 0.9rem; color: var(--text-muted); max-width: 400px; }

.result-actions {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
    justify-content: center;
    margin-top: 0.5rem;
}

.download-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.85rem 1.75rem;
    border-radius: 10px;
    background: var(--green);
    color: #0a1a0f;
    font-weight: 700;
    font-size: 0.95rem;
    text-decoration: none;
    transition: all 0.3s;
    box-shadow: 0 4px 20px rgba(74,222,128,0.35);
}
.download-btn:hover { transform: translateY(-2px); box-shadow: 0 8px 30px rgba(74,222,128,0.5); }

.btn-secondary {
    display: inline-flex;
    align-items: center;
    padding: 0.85rem 1.75rem;
    border-radius: 10px;
    border: 1px solid var(--border-bright);
    background: transparent;
    color: var(--text);
    font-family: inherit;
    font-weight: 600;
    font-size: 0.95rem;
    cursor: pointer;
    transition: all 0.2s;
}
.btn-secondary:hover { background: rgba(255,255,255,0.05); border-color: var(--border-bright); }

/* ─── Error Card ─────────────────────────────────────────────────────────── */
.error-card {
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.75rem;
    border-color: rgba(248,113,113,0.25);
}
.error-icon { font-size: 2.5rem; }
.error-msg { font-size: 0.85rem; color: var(--red); font-family: 'JetBrains Mono', monospace; max-width: 500px; word-break: break-word; }

/* ─── Dashboard Layout ───────────────────────────────────────────────────── */
.dashboard {
    display: flex;
    gap: 2rem;
    flex: 1;
    animation: slide-up 0.5s cubic-bezier(0.2, 0.8, 0.2, 1);
}

@keyframes slide-up {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

.sidebar {
    width: 260px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 20px;
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    backdrop-filter: blur(10px);
}

.sidebar-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.sidebar-header h3 {
    font-size: 0.9rem;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 1px;
}

.add-subject-btn {
    width: 28px;
    height: 28px;
    border-radius: 6px;
    border: 1px solid var(--border-bright);
    background: rgba(255,255,255,0.05);
    color: var(--text);
    cursor: pointer;
    font-size: 1.2rem;
    line-height: 1;
}
.add-subject-btn:hover { background: var(--purple); border-color: var(--purple); }

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

.subject-item {
    padding: 0.75rem 1rem;
    border-radius: 10px;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text-muted);
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 0.75rem;
}
.subject-item:hover { background: rgba(255,255,255,0.05); color: var(--text); }
.subject-item.active {
    background: var(--grad-subtle);
    color: var(--purple);
    border: 1px solid rgba(192,132,252,0.2);
}

/* Dashboard Main Area */
.dashboard-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

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

.breadcrumb {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.9rem;
    font-weight: 600;
}

.bc-item { color: var(--text-muted); }
.bc-item.active { color: var(--text); }
.bc-sep { color: var(--text-dim); }

.chapters-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1.5rem;
}

.chapter-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 1.5rem;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.2, 0.8, 0.2, 1);
    display: flex;
    flex-direction: column;
    gap: 1rem;
    position: relative;
    overflow: hidden;
}
.chapter-card::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0; height: 3px;
    background: var(--grad);
    opacity: 0;
    transition: opacity 0.3s;
}
.chapter-card:hover { 
    transform: translateY(-5px); 
    border-color: var(--border-bright); 
    box-shadow: 0 10px 30px rgba(0,0,0,0.3);
}
.chapter-card:hover::before { opacity: 1; }

.chapter-title { font-weight: 700; font-size: 1.05rem; }
.chapter-date { font-size: 0.75rem; color: var(--text-dim); }

.chapter-stats {
    display: flex;
    gap: 1rem;
    margin-top: 0.5rem;
}
.stat-item {
    font-size: 0.75rem;
    color: var(--text-muted);
    background: rgba(255,255,255,0.03);
    padding: 2px 8px;
    border-radius: 4px;
}

.empty-state {
    grid-column: 1 / -1;
    text-align: center;
    padding: 5rem 2rem;
    color: var(--text-dim);
}
.empty-icon { font-size: 4rem; margin-bottom: 1rem; opacity: 0.2; }

.primary-btn.sm {
    padding: 0.6rem 1.25rem;
    font-size: 0.85rem;
}

/* ─── Utility ────────────────────────────────────────────────────────────── */
.hidden { display: none !important; }

/* ─── Responsive ─────────────────────────────────────────────────────────── */
@media (max-width: 600px) {
    .pipeline-info { grid-template-columns: 1fr; }
    .hero-title { font-size: 2rem; }
    .upload-inner { padding: 2.5rem 1.25rem; }
    .header { flex-direction: column; gap: 1rem; }
}/* ─── Inspector Modal ────────────────────────────────────────────────────── */
/* ─── Notability Focus Mode ────────────────────────────────────────── */
.inspector-overlay {
    position: fixed;
    inset: 0;
    background: #f8f9fa; /* Notability-style slightly grey background */
    z-index: 2000;
    display: flex;
    flex-direction: column;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.inspector-overlay:not(.hidden) {
    opacity: 1;
    pointer-events: auto;
}

/* Immersive Top Bar */
.focus-header {
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid rgba(0,0,0,0.05);
    display: flex;
    align-items: center;
    padding: 0.75rem 1.5rem;
    height: 64px;
    z-index: 2010;
    box-shadow: 0 1px 2px rgba(0,0,0,0.02);
    flex-shrink: 0;
}

.focus-back .icon-btn {
    border: none;
    background: transparent;
    color: var(--text);
    width: 40px;
    height: 40px;
}
.focus-back .icon-btn:hover {
    background: rgba(0,0,0,0.03);
    color: var(--purple);
}

.focus-info {
    flex-grow: 1;
    margin: 0 1.5rem;
}

#ins-chapter-title {
    font-size: 1.1rem;
    font-weight: 700;
    margin: 0;
    color: var(--text);
    letter-spacing: -0.3px;
}

#ins-chapter-meta {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin: 0;
    font-weight: 500;
}

.focus-actions {
    display: flex;
    gap: 0.75rem;
}

/* Floating Drawing Toolbar */
.drawing-toolbar {
    position: absolute;
    top: 80px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(15, 15, 18, 0.95);
    backdrop-filter: blur(20px);
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: 100px;
    padding: 0.5rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    box-shadow: 0 12px 48px rgba(0,0,0,0.4);
    z-index: 2020;
    transition: all 0.3s ease;
}

.tool-group {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0 0.5rem;
}
.tool-group:not(:last-child) {
    border-right: 1px solid rgba(0,0,0,0.06);
}

.tool-btn {
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 8px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    color: rgba(255,255,255,0.7);
}

.tool-btn:hover {
    background: rgba(255,255,255,0.1);
    color: white;
}

.tool-btn.active {
    background: var(--purple);
    color: white;
}

/* AI Merge Button Special Styling */
.tool-btn.ai-btn {
    background: linear-gradient(135deg, #6366f1, #a855f7);
    color: white;
    border: none;
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3);
    border-radius: 50px;
    padding: 8px 12px;
    width: auto;
    min-width: 40px;
    gap: 8px;
}

.tool-btn.ai-btn .pct-label {
    display: none;
    font-size: 0.75rem;
    font-weight: 700;
    font-family: 'Inter', sans-serif;
}

.tool-btn.ai-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 6px 16px rgba(99, 102, 241, 0.4);
    color: white;
}

.tool-btn.ai-btn.processing {
    animation: pulse-ai 1.5s infinite;
    pointer-events: none;
}

.tool-btn.ai-btn.processing .pct-label {
    display: block;
}

@keyframes pulse-ai {
    0% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.05); opacity: 0.8; }
    100% { transform: scale(1); opacity: 1; }
}

.tool-sep {
    width: 1px;
    height: 24px;
    background: rgba(255,255,255,0.15);
    margin: 0 0.25rem;
}

/* Color Palette */
.tool-group.colors {
    gap: 0.5rem;
}

.color-btn {
    width: 22px;
    height: 22px;
    border-radius: 50%;
    border: 2px solid transparent;
    cursor: pointer;
    transition: transform 0.2s, border-color 0.2s;
}

.color-btn:hover { transform: scale(1.15); }

.color-btn.active {
    border-color: var(--purple);
    transform: scale(1.15);
}

/* Viewport & Canvas Layout */
.inspector-viewport {
    flex-grow: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 60px 20px;
    scroll-behavior: smooth;
    -webkit-overflow-scrolling: touch;
    position: relative;
    background: #f1f3f5;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.canvas-wrapper {
    position: relative;
    max-width: 900px;
    margin: 0 auto;
    background: white;
    box-shadow: 0 0 40px rgba(0,0,0,0.05);
    min-height: 1000px; /* Base height for empty capítulos */
}

.latex-page-container {
    position: relative;
    width: 100%;
    margin-bottom: 20px;
    background: white;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}
.save-status {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-muted);
    background: rgba(0,0,0,0.05);
    padding: 2px 8px;
    border-radius: 10px;
    margin-top: 4px;
    transition: all 0.3s ease;
    display: inline-block;
}

.save-status.saving {
    color: #0046a0;
    background: rgba(0, 70, 160, 0.1);
}

.save-status.saved {
    color: #059669;
    background: rgba(5, 150, 105, 0.1);
}

.drawing-canvas {
    position: absolute;
    top: 0;
    left: 0;
    z-index: 50;
    pointer-events: auto; 
    touch-action: pinch-zoom pan-y; /* Restore scrolling for fingers */
    cursor: crosshair;
}

#blocks-render-area {
    position: relative;
    z-index: 5;
    width: 100%;
    min-height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.latex-page-container {
    width: 100%;
    display: flex;
    justify-content: center;
    background: white;
}

.latex-page-image {
    max-width: 100%;
    height: auto;
    display: block;
    /* Optional: subtle border to see page boundaries */
    border-bottom: 1px solid #eee;
}


.block-page-divider {
    z-index: 5;
}

/* ─── Markdown Rendering Beauty (Document Style) ───────────────────────── */
.note-block h1, .note-block h2, .note-block h3 {
    margin-top: 2rem;
    margin-bottom: 1rem;
    color: #1a1a1a;
    letter-spacing: -0.5px;
    font-weight: 700;
}
.note-block h1 { font-size: 2rem; border-bottom: 2px solid #eee; padding-bottom: 0.5rem; }
.note-block h2 { font-size: 1.6rem; border-bottom: 1px solid #f5f5f5; padding-bottom: 0.3rem; }
.note-block h3 { font-size: 1.3rem; }

.note-block p { margin-bottom: 1rem; }
.note-block ul, .note-block ol { margin: 1rem 0; padding-left: 1.5rem; }
.note-block li { margin-bottom: 0.5rem; }

.note-block blockquote {
    border-left: 3px solid var(--purple);
    padding-left: 1rem;
    margin: 1.5rem 0;
    color: var(--text-muted);
    font-style: italic;
}

/* ─── TikZJax Specifics (Paper Flow) ─────────────────────────────────── */
.tikz-container {
    width: 100%;
    margin: 2.5rem 0;
    display: flex;
    justify-content: center;
    background: transparent; 
    padding: 1rem 0;
    border-radius: 0;
    box-shadow: none;
    overflow-x: auto;
}

.tikz-container svg {
    max-width: 100%;
    height: auto;
}

/* Fallback/Loader for TikZJax */
.tikz-container:empty::before {
    content: "Rendering Diagram...";
    font-size: 0.8rem;
    color: #999;
}

/* KaTeX tweaks within markdown */
.katex-display {
    margin: 2rem 0 !important;
    padding: 1rem 0;
    background: transparent;
    border-radius: 0;
    border-left: 3px solid #f0f0f0;
    padding-left: 2rem;
}
