/* —— 吉他谱站 · 原木 / 乐谱纸质感 —— */
:root {
  --font-sans: "Source Sans 3", "Segoe UI", system-ui, sans-serif;
  --font-serif: "Noto Serif SC", "Source Serif 4", "Times New Roman", serif;

  --paper: #faf6ef;
  --paper-2: #f3ebe0;
  --paper-deep: #e8dcc8;
  --cream: #fffdf8;
  --ink: #1c1410;
  --ink-soft: #3d2e26;
  --muted: #6b5346;
  --muted-light: #9a7f6e;

  --wood-deep: #2a1810;
  --wood-mid: #4a3226;
  --wood-light: #6b4e3d;
  --honey: #c9985c;
  --honey-bright: #ddb882;
  --amber-line: #b8956a;

  --surface: #fffdf9;
  --surface-raised: #ffffff;
  --border: #e0d2c0;
  --border-strong: #c9b8a4;

  --accent: #5c3d2e;
  --accent-hover: #4a3228;
  --accent-text: #f5ebe0;

  --success: #3d5c38;
  --success-bg: rgba(61, 92, 56, 0.1);
  --danger: #9c3d32;
  --danger-bg: rgba(156, 61, 50, 0.1);
  --warn: #8a6919;
  --warn-bg: rgba(184, 134, 11, 0.12);
  --info: #5a4a3a;
  --info-bg: rgba(90, 74, 58, 0.1);

  --radius: 10px;
  --radius-sm: 6px;
  --shadow-sm: 0 1px 3px rgba(44, 24, 16, 0.08);
  --shadow-md: 0 4px 20px rgba(44, 24, 16, 0.1);
  --shadow-header: 0 4px 24px rgba(20, 10, 6, 0.35);

  --header-h: 4.25rem;
}

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

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font-sans);
  font-size: 1rem;
  line-height: 1.55;
  color: var(--ink);
  background-color: var(--paper);
  background-image:
    linear-gradient(165deg, rgba(201, 152, 92, 0.06) 0%, transparent 42%),
    linear-gradient(180deg, var(--paper) 0%, var(--paper-2) 55%, #ebe3d5 100%),
    repeating-linear-gradient(
      90deg,
      transparent,
      transparent 2px,
      rgba(139, 99, 73, 0.03) 2px,
      rgba(139, 99, 73, 0.03) 3px
    );
}

a {
  color: var(--wood-mid);
  text-decoration: none;
  font-weight: 500;
  transition: color 0.15s ease, border-color 0.15s ease;
}
a:hover {
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 3px;
}

/* —— 顶栏 —— */
.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  min-height: var(--header-h);
  background: linear-gradient(180deg, #3d2618 0%, var(--wood-deep) 48%, #1f100c 100%);
  border-bottom: 1px solid rgba(201, 152, 92, 0.22);
  box-shadow: var(--shadow-header);
}

.site-header .inner {
  max-width: 1040px;
  margin: 0 auto;
  padding: 0.65rem 1.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.75rem;
  text-decoration: none;
  color: var(--honey-bright);
}
.brand:hover {
  color: #fff;
  text-decoration: none;
}

.brand-logo {
  display: block;
  width: 44px;
  height: auto;
  max-height: 52px;
  flex-shrink: 0;
  object-fit: contain;
}

/* 顶栏深色背景上，原木色矢量容易“融进背景”，提亮并加浅色勾边感 */
.site-header .brand-logo {
  filter: brightness(1.42) contrast(1.08) saturate(1.05)
    drop-shadow(0 0 1px rgba(255, 248, 238, 0.95))
    drop-shadow(0 2px 10px rgba(0, 0, 0, 0.55));
}

.brand-text {
  display: flex;
  flex-direction: column;
  gap: 0.05rem;
  line-height: 1.15;
}

.brand-title {
  font-family: var(--font-serif);
  font-weight: 700;
  font-size: 1.2rem;
  letter-spacing: 0.04em;
  color: #fff;
}

.brand-tagline {
  font-size: 0.72rem;
  font-weight: 500;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: rgba(245, 235, 224, 0.55);
}

.site-header nav {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  flex-wrap: wrap;
}

.nav-link {
  padding: 0.4rem 0.85rem;
  border-radius: 999px;
  font-size: 0.9rem;
  font-weight: 600;
  color: rgba(255, 250, 245, 0.88);
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(201, 152, 92, 0.2);
  text-decoration: none;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}
.nav-link:hover {
  background: rgba(201, 152, 92, 0.18);
  border-color: rgba(221, 184, 130, 0.45);
  color: #fff;
  text-decoration: none;
}

.site-header .user {
  font-size: 0.85rem;
  color: rgba(245, 235, 224, 0.65);
  padding: 0 0.35rem;
}

/* —— 主区域 —— */
.site-main-wrap {
  display: flex;
  flex-direction: column;
  min-height: calc(100vh - var(--header-h));
}

.container {
  flex: 1 0 auto;
  width: 100%;
  max-width: 1040px;
  margin: 0 auto;
  padding: 1.75rem 1.25rem 2.5rem;
}

body.page-auth .site-main-wrap {
  background-image:
    radial-gradient(ellipse 70% 50% at 50% 0%, rgba(201, 152, 92, 0.14), transparent 55%),
    radial-gradient(circle at 15% 85%, rgba(74, 50, 38, 0.06), transparent 40%),
    radial-gradient(circle at 90% 70%, rgba(201, 152, 92, 0.08), transparent 35%);
}

body.page-auth .container {
  flex: 0 0 auto;
  max-width: 420px;
  padding-top: 2.5rem;
  padding-bottom: 1rem;
}

/* —— 页头区块 —— */
.page-header {
  display: flex;
  align-items: flex-start;
  gap: 1rem;
  margin-bottom: 1.75rem;
  padding-bottom: 1.25rem;
  border-bottom: 1px solid var(--border);
  background: linear-gradient(180deg, rgba(255, 253, 249, 0.6) 0%, transparent 100%);
  border-radius: var(--radius);
  padding: 1rem 1.25rem 1.25rem;
  margin-left: -0.25rem;
  margin-right: -0.25rem;
}

.page-header-icon {
  flex-shrink: 0;
  width: 56px;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(145deg, var(--cream) 0%, var(--paper-2) 100%);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: var(--shadow-sm);
}
.page-header-icon img {
  display: block;
  width: 40px;
  height: auto;
  max-height: 56px;
  object-fit: contain;
}

.page-header h1 {
  margin: 0 0 0.35rem;
}

.page-lead {
  margin: 0;
  font-size: 0.95rem;
  max-width: 42rem;
}

h1 {
  font-family: var(--font-serif);
  font-size: 1.65rem;
  font-weight: 700;
  color: var(--ink-soft);
  letter-spacing: 0.02em;
}

h2 {
  font-family: var(--font-serif);
  font-size: 1.15rem;
  font-weight: 600;
  color: var(--wood-mid);
  margin-top: 0;
}

.section-title {
  font-family: var(--font-serif);
  font-size: 1.2rem;
  font-weight: 600;
  color: var(--wood-mid);
  margin: 2rem 0 1rem;
  padding-bottom: 0.35rem;
  border-bottom: 1px dashed var(--border);
}

/* —— 认证卡片 —— */
.auth-panel {
  background: var(--surface-raised);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 2rem 1.75rem 1.75rem;
  box-shadow: var(--shadow-md), 0 0 0 1px rgba(255, 255, 255, 0.8) inset;
}

.auth-panel .auth-visual {
  text-align: center;
  margin-bottom: 1.25rem;
}
.auth-panel .auth-visual img {
  width: 72px;
  height: auto;
  opacity: 0.92;
}

.auth-panel h1 {
  text-align: center;
  font-size: 1.45rem;
  margin-bottom: 1.25rem;
}

.auth-panel + .muted,
.auth-panel ~ .muted {
  text-align: center;
  margin-top: 1.25rem;
}

/* —— 提示条 —— */
.flashes {
  list-style: none;
  padding: 0;
  margin: 0 0 1.25rem;
}
.flash {
  padding: 0.65rem 1rem;
  border-radius: var(--radius-sm);
  margin-bottom: 0.5rem;
  font-size: 0.92rem;
  border-left: 4px solid;
}
.flash-success {
  background: var(--success-bg);
  border-left-color: var(--success);
  color: var(--ink-soft);
}
.flash-danger {
  background: var(--danger-bg);
  border-left-color: var(--danger);
}
.flash-warning {
  background: var(--warn-bg);
  border-left-color: var(--warn);
}
.flash-info {
  background: var(--info-bg);
  border-left-color: var(--info);
}

/* —— 表单 —— */
.stack-form {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.upload-stack {
  max-width: 520px;
}
.stack-form label {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--ink-soft);
}

.input {
  padding: 0.55rem 0.75rem;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--cream);
  color: var(--ink);
  font-size: 1rem;
  font-family: inherit;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.input:hover {
  border-color: var(--amber-line);
}
.input:focus {
  outline: none;
  border-color: var(--honey);
  box-shadow: 0 0 0 3px rgba(201, 152, 92, 0.25);
}

select.input {
  cursor: pointer;
  appearance: auto;
}

/* —— 按钮 —— */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.5rem 1.1rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: linear-gradient(180deg, #fff 0%, var(--paper-2) 100%);
  color: var(--ink-soft);
  cursor: pointer;
  font-size: 0.95rem;
  font-weight: 600;
  font-family: inherit;
  box-shadow: var(--shadow-sm);
  transition: transform 0.08s ease, box-shadow 0.15s ease, border-color 0.15s ease, filter 0.15s ease;
}
.btn:hover {
  border-color: var(--amber-line);
  filter: brightness(1.02);
  text-decoration: none;
  color: var(--ink);
}
.btn:active {
  transform: translateY(1px);
}

.btn.primary {
  background: linear-gradient(180deg, var(--wood-light) 0%, var(--accent) 100%);
  border-color: #3d2618;
  color: var(--accent-text);
  box-shadow: 0 2px 8px rgba(44, 24, 16, 0.2);
}
.btn.primary:hover {
  background: linear-gradient(180deg, #7a5540 0%, var(--accent-hover) 100%);
  color: #fff;
  border-color: var(--wood-deep);
  filter: brightness(1.05);
}

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none;
}

.btn.ghost {
  text-align: center;
  line-height: 1.2;
}

.btn.small {
  padding: 0.28rem 0.6rem;
  font-size: 0.85rem;
}

.btn.danger {
  border-color: rgba(156, 61, 50, 0.45);
  color: var(--danger);
  background: linear-gradient(180deg, #fff8f7 0%, #fce8e6 100%);
}
.btn.danger:hover {
  background: var(--danger-bg);
  border-color: var(--danger);
  color: #7a2e26;
}

/* —— 卡片 —— */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.15rem 1.35rem;
  margin-bottom: 1.25rem;
  box-shadow: var(--shadow-sm);
}

.filter-card {
  background: linear-gradient(165deg, var(--cream) 0%, var(--surface) 40%);
}

.card h2 {
  padding-bottom: 0.35rem;
  border-bottom: 1px dashed var(--border);
  margin-bottom: 0.85rem;
}

.inline-form {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 0.75rem;
}
.inline-form label {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--ink-soft);
}

.muted {
  color: var(--muted);
}
.small {
  font-size: 0.85rem;
}

/* —— 标签勾选 —— */
.tag-fieldset {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.1rem;
  background: rgba(255, 253, 249, 0.6);
}
.tag-fieldset legend {
  font-family: var(--font-serif);
  font-weight: 600;
  padding: 0 0.5rem;
  color: var(--wood-mid);
}

.req-mark {
  color: var(--danger);
  font-weight: 700;
}

.tag-group {
  margin-bottom: 0.85rem;
}
.tag-group:last-child {
  margin-bottom: 0;
}
.tag-group > strong {
  font-size: 0.88rem;
  color: var(--wood-mid);
}

.tag-checks {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  margin-top: 0.4rem;
}

.tag-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.88rem;
  cursor: pointer;
  padding: 0.35rem 0.65rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--cream);
  color: var(--ink-soft);
  transition: background 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
}
.tag-pill:hover {
  border-color: var(--amber-line);
  background: #fff;
}
.tag-pill:has(input:checked) {
  background: linear-gradient(180deg, rgba(201, 152, 92, 0.2) 0%, rgba(92, 61, 46, 0.12) 100%);
  border-color: var(--honey);
  color: var(--accent);
  font-weight: 600;
  box-shadow: 0 0 0 1px rgba(201, 152, 92, 0.25);
}

.tag-pill input {
  accent-color: var(--accent);
}

.warn-box {
  background: var(--warn-bg);
  border: 1px solid rgba(184, 134, 11, 0.35);
  padding: 0.85rem 1rem;
  border-radius: var(--radius);
  color: var(--ink-soft);
}

.filter-form .filter-actions {
  margin-top: 1rem;
  display: flex;
  gap: 0.5rem;
  align-items: center;
  flex-wrap: wrap;
}

.filter-mode-fieldset {
  border: 1px dashed var(--border);
  border-radius: var(--radius-sm);
  padding: 0.75rem 1rem 1rem;
  margin: 0 0 1rem;
  background: rgba(255, 253, 249, 0.5);
}
.filter-mode-fieldset legend {
  padding: 0 0.35rem;
  font-weight: 600;
  color: var(--wood-mid);
}
.filter-mode-options {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
}
.filter-mode-option {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
  cursor: pointer;
  font-size: 0.9rem;
  line-height: 1.45;
  color: var(--ink-soft);
}
.filter-mode-option input {
  margin-top: 0.25rem;
  accent-color: var(--accent);
  flex-shrink: 0;
}

.merge-block {
  margin-bottom: 1.25rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  /* visible：合并预览拖动项需要外扩阴影，hidden 会裁切 */
  overflow: visible;
  background: var(--surface);
}

.merge-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem 1rem;
  padding: 1rem 1.15rem;
  background: linear-gradient(90deg, rgba(92, 61, 46, 0.08) 0%, rgba(201, 152, 92, 0.1) 100%);
  border-bottom: 1px solid var(--border);
}

.merge-order-panel {
  padding: 0.85rem 1.15rem 1.15rem;
  background: rgba(255, 253, 249, 0.65);
  /* 为拖动条目的悬浮阴影留出空间 */
  overflow: visible;
}

.merge-order-heading {
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--wood-mid);
  margin-bottom: 0.5rem;
  font-family: var(--font-serif);
}

.merge-order-hint {
  font-weight: 400;
  margin-left: 0.35rem;
}

.merge-order-list {
  margin: 0;
  padding-left: 1.35rem;
  font-size: 0.92rem;
  line-height: 1.55;
  color: var(--ink-soft);
  position: relative;
  z-index: 0;
}

/* 避免浏览器把触屏手势当成页面滚动并 pointercancel，否则合并预览无法拖动排序 */
.merge-order-list:has(.merge-order-item) {
  touch-action: none;
}

.merge-order-list li {
  margin-bottom: 0.25rem;
}

.merge-order-item {
  cursor: grab;
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
  touch-action: none;
  padding: 0.15rem 0;
  border-radius: 4px;
  border: 1px solid transparent;
  transition: background 0.12s ease;
}

.merge-order-item:hover {
  background: rgba(92, 61, 46, 0.06);
}

.merge-order-item.is-dragging {
  cursor: grabbing;
  position: relative;
  z-index: 40;
  opacity: 1;
  margin-top: 0.1rem;
  margin-bottom: 0.35rem;
  padding: 0.4rem 0.55rem;
  margin-left: -0.35rem;
  transform: translateY(-6px) scale(1.02);
  transform-origin: center center;
  background: var(--surface-raised);
  border-color: var(--amber-line);
  border-radius: var(--radius-sm);
  box-shadow:
    0 2px 0 rgba(255, 255, 255, 0.85) inset,
    0 14px 32px rgba(42, 24, 16, 0.22),
    0 6px 14px rgba(42, 24, 16, 0.14),
    0 0 0 1px rgba(92, 61, 46, 0.08);
  color: var(--ink);
  transition: none;
}

.merge-order-placeholder {
  margin: 0;
  font-style: italic;
}

.merge-order-placeholder[hidden] {
  display: none;
}

/* —— 表格 —— */
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.92rem;
  background: var(--surface-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}
.data-table th,
.data-table td {
  padding: 0.7rem 0.85rem;
  text-align: left;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}
.data-table th {
  font-family: var(--font-serif);
  font-weight: 600;
  font-size: 0.88rem;
  letter-spacing: 0.03em;
  background: linear-gradient(180deg, var(--paper-deep) 0%, #ddd2c4 100%);
  color: var(--ink-soft);
}
.data-table tbody tr {
  transition: background 0.12s ease;
}
.data-table tbody tr:nth-child(even) {
  background: rgba(243, 235, 224, 0.35);
}
.data-table tbody tr:hover {
  background: rgba(201, 152, 92, 0.12);
}

.data-table tbody tr.doc-row {
  cursor: pointer;
}
.data-table tr:last-child td {
  border-bottom: none;
}

.data-table .doc-cb {
  width: 1.1rem;
  height: 1.1rem;
  accent-color: var(--accent);
  cursor: pointer;
}

.col-check {
  width: 2.75rem;
}
.col-actions {
  width: 5.5rem;
  white-space: nowrap;
}
.inline-delete-form {
  display: inline;
  margin: 0;
}
.inline-delete-form button {
  vertical-align: middle;
}
.tags-cell {
  max-width: 340px;
}
.tag-line {
  margin-bottom: 0.3rem;
  font-size: 0.9rem;
}
.cat-label {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 600;
}
.nowrap {
  white-space: nowrap;
}

/* —— 分类树 —— */
.tree {
  list-style: disc;
  padding-left: 1.25rem;
}
.tree ul {
  list-style: circle;
  margin: 0.25rem 0 0.5rem;
}

.tree-editable {
  list-style: none;
  padding-left: 0;
}
.tree-editable .tree-category {
  list-style: none;
  margin-bottom: 1.1rem;
  padding: 1rem 1.15rem;
  background: linear-gradient(145deg, var(--cream) 0%, var(--paper-2) 100%);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}
.tree-category-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.65rem;
  padding-bottom: 0.65rem;
  border-bottom: 1px dashed var(--border);
}
.tree-tags {
  list-style: none;
  padding-left: 0.35rem;
  margin: 0;
}
.tree-tag {
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.55rem;
}
.inline-row-form {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem;
}
.row-label {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--muted);
  min-width: 2.2rem;
}
.input-compact {
  min-width: 8rem;
  max-width: 15rem;
}

/* —— 页脚 —— */
.site-footer {
  flex-shrink: 0;
  width: 100%;
  margin: 0;
  padding: 1.25rem 1.25rem 1.75rem;
  text-align: center;
  border-top: 1px solid var(--border);
  background: linear-gradient(180deg, rgba(255, 253, 249, 0.4), rgba(232, 220, 200, 0.35));
}
.site-footer p {
  margin: 0 auto;
  max-width: 1040px;
  padding: 0 1.25rem;
  font-size: 0.8rem;
  color: var(--muted-light);
  letter-spacing: 0.06em;
}

/* —— 返回链接区 —— */
.back-row {
  margin-top: 2rem;
  padding-top: 1rem;
  border-top: 1px dashed var(--border);
}

/* —— 无障碍焦点 —— */
:focus-visible {
  outline: 2px solid var(--honey);
  outline-offset: 2px;
}
.btn:focus-visible,
.nav-link:focus-visible {
  outline-offset: 2px;
}

@media (max-width: 640px) {
  .page-header {
    flex-direction: column;
    align-items: center;
    text-align: center;
  }
  .page-lead {
    margin-left: auto;
    margin-right: auto;
  }
  .brand-tagline {
    display: none;
  }
}
