@font-face { font-family:"Inter Variable"; font-style:normal; font-weight:100 900; font-display:swap; src:url("library-vendor/inter-cyrillic-wght-normal.woff2") format("woff2"); unicode-range:U+0301,U+0400-045F,U+0490-0491,U+04B0-04B1,U+2116; }
@font-face { font-family:"Inter Variable"; font-style:normal; font-weight:100 900; font-display:swap; src:url("library-vendor/inter-latin-wght-normal.woff2") format("woff2"); unicode-range:U+0000-00FF,U+0131,U+0152-0153,U+02BB-02BC,U+02C6,U+02DA,U+02DC,U+0304,U+0308,U+0329,U+2000-206F,U+20AC,U+2122,U+2191,U+2193,U+2212,U+2215,U+FEFF,U+FFFD; }
#libraryPanel,#libraryDialog,#folderMenu { --radius:10px; --radius-lg:14px; font:13px/normal "Inter Variable","Segoe UI",sans-serif; font-feature-settings:"cv11","ss01"; }
#libraryPanel :is(button,input,select,.tabulator),#libraryDialog :is(button,input,select) { font-family:inherit; }
.library-view main { max-width:none; padding:0; }
.library-view main>.heading { display:none; }
.library-view #workMessage:empty { display:none; }
.library-view #libInputs :is(input,select) { background:var(--surface); color:var(--text); border:1px solid var(--border); border-radius:10px; height:34px; padding:0 12px; }

#libraryPanel:not([hidden]) { display:grid; grid-template-columns:230px minmax(0,1fr); height:100%; }
.lib-side { background:var(--panel); border-right:1px solid var(--border); padding:6px 0 20px; overflow:auto; }
.lib-side-heading { display:flex; align-items:center; justify-content:space-between; padding:16px 16px 8px; }
.lib-side-heading h2 { font:inherit; color:var(--muted); margin:0; }
#newTier,.lib-fold,.lib-folder-name,.folder-more { background:transparent; color:inherit; border:0; padding:0; }
#newTier { width:22px; height:22px; border:1px solid var(--border-2); border-radius:7px; color:var(--muted); transition:transform .15s ease; }
#newTier:hover { color:var(--accent);border-color:var(--accent);transform:rotate(90deg); }
.lib-folder { display:flex; align-items:center; position:relative; gap:8px; height:36px; margin:2px 10px; padding:0 10px 0 12px; white-space:nowrap; border-radius:10px; color:#d6d6d6; transition:transform .15s ease,background .15s ease; }
.lib-folder:hover { background:var(--surface); transform:translateX(2px); }
.lib-folder:has([aria-current=true]) { background:var(--surface-2); color:var(--accent); font-weight:600; }
.lib-folder:has([aria-current=true])::before { content:""; position:absolute; left:-10px; top:8px; bottom:8px; width:3px; border-radius:3px; background:var(--accent); }
.lib-folder.subfolder { padding-left:30px; }
.lib-folder.tier { font-weight:600; color:var(--text); }
.lib-fold { width:12px; font-size:10px; color:var(--muted); }
.lib-folder-name { display:flex; align-items:center; flex:1; min-width:0; height:100%; gap:8px; text-align:left; font:inherit; }
.lib-folder-name span { flex:1; overflow:hidden; text-overflow:ellipsis; }
.lib-folder-name small { color:var(--accent); background:var(--accent-soft); border:1px solid #f5b30166; font-size:11px; font-weight:700; padding:0 6px; border-radius:6px; line-height:17px; }
.folder-more { visibility:hidden; color:var(--muted); }
.lib-folder:hover .folder-more,.lib-folder:focus-within .folder-more { visibility:visible; }
.folder-extras { border-top:1px solid var(--border); margin-top:12px; padding-top:6px; }
.lib-folder.drop-target { outline:1px dashed var(--accent); background:var(--accent-soft); }
.lib-folder-tools { position:fixed; margin:0; border:1px solid #303030; border-radius:10px; padding:4px; background:#171717; color:#f2f2f2; min-width:160px; box-shadow:0 14px 40px #000b; }
.lib-folder-tools button { display:block; text-align:left; width:100%; border:0; background:transparent; }
.lib-folder-tools button:hover { background:#202020; }
.lib-sheet { min-width:0;min-height:0;display:flex;flex-direction:column;background:var(--bg); }
.lib-heading { display:flex;align-items:center;gap:8px;flex-wrap:wrap;padding:18px 16px 12px; }
.lib-heading h2 { margin:0 auto 0 0; font-size:24px; font-weight:800; letter-spacing:-.4px; }
.lib-heading .sep { color:var(--muted);margin:0 8px;font-weight:400; }
#sheetCount { color:var(--muted);font-size:12px; }
.lib-heading #telegramBar { padding:0; }
.lib-heading button { height:34px;padding:0 14px;border:1px solid var(--border-2);border-radius:10px;background:var(--surface);white-space:nowrap;font-size:13px;font-weight:600; }
.lib-heading button:hover { background:var(--surface-2);border-color:#3a3a3a; }
.lib-heading .primary { background:var(--accent);border-color:var(--accent);color:#111; }
.lib-heading .primary:hover { background:#ffc626; }
.lib-heading button[aria-pressed=true] { border-color:var(--accent);color:var(--accent);background:var(--accent-soft); }
#moveChannels:disabled { display:none; }
.lib-scroll {flex:1; min-height:0; margin:0 16px 16px; border:1px solid var(--border); border-radius:14px; overflow:hidden; }
#libraryGrid { width:100%; }
#libStatus:empty { display:none; }
#libStatus { color:#eab99b;margin:0 16px 8px; }
.library-view #libInputs label { display:grid;gap:5px;margin:14px 0; }
.lib-form-actions { display:flex;justify-content:flex-end;gap:8px; }
/* ---------- tabulator overrides ---------- */
.tabulator { background: var(--panel); border: none; font-size: 13px; }
.tabulator .tabulator-header { background: var(--panel); border-bottom: 1px solid var(--border); color: var(--muted); }
.tabulator .tabulator-header .tabulator-col { background: var(--panel); border-right: 1px solid var(--border); }
.tabulator .tabulator-header .tabulator-col .tabulator-col-content { padding: 10px 10px; }
.tabulator .tabulator-header .tabulator-col .tabulator-col-title { font-weight: 600; }
.tabulator .tabulator-header .tabulator-col.tabulator-sortable:hover { background: var(--surface); color: var(--text); }
.tabulator .tabulator-header .tabulator-col[aria-sort="ascending"], .tabulator .tabulator-header .tabulator-col[aria-sort="descending"] { color: var(--accent); }
.tabulator .tabulator-header .tabulator-col .tabulator-header-filter input,
.tabulator .tabulator-header .tabulator-col .tabulator-header-filter select { background: var(--surface); border: 1px solid var(--border-2); border-radius: 7px; color: var(--text); padding: 4px 6px; }
.tabulator .tabulator-tableholder { background: var(--panel); }
.tabulator-row { background: var(--panel); border-bottom: 1px solid #1c1c1c; color: var(--text); min-height: 40px; }
.tabulator-row.tabulator-row-even { background: #0f0f0f; }
.tabulator-row.tabulator-selectable:hover { background: var(--surface); }
.tabulator-row.tabulator-selected, .tabulator-row.tabulator-selected:hover { background: #262626; border-bottom-color: var(--bg); }
/* selected rows invert the grid: light fill, lines in the background colour */
.tabulator-row.tabulator-selected .tabulator-cell { border-right-color: var(--bg); }
.tabulator-row .tabulator-cell { border-right: 1px solid #1c1c1c; padding: 11px 10px; }
.tabulator-row .tabulator-cell.tabulator-editing { border: 1px solid var(--accent); padding: 0; }
.tabulator-row .tabulator-cell.tabulator-editing input,
.tabulator-row .tabulator-cell.tabulator-editing select { background: var(--surface); color: var(--text); padding: 10px 9px; }
.tabulator-row .tabulator-cell.tabulator-row-handle .tabulator-row-handle-box .tabulator-row-handle-bar { background: #4a4a4a; }
.tabulator .tabulator-footer { background: var(--panel); border-top: 1px solid var(--border); color: var(--text); }
.tabulator .tabulator-footer .tabulator-calcs-holder { background: var(--panel); border: none; }
.tabulator .tabulator-footer .tabulator-calcs-holder .tabulator-row { background: var(--panel); font-weight: 800; color: var(--accent); }
.tabulator .tabulator-tableholder .tabulator-placeholder .tabulator-placeholder-contents { color: var(--muted); font-size: 13px; font-weight: 400; }
.tabulator-row .tabulator-cell.row-num { color: var(--muted); text-align: right; }
/* sort arrows only on hover or when the column is sorted */
.tabulator .tabulator-header .tabulator-col[aria-sort="none"] .tabulator-col-sorter { opacity: 0; transition: opacity .1s; }
.tabulator .tabulator-header .tabulator-col[aria-sort="none"]:hover .tabulator-col-sorter { opacity: .5; }
.tabulator .tabulator-header .tabulator-col .tabulator-col-sorter .tabulator-arrow { border-bottom-color: var(--accent) !important; }
.cell-link { color: var(--link); text-decoration: none; cursor: pointer; }
.cell-link:hover { text-decoration: underline; }
#libraryDialog { margin:auto; width:min(420px,94vw); height:fit-content; max-height:85vh; border:1px solid var(--line); border-radius:12px; }
#libraryForm { padding:22px; }
#libInputs label { display:grid; gap:5px; margin:14px 0; }
#libInputs label[hidden] { display:none; }
#libDialogError { color:#eab99b; }
.lib-form-actions { justify-content:flex-end; margin-top:16px; }
@keyframes lib-row-in { from { opacity:0; transform:translateY(6px); } }
@keyframes lib-row-new { from { background:#f5b30138; } }
@keyframes lib-cell-flash { from { background:#f5b30130; box-shadow:inset 0 0 0 1px #f5b30180; } }
@keyframes lib-modal-in { from { opacity:0; transform:translateY(10px) scale(.97); } }
@keyframes lib-fade-in { from { opacity:0; } }
@media (prefers-reduced-motion:no-preference) {
  .primary,.secondary,nav button { transition:transform .14s ease,box-shadow .16s ease; }
  .primary:hover:not(:disabled),.secondary:hover:not(:disabled) { transform:translateY(-1px); }
  .primary:hover:not(:disabled) { box-shadow:0 6px 20px #f5b30140,0 0 0 1px #f5b30166; }
  .primary:active:not(:disabled),.secondary:active:not(:disabled),nav button:active { transform:scale(.94); transition-duration:.06s; }
  .access-card { animation:lib-modal-in .2s cubic-bezier(.2,.9,.3,1.2); }
  .lib-row-in { animation:lib-row-in .32s ease var(--delay,0s) both; }
  .lib-row-new { animation:lib-row-in .3s ease,lib-row-new 1s ease; }
  .lib-leave { transition:opacity .2s,transform .2s; opacity:0; transform:translateX(-12px); }
  .cell-flash { animation:lib-cell-flash .8s ease; }
  dialog[open] { animation:lib-modal-in .2s cubic-bezier(.2,.9,.3,1.2); }
  dialog[open]::backdrop { animation:lib-fade-in .15s ease; }
}
@media (prefers-reduced-motion:reduce) {
  .lib-folder-name,.lib-folder-name::before,#newTier { transition:none; }
  .lib-folder-name:hover,#newTier:hover { transform:none; }
}

@media(prefers-reduced-motion:no-preference) {
  .grid-enter .tabulator-row { animation:lib-row-in .32s ease both; }
  .grid-enter .tabulator-row:nth-child(2) { animation-delay:20ms; }
  .grid-enter .tabulator-row:nth-child(3) { animation-delay:40ms; }
  .grid-enter .tabulator-row:nth-child(4) { animation-delay:60ms; }
  .grid-enter .tabulator-row:nth-child(5) { animation-delay:80ms; }
  .grid-enter .tabulator-row:nth-child(6) { animation-delay:100ms; }
  .grid-enter .tabulator-row:nth-child(7) { animation-delay:120ms; }
  .grid-enter .tabulator-row:nth-child(8) { animation-delay:140ms; }
  .grid-enter .tabulator-row:nth-child(9) { animation-delay:160ms; }
  .grid-enter .tabulator-row:nth-child(10) { animation-delay:180ms; }
  .grid-enter .tabulator-row:nth-child(n+11) { animation-delay:.2s; }
}
@media (max-width:820px) {
  #libraryPanel:not([hidden]) { grid-template-columns:165px minmax(0,1fr); }
  .folder-more { visibility:visible; }
}
@media (max-width:600px) {
  #libraryPanel:not([hidden]) { display:flex;flex-direction:column;height:auto; }
  .lib-side { max-height:32dvh; }
  .lib-sheet { min-height:56dvh; }
  .lib-scroll { flex:none;height:50dvh;margin:0 8px 8px; }
  .lib-heading { padding:12px 8px; }
  .lib-heading h2 { width:100%; }
}
@media(prefers-reduced-motion:reduce) { .lib-folder,.lib-folder:hover,#newTier:hover {transform:none;transition:none;} }

@media (min-width:601px) {
  body.library-view { display:flex; flex-direction:column; height:100dvh; }
  .library-view header { flex:none; }
  .library-view #tabViewport { flex:1; min-height:0; }
  .library-view main { height:100%; width:100%; margin:0; }
}
