/* Тетрадката на Никола — хартия на квадратчета, синьо мастило, жълт маркер, червен химикал. */
:root {
    --paper: #f6f2e7;
    --paper-2: #fffdf7;
    --grid: rgba(29, 42, 74, .07);
    --ink: #1d2a4a;
    --ink-soft: #55607a;
    --line: #d9d2bf;
    --marker: #ffd84d;
    --red: #e0483e;
    --green: #2f9e6a;
    --radius: 14px;
    --shadow: 0 1px 0 rgba(29, 42, 74, .06), 0 8px 24px -12px rgba(29, 42, 74, .25);
    --display: 'Unbounded', 'Manrope', sans-serif;
    --body: 'Manrope', system-ui, sans-serif;
    --hand: 'Caveat', cursive;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }
body {
    font-family: var(--body);
    color: var(--ink);
    background-color: var(--paper);
    background-image:
        linear-gradient(var(--grid) 1px, transparent 1px),
        linear-gradient(90deg, var(--grid) 1px, transparent 1px);
    background-size: 22px 22px;
    min-height: 100vh;
    line-height: 1.45;
}
[hidden] { display: none !important; }
button, input, select { font: inherit; color: inherit; }
a { color: inherit; }
.i { flex-shrink: 0; vertical-align: -3px; }
.hand { font-family: var(--hand); font-size: 1.35rem; color: var(--ink-soft); font-weight: 600; }
mark { background: linear-gradient(transparent 55%, var(--marker) 55%, var(--marker) 92%, transparent 92%); color: inherit; padding: 0 .1em; }

/* ---------- Бутони ---------- */
.btn { border: 0; border-radius: 10px; padding: .75rem 1.2rem; font-weight: 700; cursor: pointer; transition: transform .12s, box-shadow .12s; }
.btn-ink { background: var(--ink); color: var(--paper-2); box-shadow: 3px 3px 0 var(--marker); }
.btn-ink:hover { transform: translate(-1px, -1px); box-shadow: 4px 4px 0 var(--marker); }
.btn-ink:active { transform: translate(2px, 2px); box-shadow: 1px 1px 0 var(--marker); }
.icon-btn { display: inline-grid; place-items: center; width: 34px; height: 34px; border-radius: 9px; border: 1px solid var(--line); background: var(--paper-2); cursor: pointer; }
.icon-btn:hover { background: var(--marker); border-color: var(--ink); }
.link-btn { background: none; border: 0; text-decoration: underline; cursor: pointer; color: var(--ink-soft); }

/* ---------- PIN ---------- */
.lock { position: fixed; inset: 0; display: grid; place-items: center; padding: 1.5rem; }
.lock-card { width: min(380px, 100%); background: var(--paper-2); border: 2px solid var(--ink); border-radius: var(--radius); padding: 2rem; box-shadow: 8px 8px 0 var(--ink); display: grid; gap: .9rem; text-align: center; animation: rise .5s ease-out; }
.lock-mark { font-family: var(--hand); font-size: 1.6rem; color: var(--red); transform: rotate(-4deg); }
.lock-mark span { color: var(--ink-soft); font-size: 1.2rem; }
.lock-card h1 { font-family: var(--display); font-size: 2rem; font-weight: 800; letter-spacing: -.02em; }
.lock-card p { color: var(--ink-soft); }
.lock-card input { text-align: center; font-size: 1.6rem; letter-spacing: .4em; padding: .6rem; border: 2px solid var(--line); border-radius: 10px; background: var(--paper); }
.lock-card input:focus { outline: none; border-color: var(--ink); }
.lock-error { color: var(--red); font-weight: 700; min-height: 1.4em; }

/* ---------- Подредба ---------- */
.app { max-width: 1180px; margin: 0 auto; padding: 1.5rem 1.1rem 3rem; display: grid; gap: 1.25rem; }
.app > * { animation: rise .55s ease-out both; }
.app > *:nth-child(2) { animation-delay: .07s; }
.app > *:nth-child(3) { animation-delay: .14s; }
.app > *:nth-child(4) { animation-delay: .21s; }
@keyframes rise { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }

.top { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: end; gap: 1rem; padding: .5rem .2rem 0; }
.top h1 { font-family: var(--display); font-weight: 800; font-size: clamp(1.9rem, 5vw, 3rem); letter-spacing: -.03em; line-height: 1.05; }
.top-hello .hand { text-transform: capitalize; }
.top-sub { margin-top: .4rem; color: var(--ink-soft); font-weight: 600; max-width: 52ch; }
.stats { display: flex; gap: .6rem; }
.stat { background: var(--paper-2); border: 2px solid var(--ink); border-radius: 12px; padding: .55rem .9rem; min-width: 92px; text-align: center; box-shadow: 3px 3px 0 var(--ink); }
.stat span { display: block; font-family: var(--display); font-weight: 700; font-size: 1.5rem; line-height: 1.1; }
.stat small { font-size: .72rem; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--ink-soft); }
.stat-flame { background: var(--marker); }

.grid { display: grid; grid-template-columns: minmax(0, 1.65fr) minmax(0, 1fr); gap: 1.25rem; align-items: start; }
.grid-bottom { grid-template-columns: 1fr 1fr; }
.side { display: grid; gap: 1.25rem; }

.card { background: var(--paper-2); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.25rem; box-shadow: var(--shadow); }
.card h2 { font-family: var(--display); font-weight: 700; font-size: 1.15rem; letter-spacing: -.01em; margin-bottom: .8rem; }
.card h2 small { font-size: 1.15rem; font-weight: 600; }
.card-head { display: flex; justify-content: space-between; align-items: baseline; gap: 1rem; flex-wrap: wrap; }
.sub-head { font-size: .8rem; text-transform: uppercase; letter-spacing: .08em; color: var(--red); margin: 1.2rem 0 .5rem; }
.empty { list-style: none; color: var(--ink-soft); font-style: italic; padding: .6rem 0; }

/* Днес: тетрадков ред с червено поле */
.card-today { position: relative; padding-left: 2.2rem; border: 2px solid var(--ink); box-shadow: 6px 6px 0 var(--ink); }
.card-today::before { content: ''; position: absolute; left: 1.2rem; top: 0; bottom: 0; width: 2px; background: rgba(224, 72, 62, .45); }
.progress { height: 10px; background: var(--paper); border-radius: 99px; border: 1px solid var(--line); overflow: hidden; margin-bottom: .9rem; }
.progress div { height: 100%; width: 0; background: repeating-linear-gradient(-45deg, var(--green) 0 8px, #3fb37c 8px 16px); transition: width .5s cubic-bezier(.2, .9, .3, 1.2); }

.tasks { list-style: none; display: grid; gap: .6rem; }
.task { display: grid; grid-template-columns: auto 1fr auto; gap: .8rem; align-items: start; padding: .8rem .9rem; border-radius: 12px; background: var(--paper); border-left: 5px solid var(--subj); transition: opacity .25s, background .25s; }
.task-meta { display: flex; flex-wrap: wrap; gap: .25rem .75rem; font-size: .78rem; color: var(--ink-soft); font-weight: 600; }
.subj { display: inline-block; font-weight: 800; color: #fff; background: var(--subj); padding: 0 .45rem; border-radius: 5px; font-size: .74rem; letter-spacing: .03em; }
.late { color: var(--red); }
.task-title { font-weight: 700; font-size: 1.02rem; margin-top: .15rem; }
.task-notes { color: var(--ink-soft); font-size: .9rem; margin-top: .2rem; }
.task-links { display: flex; flex-wrap: wrap; gap: .4rem; margin-top: .5rem; }
.chip { display: inline-flex; align-items: center; gap: .3rem; padding: .3rem .65rem; border-radius: 99px; font-size: .82rem; font-weight: 700; text-decoration: none; }
.chip-link { background: var(--ink); color: var(--paper-2); }
.chip-link:hover { background: var(--subj); }
.chip-ghost { border: 1px solid var(--line); }
.check { width: 34px; height: 34px; border-radius: 9px; border: 2px solid var(--ink); background: var(--paper-2); display: grid; place-items: center; cursor: pointer; color: transparent; transition: background .15s, transform .15s; }
.check:hover { background: var(--marker); }
.done-btn { align-self: center; border: 2px solid var(--ink); background: var(--marker); border-radius: 9px; padding: .45rem .8rem; font-weight: 800; cursor: pointer; font-size: .85rem; }
.done-btn:hover { transform: rotate(-2deg); }
.task.is-done { opacity: .6; background: transparent; }
.task.is-done .check { background: var(--green); border-color: var(--green); color: #fff; transform: rotate(-6deg); }
.task.is-done .task-title { text-decoration: line-through; text-decoration-color: var(--red); text-decoration-thickness: 2px; }
.task.is-done .done-btn { background: transparent; border-color: var(--line); color: var(--ink-soft); }
.tasks-compact .task { padding: .55rem .7rem; }
.later { margin-top: 1rem; }
.later summary { cursor: pointer; font-weight: 700; color: var(--ink-soft); }
.day-head { margin: .9rem 0 .4rem; font-size: .85rem; text-transform: capitalize; color: var(--ink-soft); }

/* Предстоящи */
.upcoming { list-style: none; display: grid; gap: .55rem; }
.up { display: flex; gap: .8rem; align-items: center; padding: .55rem; border-radius: 12px; background: var(--paper); }
.up-count { width: 52px; height: 52px; border-radius: 12px; border: 2px solid var(--subj); display: grid; place-content: center; text-align: center; line-height: 1; flex-shrink: 0; }
.up-count b { font-family: var(--display); font-size: 1.3rem; }
.up-count small { font-size: .65rem; font-weight: 700; color: var(--ink-soft); }
.up.is-hot .up-count { background: var(--red); border-color: var(--red); color: #fff; transform: rotate(-3deg); }
.up.is-hot .up-count small { color: #fff; }
.up-title { font-weight: 700; }
.up-meta { font-size: .8rem; color: var(--ink-soft); font-weight: 600; }

/* Утре */
.lessons { list-style: none; display: grid; gap: .1rem; }
.lessons li { display: flex; gap: .6rem; align-items: center; padding: .35rem 0; border-bottom: 1px dashed var(--line); }
.lessons li:last-child { border: 0; }
.lesson-time { font-variant-numeric: tabular-nums; font-size: .8rem; color: var(--ink-soft); font-weight: 700; width: 3.2em; }
.lesson-name { font-weight: 600; flex: 1; }
.lesson-name::before { content: ''; display: inline-block; width: 8px; height: 8px; border-radius: 2px; background: var(--subj); margin-right: .5rem; vertical-align: 1px; }
.flag { font-size: .75rem; font-weight: 800; color: #fff; background: var(--red); padding: .1rem .45rem; border-radius: 6px; }

/* Календар */
.cal-nav { display: flex; align-items: center; gap: .6rem; font-weight: 700; text-transform: capitalize; }
.cal-nav span { min-width: 9.5em; text-align: center; }
.cal-layout { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); gap: 1.25rem; }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.cal-wd { text-align: center; font-size: .75rem; font-weight: 800; color: var(--ink-soft); padding-bottom: .2rem; }
.cal-cell { position: relative; min-height: 72px; border: 1px solid var(--line); border-radius: 9px; background: var(--paper); padding: .3rem; text-align: left; cursor: pointer; display: flex; flex-direction: column; gap: 2px; transition: border-color .12s; }
.cal-cell:hover { border-color: var(--ink); }
.cal-cell.is-weekend { background: #efe9da; }
.cal-cell.is-other { opacity: .4; }
.cal-cell.is-today .cal-num { background: var(--marker); border-radius: 6px; padding: 0 .3rem; }
.cal-cell.is-selected { border: 2px solid var(--ink); box-shadow: 2px 2px 0 var(--ink); }
.cal-num { font-weight: 800; font-size: .85rem; align-self: flex-start; }
.cal-events { display: flex; flex-wrap: wrap; gap: 2px; }
.cal-ev { font-size: .62rem; font-weight: 800; padding: 0 .3rem; border-radius: 4px; border: 1px solid var(--subj); color: var(--subj); }
.cal-ev.urgent { background: var(--subj); color: #fff; }
.cal-tasks { position: absolute; right: 4px; top: 4px; font-size: .62rem; font-weight: 800; color: var(--ink-soft); }
.cal-tasks.all-done { color: var(--green); }
.cal-day h3 { font-family: var(--display); font-size: 1rem; text-transform: capitalize; margin-bottom: .6rem; }
.cal-list { list-style: none; display: grid; gap: .45rem; margin-bottom: 1rem; }
.cal-list li { display: flex; justify-content: space-between; gap: .5rem; padding: .5rem .6rem; border-radius: 10px; background: var(--paper); border-left: 4px solid var(--subj); font-size: .9rem; }
.cal-list li.empty { border: 0; background: none; }
.cal-list p { font-weight: 700; }
.cal-list small { display: block; color: var(--ink-soft); }
.cal-list .by { font-family: var(--hand); font-size: 1.05rem; }
.cal-task.is-done { opacity: .55; text-decoration: line-through; }
.cal-form { display: grid; gap: .5rem; padding: .9rem; border: 2px dashed var(--line); border-radius: 12px; }
.cal-form h4 { font-size: .9rem; display: flex; align-items: center; gap: .3rem; }
.cal-form .row { display: grid; grid-template-columns: 1fr 1.4fr; gap: .5rem; }
.cal-form input, .cal-form select { width: 100%; padding: .55rem .6rem; border: 1px solid var(--line); border-radius: 9px; background: var(--paper-2); font-size: .9rem; }
.cal-form input:focus, .cal-form select:focus { outline: 2px solid var(--marker); border-color: var(--ink); }

/* Слаби теми и резултати */
.reviews, .results { list-style: none; display: grid; gap: .45rem; }
.reviews li { display: flex; align-items: center; gap: .6rem; padding: .5rem .6rem; background: var(--paper); border-radius: 10px; }
.reviews li.is-due { outline: 2px solid var(--red); }
.rev-topic { flex: 1; font-weight: 600; }
.rev-steps { display: flex; gap: 3px; }
.rev-steps i { width: 9px; height: 9px; border-radius: 50%; border: 1.5px solid var(--subj); }
.rev-steps i.on { background: var(--subj); }
.rev-date { font-size: .78rem; font-weight: 700; color: var(--ink-soft); min-width: 5.5em; text-align: right; }
.results li { display: flex; align-items: center; gap: .8rem; padding: .45rem .6rem; background: var(--paper); border-radius: 10px; }
.res-pct { font-family: var(--display); font-weight: 700; width: 3.4em; text-align: center; padding: .25rem 0; border-radius: 8px; color: #fff; }
.res-pct.good { background: var(--green); }
.res-pct.mid { background: #d99a1e; }
.res-pct.low { background: var(--red); }
.res-title { font-weight: 700; display: grid; }
.res-title small { font-weight: 600; color: var(--ink-soft); }

.foot { display: flex; justify-content: space-between; gap: 1rem; flex-wrap: wrap; color: var(--ink-soft); font-size: .9rem; padding: 0 .2rem; }

/* Известия и конфети */
.toast { position: fixed; left: 50%; bottom: 1.5rem; transform: translateX(-50%); background: var(--ink); color: var(--paper-2); padding: .7rem 1.1rem; border-radius: 10px; font-weight: 700; box-shadow: 4px 4px 0 var(--marker); z-index: 20; transition: opacity .3s, transform .3s; }
.toast-error { box-shadow: 4px 4px 0 var(--red); }
.toast.out { opacity: 0; transform: translate(-50%, 10px); }
.confetti { position: fixed; top: 40vh; width: 9px; height: 14px; border-radius: 2px; z-index: 30; pointer-events: none; animation: confetti 1.3s ease-out forwards; }
@keyframes confetti {
    0% { transform: translate(0, 0) rotate(0); opacity: 1; }
    100% { transform: translate(var(--dx), 60vh) rotate(var(--r)); opacity: 0; }
}

/* ---------- Телефон ---------- */
@media (max-width: 860px) {
    .grid, .grid-bottom, .cal-layout { grid-template-columns: 1fr; }
    .stats { width: 100%; }
    .stat { flex: 1; min-width: 0; }
}
@media (max-width: 520px) {
    .app { padding: 1rem .7rem 2rem; }
    .card { padding: 1rem; }
    .card-today { padding-left: 1.6rem; }
    .card-today::before { left: .8rem; }
    .task { grid-template-columns: auto 1fr; }
    .done-btn { grid-column: 1 / -1; justify-self: stretch; }
    .cal-cell { min-height: 54px; padding: .2rem; }
    .cal-ev { font-size: .55rem; padding: 0 .15rem; }
}
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation: none !important; transition: none !important; }
}
