/* ==========================================================================
   Study Lab — page chrome (input card, toolbar, toast).

   Stand-alone on purpose: the Lab does not load portal.css, so it can grow
   on its own without dragging the portal's shell along. The tokens mirror the
   portal's so the two still feel like one product. The notebook pages
   themselves live in notes.css and ignore the theme — paper is paper.
   ========================================================================== */

:root {
    color-scheme: light;
    --bg: #f6f8fc;
    --surface: #ffffff;
    --surface-2: #f1f4fa;
    --text: #131a2a;
    --text-soft: #3d4759;
    --muted: #6b7688;
    --line: #e2e8f2;
    --brand: #2f6df6;
    --brand-soft: rgba(47, 109, 246, .1);
    --brand-ink: #1b4bc4;
    --accent: #e8452f;
    --good: #12a06a;
    --bad: #de3b2f;
    --sheet-bg: #e7e2d6;
    --radius: 20px;
    --shadow: 0 2px 6px rgba(19, 26, 42, .05), 0 14px 40px rgba(19, 26, 42, .07);
}

html[data-theme="dark"] {
    color-scheme: dark;
    --bg: #0c0f15;
    --surface: #151a22;
    --surface-2: #1c222c;
    --text: #eef1f7;
    --text-soft: #c3cad6;
    --muted: #8a94a6;
    --line: #262d39;
    --brand: #5b8cff;
    --brand-soft: rgba(91, 140, 255, .14);
    --brand-ink: #9db8ff;
    --accent: #ff6a52;
    --sheet-bg: #1a1e26;
    --shadow: 0 2px 6px rgba(0, 0, 0, .3), 0 14px 40px rgba(0, 0, 0, .35);
}

* { box-sizing: border-box; }
/* Panels here set their own display (flex/grid), which would beat the
   attribute's default and leave a "hidden" panel showing. */
[hidden] { display: none !important; }
html, body { margin: 0; }
body {
    min-height: 100vh;
    background: var(--bg);
    color: var(--text);
    font: 15px/1.5 Inter, system-ui, -apple-system, 'Segoe UI', sans-serif;
    -webkit-font-smoothing: antialiased;
}
button { font: inherit; color: inherit; cursor: pointer; }
a { color: inherit; }

/* ---------- top bar ---------- */
.lab-top {
    position: sticky; top: 0; z-index: 20;
    display: flex; align-items: center; justify-content: space-between;
    gap: 12px;
    padding: 10px clamp(16px, 4vw, 32px);
    padding-top: max(10px, env(safe-area-inset-top));
    background: color-mix(in srgb, var(--bg) 86%, transparent);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--line);
}
.lab-brand { display: flex; align-items: center; gap: 10px; text-decoration: none; font-weight: 800; font-size: 17px; }
.lab-brand img { border-radius: 50%; }
.lab-brand em {
    font-style: normal; font-size: 12px; font-weight: 700;
    padding: 3px 9px; border-radius: 999px;
    background: var(--brand-soft); color: var(--brand-ink);
}
.lab-top-actions { display: flex; align-items: center; gap: 8px; }
.lab-link {
    display: inline-flex; align-items: center; gap: 7px;
    padding: 8px 14px; border-radius: 999px;
    text-decoration: none; font-weight: 600; font-size: 14px;
    background: var(--surface-2); border: 1px solid var(--line);
}
.lab-icon-btn {
    display: inline-grid; place-items: center;
    width: 38px; height: 38px; border-radius: 50%;
    background: var(--surface-2); border: 1px solid var(--line);
}

/* ---------- home ---------- */
.lab-home { max-width: 720px; margin: 0 auto; padding: 28px 16px 60px; }

.lab-hero { text-align: center; padding: 10px 4px 26px; }
.lab-hero h1 {
    margin: 0;
    font-size: clamp(28px, 6vw, 42px);
    line-height: 1.22;
    font-weight: 800;
    letter-spacing: -.5px;
}
.lab-hero h1 span {
    font-family: Kalam, cursive;
    font-weight: 700;
    color: var(--accent);
    background: linear-gradient(100deg, transparent 1%, rgba(255, 220, 60, .45) 3% 97%, transparent 99%) 0 78% / 100% 34% no-repeat;
}
.lab-hero p { margin: 14px auto 0; max-width: 540px; color: var(--text-soft); font-size: 16px; }

.lab-card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 18px;
}

.lab-tabs {
    display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px;
    padding: 5px; border-radius: 16px; background: var(--surface-2);
}
.lab-tab {
    display: flex; align-items: center; justify-content: center; gap: 8px;
    padding: 11px 6px; border: 0; border-radius: 12px;
    background: transparent; color: var(--muted); font-weight: 600;
}
.lab-tab i { font-size: 17px; }
.lab-tab.is-on { background: var(--surface); color: var(--text); box-shadow: 0 1px 3px rgba(0, 0, 0, .12); }
.lab-tab.is-on[data-src="pdf"] i { color: #e5482f; }
.lab-tab.is-on[data-src="youtube"] i { color: #ff0033; }
.lab-tab.is-on[data-src="text"] i { color: var(--brand); }
.lab-tab.is-on[data-src="photo"] i { color: var(--good); }

.lab-pane { display: none; padding-top: 16px; }
.lab-pane.is-on { display: block; }

.lab-drop {
    display: flex; flex-direction: column; align-items: center; gap: 6px;
    padding: 30px 16px; text-align: center; cursor: pointer;
    border: 2px dashed var(--line); border-radius: 16px;
    background: var(--surface-2);
    transition: border-color .15s, background .15s;
}
.lab-drop:hover, .lab-drop.is-over { border-color: var(--brand); background: var(--brand-soft); }
.lab-drop i { font-size: 30px; color: var(--brand); }
.lab-drop strong { font-size: 16px; }
.lab-drop small { color: var(--muted); }

.lab-files, .lab-thumbs { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.lab-file {
    display: flex; align-items: center; gap: 10px; width: 100%;
    padding: 10px 12px; border-radius: 12px;
    background: var(--surface-2); border: 1px solid var(--line);
}
.lab-file i.fa-file-pdf { color: #e5482f; font-size: 20px; }
.lab-file span { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
.lab-file small { color: var(--muted); }
.lab-x { border: 0; background: none; color: var(--muted); padding: 4px 6px; }
.lab-thumb { position: relative; width: 74px; height: 74px; border-radius: 10px; overflow: hidden; border: 1px solid var(--line); }
.lab-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.lab-thumb .lab-x {
    position: absolute; top: 3px; right: 3px; width: 22px; height: 22px; padding: 0;
    border-radius: 50%; background: rgba(0, 0, 0, .6); color: #fff; font-size: 12px;
}

.lab-field { display: flex; flex-direction: column; gap: 7px; font-weight: 600; font-size: 14px; }
.lab-field input, .lab-field textarea {
    width: 100%; padding: 13px 14px; border-radius: 12px;
    border: 1px solid var(--line); background: var(--surface-2); color: var(--text);
    font: 400 15px/1.5 Inter, system-ui, sans-serif; resize: vertical;
}
.lab-field input:focus, .lab-field textarea:focus { outline: 2px solid var(--brand); outline-offset: 1px; }
.lab-hint { margin: 8px 2px 0; font-size: 13px; color: var(--muted); }
.lab-hint.is-bad { color: var(--bad); }
.lab-hint.is-good { color: var(--good); }

.lab-row {
    display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 10px;
    margin-top: 18px; padding-top: 16px; border-top: 1px solid var(--line);
}
.lab-row-label { font-weight: 600; font-size: 14px; color: var(--text-soft); }
.lab-row-tight { margin-top: 10px; padding-top: 0; border-top: 0; }
.lab-chips { display: flex; gap: 6px; flex-wrap: wrap; }
.lab-chip {
    padding: 8px 16px; border-radius: 999px; font-weight: 600; font-size: 14px;
    border: 1px solid var(--line); background: var(--surface-2); color: var(--text-soft);
}
.lab-chip.is-on { background: var(--brand); border-color: var(--brand); color: #fff; }

.lab-go {
    display: flex; align-items: center; justify-content: center; gap: 10px;
    width: 100%; margin-top: 18px; padding: 15px; border: 0; border-radius: 14px;
    background: linear-gradient(135deg, #ff6a3d, #e8452f 55%, #c9324f);
    color: #fff; font-size: 17px; font-weight: 700;
    box-shadow: 0 10px 24px rgba(232, 69, 47, .3);
}
.lab-go:active { transform: translateY(1px); }
.lab-go:disabled { opacity: .6; cursor: wait; }
.lab-sample {
    display: block; width: 100%; margin-top: 10px; padding: 8px;
    border: 0; background: none; color: var(--muted); font-size: 14px;
}
.lab-sample b { color: var(--brand-ink); }

.lab-perks { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-top: 18px; }
.lab-perks div {
    display: flex; flex-direction: column; gap: 3px; padding: 14px;
    border-radius: 16px; background: var(--surface); border: 1px solid var(--line);
}
.lab-perks i { font-size: 18px; color: var(--accent); margin-bottom: 4px; }
.lab-perks b { font-size: 14px; }
.lab-perks span { font-size: 12.5px; color: var(--muted); line-height: 1.4; }

/* ---------- Gemini key ---------- */
.lab-key { margin-top: 16px; }
.lab-key-need {
    padding: 14px; border-radius: 16px;
    background: var(--brand-soft); border: 1px solid color-mix(in srgb, var(--brand) 30%, transparent);
}
.lab-key-head { display: flex; gap: 12px; align-items: flex-start; }
.lab-key-head i { font-size: 18px; color: var(--brand); margin-top: 3px; }
.lab-key-head b { display: block; font-size: 15px; }
.lab-key-head small { color: var(--text-soft); font-size: 13px; }
.lab-key-steps { margin: 10px 0 12px; padding-left: 50px; font-size: 13.5px; color: var(--text-soft); }
.lab-key-steps a { color: var(--brand-ink); font-weight: 700; }
.lab-key-row { display: flex; gap: 8px; }
.lab-key-row input {
    flex: 1; min-width: 0; padding: 11px 13px; border-radius: 12px;
    border: 1px solid var(--line); background: var(--surface); color: var(--text);
    font: 400 15px Inter, system-ui, sans-serif;
}
.lab-key-row input:focus { outline: 2px solid var(--brand); outline-offset: 1px; }
.lab-key-note {
    margin: 10px 0 0; padding: 8px 12px; border-radius: 10px;
    background: rgba(222, 59, 47, .12); color: var(--bad); font-size: 13.5px; font-weight: 600;
}
.lab-key-foot { margin: 10px 2px 0; font-size: 12.5px; color: var(--muted); }
.lab-key-foot a { color: var(--brand-ink); font-weight: 700; }
.lab-key-ok { display: flex; align-items: center; gap: 8px; font-size: 14px; font-weight: 600; color: var(--good); }
.lab-key-ok small { color: var(--muted); font-weight: 500; font-size: 12.5px; }
.lab-key-ok a { margin-left: auto; color: var(--muted); font-size: 13px; font-weight: 600; }
.lab-key-ok button { border: 0; background: none; color: var(--brand-ink); font-weight: 700; font-size: 13.5px; }

/* ---------- your notes ---------- */
.lab-recent { margin-top: 22px; }
.lab-recent h2 { margin: 0 4px 10px; font-size: 16px; }
.lab-recent-row {
    display: flex; align-items: center; gap: 4px; margin-bottom: 8px; padding-right: 6px;
    border-radius: 14px; background: var(--surface); border: 1px solid var(--line);
}
.lab-recent-open {
    flex: 1; min-width: 0; display: flex; align-items: center; gap: 12px;
    padding: 12px 14px; border: 0; background: none; text-align: left;
}
.lab-recent-open i { width: 20px; text-align: center; font-size: 17px; color: var(--accent); }
.lab-recent-open span { min-width: 0; display: flex; flex-direction: column; }
.lab-recent-open b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 14.5px; }
.lab-recent-open small { color: var(--muted); font-size: 12.5px; }

/* ---------- writing… ---------- */
.lab-busy {
    position: fixed; inset: 0; z-index: 40;
    display: grid; place-items: center; padding: 16px;
    background: rgba(8, 12, 20, .62); backdrop-filter: blur(4px);
}
.lab-busy[hidden] { display: none; }
.lab-busy-card {
    width: min(100%, 360px); padding: 26px 22px 14px; text-align: center;
    border-radius: 22px; background: var(--surface); border: 1px solid var(--line);
    box-shadow: 0 30px 70px rgba(0, 0, 0, .35);
    display: flex; flex-direction: column; align-items: center; gap: 6px;
}
.lab-busy-pen {
    width: 58px; height: 58px; display: grid; place-items: center; margin-bottom: 6px;
    border-radius: 50%; background: rgba(232, 69, 47, .12); color: var(--accent); font-size: 24px;
    animation: lab-write 1.1s ease-in-out infinite;
}
@keyframes lab-write {
    0%, 100% { transform: translate(-3px, 1px) rotate(-8deg); }
    50% { transform: translate(4px, -1px) rotate(6deg); }
}
.lab-busy-card b { font-size: 17px; }
.lab-busy-card small { min-height: 20px; color: var(--muted); font-size: 13.5px; }
.lab-busy-track { width: 100%; height: 7px; margin: 10px 0 4px; border-radius: 99px; background: var(--surface-2); overflow: hidden; }
.lab-busy-track span {
    display: block; height: 100%; width: 4%; border-radius: inherit;
    background: linear-gradient(90deg, #ff6a3d, #e8452f);
    transition: width .4s ease;
}
.lab-busy-track span.is-wait { width: 35% !important; animation: lab-wait 1.4s ease-in-out infinite; }
@keyframes lab-wait { 0% { transform: translateX(-100%); } 100% { transform: translateX(290%); } }

@media (prefers-reduced-motion: reduce) {
    .lab-busy-pen, .lab-busy-track span.is-wait { animation: none; }
}

/* ---------- notes view ---------- */
/* The notes toolbar replaces the top bar rather than stacking under it. */
body.is-notes .lab-top { display: none; }
.lab-notes { min-height: 100vh; background: var(--bg); }
body.is-paper .lab-notes { background: var(--sheet-bg); }
.lab-bar {
    position: sticky; top: 0; z-index: 20;
    display: flex; align-items: center; gap: 12px;
    padding: 10px clamp(12px, 3vw, 24px);
    padding-top: max(10px, env(safe-area-inset-top));
    background: var(--surface); border-bottom: 1px solid var(--line);
}
.lab-bar-title { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.lab-bar-title b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 15px; }
.lab-bar-title small { color: var(--muted); font-size: 12.5px; }
.lab-btn {
    display: inline-flex; align-items: center; gap: 8px;
    padding: 9px 16px; border: 0; border-radius: 999px;
    background: var(--brand); color: #fff; font-weight: 700; font-size: 14px;
}
.lab-sheets { padding: 20px 16px 10px; overflow-x: auto; }
.lab-sheets .nb-pages { width: max-content; margin: 0 auto; }
#zoomBtn[aria-pressed="true"] { background: var(--brand-soft); color: var(--brand-ink); border-color: var(--brand); }

/* ---------- overview: what the AI read, and what to make from it ---------- */
.lab-over { max-width: 760px; margin: 0 auto; padding: 20px 16px 60px; }
.ov-src {
    display: inline-flex; align-items: center; gap: 7px; max-width: 100%;
    padding: 4px 11px; border-radius: 999px;
    background: var(--surface-2); color: var(--muted); font-size: 12.5px; font-weight: 600;
}
.ov-src span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ov-src i { color: var(--accent); }
.ov-sample-lang { display: flex; align-items: center; flex-wrap: wrap; gap: 8px 12px; margin-top: 12px; color: var(--muted); font-size: 13.5px; font-weight: 600; }
.ov-sample-lang .lab-chip { padding: 6px 14px; font-size: 13.5px; }
.ov-head h1 { margin: 12px 0 0; font-size: clamp(22px, 5vw, 28px); line-height: 1.3; }
.ov-sub { margin: 4px 0 0; color: var(--muted); font-size: 14px; }
.ov-summary { margin: 12px 0 0; color: var(--text-soft); font-size: 15.5px; line-height: 1.6; }

.ov-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 12px; }
.ov-act {
    display: flex; flex-direction: column; gap: 12px; padding: 16px;
    border-radius: var(--radius); background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow);
}
.ov-act-head { display: flex; align-items: center; gap: 10px; font-size: 16px; }
.ov-act-head i {
    display: grid; place-items: center; width: 36px; height: 36px; border-radius: 12px;
    background: rgba(232, 69, 47, .12); color: var(--accent);
}
.ov-act .lab-chip { padding: 7px 13px; font-size: 13.5px; }
.ov-act-meta { min-height: 20px; color: var(--muted); font-size: 13px; line-height: 1.45; }
.ov-act-meta b { color: var(--good); }
.ov-go { margin-top: auto; padding: 13px; font-size: 15.5px; }
.ov-go.is-open { background: var(--brand); box-shadow: 0 8px 20px color-mix(in srgb, var(--brand) 30%, transparent); }
.ov-new { margin-top: -6px; padding: 4px; font-weight: 600; color: var(--brand-ink); }

.ov-topics { margin-top: 12px; }
.ov-topics h2 { margin: 0 0 10px; font-size: 16px; }
.ov-topics h2 small { color: var(--muted); font-weight: 600; }
.ov-topics ol { margin: 0; padding: 0; list-style: none; counter-reset: topic; }
.ov-topics li { counter-increment: topic; border-top: 1px solid var(--line); }
.ov-topics li:first-child { border-top: 0; }
.ov-topic {
    display: flex; gap: 12px; width: 100%; padding: 11px 2px;
    border: 0; background: none; text-align: left;
}
.ov-topic::before {
    content: counter(topic);
    flex: none; display: grid; place-items: center; width: 26px; height: 26px; margin-top: 1px;
    border-radius: 50%; background: var(--brand-soft); color: var(--brand-ink); font-size: 13px; font-weight: 800;
}
.ov-topic span { display: flex; flex-direction: column; min-width: 0; }
.ov-topic b { font-size: 15px; }
.ov-topic small { color: var(--muted); font-size: 13.5px; line-height: 1.45; }
button.ov-topic:hover b { color: var(--brand-ink); }
.ov-topic i { margin-left: auto; align-self: center; color: var(--muted); font-size: 12px; }

/* Tabs for something not made yet: tapping them makes it. */
.lab-views button.is-todo::after {
    content: ''; width: 7px; height: 7px; border-radius: 50%; background: var(--accent);
}

/* ---------- credits ---------- */
.lab-coins {
    display: inline-flex; align-items: center; gap: 7px; height: 38px;
    padding: 0 14px; border-radius: 999px;
    border: 1px solid rgba(224, 134, 0, .4); background: rgba(224, 134, 0, .1);
    color: var(--text); font-weight: 800; font-size: 14px;
}
.lab-coins i { color: #e08600; }
.lab-coins.is-low { border-color: var(--bad); background: rgba(222, 59, 47, .1); }

.lab-credits-box {
    display: flex; align-items: center; gap: 12px; margin-top: 14px; padding: 12px 14px;
    border-radius: 16px; background: rgba(224, 134, 0, .08); border: 1px solid rgba(224, 134, 0, .3);
}
.lab-credits-box > i { font-size: 22px; color: #e08600; }
.lab-credits-box > div { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.lab-credits-box b { font-size: 16px; }
.lab-credits-box small { color: var(--text-soft); font-size: 12.5px; line-height: 1.4; }
.lab-chip i { margin-right: 4px; }

.lab-video-cost {
    display: flex; gap: 8px; align-items: flex-start; margin: 10px 2px 0;
    font-size: 13px; line-height: 1.45; color: var(--text-soft);
}
.lab-video-cost i { margin-top: 2px; color: #e08600; }
.lab-refund-note {
    display: flex; gap: 10px; align-items: flex-start; margin: 0 0 14px; padding: 12px 14px;
    border-radius: 14px; background: rgba(18, 160, 106, .1); border: 1px solid rgba(18, 160, 106, .35);
    color: var(--text-soft); font-size: 14px; line-height: 1.5;
}
.lab-refund-note i { margin-top: 3px; color: var(--good); }
.lab-refund-note b { color: var(--text); }
.lab-entry-note {
    display: flex; gap: 10px; align-items: flex-start; margin: 14px 0 0; padding: 11px 14px;
    border-radius: 14px; background: var(--brand-soft); color: var(--text-soft); font-size: 13.5px; line-height: 1.45;
}
.lab-entry-note i { margin-top: 3px; color: var(--brand-ink); }
.cr-entry { margin: -2px 2px 12px; color: var(--text-soft); font-size: 13.5px; line-height: 1.5; }
.ov-pay { margin: 12px 4px 0; font-size: 13.5px; color: var(--text-soft); }
.ov-pay i { color: #e08600; margin-right: 4px; }
.ov-pay button { padding: 0; border: 0; background: none; color: var(--brand-ink); font-weight: 700; }

.cr-back {
    position: fixed; inset: 0; z-index: 45;
    display: grid; place-items: center; padding: 16px;
    background: rgba(8, 12, 20, .62); backdrop-filter: blur(4px);
}
.cr-card {
    width: min(100%, 460px); max-height: calc(100vh - 32px); overflow-y: auto;
    padding: 18px 18px 20px; border-radius: 22px;
    background: var(--surface); border: 1px solid var(--line); box-shadow: 0 30px 70px rgba(0, 0, 0, .35);
}
.cr-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.cr-head h2 { margin: 0; font-size: 18px; }
.cr-head h2 i { color: #e08600; margin-right: 6px; }
.cr-balance { display: flex; align-items: baseline; gap: 8px; margin: 14px 0 4px; }
.cr-num { font-size: 40px; line-height: 1; font-weight: 800; }
.cr-balance span { color: var(--muted); font-weight: 600; }
.cr-reason { margin: 8px 0 0; padding: 9px 12px; border-radius: 12px; background: rgba(222, 59, 47, .1); color: var(--bad); font-size: 13.5px; font-weight: 600; }
.cr-card h3 { margin: 18px 0 10px; font-size: 14px; color: var(--text-soft); text-transform: uppercase; letter-spacing: .05em; }
.cr-packs { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
.cr-pack {
    position: relative; display: flex; flex-direction: column; align-items: flex-start; gap: 2px;
    padding: 12px 14px; border-radius: 14px; text-align: left;
    border: 1.5px solid var(--line); background: var(--surface-2);
}
.cr-pack b { font-size: 20px; }
.cr-pack span { color: var(--muted); font-size: 13px; font-weight: 600; }
.cr-pack.is-on { border-color: #e8452f; background: rgba(232, 69, 47, .08); }
.cr-pack .cr-tag {
    position: absolute; top: -9px; right: 10px; padding: 2px 8px; border-radius: 999px;
    background: #12a06a; color: #fff; font-size: 11px; font-weight: 800;
}
.cr-buyer { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 12px; }
.cr-buyer label { display: flex; flex-direction: column; gap: 5px; font-size: 12.5px; font-weight: 600; color: var(--text-soft); }
.cr-buyer input {
    width: 100%; padding: 10px 12px; border-radius: 12px;
    border: 1px solid var(--line); background: var(--surface-2); color: var(--text); font: 400 15px Inter, system-ui, sans-serif;
}
.cr-buyer input:focus { outline: 2px solid var(--brand); outline-offset: 1px; }
.cr-error { margin: 10px 0 0; color: var(--bad); font-size: 13.5px; font-weight: 600; }
.cr-pay { margin-top: 12px; }
.cr-prices { margin: 10px 2px 0; color: var(--muted); font-size: 12.5px; line-height: 1.5; }
.cr-prices b { color: var(--text-soft); }
.cr-history { margin: 0; padding: 0; list-style: none; }
.cr-history li { display: flex; align-items: center; gap: 10px; padding: 9px 2px; border-top: 1px solid var(--line); }
.cr-history li:first-child { border-top: 0; }
.cr-history span { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.cr-history b { font-size: 13.5px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cr-history small { color: var(--muted); font-size: 12px; }
.cr-history em { font-style: normal; font-weight: 800; }
.cr-history em.is-in { color: var(--good); }
.cr-history em.is-out { color: var(--bad); }
.cr-empty { color: var(--muted); font-size: 13.5px; }

/* ---------- toast ---------- */
.lab-toast {
    position: fixed; left: 50%; bottom: calc(22px + env(safe-area-inset-bottom)); z-index: 50;
    max-width: min(92vw, 460px);
    padding: 12px 18px; border-radius: 14px;
    background: #1b2233; color: #fff; font-size: 14px; text-align: center;
    box-shadow: 0 12px 30px rgba(0, 0, 0, .3);
    opacity: 0; transform: translate(-50%, 12px); pointer-events: none;
    transition: opacity .2s, transform .2s;
}
.lab-toast.is-on { opacity: 1; transform: translate(-50%, 0); }

@media (max-width: 560px) {
    .lab-tab { flex-direction: column; gap: 3px; font-size: 12.5px; padding: 9px 4px; }
    .lab-perks { grid-template-columns: 1fr; }
    .lab-perks div { flex-direction: row; align-items: center; gap: 10px; }
    .lab-perks i { margin: 0; width: 22px; text-align: center; }
    .lab-perks span { display: none; }
    .lab-link span { display: none; }
    .lab-link { padding: 0; width: 38px; height: 38px; justify-content: center; }
    .lab-btn span { display: none; }
    .ov-actions { grid-template-columns: 1fr; }
    .lab-credits-box { flex-wrap: wrap; }
    .lab-credits-box .lab-btn { width: 100%; justify-content: center; }
    .cr-buyer { grid-template-columns: 1fr; }
    .lab-coins { padding: 0 11px; }
    /* Room for the credits chip: the logo and "Study Lab" say enough. */
    .lab-brand > span { display: none; }
    .lab-brand em { white-space: nowrap; }
    /* Three tabs plus zoom and PDF: only the open tab keeps its label. */
    .lab-views button:not(.is-on) span { display: none; }
}

/* ---------- print: only the sheets ---------- */
@media print {
    .lab-chrome { display: none !important; }
    html, body, .lab-notes { background: #fff !important; min-height: 0 !important; }
    /* A scroll container can reserve a scrollbar's height — a blank sheet. */
    .lab-sheets { padding: 0; overflow: visible; }
}
