* { box-sizing: border-box; }
body { overflow: hidden; margin: 0; padding: 0; font-family: 'Outfit', sans-serif; }

.is-hidden {
    display: none !important;
}

/* PDF görüntüleyici ile kütüphaneyi birbirini dışlar yap (JS zamanlamasından bağımsız garanti).
   #workspace.pdf-active sınıfı, flipbook doluyken MutationObserver ile eklenir. */
#workspace.pdf-active #library-section,
#workspace.pdf-active #welcome-message {
    display: none !important;
}
#workspace:not(.pdf-active) #canvas-container {
    display: none !important;
}

#selection-box {
    position: absolute;
    border: 2.5px solid #2563eb;
    background-color: rgba(37, 99, 235, 0.12);
    display: none;
    pointer-events: none;
    z-index: 10;
    box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.45);
    border-radius: 4px;
}
#download-btn {
    position: absolute;
    display: none;
    z-index: 20;
}
#canvas-container {
    position: relative;
    display: inline-block;
    cursor: crosshair;
    background: transparent;
}
.analyzing-overlay {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(255,255,255,0.9);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 50;
    font-weight: 600;
    color: #2563eb;
    backdrop-filter: blur(4px);
}
.drop-active {
    border-color: #2563eb !important;
    background-color: rgba(37, 99, 235, 0.08) !important;
    transform: scale(1.01);
}
#workspace {
    height: calc(100vh - 64px);
    overflow: auto;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    padding: 24px;
}
.toolbar-btn {
    padding: 8px 12px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 600;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    border: none;
    background: transparent;
    color: #475569;
}
.toolbar-btn:hover { background: #f1f5f9; color: #0f172a; }
.toolbar-btn:disabled { opacity: 0.3; cursor: not-allowed; }
.toolbar-group {
    display: flex;
    align-items: center;
    gap: 4px;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    padding: 4px;
}

/* AI Twin Panel Styles */
#twin-content {
    font-family: 'Outfit', sans-serif;
    font-size: 1.15rem;
    line-height: 1.8;
    color: #1e293b;
}

#twin-content p { margin-bottom: 1.5rem; }
#twin-content strong { font-weight: 800; color: #000; }

.question-options {
    display: flex;
    justify-content: space-around;
    flex-wrap: wrap;
    align-items: center;
    margin-top: 2rem;
    padding-top: 1.5rem;
    border-top: 1px dashed #e2e8f0;
    font-weight: 600;
    gap: 1.5rem;
}

.option-item {
    display: flex;
    gap: 0.5rem;
    white-space: nowrap;
}

.twin-q-image {
    display: block;
    max-width: 100%;
    height: auto;
    margin: 1.5rem auto;
    border-radius: 12px;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    border: 1px solid #f1f5f9;
}

#twin-content ul, #twin-content ol { margin-left: 1.5rem; margin-bottom: 1.25rem; }
#twin-content li { margin-bottom: 0.5rem; }

::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}
::-webkit-scrollbar-track {
    background: transparent;
}
::-webkit-scrollbar-thumb {
    background: #e2e8f0;
    border-radius: 10px;
}
::-webkit-scrollbar-thumb:hover {
    background: #cbd5e1;
}

@keyframes pulse-violet {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

.animate-pulse-violet {
    animation: pulse-violet 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}


/* --- TWIN BOOK PREVIEW STYLES (from design.md) --- */
:root {
    --ink: #1a2230;
    --ink-soft: #4a566b;
    --muted: #8c97a8;
    --paper: #ffffff;
    --paper-2: #f3f1e9;
    --rule: #dfe5ef;
    --accent: oklch(0.72 0.13 165);
    --accent-deep: oklch(0.55 0.14 165);
    --accent-2: oklch(0.72 0.12 235);
    --accent-2-deep: oklch(0.55 0.13 240);
    --accent-3: oklch(0.74 0.15 55);
    --accent-3-deep: oklch(0.62 0.18 50);
}

.page {
    width: 210mm;
    min-height: 297mm;
    background-color: var(--paper);
    box-shadow: 0 30px 80px -30px rgba(20,30,50,.25);
    border-radius: 2px;
    position: relative;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    font-family: 'Inter', sans-serif;
    color: var(--ink);
}

/* Header */
.top-band {
    height: 170px;
    background: radial-gradient(circle at top right, var(--paper-2), var(--paper));
    border-bottom: 2px solid var(--accent);
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
}

/* Body & Columns */
.body-content {
    flex: 1;
    padding: 30px 56px;
    display: grid;
    grid-template-columns: 1fr 1px 1fr;
    gap: 0;
    position: relative;
}

.body--single {
    grid-template-columns: 1fr;
}

.divider {
    background: linear-gradient(to bottom, transparent, var(--accent-2), transparent);
    width: 1px;
    height: 100%;
    opacity: 0.5;
}

.col {
    padding: 6px 36px;
    display: flex;
    flex-direction: column;
    gap: 32px;
    height: 100%;
}

.body--compact .col {
    display: grid;
    grid-template-rows: 1fr 1fr;
    gap: 20px;
}

/* Question Block */
.q {
    display: flex;
    flex-direction: column;
    gap: 12px;
    position: relative;
}

.q-num {
    width: 30px;
    height: 30px;
    background-color: white;
    border: 2px solid var(--accent);
    box-shadow: 0 2px 0 var(--accent);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: 'Inter Tight', sans-serif;
    font-weight: 800;
    font-size: 16px;
    color: var(--accent-deep);
    margin-bottom: 8px;
}

.q-body {
    font-size: 15px;
    line-height: 1.6;
}

.q-context {
    margin: 4px 0 14px;
    color: var(--ink);
}

.q-image {
    width: 100%;
    height: auto;
    display: block;
    border-radius: 6px;
    margin-bottom: 14px;
}

.q-stem {
    font-weight: 700;
    color: var(--ink);
    margin-bottom: 14px;
}

.opts {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px 18px;
}

.opts--row4 {
    grid-template-columns: 1fr 1fr 1fr 1fr;
}

.opt {
    display: flex;
    gap: 6px;
}

.opt b {
    font-family: 'Inter Tight', sans-serif;
    font-weight: 800;
    color: var(--accent-deep);
}

/* Legacy Fallback */
.legacy-q {
    font-size: 14px;
}
.legacy-q img {
    max-width: 100%;
    border-radius: 6px;
}

/* Footer */
.footer {
    height: 118px;
    border-top: 1px solid var(--rule);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 56px;
    background-color: var(--paper);
}

.footer-tag {
    font-family: 'JetBrains Mono', monospace;
    font-size: 12px;
    letter-spacing: 0.1em;
    color: var(--muted);
    text-transform: uppercase;
}

.page-num {
    background-color: white;
    border: 2px solid var(--accent);
    box-shadow: 0 3px 0 var(--accent);
    border-radius: 999px;
    font-family: 'Bricolage Grotesque', sans-serif;
    font-weight: 800;
    font-size: 22px;
    color: var(--accent-deep);
    padding: 4px 24px;
}

/* Twin Variant Selector Styles */
.variant-selector {
    position: relative;
    float: right;
    display: flex;
    gap: 4px;
    background: var(--paper-2);
    padding: 4px;
    border-radius: 12px;
    border: 1px solid var(--rule);
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
    z-index: 20;
    margin-left: 10px;
    margin-bottom: 6px;
}

.variant-btn {
    padding: 2px 8px;
    font-size: 11px;
    font-weight: 700;
    font-family: 'Inter', sans-serif;
    border-radius: 8px;
    color: var(--ink-soft);
    cursor: pointer;
    transition: all 0.2s;
}

.variant-btn:hover {
    background: white;
}

.variant-btn.active {
    background: var(--accent-deep);
    color: white;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

/* NEW DESIGN.MD TWIN BOOK STYLES */
:root {
  --accent: #008ADF;
  --ink: #1A1A1A;
  --muted: #9AA0A6;
  --line: #D9E2E8;
  --paper: #FFFFFF;
  --divider: #D9E2E8;
}

.page {
  width: 210mm; min-height: 297mm;
  padding: 15mm;
  background: var(--paper);
  position: relative;
  font-family: 'Inter', system-ui, sans-serif;
  color: var(--ink);
  font-size: 10pt; line-height: 1.35;
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
}

.topic { text-align: center; font-weight: 700; text-transform: uppercase;
         letter-spacing: .04em; margin: 0 0 10mm;
         padding-bottom: 4px; border-bottom: 1px solid var(--line); }

.columns { 
  flex: 1;
  height: 100%;
  column-count: 2; 
  column-gap: 11mm;
  position: relative;
}

.columns::before {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  left: calc(50% - 0.5px);
  width: 1px;
  background-color: var(--divider);
}

.question { break-inside: avoid; position: relative; margin-bottom: 20px; }
.q-no { color: var(--accent); font-weight: 700; margin-right: 6px; float: left; }
.q-body { display: flow-root; }
.math { text-align: center; margin: 10px 0; }

.q-body u { text-decoration: underline; font-weight: 700; }

.options { list-style: none; display: flex; justify-content: space-between;
           gap: 6px; margin-top: 12px; padding: 0; counter-reset: opt; }
.options li { counter-increment: opt; }
.options li::before { content: counter(opt, upper-alpha) ') '; }
.options.grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px 16px;
}

/* Legacy Q Çözüm Butonlarını Gizle */
.legacy-q button,
.legacy-q [onclick*="classList.toggle"],
.legacy-q .mt-8.pt-6.border-t,
.legacy-q .border-t.border-slate-200,
.legacy-q .solution-btn {
  display: none !important;
}

.page-no { position: absolute; left: 50%; transform: translateX(-50%);
           bottom: 8mm; color: var(--accent); font-size: 8pt; font-weight: 700; }
