:root{
      --sidebar-w: 294px;
      --topbar-h: 78px;
      --radius-xs: 10px;
      --radius-sm: 14px;
      --radius-md: 20px;
      --radius-lg: 28px;
      --shadow-soft: 0 24px 60px rgba(0,0,0,.22);
      --shadow-glow: 0 0 40px rgba(139,123,255,.15);
      --transition: .24s cubic-bezier(.4,0,.2,1);
      --ease-bounce: .45s cubic-bezier(.22,1,.36,1);
      --font-size-base: 15px;
      --line-height-note: 1.72;
      --safe-bottom: env(safe-area-inset-bottom, 0px);
      --safe-top: env(safe-area-inset-top, 0px);
    }

    [data-theme="dark"]{
      --bg-primary:#090b13;
      --bg-secondary:rgba(17,21,34,.84);
      --bg-tertiary:rgba(20,27,44,.94);
      --bg-panel:rgba(12,17,29,.78);
      --bg-hover:rgba(255,255,255,.06);
      --bg-strong:rgba(123,107,255,.17);
      --bg-soft:rgba(255,255,255,.035);
      --border:rgba(255,255,255,.08);
      --border-strong:rgba(255,255,255,.16);
      --text-primary:#eef2ff;
      --text-secondary:rgba(238,242,255,.76);
      --text-tertiary:rgba(238,242,255,.42);
      --accent:#8b7bff;
      --accent-2:#44c3ff;
      --accent-3:#34d399;
      --accent-4:#f59e0b;
      --accent-5:#fb7185;
      --mesh-1:rgba(139,123,255,.28);
      --mesh-2:rgba(68,195,255,.16);
      --mesh-3:rgba(52,211,153,.11);
      --modal-overlay:rgba(4,8,16,.58);
      --input-bg:rgba(255,255,255,.045);
      --theme-card-bg:linear-gradient(180deg, rgba(255,255,255,.065), rgba(255,255,255,.03));
    }

    [data-theme="light"]{
      --bg-primary:#eef3ff;
      --bg-secondary:rgba(255,255,255,.92);
      --bg-tertiary:rgba(255,255,255,.96);
      --bg-panel:rgba(255,255,255,.8);
      --bg-hover:rgba(90,107,180,.08);
      --bg-strong:rgba(92,99,255,.12);
      --bg-soft:rgba(92,99,255,.03);
      --border:rgba(92,99,255,.13);
      --border-strong:rgba(92,99,255,.24);
      --text-primary:#1a2342;
      --text-secondary:rgba(26,35,66,.74);
      --text-tertiary:rgba(26,35,66,.45);
      --accent:#5b63ff;
      --accent-2:#0ea5e9;
      --accent-3:#10b981;
      --accent-4:#d97706;
      --accent-5:#ef476f;
      --mesh-1:rgba(91,99,255,.18);
      --mesh-2:rgba(14,165,233,.13);
      --mesh-3:rgba(16,185,129,.1);
      --modal-overlay:rgba(227,233,255,.56);
      --input-bg:rgba(255,255,255,.86);
      --theme-card-bg:linear-gradient(180deg, rgba(255,255,255,.96), rgba(242,246,255,.92));
      --shadow-glow:0 10px 32px rgba(91,99,255,.09);
    }

    *{box-sizing:border-box;margin:0;padding:0}
    html{font-size:var(--font-size-base);scroll-behavior:smooth}
    body{
      min-height:100vh;
      font-family:Inter,system-ui,-apple-system,BlinkMacSystemFont,"Segoe UI",sans-serif;
      color:var(--text-primary);
      background:var(--bg-primary);
      overflow:hidden;
      transition:background var(--transition), color var(--transition);
    }
    body.panel-lock{overflow:hidden}
    body,input,textarea,select,button{font-family:inherit}
    ::selection{background:rgba(123,107,255,.25)}
    *{scrollbar-width:thin;scrollbar-color:rgba(123,107,255,.4) transparent}
    ::-webkit-scrollbar{width:10px;height:10px}
    ::-webkit-scrollbar-track{background:transparent}
    ::-webkit-scrollbar-thumb{
      background:linear-gradient(180deg, rgba(255,255,255,.06), rgba(255,255,255,.02)), linear-gradient(180deg, rgba(123,107,255,.45), rgba(255,255,255,.04));
      border-radius:999px;border:2px solid transparent;background-clip:padding-box
    }

    .mesh-bg{
      position:fixed;inset:0;z-index:0;overflow:hidden;
      background:
        radial-gradient(circle at 12% 12%, var(--mesh-1), transparent 30%),
        radial-gradient(circle at 86% 20%, var(--mesh-2), transparent 28%),
        radial-gradient(circle at 48% 84%, var(--mesh-3), transparent 24%),
        linear-gradient(180deg, rgba(255,255,255,.03), transparent 40%);
    }
    .mesh-bg::after{
      content:"";position:absolute;inset:0;opacity:.9;pointer-events:none;
      background-image:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160' viewBox='0 0 160 160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' opacity='.035' filter='url(%23n)'/%3E%3C/svg%3E");
    }
    .glass{
      background:var(--bg-panel);
      backdrop-filter:blur(26px) saturate(165%);
      -webkit-backdrop-filter:blur(26px) saturate(165%);
      border:1px solid var(--border);
      box-shadow:var(--shadow-soft), var(--shadow-glow);
    }
    .hidden{display:none !important}
    .muted{color:var(--text-tertiary)}

    .loading-overlay,.auth-page{
      position:fixed;inset:0;z-index:100;
      display:flex;align-items:center;justify-content:center
    }
    .loading-overlay{flex-direction:column;gap:16px;background:var(--bg-primary)}
    .loading-logo{
      width:58px;height:58px;border-radius:18px;display:grid;place-items:center;
      background:linear-gradient(135deg, var(--accent), var(--accent-2));color:#fff;font-size:24px;
      box-shadow:var(--shadow-glow);animation:pulse 1.8s ease-in-out infinite
    }
    @keyframes pulse{50%{transform:scale(1.06)}}
    .spinner{
      width:20px;height:20px;border-radius:50%;
      border:2px solid rgba(255,255,255,.12);border-top-color:var(--accent);animation:spin .7s linear infinite
    }
    @keyframes spin{to{transform:rotate(360deg)}}
    .loading-text{color:var(--text-tertiary);font-size:.9rem}

    .auth-card{width:min(436px,92vw);padding:34px;border-radius:var(--radius-lg)}
    .brand-row{display:flex;align-items:center;gap:12px;margin-bottom:18px}
    .brand-icon,.logo-icon{
      width:46px;height:46px;border-radius:14px;display:grid;place-items:center;
      background:linear-gradient(135deg, var(--accent), var(--accent-2));color:#fff;font-size:20px
    }
    .brand-title{font-size:1.46rem;font-weight:800;letter-spacing:-.03em}
    .brand-sub{color:var(--text-secondary);font-size:.84rem;margin-bottom:22px;line-height:1.65}
    .field{margin-bottom:14px}
    .label{display:block;margin-bottom:8px;color:var(--text-secondary);font-size:.8rem;font-weight:700}
    .input,.textarea,.select{
      width:100%;border:1px solid var(--border);background:var(--input-bg);
      color:var(--text-primary);border-radius:16px;padding:12px 14px;outline:none;
      transition:all var(--transition);font-size:.92rem
    }
    .input:focus,.textarea:focus,.select:focus{
      border-color:var(--accent);box-shadow:0 0 0 4px rgba(123,107,255,.14);background:rgba(255,255,255,.065)
    }
    .textarea{min-height:140px;resize:vertical;line-height:var(--line-height-note)}
    .select{
      appearance:none;-webkit-appearance:none;-moz-appearance:none;padding-right:42px;
      background-image:linear-gradient(45deg, transparent 50%, var(--text-secondary) 50%), linear-gradient(135deg, var(--text-secondary) 50%, transparent 50%);
      background-position:calc(100% - 18px) calc(50% - 2px), calc(100% - 12px) calc(50% - 2px);
      background-size:6px 6px, 6px 6px;background-repeat:no-repeat
    }
    .select option{background:var(--bg-tertiary);color:var(--text-primary)}
    .btn,.icon-btn,.chip-btn,.tiny-btn,.seg-btn{
      border:1px solid transparent;cursor:pointer;transition:all var(--transition);
      display:inline-flex;align-items:center;justify-content:center;gap:8px
    }
    .btn{
      min-height:42px;border-radius:16px;padding:0 16px;font-size:.9rem;font-weight:700;white-space:nowrap
    }
    .btn-primary{
      background:linear-gradient(135deg, var(--accent), var(--accent-2));color:#fff;
      box-shadow:0 10px 24px rgba(91,99,255,.22)
    }
    .btn-primary:hover{transform:translateY(-1px)}
    .btn-ghost,.icon-btn,.chip-btn,.tiny-btn,.seg-btn{
      background:rgba(255,255,255,.04);border-color:var(--border);color:var(--text-secondary)
    }
    .btn-ghost:hover,.icon-btn:hover,.chip-btn:hover,.tiny-btn:hover,.seg-btn:hover{
      background:var(--bg-hover);color:var(--text-primary)
    }
    .btn-danger{background:rgba(251,113,133,.1);border-color:rgba(251,113,133,.24);color:var(--accent-5)}
    .auth-tip{text-align:center;color:var(--text-secondary);margin-top:16px;font-size:.84rem}
    .link-btn{color:var(--accent);font-weight:700;cursor:pointer}
    .auth-msg{display:none;margin:12px 0;padding:12px 14px;border-radius:14px;font-size:.84rem}
    .auth-msg.show{display:block}
    .auth-msg.error{background:rgba(251,113,133,.12);color:var(--accent-5);border:1px solid rgba(251,113,133,.24)}
    .auth-msg.success{background:rgba(52,211,153,.12);color:var(--accent-3);border:1px solid rgba(52,211,153,.24)}

    .app-shell{position:relative;z-index:1;display:flex;height:100vh}
    #sidebar{
      width:var(--sidebar-w);flex-shrink:0;display:flex;flex-direction:column;position:relative;z-index:10;
      border-right:1px solid var(--border);background:var(--bg-secondary);
      backdrop-filter:blur(24px) saturate(160%);-webkit-backdrop-filter:blur(24px) saturate(160%);
      transition:transform var(--transition)
    }
    .sidebar-header{padding:22px 18px 16px}
    .logo-wrap{display:flex;align-items:center;gap:12px}
    .logo-name{font-size:1.08rem;font-weight:800;letter-spacing:-.02em}
    .logo-name span{color:var(--accent)}
    .logo-tag{
      margin-left:auto;font-size:.68rem;padding:4px 8px;border-radius:999px;
      background:rgba(52,211,153,.12);color:var(--accent-3);border:1px solid rgba(52,211,153,.18)
    }
    .search-wrap{padding:0 14px 10px}
    .search-inner{
      display:flex;align-items:center;gap:8px;padding:10px 12px;border-radius:16px;
      background:rgba(255,255,255,.04);border:1px solid var(--border)
    }
    .search-inner i{color:var(--text-tertiary)}
    .search-input{flex:1;background:none;border:none;outline:none;color:var(--text-primary);font-size:.9rem}
    .clear-search-btn{
      width:28px;height:28px;border-radius:999px;border:none;background:transparent;color:var(--text-tertiary);display:none
    }
    .clear-search-btn.show{display:grid;place-items:center}
    .clear-search-btn:hover{background:var(--bg-hover);color:var(--text-primary)}
    .toolbar-row{
      display:flex;gap:8px;padding:0 14px 12px;overflow-x:auto;scrollbar-width:none
    }
    .toolbar-row::-webkit-scrollbar{display:none}
    .chip-btn{
      min-height:38px;padding:0 12px;border-radius:14px;font-size:.82rem;font-weight:700;
      min-width:max-content;flex:1
    }
    .chip-btn.active{background:var(--bg-strong);color:var(--text-primary);border-color:var(--border-strong)}
    .sidebar-title{
      padding:8px 18px 10px;font-size:.74rem;letter-spacing:.12em;text-transform:uppercase;
      color:var(--text-tertiary);font-weight:700
    }
    .new-cat-row{display:flex;gap:8px;padding:0 14px 12px}
    .new-cat-input{flex:1;min-height:38px}
    .new-cat-btn{
      width:38px;height:38px;border-radius:12px;background:var(--bg-strong);color:var(--accent);border:1px solid var(--border)
    }
    .category-list{flex:1;overflow:auto;padding:0 10px 12px}
    .category-item{
      display:flex;align-items:center;gap:10px;padding:11px 10px;border-radius:16px;
      color:var(--text-secondary);cursor:pointer;transition:all var(--transition);margin-bottom:4px;user-select:none
    }
    .category-item:hover{background:var(--bg-hover);color:var(--text-primary)}
    .category-item.active{background:var(--bg-strong);color:var(--text-primary)}
    .cat-grab{color:var(--text-tertiary);cursor:grab}
    .cat-dot{width:10px;height:10px;border-radius:999px;flex-shrink:0}
    .cat-name{flex:1;font-weight:600;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
    .cat-count{
      font-size:.74rem;min-width:26px;text-align:center;padding:3px 8px;border-radius:999px;background:rgba(255,255,255,.06);color:var(--text-tertiary)
    }
    .cat-actions{display:none;gap:4px}
    .category-item:hover .cat-actions{display:flex}
    .category-item.actions-open .cat-actions{display:flex}
    .cat-touch-toggle{display:none;width:30px;height:30px;border-radius:10px;flex:0 0 auto}
    .tiny-btn{width:26px;height:26px;border-radius:9px}
    .tiny-btn.danger:hover{color:var(--accent-5)}

    body.touch-ui .category-item{
      min-height:54px;
      padding:12px 10px;
      gap:10px;
      -webkit-tap-highlight-color:transparent;
    }
    body.touch-ui .category-item .cat-grab{
      opacity:.45;
      cursor:default;
    }
    body.touch-ui .category-item .cat-actions{
      display:none;
      margin-left:6px;
      gap:6px;
    }
    body.touch-ui .category-item .cat-touch-toggle{
      display:inline-flex;
      margin-left:4px;
      color:var(--text-secondary);
      background:rgba(255,255,255,.045);
      border:1px solid var(--border);
    }
    body.touch-ui .category-item.actions-open .cat-touch-toggle{
      color:var(--accent);
      border-color:rgba(123,107,255,.28);
      background:rgba(123,107,255,.12);
    }
    body.touch-ui .category-item.actions-open .cat-actions{
      display:flex;
      align-items:center;
    }
    body.touch-ui .category-item.actions-open{
      background:rgba(123,107,255,.12);
      border:1px solid rgba(123,107,255,.18);
      box-shadow:0 10px 24px rgba(123,107,255,.08);
    }
    body.touch-ui .category-item .tiny-btn{
      width:36px;
      height:36px;
      border-radius:12px;
    }
    body.touch-ui .category-item .tiny-btn.danger{
      color:var(--accent-5);
      border-color:rgba(251,113,133,.22);
      background:rgba(251,113,133,.08);
    }
    body.touch-ui .note-actions{
      gap:8px;
    }
    body.touch-ui .note-actions .icon-btn{
      min-height:40px;
      border-radius:13px;
    }
    body.touch-ui .btn,
    body.touch-ui .icon-btn,
    body.touch-ui .chip-btn,
    body.touch-ui .tiny-btn,
    body.touch-ui .seg-btn,
    body.touch-ui .quick-link-btn,
    body.touch-ui .stat-card,
    body.touch-ui .note-main-action,
    body.touch-ui .note-actions .icon-btn,
    body.touch-ui .theme-pill{
      -webkit-tap-highlight-color:transparent;
      touch-action:manipulation;
    }
    body.touch-ui .note-actions .icon-btn,
    body.touch-ui .footer-grid .icon-btn,
    body.touch-ui .seg-btn,
    body.touch-ui .chip-btn,
    body.touch-ui .btn{
      min-height:42px;
    }
    body.touch-ui .note-card,
    body.touch-ui .stat-card,
    body.touch-ui .quick-link-btn,
    body.touch-ui .category-item,
    body.touch-ui .note-main-action{
      transition:transform .16s ease, background .2s ease, border-color .2s ease;
    }
    body.touch-ui .tap-active{
      transform:scale(.985);
    }
    .sidebar-footer{padding:12px;border-top:1px solid var(--border);display:flex;flex-direction:column;gap:10px}
    .footer-grid{display:grid;grid-template-columns:repeat(4,1fr);gap:8px}
    .icon-btn{min-height:40px;border-radius:14px;font-size:.95rem}
    .notify-btn-wrap{position:relative}
    .notify-dot{
      position:absolute;top:8px;right:10px;width:9px;height:9px;border-radius:999px;background:#ff4d67;display:none;
      box-shadow:0 0 0 3px rgba(255,77,103,.18)
    }
    .notify-dot.show{display:block}
    .user-chip{
      display:flex;align-items:center;gap:10px;width:100%;min-height:44px;padding:8px 10px;border-radius:16px;
      border:1px solid var(--border);background:rgba(255,255,255,.04)
    }
    .avatar{
      width:30px;height:30px;border-radius:10px;display:grid;place-items:center;font-weight:800;color:#fff;
      background:linear-gradient(135deg, var(--accent), var(--accent-5))
    }
    .user-mail{flex:1;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;font-size:.82rem;color:var(--text-secondary)}

    #main{flex:1;min-width:0;display:flex;flex-direction:column;position:relative}
    .topbar{
      display:flex;align-items:flex-start;justify-content:space-between;gap:12px;padding:10px 24px 10px;
      border-bottom:1px solid var(--border);background:rgba(255,255,255,.02);backdrop-filter:blur(20px);position:sticky;top:0;z-index:6
    }
    .topbar-left{display:flex;align-items:center;gap:12px;min-width:0;flex:1 1 auto}
    .mobile-menu-btn{
      display:none;width:40px;height:40px;border-radius:14px;border:1px solid var(--border);background:rgba(255,255,255,.04);color:var(--text-primary)
    }
    .page-title-wrap{display:flex;align-items:center;gap:10px;min-width:0;flex-wrap:nowrap;overflow:visible;white-space:nowrap}
    .page-title{
      font-size:.96rem;font-weight:800;letter-spacing:-.02em;line-height:1.1;
      white-space:nowrap;overflow:visible;text-overflow:clip;word-break:normal;flex:0 0 auto
    }
    .page-desc{color:var(--text-secondary);font-size:.78rem;margin-top:2px;line-height:1.55;max-width:72ch}
    .count-badge{
      display:inline-flex;align-items:center;justify-content:center;
      min-width:56px;height:34px;padding:0 12px;border-radius:999px;background:rgba(255,255,255,.05);border:1px solid var(--border);color:var(--text-secondary);
      font-size:.96rem;font-weight:800;line-height:1.1;white-space:nowrap;margin-top:0;flex:0 0 auto
    }

    /* 关键优化：电脑端顶部操作栏不再被裁切 */
    .topbar-right{
      display:flex;align-items:center;gap:10px;flex:0 1 auto;max-width:none;min-width:0;
      flex-wrap:wrap;justify-content:flex-end;overflow:visible;padding-bottom:2px
    }
    .sort-select{min-width:158px;flex:0 0 auto}
    .action-group{
      display:flex;align-items:center;gap:10px;flex-wrap:wrap;justify-content:flex-end
    }

    .quick-links{display:flex;align-items:center;gap:8px;flex-wrap:wrap}
    .quick-links-compact{display:none;align-items:center;gap:6px;flex:0 1 auto;min-width:0}
    .quick-link-btn{
      display:inline-flex;align-items:center;justify-content:center;min-height:40px;padding:0 12px;border-radius:14px;
      border:1px solid var(--border);background:rgba(255,255,255,.04);color:var(--text-secondary);text-decoration:none;
      transition:all var(--transition);min-width:92px
    }
    .quick-link-btn:hover{background:var(--bg-hover);color:var(--text-primary);transform:translateY(-1px)}
    .quick-link-btn.icon-only{
      min-width:0;width:36px;height:36px;min-height:36px;padding:0;border-radius:12px;
      backdrop-filter:blur(16px);-webkit-backdrop-filter:blur(16px)
    }
    .quick-link-inner{display:flex;align-items:center;gap:8px}
    .quick-link-ico{width:18px;height:18px;display:grid;place-items:center;color:var(--accent)}
    .quick-link-text{font-size:.82rem;font-weight:700;white-space:nowrap}

    .quick-link-icon-img{
      width:18px;
      height:18px;
      display:block;
      object-fit:contain;
      border-radius:4px;
      flex:0 0 18px;
    }
    .quick-links-compact .quick-link-ico,
    .quick-links-compact .quick-link-icon-img{width:16px;height:16px;flex:0 0 16px}
    .danger-action{background:rgba(251,113,133,.12);border-color:rgba(251,113,133,.32);color:var(--accent-5)}
    .danger-action:hover{background:rgba(251,113,133,.18);border-color:rgba(251,113,133,.44);color:#ffc1cc}

    .workspace-banner{
      margin:8px 24px 0;padding:12px 14px;border:1px solid var(--border);border-radius:20px;
      background:linear-gradient(135deg, rgba(123,107,255,.1), rgba(68,195,255,.06));
      display:flex;align-items:center;justify-content:space-between;gap:12px;flex-wrap:wrap
    }
    .banner-main{display:flex;gap:12px;align-items:flex-start}
    .banner-icon{
      width:42px;height:42px;border-radius:14px;display:grid;place-items:center;flex-shrink:0;
      background:rgba(255,255,255,.12);color:#fff
    }
    .banner-title{font-weight:800}
    .banner-sub{color:var(--text-secondary);font-size:.84rem;line-height:1.65;margin-top:3px}
    .banner-tags{display:flex;gap:8px;flex-wrap:wrap}
    .pill{
      display:inline-flex;align-items:center;gap:6px;padding:7px 10px;border-radius:999px;
      font-size:.76rem;border:1px solid var(--border);background:rgba(255,255,255,.06);color:var(--text-secondary)
    }

    .stats-strip{
      display:flex;align-items:center;gap:10px;padding:8px 24px 0;overflow-x:auto;scrollbar-width:none
    }
    .stats-strip::-webkit-scrollbar{display:none}
    .stat-card{
      min-height:38px;padding:8px 12px;border-radius:999px;border:1px solid var(--border);background:rgba(255,255,255,.04);
      display:inline-flex;align-items:center;gap:8px;white-space:nowrap;flex:0 0 auto;transition:all var(--transition)
    }
    .stat-card:hover{transform:translateY(-1px);border-color:var(--border-strong)}
    .stat-card i{
      width:20px;height:20px;border-radius:999px;display:grid;place-items:center;background:rgba(255,255,255,.06);color:var(--accent);font-size:.82rem
    }
    .stat-label{color:var(--text-tertiary);font-size:.72rem;font-weight:700}
    .stat-value{font-size:.82rem;font-weight:800}

    .quick-filter-bar{
      display:flex;align-items:center;gap:8px;padding:8px 24px 0;overflow-x:auto;scrollbar-width:none
    }
    .quick-filter-bar::-webkit-scrollbar{display:none}
    .seg-btn{
      min-height:38px;padding:0 14px;border-radius:14px;font-size:.83rem;font-weight:700;white-space:nowrap
    }
    .seg-btn.active{
      background:linear-gradient(135deg, rgba(123,107,255,.18), rgba(68,195,255,.14));
      color:var(--text-primary);border-color:var(--border-strong)
    }

    .bulk-bar{
      display:none;align-items:center;gap:10px;padding:12px 16px;margin:12px 24px 0;border-radius:18px;
      background:rgba(123,107,255,.08);border:1px solid rgba(123,107,255,.18);flex-wrap:wrap
    }
    .bulk-bar.show{display:flex}
    .bulk-text{flex:1;color:var(--text-secondary);font-size:.86rem;min-width:180px}

    .notes-container{flex:1;overflow:auto;padding:10px 24px 24px}
    .notes-grid{display:grid;grid-template-columns:repeat(auto-fill, minmax(320px,1fr));gap:18px}
    .empty-state{
      min-height:56vh;grid-column:1/-1;display:flex;flex-direction:column;align-items:center;justify-content:center;
      text-align:center;gap:14px;color:var(--text-tertiary)
    }
    .empty-icon{
      width:80px;height:80px;border-radius:24px;display:grid;place-items:center;font-size:29px;background:rgba(255,255,255,.04);border:1px solid var(--border)
    }
    .empty-title{color:var(--text-secondary);font-size:1.04rem;font-weight:800}
    .empty-desc{max-width:340px;line-height:1.75;font-size:.88rem}
    .empty-actions{display:flex;gap:10px;flex-wrap:wrap;justify-content:center;margin-top:6px}

    .note-card{
      border-radius:24px;overflow:hidden;border:1px solid var(--border);background:linear-gradient(180deg, rgba(255,255,255,.028), rgba(255,255,255,.01)), var(--bg-tertiary);
      box-shadow:var(--shadow-glow);transition:transform var(--transition),border-color var(--transition),box-shadow var(--transition);
      position:relative;display:flex;flex-direction:column;min-height:0
    }
    .note-card:hover{transform:translateY(-3px);border-color:var(--border-strong);box-shadow:0 20px 44px rgba(0,0,0,.18), var(--shadow-glow)}
    .note-card.selected{border-color:rgba(123,107,255,.44);box-shadow:0 0 0 1px rgba(123,107,255,.2), var(--shadow-soft)}
    .note-topline{height:4px;background:var(--card-gradient)}
    .note-head{display:flex;align-items:flex-start;gap:10px;padding:16px 16px 10px}
    .note-head-main{flex:1;min-width:0;display:flex;flex-direction:column;gap:8px}
    .note-head-top{display:flex;align-items:flex-start;gap:8px;min-width:0}
    .check{margin-top:3px;accent-color:var(--accent)}
    .star-btn{
      width:30px;height:30px;border-radius:10px;border:none;background:transparent;color:var(--text-tertiary);cursor:pointer;flex:0 0 auto
    }
    .star-btn.active{color:#f6b73c}
    .star-btn:hover{background:var(--bg-hover)}
    .note-title{
      flex:1;min-width:0;font-size:1rem;font-weight:800;line-height:1.46;word-break:break-word;letter-spacing:-.01em
    }
    .note-preview-line{
      display:flex;align-items:center;gap:8px;min-width:0;padding:8px 10px;border-radius:14px;
      background:rgba(255,255,255,.035);border:1px solid rgba(255,255,255,.05);color:var(--text-secondary);font-size:.82rem
    }
    .note-preview-line i{color:var(--text-tertiary);flex:0 0 auto}
    .note-preview-text{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
    .note-body{
      position:relative;padding:0 16px 14px;color:var(--text-secondary);font-size:.9rem;line-height:var(--line-height-note);
      white-space:pre-wrap;word-break:break-word;display:-webkit-box;-webkit-line-clamp:5;-webkit-box-orient:vertical;overflow:hidden
    }
    .note-body::after{
      content:"";position:absolute;left:16px;right:16px;bottom:0;height:34px;
      background:linear-gradient(180deg, rgba(0,0,0,0), var(--bg-tertiary));
      pointer-events:none
    }
    [data-theme="light"] .note-body::after{
      background:linear-gradient(180deg, rgba(255,255,255,0), rgba(255,255,255,.96))
    }
    .note-meta{
      display:flex;flex-wrap:wrap;gap:8px;padding:0 16px 14px;color:var(--text-tertiary);font-size:.75rem
    }
    .note-primary-meta{display:flex;flex-wrap:wrap;gap:8px;padding:0 16px 10px;color:var(--text-tertiary);font-size:.75rem}
    .meta-pill{
      display:inline-flex;align-items:center;gap:6px;padding:5px 9px;border-radius:999px;border:1px solid var(--border);background:rgba(255,255,255,.04)
    }
    .note-footer{
      margin-top:auto;border-top:1px solid var(--border);padding:12px 14px;display:flex;align-items:center;gap:8px;flex-wrap:wrap
    }
    .note-main-action{flex:1 1 100%;display:flex;align-items:center;justify-content:space-between;gap:10px;padding:10px 12px;border-radius:16px;border:1px solid var(--border);background:rgba(255,255,255,.04);cursor:pointer;transition:all var(--transition)}
    .note-main-action:hover{background:var(--bg-hover);border-color:var(--border-strong)}
    .note-main-action-title{display:flex;align-items:center;gap:8px;font-size:.86rem;font-weight:700;color:var(--text-primary)}
    .note-main-action-sub{font-size:.76rem;color:var(--text-tertiary)}
    .cat-badge{
      display:inline-flex;align-items:center;gap:6px;padding:6px 10px;border-radius:999px;font-size:.76rem;font-weight:700;background:rgba(255,255,255,.04)
    }
    .cat-badge .dot{width:7px;height:7px;border-radius:999px}
    .sync-state{margin-left:auto;color:var(--text-tertiary);font-size:.74rem}
    .note-actions{display:flex;gap:6px;width:100%;flex-wrap:wrap}
    .note-actions .icon-btn{flex:1;min-height:38px;font-size:.84rem;min-width:96px}
    .note-actions .secondary-action{flex:0 0 auto;min-width:44px;padding:0 12px}

    .aux-panel-stack{
      position:absolute;top:0;right:0;bottom:0;width:min(560px,100%);pointer-events:none;z-index:30
    }
    .page-panel.aux-panel{
      position:absolute;top:0;right:0;bottom:0;width:min(560px,100%);margin:0;padding:22px 22px calc(22px + var(--safe-bottom));
      border-radius:0;border-left:1px solid var(--border);background:rgba(15,20,33,.92);
      backdrop-filter:blur(28px) saturate(150%);-webkit-backdrop-filter:blur(28px) saturate(150%);
      overflow:auto;transform:translateX(100%);transition:transform var(--ease-bounce);
      pointer-events:auto;box-shadow:-24px 0 64px rgba(0,0,0,.18)
    }
    [data-theme="light"] .page-panel.aux-panel{background:rgba(255,255,255,.95)}
    .page-panel.aux-panel.panel-open{transform:translateX(0)}
    .panel-topbar{
      display:flex;align-items:flex-start;justify-content:space-between;gap:14px;margin-bottom:16px;padding-bottom:14px;border-bottom:1px solid var(--border);
      position:sticky;top:0;z-index:2;background:inherit
    }
    .panel-kicker{color:var(--accent);font-size:.72rem;font-weight:800;letter-spacing:.14em;text-transform:uppercase;margin-bottom:6px}
    .panel-close-btn{
      width:40px;height:40px;border-radius:14px;border:1px solid var(--border);background:rgba(255,255,255,.04);color:var(--text-secondary)
    }
    .panel-close-btn:hover{background:var(--bg-hover);color:var(--text-primary);transform:translateY(-1px)}
    .about-copy,.notice-copy,.kb-card,.ai-box,.setting-box,.insight-card{
      padding:18px;border-radius:20px;border:1px solid var(--border);background:rgba(255,255,255,.04)
    }
    .about-copy,.notice-copy{white-space:pre-wrap;line-height:1.9}
    .about-copy{padding:24px}
    .ai-grid{display:grid;grid-template-columns:1fr;gap:18px;margin-top:18px}
    .ai-actions{display:grid;grid-template-columns:repeat(2, minmax(0,1fr));gap:10px;margin-top:14px}
    .ai-result{min-height:200px;white-space:pre-wrap;line-height:1.82;color:var(--text-secondary)}
    .settings-grid{display:grid;grid-template-columns:1fr;gap:14px;margin-top:18px}
    .switch{position:relative;display:inline-block;width:48px;height:28px}
    .switch input{opacity:0;width:0;height:0}
    .slider{position:absolute;inset:0;border-radius:999px;background:rgba(255,255,255,.1);border:1px solid var(--border);transition:.2s}
    .slider::before{content:"";position:absolute;width:20px;height:20px;left:4px;top:3px;border-radius:50%;background:#fff;transition:.2s}
    .switch input:checked + .slider{background:rgba(123,107,255,.28)}
    .switch input:checked + .slider::before{transform:translateX(19px)}
    .theme-card{
      padding:18px;border-radius:22px;border:1px solid var(--border);background:var(--theme-card-bg);box-shadow:0 10px 28px rgba(91,99,255,.06)
    }
    .theme-toggle-wrap{
      display:flex;align-items:center;justify-content:space-between;gap:14px;margin-top:12px;padding:12px;border-radius:18px;border:1px solid var(--border);background:rgba(255,255,255,.04)
    }
    .theme-title{font-weight:800;font-size:.95rem}
    .theme-sub{color:var(--text-secondary);font-size:.82rem;margin-top:4px}
    .theme-segment{display:flex;gap:6px;padding:6px;border-radius:999px;background:rgba(255,255,255,.06);border:1px solid var(--border);min-width:156px}
    .theme-pill{
      flex:1;min-height:40px;border:none;border-radius:999px;background:transparent;color:var(--text-secondary);font-weight:700;cursor:pointer;transition:all var(--transition)
    }
    .theme-pill.active{background:linear-gradient(135deg, var(--accent), var(--accent-2));color:#fff;box-shadow:0 10px 24px rgba(91,99,255,.2)}
    .panel-backdrop{
      position:absolute;inset:0;background:rgba(0,0,0,.18);backdrop-filter:blur(4px);-webkit-backdrop-filter:blur(4px);opacity:0;pointer-events:none;transition:opacity var(--transition);z-index:20
    }
    .panel-backdrop.show{opacity:1;pointer-events:auto}
    .fab{
      position:fixed;right:20px;bottom:calc(22px + var(--safe-bottom));width:58px;height:58px;border-radius:999px;z-index:60;
      background:linear-gradient(135deg, var(--accent), var(--accent-2));color:#fff;border:none;display:none;place-items:center;
      box-shadow:0 18px 40px rgba(91,99,255,.34);font-size:20px
    }

    .modal-overlay{
      position:fixed;inset:0;background:var(--modal-overlay);z-index:120;display:flex;align-items:center;justify-content:center;
      opacity:0;pointer-events:none;transition:opacity var(--transition);backdrop-filter:blur(10px);-webkit-backdrop-filter:blur(10px);padding:12px
    }
    .modal-overlay.open{opacity:1;pointer-events:auto}
    .modal{
      width:min(840px,94vw);max-height:calc(100vh - 24px);overflow:auto;border-radius:28px;padding:24px;
      transform:translateY(12px) scale(.98);transition:transform var(--ease-bounce)
    }
    .modal-overlay.open .modal{transform:translateY(0) scale(1)}
    .modal-header{display:flex;align-items:center;justify-content:space-between;gap:12px;margin-bottom:18px}
    .modal-title{font-size:1.12rem;font-weight:800}
    .modal-close{
      width:38px;height:38px;border-radius:12px;border:1px solid var(--border);background:rgba(255,255,255,.04);color:var(--text-secondary)
    }
    .modal-grid{display:grid;grid-template-columns:minmax(0,1fr) 300px;gap:16px}
    .editor-textarea{min-height:56vh}
    .editor-ai-box{
      padding:16px;border-radius:20px;border:1px solid var(--border);
      background:linear-gradient(180deg, rgba(123,107,255,.08), rgba(255,255,255,.03))
    }
    .editor-ai-head{display:flex;align-items:flex-start;justify-content:space-between;gap:10px;margin-bottom:12px}
    .editor-ai-sub{color:var(--text-secondary);font-size:.8rem;line-height:1.65}
    .editor-ai-actions{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:8px;margin-bottom:12px}
    .editor-ai-actions .btn{min-height:38px;padding:0 10px}
    .editor-ai-result{
      min-height:180px;padding:12px;border-radius:16px;border:1px solid var(--border);
      background:rgba(255,255,255,.04);white-space:pre-wrap;line-height:1.8;color:var(--text-secondary)
    }
    .editor-ai-footer{display:flex;gap:8px;margin-top:12px}
    .editor-main-column{min-width:0}
    .editor-side-column{min-width:0}
    .field-stack{display:flex;flex-direction:column;gap:14px}
    .inline-row{display:flex;gap:10px}
    .helper-text{margin-top:8px;color:var(--text-tertiary);font-size:.78rem;line-height:1.6}
    .editor-stats{display:grid;grid-template-columns:1fr 1fr;gap:10px}
    .editor-stat{
      padding:12px;border-radius:16px;border:1px solid var(--border);background:rgba(255,255,255,.035)
    }
    .editor-stat .k{color:var(--text-tertiary);font-size:.72rem;font-weight:700}
    .editor-stat .v{display:block;font-size:1.06rem;font-weight:800;margin-top:4px}
    .focus-tip{
      display:flex;gap:10px;align-items:flex-start;border:1px solid var(--border);background:rgba(255,255,255,.04);padding:14px;border-radius:18px;color:var(--text-secondary);line-height:1.72;font-size:.84rem
    }
    .editor-primary-actions{
      display:flex;gap:10px;align-items:center;justify-content:flex-end;flex-wrap:wrap;
      padding:14px;border-radius:20px;border:1px solid var(--border);
      background:linear-gradient(180deg, rgba(123,107,255,.08), rgba(255,255,255,.03));
      box-shadow:0 12px 26px rgba(0,0,0,.12)
    }
    .editor-primary-actions .btn{
      min-width:116px;
    }
    .editor-primary-actions .btn-primary{
      box-shadow:0 12px 24px rgba(91,99,255,.22)
    }
    .editor-mobile-savebar{display:none}
    .editor-mobile-savebar .savebar-card{
      display:flex;align-items:center;gap:10px;padding:12px 14px;border-radius:20px;border:1px solid var(--border);
      background:rgba(12,17,29,.92);backdrop-filter:blur(20px) saturate(150%);-webkit-backdrop-filter:blur(20px) saturate(150%);
      box-shadow:0 -10px 30px rgba(0,0,0,.16), var(--shadow-glow)
    }
    [data-theme="light"] .editor-mobile-savebar .savebar-card{background:rgba(255,255,255,.94)}
    .editor-mobile-saveinfo{flex:1;min-width:0}
    .editor-mobile-saveinfo .k{font-size:.72rem;color:var(--text-tertiary);font-weight:700}
    .editor-mobile-saveinfo .v{display:block;margin-top:3px;font-size:.92rem;font-weight:800;color:var(--text-primary);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
    .editor-mobile-saveactions{display:flex;gap:8px;flex:0 0 auto}
    .editor-mobile-saveactions .btn{min-height:44px;border-radius:14px;padding:0 14px}

    #sidebar-overlay{display:none;position:fixed;inset:0;background:rgba(0,0,0,.45);z-index:8}
    #sidebar-overlay.show{display:block}
    .toast-area{position:fixed;right:22px;bottom:calc(22px + var(--safe-bottom));z-index:200;display:flex;flex-direction:column;gap:10px}
    .toast{
      min-width:240px;max-width:360px;border-radius:18px;padding:12px 14px;display:flex;gap:10px;align-items:flex-start;
      border:1px solid var(--border);background:var(--bg-tertiary);box-shadow:var(--shadow-soft);animation:toastIn .25s ease
    }
    .toast i{margin-top:2px}
    .toast.success i{color:var(--accent-3)}
    .toast.error i{color:var(--accent-5)}
    .toast.info i{color:var(--accent-2)}
    @keyframes toastIn{from{transform:translateY(10px);opacity:0}to{transform:none;opacity:1}}

    .mobile-only-inline{display:none !important}
    .scroll-top-btn{
      position:fixed;right:20px;bottom:calc(92px + var(--safe-bottom));width:48px;height:48px;border-radius:999px;z-index:59;
      border:1px solid var(--border);background:rgba(15,20,33,.88);backdrop-filter:blur(18px);-webkit-backdrop-filter:blur(18px);
      color:var(--text-primary);display:grid;place-items:center;box-shadow:0 14px 28px rgba(0,0,0,.22);
      opacity:0;pointer-events:none;transform:translateY(10px);transition:all var(--transition)
    }
    [data-theme="light"] .scroll-top-btn{background:rgba(255,255,255,.92)}
    .scroll-top-btn.show{opacity:1;pointer-events:auto;transform:none}

    body.compact-notes .topbar{padding:10px 24px 10px}
    body.compact-notes .workspace-banner{display:none}
    body.compact-notes .stats-strip{padding-top:8px}
    body.compact-notes .quick-filter-bar{padding-top:8px}
    body.compact-notes #notes-view{padding-top:12px}
    body.compact-notes .page-desc.notes-page-desc{display:none}
    body.compact-notes .count-badge{margin-top:0}

    body.focus-mode #sidebar{display:none}
    body.focus-mode .workspace-banner,
    body.focus-mode .stats-strip,
    body.focus-mode .quick-filter-bar,
    body.focus-mode .bulk-bar{display:none !important}
    body.focus-mode #main{width:100%}
    body.focus-mode .topbar{padding:10px 20px 10px}
    body.focus-mode .notes-container{padding-top:12px}

    .desktop-mode-btn{display:inline-flex}
    .banner-compact{padding:10px 14px;border-radius:18px;align-items:center}
    .banner-compact .banner-icon{width:36px;height:36px;border-radius:12px}
    .banner-compact .banner-title{font-size:.95rem}
    .banner-compact .banner-sub{font-size:.8rem;line-height:1.6}
    .topbar.page-lean{padding:12px 24px 12px}
    .topbar.page-lean .page-desc.notes-page-desc{display:none}


    @media (min-width:1181px){
      .topbar-right{align-items:flex-end}
      .action-group{width:100%;justify-content:flex-end}
      .sort-select{
        min-width:0;
        width:360px;
        max-width:360px;
        margin-left:auto;
      }
    }

    @media (max-width:1180px){
      .notes-grid{grid-template-columns:repeat(auto-fill, minmax(290px,1fr))}
      .topbar-right{justify-content:flex-start}
      .quick-links{display:none !important}
      .quick-links-compact{display:flex}
      .count-badge{margin-left:auto}
    }

    @media (max-width:900px){
      #sidebar{
        position:fixed;left:0;top:0;bottom:0;transform:translateX(-100%);z-index:50;box-shadow:0 24px 60px rgba(0,0,0,.3)
      }
      .topbar{flex-wrap:wrap;align-items:flex-start}
      .topbar-left{width:100%;align-items:center;flex-wrap:nowrap}
      .page-title-wrap{display:flex;align-items:center;gap:10px;flex-wrap:nowrap;min-width:0;flex:1 1 auto;overflow:visible;white-space:nowrap}
      .page-title{font-size:.96rem;line-height:1.1;white-space:nowrap;overflow:visible;text-overflow:clip;word-break:normal;flex:0 0 auto}
      .count-badge{display:inline-flex;font-size:.96rem;line-height:1.1;flex:0 0 auto}
      .topbar-right{width:100%;justify-content:flex-start}
      #sidebar.open{transform:translateX(0)}
      .mobile-menu-btn{display:grid;place-items:center}
      .topbar{padding:calc(10px + var(--safe-top)) 16px 8px}
      .workspace-banner{margin:8px 16px 0}
      .notes-container{padding:8px 16px 24px}
      .stats-strip,.quick-filter-bar{padding-left:16px;padding-right:16px}
      .bulk-bar{margin:12px 16px 0}
      .notes-grid{grid-template-columns:1fr;gap:14px}
      .fab{display:grid}
      .modal-grid{grid-template-columns:1fr}
      .editor-textarea{min-height:38vh}
      .editor-ai-actions{grid-template-columns:1fr 1fr}
      .editor-ai-footer{flex-direction:column}
      .editor-primary-actions{display:none}
      .editor-mobile-savebar{
        display:block;position:sticky;bottom:0;z-index:6;margin-top:14px;
        padding-top:8px;padding-bottom:calc(2px + var(--safe-bottom));
        background:linear-gradient(180deg, rgba(9,11,19,0), rgba(9,11,19,.78) 26%, rgba(9,11,19,.96))
      }
      [data-theme="light"] .editor-mobile-savebar{
        background:linear-gradient(180deg, rgba(255,255,255,0), rgba(255,255,255,.82) 26%, rgba(255,255,255,.97))
      }
      .aux-panel-stack{position:fixed;inset:0;width:100%;z-index:80;pointer-events:none}
      .page-panel.aux-panel{
        width:100%;transform:translateY(100%);border-left:none;border-top-left-radius:24px;border-top-right-radius:24px;
        top:auto;height:min(100vh, 100dvh);padding:18px 16px calc(18px + var(--safe-bottom));box-shadow:0 -24px 60px rgba(0,0,0,.26)
      }
      .page-panel.aux-panel.panel-open{transform:translateY(0)}
      .panel-backdrop.show{position:fixed;z-index:70}
    }

    @media (max-width:640px){
      :root{--font-size-base:14px}
      .topbar{
        flex-wrap:wrap;
        padding:calc(6px + var(--safe-top)) 12px 6px;
        gap:8px;
        align-items:center;
        transition:padding var(--transition), background var(--transition), border-color var(--transition)
      }
      body.mobile-compact-header .topbar{
        padding:calc(6px + var(--safe-top)) 12px 6px;
        background:rgba(9,11,19,.86)
      }
      [data-theme="light"] body.mobile-compact-header .topbar{background:rgba(255,255,255,.86)}
      .topbar-left{width:100%;gap:8px;align-items:center;flex-wrap:nowrap}
      .mobile-menu-btn{width:36px;height:36px;border-radius:12px;flex:0 0 36px}
      .page-title-wrap{display:flex;align-items:center;min-width:0;gap:8px;flex-wrap:nowrap;overflow:visible;flex:1 1 auto;white-space:nowrap}
      .page-title{font-size:.96rem;line-height:1.15;white-space:nowrap;overflow:visible;text-overflow:clip;word-break:normal;transition:font-size var(--transition);flex:0 0 auto}
      body.mobile-compact-header .page-title{font-size:.9rem}
      .page-desc{display:none}
      .quick-links-compact{gap:4px;max-width:calc(100vw - 180px);overflow:hidden}
      .quick-links-compact .quick-link-btn.icon-only{
        width:30px;height:30px;min-height:30px;border-radius:10px
      }
      .quick-links-compact .quick-link-ico,
      .quick-links-compact .quick-link-icon-img{width:14px;height:14px;flex:0 0 14px}
      .count-badge{display:inline-flex;font-size:.96rem;line-height:1.15;flex:0 0 auto}
      .topbar-right{width:100%;justify-content:space-between;gap:8px;transition:transform var(--transition), opacity var(--transition)}
      .topbar-right .action-group{width:100%;gap:8px;display:grid;grid-template-columns:36px 1fr 96px}
      .topbar-right .sort-select{min-width:0;width:100%}
      .topbar-right .btn{min-height:36px;padding:0 12px;border-radius:12px}
      .topbar-right .btn-ghost{display:none}
      .desktop-mode-btn{display:none !important}
      .topbar-right .btn-primary{min-width:96px}
      .mobile-only-inline{display:inline-flex !important}
      .mobile-search-btn{width:36px;min-width:36px;padding:0;border-radius:12px}
      .workspace-banner,
      .stats-strip{display:none !important}
      .quick-filter-bar{
        padding:6px 12px 0;
        gap:6px;
        position:sticky;
        top:60px;
        z-index:5;
        background:linear-gradient(180deg, var(--bg-primary), rgba(0,0,0,0));
        transition:transform var(--transition), opacity var(--transition), padding var(--transition)
      }
      body.mobile-compact-header .quick-filter-bar{
        transform:translateY(-110%);
        opacity:0;
        pointer-events:none;
        padding-top:0
      }
      .seg-btn{min-height:34px;padding:0 11px;border-radius:12px;font-size:.78rem}
      .seg-btn i{display:none}
      .notes-container{padding:6px 12px 20px}
      .notes-grid{gap:12px}
      .note-card{min-height:0;border-radius:20px}
      .note-head{padding:14px 14px 8px;gap:8px}
      .note-head-main{gap:7px}
      .note-preview-line{padding:7px 9px;border-radius:12px;font-size:.78rem}
      .note-body{padding:0 14px 10px;font-size:.86rem;-webkit-line-clamp:4}
      .note-primary-meta{padding:0 14px 10px;gap:6px}
      .note-meta{display:none}
      .note-footer{padding:10px 12px;gap:8px}
      .note-main-action{padding:9px 10px;border-radius:14px}
      .bulk-bar{margin:8px 12px 0;padding:10px 12px;border-radius:16px}
      .banner-main{width:100%}
      .theme-toggle-wrap{flex-direction:column;align-items:stretch}
      .theme-segment{width:100%;min-width:0}
      .auth-card{padding:24px}
      .modal{width:calc(100vw - 12px);max-height:calc(100vh - 12px);padding:16px 16px calc(92px + var(--safe-bottom));border-radius:22px}
      .editor-mobile-savebar .savebar-card{padding:10px 12px;border-radius:18px}
      .editor-mobile-saveactions{display:grid;grid-template-columns:1fr 1fr;flex:1}
      .editor-mobile-saveactions .btn{min-width:0;padding:0 12px;font-size:.84rem}
      .inline-row{flex-direction:column}
      .editor-primary-actions{
        padding:12px;
        gap:8px;
        border-radius:18px;
      }
      .editor-primary-actions .btn{
        flex:1 1 calc(50% - 4px);
        min-width:0;
        min-height:42px;
        border-radius:14px;
      }
      .footer-grid{grid-template-columns:repeat(4,1fr)}
      .ai-actions{grid-template-columns:1fr}
      .note-actions .icon-btn{min-width:calc(50% - 3px)}
      .toast-area{left:12px;right:12px;bottom:calc(12px + var(--safe-bottom))}
      .toast{min-width:0;max-width:none;width:100%}
      .scroll-top-btn{right:14px;bottom:calc(84px + var(--safe-bottom));width:44px;height:44px}
    }
  
@media (max-width:900px){
  #focus-mode-btn{display:none !important}
}


#overview-view .overview-mobile-stats{
  scrollbar-width:none;
}
#overview-view .overview-mobile-stats::-webkit-scrollbar{
  display:none;
}
#overview-view .overview-mobile-stats .stat-card{
  min-width:112px;
}
#overview-view .setting-box,
#overview-view .kb-card{
  margin-top:18px;
}
@media (max-width:640px){
  #overview-view{
    padding-top:16px;
  }
  #overview-view .overview-mobile-stats{
    padding-top:0 !important;
    margin-top:2px;
  }
  #overview-view .overview-mobile-stats .stat-card{
    min-width:124px;
  }
}


#overview-view .overview-sync-box,
#overview-view .overview-actions-box{
  border-radius:20px;
}
#overview-view .overview-action-grid .btn{
  min-height:42px;
}
@media (max-width:640px){
  #overview-view .overview-action-grid{
    grid-template-columns:repeat(2,minmax(0,1fr)) !important;
  }
  #overview-view .overview-action-grid .btn{
    min-height:40px;
    padding:0 10px;
    border-radius:14px;
    font-size:.82rem;
  }
}


    .note-actions .copy-action{
      flex:1 1 auto;
      min-width:0;
    }
    .note-actions .delete-action{
      flex:0 0 48px;
      min-width:48px;
      padding:0 12px;
    }
    .ai-helper-note{
      margin-top:12px;
      padding:12px 14px;
      border-radius:16px;
      border:1px solid var(--border);
      background:rgba(255,255,255,.04);
      color:var(--text-secondary);
      line-height:1.75;
      font-size:.82rem;
    }
    .editor-ai-footer{
      display:grid;
      grid-template-columns:repeat(2,minmax(0,1fr));
      gap:8px;
      margin-top:12px;
    }
    @media (max-width:640px){
      .note-actions{
        display:flex;
        flex-wrap:nowrap;
        align-items:center;
      }
      .note-actions .copy-action{
        flex:1 1 auto;
        min-width:0;
      }
      .note-actions .delete-action{
        flex:0 0 42px;
        min-width:42px;
        width:42px;
        padding:0;
      }
      .note-actions .delete-action i{
        margin:0;
      }
      .editor-ai-footer{
        grid-template-columns:repeat(2,minmax(0,1fr));
      }
      .editor-ai-footer .btn{
        min-width:0 !important;
        padding:0 10px;
      }
    }


    .ai-status-bar{display:flex;align-items:center;justify-content:space-between;gap:10px;margin-top:12px;padding:10px 12px;border-radius:14px;border:1px solid var(--border);background:rgba(255,255,255,.035)}
    .ai-status-text{font-size:.8rem;color:var(--text-secondary);line-height:1.6}
    .ai-status-actions{display:flex;gap:8px;flex-wrap:wrap}
    .ai-status-actions .tiny-btn{width:auto;min-width:40px;padding:0 10px}
    .ai-status-actions .tiny-btn[disabled]{opacity:.55;cursor:not-allowed}
    .save-note-trigger[disabled], .btn[disabled], .icon-btn[disabled], .tiny-btn[disabled]{opacity:.65;cursor:not-allowed;transform:none !important}
    .input:focus-visible,.textarea:focus-visible,.select:focus-visible,.btn:focus-visible,.icon-btn:focus-visible,.tiny-btn:focus-visible,.seg-btn:focus-visible,.chip-btn:focus-visible,.quick-link-btn:focus-visible,.theme-pill:focus-visible,.mobile-menu-btn:focus-visible,.modal-close:focus-visible,.panel-close-btn:focus-visible{outline:2px solid var(--accent);outline-offset:2px}
    @media (max-width:640px){
      .ai-status-bar{align-items:flex-start;flex-direction:column}
      .ai-status-actions{width:100%}
    }

.ai-recommend-wrap{margin-top:12px;display:grid;gap:10px}
.ai-recommend-card{padding:12px 14px;border-radius:16px;border:1px solid var(--border);background:rgba(255,255,255,.04)}
.ai-recommend-title{font-size:.8rem;font-weight:800;color:var(--text-primary);margin-bottom:6px}
.ai-recommend-text{font-size:.8rem;line-height:1.75;color:var(--text-secondary)}
.ai-recommend-actions{display:flex;gap:8px;flex-wrap:wrap;margin-top:10px}
.ai-recommend-actions .btn,.ai-recommend-actions .tiny-btn{min-height:36px}
.ai-result.is-cached,.editor-ai-result.is-cached{box-shadow:0 0 0 1px rgba(52,211,153,.18) inset}
@media (max-width:640px){
  .ai-recommend-actions{display:grid;grid-template-columns:1fr 1fr}
  .ai-recommend-actions .btn,.ai-recommend-actions .tiny-btn{width:100%;min-width:0}
}


/* phase 3 usability polish */

.ai-recommend-actions .tiny-btn{
  width:auto;
  min-width:92px;
  padding:0 12px;
  white-space:nowrap;
  writing-mode:horizontal-tb;
}
.ai-recommend-actions .btn{
  white-space:nowrap;
}
.editor-modal-grid{
  align-items:start;
}
.editor-side-column{
  position:sticky;
  top:0;
}
.editor-ai-box{
  display:flex;
  flex-direction:column;
  gap:12px;
}
.editor-ai-result-wrap{
  position:relative;
}
.editor-ai-result{
  min-height:200px;
  max-height:260px;
  overflow:auto;
  padding-right:10px;
  scroll-behavior:smooth;
}
.editor-ai-result-tools{
  display:flex;
  gap:8px;
  flex-wrap:wrap;
  margin-top:10px;
}
.editor-ai-result-tools .tiny-btn{
  width:auto;
  min-width:86px;
  padding:0 10px;
}
.editor-ai-footer{
  position:sticky;
  bottom:0;
  z-index:2;
  padding-top:12px;
  background:linear-gradient(180deg, rgba(9,11,19,0), rgba(9,11,19,.78) 22%, rgba(9,11,19,.96));
}
[data-theme="light"] .editor-ai-footer{
  background:linear-gradient(180deg, rgba(255,255,255,0), rgba(255,255,255,.82) 22%, rgba(255,255,255,.98));
}
.editor-ai-footer .btn{
  min-height:40px;
}
@media (max-width:900px){
  .editor-side-column{position:static;}
  .editor-ai-result{max-height:220px;}
}
@media (max-width:640px){
  .ai-recommend-actions{display:grid;grid-template-columns:1fr 1fr;}
  .ai-recommend-actions .tiny-btn,
  .ai-recommend-actions .btn{min-width:0;width:100%;}
  .editor-ai-result{max-height:200px;}
  .editor-ai-result-tools{display:grid;grid-template-columns:1fr 1fr;}
  .editor-ai-result-tools .tiny-btn{min-width:0;width:100%;}
}


/* phase 4 practical ai cleanup */
.ai-actions-compact,.editor-ai-actions-compact{grid-template-columns:repeat(2,minmax(0,1fr));}
.editor-primary-actions{display:none !important;}
.editor-mobile-savebar{display:block;position:sticky;bottom:0;z-index:8;margin-top:14px;padding-top:10px;padding-bottom:calc(4px + var(--safe-bottom));background:linear-gradient(180deg, rgba(9,11,19,0), rgba(9,11,19,.78) 26%, rgba(9,11,19,.96));}
[data-theme="light"] .editor-mobile-savebar{background:linear-gradient(180deg, rgba(255,255,255,0), rgba(255,255,255,.82) 26%, rgba(255,255,255,.97));}
.editor-mobile-savebar .savebar-card{position:sticky;bottom:0;}
.editor-ai-result{min-height:220px;max-height:300px;}
.editor-ai-result-tools{display:grid;grid-template-columns:1fr 1fr;gap:8px;}
.editor-ai-result-tools .tiny-btn{min-width:0;width:100%;}
.editor-ai-footer{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:8px;position:sticky;bottom:calc(74px + var(--safe-bottom));z-index:5;padding-top:12px;}
.editor-ai-footer .btn{min-width:0;width:100%;}
.editor-side-column{padding-bottom:8px;}
.ai-helper-note{font-size:.8rem;}
@media (max-width:900px){
  .editor-ai-footer{bottom:calc(72px + var(--safe-bottom));}
  .editor-ai-result{max-height:240px;}
}
@media (max-width:640px){
  .ai-actions-compact,.editor-ai-actions-compact{grid-template-columns:1fr 1fr;}
  .editor-ai-footer{bottom:calc(82px + var(--safe-bottom));}
}


/* phase 5 template-driven AI */
.template-list{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:12px;margin-top:14px;max-height:56vh;overflow:auto;padding-right:4px}
.template-card{padding:14px;border-radius:18px;border:1px solid var(--border);background:rgba(255,255,255,.04);display:flex;flex-direction:column;gap:8px}
.template-card-head{display:flex;align-items:flex-start;justify-content:space-between;gap:10px}
.template-card-title{font-size:.92rem;font-weight:800;color:var(--text-primary)}
.template-card-desc{font-size:.8rem;line-height:1.7;color:var(--text-secondary)}
.template-card-tags{display:flex;gap:6px;flex-wrap:wrap}
.template-card-tags .pill{padding:5px 8px;font-size:.72rem}
.template-card-actions{display:flex;gap:8px;flex-wrap:wrap;margin-top:auto}
.template-card-actions .btn{min-height:38px;padding:0 12px}
.ai-route-badge{display:inline-flex;align-items:center;gap:6px;padding:6px 10px;border-radius:999px;border:1px solid var(--border);background:rgba(52,211,153,.1);color:var(--accent-3);font-size:.75rem;font-weight:700;margin-bottom:10px}
.ai-route-reason{font-size:.8rem;line-height:1.7;color:var(--text-secondary);margin-bottom:10px}
.editor-primary-actions{display:flex !important;position:sticky;bottom:0;z-index:7;padding:12px;border-radius:18px;background:linear-gradient(180deg, rgba(9,11,19,0), rgba(9,11,19,.78) 22%, rgba(9,11,19,.97));backdrop-filter:blur(12px)}
[data-theme="light"] .editor-primary-actions{background:linear-gradient(180deg, rgba(255,255,255,0), rgba(255,255,255,.82) 22%, rgba(255,255,255,.98));}
.editor-primary-actions .btn{min-height:44px}
@media (max-width:900px){.template-list{grid-template-columns:1fr}.editor-primary-actions{display:none !important}.editor-mobile-savebar{display:block}}
@media (min-width:901px){.editor-mobile-savebar{display:none !important}}


/* phase 6 cleanup */
.ai-recommend-wrap{display:none !important}
.ai-actions-compact,.editor-ai-actions-compact{grid-template-columns:repeat(3,minmax(0,1fr));gap:10px}
.ai-actions-compact .btn,.editor-ai-actions-compact .btn{min-height:42px}
.editor-modal-grid{grid-template-columns:minmax(0,1.25fr) minmax(320px,.85fr);align-items:start}
.editor-side-column{position:sticky;top:0;align-self:start;padding-bottom:200px}
.editor-ai-box{background:linear-gradient(180deg, rgba(123,107,255,.06), rgba(255,255,255,.025));border-radius:22px}
.editor-ai-result{min-height:260px;max-height:320px;overflow:auto;padding:14px 14px 18px;line-height:1.9;font-size:.9rem;border-radius:18px;background:rgba(255,255,255,.045)}
.editor-ai-result-tools{position:sticky;bottom:0;z-index:4;padding-top:10px;background:linear-gradient(180deg, rgba(9,11,19,0), rgba(9,11,19,.92) 35%)}
[data-theme="light"] .editor-ai-result-tools{background:linear-gradient(180deg, rgba(255,255,255,0), rgba(255,255,255,.95) 35%)}
.editor-ai-footer{position:sticky;bottom:88px;z-index:4;padding-top:10px;background:linear-gradient(180deg, rgba(9,11,19,0), rgba(9,11,19,.94) 35%)}
[data-theme="light"] .editor-ai-footer{background:linear-gradient(180deg, rgba(255,255,255,0), rgba(255,255,255,.97) 35%)}
.editor-global-savebar{position:sticky;bottom:0;z-index:15;margin-top:16px;padding-top:10px;padding-bottom:calc(6px + var(--safe-bottom));background:linear-gradient(180deg, rgba(9,11,19,0), rgba(9,11,19,.80) 25%, rgba(9,11,19,.98))}
[data-theme="light"] .editor-global-savebar{background:linear-gradient(180deg, rgba(255,255,255,0), rgba(255,255,255,.84) 25%, rgba(255,255,255,.98))}
.editor-global-savebar .savebar-card{display:flex;align-items:center;gap:10px;padding:12px 14px;border-radius:20px;border:1px solid var(--border);background:rgba(12,17,29,.94);backdrop-filter:blur(18px) saturate(150%);box-shadow:0 -8px 26px rgba(0,0,0,.15), var(--shadow-glow)}
[data-theme="light"] .editor-global-savebar .savebar-card{background:rgba(255,255,255,.95)}
.editor-global-savebar .editor-mobile-saveactions{display:flex;gap:8px;margin-left:auto}
.editor-global-savebar .btn{min-height:44px;border-radius:14px}
.editor-primary-actions,.editor-mobile-savebar{display:none !important}
@media (max-width:900px){
  .editor-modal-grid{grid-template-columns:1fr}
  .editor-side-column{position:static;padding-bottom:0}
  .ai-actions-compact,.editor-ai-actions-compact{grid-template-columns:1fr 1fr}
  .editor-ai-result{max-height:260px}
  .editor-ai-footer{bottom:96px}
}
@media (max-width:640px){
  .editor-global-savebar .savebar-card{padding:10px 12px;border-radius:18px}
  .editor-global-savebar .editor-mobile-saveactions{display:grid;grid-template-columns:1fr 1fr;flex:1;margin-left:0}
  .editor-global-savebar .btn{min-width:0;padding:0 12px;font-size:.84rem}
}


/* phase 7 template manager + refined editor */
.hidden-legacy-savebar{display:none !important}
.editor-modal-grid{grid-template-columns:minmax(0,1.35fr) minmax(340px,.92fr);gap:18px;align-items:start}
.editor-main-column,.editor-side-column{display:flex;flex-direction:column;gap:14px}
.editor-side-column{position:relative;top:auto;padding-bottom:0}
.editor-ai-box{padding:18px;border-radius:24px;background:linear-gradient(180deg, rgba(123,107,255,.07), rgba(255,255,255,.03));box-shadow:0 16px 30px rgba(0,0,0,.08)}
.editor-ai-sub{font-size:.82rem;line-height:1.75}
.editor-ai-actions-compact{grid-template-columns:1fr;gap:10px}
.editor-ai-actions-compact .btn{justify-content:flex-start;padding:0 14px}
.editor-ai-result-wrap{border:1px solid var(--border);border-radius:20px;background:rgba(255,255,255,.035);padding:10px}
.editor-ai-result{min-height:280px;max-height:min(38vh,420px);overflow:auto;padding:16px;border:none;background:transparent;line-height:1.9;font-size:.92rem}
.editor-ai-result-tools{position:static;padding-top:8px;background:none;display:grid;grid-template-columns:1fr 1fr;gap:8px}
.editor-ai-result-tools .tiny-btn{width:100%;height:40px;border-radius:12px}
.ai-status-bar{padding:12px 14px;border-radius:16px}
.editor-ai-footer{position:static;display:grid;grid-template-columns:1fr 1fr;gap:10px;padding-top:0;background:none}
.editor-ai-footer .btn{min-height:42px}
.editor-global-savebar{position:sticky;bottom:-16px;z-index:25;margin-top:18px;padding-top:12px;padding-bottom:calc(10px + var(--safe-bottom));background:linear-gradient(180deg, rgba(9,11,19,0), rgba(9,11,19,.72) 18%, rgba(9,11,19,.98) 58%)}
[data-theme="light"] .editor-global-savebar{background:linear-gradient(180deg, rgba(255,255,255,0), rgba(255,255,255,.8) 18%, rgba(255,255,255,.99) 58%)}
.editor-global-savebar .savebar-card{display:flex;align-items:center;gap:10px;padding:14px 16px;border-radius:22px;border:1px solid var(--border);background:rgba(12,17,29,.94);backdrop-filter:blur(18px) saturate(150%);box-shadow:0 -8px 26px rgba(0,0,0,.15), var(--shadow-glow)}
[data-theme="light"] .editor-global-savebar .savebar-card{background:rgba(255,255,255,.95)}
.editor-global-savebar .editor-mobile-saveactions{display:flex;gap:10px;margin-left:auto}
.editor-global-savebar .btn{min-height:46px;padding:0 16px}
.template-manager-layout{display:grid;grid-template-columns:minmax(280px,.9fr) minmax(0,1.2fr);gap:18px}
.template-manager-list-panel,.template-manager-editor-panel{padding:16px;border-radius:22px;border:1px solid var(--border);background:rgba(255,255,255,.04)}
.template-manager-toolbar{display:flex;gap:10px;margin:12px 0}
.template-manager-list{display:flex;flex-direction:column;gap:8px;max-height:58vh;overflow:auto;padding-right:4px}
.template-manager-item{display:flex;align-items:flex-start;justify-content:space-between;gap:10px;padding:12px 14px;border-radius:16px;border:1px solid var(--border);background:rgba(255,255,255,.03);color:var(--text-primary);text-align:left}
.template-manager-item:hover{background:var(--bg-hover)}
.template-manager-item-title{font-weight:800;font-size:.9rem}
.template-manager-item-desc{font-size:.8rem;line-height:1.65;color:var(--text-secondary);margin-top:4px}
.template-manager-checks{display:grid;grid-template-columns:1fr 1fr 1fr;gap:10px;color:var(--text-secondary);font-size:.84rem}
.template-manager-actions{display:flex;gap:10px;flex-wrap:wrap}
#tm-prompt{min-height:220px}
@media (max-width:900px){.template-manager-layout{grid-template-columns:1fr}.editor-modal-grid{grid-template-columns:1fr;gap:14px}.editor-ai-actions-compact{grid-template-columns:1fr 1fr 1fr}.editor-ai-result{max-height:34vh}}
@media (max-width:640px){.editor-ai-actions-compact{grid-template-columns:1fr}.editor-ai-footer{grid-template-columns:1fr 1fr}.template-manager-toolbar{flex-direction:column}.template-manager-checks{grid-template-columns:1fr}.editor-global-savebar .savebar-card{padding:12px;border-radius:18px}.editor-global-savebar .editor-mobile-saveactions{display:grid;grid-template-columns:1fr 1fr;flex:1;margin-left:0}}
