  :root {
    --bg: #141413; --panel: #1e1d1b; --panel2: #26241f; --border: #35332e;
    --text: #faf9f5; --muted: #b0aea5; --accent: #d97757; --accent2: #c56144;
    --ok: #788c5d; --err: #cf6a4c; --ring: rgba(217,119,87,.35);
    --add: rgba(120,140,93,.22); --del: rgba(207,106,76,.20);
    --shadow: 0 1px 2px rgba(0,0,0,.3), 0 12px 32px rgba(0,0,0,.28);
    --ui: "Poppins", Arial, sans-serif; --serif: "Lora", Georgia, serif;
    --sheet: "Open Sans", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  }
  body.light {
    --bg: #faf9f5; --panel: #ffffff; --panel2: #f3f1ea; --border: #e8e6dc;
    --text: #141413; --muted: #6b6862; --accent: #d97757; --accent2: #bf5b3b;
    --ok: #5f7346; --err: #b8492c; --ring: rgba(217,119,87,.28);
    --add: rgba(95,115,70,.16); --del: rgba(184,73,44,.13);
    --shadow: 0 1px 2px rgba(20,20,19,.05), 0 10px 30px rgba(20,20,19,.07);
  }
  * { box-sizing: border-box; }
  html, body { height: 100%; }
  body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.5 var(--serif);
         display: flex; flex-direction: column; -webkit-font-smoothing: antialiased; }
  button, input, select { font-family: var(--ui); color: inherit; }
  h1, h2, h3 { font-family: var(--ui); letter-spacing: -.01em; }
  a { color: var(--accent); }
  .hidden { display: none !important; }

  header { display: flex; align-items: center; gap: .8rem; padding: .7rem 1.15rem;
           border-bottom: 1px solid var(--border); background: var(--panel); flex-wrap: wrap; }
  .logo { width: 2.1rem; height: 2.1rem; flex: none; border-radius: 10px; display: grid;
          place-items: center; font-size: 1.1rem; color: #fff;
          background: linear-gradient(135deg, var(--accent), #e0895f); box-shadow: 0 2px 8px var(--ring); }
  header h1 { margin: 0; font-size: 1.14rem; font-weight: 600; line-height: 1.1; }
  header .sub { display: block; color: var(--muted); font-size: .8rem; }
  .grow { flex: 1; }
  .chip { font-family: var(--ui); font-size: .78rem; color: var(--muted); border: 1px solid var(--border);
          border-radius: 999px; padding: .2rem .65rem; background: var(--panel2); white-space: nowrap; }
  .btn { border: 1px solid var(--border); background: var(--panel2); border-radius: 10px;
         padding: .45rem .85rem; cursor: pointer; font-weight: 500; font-size: .86rem; text-decoration: none;
         color: var(--text); display: inline-flex; align-items: center; gap: .35rem;
         transition: border-color .15s, background .15s; font-family: var(--ui); }
  .btn:hover { border-color: var(--accent); }
  .btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
  .btn.primary:hover { background: var(--accent2); border-color: var(--accent2); }
  .btn.danger:hover { border-color: var(--err); color: var(--err); }
  .btn:disabled { opacity: .45; cursor: default; }

  .layout { flex: 1; display: grid; grid-template-columns: 22rem 1fr; min-height: 0; }
  aside { border-right: 1px solid var(--border); background: var(--panel); display: flex;
          flex-direction: column; min-height: 0; }
  #drop { margin: .8rem; border: 2px dashed var(--border); border-radius: 14px; padding: 1rem;
          text-align: center; cursor: pointer; background: var(--panel2); font-family: var(--ui);
          font-size: .9rem; transition: border-color .15s, background .15s; }
  #drop:hover, #drop.over { border-color: var(--accent); }
  #drop.over { background: var(--ring); }
  #drop small { display: block; color: var(--muted); font-family: var(--serif); font-size: .78rem; }
  .search { padding: 0 .8rem .6rem; }
  .search input { width: 100%; background: var(--panel2); border: 1px solid var(--border);
                  border-radius: 10px; padding: .5rem .7rem; font-size: .9rem; }
  .search input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--ring); }
  .tagbar { display: flex; flex-wrap: wrap; gap: .3rem; padding: 0 .8rem .6rem; flex: none;
            max-height: 7.5rem; overflow-y: auto; }
  .tag { font-family: var(--ui); font-size: .74rem; font-weight: 500; white-space: nowrap;
         border: 1px solid var(--border); background: var(--panel2); color: var(--text);
         border-radius: 999px; padding: .15rem .55rem; cursor: pointer; line-height: 1.5;
         display: inline-flex; align-items: center; gap: .3rem; }
  .tag:hover { border-color: var(--accent); }
  .tag.on { background: var(--accent); border-color: var(--accent); color: #fff; }
  .tag.auto { border-style: dashed; color: var(--muted); }
  .tag .x { opacity: .6; font-size: .8em; }
  .tag .x:hover { opacity: 1; color: var(--err); }
  .tag .n { opacity: .65; font-size: .9em; }
  #list .tags { display: flex; flex-wrap: wrap; gap: .2rem; margin-top: .15rem; }
  #list .tags .tag { font-size: .66rem; padding: 0 .4rem; cursor: default; }
  .songtags { display: flex; flex-wrap: wrap; gap: .35rem; align-items: center; margin: -.3rem 0 1rem; }
  .songtags select, .selbar select { background: var(--panel2); border: 1px solid var(--border);
         border-radius: 999px; padding: .15rem .5rem; font-size: .76rem; font-family: var(--ui); }
  .notes { border: 1px solid var(--border); border-radius: 12px; padding: .6rem .8rem;
           margin: -.2rem 0 1.1rem; background: var(--panel2); }
  .notes .head { display: flex; align-items: center; gap: .6rem; font-family: var(--ui);
                 font-weight: 600; font-size: .9rem; }
  .notes .empty-n { color: var(--muted); font-size: .85rem; margin: .3rem 0 0; }
  .notelist { display: flex; flex-wrap: wrap; gap: .6rem; margin-top: .5rem; }
  .note { border: 1px solid var(--border); border-radius: 10px; background: var(--panel);
          padding: .5rem .6rem; width: 13.5rem; display: flex; flex-direction: column; gap: .35rem; }
  .note .thumb { height: 7.5rem; border-radius: 6px; background: #fff; display: grid; place-items: center;
                 overflow: hidden; font-size: 2.2rem; cursor: pointer; border: 1px solid var(--border); }
  .note .thumb img { max-width: 100%; max-height: 100%; object-fit: contain; }
  .note .nm { font-family: var(--ui); font-weight: 600; font-size: .82rem; word-break: break-word; }
  .note .sub { color: var(--muted); font-size: .72rem; word-break: break-word; }
  .note .acts { display: flex; gap: .3rem; flex-wrap: wrap; }
  .note .acts .btn { padding: .2rem .5rem; font-size: .75rem; }
  .tag.zb { border-color: color-mix(in srgb, var(--accent) 45%, var(--border)); }
  .tag.hid { opacity: .55; text-decoration: line-through; }
  .tag .eye { font-size: .85em; opacity: .75; }
  .tag .eye:hover { opacity: 1; }
  .imptags { padding: 0 .8rem .6rem; }
  .imptags input { width: 100%; background: var(--panel2); border: 1px solid var(--border);
                   border-radius: 10px; padding: .4rem .7rem; font-size: .8rem; }
  .imptags input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--ring); }
  .editor { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 1rem; }
  .editor .fields { display: grid; grid-template-columns: 1fr 1fr 8rem; gap: .5rem; margin-bottom: .6rem; }
  .editor label { font-family: var(--ui); font-size: .75rem; color: var(--muted); display: flex;
                  flex-direction: column; gap: .2rem; }
  .editor input { width: 100%; min-width: 0; }
  .editor input, .editor textarea { background: var(--panel2); border: 1px solid var(--border); border-radius: 8px;
                  padding: .4rem .55rem; color: var(--text); font-size: .9rem; }
  .editor textarea { font-family: ui-monospace, "DejaVu Sans Mono", Menlo, Consolas, monospace;
                     font-size: 14px; line-height: 1.35; width: 100%; resize: vertical; white-space: pre;
                     overflow-wrap: normal; overflow-x: auto; tab-size: 4; }
  .editor input:focus, .editor textarea:focus { outline: none; border-color: var(--accent);
                     box-shadow: 0 0 0 3px var(--ring); }
  .editor .help { font-size: .78rem; color: var(--muted); margin: .4rem 0; }
  .editor .help code { background: var(--panel2); border-radius: 4px; padding: 0 .25rem; }
  .editor .prev { border: 1px solid var(--border); border-radius: 12px; padding: .7rem .9rem;
                  background: var(--panel); min-width: 0; }
  .versions li { display: flex; gap: .6rem; align-items: center; padding: .25rem 0; font-family: var(--ui);
                 font-size: .84rem; }
  @media (max-width: 1000px) { .editor { grid-template-columns: 1fr; } .editor .fields { grid-template-columns: 1fr; } }
  .sl-part { display: grid; grid-template-columns: 9.5rem 1fr; gap: .6rem; padding: .45rem 0;
             border-bottom: 1px solid var(--border); align-items: start; }
  .sl-part > b { font-family: var(--ui); font-size: .88rem; padding-top: .3rem; }
  .sl-item { display: flex; gap: .4rem; align-items: center; flex-wrap: wrap; padding: .15rem 0;
             font-family: var(--ui); font-size: .88rem; }
  .sl-item a { color: var(--text); cursor: pointer; }
  .sl-item .btn, .sl-part .btn { padding: .15rem .45rem; font-size: .75rem; }
  .sl-item select { background: var(--panel2); border: 1px solid var(--border); border-radius: 8px;
                    font-size: .75rem; padding: .1rem .3rem; color: var(--text); }
  .sl-head { display: flex; gap: .5rem; flex-wrap: wrap; align-items: end; margin-bottom: .6rem; }
  .sl-head input { background: var(--panel2); border: 1px solid var(--border); border-radius: 8px;
                   padding: .35rem .55rem; color: var(--text); font-family: var(--ui); }
  @media (max-width: 820px) { .sl-part { grid-template-columns: 1fr; } }
  .trchip { display: inline-flex; align-items: center; gap: .3rem; color: var(--text); }
  .trchip select { background: var(--panel); border: 1px solid var(--border); border-radius: 999px;
                   padding: .05rem .4rem; font-size: .78rem; font-family: var(--ui); color: var(--text); }
  .badge { font-family: var(--ui); font-size: .66rem; border-radius: 999px; padding: 0 .4rem;
           border: 1px dashed var(--border); color: var(--muted); margin-left: .3rem; white-space: nowrap; }
  .note .st { font-family: var(--ui); font-size: .72rem; color: var(--accent); }
  .note .st.bad { color: var(--err); }
  .links { border: 1px solid var(--border); border-radius: 12px; padding: .6rem .8rem;
           margin: -.2rem 0 1.1rem; background: var(--panel2); }
  .links .head { display: flex; align-items: center; gap: .6rem; font-family: var(--ui);
                 font-weight: 600; font-size: .9rem; }
  .linkrow { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; padding: .35rem 0;
             border-bottom: 1px solid var(--border); font-family: var(--ui); font-size: .84rem; }
  .linkrow:last-of-type { border-bottom: 0; }
  .linkrow .voice { font-weight: 600; min-width: 5.5rem; }
  .linkrow .lt { color: var(--muted); word-break: break-all; flex: 1; min-width: 8rem; }
  .linkrow .btn { padding: .2rem .5rem; font-size: .75rem; }
  .player { width: 100%; margin: .2rem 0 .5rem; }
  .player iframe { width: 100%; max-width: 640px; border: 0; border-radius: 10px; background: #000; display: block; }
  .player iframe.yt { aspect-ratio: 16 / 9; }
  .player iframe.drive { height: 180px; background: var(--panel); }
  .player audio { width: 100%; max-width: 640px; }
  .addlink { display: flex; gap: .4rem; flex-wrap: wrap; margin-top: .5rem; }
  .addlink select, .addlink input { background: var(--panel); border: 1px solid var(--border);
         border-radius: 8px; padding: .3rem .5rem; font-size: .8rem; font-family: var(--ui); }
  .addlink input.url { flex: 1; min-width: 12rem; }
  .info { border-left: 3px solid var(--accent); padding: .4rem .7rem; margin: 0 0 1rem;
          background: var(--panel2); border-radius: 6px; font-size: .88rem; }
  .modal { position: fixed; inset: 0; background: rgba(20,20,19,.6); z-index: 25; display: flex;
           align-items: center; justify-content: center; padding: 1rem; }
  .modal .win { background: var(--panel); border: 1px solid var(--border); border-radius: 14px;
                box-shadow: var(--shadow); width: min(1100px, 100%); max-height: 100%; display: flex;
                flex-direction: column; min-height: 0; }
  .modal .bar { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; padding: .6rem .8rem;
                border-bottom: 1px solid var(--border); font-family: var(--ui); font-size: .85rem; }
  .modal .bar select, .modal .bar input { background: var(--panel2); border: 1px solid var(--border);
                border-radius: 8px; padding: .25rem .5rem; font-family: var(--ui); }
  .modal .body { overflow: auto; padding: .8rem; min-height: 0; }
  .modal .score { background: #fff; border-radius: 8px; padding: .5rem; }
  .modal .score svg { max-width: 100%; height: auto; display: block; margin: 0 auto; }
  .picklist { list-style: none; margin: .5rem 0 0; padding: 0; max-height: 50vh; overflow-y: auto; }
  .picklist li { padding: .4rem .6rem; border-radius: 8px; cursor: pointer; font-family: var(--ui); font-size: .88rem; }
  .picklist li:hover { background: var(--ring); }
  #importBar { margin: 0 .8rem .6rem; padding: .5rem .7rem; border-radius: 10px; cursor: pointer;
               border: 1px solid var(--border); background: var(--panel2); font-family: var(--ui); font-size: .82rem; }
  .progress { height: .55rem; border-radius: 999px; background: var(--panel2); border: 1px solid var(--border);
              overflow: hidden; margin: .4rem 0; }
  .progress > div { height: 100%; background: var(--accent); transition: width .3s; }
  #pendingBar { margin: 0 .8rem .6rem; padding: .55rem .7rem; border-radius: 10px; cursor: pointer;
                border: 1px solid var(--accent); background: color-mix(in srgb, var(--accent) 14%, var(--panel));
                font-family: var(--ui); font-size: .85rem; }
  #list { list-style: none; margin: 0; padding: .2rem .5rem; overflow-y: auto; flex: 1; }
  #list li { display: flex; gap: .5rem; align-items: flex-start; padding: .45rem .5rem; border-radius: 10px;
             cursor: pointer; border: 1px solid transparent; }
  #list li:hover { background: var(--panel2); }
  #list li.sel { background: var(--ring); border-color: var(--accent); }
  #list input { accent-color: var(--accent); margin-top: .25rem; width: 1rem; height: 1rem; flex: none; }
  #list .t { font-family: var(--ui); font-size: .88rem; font-weight: 500; line-height: 1.3; }
  #list .m { color: var(--muted); font-size: .76rem; }
  .selbar { border-top: 1px solid var(--border); padding: .6rem .8rem; display: flex; gap: .4rem;
            flex-wrap: wrap; align-items: center; font-family: var(--ui); font-size: .8rem; }

  #main { overflow-y: auto; padding: 1.3rem 1.6rem 3rem; min-width: 0; }
  .empty { color: var(--muted); text-align: center; margin-top: 18vh; font-size: 1rem; }
  .empty h2 { color: var(--text); font-weight: 600; }
  .card { background: var(--panel); border: 1px solid var(--border); border-radius: 14px;
          padding: 1rem 1.2rem; margin-bottom: 1rem; box-shadow: var(--shadow); }
  .card h3 { margin: 0 0 .4rem; font-size: 1rem; font-weight: 600; }
  .muted { color: var(--muted); }
  .rep li { margin: .15rem 0; }
  .ok { color: var(--ok); } .warn { color: var(--accent); } .bad { color: var(--err); }

  .song-head { display: flex; gap: 1rem; align-items: flex-start; flex-wrap: wrap; margin-bottom: .8rem; }
  .song-head h2 { margin: 0; font-size: 1.45rem; font-weight: 600; line-height: 1.2; }
  .song-head .sub { color: var(--muted); }
  .actions { display: flex; gap: .4rem; flex-wrap: wrap; margin: .3rem 0 1rem; }

  .sheet { font-family: var(--sheet); font-size: 15px; line-height: 1.35; }
  .sheet .lab { font-weight: 700; font-size: 1.05em; margin: 1.1em 0 .2em; font-family: var(--sheet); }
  .sheet .sec:first-child .lab { margin-top: .2em; }
  .sheet .sec { margin-bottom: .9em; }
  .sheet .ln { white-space: pre; min-height: 1.35em; border-radius: 4px; }
  .sheet .seg { display: inline-flex; flex-direction: column; align-items: flex-start;
                vertical-align: bottom; white-space: pre; }
  .sheet .ch { font-weight: 700; color: var(--accent); padding-right: .3em; min-height: 1.35em; }
  .sheet .ly { min-height: 1.35em; }
  .sheet .ln.it .ly, .sheet .ln.it:not(:has(.seg)) { font-style: italic; }
  .sheet .ln.bo .ly, .sheet .ln.bo:not(:has(.seg)) { font-weight: 700; }
  .sheet .ly.hy::after { content: "-"; }
  .sheet .conly { font-weight: 700; color: var(--accent); }
  .sheet .meta { color: var(--muted); }
  .sheet .diff { background: var(--add); }
  .scroll-x { overflow-x: auto; }

  .cmp { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; margin: .8rem 0; }
  .cmp > div { border: 1px solid var(--border); border-radius: 12px; padding: .8rem 1rem; background: var(--panel2);
               min-width: 0; }
  .cmp h4 { margin: 0 0 .5rem; font-family: var(--ui); font-size: .9rem; }
  .simbadge { font-family: var(--ui); font-weight: 600; color: #fff; background: var(--accent);
              border-radius: 999px; padding: .1rem .55rem; font-size: .8rem; }

  #toast { position: fixed; left: 50%; bottom: 1.3rem; transform: translateX(-50%); background: var(--panel);
           border: 1px solid var(--border); border-left: 4px solid var(--ok); border-radius: 12px;
           padding: .7rem 1.1rem; max-width: 90%; box-shadow: var(--shadow); font-family: var(--ui);
           font-size: .9rem; opacity: 0; pointer-events: none; transition: opacity .2s; z-index: 30; }
  #toast.show { opacity: 1; } #toast.err { border-left-color: var(--err); }
  #busy { position: fixed; inset: 0; background: rgba(20,20,19,.5); display: flex; align-items: center;
          justify-content: center; z-index: 20; }
  #busy .box { background: var(--panel); border: 1px solid var(--border); border-radius: 14px;
               padding: 1.1rem 1.7rem; display: flex; gap: .8rem; align-items: center; font-family: var(--ui); }
  .spin { width: 1.15rem; height: 1.15rem; border: 3px solid var(--border); border-top-color: var(--accent);
          border-radius: 50%; animation: spin .8s linear infinite; }
  @keyframes spin { to { transform: rotate(360deg); } }
  #btnTheme { background: var(--panel2); border: 1px solid var(--border); border-radius: 10px;
              padding: .4rem .6rem; cursor: pointer; line-height: 1; }

  @media (max-width: 820px) {
    header .sub { display: none; }
    .layout { grid-template-columns: 1fr; grid-template-rows: auto 1fr; }
    aside { border-right: 0; border-bottom: 1px solid var(--border); max-height: 46vh; }
    #main { padding: 1rem; }
    .cmp { grid-template-columns: 1fr; }
  }
