  :root{
    --paper: #FFFFFF;
    --paper-deep: #ECECEC;
    --card: #FFFFFF;
    --ink: #111111;
    --ink-soft: #5C5C5C;
    --ink-faint: #9A9A9A;
    --accent-1: #F55513;
    --accent-2: #DD557E;
    --accent: linear-gradient(135deg, var(--accent-1) 0%, var(--accent-2) 100%);
    --accent-dark: #C43D0C;
    --on-accent: #FFFFFF;
    --danger: #111111;
    --danger-bg: #ECECEC;
    --danger-hover: #000000;
    --border: #D9D9D9;
    --radius: 10px;
    --bar-gap: 20px;
    --bar-height: 64px;
    --bar-bg: rgba(0, 0, 0, 0.3);
    --bar-bg-open: rgba(0, 0, 0, 0.64);
    --tray-text: rgba(255,255,255,0.6);
    --tray-text-strong: #FFFFFF;
    --tray-text-faint: rgba(255,255,255,0.55);
    --tray-border: rgba(255,255,255,0.16);
    --tray-hover-bg: rgba(255,255,255,0.14);
    --tray-hover-border: rgba(255,255,255,0.22);
  }

  body.theme-dark{
    --paper: #121212;
    --paper-deep: #1E1E1E;
    --card: #1A1A1A;
    --ink: #F2F2F2;
    --ink-soft: #B0B0B0;
    --ink-faint: #6E6E6E;
    --danger: #F2F2F2;
    --danger-bg: #262626;
    --danger-hover: #FFFFFF;
    --border: #333333;
    --bar-bg: rgba(255, 255, 255, 0.12);
    --bar-bg-open: rgba(255, 255, 255, 0.20);
    --tray-text: rgba(17,17,17,0.6);
    --tray-text-strong: #111111;
    --tray-text-faint: rgba(17,17,17,0.55);
    --tray-border: rgba(17,17,17,0.16);
    --tray-hover-bg: rgba(17,17,17,0.10);
    --tray-hover-border: rgba(17,17,17,0.22);
  }

  *{box-sizing:border-box;}
  html,body{height:100%; overflow-x:hidden; max-width:100%;}
  body{
    margin:0;
    font-family:'Manrope', sans-serif;
    color:var(--ink);
    background:var(--paper);
    -webkit-font-smoothing:antialiased;
    transition: background .25s ease, color .25s ease;
  }

  .app{
    display:flex;
    flex-direction:column;
    height:100vh;
    width:100%;
    overflow:hidden;
  }

  /* ---------- Top logo ---------- */
  .top-bar{
    position:relative;
    flex-shrink:0;
    padding:20px 30px;
    display:flex;
    align-items:center;
    justify-content:space-between;
    flex-wrap:wrap;
    gap:16px;
  }
  .top-bar-right{display:flex; align-items:center; gap:8px; flex-shrink:0;}
  .logo-mark{
    height:30px;
    width:auto;
    display:block;
    cursor:pointer;
    flex-shrink:0;
    transition: filter .25s ease, opacity .15s ease;
  }
  .logo-mark:hover{opacity:0.75;}
/*  body.theme-dark .logo-mark{filter:invert(1);}*/
  .header-actions{
    display:flex;
    align-items:center;
    gap:10px;
    flex-wrap:wrap;
  }

  /* ---------- Mobile hamburger menu (hidden on desktop; shown under 640px) ---------- */
  .hamburger-wrap{position:relative; display:none;}
  .hamburger-btn.active-state{background:var(--card); color:var(--ink);}
  .hamburger-menu{
    display:none;
    position:absolute;
    top:calc(100% + 8px);
    right:0;
    min-width:170px;
    background:var(--card);
    border:1px solid var(--border);
    border-radius:12px;
    box-shadow: 0 14px 32px rgba(0,0,0,0.18);
    padding:6px;
    z-index:130;
    flex-direction:column;
    gap:2px;
  }
  .hamburger-menu.show{display:flex;}
  .hamburger-item{
    display:flex;
    align-items:center;
    gap:10px;
    width:100%;
    border:none;
    background:transparent;
    color:var(--ink);
    font-family:'Manrope', sans-serif;
    font-size:13.5px;
    font-weight:600;
    padding:10px 12px;
    border-radius:8px;
    cursor:pointer;
    text-align:left;
    transition: background .15s ease, color .15s ease;
  }
  .hamburger-item:hover{background:var(--paper-deep);}
  .hamburger-item.danger{color:var(--danger);}
  .hamburger-item.danger:hover{background:var(--danger-bg);}

  /* ---------- Main / editor ---------- */
  .main{
    flex:1;
    min-width:0;
    overflow-y:auto;
    overflow-x:hidden;
    padding:0 30px;
    padding-bottom: calc(var(--bar-height) + var(--bar-gap) * 2 + 30px);
  }

  .editor-body{
    max-width:760px;
    margin:0 auto;
    width:100%;
    min-width:0;
    padding-top:24px;
  }

  .title-input{
    flex:1;
    min-width:0;
    border:none;
    outline:none;
    background:transparent;
    font-style:normal;
    color:var(--ink);
    padding:0;
    font-size:24px;
    font-weight:100;
    letter-spacing:-0.02em;
    line-height:1.15;
  }
  .title-input::placeholder{color:var(--ink-faint);}

  /* ---------- Title row now lives centered in the top bar.
     Positioned absolutely (same centering trick as .bottom-menu) so its
     position never shifts when sibling content — like save-info popping
     in/out — changes width. ---------- */
  .title-row{
    position:absolute;
    left:50%;
    top:60%;
    transform:translate(-50%, -50%);
    display:flex;
    align-items:center;
    gap:10px;
    min-width:0;
    width:min(760px, calc(100vw - var(--bar-gap) * 2), calc(100% - 180px));
    pointer-events:none;
  }
  .title-row > *{pointer-events:auto;}
  .title-row-right{
    display:flex;
    align-items:center;
    gap:6px;
    flex-shrink:1;
    min-width:0;
    margin-left:auto;
  }
  .save-info{
    display:none;
    font-size:11px;
    color:var(--ink-faint);
    padding:3px 8px;
    letter-spacing:0.02em;
    white-space:nowrap;
  }
  .meta-stamp{
    font-size:11px;
    color:var(--ink-faint);
    padding:3px 8px;
    letter-spacing:0.02em;
    white-space:nowrap;
  }

  /* ---------- Pin button (title row, before the title) ---------- */
  .pin-btn{
    width:36px;
    height:36px;
    box-sizing:content-box;
    flex-shrink:0;
  }
  .pin-btn svg{width:24px; height:24px;}

  /* ---------- Tags row (now unused — kept hidden, chips moved into tag-area) ---------- */
  .tags-row{display:none;}

  /* ---------- Tag area: chips + input/add-button, all in one place ---------- */
  .tag-area{
    display:flex;
    flex-wrap:wrap;
    align-items:center;
    gap:6px;
    min-width:0;
    max-width:100%;
  }
  .tag-chips{display:flex; flex-wrap:wrap; gap:6px;}
  .tag-chip{
    display:inline-flex;
    align-items:center;
    gap:5px;
    background:var(--card);
    border:1px solid var(--border);
    border-radius:14px;
    padding:4px 6px 4px 10px;
    font-family:'Manrope', sans-serif;
    font-size:11.5px;
    font-weight:600;
    color:var(--ink-soft);
    white-space:nowrap;
  }
  .tag-chip-remove{
    display:flex;
    align-items:center;
    justify-content:center;
    width:16px;height:16px;
    border-radius:50%;
    border:none;
    background:transparent;
    color:var(--ink-faint);
    cursor:pointer;
    flex-shrink:0;
    transition: background .15s ease, color .15s ease;
  }
  .tag-chip-remove:hover{background:var(--paper-deep); color:var(--ink);}
  .tag-input{
    border:1px solid transparent;
    outline:none;
    background:transparent;
    font-family:'Manrope', sans-serif;
    font-size:12px;
    font-weight:500;
    color:var(--ink-soft);
    padding:6px 10px;
    width:120px;
    max-width:100%;
    min-width:60px;
    border-radius:14px;
    transition: background .15s ease, border-color .15s ease;
  }
  .tag-input:focus{background:var(--card); border-color:var(--border);}
  .tag-input::placeholder{color:var(--ink-faint);}
  .tag-input.hidden{display:none;}

  /* ---------- Tag badges (mini, on note cards in lists) ---------- */
  .row-tags{display:flex; flex-wrap:wrap; gap:5px; margin:2px 0 -1px;}
  .tag-chip-mini{
    background:var(--paper-deep);
    border:1px solid var(--border);
    border-radius:10px;
    padding:2px 8px;
    font-family:'Manrope', sans-serif;
    font-size:10px;
    font-weight:600;
    color:var(--ink-soft);
    white-space:nowrap;
  }

  .toast{
    position:fixed;
    top:18px;
    left:50%;
    transform:translateX(-50%) translateY(-14px);
    background:var(--ink);
    color:var(--paper);
    font-family:'Manrope', sans-serif;
    font-size:13px;
    font-weight:600;
    padding:9px 18px;
    border-radius:20px;
    box-shadow: 0 14px 32px rgba(0,0,0,0.22);
    opacity:0;
    pointer-events:none;
    z-index:150;
    white-space:nowrap;
    transition: opacity .2s ease, transform .2s ease;
  }
  .toast.show{opacity:1; transform:translateX(-50%) translateY(0);}

  .icon-btn{
    width:36px;height:36px;
    border-radius:8px;
    border:1px solid transparent;
    background:transparent;
    display:flex;align-items:center;justify-content:center;
    cursor:pointer;
    color:var(--ink-soft);
    transition: background .15s ease, color .15s ease;
    flex-shrink:0;
  }
  .icon-btn:hover{background:var(--card); border-color:transparent; color:var(--ink);}
  .icon-btn.pinned-active{color:var(--ink);}
  .icon-btn.pinned-active svg path{fill:currentColor;}
  .icon-btn.danger:hover{background:var(--danger-bg); color:var(--danger); border-color:var(--border);}

  /* ---------- Icon swap: base/hover SVG pairs cross-fade smoothly on hover ---------- */
  .icon-swap{position:relative;}
  .icon-swap svg{
    position:absolute;
    top:50%;
    left:50%;
    transform:translate(-50%, -50%);
    transition: opacity .2s ease, transform .2s ease;
  }
  .icon-swap svg.icon-hover{
    opacity:0;
    transform:translate(-50%, -42%);
  }
  .icon-swap:hover svg.icon-base{
    opacity:0;
    transform:translate(-50%, -58%);
  }
  .icon-swap:hover svg.icon-hover{
    opacity:1;
    transform:translate(-50%, -50%);
  }
  @media (prefers-reduced-motion: reduce){
    .icon-swap svg{transition:opacity .12s ease;}
    .icon-swap svg.icon-hover, .icon-swap:hover svg.icon-base{transform:translate(-50%, -50%);}
  }

  .has-tooltip{position:relative;}
  .has-tooltip::after{
    content:attr(data-tooltip);
    position:absolute;
    top:calc(100% + 8px);
    left:50%;
    transform:translateX(-50%) translateY(-4px);
    background:var(--ink);
    color:var(--paper);
    font-family:'Manrope', sans-serif;
    font-size:12px;
    font-weight:600;
    padding:5px 9px;
    border-radius:6px;
    white-space:nowrap;
    opacity:0;
    visibility:hidden;
    pointer-events:none;
    transition: opacity .15s ease, transform .15s ease;
    z-index:200;
  }
  .has-tooltip::before{
    content:'';
    position:absolute;
    top:calc(100% + 3px);
    left:50%;
    transform:translateX(-50%);
    border:5px solid transparent;
    border-bottom-color:var(--ink);
    opacity:0;
    visibility:hidden;
    pointer-events:none;
    transition: opacity .15s ease;
    z-index:200;
  }
  .has-tooltip:hover::after, .has-tooltip:hover::before{
    opacity:1;
    visibility:visible;
    transform:translateX(-50%) translateY(0);
  }

  .content-area{
    width:100%;
    max-width:100%;
    min-height:40vh;
    outline:none;
    line-height:1.65;
    font-family:'Manrope', sans-serif;
    font-size:18px;
    color:var(--ink);
    overflow-wrap:anywhere;
    word-break:break-word;
    transition: opacity .16s ease, transform .16s ease;
    opacity:1;
    transform:translateY(0);
  }
  .content-area.view-fade-out{
    opacity:0;
    transform:translateY(6px);
  }
  .content-area:empty:not(:focus)::before{
    content:attr(data-placeholder);
    color:var(--ink-faint);
  }
  .content-area h3{
    font-family:'Manrope', sans-serif;
    font-weight:700;
    font-size:17.5px;
    margin:14px 0 6px;
    color:var(--ink);
  }
  .content-area p{margin:0 0 10px;}
  .content-area ul, .content-area ol{margin:0 0 10px; padding-left:24px;}
  .voice-interim{color: #fff;
    opacity: 1;
    font-style: normal;
    background: #000;
    border-radius: 6px;
    padding: 0 2px;}
  /* Low-confidence dictation: likely misheard because of noise or unclear speech.
     Flagged with a soft amber wavy underline so the user can spot and fix it. The
     flag is transient — it unwraps back to plain text a few seconds after landing. */
  .voice-uncertain{
    text-decoration: underline wavy #e0a300;
    text-decoration-skip-ink: none;
    text-underline-offset: 3px;
    background: rgba(224,163,0,0.12);
    border-radius: 3px;
    transition: background 0.6s ease;
  }
  .content-area li{margin-bottom:4px;}

  /* ---------- Print (Export PDF) ---------- */
  @media print{
    .top-bar, .bottom-menu{display:none !important;}
    .main{padding:0; min-height:0;}
    .editor{display:block !important; position:static;}
    .editor-body{max-width:100%; padding:0;}
    .title-input{border:none; font-size:22px;}
    .content-area{border:none; padding:0;}
    .pin-btn, .title-row-right{display:none !important;}
    body{background:#FFFFFF; color:#000000;}
  }

  /* ---------- Bottom floating menu (wrap) — mirrors input-bar-wrap/tray-open: ---------- */
  /* one continuous container; the notes/search tray lives inside it, not floating apart */
  .bottom-menu{
    position:fixed;
    left:50%;
    bottom:var(--bar-gap);
    transform:translateX(-50%);
    width:min(760px, calc(100vw - var(--bar-gap) * 2));
    background:var(--bar-bg);
    -webkit-backdrop-filter: blur(6px);
    backdrop-filter: blur(6px);
    border-radius:30px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.16);
    display:flex;
    flex-direction:column;
    padding:8px;
    z-index:40;
    transition: background .22s ease, backdrop-filter .22s ease, box-shadow .22s ease, width .32s cubic-bezier(.4,0,.2,1);
  }
  /* darken/deepen the same bar, same shape — like .input-bar-wrap.tray-open */
  .bottom-menu.panel-open{
    background: var(--bar-bg-open);
    -webkit-backdrop-filter: blur(10px);
    backdrop-filter: blur(10px);
    box-shadow: 0 18px 44px rgba(0,0,0,0.34);
  }

  /* ---------- Voice input active: solid dark bar, secondary controls step back ---------- */
  .bottom-menu.listening{
    background:#16140F;
    box-shadow: 0 18px 44px rgba(0,0,0,0.34);
    /* Narrow the bar down to just the wave + mic while dictating; it eases back out
       to full width when listening stops. */
    width:min(360px, calc(100vw - var(--bar-gap) * 2));
  }
  .bottom-menu.listening .bar-btn-pill{
    opacity:0;
    pointer-events:none;
    /* Collapse the hidden pills so the bar can actually shrink around the wave. */
    max-width:0;
    padding-left:0;
    padding-right:0;
    border-width:0;
    overflow:hidden;
  }

  .menu-row{
    display:grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    align-items:center;
    gap:14px;
  }

  .menu-col{display:flex; align-items:center; min-width:0;}
  .menu-left{justify-content:flex-start; gap:8px;}
  .menu-center{
    display:flex;
    align-items:center;
    justify-content:center;
    gap:8px;
    overflow:hidden;
    border-radius: 50px;
    height: 40px;
    padding: 0 6px;
  }
  .menu-right{justify-content:flex-end; gap:8px;}
  .voice-wave{
    display:flex;
    align-items:center;
    justify-content:center;
    gap:9px;
  }
  .voice-wave-bar{
    width:3px;
    height:6px;
    border-radius:2px;
    background:var(--accent);
    flex-shrink:0;
    animation: voice-wave-bounce 0.9s ease-in-out infinite;
  }
  .voice-wave-bar:nth-child(1){animation-delay:0s;}
  .voice-wave-bar:nth-child(2){animation-delay:0.1s;}
  .voice-wave-bar:nth-child(3){animation-delay:0.2s;}
  .voice-wave-bar:nth-child(4){animation-delay:0.3s;}
  .voice-wave-bar:nth-child(5){animation-delay:0.2s;}
  .voice-wave-bar:nth-child(6){animation-delay:0.1s;}
  .voice-wave-bar:nth-child(7){animation-delay:0s;}
  /* When JS is driving the bars from live mic volume, stop the canned animation and let
     the inline heights control them, with a touch of smoothing so it isn't jittery. */
  .voice-wave.metering .voice-wave-bar{
    animation:none;
    height:4px;
    transition:height 0.06s linear;
  }
  @keyframes voice-wave-bounce{
    0%, 100%{height:6px;}
    50%{height:18px;}
  }
  .voice-wave-label{
    font-family:'Manrope', sans-serif;
    font-size:12px;
    font-weight:600;
    color:var(--ink-soft);
    margin-left:4px;
    white-space:nowrap;
  }
  #voiceBtn.listening{
    background:var(--accent);
    border-color:var(--accent-1);
    color:var(--on-accent);
    animation: voice-pulse 1.4s ease-in-out infinite;
  }
  /* Show the mic normally, swap to the pause/stop square while listening. */
  #voiceBtn .vb-icon{display:none;}
  #voiceBtn .vb-mic{display:block;}
  #voiceBtn.listening .vb-mic{display:none;}
  #voiceBtn.listening .vb-pause{display:block;}
  @keyframes voice-pulse{
    0%, 100%{ box-shadow: 0 0 0 0 rgba(245,85,19,0.45); }
    50%{ box-shadow: 0 0 0 8px rgba(245,85,19,0); }
  }

  .bar-btn-round{
    width:40px;height:40px;
    border-radius:50%;
    border:1px solid transparent;
    display:flex;align-items:center;justify-content:center;
    cursor:pointer;
    flex-shrink:0;
    transition: transform .12s ease, background .15s ease;
  }
  .bar-btn-round.neutral{background:var(--accent); border-color:var(--accent-1); color:var(--on-accent);}
  .bar-btn-round.neutral:hover{background:#000000; border-color:#000000; color:var(--accent-1);}
  .bar-btn-round.neutral:active{background:#000000; border-color:#000000; color:var(--accent-1);}
  .bar-btn-round.neutral.active-state{background:#000000; border-color:#000000; color:var(--accent-1);}

  .bar-btn-pill{
    height:40px;
    padding:0 14px 0 12px;
    border-radius:20px;
    border:1px solid transparent;
    background:transparent;
    color:var(--ink-soft);
    display:flex;align-items:center;gap:6px;
    cursor:pointer;
    font-family:'Manrope', sans-serif;
    font-size:13px;
    font-weight:600;
    transition: background .15s ease, border-color .15s ease, color .15s ease, opacity .18s ease, max-width .3s cubic-bezier(.4,0,.2,1), padding .3s cubic-bezier(.4,0,.2,1);
    flex-shrink:0;
    max-width:220px;
  }
  .bar-btn-pill:hover{background:var(--paper-deep); border-color:var(--border); color:var(--ink);}
  .bar-btn-pill.active-state{background:transparent; border-color:transparent; color:var(--ink);}
  .bar-btn-pill svg.chev{transition: transform .15s ease;}
  .bar-btn-pill.active-state svg.chev{transform:rotate(180deg);}

  /* the bar's glass shifts tone in panel-open — flip resting text via theme-aware tokens so it stays visible either way */
  .bottom-menu.panel-open .bar-btn-pill{color:var(--tray-text);}
  .bottom-menu.panel-open .bar-btn-pill.active-state{color:var(--tray-text-strong);}
  .bottom-menu.panel-open .bar-btn-pill:hover{background:var(--tray-hover-bg); border-color:var(--tray-hover-border); color:var(--tray-text-strong);}
  .bottom-menu.panel-open .bar-btn-round.neutral{background:var(--accent); border-color:var(--accent-1); color:var(--on-accent);}

  .voice-lang-wrap{position:relative;}
  .voice-lang-btn{height:36px; padding:0 10px 0 12px;}
  .voice-lang-btn .pill-label{font-variant:none; letter-spacing:.02em;}
  .voice-lang-menu{
    display:none;
    position:absolute;
    bottom:calc(100% + 10px);
    right:0;
    min-width:190px;
    max-height:280px;
    overflow-y:auto;
    background:var(--bar-bg-open);
    -webkit-backdrop-filter: blur(10px);
    backdrop-filter: blur(10px);
    border:1px solid var(--tray-border);
    border-radius:14px;
    box-shadow: 0 18px 44px rgba(0,0,0,0.34);
    padding:6px;
    z-index:160;
  }
  .voice-lang-menu.show{display:block;}
  .voice-lang-option{
    display:flex;
    align-items:center;
    justify-content:space-between;
    gap:10px;
    width:100%;
    padding:8px 10px;
    border-radius:8px;
    border:none;
    background:transparent;
    color:var(--tray-text-strong);
    font-family:'Manrope', sans-serif;
    font-size:13px;
    font-weight:600;
    text-align:left;
    cursor:pointer;
    transition: background .12s ease;
  }
  .voice-lang-option:hover{background:var(--tray-hover-bg);}
  .voice-lang-option.selected{color:var(--accent-1);}
  .voice-lang-option .lang-native{font-weight:400; color:var(--tray-text-faint); font-size:12px;}
  /* Dark mode: the language tray reads darker, so lighten the option text. */
  body.theme-dark .voice-lang-option{color:var(--ink);}
  body.theme-dark .voice-lang-option.selected{color:var(--accent-1);}
  body.theme-dark .voice-lang-option .lang-native{color:var(--ink-soft);}
  .bottom-menu.panel-open .bar-btn-round.neutral:hover{background:#000000; border-color:#000000; color:var(--accent-1);}

  .fmt-btn{
    width:32px;height:32px;
    border-radius:7px;
    border:1px solid transparent;
    background:transparent;
    display:flex;align-items:center;justify-content:center;
    cursor:pointer;
    color:var(--ink-soft);
    font-family:'Manrope', sans-serif;
    font-size:14px;
    flex-shrink:0;
    transition: background .15s ease, color .15s ease;
  }
  .fmt-btn:hover{background:var(--paper-deep); color:var(--ink);}
  .fmt-btn.active{background:var(--ink); color:var(--paper);}

  /* ---------- Floating formatting tooltip — appears over a text selection ---------- */
  .selection-toolbar{
    position:fixed;
    display:none;
    align-items:center;
    gap:2px;
    background:rgba(20,20,20,0.92);
    -webkit-backdrop-filter: blur(6px);
    backdrop-filter: blur(6px);
    border-radius:10px;
    padding:5px;
    box-shadow: 0 12px 28px rgba(0,0,0,0.28);
    z-index:120;
  }
  .selection-toolbar .fmt-btn{color:rgba(255,255,255,0.7);}
  .selection-toolbar .fmt-btn:hover{background:rgba(255,255,255,0.14); color:#FFFFFF;}
  .selection-toolbar .fmt-btn.active{background:#FFFFFF; color:#111111;}

  /* ---------- Notes tray — sits inside the bottom-menu, same bar, same surface ---------- */
  .panel-dock{
    display:none;
    flex-direction:column;
    padding:8px 8px 2px;
  }
  .panel-dock.show{display:flex;}

  .panel-header{
    display:flex;
    align-items:center;
    justify-content:space-between;
    gap:10px;
    font-size:10.5px;
    color:var(--tray-text-faint);
    letter-spacing:0.03em;
    padding-bottom:10px;
    margin-bottom:10px;
    border-bottom:1px solid var(--tray-border);
  }
  .panel-search{
    display:flex;
    align-items:center;
    gap:5px;
    flex-shrink:0;
    color:var(--tray-text-faint);
  }
  .panel-search-input{
    border:none;
    outline:none;
    background:transparent;
    font-family:'IBM Plex Mono', monospace;
    font-size:10.5px;
    color:var(--tray-text-strong);
    width:84px;
  }
  .panel-search-input::placeholder{color:var(--tray-text-faint);}

  .panel-list{
    display:grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap:10px;
    max-height:min(50vh, 400px);
    overflow-y:auto;
    padding-right:2px;
    padding-bottom:4px;
  }
  .panel-empty{
    grid-column:1 / -1;
    font-family:'IBM Plex Mono', monospace;
    font-size:11.5px;
    color:var(--tray-text-faint);
    text-align:center;
    padding:24px 6px;
    line-height:1.6;
  }

  .panel-section{display:flex; flex-direction:column;}

  /* ---------- Mic-permission toast — standalone; sits above the toolbar, not part of the panel-dock ---------- */
  .mic-toast{
    position:fixed;
    left:50%;
    /* Just above the toolbar. When the toolbar's panel-open tray is expanded, the
       toast is hidden anyway (see JS), so anchoring to the closed-bar height keeps
       the layout stable and predictable. */
    bottom:calc(var(--bar-height) + var(--bar-gap) * 2);
    transform:translate(-50%, 8px);
    width:min(560px, calc(100vw - var(--bar-gap) * 2));
    z-index:45;                   /* above .bottom-menu (z-index:40) so it clears the toolbar */
    background:var(--bar-bg-open);
    -webkit-backdrop-filter: blur(10px);
    backdrop-filter: blur(10px);
    border-radius:16px;
    box-shadow: 0 18px 40px -16px rgba(0,0,0,0.35);
    display:flex; flex-direction:column; gap:14px;
    padding:14px 16px;
    opacity:0; visibility:hidden; pointer-events:none;
    transition: opacity .22s ease, transform .22s ease, visibility .22s;
  }
  .mic-toast.show{
    opacity:1; visibility:visible; pointer-events:auto;
    transform:translate(-50%, 0);
  }
  .mic-toast-row{ display:flex; align-items:center; gap:12px; }
  .mic-toast-ico{
    flex:none; width:36px; height:36px; border-radius:10px;
    display:flex; align-items:center; justify-content:center;
    color:var(--on-accent); background:var(--accent);
  }
  .mic-toast-tx{ flex:1; min-width:0; line-height:1.35; color:var(--tray-text); }
  .mic-toast-tx b{ display:block; font-weight:700; color:var(--tray-text-strong); }
  .mic-toast-tx small{ color:var(--tray-text-faint); font-size:12.5px; }
  .mic-toast-actions{ display:flex; justify-content:flex-end; gap:10px; }
  .mic-toast-btn{
    font-family:'Manrope', sans-serif; font-size:13px; font-weight:600;
    padding:9px 16px; border-radius:99px; cursor:pointer;
    border:1px solid var(--tray-border); background:transparent; color:var(--tray-text);
    transition:background .15s ease, border-color .15s ease, color .15s ease;
  }
  .mic-toast-btn:hover{ background:var(--tray-hover-bg); border-color:var(--tray-hover-border); color:var(--tray-text-strong); }
  .mic-toast-btn.primary{ background:var(--accent); border-color:var(--accent-1); color:var(--on-accent); }
  .mic-toast-btn.primary:hover{ filter:brightness(1.06); }

  @media (max-width:640px){
    .mic-toast{ width:calc(100vw - 24px); left:12px; right:12px; transform:translate(0,8px); }
    .mic-toast.show{ transform:translate(0,0); }
  }

  .note-card{
    background:var(--paper);
    border-radius:10px;
    padding:10px 11px;
    cursor:pointer;
    display:flex;
    flex-direction:column;
    gap:4px;
    transition: background .12s ease, border-color .12s ease;
    min-height:84px;
  }
  .note-card:hover{background:var(--paper-deep);}
  .note-card.active{background:var(--paper-deep);}

  /* ---------- New note card (always first in the panel list) ---------- */
  .new-note-card{
    align-items:center;
    justify-content:center;
    flex-direction:row;
    gap:8px;
    color:var(--ink-soft);
    font-family:'Manrope', sans-serif;
    font-size:13.5px;
    font-weight:700;
    width:100%;
    transition: background .12s ease, color .12s ease;
    border: none;
  }
  .new-note-card:hover{background:var(--paper-deep); color:var(--ink);}
  .new-note-card svg{flex-shrink:0;}

  .row-top{display:flex; align-items:center; justify-content:space-between; gap:8px;}
  .row-title{
    font-family:'Manrope', sans-serif;
    font-weight:600;
    font-size:14px;
    color:var(--ink);
    overflow:hidden; text-overflow:ellipsis; white-space:nowrap;
    flex:1;
  }
  .row-actions{display:flex; gap:2px; flex-shrink:0;}
  .row-actions button{
    width:22px;height:22px;
    border:none; background:transparent;
    border-radius:6px;
    display:flex;align-items:center;justify-content:center;
    color:var(--ink-faint);
    cursor:pointer;
  }
  .row-actions button:hover{background:var(--card); color:var(--ink);}
  .row-actions button.pinned{color:var(--ink);}
  .row-snippet{
    font-size:12px;
    color:var(--ink-soft);
    overflow:hidden;
    display:-webkit-box;
    -webkit-line-clamp:2;
    -webkit-box-orient:vertical;
    line-height:1.4;
    flex:1;
  }
  .row-time{
    font-family:'IBM Plex Mono', monospace;
    font-size:10px;
    color:var(--ink-faint);
  }
  .row-bottom{
    display:flex;
    align-items:center;
    gap:8px;
  }
  .row-bottom .row-time{margin-left:auto;}

  /* ---------- Confirm modal ---------- */
  /* Delete-note confirmation — a tooltip-style popover anchored to the
     delete button, with a pointer arrow, instead of a full-screen modal. */
  .delete-tip{
    position:fixed;
    z-index:60;
    background:var(--card);
    border:1px solid var(--border);
    border-radius:var(--radius);
    padding:16px 18px;
    width:260px;
    box-shadow: 0 14px 34px -12px rgba(0,0,0,0.28);
    opacity:0;
    visibility:hidden;
    pointer-events:none;
    transform:translateY(-4px);
    transition: opacity .15s ease, transform .15s ease, visibility .15s;
  }
  .delete-tip.show{
    opacity:1;
    visibility:visible;
    pointer-events:auto;
    transform:translateY(0);
  }
  .delete-tip-arrow{ position:absolute; width:14px; height:14px; overflow:hidden; pointer-events:none; }
  .delete-tip-arrow::after{
    content:'';
    position:absolute;
    width:10px; height:10px;
    background:var(--card);
    border:1px solid var(--border);
    transform:rotate(45deg);
  }
  /* arrow points up at the button (popover sits below it) */
  .delete-tip-arrow.point-up{ top:-7px; }
  .delete-tip-arrow.point-up::after{ top:4px; left:2px; }
  /* arrow points down at the button (popover sits above it) */
  .delete-tip-arrow.point-down{ bottom:-7px; }
  .delete-tip-arrow.point-down::after{ bottom:4px; left:2px; }
  .delete-tip h3{
    font-family:'Manrope', sans-serif;
    margin:0 0 8px;
    font-size:16px;
  }
  .delete-tip p{
    font-size:13px;
    color:var(--ink-soft);
    margin:0 0 16px;
    line-height:1.5;
  }
  .modal-actions{display:flex; justify-content:flex-end; gap:10px;}
  .field-label{
    display:block;
    font-family:'IBM Plex Mono', monospace;
    font-size:10.5px;
    letter-spacing:0.04em;
    text-transform:uppercase;
    color:var(--ink-faint);
    margin:14px 0 6px;
  }
  .field-input{
    width:100%;
    border:1px solid var(--border);
    background:var(--paper-deep);
    color:var(--ink);
    font-family:'IBM Plex Mono', monospace;
    font-size:13px;
    padding:10px 12px;
    border-radius:8px;
    outline:none;
    transition: background .15s ease, border-color .15s ease;
  }
  .field-input:focus{background:var(--card); border-color:var(--ink-faint);}
  .btn{
    font-family:'Manrope', sans-serif;
    font-size:13px;
    font-weight:600;
    padding:8px 16px;
    border-radius:7px;
    border:1px solid var(--border);
    background:var(--card);
    color:var(--ink);
    cursor:pointer;
  }
  .btn:hover{background:var(--paper-deep);}
  .btn.danger{background:var(--danger); border-color:var(--danger); color:var(--paper);}
  .btn.danger:hover{background:var(--danger-hover);}
  .btn.primary{background:var(--accent); border-color:var(--accent-1); color:var(--on-accent);}
  .btn.primary:hover{background:var(--accent-dark); border-color:var(--accent-dark);}

  /* ---------- Scrollbars ---------- */
  .main::-webkit-scrollbar, .panel-list::-webkit-scrollbar{width:8px;}
  .main::-webkit-scrollbar-thumb, .panel-list::-webkit-scrollbar-thumb{
    background:var(--border); border-radius:8px;
  }

  /* ---------- Responsive ---------- */
  @media (max-width: 640px){
    :root{ --bar-gap: 12px; --bar-height: 68px; }
    .top-bar{padding:16px 18px 4px; gap:8px;}
    .main{padding:0 18px; padding-bottom: calc(var(--bar-height) + var(--bar-gap) * 2 + 24px);}
    .title-row{flex-wrap:wrap;}

    /* ---------- header-actions (meta-stamp / save-info) hidden on mobile ---------- */
    .header-actions{display:none !important;}

    /* Keep the same glass bar surface as desktop — don't strip it down */
    .bottom-menu{width:calc(100vw - var(--bar-gap) * 2); padding:8px;}

    /* Keep labels visible (e.g. "Notes", language code) so mobile has the same
       at-a-glance features as desktop, just in a more compact pill */
    .pill-label{display:inline; font-size:16px;}
    .bar-btn-pill{padding:0 10px 0 10px; height:44px; gap:4px;}
    .voice-lang-btn{height:40px; padding:0 8px 0 10px;}

    .menu-row{gap:6px;}
    .menu-center{gap:4px; padding:0 4px; height:48px; flex:1; min-width:0;}
    .menu-left, .menu-right{gap:6px; flex-shrink:0;}
    .bar-btn-round{width:48px; height:48px; flex-shrink:0;}
    #voiceBtn{flex-shrink:0;}
    #voiceBtn.listening{background:var(--accent); border-color:var(--accent-1); color:var(--on-accent);}

    .voice-wave-label{display:none;}

    /* ---------- Readability: bump up text sizes that are too small to read on mobile ---------- */
    .content-area{font-size:18px; line-height:1.7;}
    .title-input{font-size:21px;}
    .tag-chip{font-size:13px;}
    .tag-input{display:none;}
    .row-title{font-size:15.5px;}
    .row-snippet{font-size:13.5px;}
    .row-time{font-size:11px;}
    .panel-header{font-size:12px;}
    .panel-search-input{font-size:12px;}
    .meta-stamp, .save-info{font-size:12px;}

    .panel-list{grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap:8px;}
    .panel-dock{padding:10px 6px 2px;}

    /* ---------- Bigger touch targets for hamburger + pin on mobile ---------- */
    .hamburger-btn{width:48px; height:48px;}
    .hamburger-btn svg{width:24px; height:24px;}
    .pin-btn{width:44px; height:44px;}
    .pin-btn svg{width:28px; height:28px;}

    /* Voice language menu and selection toolbar need to stay reachable/tappable
       on small screens, matching the same functionality available on desktop */
    .voice-lang-menu{max-height:50vh; overflow-y:auto;}
    .selection-toolbar{flex-wrap:wrap; gap:4px; padding:8px; border-radius:14px;}
    .selection-toolbar .fmt-btn{width:44px; height:44px; border-radius:10px; font-size:18px;}
    .selection-toolbar .fmt-btn svg{width:20px; height:20px;}

    /* ---------- Hamburger menu: consolidates Delete + Export PDF on mobile ---------- */
    .hamburger-wrap.note-open{display:flex;}
    /* The same actions now live in the hamburger, so hide the duplicate inline
       controls to avoid clutter in the cramped title row / top bar */
    .title-row-right #topDeleteBtn{display:none;}
    .title-row-right #topExportPdfBtn{display:none;}

    /* ---------- Notes panel: fill the screen height when open, instead of a small floating tray ---------- */
    .bottom-menu.notes-open{
      top:0;
      left:0;
      right:0;
      bottom:0;
      width:100%;
      transform:none;
      border-radius:0;
      display:flex;
      flex-direction:column;
    }
    .bottom-menu.notes-open .panel-dock.show{
      flex:1;
      min-height:0;
      display:flex;
      padding:max(16px, env(safe-area-inset-top)) 14px 8px;
    }
    .bottom-menu.notes-open #notesPanelSection{
      flex:1;
      min-height:0;
    }
    .bottom-menu.notes-open .panel-list{
      flex:1 1 0;
      min-height:0;
      height:0;
      overflow-y:auto;
    }
    .bottom-menu.notes-open .menu-row{
      flex-shrink:0;
      padding:8px 6px max(8px, env(safe-area-inset-bottom));
    }
  }

