*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:           #f2f2f8;
  --sidebar-bg:   #e6e6f2;
  --card-bg:      #ffffff;
  --border:       #d0d0e4;
  --accent:       #5c4ee8;
  --accent-hover: #7060f0;
  --danger:       #d93247;
  --text:         #1a1a30;
  --muted:        #7070a0;
}

html, body { height: 100%; font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif; background: var(--bg); color: var(--text); font-size: 14px; }

#app { display: flex; height: calc(100vh - 32px); overflow: hidden; }

#about-footer { height: 32px; display: flex; align-items: center; justify-content: center; gap: 10px; font-size: 11px; color: var(--muted); border-top: 1px solid var(--border); background: var(--sidebar-bg); padding: 0 16px; flex-shrink: 0; }
.about-name { font-weight: 700; color: var(--accent); }
.about-version { font-family: monospace; }
.about-sep { opacity: .4; }
.about-brand { font-style: italic; }
.about-link { color: inherit; text-decoration: none; }
.about-link:hover { text-decoration: none; color: inherit; }

/* ── CHATBOT ── */
#chat-fab { position: fixed; bottom: 24px; right: 24px; width: 52px; height: 52px; border-radius: 50%; background: var(--accent); color: #fff; border: none; font-size: 22px; cursor: pointer; box-shadow: 0 4px 16px rgba(92,78,232,.4); z-index: 1000; transition: background .15s, transform .15s; display: flex; align-items: center; justify-content: center; }
#chat-fab:hover { background: var(--accent-hover); transform: scale(1.07); }

#chat-panel { position: fixed; bottom: 88px; right: 24px; width: 340px; height: 460px; background: var(--card-bg); border: 1px solid var(--border); border-radius: 14px; box-shadow: 0 8px 32px rgba(0,0,0,.15); z-index: 1000; display: flex; flex-direction: column; overflow: hidden; }

#chat-header { display: flex; justify-content: space-between; align-items: center; padding: 12px 16px; background: var(--accent); color: #fff; font-weight: 700; font-size: 14px; }
#chat-close { background: none; border: none; color: #fff; cursor: pointer; font-size: 16px; opacity: .8; }
#chat-close:hover { opacity: 1; }

#chat-messages { flex: 1; overflow-y: auto; padding: 12px; display: flex; flex-direction: column; gap: 10px; }

.chat-msg { max-width: 88%; padding: 8px 12px; border-radius: 10px; font-size: 13px; line-height: 1.5; word-break: break-word; }
.chat-msg.user { background: var(--accent); color: #fff; align-self: flex-end; border-bottom-right-radius: 3px; }
.chat-msg.bot  { background: var(--bg); color: var(--text); align-self: flex-start; border-bottom-left-radius: 3px; }
.chat-msg.bot.thinking { color: var(--muted); font-style: italic; }

#chat-input-row { display: flex; gap: 8px; padding: 10px 12px; border-top: 1px solid var(--border); }
#chat-input { flex: 1; background: var(--bg); border: 1px solid var(--border); color: var(--text); padding: 7px 10px; border-radius: 8px; font-size: 13px; font-family: inherit; outline: none; resize: none; }
#chat-input:focus { border-color: var(--accent); }
#chat-send { width: 34px; height: 34px; background: var(--accent); color: #fff; border: none; border-radius: 8px; font-size: 16px; cursor: pointer; transition: background .15s; align-self: flex-end; }
#chat-send:hover { background: var(--accent-hover); }

/* ── SIDEBAR ── */
#sidebar { width: 280px; min-width: 280px; background: var(--sidebar-bg); border-right: 1px solid var(--border); display: flex; flex-direction: column; overflow: hidden; }

.sidebar-top { padding: 16px; border-bottom: 1px solid var(--border); display: flex; flex-direction: column; gap: 8px; }

.app-title { font-size: 17px; font-weight: 700; color: var(--accent); text-decoration: none; cursor: pointer; }
.app-title:hover { color: var(--accent-hover); }

#search-input { background: var(--bg); border: 1px solid var(--border); color: var(--text); padding: 7px 10px; border-radius: 6px; font-size: 13px; outline: none; width: 100%; }
#search-input:focus { border-color: var(--accent); }

.btn-secondary { background: transparent; border: 1px solid var(--border); color: var(--text); padding: 7px; border-radius: 6px; font-size: 12px; cursor: pointer; width: 100%; transition: border-color .15s, color .15s; text-decoration: none; display: block; text-align: center; }
.btn-export { color: var(--muted); }
.btn-secondary:hover { border-color: var(--accent); color: var(--accent); }
.btn-secondary:disabled { opacity: .5; cursor: default; }

.btn-filter { background: transparent; border: 1px solid var(--border); color: var(--muted); padding: 7px; border-radius: 6px; font-size: 12px; cursor: pointer; width: 100%; transition: border-color .15s, color .15s, background .15s; text-align: left; }
.btn-filter:hover { border-color: var(--accent); color: var(--accent); }
.btn-filter.active { border-color: var(--accent); color: var(--accent); background: rgba(123,104,238,.12); }

.note-flag { font-size: 10px; margin-left: 5px; opacity: .8; }

.song-count { padding: 5px 16px; font-size: 11px; color: var(--muted); border-bottom: 1px solid var(--border); }

#song-list { list-style: none; overflow-y: auto; flex: 1; }
#song-list li { padding: 10px 16px; cursor: pointer; border-bottom: 1px solid var(--border); transition: background .1s; }
#song-list li:hover { background: var(--card-bg); }
#song-list li.active { background: var(--card-bg); border-left: 3px solid var(--accent); padding-left: 13px; }

.song-item-title { font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.song-item-meta  { font-size: 11px; color: var(--muted); margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.song-duration   { font-weight: 600; color: var(--accent); margin-left: 5px; font-variant-numeric: tabular-nums; }

/* ── SCAN PANEL ── */
#scan-panel { border-top: 1px solid var(--border); background: var(--card-bg); padding: 10px 12px 4px; }

.scan-panel-label { font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin-bottom: 5px; }
.scan-panel-section { margin-bottom: 10px; }

#folders-list { list-style: none; }
#folders-list li { display: flex; align-items: center; gap: 5px; padding: 4px 2px; border-bottom: 1px solid var(--border); }
#folders-list li:last-child { border-bottom: none; }
.folder-path { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-family: monospace; font-size: 11px; color: var(--text); }
.folder-del { background: none; border: none; color: var(--muted); cursor: pointer; font-size: 11px; padding: 1px 4px; border-radius: 3px; transition: color .1s; flex-shrink: 0; }
.folder-del:hover { color: var(--danger); }

#drives-list { display: flex; flex-wrap: wrap; gap: 5px; }
.drive-chip { background: var(--bg); border: 1px solid var(--border); color: var(--text); font-family: monospace; font-size: 12px; font-weight: 600; padding: 4px 10px; border-radius: 5px; cursor: pointer; transition: border-color .15s, color .15s; }
.drive-chip:hover { border-color: var(--accent); color: var(--accent); }
.drive-chip.active { border-color: var(--accent); background: rgba(92,78,232,.1); color: var(--accent); }

.folders-add { display: flex; gap: 5px; }
#folder-input { flex: 1; background: var(--bg); border: 1px solid var(--border); color: var(--text); padding: 5px 7px; border-radius: 5px; font-size: 11px; font-family: monospace; outline: none; min-width: 0; }
#folder-input:focus { border-color: var(--accent); }
#folder-add-btn { background: var(--accent); color: #fff; border: none; border-radius: 5px; width: 26px; font-size: 16px; cursor: pointer; transition: background .15s; flex-shrink: 0; }
#folder-add-btn:hover { background: var(--accent-hover); }

.folder-error { font-size: 11px; color: var(--danger); margin-top: 4px; min-height: 14px; }

.btn-scan-now { width: 100%; padding: 8px; background: var(--accent); color: #fff; border: none; border-radius: 6px; font-size: 13px; font-weight: 600; cursor: pointer; margin-top: 2px; transition: background .15s; }
.btn-scan-now:hover { background: var(--accent-hover); }

/* ── MAIN ── */
#main { flex: 1; overflow-y: auto; padding: 24px; }

#empty-state { display: flex; flex-direction: column; align-items: center; justify-content: center; height: 100%; gap: 8px; }
.empty-icon { font-size: 48px; margin-bottom: 12px; }
.muted { color: var(--muted); font-size: 13px; }
.hidden { display: none !important; }

/* ── CARDS ── */
.card { background: var(--card-bg); border: 1px solid var(--border); border-radius: 10px; padding: 20px; margin-bottom: 16px; }
.card h3 { font-size: 12px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); margin-bottom: 14px; display: flex; align-items: center; gap: 6px; }

/* ── NOW PLAYING ── */
#np-title-row { display: flex; align-items: center; gap: 8px; margin-bottom: 4px; }
#np-title-edit-wrap { display: flex; align-items: center; gap: 6px; min-width: 0; flex: 1; }
#np-title { font-size: 20px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; flex-shrink: 1; min-width: 0; }
.rename-input { flex: 1; font-size: 18px; font-weight: 700; background: var(--bg); border: 1px solid var(--accent); border-radius: 5px; color: var(--text); padding: 2px 8px; outline: none; min-width: 0; font-family: inherit; }
.btn-icon { background: var(--bg); border: 1px solid var(--border); cursor: pointer; font-size: 13px; opacity: .8; padding: 4px 8px; border-radius: 6px; transition: opacity .15s, border-color .15s; flex-shrink: 0; line-height: 1; }
.btn-icon:hover { opacity: 1; border-color: var(--accent); }
.btn-icon-danger:hover { opacity: 1; border-color: var(--danger); }
#np-meta  { font-size: 13px; color: var(--muted); margin-bottom: 18px; }

#progress-row { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
#progress-row span { font-size: 12px; color: var(--muted); min-width: 36px; text-align: center; font-variant-numeric: tabular-nums; }
#progress { flex: 1; accent-color: var(--accent); cursor: pointer; height: 4px; }

#controls-row { display: flex; align-items: center; gap: 16px; }
.btn-play { width: 44px; height: 44px; border-radius: 50%; background: var(--accent); color: #fff; border: none; font-size: 16px; cursor: pointer; transition: background .15s; display: flex; align-items: center; justify-content: center; }
.btn-play:hover { background: var(--accent-hover); }

.volume-row { display: flex; align-items: center; gap: 8px; }
#volume { width: 80px; accent-color: var(--accent); cursor: pointer; }

/* ── MARK BUTTON ── */
.btn-mark { width: 100%; padding: 14px; background: var(--accent); color: #fff; border: none; border-radius: 10px; font-size: 16px; font-weight: 700; cursor: pointer; margin-bottom: 6px; transition: background .15s, transform .1s; letter-spacing: .02em; }
.btn-mark:hover { background: var(--accent-hover); }
.btn-mark:active { transform: scale(.98); }

.mark-hint { text-align: center; margin-bottom: 16px; font-size: 12px; }
kbd { background: var(--card-bg); border: 1px solid var(--border); border-radius: 3px; padding: 1px 5px; font-family: monospace; font-size: 11px; color: var(--text); }

/* ── TIMESTAMPS ── */
#ts-list { list-style: none; }
.ts-empty { font-style: italic; }

.ts-item { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--border); }
.ts-item:last-child { border-bottom: none; }

.ts-time { font-size: 13px; font-weight: 700; color: var(--accent); cursor: pointer; min-width: 46px; font-family: monospace; }
.ts-time:hover { text-decoration: underline; }

.ts-label { flex: 1; background: transparent; border: 1px solid transparent; color: var(--text); font-size: 13px; outline: none; padding: 3px 5px; border-radius: 4px; font-family: inherit; }
.ts-label:focus { background: var(--bg); border-color: var(--border); }
.ts-label::placeholder { color: var(--muted); }

.ts-del { background: none; border: none; color: var(--muted); cursor: pointer; font-size: 13px; padding: 2px 6px; border-radius: 4px; transition: color .1s; line-height: 1; }
.ts-del:hover { color: var(--danger); }

.badge { background: var(--accent); color: #fff; border-radius: 10px; font-size: 10px; padding: 1px 7px; font-weight: 700; letter-spacing: 0; text-transform: none; }

/* ── NOTES ── */
#note-input { width: 100%; min-height: 110px; background: var(--bg); border: 1px solid var(--border); color: var(--text); padding: 10px; border-radius: 6px; font-size: 13px; font-family: inherit; resize: vertical; outline: none; line-height: 1.6; }
#note-input:focus { border-color: var(--accent); }

.note-status { font-size: 11px; color: var(--muted); font-weight: 400; text-transform: none; letter-spacing: 0; }

/* ── IMPORT TOAST ── */
.import-toast { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%) translateY(12px); background: #1e293b; border: 1px solid var(--border); color: var(--text); font-size: 13px; padding: 10px 18px; border-radius: 8px; box-shadow: 0 4px 20px rgba(0,0,0,.5); z-index: 9999; opacity: 0; transition: opacity .2s, transform .2s; white-space: nowrap; pointer-events: none; }
.import-toast.visible { opacity: 1; transform: translateX(-50%) translateY(0); }
.import-toast-ok  { border-color: var(--accent); color: #a5f3fc; }
.import-toast-error { border-color: var(--danger); color: #fca5a5; }

/* ── IMPORT BUTTON ── */
.btn-import { text-align: center; }


/* ── SCROLLBAR ── */
#main { scrollbar-width: thin; scrollbar-color: var(--border) transparent; }
#main::-webkit-scrollbar { width: 5px; }
#main::-webkit-scrollbar-track { background: transparent; }
#main::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
#song-list { scrollbar-width: thin; scrollbar-color: var(--border) transparent; }
#song-list::-webkit-scrollbar { width: 4px; }
#song-list::-webkit-scrollbar-track { background: transparent; }
#song-list::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

/* ── RESPONSIVE ── */
@media (max-width: 768px) {
  #app { flex-direction: column; height: auto; min-height: calc(100vh - 32px); overflow: visible; }
  #sidebar { width: 100%; min-width: 0; border-right: none; border-bottom: 1px solid var(--border); overflow: visible; }
  #sidebar .sidebar-top { flex-direction: row; flex-wrap: wrap; gap: 6px; padding: 10px 12px; }
  #sidebar .sidebar-top .app-title { width: 100%; }
  #sidebar .sidebar-top .btn-secondary,
  #sidebar .sidebar-top .btn-filter { width: calc(50% - 3px); }
  #sidebar .sidebar-top #search-input { width: 100%; }
  #song-list { max-height: 240px; }
  #main { overflow-y: visible; padding: 16px; }
  #chat-panel { width: calc(100vw - 24px); right: 12px; }
  .home-hero { padding: 24px 16px 16px; }
  .home-section { padding: 0 12px 16px; }
  .install-section { padding: 0 12px 24px; }
}

@media (max-width: 480px) {
  .home-features { grid-template-columns: 1fr 1fr; }
  #sidebar .sidebar-top .btn-secondary,
  #sidebar .sidebar-top .btn-filter { width: 100%; }
}

@media (max-width: 340px) {
  .home-features { grid-template-columns: 1fr; }
}
