:root {
  color-scheme: light;
  --ink: #354747;
  --ink-soft: #53645c;
  --muted: #747b72;
  --canvas: #f8f5eb;
  --paper: #fffdf7;
  --line: #deded3;
  --soft: #f3f0e7;
  --sage: #435e51;
  --sage-light: #e3ecdf;
  --rust: #ad553e;
  --rust-dark: #874230;
  --gold: #af8550;
  --danger: #994c41;
  --shadow: 0 14px 34px #4438290e;
  font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
body { min-height: 100vh; margin: 0; color: var(--ink); background: radial-gradient(ellipse 50rem 34rem at 100% -12%, #e4ece2 0%, transparent 65%), radial-gradient(ellipse 38rem 27rem at -10% 34%, #f4e7d5 0%, transparent 68%), var(--canvas); }
body::before { position: fixed; z-index: -1; inset: 0; pointer-events: none; content: ""; opacity: .22; background-image: radial-gradient(#83947d2b .7px, transparent .7px); background-size: 7px 7px; }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; border: 1px solid var(--rust); border-radius: 999px; padding: .76rem 1.08rem; color: var(--paper); background: var(--rust); font-size: .86rem; font-weight: 700; letter-spacing: -.01em; transition: transform .18s ease, color .18s ease, background .18s ease, border-color .18s ease, box-shadow .18s ease; }
button:hover { background: var(--rust-dark); box-shadow: 0 8px 18px #74392b20; transform: translateY(-1px); }
button:active { transform: translateY(0); }
button:disabled { cursor: not-allowed; opacity: .48; }
button.secondary, .quiet-button { border-color: var(--line); color: var(--ink); background: transparent; }
button.secondary:hover, .quiet-button:hover { background: #eeeee3; box-shadow: none; }
button.danger { border-color: #e1b8ae; color: #873d35; background: #f5e3df; }
a { color: inherit; }
input, select, textarea { width: 100%; padding: .78rem .9rem; border: 1px solid #d5d9ce; border-radius: 12px; color: var(--ink); background: var(--paper); box-shadow: inset 0 1px #fff; }
input:focus, select:focus, textarea:focus, button:focus-visible, a:focus-visible { outline: 3px solid #af8550; outline-offset: 3px; }
textarea { min-height: 92px; resize: vertical; }
label { display: grid; gap: .42rem; color: var(--ink-soft); font-size: .78rem; font-weight: 700; }
h1, h2, h3, p { margin-top: 0; }
h2 { margin-bottom: .25rem; font: 400 clamp(1.35rem, 3vw, 1.85rem)/1.14 Georgia, "Times New Roman", serif; letter-spacing: -.04em; }

.shell { width: min(1180px, 100%); margin: auto; padding: 1rem 1rem 6.8rem; }
.app-main { min-width: 0; }
.top { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: .35rem 0 1.4rem; }
.brand-lockup { display: flex; align-items: center; gap: .72rem; color: inherit; text-decoration: none; }
.brand-lockup > span:last-child { display: grid; gap: .16rem; }
.brand-mark { display: grid; width: 43px; height: 43px; place-items: center; flex: 0 0 auto; border: 1px solid #b7b6a0; border-radius: 50%; color: #76806d; background: #faf6eb; box-shadow: inset 0 0 0 4px #fffdf7, inset 0 0 0 5px #d0cdbc; font: 23px/1 Georgia, serif; }
.brand { font: 400 1.48rem/1 Georgia, "Times New Roman", serif; letter-spacing: -.055em; }
.subtle { color: var(--muted); font-size: .82rem; line-height: 1.5; }
.top-actions { display: flex; align-items: center; gap: .48rem; }
.flag-button { min-width: 43px; padding: .5rem; border: 1px solid var(--line); color: var(--ink); background: var(--paper); font-size: 1.05rem; text-align: center; }
.navigation { position: fixed; z-index: 4; right: 0; bottom: 0; left: 0; display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 2px; padding: .55rem max(.35rem, env(safe-area-inset-right)) calc(.55rem + env(safe-area-inset-bottom)) max(.35rem, env(safe-area-inset-left)); border-top: 1px solid #d9ddd3; background: #fffdf7ed; backdrop-filter: blur(16px); }
.navigation a { padding: .52rem .2rem; border: 1px solid transparent; border-radius: 12px; color: var(--muted); font-size: .7rem; font-weight: 700; text-align: center; text-decoration: none; }
.navigation a::before { display: block; margin-bottom: .13rem; font-size: 1.1rem; line-height: 1.1; }
.navigation a[data-tab="learn"]::before { content: "⌂"; }
.navigation a[data-tab="quiz"]::before { content: "✦"; }
.navigation a[data-tab="add"]::before { content: "＋"; }
.navigation a[data-tab="progress"]::before { content: "◔"; }
.navigation a[data-tab="spatial"]::before { content: "◈"; }
.navigation a[data-tab="settings"]::before { content: "⚙"; }
.navigation a.active { border-color: #d6dacc; color: var(--ink); background: #eeeee3; }

.notice, .error { margin: 0 0 1rem; padding: .8rem .95rem; border: 1px solid; border-radius: 13px; font-size: .88rem; }
.notice { border-color: #cddac7; color: #466552; background: var(--sage-light); }
.error { border-color: #e8c3bc; color: #873d35; background: #f8e7e3; }
.card, .auth, .editor-card, .quiz-config { padding: clamp(1.1rem, 3vw, 1.65rem); border: 1px solid var(--line); border-radius: 20px; background: var(--paper); box-shadow: var(--shadow); }
.stack { display: grid; gap: 1.15rem; }
.grid { display: grid; gap: .85rem; }
.row { display: flex; align-items: center; flex-wrap: wrap; gap: .6rem; }
.grow { flex: 1; }
.page-title { margin: .12rem 0 .55rem; font: 400 clamp(2.45rem, 5.3vw, 4rem)/1.01 Georgia, "Times New Roman", serif; letter-spacing: -.065em; }
.page-title em { color: var(--rust); font-weight: inherit; }
.eyebrow { color: #778170; font-size: .64rem; font-weight: 750; letter-spacing: .16em; text-transform: uppercase; }
.quiet-button { padding: .54rem .78rem; font-size: .76rem; }

.library-home { gap: 1.5rem; }
.library-intro { display: grid; gap: 1.25rem; padding: clamp(1.3rem, 4vw, 2.4rem); overflow: hidden; border: 1px solid #d9ddd3; border-radius: 24px; background: linear-gradient(115deg, #eef1e8, #fffdf7 54%, #f5e3d3); }
.library-intro > div { position: relative; z-index: 1; max-width: 710px; }
.library-intro .page-title { font-size: clamp(3.2rem, 7vw, 5.3rem); }
.library-intro p, .collection-header p, .browser-heading p, .editor-heading p, .quiz-intro p, .progress-intro p { max-width: 560px; margin-bottom: 0; color: var(--ink-soft); font-size: .96rem; line-height: 1.65; }
.library-intro-actions { display: flex; align-items: center; flex-wrap: wrap; gap: .7rem; margin-top: 1.4rem; }
.material-switch { display: inline-flex; width: fit-content; padding: 4px; border: 1px solid var(--line); border-radius: 999px; background: #eeeee3; }
.material-switch button { border-color: transparent; color: var(--muted); background: transparent; box-shadow: none; }
.material-switch button.active { color: var(--paper); background: var(--sage); }
.library-tally { align-self: end; display: grid; width: min(100%, 250px); gap: .3rem; padding: 1.05rem 1.1rem; border: 1px solid #d9ddd3; border-radius: 18px; background: #fffdf7c7; }
.library-tally strong { color: var(--rust); font: 400 3.2rem/.9 Georgia, serif; letter-spacing: -.08em; }
.library-tally strong small { color: var(--ink-soft); font: .9rem ui-sans-serif, system-ui, sans-serif; letter-spacing: 0; }
.library-tally > span:last-of-type { color: var(--muted); font-size: .78rem; }
.collection-heading { display: flex; align-items: end; justify-content: space-between; gap: 1rem; }
.collection-heading h2 { margin: .35rem 0 0; }
.collection-heading > p { margin: 0; text-align: right; }
.section-list { display: grid; gap: .9rem; }
.section-card, .chapter-card { position: relative; display: grid; width: 100%; overflow: hidden; border: 1px solid var(--line); border-radius: 20px; color: var(--ink); background: var(--paper); box-shadow: 0 4px 12px #44382908; text-align: left; }
.section-card:hover, .chapter-card:hover { border-color: #c1cab9; background: var(--paper); box-shadow: 0 15px 30px #44382912; }
.collection-card { grid-template-columns: minmax(122px, 34%) 1fr; min-height: 176px; padding: 0; }
.collection-art { position: relative; display: block; overflow: hidden; background: #dce8df; }
.collection-card:nth-child(4n + 2) .collection-art { background: #f1e2ca; }
.collection-card:nth-child(4n + 3) .collection-art { background: #dce9ec; }
.collection-card:nth-child(4n) .collection-art { background: #e9dfeb; }
.collection-art::before, .collection-art::after, .collection-art i, .collection-art b, .collection-art em { position: absolute; display: block; content: ""; }
.collection-art::before { width: 122%; height: 57%; right: -20%; bottom: -21%; border-radius: 50% 50% 0 0; background: #809c85; }
.collection-art::after { width: 62%; aspect-ratio: 1; left: 18%; top: 17%; border: 1px solid #fffdf799; border-radius: 50%; }
.collection-art i { width: 30%; aspect-ratio: 1; top: 28%; left: 35%; border-radius: 50%; background: #fffaf0; box-shadow: 0 0 0 13px #fffaf055; }
.collection-art b { width: 18%; height: 52%; left: 43%; bottom: 23%; border-radius: 16px 16px 0 0; background: #536d59; }
.collection-art em { width: 52%; height: 6px; left: 26%; bottom: 21%; border-radius: 99px; background: #fffaf0aa; }
.collection-card:nth-child(4n + 2) .collection-art::before { background: #c08d62; }
.collection-card:nth-child(4n + 2) .collection-art b { background: #8e6747; }
.collection-card:nth-child(4n + 3) .collection-art::before { background: #6d98a0; }
.collection-card:nth-child(4n + 3) .collection-art b { background: #4e7784; }
.collection-card:nth-child(4n) .collection-art::before { background: #9b84a0; }
.collection-card:nth-child(4n) .collection-art b { background: #735f79; }
.collection-art small { position: absolute; top: .8rem; left: .9rem; color: #3547479c; font-size: .68rem; font-variant-numeric: tabular-nums; }
.collection-copy { display: grid; align-content: center; gap: .65rem; min-width: 0; padding: 1.15rem; }
.section-heading, .chapter-heading { font: 400 1.55rem/1.08 Georgia, "Times New Roman", serif; letter-spacing: -.045em; }
.collection-arrow { color: #8b9a89; font-size: 1.2rem; }
.count { color: var(--muted); font-size: .76rem; font-variant-numeric: tabular-nums; font-weight: 700; }
.progress-line { height: 4px; margin-top: .28rem; overflow: hidden; border-radius: 999px; background: #e7e5d9; }
.progress-line i { display: block; height: 100%; border-radius: inherit; background: #80947c; }
.spatial-progress-strip { display: flex; flex-wrap: wrap; gap: .7rem 1.1rem; margin: 0 auto 1rem; width: min(1180px, calc(100% - 2rem)); padding: .75rem 1rem; border: 1px solid #d8ddd1; border-radius: 16px; background: #f8f7f0; color: #52665c; font-size: .88rem; }
.spatial-progress-strip span { white-space: nowrap; }
.spatial-progress-strip b { color: #33483e; }

.chapter-index, .chapter-browser { gap: 1.35rem; }
.collection-header, .browser-header { padding: clamp(.4rem, 2vw, 1rem) 0 .6rem; border-bottom: 1px solid var(--line); }
.collection-header .row, .browser-header .row { margin-bottom: 1.2rem; }
.chapter-list { gap: .7rem; }
.chapter-card { grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; min-height: 112px; padding: 1rem 1.1rem; }
.chapter-number { display: grid; width: 42px; height: 42px; margin-right: .95rem; place-items: center; border: 1px solid #d0d7cc; border-radius: 50%; color: #778170; font-size: .66rem; font-weight: 750; }
.chapter-copy { display: grid; gap: .42rem; min-width: 0; }
.browser-heading { display: grid; gap: 1rem; }
.browser-actions { display: flex; flex-wrap: wrap; gap: .55rem; }
.card-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: .78rem 0; }
.search-field { display: flex; align-items: center; width: min(100%, 390px); gap: .55rem; padding: 0 .7rem; border: 1px solid #d5d9ce; border-radius: 12px; background: var(--paper); color: var(--muted); }
.search-field input { border: 0; padding-left: 0; box-shadow: none; }
.item-list { display: grid; gap: .65rem; }
.item { display: grid; width: 100%; gap: .3rem; padding: 1rem; border: 1px solid var(--line); border-radius: 16px; color: var(--ink); background: var(--paper); box-shadow: 0 3px 8px #6a403208; text-align: left; }
.item:hover { border-color: #b7c2b2; background: #fafbf6; }
.item.is-selected { border-color: #88a28c; background: #f1f5eb; }
.item-with-location { padding: 0; gap: 0; overflow: hidden; }
.item-with-location:hover { background: var(--paper); }
.item-open { border: 0; border-radius: 0; box-shadow: none; }
.item-open:hover { background: #fafbf6; box-shadow: none; transform: none; }
.location-link { display: flex; align-items: center; justify-content: space-between; width: 100%; padding: .65rem 1rem; border: 0; border-top: 1px solid var(--line); border-radius: 0; color: #54745c; background: #f3f7ef; font-size: .72rem; font-weight: 750; text-align: left; }
.location-link:hover { background: #eaf2e6; box-shadow: none; transform: none; }
.item-status { display: flex; align-items: center; gap: .35rem; color: var(--muted); font-size: .67rem; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; }
.status-dot { width: 8px; height: 8px; border-radius: 50%; background: #d5d2c8; }
.status-dot.known { background: #6d9577; }
.status-dot.attention { background: #c58a3e; }
.translation { font: 400 1.5rem/1.35 Tahoma, Arial, sans-serif; }
.rtl { direction: rtl; text-align: right; }
.item-english { font: .91rem/1.35 Georgia, "Times New Roman", serif; }
.tag { width: fit-content; padding: .16rem .48rem; border: 1px solid #e2e1d7; border-radius: 999px; color: var(--muted); background: var(--soft); font-size: .65rem; font-weight: 700; }
.item-meta { display: flex; align-items: center; flex-wrap: wrap; gap: .36rem; margin-top: .22rem; }
.selection-tag { border-color: #a9bea8; background: #e8f0e5; color: #496652; }
.empty-state { text-align: center; }
.hidden { display: none; }

.connections-page { gap: 1.65rem; }
.connections-intro { display: grid; gap: 1rem; padding: clamp(1.45rem, 4vw, 2.55rem); overflow: hidden; border: 1px solid #d6ddd4; border-radius: 26px; background: radial-gradient(circle at 90% 18%, #d8e7df 0 8%, transparent 31%), radial-gradient(circle at 83% 78%, #eeddbf 0 5%, transparent 22%), linear-gradient(125deg, #e8efe8, #fffdf7 57%, #f2e5d4); }
.connections-intro > div { max-width: 660px; }
.connections-intro .page-title { font-size: clamp(3rem, 7vw, 5.2rem); }
.connections-intro p { max-width: 600px; margin: 0; color: var(--ink-soft); line-height: 1.65; }
.connections-tally { display: grid; align-content: end; justify-self: start; gap: .22rem; padding: 1rem 1.1rem; border: 1px solid #d9ddd3; border-radius: 17px; background: #fffdf7c9; }
.connections-tally strong { color: var(--sage); font: 400 3.4rem/.85 Georgia, serif; letter-spacing: -.09em; }
.connections-tally > span:not(.eyebrow), .connections-tally small { color: var(--muted); font-size: .76rem; line-height: 1.4; }
.connections-tally small { max-width: 190px; margin-top: .35rem; padding-top: .5rem; border-top: 1px solid var(--line); }
.connection-tray { position: sticky; z-index: 2; top: .65rem; display: flex; align-items: center; flex-wrap: wrap; gap: .65rem; padding: .8rem 1rem; border: 1px solid #b9cfb9; border-radius: 16px; background: #edf5eaed; box-shadow: 0 8px 24px #48644416; backdrop-filter: blur(14px); }
.connection-tray span { flex: 1; min-width: 190px; color: #466252; font-size: .85rem; }
.connection-section { display: grid; gap: .9rem; }
.connection-section > header { display: grid; gap: .28rem; padding: .15rem .1rem .45rem; }
.connection-section > header h2 { margin: 0; }
.connection-section > header p { max-width: 660px; margin: 0; }
.connection-grid { display: grid; gap: .75rem; }
.connection-group { display: grid; gap: .9rem; padding: 1.1rem; border: 1px solid var(--line); border-radius: 20px; background: #fffdf7d9; box-shadow: 0 7px 18px #44382908; }
.connection-group-copy { display: grid; gap: .38rem; }
.connection-group-copy h2 { margin: 0; font-size: 1.5rem; }
.connection-group-copy p { margin: 0; color: var(--ink-soft); font-size: .88rem; line-height: 1.5; }
.connection-evidence { padding: .15rem .48rem; border: 1px solid #dae1d7; border-radius: 99px; color: #627162; background: #f1f5ee; font-size: .61rem; font-weight: 750; letter-spacing: .06em; text-transform: uppercase; }
.research-section .connection-group { background: #fbf7ef; }
.research-section .connection-evidence { border-color: #e3d4ba; color: #826a4b; background: #f7edda; }
.connection-card-links { display: flex; flex-wrap: wrap; gap: .45rem; }
.connection-word { display: grid; min-width: min(100%, 120px); gap: .1rem; padding: .54rem .65rem; border: 1px solid #dde1d7; border-radius: 12px; color: var(--ink); background: #fff; box-shadow: none; text-align: left; }
.connection-word:hover { border-color: #9daf9d; color: var(--ink); background: #f5f8f1; box-shadow: none; }
.connection-word > span { font: 400 1.05rem/1.2 Georgia, serif; }
.connection-word small { color: var(--muted); font-size: .66rem; font-weight: 500; }
.connection-word b { max-width: 150px; overflow: hidden; color: var(--ink-soft); font-size: .68rem; font-weight: 650; text-overflow: ellipsis; white-space: nowrap; }
.connection-word.known { border-color: #b9d2ba; background: #f1f8ef; }
.connection-word.attention { border-color: #e5c68c; background: #fff9eb; }
.connection-actions { display: flex; flex-wrap: wrap; gap: .45rem; }
.connection-actions button { padding: .58rem .82rem; font-size: .75rem; }
.connection-membership { grid-column: 1 / -1; }
.connection-membership p { margin-bottom: .7rem; }
.connection-membership-list { display: grid; gap: .36rem; margin: 0 0 .8rem; }
.connection-membership-list span { display: grid; gap: .1rem; padding: .5rem .6rem; border-radius: 9px; background: #f4f6ef; color: var(--ink-soft); font-size: .76rem; }
.connection-membership-list b { color: var(--sage); font-size: .62rem; letter-spacing: .1em; text-transform: uppercase; }
.connection-editor { display: grid; gap: .65rem; padding-top: .8rem; border-top: 1px solid var(--line); }
.connection-editor select, .connection-editor input { min-width: 0; }
.personal-connections .connection-group { background: #fff7f1; }
.personal-connections .connection-evidence { border-color: #e8c5b5; color: #9a5b42; background: #fff0e7; }

.settings-page { width: min(850px, 100%); margin: 0 auto; }
.settings-intro { padding: clamp(1.4rem, 4vw, 2.5rem); border: 1px solid #d9ddd3; border-radius: 24px; background: linear-gradient(125deg, #e4ece6, #fffdf7 60%, #f6e1ce); }
.settings-intro p { max-width: 640px; margin: 0; color: var(--ink-soft); line-height: 1.6; }
.settings-card { padding: clamp(1.1rem, 3vw, 1.65rem); border: 1px solid var(--line); border-radius: 20px; background: var(--paper); box-shadow: var(--shadow); }
.settings-card h2 { margin: .3rem 0; }
.settings-fields { grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); }
.settings-fields label { padding: .7rem; border: 1px solid #e5e3d8; border-radius: 14px; background: #fbfaf4; }
.connection-label-list { display: flex; flex-wrap: wrap; gap: .45rem; }
.connection-label-list .tag { display: inline-flex; align-items: center; gap: .2rem; }
.connection-label-list .quiet-button { padding: 0 .15rem; color: #9a5b42; }

.quiz-builder { gap: 1.5rem; }
.quiz-intro, .progress-intro { display: grid; gap: 1rem; padding: clamp(1.35rem, 4vw, 2.4rem); overflow: hidden; border: 1px solid #d9ddd3; border-radius: 24px; background: linear-gradient(115deg, #f7ebd8, #fffdf7 59%, #e1ebe1); }
.quiz-intro .page-title, .progress-intro .page-title { font-size: clamp(3rem, 6.6vw, 5rem); }
.quiz-intro aside { display: grid; align-content: end; justify-self: start; gap: .2rem; padding: .9rem 1rem; border-radius: 16px; background: #fffdf7b8; }
.quiz-intro aside strong { color: var(--rust); font: 400 3.2rem/.9 Georgia, serif; letter-spacing: -.07em; }
.quiz-intro aside span:last-child { color: var(--muted); font-size: .76rem; }
.quiz-config { display: grid; gap: 1.35rem; }
.quiz-config-heading { display: grid; gap: .28rem; padding-bottom: .8rem; border-bottom: 1px solid var(--line); }
.quiz-config-heading h2 { margin: 0; }
.quiz-fields label { padding: .7rem; border: 1px solid #e5e3d8; border-radius: 14px; background: #fbfaf4; }
.quiz-fields input, .quiz-fields select { background: var(--paper); }
.filter-panels { display: grid; gap: .75rem; }
.overview-section { padding: 1rem; border: 1px solid #e5e1d6; border-radius: 16px; background: var(--soft); }
.overview-section h3 { margin: 0 0 .75rem; color: var(--muted); font-size: .65rem; letter-spacing: .15em; text-transform: uppercase; }
.filter-options { display: flex; flex-wrap: wrap; gap: .45rem 1rem; }
.filter-options label, .quiz-footer label { display: flex; align-items: center; gap: .45rem; font-size: .76rem; }
.quiz-footer { display: grid; gap: 1rem; align-items: end; padding-top: .2rem; border-top: 1px solid var(--line); }
.quiz-footer > div:first-child { display: grid; gap: .55rem; }
.quiz-footer p { max-width: 340px; margin: .55rem 0 0; }
.quiz-session { width: min(760px, 100%); margin: 0 auto; gap: 1rem; }
.quiz-session-top { display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.quiz-session-top > div { display: grid; gap: .25rem; }
.quiz-round-track { height: 4px; overflow: hidden; border-radius: 999px; background: #e0e3d8; }
.quiz-round-track i { display: block; height: 100%; background: var(--sage); }
.quiz-card { padding: clamp(1.35rem, 5vw, 3rem); border: 1px solid #d8ddd1; border-radius: 24px; background: var(--paper); box-shadow: var(--shadow); text-align: center; }
.quiz-difficulty { display: flex; flex-wrap: wrap; justify-content: center; align-items: center; gap: .45rem; padding-top: .7rem; border-top: 1px solid #e4e7df; }
.quiz-difficulty button { min-width: auto; }
.masked-answer { letter-spacing: .11em; }
.quiz-prompt-label { color: var(--muted); font-size: .66rem; font-weight: 750; letter-spacing: .15em; text-transform: uppercase; }
.prompt { margin: 1.25rem 0; font: 400 clamp(2.2rem, 6vw, 4rem)/1.1 Georgia, "Times New Roman", serif; letter-spacing: -.055em; }
.answers { display: grid; gap: .65rem; text-align: left; }
.answers button { border-color: #d6dacc; color: var(--ink); background: var(--paper); }
.answers button:hover { background: #eeeee3; }
.answers button.good { border-color: #aec8af; background: #dcebdc; }
.answers button.bad { border-color: #e2bcb3; background: #f4ded9; }
.quiz-helpers { display: flex; justify-content: center; flex-wrap: wrap; gap: .55rem; margin-top: .35rem; }
.quiz-reassurance { margin: 0; color: var(--muted); font-size: .77rem; text-align: center; }
.active-round-dot { color: var(--rust); font-size: 1.15em; line-height: 0; }
.quiz-timer { padding: .35rem .6rem; border: 1px solid var(--line); border-radius: 999px; background: #fff9ed; color: var(--ink-soft); font-size: .8rem; font-weight: 700; }
.quiz-timer.urgent { color: #9e3326; background: #fff0ed; border-color: #e6b6ae; }
.scope-picker details { margin-top: .85rem; }
.scope-picker summary { cursor: pointer; color: var(--ink-soft); font-weight: 700; }
.scope-tree { display: grid; gap: .8rem; margin-top: .9rem; }
.scope-section { padding: .8rem; border: 1px solid #e5e3d8; border-radius: 14px; background: #fbfaf4; }
.scope-chapters { display: grid; gap: .45rem; margin: .55rem 0 0 1.1rem; }
.scope-chapters label { justify-content: flex-start; font-size: .82rem; }
.analytics-dashboard, .analytics-grid, .analytics-page { min-width: 0; gap: 1rem; }
.analytics-grid { display: grid; gap: 1rem; }
.table-scroll { min-width: 0; max-width: 100%; overflow: auto; margin-top: .85rem; border: 1px solid var(--line); border-radius: 12px; }
.table-scroll table { width: 100%; border-collapse: collapse; font-size: .78rem; white-space: nowrap; }
.table-scroll th, .table-scroll td { padding: .65rem .7rem; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
.table-scroll th { position: sticky; top: 0; background: #f8f5ed; color: var(--ink-soft); font-size: .67rem; letter-spacing: .06em; text-transform: uppercase; }
.table-scroll tr:last-child td { border-bottom: 0; }

.overview-layout { display: grid; gap: 1rem; }
.overview-hero { position: relative; padding: clamp(1.4rem, 4vw, 2.2rem); overflow: hidden; border: 1px solid #d9ddd3; border-radius: 21px; background: linear-gradient(135deg, #e4ece6, #fffdf7 70%); }
.card-artwork-status { position: relative; z-index: 1; margin-top: 1.25rem; text-align: left; }
.card-artwork-status .atlas-canvas, .visual-quiz-art { margin-top: .6rem; overflow: hidden; border: 1px solid #d8ddd1; border-radius: 16px; }
.card-artwork-status .atlas-art { max-height: 320px; }
.visual-quiz-art .atlas-art { max-height: min(48vh, 410px); }
.overview-hero::after { position: absolute; right: -45px; bottom: -60px; width: 180px; height: 180px; border: 1px solid #435e5130; border-radius: 50%; content: ""; }
.overview-word { position: relative; z-index: 1; margin: .45rem 0; font: 400 clamp(3rem, 10vw, 5rem)/1 Georgia, "Times New Roman", serif; letter-spacing: -.07em; }
.flag-row button { border-color: var(--line); color: var(--ink); background: var(--paper); }
.flag-row button.active { border-color: #dbb3a7; color: #873d35; background: #f4ded9; }
.editor-page { gap: 1.4rem; }
.editor-heading { display: flex; align-items: start; justify-content: space-between; gap: 1rem; padding-bottom: 1rem; border-bottom: 1px solid var(--line); }
.editor-section { display: grid; gap: .75rem; }
.editor-fields label { padding: .7rem; border: 1px solid #e5e3d8; border-radius: 14px; background: #fbfaf4; }
.editor-actions { display: flex; flex-wrap: wrap; gap: .55rem; padding-top: .15rem; }
.editor-id { margin: 0; }

.progress-page { gap: 1.35rem; }
.progress-dashboard { width: min(100%, 940px); margin: 0 auto; gap: 1.1rem; }
.progress-app-intro, .progress-panel { padding: clamp(1.05rem, 3vw, 1.45rem); border: 1px solid var(--line); border-radius: 20px; background: var(--paper); box-shadow: var(--shadow); }
.progress-app-intro { background: linear-gradient(125deg, #e6eee7, #fffdf7 63%, #f2e3d4); }
.progress-app-intro .page-title { max-width: 680px; margin-top: .35rem; font-size: clamp(2.2rem, 5vw, 3.6rem); }
.progress-app-intro p { max-width: 630px; margin-bottom: 0; color: var(--ink-soft); line-height: 1.6; }
.progress-panel { display: grid; gap: .9rem; min-width: 0; }
.progress-panel h2 { margin: 0; font-size: 1.25rem; }
.progress-metric-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .65rem; }
.progress-metric-grid > div { display: grid; align-content: start; min-height: 72px; gap: .28rem; padding: .72rem; border-radius: 14px; background: #435e510f; }
.progress-metric-grid strong { color: var(--sage); font: 600 1.22rem/1.1 Georgia, "Times New Roman", serif; letter-spacing: -.025em; }
.progress-metric-grid span { color: var(--muted); font-size: .72rem; line-height: 1.25; }
.observed-block-list { display: grid; gap: .25rem; }
.observed-block-list > div { display: flex; justify-content: space-between; align-items: baseline; gap: 1rem; padding: .53rem 0; border-bottom: 1px solid #ebe8df; }
.observed-block-list > div:last-child { border-bottom: 0; }
.observed-block-list span { color: var(--sage); font-size: .82rem; font-weight: 700; text-align: right; }
.progress-range-picker { display: flex; width: min(100%, 430px); flex-wrap: wrap; gap: .35rem; }
.progress-range-picker button { min-width: 0; padding: .42rem .66rem; font-size: .72rem; }
.progress-range-picker button.active { border-color: var(--sage); color: var(--paper); background: var(--sage); }
.progress-chart { display: flex; align-items: end; gap: clamp(3px, .7vw, 7px); height: 210px; min-width: 0; padding: 1rem 0 0; overflow: hidden; border-bottom: 1px solid var(--line); }
.progress-chart-column { display: flex; min-width: 0; flex: 1 1 0; height: 100%; flex-direction: column; justify-content: end; align-items: center; gap: 6px; }
.progress-chart-column > i, .stacked-progress-bar { display: flex; width: 100%; min-height: 0; overflow: hidden; border-radius: 7px 7px 0 0; background: #e8ebe3; }
.progress-chart-column > i { background: linear-gradient(#9aae92, #54715e); }
.progress-chart-column small { min-width: 0; overflow: hidden; color: var(--muted); font-size: .6rem; text-align: center; text-overflow: ellipsis; white-space: nowrap; }
.stacked-progress-bar { flex-direction: column-reverse; }
.stacked-progress-bar i { display: block; min-height: 0; }
.known-progress-chart .progress-chart-column > i { background: linear-gradient(#a9c0a6, #54715e); }
.empty-chart { display: grid; min-height: 170px; margin: 0; place-items: center; border-bottom: 1px solid var(--line); }
.progress-intro { grid-template-columns: minmax(0, 1fr) auto; align-items: center; }
.progress-seal { display: grid; width: 156px; aspect-ratio: 1; place-content: center; border: 1px solid #b7b6a0; border-radius: 50%; color: var(--ink-soft); background: #fffdf7a8; box-shadow: inset 0 0 0 7px #faf6eb, inset 0 0 0 8px #d0cdbc; text-align: center; }
.progress-seal strong { color: var(--rust); font: 400 3rem/.9 Georgia, serif; letter-spacing: -.08em; }
.progress-seal small { font: .9rem ui-sans-serif, system-ui, sans-serif; letter-spacing: 0; }
.progress-seal span { margin-top: .38rem; font-size: .66rem; line-height: 1.3; }
.metric-grid { display: grid; gap: .75rem; }
.metric-card { display: grid; gap: .38rem; padding: 1.2rem; border: 1px solid var(--line); border-radius: 18px; background: var(--paper); }
.metric-card strong { color: var(--rust); font: 400 clamp(2.7rem, 5vw, 3.5rem)/.9 Georgia, serif; letter-spacing: -.08em; }
.metric-card p { margin: 0; color: var(--muted); font-size: .78rem; }
.activity-card, .return-card { padding: clamp(1.1rem, 3vw, 1.5rem); border: 1px solid var(--line); border-radius: 20px; background: var(--paper); }
.activity-card h2, .return-card h2 { margin: .35rem 0 0; }
.chart { display: flex; align-items: end; gap: 7px; height: 174px; margin-top: 1.25rem; padding: 1rem 0 0; border-bottom: 1px solid var(--line); }
.chart i { min-width: 5px; flex: 1; border-radius: 7px 7px 0 0; background: linear-gradient(#9aae92, #54715e); }
.chart-labels { gap: 7px; }
.chart-labels span { text-align: center; font-size: .68rem; }
.attention-copy { color: #a5523c; font-weight: 650; }
.card-history { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .7rem; margin: 1rem 0; }
.card-history div { padding: .65rem; border-radius: 12px; background: #f5eee7; }
.card-history dt { color: var(--muted); font-size: .72rem; }
.card-history dd { margin: .18rem 0 0; font-size: .85rem; font-weight: 650; }
.stacked-chart { display: flex; align-items: end; gap: 6px; height: 190px; margin-top: 1.25rem; padding: 1rem 0 0; border-bottom: 1px solid var(--line); }
.stacked-day { min-width: 0; flex: 1; height: 100%; display: flex; flex-direction: column; justify-content: end; align-items: center; gap: 6px; }
.stacked-column { width: 100%; min-height: 3px; display: flex; flex-direction: column-reverse; overflow: hidden; border-radius: 7px 7px 0 0; background: #ece7df; }
.stacked-column i { display: block; min-height: 0; }
.stacked-column .right, .chart-legend .right { background: #54715e; }
.stacked-column .assisted, .chart-legend .assisted { background: #8ba37d; }
.stacked-column .wrong, .chart-legend .wrong { background: #bd6248; }
.stacked-column .practice, .chart-legend .practice { background: #d7ac5b; }
.stacked-day small { font-size: .62rem; color: var(--muted); white-space: nowrap; }
.chart-legend { display: flex; gap: 1rem; flex-wrap: wrap; margin-top: .85rem; color: var(--muted); font-size: .78rem; }
.chart-legend span { display: inline-flex; align-items: center; gap: .35rem; }
.chart-legend i { width: 9px; height: 9px; border-radius: 50%; display: inline-block; }
.return-card { display: grid; gap: 1.25rem; background: #f3f0e7; }
.return-card p { margin-bottom: 0; }
.missed-list { display: grid; gap: .55rem; }
.missed-list .item { box-shadow: none; }
.bar { display: block; height: 5px; overflow: hidden; border-radius: 999px; background: #e7e5d9; }
.bar > i { display: block; height: 100%; background: var(--rust); }
.studied-ledger { display: grid; gap: 1rem; padding: clamp(1.1rem, 3vw, 1.5rem); border: 1px solid var(--line); border-radius: 20px; background: var(--paper); }
.studied-ledger header { display: flex; align-items: start; justify-content: space-between; flex-wrap: wrap; gap: 1rem; }
.studied-ledger h2 { margin: .35rem 0 0; }
.studied-ledger p { max-width: 48rem; margin-bottom: 0; }
.studied-ledger-scroll { max-height: min(70vh, 42rem); overflow: auto; border: 1px solid #e5e1d6; border-radius: 14px; background: #fffdf7; }
.studied-ledger table { width: max-content; min-width: 100%; border-collapse: separate; border-spacing: 0; font-size: .75rem; line-height: 1.4; }
.studied-ledger th, .studied-ledger td { max-width: 18rem; padding: .7rem .75rem; border-bottom: 1px solid #e9e6dc; vertical-align: top; text-align: left; overflow-wrap: anywhere; }
.studied-ledger th { position: sticky; top: 0; z-index: 1; color: var(--ink-soft); background: #f5f1e7; font-size: .68rem; letter-spacing: .06em; text-transform: uppercase; }
.studied-ledger tbody tr:last-child td { border-bottom: 0; }
.studied-ledger tbody tr:hover td { background: #faf4e9; }
.hints-page { gap: 1.25rem; }
.hints-intro { display: grid; gap: 1.1rem; padding: clamp(1.3rem, 4vw, 2.25rem); border: 1px solid #d9ddd3; border-radius: 24px; background: linear-gradient(120deg, #eef1e8, #fffdf7 55%, #f5e3d3); }
.hints-intro p { max-width: 44rem; margin-bottom: 0; color: var(--ink-soft); line-height: 1.65; }
.hint-sync-panel { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: .75rem; padding: .8rem .9rem; border: 1px solid #d9ddd3; border-radius: 15px; background: #fffdf7c7; }
.hint-sync-panel strong { color: var(--sage); font-size: .82rem; }
.hint-add-card, .hint-table-card { padding: clamp(1.05rem, 3vw, 1.5rem); border: 1px solid var(--line); border-radius: 20px; background: var(--paper); box-shadow: var(--shadow); }
.hint-add-card { display: grid; gap: .7rem; }
.hint-search-results { display: grid; overflow: hidden; border: 1px solid #e0e2d8; border-radius: 14px; }
.hint-search-result { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; align-items: center; gap: .8rem; width: 100%; padding: .72rem .85rem; border: 0; border-bottom: 1px solid #e8e9e1; border-radius: 0; color: var(--ink); background: transparent; text-align: left; box-shadow: none; }
.hint-search-result:last-child { border-bottom: 0; }
.hint-search-result:hover { color: var(--ink); background: #f6f2e9; box-shadow: none; transform: none; }
.hint-search-result span:first-child { min-width: 0; display: grid; gap: .13rem; }
.hint-search-result small, .hint-card-link small { color: var(--muted); font-size: .72rem; font-weight: 500; }
.hint-table-card { display: grid; gap: .9rem; }
.hint-table-card header { display: flex; align-items: end; justify-content: space-between; flex-wrap: wrap; gap: .8rem; }
.hint-table-card h2 { margin: .25rem 0 0; }
.hint-table-card header p { max-width: 25rem; margin: 0; }
.hint-table-scroll { max-height: min(68vh, 45rem); overflow: auto; border: 1px solid #e5e1d6; border-radius: 14px; background: #fffdf7; }
.hint-table-scroll table { width: max-content; min-width: 100%; border-collapse: separate; border-spacing: 0; font-size: .82rem; }
.hint-table-scroll th, .hint-table-scroll td { max-width: 27rem; padding: .72rem .78rem; border-bottom: 1px solid #e9e6dc; text-align: left; vertical-align: top; white-space: pre-wrap; overflow-wrap: anywhere; }
.hint-table-scroll th { position: sticky; z-index: 1; top: 0; color: var(--ink-soft); background: #f5f1e7; font-size: .68rem; letter-spacing: .06em; text-transform: uppercase; }
.hint-table-scroll tbody tr:last-child td { border-bottom: 0; }
.hint-table-scroll tbody tr:hover td { background: #faf4e9; }
.hint-card-link { display: grid; gap: .2rem; min-width: 14rem; padding: 0; border: 0; border-radius: 0; color: var(--ink); background: transparent; box-shadow: none; font-size: inherit; text-align: left; }
.hint-card-link:hover { color: var(--rust-dark); background: transparent; box-shadow: none; transform: none; }
.hint-card-link .rtl { font: 400 1.15rem/1.1 Georgia, serif; }
.hint-edit-cell { min-width: min(29rem, 70vw); outline: none; cursor: text; }
.hint-edit-cell:focus { position: relative; z-index: 2; background: #fffdf7; box-shadow: inset 0 0 0 2px #af8550; }
.hint-edit-cell:empty::before { color: #a5a99f; content: "Paste or write a hint…"; pointer-events: none; }
.hint-empty { padding: 1.2rem !important; color: var(--muted); text-align: center !important; }
.dig-page { gap: 1.25rem; }
.dig-intro { display: flex; align-items: end; justify-content: space-between; flex-wrap: wrap; gap: 1rem; padding: clamp(1.3rem, 4vw, 2.25rem); border: 1px solid #d9ddd3; border-radius: 24px; background: linear-gradient(120deg, #e7eee8, #fffdf7 58%, #e8eef0); }
.dig-intro p { max-width: 44rem; margin-bottom: 0; color: var(--ink-soft); line-height: 1.65; }
.dig-language-badge { padding: .5rem .7rem; border: 1px solid #c9d5cb; border-radius: 999px; color: var(--sage); background: #f8fcf7; font: 700 .7rem ui-monospace, SFMono-Regular, Menlo, monospace; letter-spacing: .06em; }
.dig-query-card, .dig-result-card { display: grid; gap: .9rem; padding: clamp(1.05rem, 3vw, 1.5rem); border: 1px solid var(--line); border-radius: 20px; background: var(--paper); box-shadow: var(--shadow); }
.dig-query-card header, .dig-query-card footer, .dig-result-card header { display: flex; align-items: end; justify-content: space-between; flex-wrap: wrap; gap: .75rem; }
.dig-query-card h2, .dig-result-card h2 { margin: .25rem 0 0; }
.dig-query-card header p, .dig-query-card footer .subtle { margin: 0; }
.dig-example-row { display: flex; flex-wrap: wrap; gap: .45rem; }
.sql-editor-shell { display: grid; gap: 0; overflow: hidden; border: 1px solid #263b36; border-radius: 14px; background: #1f302c; color: #e9efe6; box-shadow: inset 0 1px #ffffff0c; }
.sql-editor-shell > span { padding: .5rem .75rem; border-bottom: 1px solid #ffffff1a; color: #b3c6b6; font: 700 .68rem ui-monospace, SFMono-Regular, Menlo, monospace; letter-spacing: .12em; }
.sql-editor { min-height: 235px; padding: 1rem; border: 0; border-radius: 0; color: #eff5ec; background: transparent; box-shadow: none; font: .88rem/1.55 ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace; tab-size: 2; }
.sql-editor:focus { outline: 2px solid #d6b16f; outline-offset: -2px; }
.dig-result-card { min-width: 0; }
.dig-result-card .error { margin: 0; }
.dig-table-scroll { max-height: min(65vh, 44rem); overflow: auto; border: 1px solid #e5e1d6; border-radius: 14px; background: #fffdf7; }
.dig-table-scroll table { width: max-content; min-width: 100%; border-collapse: separate; border-spacing: 0; font-size: .78rem; }
.dig-table-scroll th, .dig-table-scroll td { max-width: 33rem; padding: .65rem .72rem; border-bottom: 1px solid #e9e6dc; text-align: left; vertical-align: top; }
.dig-table-scroll th { position: sticky; z-index: 1; top: 0; color: var(--ink-soft); background: #f5f1e7; font-size: .68rem; letter-spacing: .06em; text-transform: uppercase; }
.dig-table-scroll tbody tr:last-child td { border-bottom: 0; }
.dig-table-scroll td pre { max-width: 33rem; margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; font: .74rem/1.45 ui-monospace, SFMono-Regular, Menlo, monospace; }
.dig-empty { min-height: 12rem; align-content: center; }

@media (min-width: 620px) {
  .library-intro { grid-template-columns: minmax(0, 1fr) auto; align-items: end; }
  .quiz-intro { grid-template-columns: minmax(0, 1fr) auto; align-items: end; }
  .chapter-list { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .item-list { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .filter-panels, .quiz-footer { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .return-card { grid-template-columns: minmax(0, .8fr) minmax(0, 1.2fr); align-items: start; }
  .connections-intro { grid-template-columns: minmax(0, 1fr) auto; align-items: end; }
  .connection-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (min-width: 760px) {
  .shell { padding: 1.5rem 2rem 2.5rem; }
  .navigation { position: static; display: flex; justify-content: flex-start; gap: .35rem; margin: .15rem 0 2rem; padding: 0; border: 0; background: transparent; backdrop-filter: none; }
  .navigation a { padding: .55rem .85rem; border-radius: 999px; font-size: .8rem; }
  .navigation a::before { display: none; }
  .top { padding-top: .5rem; }
  .grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .section-list { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .collection-card { grid-template-columns: 42% 1fr; }
  .chapter-list { grid-template-columns: 1fr; }
  .browser-heading { grid-template-columns: minmax(0, 1fr) auto; align-items: end; }
  .browser-actions { justify-content: end; }
  .item-list { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .collision-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .overview-layout { grid-template-columns: minmax(0, 1.25fr) minmax(260px, .75fr); }
  .overview-hero { grid-column: 1 / -1; }
  .metric-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (min-width: 1050px) {
  .section-list { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .chapter-list { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .collection-card { grid-template-columns: 38% 1fr; }
  .root-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 540px) {
  .library-tally, .quiz-intro aside { width: 100%; }
  .collection-heading { align-items: start; flex-direction: column; }
  .collection-heading > p { text-align: left; }
  .card-toolbar { align-items: stretch; flex-direction: column; }
  .search-field { width: 100%; }
  .editor-heading, .quiz-session-top { align-items: start; flex-direction: column; }
  .progress-intro { grid-template-columns: 1fr; }
  .progress-seal { width: 132px; }
}
@media (max-width: 420px) {
  .shell { padding-right: .8rem; padding-left: .8rem; }
  .top { gap: 8px; }
  .brand-lockup { min-width: 0; gap: 7px; }
  .brand-lockup > span:last-child { min-width: 0; }
  .brand { font-size: 1.2rem; }
  .brand-mark { width: 34px; height: 34px; font-size: 18px; }
  .top .subtle { overflow-wrap: anywhere; font-size: .64rem; }
  .top-actions { flex-shrink: 0; gap: 5px; }
  .top-actions .flag-button { min-width: 32px; padding: 5px; font-size: .9rem; }
  .top-actions button { padding: 9px; font-size: 11px; white-space: nowrap; }
  .library-intro .page-title, .quiz-intro .page-title, .progress-intro .page-title { font-size: 3rem; }
  .collection-card { grid-template-columns: 110px 1fr; }
  .collection-copy { padding: .95rem; }
  .section-heading { font-size: 1.3rem; }
  .chapter-card { padding: .85rem; }
  .chapter-number { width: 34px; height: 34px; margin-right: .65rem; }
  .chapter-heading { font-size: 1.28rem; }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { scroll-behavior: auto !important; transition-duration: 0.01ms !important; animation-duration: 0.01ms !important; } }
