.hero { margin: 0 0 4px; border-radius: 14px; overflow: hidden; }
.hero img { display: block; width: 100%; max-height: 220px; object-fit: cover; }

/* formula renderer */
.fx { font-size: 17px; line-height: 1.5; overflow-wrap: break-word; }
.fx i { font-style: italic; }
.fx-var { padding-right: 0.03em; }
.fx-pn { padding: 0 0.04em; }
.fx-frac { display: inline-flex; flex-direction: column; text-align: center; vertical-align: middle; margin: 0.15em 0.22em; line-height: 1.3; }
.fx-frac > .fx-num { border-bottom: 1.5px solid currentColor; padding: 0.12em 0.35em 0.2em; }
.fx-frac > .fx-den { padding: 0.3em 0.35em 0.1em; }
.fx-base { white-space: nowrap; }
.fx-base sub, .fx-base sup { font-size: 0.72em; line-height: 0; margin-left: 0.05em; margin-right: 0.14em; }
.fx-ss { display: inline-flex; flex-direction: column; line-height: 1; vertical-align: middle; margin-left: 0.05em; margin-right: 0.14em; }
.fx-ss sup, .fx-ss sub { font-size: 0.66em; margin: 0; line-height: 1.15; }
.fx-sqrt { display: inline-flex; align-items: stretch; vertical-align: middle; margin: 0.15em 0.2em; }
.fx-rad { width: 0.8em; min-width: 11px; align-self: stretch; height: auto; flex: none; overflow: visible; }
.fx-sqrtbody { border-top: 1.5px solid currentColor; padding: 0.2em 0.2em 0.1em; display: flex; align-items: center; }
.fx-rootn { font-size: 0.62em; margin-right: -0.1em; align-self: flex-start; }
.fx-limop { display: inline-flex; align-items: center; gap: 0.25em; vertical-align: middle; margin: 0.1em 0.2em; }
.fx-lims { display: inline-flex; flex-direction: column; align-items: center; line-height: 1.1; }
.fx-limsym { font-size: 1.3em; line-height: 1.05; }
.fx-limtop, .fx-limbot { font-size: 0.66em; line-height: 1.2; white-space: nowrap; }
.fx-bar { border-top: 1.2px solid currentColor; padding-top: 0.06em; line-height: 1.2; display: inline-block; }


/* flashcard */
.flash { border: 1px solid var(--file-hairline, rgba(0,0,0,0.12)); border-radius: 16px; padding: 22px 18px; min-height: 200px; cursor: pointer; display: flex; align-items: center; justify-content: center; text-align: center; background: var(--file-surface, #fff); }
.flash:focus-visible { outline: 2px solid currentColor; outline-offset: 2px; }
.card-front { width: 100%; }
.card-eyebrow { font-size: 12px; letter-spacing: 0.08em; text-transform: uppercase; opacity: 0.6; margin: 0 0 10px; }
.card-name { font-size: 22px; font-weight: 600; margin: 0 0 14px; line-height: 1.25; }
.card-hint { font-size: 13px; opacity: 0.55; margin: 0; }
.card-back { width: 100%; text-align: left; }
.card-back .fx { text-align: center; margin-bottom: 6px; }
.card-list { margin: 8px 0; padding-left: 20px; font-size: 15px; line-height: 1.55; }
.card-list li { margin: 4px 0; }
.card-note { font-size: 14px; opacity: 0.8; margin: 10px 0 0; line-height: 1.5; }
.card-explain { margin: 12px 0 0; padding: 10px 12px; background: rgba(0,0,0,0.045); border-radius: 10px; font-size: 14px; line-height: 1.5; text-align: left; }
.card-explain-title { font-size: 11.5px; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; opacity: 0.55; margin: 0 0 6px; }
.card-explain ul { margin: 0; padding-left: 18px; }
.card-explain li { margin: 5px 0; }
.card-flag { font-size: 13px; background: #fff4d6; border: 1px solid #ecd27a; color: #6b5300; border-radius: 10px; padding: 8px 10px; margin: 10px 0 0; line-height: 1.45; }
.card-page { font-size: 12px; opacity: 0.5; margin: 12px 0 0; text-align: right; }
.card-table { border-collapse: collapse; width: 100%; font-size: 13.5px; margin: 10px 0; }
.card-table th, .card-table td { border: 1px solid rgba(0,0,0,0.15); padding: 5px 8px; text-align: left; }
.card-table th { background: rgba(0,0,0,0.05); font-weight: 600; }

.grade-row { display: flex; gap: 10px; margin-top: 12px; }
.grade-row .file-button { flex: 1; min-height: 46px; }
.button-row { display: flex; gap: 10px; margin-top: 10px; }
.empty-note { font-size: 15px; line-height: 1.5; }

/* home topic list */
.topic-list { display: flex; flex-direction: column; gap: 8px; }
.topic-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 10px 12px; border: 1px solid var(--file-hairline, rgba(0,0,0,0.12)); border-radius: 12px; }
.topic-name { font-size: 15.5px; font-weight: 600; margin: 0; }
.topic-detail { font-size: 12.5px; opacity: 0.6; margin: 2px 0 0; }
.topic-actions { display: flex; gap: 6px; flex-shrink: 0; }

/* browse */
.browse-section { margin-bottom: 14px; }
.browse-eyebrow { font-size: 12px; letter-spacing: 0.08em; text-transform: uppercase; opacity: 0.55; margin: 12px 0 6px; }
.browse-item { border-bottom: 1px solid var(--file-hairline, rgba(0,0,0,0.08)); }
.browse-row { display: flex; width: 100%; align-items: baseline; justify-content: space-between; gap: 10px; background: none; border: 0; padding: 10px 4px; font: inherit; text-align: left; cursor: pointer; min-height: 44px; }
.browse-name { font-size: 15px; font-weight: 500; }
.browse-meta { font-size: 12px; opacity: 0.55; white-space: nowrap; }
.browse-detail { padding: 6px 4px 14px; }

.grade-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.grade-btn { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 8px 2px; font-size: 14px; }
.grade-ivl { font-size: 11px; opacity: 0.65; font-weight: 400; }
.reveal-btn { width: 100%; margin-top: 12px; min-height: 46px; }
.nav-row { display: flex; gap: 10px; margin-top: 12px; }
.nav-row .file-button { flex: 1; min-height: 44px; }
.rated-note { font-size: 13px; opacity: 0.7; margin: 8px 0 0; text-align: center; }
.topic-row { flex-wrap: wrap; }
.topic-info { flex: 1 1 160px; min-width: 0; }
.topic-actions { flex: 0 0 auto; }
@media (max-width: 400px) { .grade-btn { font-size: 13px; } .grade-ivl { font-size: 10.5px; } }

.fx-br { display: inline-flex; align-items: stretch; vertical-align: middle; margin: 0 0.05em; }
.fx-brc { display: inline-block; padding: 0.05em 0.1em; }
.fx-brk-svg { width: 0.45em; min-width: 6px; flex: none; height: auto; align-self: stretch; overflow: visible; }

.card-list { list-style: none; padding-left: 0; }
.card-list li { position: relative; padding-left: 16px; margin: 6px 0; }
.card-list li::before { content: ''; position: absolute; left: 3px; top: 0.72em; width: 5px; height: 5px; border-radius: 50%; background: currentColor; opacity: 0.55; }
.card-list li.plain { padding-left: 16px; }
.card-list li.num { padding-left: 0; }
.card-list li.plain::before { display: none; }

/* long math: keep one expression on one line, scroll inside the card if too wide */
.fx:has(.fx-frac, .fx-sqrt, .fx-limop, .fx-ss) { white-space: nowrap; overflow-x: auto; overflow-y: hidden; max-width: 100%; padding-bottom: 4px; -webkit-overflow-scrolling: touch; }

/* standalone base styles (replace the hosted viewer kit) */
:root {
    --sand: #f4efec;
    --ink: #3d3229;
    --accent: #8a4b2d;
    --hairline: rgba(61, 50, 41, 0.14);
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
    margin: 0;
    background: var(--sand);
    color: var(--ink);
    font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Text', 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    font-size: 16px;
    line-height: 1.45;
}
.file-card { max-width: 640px; margin: 0 auto; padding: 16px 16px 48px; }
.file-header { margin: 14px 0 18px; }
.file-title { font-size: 26px; font-weight: 700; line-height: 1.2; margin: 0 0 6px; }
.file-fact { font-size: 14px; opacity: 0.65; margin: 0; }
.group { margin: 22px 0; }
.group-label { font-size: 13px; font-weight: 700; letter-spacing: 0.09em; text-transform: uppercase; opacity: 0.55; margin: 0 0 10px; }
.facts { margin: 0 0 4px; display: flex; flex-direction: column; gap: 8px; }
.fact { display: flex; align-items: baseline; justify-content: space-between; gap: 14px; border-bottom: 1px solid var(--hairline); padding-bottom: 8px; }
.fact dt { font-size: 14px; opacity: 0.65; }
.fact dd { margin: 0; font-size: 14.5px; font-weight: 600; text-align: right; }
.caption { font-size: 12.5px; opacity: 0.6; line-height: 1.5; margin: 10px 0 0; }
.closing { font-size: 12.5px; opacity: 0.55; line-height: 1.55; margin-top: 28px; border-top: 1px solid var(--hairline); padding-top: 14px; }
.file-button {
    appearance: none; border: 1px solid var(--hairline); border-radius: 999px;
    background: #fff; color: var(--ink); font: inherit; font-weight: 600;
    padding: 8px 14px; cursor: pointer; touch-action: manipulation;
}
.file-button:active { transform: scale(0.98); }
.file-button[data-variant="primary"] { background: var(--accent); border-color: var(--accent); color: #fff; }
.file-button[data-variant="secondary"] { background: #fff; }
.file-button.is-compact { font-size: 14px; padding: 7px 12px; }
.file-button:disabled { opacity: 0.45; }

/* Netlify's fixed "Powered by Netlify" badge (bottom-right, ~64px tall) must never
   permanently cover content: extra bottom room lets every control scroll fully clear. */
body { padding-bottom: 88px; }

/* Flip-through navigation sticks above the viewport's bottom edge so fixed hosting
   badges and mobile browser toolbars never cover Previous/Next. */
.flip-nav { position: sticky; bottom: 76px; z-index: 5; }
