:root {
  --bg: #f6f4ef;
  --surface: #ffffff;
  --surface-2: #fbf9f5;
  --line: #e7e2d8;
  --text: #23201c;
  --text-2: #6b645a;
  --text-3: #9a938a;
  --brand: #e8623c;
  --brand-soft: #fdeee8;
  --green: #2f9e6b;
  --green-soft: #e8f6ef;
  --blue: #3568c9;
  --blue-soft: #eaf0fc;
  --amber: #b7791f;
  --amber-soft: #fdf3e0;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(35, 32, 28, .05), 0 8px 24px -12px rgba(35, 32, 28, .18);
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }

/* 关键：.login-wrap / .app 都写了 display，会盖掉浏览器默认的 [hidden]{display:none}，
   导致 hidden 属性失效（登录后登录页不消失）。这里显式兜底。 */
[hidden] { display: none !important; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB",
               "Microsoft YaHei", "Segoe UI", Roboto, sans-serif;
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
::selection { background: var(--brand-soft); }

/* ---------------------------------------------------------------- 布局 */
.app { display: flex; min-height: 100vh; }

.sidebar {
  width: 216px;
  flex: 0 0 216px;
  background: var(--surface);
  border-right: 1px solid var(--line);
  padding: 22px 14px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  position: sticky;
  top: 0;
  height: 100vh;
}

.logo {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 8px 20px;
}
.logo-mark {
  width: 34px; height: 34px; border-radius: 10px;
  background: var(--brand);
  display: grid; place-items: center;
  color: #fff; font-weight: 700; font-size: 15px;
  box-shadow: 0 6px 14px -6px rgba(232, 98, 60, .8);
}
.logo-text { font-weight: 650; letter-spacing: .3px; }
.logo-sub { font-size: 11px; color: var(--text-3); margin-top: 2px; }

.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 11px; border-radius: 10px;
  color: var(--text-2); cursor: pointer; font-weight: 500;
  transition: background .16s, color .16s;
  border: none; background: transparent; width: 100%; text-align: left;
}
.nav-item:hover { background: var(--surface-2); color: var(--text); }
.nav-item.active { background: var(--brand-soft); color: var(--brand); }
.nav-item .ico { font-size: 15px; width: 18px; text-align: center; }

.sidebar-foot { margin-top: auto; font-size: 11px; color: var(--text-3); padding: 8px 11px; line-height: 1.7; }

.main { flex: 1; min-width: 0; padding: 26px 32px 60px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 20px; }
.page-title { font-size: 22px; font-weight: 680; margin: 0 0 6px; letter-spacing: -.2px; }
.page-desc { color: var(--text-3); font-size: 13px; }

/* ---------------------------------------------------------------- 组件 */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 36px; padding: 0 14px; border-radius: 10px;
  border: 1px solid var(--line); background: var(--surface);
  color: var(--text); font-weight: 550; cursor: pointer;
  transition: transform .08s, background .16s, border-color .16s;
  white-space: nowrap;
}
.btn:hover { background: var(--surface-2); }
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn-primary:hover { background: #d9552f; border-color: #d9552f; }
.btn-ghost { border-color: transparent; background: transparent; color: var(--text-2); }
.btn-ghost:hover { background: var(--surface-2); color: var(--text); }
.btn-sm { height: 30px; padding: 0 10px; font-size: 13px; border-radius: 8px; }
.btn-danger { color: #c0392b; }
.btn-danger:hover { background: #fdecea; }

.field { display: flex; flex-direction: column; gap: 6px; }
.field > label { font-size: 12px; color: var(--text-2); font-weight: 550; }
.input, .select, .textarea {
  width: 100%; height: 36px; padding: 0 11px;
  border: 1px solid var(--line); border-radius: 9px;
  background: var(--surface); outline: none;
  transition: border-color .16s, box-shadow .16s;
}
.textarea { height: auto; padding: 10px 12px; resize: vertical; line-height: 1.65; }
.input:focus, .select:focus, .textarea:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px var(--brand-soft);
}

.badge {
  display: inline-flex; align-items: center; gap: 4px;
  height: 21px; padding: 0 8px; border-radius: 6px;
  font-size: 11.5px; font-weight: 550;
  background: var(--surface-2); color: var(--text-2);
  border: 1px solid var(--line);
}
.badge-brand { background: var(--brand-soft); color: var(--brand); border-color: transparent; }
.badge-green { background: var(--green-soft); color: var(--green); border-color: transparent; }
.badge-blue { background: var(--blue-soft); color: var(--blue); border-color: transparent; }
.badge-amber { background: var(--amber-soft); color: var(--amber); border-color: transparent; }

/* ---------------------------------------------------------------- 表格 */
.table { width: 100%; border-collapse: collapse; }
.table th {
  text-align: left; font-size: 12px; font-weight: 600; color: var(--text-3);
  padding: 12px 14px; border-bottom: 1px solid var(--line); white-space: nowrap;
}
.table td { padding: 12px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tr:last-child td { border-bottom: none; }
.table tbody tr:hover { background: var(--surface-2); }
.song-title { font-weight: 600; }
.song-meta { font-size: 12px; color: var(--text-3); margin-top: 3px; }
.row-actions { display: flex; gap: 4px; justify-content: flex-end; }

/* ---------------------------------------------------------------- 用量护栏 */
.usage { padding: 16px 18px; margin-bottom: 18px; }
.usage-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.usage-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 14px 18px; }
.meter-item { min-width: 0; }
.meter-head { display: flex; align-items: baseline; justify-content: space-between; font-size: 12px; color: var(--text-2); margin-bottom: 5px; }
.meter-head b { font-family: var(--mono); font-size: 11.5px; font-weight: 600; color: var(--text); }
.meter { height: 6px; border-radius: 3px; background: var(--line); overflow: hidden; }
.meter i { display: block; height: 100%; border-radius: 3px; transition: width .3s ease; }
.meter-foot { display: flex; justify-content: space-between; font-size: 10.5px; color: var(--text-3); margin-top: 4px; }
.usage-foot { display: flex; align-items: center; justify-content: space-between; gap: 14px; margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--line); flex-wrap: wrap; }

/* ---------------------------------------------------------------- 统计卡 */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-bottom: 22px; }
.stat { padding: 15px 16px; }
.stat-label { font-size: 12px; color: var(--text-3); }
.stat-value { font-size: 26px; font-weight: 700; letter-spacing: -.6px; margin-top: 6px; }
.stat-value small { font-size: 13px; font-weight: 500; color: var(--text-3); margin-left: 3px; }

/* ---------------------------------------------------------------- 曲谱纸面 */
.paper {
  background: #fffdf8;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 26px 30px;
  color: #23201c;
}
.sheet-title { font-size: 19px; font-weight: 700; letter-spacing: .5px; }
.sheet-artist { font-size: 12.5px; color: var(--text-2); margin-top: 5px; }
.sheet-modules { display: flex; flex-wrap: wrap; gap: 8px; margin: 12px 0 4px; }
.sheet-module {
  font-size: 11.5px; color: var(--text-2);
  border: 1px solid var(--line); border-radius: 6px; padding: 2px 7px;
  background: #fff;
}
.sheet-section {
  display: flex; align-items: center; gap: 8px;
  margin: 22px 0 10px;
  font-size: 12px; font-weight: 650; color: var(--brand);
  letter-spacing: .6px;
}
.sheet-section::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.sheet-comment { font-size: 12.5px; color: var(--text-3); margin: 14px 0 6px; font-style: italic; }
.sheet-gap { height: 9px; }
.sheet-line { display: flex; flex-wrap: wrap; align-items: flex-end; margin-bottom: 4px; }
.seg { display: inline-flex; flex-direction: column; align-items: flex-start; }
.seg-chord {
  font-family: var(--mono);
  font-size: 12.5px; font-weight: 700; color: var(--brand);
  line-height: 1.35; min-height: 17px; white-space: pre;
  letter-spacing: .2px;
}
.seg-lyric { font-size: 15.5px; line-height: 1.55; white-space: pre-wrap; }
/* 和弦覆盖的歌词下面加一条细线，明确对应关系（右侧留 3px 断口，相邻段不会连成一条） */
.seg.has-chord .seg-lyric { position: relative; }
.seg.has-chord .seg-lyric::after {
  content: "";
  position: absolute;
  left: 0;
  right: 3px;
  bottom: 0;
  height: 1px;
  background: rgba(194, 65, 12, .38);
}
.sheet-tab, .sheet-grid {
  font-family: var(--mono); font-size: 12.5px; line-height: 1.55;
  background: var(--surface-2); border: 1px solid var(--line); border-radius: 10px;
  padding: 12px 14px; overflow-x: auto; margin: 10px 0; color: #3a352e;
}
.sheet-grid { background: #fff; }

.chord-strip { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 14px; }
.chord-chip {
  display: flex; flex-direction: column; align-items: center;
  border: 1px solid var(--line); border-radius: 10px; background: #fff;
  padding: 7px 8px 4px; cursor: pointer;
}
.chord-chip:hover { border-color: var(--brand); }

/* ---------------------------------------------------------------- 登录 */
.login-wrap {
  min-height: 100vh; display: grid; place-items: center;
  background: radial-gradient(1200px 600px at 50% -10%, #fdeee8, var(--bg) 60%);
  padding: 24px;
}
.login-card { width: 360px; padding: 30px 28px; }
.login-card h1 { font-size: 20px; margin: 0 0 6px; }
.login-card p { color: var(--text-3); font-size: 13px; margin: 0 0 22px; }

/* ---------------------------------------------------------------- 上传 */
.dropzone {
  border: 1.5px dashed var(--line); border-radius: 12px;
  padding: 30px; text-align: center; color: var(--text-3);
  background: var(--surface-2); cursor: pointer; transition: all .16s;
}
.dropzone:hover, .dropzone.dragover {
  border-color: var(--brand); background: var(--brand-soft); color: var(--brand);
}
.thumbs { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 14px; }
.thumb {
  position: relative; width: 104px; height: 138px; border-radius: 8px;
  overflow: hidden; border: 1px solid var(--line); background: #fff;
}
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.thumb .del {
  position: absolute; top: 4px; right: 4px; width: 20px; height: 20px;
  border-radius: 50%; border: none; background: rgba(0, 0, 0, .55); color: #fff;
  cursor: pointer; font-size: 12px; line-height: 1;
}
.thumb .idx {
  position: absolute; bottom: 4px; left: 4px;
  background: rgba(0, 0, 0, .55); color: #fff; font-size: 10.5px;
  border-radius: 4px; padding: 1px 5px;
}

.tabs { display: flex; gap: 4px; background: var(--surface-2); padding: 3px; border-radius: 10px; width: fit-content; }
.tab {
  border: none; background: transparent; height: 30px; padding: 0 14px;
  border-radius: 8px; cursor: pointer; color: var(--text-2); font-weight: 550;
}
.tab.active { background: var(--surface); color: var(--text); box-shadow: 0 1px 3px rgba(0, 0, 0, .08); }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; }

.split { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 18px; align-items: start; }
@media (max-width: 1080px) {
  .split { grid-template-columns: 1fr; }
  .sidebar { display: none; }
  .main { padding: 20px 18px 50px; }
  .grid-4, .grid-3 { grid-template-columns: 1fr 1fr; }
}

.editor-area {
  font-family: var(--mono); font-size: 13px; line-height: 1.75;
  min-height: 520px;
}
.toolbar { display: flex; flex-wrap: wrap; gap: 6px; }
.hint { font-size: 12px; color: var(--text-3); line-height: 1.75; }
.hint code {
  background: var(--surface-2); border: 1px solid var(--line);
  border-radius: 4px; padding: 0 4px; font-family: var(--mono); font-size: 11.5px;
}

.toast {
  position: fixed; left: 50%; bottom: 34px; transform: translate(-50%, 20px);
  background: #23201c; color: #fff; padding: 10px 18px; border-radius: 99px;
  font-size: 13px; opacity: 0; pointer-events: none; transition: all .22s;
  z-index: 100;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

.empty { text-align: center; padding: 48px 0; color: var(--text-3); }

/* 谱面字体缩放 */
.paper[data-scale="s"] .seg-lyric { font-size: 14px; }
.paper[data-scale="l"] .seg-lyric { font-size: 17.5px; }
.paper[data-scale="l"] .seg-chord { font-size: 14px; }
