@font-face{
    font-family: "Lispako";
    src: url("../fonts/MathBlog_Lispako.ttf") format("truetype");
    font-display: swap;
  }
  @import url("https://fonts.googleapis.com/css2?family=Roboto:wght@300;400;500;600;700&family=Roboto+Mono:wght@400;500&display=swap");

  :root{
    /* Sticky offset для левой колонки фильтров (библиотека): под топбар + зазор; в REC — под топбар и красную полосу */
    --library-filters-sticky-top: 80px;
    --accent: #F4FF67;
    --accent-ink: #0B0B0B;
    --ink: #0B0B0B;
    --ink-2: #2B2B2B;
    --ink-3: #5A5A5A;
    --ink-4: #8B8B8B;
    --line: #ECECE6;
    --line-2: #DCDCD4;
    --bg: #FAFAF6;
    --surface: #FFFFFF;
    --surface-2: #F5F5EF;
    --danger: #C0341D;
    --success: #1F7A3A;
    --info: #1F4FA1;
    --rec: #E11D2C;
    --rec-deep: #C81928;
    --rec-tint: #FFF1F1;
    --rec-tint-2: #FFE3E5;
    --radius: 10px;
    --radius-sm: 6px;
    --radius-lg: 14px;
    --shadow-1: 0 1px 0 rgba(0,0,0,0.04), 0 1px 2px rgba(0,0,0,0.04);
    --shadow-2: 0 8px 24px -8px rgba(0,0,0,0.18), 0 2px 4px rgba(0,0,0,0.06);
  }

  *{ box-sizing: border-box; }
  html, body{
    margin:0; padding:0;
    background: var(--bg);
    color: var(--ink);
    font-family: "Roboto", -apple-system, BlinkMacSystemFont, "Helvetica Neue", Arial, sans-serif;
    font-size: 14px;
    line-height: 1.45;
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
  }

  button, input, select, textarea{ font-family: inherit; font-size: inherit; color: inherit; }
  button{ cursor: pointer; }
  a{ color: inherit; }

  ::selection{ background: var(--accent); color: var(--accent-ink); }

  /* Accent typeface — used only UPPERCASE */
  .lispako{
    font-family: "Lispako", "Roboto", sans-serif;
    text-transform: uppercase;
    letter-spacing: 0.02em;
  }

  /* ----- Layout ----- */
  .app{
    display: grid;
    grid-template-columns: 248px 1fr;
    min-height: 100vh;
  }
  .app.collapsed{ grid-template-columns: 72px 1fr; }

  /* ----- Sidebar ----- */
  .sidebar{
    background: #0B0B0B;
    color: #EDEDE6;
    display: flex; flex-direction: column;
    position: sticky; top: 0; height: 100vh;
  }
  .sidebar .brand{
    padding: 22px 20px 18px;
    display: flex; align-items: center; gap: 12px;
    border-bottom: 1px solid #1c1c1c;
  }
  .sidebar .brand .mark{
    width: 40px; height: 40px;
    flex: 0 0 40px;
    background: var(--accent);
    border-radius: 999px;
    background-image: url("../uploads/claude_avatar.png");
    background-size: cover;
    background-position: center;
    aspect-ratio: 1 / 1;
  }
  .app.collapsed .sidebar .brand .mark{
    width: 40px; height: 40px; flex: 0 0 40px;
  }
  .sidebar .brand .name{
    font-family: "Lispako", "Roboto", sans-serif;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    font-size: 16px; line-height: 1.1;
    color: #fff;
  }
  .sidebar .brand .name span{ display:block; color: var(--accent); }
  .app.collapsed .sidebar .brand .name{ display: none; }
  .app.collapsed .sidebar .brand{ justify-content: center; padding: 22px 0 18px; }

  .sidebar nav{ padding: 12px 10px; display:flex; flex-direction: column; gap: 2px; flex: 1; }
  .nav-section{ font-size: 11px; text-transform: uppercase; letter-spacing: 0.12em; color: #6b6b66; padding: 14px 12px 6px; }
  .app.collapsed .nav-section{ display: none; }
  .nav-item{
    display: flex; align-items: center; gap: 12px;
    padding: 11px 12px; border-radius: 8px;
    color: #C8C8C0;
    background: transparent; border: 0; width: 100%;
    text-align: left; font-size: 14px; font-weight: 400;
    position: relative;
  }
  .nav-item:hover{ background: #161616; color: #fff; }
  .nav-item.active{
    background: #1a1a1a; color: #fff;
  }
  .nav-item.active::before{
    content: ""; position: absolute; left: 0; top: 8px; bottom: 8px; width: 3px;
    background: var(--accent); border-radius: 0 3px 3px 0;
  }
  .nav-item .ico{ width: 18px; height: 18px; flex: 0 0 18px; opacity: 0.85; }
  .nav-item .label{ flex: 1; }
  .nav-item .count{
    font-size: 11px; padding: 2px 7px; border-radius: 999px;
    background: #2a2a2a; color: #d9d9d2;
  }
  .app.collapsed .nav-item .label,
  .app.collapsed .nav-item .count{ display: none; }
  .app.collapsed .nav-item{ justify-content: center; }

  .sidebar .foot{
    padding: 12px; border-top: 1px solid #1c1c1c;
    display: flex; align-items: center; gap: 10px;
  }
  .sidebar .foot .avatar{
    width: 30px; height: 30px; border-radius: 999px;
    background: #2a2a2a; color: var(--accent);
    display: flex; align-items: center; justify-content: center;
    font-weight: 600; font-size: 12px;
  }
  .sidebar .foot .who{ flex: 1; min-width: 0; }
  .sidebar .foot .who .n{ color: #fff; font-size: 13px; white-space: nowrap; overflow:hidden; text-overflow: ellipsis; }
  .sidebar .foot .who .e{ color: #7a7a73; font-size: 11px; white-space: nowrap; overflow:hidden; text-overflow: ellipsis; }
  .app.collapsed .sidebar .foot .who{ display: none; }
  .app.collapsed .sidebar .foot{ justify-content: center; }

  .collapse-btn{
    background: transparent; border: 1px solid #2a2a2a; color: #aaa;
    width: 28px; height: 28px; border-radius: 6px; padding: 0;
    display:flex; align-items:center; justify-content:center;
  }
  .collapse-btn:hover{ background: #161616; color: #fff; }

  /* ----- Main ----- */
  main.work{ min-width: 0; display: flex; flex-direction: column; }
  .topbar{
    height: 64px; background: var(--surface);
    border-bottom: 1px solid var(--line);
    display: flex; align-items: center; gap: 14px; padding: 0 28px;
    position: sticky; top: 0; z-index: 5;
  }
  .topbar .crumbs{ font-size: 13px; color: var(--ink-3); display:flex; align-items:center; gap:8px; flex: 1; min-width: 0; overflow: hidden; white-space: nowrap; }
  .topbar .crumb-link{ color: var(--ink-2); text-decoration: none; border-bottom: 1px solid transparent; transition: color .15s ease, border-color .15s ease; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
  .topbar .crumb-link:hover{ color: var(--ink); border-bottom-color: var(--line-2); }
  .topbar .crumb-current{ color: var(--ink-3); min-width: 0; overflow: hidden; text-overflow: ellipsis; }
  .topbar .sep{ color: var(--ink-4); flex: 0 0 auto; }
  .search-shell{
    position: relative; min-width: 280px; max-width: 420px; flex: 0 1 320px;
  }
  .search-shell input{
    width: 100%;
    border: 1px solid var(--line); background: var(--surface-2);
    border-radius: 8px; height: 34px; padding: 0 10px 0 32px;
    outline: none;
  }
  .search-shell input:focus{ border-color: var(--ink-2); background: #fff; }
  .search-shell .ico{ position: absolute; left: 9px; top: 8px; opacity: 0.55; }
  .search-shell .kbd{
    position: absolute; right: 8px; top: 7px; font-size: 10px;
    color: var(--ink-3); border:1px solid var(--line-2); padding: 2px 5px; border-radius: 4px;
    background: #fff; line-height: 1;
  }
  .topbar .acts{ display: flex; align-items: center; gap: 8px; }

  /* ----- Recording state ----- */
  .topbar.recording{
    background: var(--surface);
    border-bottom-color: var(--line);
  }
  .topbar.recording::before{
    content:""; position:absolute; left: 0; right: 0; bottom: -1px; height: 2px;
    background: var(--rec);
  }
  .rec-pill{
    display: inline-flex; align-items: center; gap: 6px;
    color: var(--rec);
    padding: 4px 8px 4px 4px;
    font-family: "Lispako", "Roboto", sans-serif;
    text-transform: uppercase;
    font-size: 11px; font-weight: 700; letter-spacing: 0.08em;
  }
  .rec-pill--hidden,
  .rec-bar-wrap--hidden{
    display: none !important;
  }
  .rec-pill .rec-dot{
    width: 8px; height: 8px; border-radius: 999px;
    background: var(--rec);
    animation: rec-blink 1.2s ease-in-out infinite;
  }
  @keyframes rec-blink{
    0%, 100%{ opacity: 1; }
    50%{ opacity: 0.3; }
  }

  /* Полоса REC закреплена к окну (не уезжает при скролле контента в main.work) */
  .rec-bar-wrap:not(.rec-bar-wrap--hidden){
    position: fixed;
    top: 64px;
    left: 248px;
    right: 0;
    z-index: 4;
    box-sizing: border-box;
  }
  .app.collapsed .rec-bar-wrap:not(.rec-bar-wrap--hidden){
    left: 72px;
  }
  body.is-recording{
    --library-filters-sticky-top: 132px;
  }

  body.is-recording main.work > .page{
    /* место под фиксированную полосу (одна строка + запас при переносе чипов) */
    padding-top: 72px;
  }

  .rec-bar{
    position: relative;
    background: var(--rec);
    color: #fff;
    border-bottom: 1px solid rgba(0,0,0,0.1);
  }
  .rec-bar-inner{
    display: flex; align-items: center; gap: 12px;
    padding: 8px 24px; min-height: 40px;
    font-size: 13px;
  }
  .rec-led{
    width: 8px; height: 8px; border-radius: 999px; background: #fff;
    animation: rec-blink 1.2s ease-in-out infinite;
    flex: 0 0 auto;
  }
  .rec-label{
    font-family: "Lispako", "Roboto", sans-serif;
    text-transform: uppercase;
    font-size: 11.5px; font-weight: 700; letter-spacing: 0.1em;
  }
  .rec-chips{
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
  }
  .rec-bar-spacer{
    flex: 1;
    min-width: 8px;
  }
  .rec-chip-close-form{
    display: inline;
    margin: 0;
    padding: 0;
  }
  .rec-stop-form{
    margin: 0;
  }
  .rec-chip{
    display: inline-flex; align-items: center; gap: 8px;
    background: rgba(0,0,0,0.18);
    padding: 3px 4px 3px 10px; border-radius: 999px;
  }
  .rec-chip-tag{
    font-family: "Lispako", "Roboto", sans-serif;
    font-size: 10.5px; font-weight: 700; letter-spacing: 0.08em;
    color: rgba(255,255,255,0.75);
  }
  .rec-chip-name{ font-weight: 500; font-size: 13px; }
  .rec-chip-meta{ color: rgba(255,255,255,0.65); font-size: 12.5px; }
  .rec-chip-btn{
    background: transparent; color: #fff;
    border: none;
    padding: 3px 8px; border-radius: 999px;
    font-size: 12px; display:inline-flex; align-items:center; gap: 4px;
  }
  .rec-chip a.rec-chip-btn{
    text-decoration: none;
    color: #fff;
  }
  .rec-chip-btn:hover{ background: rgba(255,255,255,0.18); }
  .rec-chip-btn.ghost{ padding: 3px 6px; opacity: 0.7; }
  .rec-chip-btn.ghost:hover{ opacity: 1; background: rgba(255,255,255,0.18); }
  .rec-stop{
    display: inline-flex; align-items: center; gap: 6px;
    background: rgba(0,0,0,0.18); color: #fff;
    border: none; padding: 5px 12px; border-radius: 999px;
    font-weight: 500; font-size: 12.5px;
  }
  .rec-stop:hover{ background: rgba(0,0,0,0.3); }

  :root[data-theme="dark"] .rec-bar{
    background: var(--rec-deep);
  }

  /* ----- Buttons ----- */
  .btn{
    display: inline-flex; align-items: center; gap: 8px;
    border-radius: 8px; padding: 0 14px; height: 34px;
    border: 1px solid var(--line-2);
    background: #fff; color: var(--ink);
    font-weight: 500; transition: 80ms ease;
    white-space: nowrap;
  }
  .btn:hover{ border-color: var(--ink-2); }
  .btn.primary{
    background: var(--accent); color: var(--accent-ink);
    border-color: #d9e34a;
  }
  .btn.primary:hover{ filter: brightness(0.96); border-color: #b8c13b; }
  .btn.dark{
    background: #0B0B0B; color: #fff; border-color: #0B0B0B;
  }
  .btn.dark:hover{ background: #1c1c1c; }
  .btn.ghost{ background: transparent; border-color: transparent; color: var(--ink-2); }
  .btn.ghost:hover{ background: var(--surface-2); color: var(--ink); }
  .btn.danger{ color: var(--danger); border-color: transparent; background: transparent; }
  .btn.danger:hover{ background: #fbeae6; }
  .btn.sm{ height: 28px; padding: 0 10px; font-size: 12.5px; border-radius: 6px; gap: 6px; }
  .btn.lg{ height: 40px; padding: 0 18px; font-size: 14.5px; }
  .btn.icon{ padding: 0; width: 34px; justify-content: center; }
  .btn.icon.sm{ width: 28px; }
  .btn[disabled]{ opacity: 0.5; cursor: not-allowed; }

  /* ----- Chips ----- */
  .chip{
    display: inline-flex; align-items: center; gap: 6px;
    height: 26px; padding: 0 10px; border-radius: 999px;
    background: var(--surface-2); border: 1px solid var(--line);
    color: var(--ink-2); font-size: 12.5px;
  }
  .chip.active{ background: #0B0B0B; color: #fff; border-color: #0B0B0B; }
  .chip.accent{ background: var(--accent); color: var(--accent-ink); border-color: #d9e34a; }
  .chip button{ background: none; border: 0; padding: 0; color: inherit; opacity: 0.7; line-height: 1;}
  .chip button:hover{ opacity: 1; }
  .chip.removable{ padding-right: 4px; }
  .chip.removable .x{
    width: 18px; height: 18px; border-radius: 999px;
    display:flex; align-items:center; justify-content:center;
    background: rgba(0,0,0,0.06);
  }

  .tag{
    display: inline-flex; align-items: center; height: 22px;
    padding: 0 8px; border-radius: 4px;
    font-size: 11.5px; font-weight: 500;
    background: var(--surface-2); color: var(--ink-2);
    border: 1px solid var(--line);
  }
  .tag.kes{ background: #FFF8D6; border-color: #F0E489; color: #5A4900; }
  .tag.section{ background: #EAF1FE; border-color: #C9DAFB; color: #1B3F8C; }
  .tag.id{ font-family: "Roboto Mono", monospace; background: #fff; color: var(--ink-3); }
  .tag.solid{ background: #0B0B0B; color: #fff; border-color: #0B0B0B; }

  /* ----- Cards ----- */
  .card{
    background: var(--surface); border: 1px solid var(--line);
    border-radius: var(--radius); box-shadow: var(--shadow-1);
  }
  .card.lift:hover{ border-color: var(--line-2); box-shadow: var(--shadow-2); }

  /* ----- Forms ----- */
  .field label{ display:block; font-size: 12px; color: var(--ink-3); margin-bottom: 6px; font-weight: 500; }
  .input, .select{
    width: 100%; height: 36px; padding: 0 10px;
    border: 1px solid var(--line-2); border-radius: 8px;
    background: #fff; outline: none;
  }
  .input:focus, .select:focus{ border-color: var(--ink); }
  textarea.input{ height: auto; padding: 10px; min-height: 80px; line-height: 1.5; }
  .switch{ position: relative; display: inline-block; width: 36px; height: 20px; }
  .switch input{ display: none; }
  .switch .slider{
    position: absolute; inset: 0; background: #d8d8d0; border-radius: 999px; transition: 120ms;
  }
  .switch .slider::before{
    content:""; position:absolute; left: 2px; top: 2px; width: 16px; height: 16px;
    background: #fff; border-radius: 999px; transition: 120ms;
    box-shadow: 0 1px 2px rgba(0,0,0,0.15);
  }
  .switch input:checked + .slider{ background: #0B0B0B; }
  .switch input:checked + .slider::before{ transform: translateX(16px); }
  .switch.accent input:checked + .slider{ background: var(--accent); }
  .switch.accent input:checked + .slider::before{ background: #0B0B0B; }

  .check{
    display: inline-flex; align-items: center; gap: 8px; cursor: pointer;
    font-size: 13px; color: var(--ink-2);
  }
  .check input{ appearance: none; width: 16px; height: 16px; border: 1.5px solid var(--line-2); border-radius: 4px; background: #fff; display: inline-flex; align-items: center; justify-content: center; cursor: pointer; }
  .check input:checked{ background: #0B0B0B; border-color: #0B0B0B; }
  .check input:checked::after{
    content: ""; width: 8px; height: 4px; border-left: 2px solid var(--accent);
    border-bottom: 2px solid var(--accent); transform: rotate(-45deg) translate(1px, -1px);
  }

  /* ----- Toast / Inline alert ----- */
  .alert{
    display: flex; align-items: flex-start; gap: 10px;
    border-radius: 8px; padding: 10px 12px; font-size: 13px;
    border: 1px solid;
  }
  .alert.success{ background: #ECF7EF; border-color: #BCE4C8; color: #15572A; }
  .alert.error{ background: #FBEAE6; border-color: #F2B7AB; color: #8C1D08; }
  .alert.info{ background: #EAF1FE; border-color: #C9DAFB; color: #1B3F8C; }
  .alert.warn{ background: #FFF7D6; border-color: #F2DF7A; color: #5A4500; }

  /* ----- Misc ----- */
  .h-section{
    font-size: 11px; text-transform: uppercase; letter-spacing: 0.12em;
    color: var(--ink-3); font-weight: 600;
  }
  .divider{ height: 1px; background: var(--line); }
  .scroll-x{ overflow-x: auto; }
  .scroll-x::-webkit-scrollbar{ height: 0; }

  /* ----- Build bar (sticky bottom) ----- */
  .buildbar{
    position: sticky; bottom: 0; z-index: 4;
    margin: 0 -24px -24px;
    background: #0B0B0B; color: #fff;
    border-top: 2px solid var(--accent);
    padding: 12px 24px;
    display: flex; align-items: center; gap: 14px;
    box-shadow: 0 -8px 24px -10px rgba(0,0,0,0.18);
  }
  .buildbar .bb-tag{
    background: var(--accent); color: #000; padding: 4px 8px;
    border-radius: 4px; font-weight: 600; font-size: 11.5px;
    text-transform: uppercase; letter-spacing: 0.05em;
  }
  .buildbar .bb-name{ font-weight: 600; font-size: 14.5px; }
  .buildbar .bb-meta{ color: #b6b6ae; font-size: 12.5px; }
  .buildbar .bb-spacer{ flex: 1; }

  /* ----- Page padding ----- */
  .page{ padding: 36px 40px; max-width: 1520px; margin: 0 auto; width: 100%; display: flex; flex-direction: column; gap: 28px; }
  .page-head{ display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; }
  .page-head h1{
    font-family: "Lispako", "Roboto", sans-serif; font-weight: 400;
    text-transform: uppercase; letter-spacing: 0.02em;
    font-size: 30px; margin: 0;
  }
  .page-head .sub{ color: var(--ink-3); font-size: 14px; margin-top: 6px; max-width: 640px; }
  .page-head .right{ display: flex; gap: 10px; align-items: center; }
  .page-head .right .btn{ text-decoration: none; }

  /* Math placeholder rendering */
  .math{
    font-family: "Times New Roman", "Cambria Math", serif;
    font-style: italic;
  }

  /* Stripe placeholder for images */
  .ph-image{
    background:
      repeating-linear-gradient(135deg, #f0f0e9 0 8px, #e7e7df 8px 16px);
    border: 1px solid var(--line);
    border-radius: 6px;
    display: flex; align-items: center; justify-content: center;
    color: #8b8b80; font-family: "Roboto Mono", monospace; font-size: 11px;
  }

  /* Loading shimmer */
  @keyframes shimmer{ 0%{ background-position: -200px 0; } 100%{ background-position: 200px 0; } }
  .shimmer{
    background: #f0f0e9 linear-gradient(90deg, transparent 0, rgba(255,255,255,0.7) 40%, transparent 80%) -200px 0/200px 100% no-repeat;
    animation: shimmer 1.2s infinite linear;
    border-radius: 6px;
  }

  /* Modal */
  .modal-backdrop{
    position: fixed; inset: 0; background: rgba(11,11,11,0.45);
    display:flex; align-items:center; justify-content:center; z-index: 50;
    backdrop-filter: blur(2px);
  }
  .modal{
    background: #fff; border-radius: 14px; width: 480px; max-width: calc(100vw - 32px);
    box-shadow: 0 20px 60px -10px rgba(0,0,0,0.3);
    overflow: hidden;
  }
  .modal-head{ padding: 18px 20px 12px; }
  .modal-head h3{ margin: 0; font-size: 18px; }
  .modal-body{ padding: 4px 20px 16px; }
  .modal-foot{ padding: 14px 20px; background: var(--surface-2); display: flex; gap: 8px; justify-content: flex-end; border-top: 1px solid var(--line); }

  /* Toggle group */
  .seg{ display: inline-flex; background: var(--surface-2); border: 1px solid var(--line); border-radius: 8px; padding: 3px; }
  .seg button{ height: 26px; padding: 0 10px; border: 0; background: transparent; border-radius: 6px; color: var(--ink-3); font-weight: 500; }
  .seg button.on{ background: #fff; color: var(--ink); box-shadow: var(--shadow-1); }

  /* Tabs */
  .tabs{ display: flex; gap: 24px; border-bottom: 1px solid var(--line); }
  .tabs .tab{
    background: transparent; border: 0; padding: 12px 0; color: var(--ink-3);
    font-weight: 500; font-size: 14px; position: relative;
  }
  .tabs .tab.on{ color: var(--ink); }
  .tabs .tab.on::after{
    content: ""; position: absolute; left: 0; right: 0; bottom: -1px;
    height: 2px; background: #0B0B0B;
  }
  .tabs .tab .badge{
    margin-left: 6px; background: var(--surface-2); padding: 1px 6px; border-radius: 999px;
    font-size: 11px; color: var(--ink-3);
  }

  /* Slide deck preview */
  .slide{
    width: 100%; aspect-ratio: 16 / 9; background: #fff;
    border: 1px solid var(--line-2); border-radius: 6px;
    padding: 32px; position: relative; overflow: hidden;
  }
  .slide.thumb{ padding: 14px; font-size: 9px; }

  /* Custom scrollbar in lists */
  .list-scroll{ max-height: 100%; overflow: auto; }
  .list-scroll::-webkit-scrollbar{ width: 8px; }
  .list-scroll::-webkit-scrollbar-thumb{ background: #d8d8d0; border-radius: 999px; }

  /* Number input */
  .stepper{
    display: inline-flex; align-items: center; border: 1px solid var(--line-2);
    border-radius: 8px; overflow: hidden; height: 30px; background: #fff;
  }
  .stepper button{
    width: 28px; height: 28px; border: 0; background: transparent; color: var(--ink-2);
  }
  .stepper button:hover{ background: var(--surface-2); }
  .stepper input{
    width: 40px; border: 0; outline: 0; text-align: center; font-weight: 500;
    height: 28px;
  }
