/* ============================================================
   方正主义 · MusicFree Tools 设计系统
   结构：方正（12 列满铺 / 2px 墨线 / 零圆角 / 零投影）
   配色：取背景图（米白纸 · 墨绿 · 青柠）为主，方正原版四色仅作点缀
   主题：body.dark-theme 切换深色（墨绿底 + 青柠强调）
   ============================================================ */

:root {
  color-scheme: light;

  /* 纸面 */
  --paper: #F7F4EC;
  --surface: #FFFDF7;
  --surface-2: #EFEAD9;
  --surface-3: #E7E1D0;

  /* 墨与线 */
  --ink: #23261F;
  --muted: rgba(35, 38, 31, 0.62);
  --faint: rgba(35, 38, 31, 0.42);
  --line: #23261F;
  --hair: rgba(35, 38, 31, 0.20);
  --hair-strong: rgba(35, 38, 31, 0.42);

  /* 主视觉（取图：青柠 / 墨绿 / 青瓷绿） */
  --accent: #C8F03C;
  --accent-ink: #1C2410;
  --deep: #2F4A3A;
  --deep-ink: #F3F6E7;
  --teal: #3F8F73;
  --teal-ink: #F2F8F3;

  /* 方正原版点缀色（每屏每色 ≤ 2 块） */
  --brick: #AE5244;
  --mustard: #C98A3E;
  --olive: #6B6A4A;
  --navy: #2C3E50;

  /* 背景图 + 纯色半透明遮罩 */
  --bg-image: url("bg.jpg");
  --overlay: rgba(247, 244, 236, 0.84);
  --overlay-strong: rgba(247, 244, 236, 0.94);

  /* 模数 */
  --seam: 16px;
  --row: 76px;
  --pad: 24px;
  --wrap: 1280px;

  --sans: "Inter", "Segoe UI", "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  --mono: "Cascadia Mono", ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", Menlo, monospace;

  --speed: 0.18s;
  --speed-slow: 0.5s;
  --ease: cubic-bezier(.2, .7, .3, 1);
}

body.dark-theme {
  color-scheme: dark;

  --paper: #0F1411;
  --surface: #161C17;
  --surface-2: #1D2520;
  --surface-3: #243029;

  --ink: #EDEFE6;
  --muted: rgba(237, 239, 230, 0.66);
  --faint: rgba(237, 239, 230, 0.44);
  --line: #EDEFE6;
  --hair: rgba(237, 239, 230, 0.22);
  --hair-strong: rgba(237, 239, 230, 0.46);

  --deep: #24322A;
  --deep-ink: #EDEFE6;

  --overlay: rgba(11, 15, 13, 0.78);
  --overlay-strong: rgba(11, 15, 13, 0.88);
}

/* ---------- 基础 ---------- */

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

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100vh;
  padding: clamp(16px, 3vw, 32px);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.6;
  color: var(--ink);
  background: var(--paper);
  position: relative;
  overflow-x: hidden;
}

/* 背景图一层、纯色遮罩一层，都固定在视口 */
body::before,
body::after {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
}
body::before {
  background-image: var(--bg-image);
  background-position: center;
  background-size: cover;
  background-repeat: no-repeat;
  z-index: -2;
}
body::after {
  background: var(--overlay);
  z-index: -1;
}

.wrap {
  width: 100%;
  max-width: var(--wrap);
  margin: 0 auto;
}

a { color: inherit; text-decoration: none; }
img { max-width: 100%; display: block; }
button, input, textarea, select { font: inherit; color: inherit; }

::selection { background: var(--accent); color: var(--accent-ink); }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* ---------- 顶栏 ---------- */

.topbar {
  display: flex;
  align-items: center;
  gap: 18px;
  flex-wrap: wrap;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--hair-strong);
  margin-bottom: var(--seam);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 44px;
  font-weight: 800;
  letter-spacing: 0.02em;
}

.brand-mark {
  width: 36px;
  height: 36px;
  border: 2px solid var(--line);
  display: grid;
  place-items: center;
  font: 700 17px/1 var(--mono);
  flex: 0 0 auto;
}

.brand-text { display: flex; flex-direction: column; gap: 2px; }
.brand-text b { font-size: 15px; letter-spacing: 0.04em; }
.brand-text span {
  font: 9px/1 var(--mono);
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--faint);
}

.nav {
  display: flex;
  align-items: center;
  gap: 2px;
  margin-left: auto;
  flex-wrap: wrap;
}

.nav a {
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  padding: 0 14px;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.02em;
  border-bottom: 1px solid transparent;
  transition: color var(--speed), border-color var(--speed), background var(--speed);
}
.nav a:hover { border-bottom-color: var(--accent); background: var(--surface-2); }
.nav a[aria-current="page"] { border-bottom: 2px solid var(--accent); }

.status {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font: 10px/1 var(--mono);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
  white-space: nowrap;
}
.status i {
  width: 7px;
  height: 7px;
  background: var(--teal);
  display: block;
}

.icon-btn {
  width: 44px;
  height: 44px;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  border: 2px solid var(--line);
  background: var(--surface);
  cursor: pointer;
  transition: background var(--speed), color var(--speed);
}
.icon-btn:hover { background: var(--accent); color: var(--accent-ink); }
.icon-btn svg { width: 18px; height: 18px; }

/* ---------- 12 列满铺拼版 ---------- */

.mosaic {
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  grid-auto-rows: minmax(var(--row), auto);
  gap: var(--seam);
  margin-top: var(--seam);
}

.b {
  position: relative;
  min-width: 0;
  border: 2px solid var(--line);
  background: var(--surface);
  padding: var(--pad);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.b--deep { background: var(--deep); color: var(--deep-ink); --line: var(--deep-ink); --hair: rgba(243, 246, 231, 0.30); --muted: rgba(243, 246, 231, 0.74); --faint: rgba(243, 246, 231, 0.54); }
.b--accent { background: var(--accent); color: var(--accent-ink); --line: var(--accent-ink); --hair: rgba(28, 36, 16, 0.26); --muted: rgba(28, 36, 16, 0.74); --faint: rgba(28, 36, 16, 0.56); }
.b--brick { background: var(--brick); color: #FBF3EE; --line: #FBF3EE; --hair: rgba(251, 243, 238, 0.34); --muted: rgba(251, 243, 238, 0.78); --faint: rgba(251, 243, 238, 0.58); }
.b--mustard { background: var(--mustard); color: #23180B; --line: #23180B; --hair: rgba(35, 24, 11, 0.28); --muted: rgba(35, 24, 11, 0.76); --faint: rgba(35, 24, 11, 0.58); }
.b--navy { background: var(--navy); color: #F3F6E7; --line: #F3F6E7; --hair: rgba(243, 246, 231, 0.32); --muted: rgba(243, 246, 231, 0.74); --faint: rgba(243, 246, 231, 0.54); }

.eyebrow {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--hair);
  font: 10px/1 var(--mono);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: inherit;
}
.eyebrow .idx { display: inline-flex; align-items: center; gap: 8px; }
.eyebrow .idx::before { content: ""; width: 16px; height: 2px; background: var(--accent); }
.b--accent .eyebrow .idx::before { background: var(--accent-ink); }

.b-body { margin-top: auto; padding-top: 18px; }

/* 齐边操作条 */
.bar {
  display: flex;
  border-top: 2px solid var(--line);
  margin: auto calc(-1 * var(--pad)) calc(-1 * var(--pad));
}
.bar-cell {
  flex: 1 1 0;
  min-height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 0 20px;
  font-weight: 800;
  font-size: 14px;
  cursor: pointer;
  background: transparent;
  border: 0;
  text-align: left;
  transition: background var(--speed), color var(--speed);
}
.bar-cell + .bar-cell { border-left: 2px solid var(--line); }
.bar-cell:hover { background: var(--accent); color: var(--accent-ink); }
.bar-cell svg { width: 16px; height: 16px; flex: 0 0 auto; }

/* 字格印记 */
.mark {
  width: 104px;
  aspect-ratio: 1;
  border: 2px solid var(--line);
  display: grid;
  place-items: center;
  font: 800 40px/1 var(--sans);
  background-color: var(--surface);
  background-image:
    repeating-linear-gradient(0deg, var(--hair) 0 4px, transparent 4px 10px),
    repeating-linear-gradient(90deg, var(--hair) 0 4px, transparent 4px 10px);
  background-size: 1px 100%, 100% 1px;
  background-position: center, center;
  background-repeat: no-repeat;
  position: relative;
}
.mark::after { content: ""; position: absolute; inset: 9px; border: 1px solid var(--hair); }

/* 竖脊 */
.spine {
  writing-mode: vertical-rl;
  text-orientation: upright;
  font: 700 11px/1 var(--sans);
  letter-spacing: 0.22em;
  color: var(--muted);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--pad) 0;
}

/* ---------- 标题与文字 ---------- */

h1, h2, h3, p { margin: 0; }

.h1 {
  font-size: clamp(32px, 4.6vw, 62px);
  line-height: 1.02;
  letter-spacing: -0.02em;
  font-weight: 800;
}
.h2 { font-size: clamp(20px, 2vw, 26px); line-height: 1.15; font-weight: 800; letter-spacing: -0.01em; }
.h3 { font-size: 16px; line-height: 1.2; font-weight: 800; }
.lead { font-size: clamp(14px, 1.2vw, 16px); color: var(--muted); }
.small { font-size: 13px; }
.tiny { font: 10px/1.5 var(--mono); letter-spacing: 0.08em; text-transform: uppercase; color: var(--faint); }
.mono { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.accent-text { color: var(--deep); }
.hl { background: var(--accent); color: var(--accent-ink); padding: 0 6px; }

/* ---------- 按钮 / 标签 ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: 48px;
  padding: 0 20px;
  border: 2px solid var(--line);
  background: var(--surface);
  color: inherit;
  font-weight: 800;
  font-size: 14px;
  cursor: pointer;
  transition: background var(--speed), color var(--speed), border-color var(--speed);
  text-align: center;
}
.btn:hover { background: var(--accent); color: var(--accent-ink); border-color: var(--line); }
.btn:active { transform: none; }
.btn--primary { background: var(--deep); color: var(--deep-ink); border-color: var(--line); }
.btn--primary:hover { background: var(--accent); color: var(--accent-ink); }
.btn--accent { background: var(--accent); color: var(--accent-ink); }
.btn--accent:hover { background: var(--deep); color: var(--deep-ink); }
.btn--ghost { background: transparent; }
.btn[disabled], .btn[aria-disabled="true"] { opacity: 0.42; cursor: not-allowed; }
.btn svg { width: 16px; height: 16px; flex: 0 0 auto; }

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 26px;
  padding: 0 9px;
  border: 1px solid var(--hair-strong);
  font: 10px/1 var(--mono);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  white-space: nowrap;
}
.chip::before { content: ""; width: 6px; height: 6px; background: var(--accent); flex: 0 0 auto; }
.chip--teal::before { background: var(--teal); }
.chip--brick::before { background: var(--brick); }
.chip--muted::before { background: var(--faint); }

/* ---------- 卡片网格（非满铺场景） ---------- */

.grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--seam); }
.grid3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--seam); }

.card {
  border: 2px solid var(--line);
  background: var(--surface);
  padding: var(--pad);
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-height: 100%;
  transition: background var(--speed);
}
a.card:hover { background: var(--surface-2); }
.card .card-ico { width: 34px; height: 34px; }
.card .card-ico svg { width: 100%; height: 100%; }

/* ---------- 列表行（插件 / 评论） ---------- */

.rows { border-top: 2px solid var(--line); }
.row {
  display: grid;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--hair);
  background: transparent;
  transition: background var(--speed);
}
.row:hover { background: var(--surface-2); }
.row.is-on { background: color-mix(in srgb, var(--accent) 22%, transparent); }
.row .row-idx { font: 11px/1 var(--mono); color: var(--faint); }
.row .row-name { font-weight: 700; font-size: 14px; }
.row .row-meta { font: 10px/1.4 var(--mono); color: var(--faint); }

/* 方形勾选 */
.check {
  appearance: none;
  width: 20px;
  height: 20px;
  border: 2px solid var(--line);
  background: var(--surface);
  display: inline-grid;
  place-items: center;
  cursor: pointer;
  flex: 0 0 auto;
  margin: 0;
}
.check:checked { background: var(--accent); }
.check:checked::after {
  content: "";
  width: 10px;
  height: 6px;
  border-left: 2px solid var(--accent-ink);
  border-bottom: 2px solid var(--accent-ink);
  transform: rotate(-45deg) translateY(-1px);
}

/* ---------- 表单 ---------- */

.field { display: flex; flex-direction: column; gap: 7px; }
.field > label, .label {
  font: 10px/1 var(--mono);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
}
.input, .textarea, .select {
  width: 100%;
  min-height: 48px;
  padding: 10px 12px;
  border: 2px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  outline: none;
}
.textarea { min-height: 132px; resize: vertical; line-height: 1.6; }
.input:focus, .textarea:focus, .select:focus { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent) inset; }
.input::placeholder, .textarea::placeholder { color: var(--faint); }

/* ---------- 页脚 ---------- */

.footer {
  margin-top: var(--seam);
  padding-top: 14px;
  border-top: 1px solid var(--hair-strong);
  display: flex;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  font: 11px/1.6 var(--mono);
  letter-spacing: 0.06em;
  color: var(--muted);
}

/* ---------- 提示条 ---------- */

.toast {
  position: fixed;
  left: 50%;
  bottom: 22px;
  transform: translate(-50%, 12px);
  opacity: 0;
  pointer-events: none;
  z-index: 90;
  min-height: 44px;
  display: flex;
  align-items: center;
  padding: 0 16px;
  border: 2px solid var(--line);
  background: var(--surface);
  font-size: 13px;
  font-weight: 700;
  transition: opacity var(--speed), transform var(--speed);
  max-width: min(90vw, 560px);
}
.toast.is-show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- 装饰 ---------- */

.hr { height: 1px; background: var(--hair); border: 0; margin: 14px 0; }
.hr-strong { height: 2px; background: var(--line); border: 0; margin: 16px 0; }
.sq { width: 7px; height: 7px; background: var(--accent); display: inline-block; }

/* ---------- 动效 ---------- */

.blk { opacity: 0; transform: translateY(10px); transition: opacity var(--speed-slow) var(--ease), transform var(--speed-slow) var(--ease); }
.blk.is-in { opacity: 1; transform: none; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
  .blk { opacity: 1; transform: none; }
}

/* ---------- 响应式：12 列 → 6 列 ---------- */

@media (max-width: 1279px) {
  .mosaic { grid-template-columns: repeat(6, 1fr); grid-auto-rows: minmax(56px, auto); gap: 12px; }
  :root { --pad: 20px; }
}

@media (max-width: 900px) {
  .grid3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 700px) {
  :root { --row: 50px; --seam: 10px; --pad: 16px; }
  body { padding: 14px; font-size: 14px; }
  .topbar { gap: 10px; }
  .brand-text span { display: none; }
  .brand-text b { white-space: nowrap; font-size: 14px; }
  .status { display: none; }
  .icon-btn { margin-left: auto; }
  .nav {
    order: 3;
    width: 100%;
    margin-left: 0;
    border-top: 1px solid var(--hair);
    padding-top: 4px;
    flex-wrap: nowrap;
    overflow-x: auto;
    scrollbar-width: none;
  }
  .nav::-webkit-scrollbar { display: none; }
  .nav a { flex: 0 0 auto; padding: 0 10px; font-size: 12px; }
  .grid2, .grid3 { grid-template-columns: 1fr; }
  .mark { width: 84px; font-size: 32px; }
  .bar-cell { padding: 0 14px; font-size: 13px; }
}
