@import url("https://fonts.googleapis.com/css2?family=DM+Mono:wght@400;500&family=Space+Grotesk:wght@400;500;600;700&display=swap");

:root {
    --bg: #f4f1ea;
    --surface: #fffdf7;
    --ink: #171717;
    --muted: #68665f;
    --line: #171717;
    --lime: #d9ff4f;
    --pink: #ff74b7;
    --blue: #91d7ff;
    --orange: #ff9a62;
    --shadow: 7px 7px 0 var(--ink);
    --soft-shadow: 3px 3px 0 var(--ink);
    --ease: 180ms cubic-bezier(.2,.8,.2,1);
}

body.dark-mode {
    --bg: #151515;
    --surface: #22211f;
    --ink: #f8f5ec;
    --muted: #b3aea3;
    --line: #f8f5ec;
    --lime: #c6ed36;
    --pink: #ff76bc;
    --blue: #7cc8f2;
    --orange: #ff925f;
    --shadow: 7px 7px 0 #000;
    --soft-shadow: 3px 3px 0 #000;
}
body.dark-mode .note-card, .note-card { mix-blend-mode: normal !important; }
html.dark-mode-preload body { background: #151515; color: #f8f5ec; }

* { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body {
    background: var(--bg);
    color: var(--ink);
    display: flex;
    flex-direction: column;
    font-family: "Space Grotesk", sans-serif;
    line-height: 1.5;
    min-height: 100vh;
    transition: background var(--ease), color var(--ease);
}
body::before {
    background-image: radial-gradient(var(--ink) 1px, transparent 1px);
    background-size: 18px 18px;
    content: "";
    inset: 0;
    opacity: .07;
    pointer-events: none;
    position: fixed;
    z-index: -1;
}
body.modal-open { overflow: hidden; }
.container { margin: 0 auto; max-width: 1160px; padding: 0 28px; width: 100%; }
.site-header { border-bottom: 2px solid var(--line); padding: 22px 0; }
.header-flex, .site-header > .container { align-items: center; display: flex; justify-content: space-between; gap: 24px; }
.header-actions { align-items: center; display: flex; gap: 14px; }
.logo { font-size: clamp(1.7rem, 4vw, 2.2rem); font-weight: 700; letter-spacing: -.1em; line-height: 1; }
.logo a { color: inherit; text-decoration: none; }
.logo span { background: var(--lime); color: #171717; display: inline-block; letter-spacing: -.08em; margin-left: 5px; padding: 3px 7px; transform: rotate(-3deg); }
.tagline, .eyebrow, .note-badge { font-family: "DM Mono", monospace; text-transform: uppercase; }
.tagline { color: var(--muted); font-size: .7rem; letter-spacing: .08em; margin-top: 9px; }
.theme-toggle, .back-btn { background: transparent; border: 1.5px solid var(--line); color: var(--ink); cursor: pointer; font: 500 .78rem "DM Mono", monospace; padding: 9px 12px; text-decoration: none; transition: var(--ease); }
.theme-toggle:hover, .back-btn:hover { background: var(--ink); color: var(--bg); transform: rotate(-2deg); }
.main-content { flex: 1; padding-bottom: 80px; padding-top: 72px; }
.hero { max-width: 780px; padding: 28px 0 50px; }
.eyebrow { color: var(--muted); font-size: .72rem; letter-spacing: .08em; margin-bottom: 18px; }
.hero h2, .subject-header h2 { font-size: clamp(3.3rem, 9vw, 7.3rem); letter-spacing: -.09em; line-height: .88; }
.hero h2 em { color: var(--pink); font-style: normal; }
.hero p:not(.eyebrow), .subject-header p { color: var(--muted); font-size: 1.05rem; margin-top: 25px; max-width: 480px; }
.subject-header { border-bottom: 2px solid var(--line); margin-bottom: 30px; padding-bottom: 32px; }
.subject-header h2 { font-size: clamp(2.6rem, 7vw, 5rem); }
.subject-grid, .notes-grid { display: grid; gap: 22px; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }
.subject-card, .note-card { border: 2px solid var(--line); box-shadow: var(--shadow); color: var(--ink); transition: var(--ease); }
.subject-card { align-items: center; display: flex; min-height: 190px; padding: 24px; text-decoration: none; }
.subject-card:nth-child(1) { background: var(--pink); transform: rotate(-1deg); }
.subject-card:nth-child(2) { background: var(--blue); transform: rotate(1deg); }
.subject-card:nth-child(3) { background: var(--orange); transform: rotate(-.5deg); }
.subject-card:hover, .note-card:hover { box-shadow: 11px 11px 0 var(--ink); transform: translate(-4px, -5px) rotate(0); }
.card-icon { align-items: center; background: var(--surface); border: 2px solid var(--line); display: flex; font-size: 2.4rem; height: 68px; justify-content: center; margin-right: 17px; width: 68px; }
.card-info { flex: 1; }
.card-info h3 { font-size: 1.45rem; letter-spacing: -.05em; }
.card-info p { font-size: .82rem; font-weight: 500; margin-top: 5px; }
.arrow { font-size: 1.8rem; font-weight: 700; }
.notes-grid { grid-template-columns: repeat(auto-fill, minmax(270px, 1fr)); }
.loading-state { align-items: center; color: var(--muted); display: flex; font: .78rem "DM Mono", monospace; gap: 12px; grid-column: 1 / -1; justify-content: center; min-height: 180px; text-transform: uppercase; }
.loader { animation: spin .8s linear infinite; border: 2px solid color-mix(in srgb, var(--ink) 20%, transparent); border-radius: 50%; border-top-color: var(--ink); display: inline-block; height: 22px; width: 22px; }
.loader-light { border-color: rgba(255,255,255,.3); border-top-color: #fff; }
.note-actions .is-busy { cursor: wait; opacity: .65; pointer-events: none; }
.note-card { animation: jitter 4s infinite; animation-delay: calc(var(--card-index) * -90ms); background: var(--surface); display: flex; flex-direction: column; justify-content: space-between; min-height: 230px; padding: 23px; transform: rotate(var(--card-rotation, 0deg)); }
.note-info h4 { font-size: 1.25rem; letter-spacing: -.04em; line-height: 1.1; margin-top: 12px; overflow-wrap: anywhere; }
.note-badge { background: var(--lime); border: 1.5px solid var(--line); color: #171717; display: inline-block; font-size: .64rem; mix-blend-mode: normal; padding: 4px 7px; }
.note-actions { display: flex; gap: 10px; margin-top: 25px; }
.btn { border: 1.5px solid var(--line); box-shadow: var(--soft-shadow); cursor: pointer; flex: 1; font: 600 .76rem "DM Mono", monospace; padding: 10px 8px; text-align: center; text-decoration: none; transition: var(--ease); }
.btn:hover { box-shadow: 5px 5px 0 var(--ink); transform: translate(-2px, -2px); }
.btn-primary { background: var(--ink); color: var(--bg); }
.btn-outline { background: transparent; color: var(--ink); }
.empty-state { border: 2px dashed var(--line); color: var(--muted); padding: 30px; }
.modal { align-items: center; background: rgba(0,0,0,.78); display: none; inset: 0; justify-content: center; padding: 20px; position: fixed; z-index: 10; }
.modal.active { display: flex; }
.modal-content { background: var(--surface); border: 2px solid var(--line); box-shadow: 9px 9px 0 #000; display: flex; flex-direction: column; height: min(86vh, 850px); max-width: 900px; overflow: hidden; width: 100%; }
.modal-header { align-items: center; border-bottom: 2px solid var(--line); display: flex; justify-content: space-between; padding: 14px 18px; }
.modal-header h3 { font-size: 1rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.close-btn { background: var(--ink); border: 1.5px solid var(--line); color: var(--bg); cursor: pointer; font-size: 1.3rem; height: 32px; width: 32px; }
.modal-body { background: #050505; display: flex; flex-direction: column; flex: 1; min-height: 0; }
.pdf-toolbar { align-items: center; background: var(--surface); border-bottom: 2px solid var(--line); color: var(--ink); display: flex; flex-wrap: wrap; gap: 8px; padding: 9px 12px; }
.pdf-control { background: var(--ink); border: 1px solid var(--line); color: var(--bg); cursor: pointer; font: 700 1rem "DM Mono", monospace; min-width: 30px; padding: 3px 8px; }
.pdf-control:hover { background: var(--pink); color: #171717; }
.pdf-toolbar span { font: .7rem "DM Mono", monospace; }
.pdf-search { background: transparent; border: 1px solid var(--line); color: var(--ink); font: .7rem "DM Mono", monospace; margin-left: auto; max-width: 190px; padding: 7px 9px; }
.pdf-search-status { color: var(--muted); min-width: 55px; }
#pdf-stage { align-items: flex-start; display: flex; flex: 1; justify-content: center; min-height: 0; overflow: auto; padding: 24px; }
#pdf-canvas { background: #fff; box-shadow: 0 4px 18px #000; display: block; max-width: 100%; }
.pdf-loading { align-items: center; background: rgba(5,5,5,.82); color: #fff; display: none; flex-direction: column; font: .72rem "DM Mono", monospace; gap: 13px; inset: 0; justify-content: center; position: absolute; text-align: center; z-index: 2; }
.pdf-loading.active { display: flex; }
#pdf-stage { position: relative; }
.site-footer { border-top: 2px solid var(--line); color: var(--muted); font: .7rem "DM Mono", monospace; padding: 22px 0; text-align: center; }

@keyframes jitter {
    0% { transform: translate(0px, 0px) rotate(var(--card-rotation, 0deg)); }
    20% { transform: translate(-2px, 1px) rotate(calc(var(--card-rotation, 0deg) + .4deg)); }
    40% { transform: translate(1px, -1px) rotate(calc(var(--card-rotation, 0deg) - .4deg)); }
    60% { transform: translate(-1px, 2px) rotate(calc(var(--card-rotation, 0deg) + .2deg)); }
    80% { transform: translate(2px, -2px) rotate(calc(var(--card-rotation, 0deg) - .3deg)); }
    100% { transform: translate(0px, 0px) rotate(var(--card-rotation, 0deg)); }
}

@media (max-width: 620px) {
    .container { padding: 0 19px; }
    .site-header > .container, .header-flex { align-items: flex-start; flex-direction: column; }
    .header-actions { width: 100%; }
    .theme-toggle { flex: 1; }
    .main-content { padding-top: 42px; }
    .hero h2 { font-size: 3.5rem; }
    .subject-card { min-height: 160px; }
    .main-content { padding-bottom: 48px; }
    .subject-grid, .notes-grid { gap: 16px; grid-template-columns: 1fr; }
    .note-card { min-height: 205px; padding: 18px; }
    .modal { padding: 0; }
    .modal-content { border-left: 0; border-right: 0; height: 100dvh; max-height: none; width: 100%; }
    .modal-header { padding: 12px 14px; }
    .pdf-toolbar { gap: 6px; padding: 8px; }
    .pdf-search { flex-basis: 100%; margin-left: 0; max-width: none; order: 2; }
    .pdf-search-status { order: 3; }
    #pdf-stage { padding: 12px 8px; }
    #pdf-canvas { max-width: none; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation-duration: .01ms !important; scroll-behavior: auto !important; transition-duration: .01ms !important; }
}

@keyframes spin { to { transform: rotate(360deg); } }

@media (max-width: 820px) {
    .container { padding-left: 22px; padding-right: 22px; }
    .main-content { padding-top: 52px; }
    .hero { padding-bottom: 36px; }
    .hero h2 { font-size: clamp(3rem, 10vw, 5.5rem); }
    .header-actions { gap: 9px; }
}
