/* AgriNotes - design system.  Dark paddy-green + turmeric by default, "lime-wash" light theme. */
:root {
  --font-ui: 'Bricolage Grotesque', system-ui, 'Nirmala UI', 'Noto Sans Devanagari', 'Mukta', -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  --font-read: 'Source Serif 4', Georgia, 'Times New Roman', 'Nirmala UI', 'Noto Serif Devanagari', 'Mangal', serif;
  --r-lg: 22px; --r-md: 14px; --r-sm: 10px;
  --nav-w: 248px;
  --ease: cubic-bezier(.2, .8, .2, 1);
}
[data-theme="dark"] {
  --bg: #0b1613; --bg-2: #0f1d19; --surface: #13241f; --surface-2: #1a302a; --surface-3: #21392f;
  --line: #27413a; --line-2: #36574c; --text: #e8f0e7; --muted: #97b0a4; --faint: #6b8478;
  --accent: #f2b632; --accent-ink: #201600; --accent-text: #f6c453; --accent-soft: rgba(242, 182, 50, .15);
  --leaf: #6fd08c; --leaf-soft: rgba(111, 208, 140, .15); --sky: #7cc4ff; --sky-soft: rgba(124, 196, 255, .14);
  --chili: #ff7a66; --chili-soft: rgba(255, 107, 87, .15);
  --shadow: 0 22px 50px -28px rgba(0, 0, 0, .75); --mark: rgba(242, 182, 50, .32);
  --bg-img: radial-gradient(1100px 560px at 88% -12%, rgba(111, 208, 140, .11), transparent 62%), radial-gradient(900px 520px at -8% 108%, rgba(242, 182, 50, .075), transparent 60%);
  color-scheme: dark;
}
[data-theme="light"] {
  --bg: #edf2e6; --bg-2: #e3ebdb; --surface: #fbfdf8; --surface-2: #eff5e9; --surface-3: #e3ecdb;
  --line: #d2decb; --line-2: #bacdb0; --text: #122620; --muted: #526a5f; --faint: #7a8f84;
  --accent: #f2b632; --accent-ink: #201600; --accent-text: #8a5b00; --accent-soft: rgba(242, 182, 50, .22);
  --leaf: #2a8f50; --leaf-soft: rgba(42, 143, 80, .13); --sky: #1b72b8; --sky-soft: rgba(27, 114, 184, .11);
  --chili: #cf3e2b; --chili-soft: rgba(207, 62, 43, .1);
  --shadow: 0 22px 44px -30px rgba(26, 62, 40, .5); --mark: rgba(242, 182, 50, .45);
  --bg-img: radial-gradient(1100px 560px at 88% -12%, rgba(42, 143, 80, .10), transparent 62%), radial-gradient(900px 520px at -8% 108%, rgba(242, 182, 50, .14), transparent 60%);
  color-scheme: light;
}
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body { margin: 0; font-family: var(--font-ui); font-size: 16px; line-height: 1.55; color: var(--text); background: var(--bg-img), var(--bg); background-attachment: fixed; min-height: 100vh; -webkit-font-smoothing: antialiased; font-variant-numeric: tabular-nums; }
img, svg { max-width: 100%; }
a { color: var(--accent-text); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 3px; }
h1, h2, h3, h4 { font-weight: 600; letter-spacing: -.015em; line-height: 1.2; margin: 0; }
h1 { font-size: clamp(1.7rem, 1.2rem + 1.7vw, 2.6rem); letter-spacing: -.028em; }
h2 { font-size: 1.28rem; } h3 { font-size: 1.05rem; }
p { margin: 0 0 .8em; }
.muted { color: var(--muted); } .faint { color: var(--faint); } .small { font-size: .86rem; } .nowrap { white-space: nowrap; }
.right { text-align: right; } .center { text-align: center; } .mt { margin-top: 1.25rem; } .mt-s { margin-top: .6rem; } .mb { margin-bottom: 1.25rem; }
.row { display: flex; gap: .75rem; align-items: center; flex-wrap: wrap; } .row.between { justify-content: space-between; } .grow { flex: 1 1 auto; min-width: 0; }
.stack > * + * { margin-top: 1rem; } .stack, .split > *, .reader > * { min-width: 0; }
.skip { position: absolute; left: -999px; top: 8px; background: var(--accent); color: var(--accent-ink); padding: .5rem .8rem; border-radius: 8px; z-index: 999; }
.skip:focus { left: 8px; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px; }
::selection { background: var(--accent); color: var(--accent-ink); }
[hidden] { display: none !important; }
kbd { font: 500 .72rem var(--font-ui); border: 1px solid var(--line-2); border-bottom-width: 2px; padding: 1px 6px; border-radius: 6px; color: var(--muted); background: var(--surface-2); }
mark { background: var(--mark); color: inherit; padding: 0 2px; border-radius: 3px; }

/* icons */
.i { width: 1.25em; height: 1.25em; flex: none; vertical-align: -.2em; }
.when-light { display: none; } [data-theme="light"] .when-light { display: inline-block; } [data-theme="light"] .when-dark { display: none; }

/* ---------- shell ---------- */
.shell { display: grid; grid-template-columns: var(--nav-w) minmax(0, 1fr); min-height: 100vh; }
.rail { position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; padding: 18px 14px; border-right: 1px solid var(--line); background: color-mix(in srgb, var(--bg-2) 80%, transparent); backdrop-filter: blur(12px); z-index: 40; overflow-y: auto; }
.brand { display: flex; align-items: center; gap: .65rem; color: var(--text); font-weight: 650; font-size: 1.15rem; letter-spacing: -.02em; padding: 4px 10px 18px; }
.brand:hover { text-decoration: none; }
.brand-mark { display: grid; place-items: center; width: 38px; height: 38px; border-radius: 12px; background: var(--accent); color: var(--accent-ink); transform: rotate(-6deg); }
.brand-mark .i { width: 22px; height: 22px; }
.brand-name small { display: block; font-size: .72rem; font-weight: 500; color: var(--muted); letter-spacing: 0; margin-top: -3px; }
.rail-nav { display: grid; gap: 3px; }
.rail-link { display: flex; align-items: center; gap: .75rem; padding: .62rem .8rem; border-radius: 12px; color: var(--muted); font-weight: 500; position: relative; transition: background .15s, color .15s; }
.rail-link:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.rail-link.active { background: var(--accent-soft); color: var(--text); }
.rail-link.active::before { content: ''; position: absolute; left: -14px; top: 9px; bottom: 9px; width: 4px; border-radius: 0 4px 4px 0; background: var(--accent); }
.rail-link .i { width: 20px; height: 20px; }
.rail-foot { margin-top: auto; padding-top: 14px; border-top: 1px solid var(--line); display: grid; gap: 3px; }
.badge-n { margin-left: auto; font-style: normal; font-size: .72rem; font-weight: 700; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 99px; display: grid; place-items: center; background: var(--accent); color: var(--accent-ink); }
.stage { min-width: 0; display: flex; flex-direction: column; }
.topbar { position: sticky; top: 0; z-index: 30; display: flex; align-items: center; gap: .9rem; padding: 12px clamp(16px, 3vw, 36px); background: color-mix(in srgb, var(--bg) 78%, transparent); backdrop-filter: blur(14px); border-bottom: 1px solid var(--line); }
.brand-sm { display: none; padding: 0; }
.gsearch { position: relative; flex: 1 1 auto; max-width: 560px; display: flex; align-items: center; }
.gsearch > .i { position: absolute; left: 14px; color: var(--faint); pointer-events: none; }
.gsearch input { width: 100%; padding: .68rem 4.4rem .68rem 2.7rem; border-radius: 14px; border: 1px solid var(--line); background: var(--surface); color: var(--text); font: inherit; }
.gsearch input::placeholder { color: var(--faint); }
.gsearch kbd { position: absolute; right: 10px; pointer-events: none; }
.top-actions { display: flex; align-items: center; gap: .4rem; margin-left: auto; }
.icon-btn { position: relative; display: grid; place-items: center; width: 42px; height: 42px; border-radius: 12px; border: 1px solid transparent; background: transparent; color: var(--muted); cursor: pointer; }
.icon-btn:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.dot-n { position: absolute; top: 3px; right: 2px; font-style: normal; font-size: .66rem; font-weight: 700; min-width: 18px; height: 18px; padding: 0 4px; border-radius: 9px; display: grid; place-items: center; background: var(--chili); color: #fff; }
.avatar { width: 40px; height: 40px; border-radius: 50%; border: 2px solid var(--line-2); background: var(--surface-3); color: var(--text); font: 600 .85rem var(--font-ui); cursor: pointer; }
.menu { position: relative; }
.menu-pop { position: absolute; right: 0; top: calc(100% + 8px); min-width: 230px; padding: 8px; border-radius: 16px; background: var(--surface); border: 1px solid var(--line-2); box-shadow: var(--shadow); z-index: 60; }
.menu-pop a { display: flex; gap: .6rem; align-items: center; padding: .55rem .7rem; border-radius: 10px; color: var(--text); }
.menu-pop a:hover { background: var(--surface-2); text-decoration: none; }
.menu-head { padding: .5rem .7rem .7rem; border-bottom: 1px solid var(--line); margin-bottom: 6px; display: grid; }
.menu-head span { color: var(--muted); font-size: .84rem; overflow: hidden; text-overflow: ellipsis; }
.main { width: 100%; max-width: 1260px; padding: clamp(18px, 3vw, 38px); margin: 0 auto; flex: 1; }
.main.narrow { max-width: 860px; }
.phead { display: flex; justify-content: space-between; align-items: flex-end; gap: 1rem; flex-wrap: wrap; margin-bottom: 1.6rem; }
.phead p { margin: .35rem 0 0; max-width: 62ch; }
.phead-actions { display: flex; gap: .6rem; flex-wrap: wrap; }
.tabbar { display: none; }
.scrim { position: fixed; inset: 0; background: rgba(0, 0, 0, .55); z-index: 35; }

@media (max-width: 1099px) {
  :root { --nav-w: 78px; }
  .rail { padding: 14px 10px; align-items: center; }
  .rail .brand-name, .rail-link span, .rail-link .badge-n { display: none; }
  .rail-link { justify-content: center; padding: .7rem; } .rail-link.active::before { left: -10px; }
  .brand { padding: 4px 0 16px; }
}
@media (max-width: 759px) {
  .shell { grid-template-columns: minmax(0, 1fr); }
  .rail { position: fixed; left: 0; top: 0; bottom: 0; width: min(290px, 84vw); transform: translateX(-102%); transition: transform .28s var(--ease); align-items: stretch; background: var(--bg-2); }
  .rail.open { transform: none; box-shadow: var(--shadow); }
  .rail .brand-name, .rail-link span { display: initial; } .rail-link .badge-n { display: grid; } .rail-link { justify-content: flex-start; padding: .62rem .8rem; }
  .brand-sm { display: flex; } .gsearch kbd { display: none; } .gsearch input { padding-right: 1rem; }
  .tabbar { display: grid; grid-template-columns: repeat(6, 1fr); position: fixed; left: 0; right: 0; bottom: 0; z-index: 34; padding: 6px 6px calc(6px + env(safe-area-inset-bottom)); background: color-mix(in srgb, var(--bg-2) 88%, transparent); backdrop-filter: blur(16px); border-top: 1px solid var(--line); }
  .tab { display: grid; justify-items: center; gap: 2px; padding: 6px 2px; border-radius: 12px; color: var(--muted); font: 500 .68rem var(--font-ui); background: none; border: 0; cursor: pointer; }
  .tab:hover { text-decoration: none; } .tab.active { color: var(--text); background: var(--accent-soft); }
  .main { padding-bottom: 96px; }
  .top-actions .icon-btn:first-child { display: none; }
}

/* ---------- buttons / forms ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: .5rem; padding: .62rem 1.05rem; border-radius: 12px; border: 1px solid var(--line-2); background: var(--surface-2); color: var(--text); font: 600 .94rem var(--font-ui); cursor: pointer; transition: transform .12s var(--ease), background .15s, border-color .15s; white-space: nowrap; }
.btn:hover { text-decoration: none; border-color: var(--faint); background: var(--surface-3); }
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { background: color-mix(in srgb, var(--accent) 88%, white); }
.btn.ghost { background: transparent; } .btn.sm { padding: .38rem .7rem; font-size: .85rem; border-radius: 10px; }
.btn.danger { background: var(--chili-soft); border-color: transparent; color: var(--chili); } .btn.danger:hover { background: var(--chili); color: #fff; }
.btn.ok { background: var(--leaf-soft); border-color: transparent; color: var(--leaf); } .btn.ok:hover { background: var(--leaf); color: #04200f; }
.btn.block { width: 100%; } .btn[disabled] { opacity: .5; pointer-events: none; }
.btn .i { width: 1.1em; height: 1.1em; }
.field { display: grid; gap: .35rem; margin-bottom: 1rem; }
.field > label, .lbl { font-weight: 600; font-size: .88rem; color: var(--muted); }
.input, .select, .textarea, .field input:not([type=checkbox]):not([type=radio]):not([type=file]):not([type=color]), .field select, .field textarea { width: 100%; padding: .66rem .85rem; border-radius: 12px; border: 1px solid var(--line-2); background: var(--surface); color: var(--text); font: inherit; }
.textarea, .field textarea { min-height: 110px; resize: vertical; }
.input:focus, .select:focus, .textarea:focus, .field input:focus, .field select:focus, .field textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.hint { font-size: .82rem; color: var(--faint); }
.check { display: flex; gap: .6rem; align-items: center; cursor: pointer; }
.check input { width: 18px; height: 18px; accent-color: var(--accent); }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 0 1rem; }
.flash { display: flex; gap: .7rem; align-items: flex-start; padding: .8rem 1rem; border-radius: 14px; margin-bottom: 1.2rem; border: 1px solid var(--line-2); background: var(--surface); }
.flash.ok { border-color: var(--leaf); background: var(--leaf-soft); } .flash.err { border-color: var(--chili); background: var(--chili-soft); } .flash.warn { border-color: var(--accent); background: var(--accent-soft); }

/* ---------- surfaces ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); padding: clamp(16px, 2vw, 24px); box-shadow: var(--shadow); }
.card.flat { box-shadow: none; } .card.tight { padding: 14px 16px; }
.card h2 + .muted { margin-top: .25rem; }
.grid { display: grid; gap: 1rem; } .grid.c2 { grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); } .grid.c3 { grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); } .grid.c4 { grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); }
.split { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); gap: 1.2rem; } @media (max-width: 1000px) { .split { grid-template-columns: minmax(0, 1fr); } }
.chip { display: inline-flex; align-items: center; gap: .35rem; padding: .18rem .6rem; border-radius: 99px; font-size: .78rem; font-weight: 600; background: var(--surface-3); color: var(--muted); white-space: nowrap; }
.chip.ok { background: var(--leaf-soft); color: var(--leaf); } .chip.warn { background: var(--accent-soft); color: var(--accent-text); } .chip.err { background: var(--chili-soft); color: var(--chili); } .chip.info { background: var(--sky-soft); color: var(--sky); }
.chip .i { width: 1em; height: 1em; }
.empty { text-align: center; padding: 2.4rem 1rem; color: var(--muted); } .empty .i { width: 34px; height: 34px; color: var(--faint); margin-bottom: .5rem; }
.divider { height: 1px; background: var(--line); margin: 1.2rem 0; border: 0; }

/* progress bits */
.bar { display: block; height: 7px; border-radius: 99px; background: var(--surface-3); overflow: hidden; }
.bar i { display: block; height: 100%; border-radius: 99px; background: linear-gradient(90deg, var(--leaf), color-mix(in srgb, var(--leaf) 55%, var(--accent))); transition: width .5s var(--ease); }
.ring { position: relative; display: inline-grid; place-items: center; flex: none; }
.ring svg { position: absolute; inset: 0; width: 100%; height: 100%; }
.ring-bg { fill: none; stroke: var(--surface-3); stroke-width: 3.2; } .ring-fg { fill: none; stroke: var(--leaf); stroke-width: 3.2; stroke-linecap: round; transition: stroke-dasharray .6s var(--ease); }
.ring-i { width: 46%; height: 46%; color: var(--leaf); position: relative; } .ring-n { position: relative; font-size: .85em; }
.ring.lg .ring-i { width: 40%; height: 40%; }

/* ---------- tables ---------- */
.tbl-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--r-md); background: var(--surface); }
.tbl { width: 100%; border-collapse: collapse; font-size: .93rem; }
.tbl th { text-align: left; font-weight: 600; color: var(--muted); font-size: .8rem; padding: .7rem .9rem; background: var(--surface-2); border-bottom: 1px solid var(--line); white-space: nowrap; }
.tbl td { padding: .7rem .9rem; border-bottom: 1px solid var(--line); vertical-align: middle; }
.tbl tr:last-child td { border-bottom: 0; } .tbl tbody tr:hover { background: color-mix(in srgb, var(--surface-2) 70%, transparent); }
.tbl .actions { display: flex; gap: .35rem; justify-content: flex-end; }
.tabs { display: flex; gap: .3rem; flex-wrap: wrap; margin-bottom: 1.2rem; padding: 4px; border-radius: 14px; background: var(--surface); border: 1px solid var(--line); width: fit-content; max-width: 100%; overflow-x: auto; }
.tabs a { padding: .45rem .9rem; border-radius: 10px; color: var(--muted); font-weight: 600; font-size: .9rem; white-space: nowrap; } .tabs a:hover { text-decoration: none; color: var(--text); }
.tabs a.active { background: var(--accent); color: var(--accent-ink); } .tabs .n { opacity: .7; margin-left: .3rem; font-weight: 500; }
.pager { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-top: 1.2rem; flex-wrap: wrap; }

/* ---------- autocomplete ---------- */
.ac-wrap { position: relative; }
.ac-pop { position: absolute; left: 0; right: 0; top: calc(100% + 6px); background: var(--surface); border: 1px solid var(--line-2); border-radius: 16px; box-shadow: var(--shadow); z-index: 70; padding: 6px; max-height: min(420px, 62vh); overflow-y: auto; min-width: 280px; }
.ac-item { display: flex; gap: .7rem; align-items: center; padding: .55rem .7rem; border-radius: 10px; color: var(--text); cursor: pointer; }
.ac-item .i { color: var(--faint); width: 1.1rem; height: 1.1rem; } .ac-item small { display: block; color: var(--muted); font-size: .78rem; }
.ac-item b { font-weight: 600; } .ac-item.on, .ac-item:hover { background: var(--surface-3); text-decoration: none; }
.ac-all { border-top: 1px solid var(--line); margin-top: 4px; padding-top: 8px; }
.ac-empty { padding: .8rem; color: var(--muted); font-size: .9rem; }

/* ---------- modal & toast ---------- */
dialog.modal { border: 1px solid var(--line-2); border-radius: 20px; background: var(--surface); color: var(--text); padding: 0; width: min(460px, 92vw); box-shadow: var(--shadow); }
dialog.modal::backdrop { background: rgba(3, 10, 8, .66); backdrop-filter: blur(3px); }
.modal-in { padding: 22px; } .modal-in h3 { margin-bottom: .5rem; } .modal-actions { display: flex; justify-content: flex-end; gap: .6rem; margin-top: 1.2rem; }
.toasts { position: fixed; right: 18px; bottom: 18px; display: grid; gap: 8px; z-index: 120; max-width: min(380px, 92vw); }
.toast { display: flex; gap: .6rem; align-items: center; padding: .75rem 1rem; border-radius: 14px; background: var(--surface-3); border: 1px solid var(--line-2); box-shadow: var(--shadow); animation: toast-in .25s var(--ease); }
.toast.ok .i { color: var(--leaf); } .toast.err .i { color: var(--chili); }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }
@media (max-width: 759px) { .toasts { bottom: 84px; } }

/* ---------- protection ---------- */
body[data-protect] { -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
body[data-protect] input, body[data-protect] textarea { -webkit-user-select: text; user-select: text; }
body[data-protect] img { -webkit-user-drag: none; user-drag: none; }
.wm { position: fixed; inset: 0; pointer-events: none; z-index: 90; background-repeat: repeat; }
.shield { position: fixed; inset: 0; z-index: 200; display: grid; place-items: center; text-align: center; background: color-mix(in srgb, var(--bg) 92%, transparent); backdrop-filter: blur(22px); cursor: pointer; padding: 2rem; }
.shield .i { width: 38px; height: 38px; color: var(--accent); } .shield p { font-weight: 600; margin: .6rem 0 .2rem; }
body.blackout::after { content: ''; position: fixed; inset: 0; background: #000; z-index: 300; }
@media print { body[data-protect] > * { display: none !important; } body[data-protect]::before { content: 'Printing is turned off for this library.'; display: block; padding: 2rem; font-size: 1.2rem; } }

/* ---------- public pages (login / register / landing) ---------- */
body.public { background: var(--bg-img), var(--bg); }
.auth { min-height: 100vh; display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr); }
.auth-art { position: relative; overflow: hidden; padding: clamp(28px, 5vw, 64px); display: flex; flex-direction: column; justify-content: space-between; background: linear-gradient(160deg, #123a2b, #0b1f19 70%); color: #e8f0e7; border-right: 1px solid var(--line); }
[data-theme="light"] .auth-art { background: linear-gradient(160deg, #1d5a3f, #0f3326 80%); }
.auth-art .contour { position: absolute; inset: 0; width: 100%; height: 100%; color: rgba(242, 182, 50, .32); }
.auth-art > * { position: relative; }
.auth-art h1 { font-size: clamp(2.1rem, 1.2rem + 3.4vw, 4rem); letter-spacing: -.04em; line-height: 1.02; max-width: 12ch; }
.auth-art p { color: #b5ccc0; max-width: 40ch; font-size: 1.05rem; }
.auth-stats { display: flex; gap: 1.6rem; flex-wrap: wrap; } .auth-stats b { display: block; font-size: 1.8rem; letter-spacing: -.03em; color: var(--accent); } .auth-stats span { color: #9db8ab; font-size: .86rem; }
.auth-form { display: grid; align-content: center; padding: clamp(24px, 5vw, 64px); }
.auth-card { width: min(440px, 100%); margin: 0 auto; }
.auth-card h2 { font-size: 1.7rem; letter-spacing: -.03em; margin-bottom: .3rem; }
.auth-top { position: absolute; right: 18px; top: 14px; z-index: 5; }
@media (max-width: 900px) { .auth { grid-template-columns: minmax(0, 1fr); } .auth-art { min-height: 280px; border-right: 0; border-bottom: 1px solid var(--line); } .auth-art h1 { font-size: 2.2rem; } }
.pw-wrap { position: relative; } .pw-wrap button { position: absolute; right: 6px; top: 50%; transform: translateY(-50%); }
.state-card { text-align: center; padding: 2rem 1.4rem; } .state-card .big { width: 64px; height: 64px; border-radius: 20px; display: grid; place-items: center; margin: 0 auto 1rem; background: var(--accent-soft); color: var(--accent-text); } .state-card .big .i { width: 32px; height: 32px; }

/* ---------- subjects ---------- */
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(262px, 1fr)); gap: 1rem; }
.tile { position: relative; display: flex; flex-direction: column; border-radius: var(--r-lg); background: var(--surface); border: 1px solid var(--line); overflow: hidden; color: var(--text); transition: transform .2s var(--ease), border-color .2s, box-shadow .2s; }
.tile:hover { text-decoration: none; transform: translateY(-3px); border-color: hsl(var(--h) 50% 50% / .7); box-shadow: var(--shadow); }
.tile-top { position: relative; height: 112px; padding: 14px 16px; background: linear-gradient(135deg, hsl(var(--h) 52% 24%), hsl(var(--h) 46% 13%)); color: hsl(var(--h) 80% 78%); display: flex; justify-content: space-between; align-items: flex-start; overflow: hidden; }
[data-theme="light"] .tile-top { background: linear-gradient(135deg, hsl(var(--h) 52% 38%), hsl(var(--h) 55% 24%)); color: hsl(var(--h) 90% 88%); }
.tile-top .contour { position: absolute; inset: 0; width: 100%; height: 100%; color: hsl(var(--h) 85% 72% / .55); }
.tile-code { position: relative; font-weight: 700; font-size: 1.5rem; letter-spacing: -.03em; color: #fff; text-shadow: 0 2px 14px rgba(0, 0, 0, .4); }
.tile-top .ring { position: relative; background: rgba(5, 15, 10, .35); border-radius: 50%; backdrop-filter: blur(4px); } .tile-top .ring-bg { stroke: rgba(255, 255, 255, .18); } .tile-top .ring-fg, .tile-top .ring-i { stroke: #fff; color: #fff; }
.tile-body { padding: 14px 16px 16px; display: grid; gap: .5rem; flex: 1; align-content: start; }
.tile-title { font-weight: 600; line-height: 1.25; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; min-height: 2.5em; }
.tile-meta { display: flex; gap: .4rem; flex-wrap: wrap; }
.fav-btn { position: absolute; right: 10px; top: 10px; z-index: 3; } .tile .fav-btn { top: auto; bottom: 10px; right: 8px; }
.fav { display: inline-grid; place-items: center; width: 34px; height: 34px; border-radius: 10px; border: 0; background: transparent; color: var(--faint); cursor: pointer; }
.fav:hover { background: var(--surface-3); color: var(--accent-text); } .fav.on { color: var(--accent); } .fav.on .i { fill: currentColor; }
.filters { display: flex; gap: .5rem; flex-wrap: wrap; margin-bottom: 1.3rem; align-items: center; }
.fchip { padding: .38rem .85rem; border-radius: 99px; border: 1px solid var(--line-2); background: var(--surface); color: var(--muted); font-weight: 600; font-size: .86rem; cursor: pointer; }
.fchip:hover { text-decoration: none; color: var(--text); } .fchip.on { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }

/* topic > sub-topic tree */
.subj-hero { position: relative; overflow: hidden; border-radius: var(--r-lg); padding: clamp(18px, 3vw, 32px); margin-bottom: 1.4rem; border: 1px solid var(--line); background: linear-gradient(135deg, hsl(var(--h) 50% 20%), hsl(var(--h) 44% 11%)); color: #e9f3ec; display: flex; gap: 1.4rem; align-items: center; flex-wrap: wrap; }
[data-theme="light"] .subj-hero { background: linear-gradient(135deg, hsl(var(--h) 50% 30%), hsl(var(--h) 52% 18%)); }
.subj-hero .contour { position: absolute; inset: 0; width: 100%; height: 100%; color: hsl(var(--h) 85% 72% / .4); }
.subj-hero > * { position: relative; } .subj-hero h1 { color: #fff; font-size: clamp(1.5rem, 1rem + 1.6vw, 2.4rem); } .subj-hero .muted { color: #b3cdbd; }
.subj-hero .ring-bg { stroke: rgba(255, 255, 255, .18); } .subj-hero .ring-fg, .subj-hero .ring-i { stroke: #fff; color: #fff; }
.subj-hero .chip { background: rgba(255, 255, 255, .13); color: #e9f3ec; }
.topic { border: 1px solid var(--line); border-radius: var(--r-md); background: var(--surface); margin-bottom: .6rem; overflow: hidden; }
.topic[open] { border-color: var(--line-2); } .topic > summary { list-style: none; display: flex; align-items: center; gap: .9rem; padding: .85rem 1rem; cursor: pointer; }
.topic > summary::-webkit-details-marker { display: none; }
.topic > summary .chev { transition: transform .2s; color: var(--faint); } .topic[open] > summary .chev { transform: rotate(90deg); }
.topic-t { font-weight: 600; flex: 1; min-width: 0; } .topic-t small { display: block; color: var(--muted); font-weight: 400; font-size: .8rem; }
.topic-prog { width: 120px; flex: none; text-align: right; font-size: .8rem; color: var(--muted); } .topic-prog .bar { margin-top: 4px; }
.topic.done > summary .topic-t { color: var(--muted); }
.prows { border-top: 1px solid var(--line); }
.prow { display: flex; align-items: center; gap: .6rem; padding: .5rem .8rem .5rem .6rem; border-bottom: 1px solid var(--line); color: var(--text); } .prow:last-child { border-bottom: 0; }
.prow:hover { background: var(--surface-2); text-decoration: none; }
.prow-t { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; } .prow-t small { color: var(--faint); margin-right: .5rem; }
.prow.read .prow-t { color: var(--muted); }
.tick { display: grid; place-items: center; width: 30px; height: 30px; border-radius: 9px; border: 2px solid var(--line-2); background: transparent; color: transparent; cursor: pointer; flex: none; transition: all .15s; }
.tick:hover { border-color: var(--leaf); } .tick.on { background: var(--leaf); border-color: var(--leaf); color: #04200f; } .tick .i { width: 18px; height: 18px; stroke-width: 3; }
.unread-only .prow.read { display: none; }

/* ---------- reader ---------- */
.reader { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 1.4rem; align-items: start; }
@media (max-width: 1180px) { .reader { grid-template-columns: minmax(0, 1fr); } }
.crumbs { display: flex; flex-wrap: wrap; gap: .35rem; align-items: center; font-size: .86rem; color: var(--muted); margin-bottom: 1rem; } .crumbs .i { width: 14px; height: 14px; color: var(--faint); } .crumbs a { color: var(--muted); } .crumbs a:hover { color: var(--text); }
.sheet { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); padding: clamp(18px, 3.2vw, 44px); box-shadow: var(--shadow); }
.sheet-head { display: flex; justify-content: space-between; gap: 1rem; flex-wrap: wrap; margin-bottom: 1.2rem; padding-bottom: 1rem; border-bottom: 1px dashed var(--line-2); }
.sheet-head h1 { font-size: clamp(1.3rem, 1rem + 1vw, 1.9rem); }
.note-text, .note-html { font-family: var(--font-read); font-size: var(--read-size, 1.12rem); line-height: 1.78; max-width: 74ch; overflow-wrap: anywhere; }
.note-text { white-space: pre-wrap; }
.note-html h2 { font-family: var(--font-ui); margin: 1.4em 0 .5em; } .note-html h3, .note-html h4 { font-family: var(--font-ui); margin: 1.2em 0 .4em; }
.note-html table { border-collapse: collapse; width: 100%; margin: 1em 0; font-size: .88em; overflow-wrap: normal; word-break: normal; display: block; max-width: 100%; overflow-x: auto; } .note-html td, .note-html th { overflow-wrap: break-word; } .note-html th, .note-html td { border: 1px solid var(--line-2); padding: .4rem .5rem; text-align: left; } .note-html th { background: var(--surface-2); }
.note-html img { border-radius: 12px; margin: .8em 0; } .note-html blockquote { margin: 1em 0; padding: .2em 1em; border-left: 4px solid var(--accent); background: var(--surface-2); border-radius: 0 10px 10px 0; }
.note-html pre { background: var(--surface-2); padding: .8rem 1rem; border-radius: 10px; overflow: auto; font-size: .9em; } .note-html ul, .note-html ol { padding-left: 1.4em; }
.scan { margin-top: 1.4rem; border: 1px solid var(--line); border-radius: var(--r-md); overflow: hidden; background: #fff; } .scan img { display: block; width: 100%; height: auto; }
.ocr-note { display: flex; gap: .7rem; padding: .75rem 1rem; border-radius: 12px; background: var(--accent-soft); color: var(--text); font-size: .9rem; margin-bottom: 1.2rem; }
.reader-nav { position: sticky; bottom: 12px; z-index: 20; display: flex; gap: .6rem; justify-content: space-between; align-items: center; margin-top: 1.4rem; padding: .6rem; border-radius: 18px; background: color-mix(in srgb, var(--surface-2) 90%, transparent); backdrop-filter: blur(14px); border: 1px solid var(--line-2); box-shadow: var(--shadow); }
@media (max-width: 759px) { .reader-nav { bottom: 78px; } }
.side { display: grid; gap: 1rem; position: sticky; top: 84px; } @media (max-width: 1180px) { .side { position: static; } }
.side h3 { font-size: .95rem; margin-bottom: .6rem; }
.note-area { width: 100%; min-height: 120px; padding: .7rem; border-radius: 12px; border: 1px solid var(--line-2); background: var(--surface-2); color: var(--text); font: inherit; resize: vertical; }

/* ---------- dashboard / stats ---------- */
.stat { display: flex; gap: 1rem; align-items: center; }
.stat b { display: block; font-size: 1.9rem; letter-spacing: -.035em; line-height: 1.05; } .stat span { color: var(--muted); font-size: .86rem; }
.stat .ico { width: 46px; height: 46px; border-radius: 14px; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent-text); flex: none; } .stat .ico.leaf { background: var(--leaf-soft); color: var(--leaf); } .stat .ico.sky { background: var(--sky-soft); color: var(--sky); } .stat .ico.chili { background: var(--chili-soft); color: var(--chili); }
.announce { display: flex; gap: .9rem; padding: 1rem 1.2rem; border-radius: var(--r-md); background: linear-gradient(90deg, var(--accent-soft), transparent); border: 1px solid color-mix(in srgb, var(--accent) 40%, var(--line)); margin-bottom: 1.2rem; } .announce .i { color: var(--accent-text); margin-top: 3px; }
.hello h1 em { font-style: normal; color: var(--accent-text); }
.list { display: grid; } .list-item { display: flex; flex-wrap: wrap; gap: .5rem .8rem; align-items: center; padding: .7rem 0; border-bottom: 1px solid var(--line); color: var(--text); } .list-item:last-child { border-bottom: 0; } a.list-item:hover { text-decoration: none; color: var(--accent-text); }
.list-item .grow { flex: 1 1 12rem; min-width: 0; overflow-wrap: anywhere; } .list-item .grow small { display: block; color: var(--muted); }
.cal { display: grid; grid-auto-flow: column; grid-template-rows: repeat(7, 14px); gap: 4px; overflow-x: auto; padding-bottom: 6px; } .cal i { width: 14px; height: 14px; border-radius: 4px; background: var(--surface-3); display: block; }
.cal i.l1 { background: color-mix(in srgb, var(--leaf) 35%, var(--surface-3)); } .cal i.l2 { background: color-mix(in srgb, var(--leaf) 60%, var(--surface-3)); } .cal i.l3 { background: var(--leaf); } .cal i.l4 { background: var(--accent); }
.badge-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: .8rem; } .badge-i { text-align: center; padding: 1rem .6rem; border-radius: var(--r-md); border: 1px dashed var(--line-2); color: var(--faint); } .badge-i .i { width: 30px; height: 30px; } .badge-i.got { border-style: solid; border-color: var(--accent); background: var(--accent-soft); color: var(--text); } .badge-i.got .i { color: var(--accent-text); } .badge-i b { display: block; font-size: .9rem; margin-top: .3rem; } .badge-i span { font-size: .76rem; color: var(--muted); }

/* ---------- search ---------- */
.result { display: block; padding: 1rem 1.1rem; border: 1px solid var(--line); border-radius: var(--r-md); background: var(--surface); margin-bottom: .7rem; color: var(--text); } .result:hover { text-decoration: none; border-color: var(--line-2); background: var(--surface-2); }
.result h3 { font-size: 1rem; margin-bottom: .2rem; } .result p { color: var(--muted); font-size: .92rem; margin: .3rem 0 0; font-family: var(--font-read); }

@media (prefers-reduced-motion: reduce) { * { scroll-behavior: auto !important; transition-duration: .01ms !important; } }
/* ---------- admin ---------- */
.is-admin .rail { background: color-mix(in srgb, #0a1411 85%, var(--bg-2)); }
[data-theme="light"] .is-admin .rail { background: #17352a; border-color: #17352a; } [data-theme="light"] .is-admin .rail * { --muted: #b3cdbd; --text: #f0f7f1; }
.kpi { display: grid; grid-template-columns: repeat(auto-fit, minmax(176px, 1fr)); gap: 1rem; margin-bottom: 1.4rem; }
.bars { display: flex; align-items: flex-end; gap: 6px; height: 140px; padding-top: 8px; } .bars .col { flex: 1; display: grid; gap: 4px; align-content: end; justify-items: center; height: 100%; } .bars .col i { width: 100%; max-width: 28px; border-radius: 6px 6px 3px 3px; background: linear-gradient(180deg, var(--accent), color-mix(in srgb, var(--accent) 40%, var(--leaf))); min-height: 3px; display: block; } .bars .col span { font-size: .68rem; color: var(--faint); }
.hbar { display: grid; grid-template-columns: 110px 1fr 46px; gap: .7rem; align-items: center; font-size: .88rem; margin-bottom: .5rem; } .hbar .bar { height: 10px; }
.toolbar { display: flex; gap: .6rem; flex-wrap: wrap; align-items: center; margin-bottom: 1rem; } .toolbar .grow { max-width: 360px; }
.editor { max-width: 100%; min-width: 0; border: 1px solid var(--line-2); border-radius: var(--r-md); background: var(--surface); }
.ed-bar { display: flex; flex-wrap: wrap; gap: 2px; padding: 8px; background: var(--surface-2); border-bottom: 1px solid var(--line); position: sticky; top: 72px; z-index: 5; border-radius: var(--r-md) var(--r-md) 0 0; }
.ed-btn { display: grid; place-items: center; min-width: 34px; height: 34px; padding: 0 6px; border-radius: 8px; border: 0; background: transparent; color: var(--text); cursor: pointer; font: 600 .82rem var(--font-ui); } .ed-btn:hover { background: var(--surface-3); } .ed-btn.on { background: var(--accent-soft); color: var(--accent-text); }
.ed-sep { width: 1px; background: var(--line-2); margin: 4px 4px; } .ed-select { height: 34px; border-radius: 8px; border: 1px solid var(--line-2); background: var(--surface); color: var(--text); font: inherit; font-size: .84rem; padding: 0 6px; }
.ed-area { min-height: 420px; max-width: 100%; overflow-x: auto; padding: 20px 24px; outline: none; font-family: var(--font-read); font-size: 1.08rem; line-height: 1.75; } .ed-src { width: 100%; min-height: 420px; border: 0; padding: 16px; background: var(--surface); color: var(--text); font: .85rem/1.5 ui-monospace, Menlo, Consolas, monospace; resize: vertical; }
.ed-area table { border-collapse: collapse; width: 100%; } .ed-area td, .ed-area th { border: 1px solid var(--line-2); padding: .4rem .6rem; } .ed-area img { max-width: 100%; border-radius: 10px; }
.side-by-side { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 1.2rem; align-items: start; } @media (max-width: 1100px) { .side-by-side { grid-template-columns: minmax(0, 1fr); } }
.media-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: .9rem; } .media-i { border: 1px solid var(--line); border-radius: var(--r-md); background: var(--surface); overflow: hidden; } .media-i img { width: 100%; aspect-ratio: 4/3; object-fit: cover; display: block; background: var(--surface-3); } .media-i div { padding: .6rem .7rem; font-size: .8rem; color: var(--muted); }
.drop { border: 2px dashed var(--line-2); border-radius: var(--r-md); padding: 1.4rem; text-align: center; color: var(--muted); cursor: pointer; } .drop.over { border-color: var(--accent); background: var(--accent-soft); }
.status-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: .4rem; background: var(--faint); } .status-dot.approved { background: var(--leaf); } .status-dot.pending { background: var(--accent); } .status-dot.rejected, .status-dot.blocked { background: var(--chili); }

/* ---------- structure patches ---------- */
.tile { position: relative; }
.tile-link { color: inherit; } .tile-link:hover { text-decoration: none; }
.tile-link::after { content: ''; position: absolute; inset: 0; z-index: 1; }
.tile .fav, .tile-body .fav { position: relative; z-index: 3; }
.prow { padding: 0 .8rem 0 .6rem; min-height: 46px; }
.prow .tick { margin: .4rem 0; }
.prow-t { display: block; padding: .6rem 0; color: var(--text); } .prow-t:hover { text-decoration: none; color: var(--accent-text); }
.hide-s { } @media (max-width: 560px) { .hide-s { display: none; } }
.btn.on[data-act="read"] { background: var(--leaf-soft); border-color: transparent; color: var(--leaf); }
.btn.on[data-act="rev"] { background: var(--sky-soft); border-color: transparent; color: var(--sky); }
#focus-toggle.on { background: var(--accent-soft); color: var(--accent-text); }
body.focus .side, body.focus .rail, body.focus .topbar, body.focus .tabbar, body.focus .crumbs { display: none; }
body.focus .shell { grid-template-columns: minmax(0, 1fr); } body.focus .reader { grid-template-columns: minmax(0, 1fr); max-width: 820px; margin: 0 auto; }
.rank .rn::before { content: counter(r); }
.note-clip { max-height: 62vh; overflow: auto; padding-right: .5rem; }
.btn small { display: block; font-size: .72rem; line-height: 1; }
.btn:has(small) { flex-direction: column; gap: .15rem; padding-block: .5rem; }
.rail-link .i, .tab .i { stroke-width: 1.7; }
.avatar:hover { border-color: var(--accent); }
.toolbar form { display: contents; }
.ok-text { color: var(--leaf); } .err-text { color: var(--chili); }
.sticky-actions { position: sticky; bottom: 12px; z-index: 15; display: flex; gap: .6rem; justify-content: flex-end; padding: .7rem; border-radius: 16px; background: color-mix(in srgb, var(--surface-2) 92%, transparent); backdrop-filter: blur(12px); border: 1px solid var(--line-2); margin-top: 1rem; }
@media (max-width: 759px) { .sticky-actions { bottom: 78px; } }
.mini-table td, .mini-table th { padding: .45rem .6rem; }
pre.raw { white-space: pre-wrap; background: var(--surface-2); border: 1px solid var(--line); border-radius: 12px; padding: 1rem; max-height: 340px; overflow: auto; font: .82rem/1.55 ui-monospace, Menlo, Consolas, monospace; }

/* ---- admin additions ---- */
.media-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 1rem; }
.media-card { display: grid; gap: .5rem; margin: 0; } .media-card img { width: 100%; aspect-ratio: 4/3; object-fit: cover; border-radius: 10px; background: var(--surface-3); display: block; }
.media-card figcaption { display: grid; line-height: 1.3; }
.media-pick { display: grid; grid-template-columns: repeat(auto-fill, minmax(78px, 1fr)); gap: .5rem; max-height: 180px; overflow: auto; }
.media-thumb { padding: 0; border: 2px solid transparent; border-radius: 10px; overflow: hidden; background: var(--surface-3); cursor: pointer; aspect-ratio: 1; } .media-thumb:hover, .media-thumb:focus-visible { border-color: var(--accent); } .media-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.scan-edit img { width: 100%; border-radius: 10px; border: 1px solid var(--line); display: block; }
.tglb { font-family: inherit; }
.phead-actions { display: flex; gap: .5rem; flex-wrap: wrap; }

/* ---------- admin library workspace ---------- */
.topic-body { padding: .2rem 1rem 1rem; border-top: 1px solid var(--line); }
.topic-body > form.row { margin-top: .9rem; }
.pg-list { margin-top: .9rem; }
.pg-row { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; padding: .45rem 0; border-bottom: 1px dashed var(--line); }
.pg-row:last-child { border-bottom: 0; }
.pg-no { flex: none; min-width: 3rem; color: var(--muted); font-size: .82rem; }
.pg-title { flex: 1 1 14rem; min-width: 0; color: inherit; overflow-wrap: anywhere; }
.mv { display: inline-flex; gap: 2px; flex: none; }
.mv .btn[disabled] { opacity: .3; cursor: default; }
.adv > summary { list-style: none; } .adv > summary::-webkit-details-marker { display: none; }
details.adv.card { margin-bottom: 1rem; }
.mr-btn { font-weight: 700; font-size: .85rem; line-height: 1; }
.mr-btn[aria-pressed="true"] { background: var(--leaf-soft); color: var(--leaf); outline: 2px solid var(--leaf); }
body.mr-on [data-mr], body.mr-on .ed-area { box-shadow: inset 0 -2px 0 var(--leaf); }
[lang="mr"], .note-html { font-feature-settings: "kern" 1; }
