:root { color-scheme: light; font: 14px/1.5 system-ui, -apple-system, sans-serif; color: #242c3a; background: #eef1f5; --border: #d9dee7; --accent: #2457c6; }
* { box-sizing: border-box; }
body { margin: 0; height: 100dvh; overflow: hidden; }
[hidden] { display: none !important; }
button, input, select, textarea { font: inherit; }
button { border: 1px solid var(--accent); background: var(--accent); color: white; padding: .5rem .85rem; border-radius: 5px; cursor: pointer; white-space: nowrap; }
button.secondary { background: white; color: #34445f; border-color: #cbd3e0; }
button:disabled { opacity: .5; cursor: default; }
button.small { padding: .3rem .65rem; font-size: .85rem; }
button.icon-button { border: 0; background: transparent; color: #536079; font-size: 1.4rem; line-height: 1; padding: .35rem .55rem; }
button:hover:not(:disabled) { filter: brightness(.96); }
:focus-visible { outline: 2px solid #3b7bec; outline-offset: 2px; }
a { color: var(--accent); text-underline-offset: .18em; }
h1, h2, h3, p, figure { margin: 0; }
h1 { font-size: 1.15rem; font-weight: 700; letter-spacing: -.03em; }
h2 { font-size: 1.1rem; } h3 { font-size: .92rem; }
.app-header { height: 58px; padding: 0 20px; background: #fff; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.header-actions { display: flex; align-items: center; gap: .6rem; }
.brand { color: inherit; text-decoration: none; }
.account-menu { position: relative; }
.account-menu > summary { display: flex; align-items: center; gap: .55rem; cursor: pointer; list-style: none; border-radius: 5px; padding: 3px; }
.account-menu > summary::-webkit-details-marker { display: none; }
.account-avatar { display: grid; place-items: center; width: 32px; height: 32px; flex-shrink: 0; border-radius: 50%; background: #e8effd; color: var(--accent); font-size: .8rem; font-weight: 650; }
.account-label { max-width: 160px; text-overflow: ellipsis; overflow: hidden; white-space: nowrap; font-size: .85rem; }
.account-panel { position: absolute; right: 0; top: calc(100% + 10px); z-index: 20; display: flex; flex-direction: column; gap: .35rem; width: min(290px, calc(100vw - 24px)); padding: 18px; background: white; border: 1px solid var(--border); border-radius: 7px; box-shadow: 0 8px 28px #24334f1c; overflow-wrap: anywhere; }
.account-email { color: #6d798e; font-size: .85rem; }
.account-panel form { margin-top: 12px; }
.account-panel button { width: 100%; }
.library-page, .login-page { height: auto; min-height: 100dvh; overflow: auto; }
.library-main { max-width: 1120px; margin: 0 auto; padding: 36px 28px 60px; }
.library-title { font-size: 1.65rem; margin-bottom: 28px; letter-spacing: -.025em; }
.library-section + .library-section { margin-top: 32px; }
.library-section-heading { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.library-section-heading h3 { font-size: 1rem; }
.library-section-heading > span { font-size: .85rem; }
.library-list { background: white; border: 1px solid var(--border); border-radius: 7px; overflow: hidden; }
.library-row { display: flex; align-items: center; gap: 18px; padding-right: 22px; }
.library-row + .library-row { border-top: 1px solid var(--border); }
.library-row:hover { background: #f8faff; }
.library-item-link { flex: 1; min-width: 0; padding: 18px 22px; color: inherit; text-decoration: none; display: flex; flex-direction: column; gap: 4px; }
.library-item-title { font-weight: 550; overflow-wrap: anywhere; }
.library-item-meta { color: #758197; font-size: .8rem; }
.library-download { font-size: .85rem; flex-shrink: 0; }
.library-empty { display: flex; flex-direction: column; align-items: center; gap: 16px; padding: 38px 22px; text-align: center; color: #6d798e; }
.file-library { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(220px, 100%), 1fr)); gap: 16px; background: transparent; border: 0; overflow: visible; }
.file-card { min-width: 0; border: 1px solid var(--border); border-radius: 7px; overflow: hidden; background: white; display: flex; flex-direction: column; }
.file-card:hover { border-color: #a9bbdf; }
.file-card-link { display: flex; flex-direction: column; flex: 1; color: inherit; text-decoration: none; min-width: 0; }
.file-preview { height: 250px; padding: 15px; display: flex; justify-content: center; align-items: center; overflow: hidden; background: #e9edf3; color: #758197; font-size: .8rem; }
.file-preview canvas { max-width: 100%; max-height: 100%; object-fit: contain; background: white; box-shadow: 0 2px 8px #24334f18; }
.file-text-excerpt { width: 100%; height: 220px; margin: 0; padding: 14px; overflow: hidden; white-space: pre-wrap; overflow-wrap: anywhere; background: white; color: #536079; font: 11px/1.6 ui-monospace, monospace; }
.file-card-details { padding: 15px 16px 10px; display: flex; flex-direction: column; gap: 5px; }
.file-card-footer { padding: 0 16px 15px; }
.file-card-link:focus-visible { outline-offset: -3px; }
.library-main > .error, .upload-progress { margin: 0 0 20px; white-space: pre-wrap; }
.upload-progress { color: #526781; font-size: .9rem; }
.login-main { min-height: calc(100dvh - 58px); display: grid; place-items: center; padding: 32px 20px; }
.login-card { width: min(400px, 100%); padding: 32px; background: white; border: 1px solid var(--border); border-radius: 8px; }
.login-card h2 { font-size: 1.4rem; margin-bottom: 10px; }
.login-card > p { color: #6d798e; }
.login-card .error { color: #ad253c; }
.button-link { display: inline-flex; align-items: center; justify-content: center; gap: 12px; padding: .7rem 1rem; border: 1px solid #cbd3e0; border-radius: 5px; background: white; color: #34445f; text-decoration: none; }
.google-sign-in { width: 100%; margin: 28px 0 18px; font-weight: 550; }
.button-link:hover { background: #f7f9fc; }
.button-link[aria-disabled="true"] { opacity: .5; cursor: default; }
.workspace { height: calc(100dvh - 58px); display: grid; grid-template-columns: minmax(240px, var(--source-size, 50%)) 8px minmax(280px, 1fr); padding: 12px; }
.pane { display: flex; flex-direction: column; min-width: 0; min-height: 0; background: white; border: 1px solid var(--border); border-radius: 6px; overflow: hidden; }
.tabs-bar { display: flex; min-height: 42px; flex-shrink: 0; background: #f3f5f8; border-bottom: 1px solid var(--border); min-width: 0; }
.tab-list { display: flex; overflow-x: auto; scrollbar-width: thin; min-width: 0; }
.tabs-bar > .tab-list { flex: 1; }
.tab { border: 0; border-right: 1px solid var(--border); border-radius: 0; background: transparent; color: #667186; padding: .65rem .95rem; min-width: 80px; max-width: 230px; display: inline-flex; align-items: center; gap: .5rem; flex: 0 0 auto; font-size: .85rem; }
.tab > span { text-overflow: ellipsis; overflow: hidden; white-space: nowrap; }
.tab[aria-selected="true"] { color: #27364f; background: white; box-shadow: inset 0 2px var(--accent); }
.tab .unsaved-mark { flex-shrink: 0; width: 6px; height: 6px; background: #7383a1; border-radius: 50%; }
.closable-tab { display: flex; flex: 0 0 auto; max-width: 230px; border-right: 1px solid var(--border); }
.closable-tab:has([aria-selected="true"]) { background: white; box-shadow: inset 0 2px var(--accent); }
.closable-tab .tab { flex: 1; min-width: 0; border: 0; padding-right: .35rem; box-shadow: none; background: transparent; }
.tab-close { flex: 0 0 28px; border: 0; border-radius: 0; padding: .25rem .5rem; font-size: 1.15rem; background: transparent; color: #65738b; }
.tab-close:hover { background: #dfe5ee; }
.tab-action { border: 0; border-left: 1px solid var(--border); background: transparent; color: #364c70; padding: .6rem .8rem; font-size: .85rem; border-radius: 0; }
.pane-toolbar { height: 45px; padding: 0 12px; display: flex; align-items: center; gap: .6rem; border-bottom: 1px solid var(--border); flex-shrink: 0; min-width: 0; }
.pdf-controls, #page-form { display: flex; align-items: center; gap: .35rem; }
#page-form label, #page-count { font-size: .8rem; color: #647087; white-space: nowrap; }
#page { width: 48px; padding: .22rem .3rem; font-size: .85rem; }
#zoom { padding: .25rem; font-size: .8rem; width: 88px; }
.toolbar-link { margin-left: auto; font-size: .8rem; }
.document-views { flex: 1; min-height: 0; position: relative; background: #e9ecf1; }
#document-pane { container-type: inline-size; }
@container (max-width: 400px) {
  .pdf-controls { gap: .15rem; } .pdf-controls .icon-button { padding: .35rem .3rem; }
  #page-form label { display: none; } #page { width: 36px; }
  #zoom { width: 74px; padding: .2rem; font-size: .75rem; }
  .pane-toolbar { padding: 0 8px; }
}
@container (max-width: 280px) { #zoom { display: none; } }
.document-view { width: 100%; height: 100%; overflow: auto; }
.document-view iframe { width: 100%; height: 100%; border: 0; display: block; }
.document-empty, .upload-state { display: flex; flex-direction: column; justify-content: center; align-items: center; height: 100%; gap: 12px; padding: 24px; text-align: center; color: #667389; overflow-wrap: anywhere; }
.text-preview { padding: 24px; background: white; margin: 16px; white-space: pre-wrap; overflow-wrap: anywhere; font: 13px/1.7 ui-monospace, monospace; }
.image-preview { display: block; max-width: 100%; max-height: 100%; object-fit: contain; margin: auto; padding: 20px; }
.splitter { position: relative; cursor: col-resize; touch-action: none; }
.splitter::after { content: ''; position: absolute; top: 45%; left: 2px; width: 4px; height: 42px; border-radius: 4px; background: #c6cedc; }
.splitter:hover::after, .splitter:focus-visible::after, body.resizing .splitter::after { background: var(--accent); }
body.resizing { cursor: col-resize; user-select: none; }
body.resizing iframe { pointer-events: none; }
.result-actions { display: flex; gap: .5rem; margin-left: auto; }
#set-status { font-size: .8rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.generation-progress { display: flex; align-items: center; gap: 12px; padding: 16px; background: #f4f7ff; border-bottom: 1px solid #d4dff4; flex-shrink: 0; }
.generation-spinner { width: 28px; height: 28px; border: 3px solid #d3def5; border-top-color: var(--accent); border-radius: 50%; animation: generation-spin .9s linear infinite; flex-shrink: 0; }
.generation-progress-copy { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.generation-progress-copy strong { font-size: .9rem; font-weight: 600; }
.generation-progress-copy > span { font-size: .8rem; color: #6d798e; }
.generation-elapsed { margin-left: auto; color: #6d798e; font-size: .8rem; font-variant-numeric: tabular-nums; flex-shrink: 0; }
@keyframes generation-spin { to { transform: rotate(360deg); } }
.item-tabs { border-bottom: 1px solid var(--border); flex-shrink: 0; padding: 0 .5rem; min-height: 38px; }
.item-tabs .tab { border: 0; padding: .5rem .75rem; min-width: 60px; background: white; }
.item-tabs .tab[aria-selected="true"] { box-shadow: inset 0 -2px var(--accent); color: var(--accent); }
.practice-content { flex: 1; min-height: 0; overflow: auto; padding: 24px; display: flex; flex-direction: column; }
.empty-state { margin: auto; max-width: 300px; padding: 30px 10px; text-align: center; color: #7a8495; font-size: .95rem; }
.deck { display: flex; flex-direction: column; justify-content: center; gap: 20px; max-width: 720px; width: 100%; margin: auto; }
.flashcard { perspective: 1600px; height: clamp(320px, 53dvh, 580px); width: 100%; cursor: pointer; outline-offset: 5px; }
.card-inner { position: relative; width: 100%; height: 100%; transform-style: preserve-3d; transition: transform .48s cubic-bezier(.2,.65,.3,1); }
.flashcard.flipped .card-inner { transform: rotateY(180deg); }
.card-face { position: absolute; inset: 0; border: 1px solid #ced6e3; border-radius: 14px; padding: 24px; background: #fff; box-shadow: 0 6px 22px #24334f14, 0 1px 2px #24334f0a; backface-visibility: hidden; -webkit-backface-visibility: hidden; display: flex; flex-direction: column; overflow: hidden; }
.card-back { transform: rotateY(180deg); background: #f7faff; border-color: #bfcfe8; }
.card-label { display: flex; justify-content: space-between; font-size: .75rem; letter-spacing: .04em; text-transform: uppercase; color: #77849b; margin-bottom: 15px; flex-shrink: 0; }
.card-body { flex: 1; min-height: 0; overflow: auto; display: flex; flex-direction: column; }
.card-body > h2 { font-size: 1.08rem; margin-bottom: 16px; overflow-wrap: anywhere; }
.card-front .card-blocks { margin-block: auto; }
.card-front .math-output { font-size: 1.3rem; }
.card-front .text-block { color: #53617a; }
.card-hint { color: #8b96a8; font-size: .75rem; text-align: center; padding-top: 16px; flex-shrink: 0; }
.deck-controls { display: flex; align-items: center; justify-content: center; gap: .8rem; }
.deck-counter { color: #6e7b91; font-size: .8rem; min-width: 50px; text-align: center; }
.problem { max-width: 780px; width: 100%; margin: 0 auto; }
.problem h2 { margin: 0 0 24px; }
.problem .solution { margin-top: 24px; border-top: 1px solid var(--border); padding-top: 16px; }
.solution summary { color: var(--accent); cursor: pointer; font-weight: 600; margin-bottom: 16px; }
.text-block { white-space: pre-wrap; overflow-wrap: anywhere; margin: .5rem 0 1rem; }
.math-block { min-width: 0; margin: .75rem 0 1.1rem; }
.math-output { padding: .5rem 0; overflow-x: auto; overflow-y: hidden; max-width: 100%; }
.katex-display { margin: .3rem 0; }
.katex-display > .katex { text-align: left; }
.card-front .katex-display > .katex { text-align: center; }
.citation, .field-note { font-size: .8rem; color: #758197; }
.citation { margin-top: .35rem; }
.math-error, .error { color: #ad253c; overflow-wrap: anywhere; }
.study-notes { border-top: 1px solid var(--border); padding: 10px 16px; font-size: .8rem; color: #667389; max-height: 110px; overflow: auto; }
.study-notes summary { cursor: pointer; } .study-notes details[open] summary { margin-bottom: 8px; }
.status-message { position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%); max-width: min(720px, 90vw); z-index: 10; background: #253650; color: #fff; padding: .75rem 1rem; border-radius: 7px; box-shadow: 0 4px 20px #1c2a4630; font-size: .85rem; }
.status-message.error { background: #8e2738; color: white; }
.muted { color: #6d798e; }
input, select, textarea { border: 1px solid #c6cfdd; border-radius: 5px; color: inherit; background: white; padding: .55rem .65rem; min-width: 0; }
input[type="checkbox"] { width: 16px; height: 16px; accent-color: var(--accent); }
input[type="number"] { appearance: textfield; }
input::-webkit-inner-spin-button { appearance: none; }
label { display: block; color: #55637a; font-size: .85rem; }
label > input, label > select { display: block; width: 100%; margin-top: .35rem; }
.context-comment { margin-top: 18px; }
.context-comment textarea { display: block; width: 100%; margin-top: .35rem; resize: vertical; }
dialog { width: min(600px, calc(100vw - 32px)); max-height: calc(100dvh - 48px); border: 1px solid #d4dce9; border-radius: 10px; padding: 0; color: inherit; box-shadow: 0 24px 90px #17233d38; }
dialog::backdrop { background: #17233d6b; }
.dialog-header { padding: 18px 22px; display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid var(--border); }
.dialog-body { padding: 20px 22px; max-height: calc(100dvh - 220px); overflow: auto; }
.dialog-body h3 { margin: 20px 0 10px; }
.dialog-body > select, #set-name { width: 100%; margin-top: .35rem; }
.dialog-footer { padding: 14px 22px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: .6rem; }
.close-set-actions { flex-wrap: wrap; }
.form-grid { display: grid; grid-template-columns: 1fr 100px; gap: 16px; }
.range-controls { display: grid; grid-template-columns: 1fr 85px 85px; gap: 10px; margin-top: 12px; }
.context-heading { display: flex; align-items: center; justify-content: space-between; margin-top: 20px; }
.context-heading h3 { margin: 0; }
.context-heading + .field-note { margin: 8px 0 12px; }
.context-file { border: 1px solid var(--border); border-radius: 6px; margin: 8px 0; padding: 12px; }
.context-check { display: flex; align-items: center; gap: 9px; color: #34435a; overflow-wrap: anywhere; }
.context-check input { flex-shrink: 0; margin: 0; }
.context-file .range-controls { margin-top: 10px; }
.selection-summary { margin-top: 18px; padding-top: 12px; border-top: 1px solid var(--border); font-size: .85rem; color: #526781; }
.error:not(:empty) { margin-top: 12px; }
.saved-list > button { display: flex; flex-direction: column; align-items: flex-start; text-align: left; width: 100%; white-space: normal; gap: 3px; background: white; color: #354563; border: 1px solid var(--border); margin-bottom: 10px; }
.saved-list small { color: #7a869a; }
@media (prefers-reduced-motion: reduce) { .card-inner { transition: none; } .generation-spinner { animation: none; } }
@media (max-width: 640px) {
  body { overflow: auto; height: auto; }
  .app-header { padding: 0 12px; position: sticky; top: 0; z-index: 5; }
  .header-actions { gap: 5px; }
  .header-actions button { padding: .45rem .6rem; font-size: .8rem; }
  .account-label { display: none; }
  .app-header { gap: 8px; }
  .library-main { padding: 24px 16px 40px; }
  .library-title { margin-bottom: 22px; font-size: 1.45rem; }
  .library-row { gap: 6px; padding-right: 14px; }
  .library-item-link { padding: 16px 14px; }
  .library-download { font-size: .8rem; }
  .workspace { height: auto; display: flex; flex-direction: column; padding: 8px; gap: 10px; }
  #document-pane { height: 58dvh; min-height: 350px; }
  #practice-pane { min-height: 520px; }
  .splitter { display: none; }
  .practice-content { padding: 16px; }
  .card-face { padding: 20px; }
  .flashcard { height: 400px; }
}
@media (max-width: 400px) { .range-controls { grid-template-columns: 1fr 65px 65px; } .pane-toolbar { gap: 4px; padding: 0 8px; } #zoom { width: 73px; } }
