:root {
  --ink: #111;
  --muted: rgba(17, 17, 17, 0.62);
  --line: rgba(17, 17, 17, 0.24);
  --paper: rgba(255, 255, 255, 0.92);
  --orange: #e07b14;
  --gold: #ede3a3;
  --shadow: 0 16px 40px rgba(17, 17, 17, 0.05);
  --font: "Patrick Hand", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", cursive, sans-serif;
  --radius: 12px;
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

body {
  margin: 0;
  min-height: 100dvh;
  color: var(--ink);
  font-family: var(--font);
  font-size: 20px;
  background: #fcfcfa;
}

body.style-sketch {
  background-image: radial-gradient(circle at 1px 1px, rgba(17, 17, 17, 0.05) 1px, transparent 0);
  background-size: 18px 18px;
}

body.style-classic {
  --font: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  --ink: #172033;
  --muted: rgba(32, 41, 57, 0.62);
  --line: rgba(32, 41, 57, 0.14);
  color: #172033;
  font-size: 16px;
  background: #f4f6f8;
  background-image: none;
}

button, select, input { font-family: inherit; color: inherit; }

.app {
  width: min(1440px, 100%);
  margin: 0 auto;
  min-height: 100dvh;
  padding: 1.1rem 1rem 1.4rem;
  display: flex;
  flex-direction: column;
  gap: 0.8rem;
}

.app__header {
  border-bottom: 2px dashed rgba(17, 17, 17, 0.22);
  padding-bottom: 0.35rem;
}

body.style-classic .app__header {
  border-bottom: 1px solid rgba(32, 41, 57, 0.12);
}

.header-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  grid-template-areas: "left right";
  gap: 0.7rem 1rem;
  align-items: center;
}

.header-left { grid-area: left; display: flex; flex-direction: column; align-items: flex-start; gap: 0.55rem; }
.header-right { grid-area: right; display: flex; gap: 0.5rem; align-items: center; justify-content: flex-end; }

.lang-switch {
  display: inline-flex;
  align-items: center;
  gap: 0.15rem;
  padding: 0.18rem;
  border-radius: 999px;
  border: 1px solid rgba(32, 41, 57, 0.14);
  background: #fff;
}

.lang-switch__btn {
  border: 0;
  background: transparent;
  border-radius: 999px;
  padding: 0.38rem 0.72rem;
  cursor: pointer;
  font-size: 0.85rem;
  color: inherit;
}

.lang-switch__btn.is-on {
  background: #e5e7eb;
  color: #111827;
}

.header-tool-buttons, .header-right, .export-wrap { display: flex; gap: 0.5rem; position: relative; }

.header-tool-btn, .block-btn, .choice, .pop-menu button, .shape-card, .drawer__head button, .modal__head button {
  cursor: pointer;
}

.header-tool-btn {
  position: relative;
  width: 3.5rem;
  height: 3.5rem;
  border-radius: 12px;
  border: 1px dashed var(--line);
  background: var(--paper);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transform: rotate(-0.8deg);
}

.header-tool-btn svg { width: 1.85rem; height: 1.6rem; }

.header-tool-btn::after {
  content: "";
  position: absolute;
  inset: 3px;
  border: 1px solid rgba(17, 17, 17, 0.12);
  border-radius: 9px;
  transform: rotate(-1.4deg);
  pointer-events: none;
}

.header-tool-btn:hover, .block-btn:hover { background: #fff; }
.header-tool-btn.is-on { background: var(--gold); border-style: solid; transform: none; }

body.style-classic .header-tool-btn,
body.style-classic .instrument-switch,
body.style-classic .block-btn,
body.style-classic .control-bar,
body.style-classic .choice,
body.style-classic .pop-menu,
body.style-classic .modal__panel,
body.style-classic .drawer,
body.style-classic select,
body.style-classic input {
  border-style: solid;
  border-color: rgba(32, 41, 57, 0.14);
  transform: none;
  background: #fff;
  box-shadow: none;
}

body.style-classic .header-tool-btn {
  width: 2.9rem;
  height: 2.9rem;
  border-radius: 10px;
  box-shadow: 0 8px 20px rgba(15, 23, 42, 0.06);
}

body.style-classic .header-tool-btn::after,
body.style-classic .instrument-switch::after { display: none; }

body.style-classic .header-tool-btn.is-on,
body.style-classic .block-btn.is-on,
body.style-classic .choice.is-on {
  background: #e5e7eb;
  border-color: rgba(32, 41, 57, 0.24);
  color: #111827;
}

body.style-classic .instrument-switch {
  padding: 0.28rem 0.4rem;
  border-radius: 12px;
  box-shadow: 0 8px 20px rgba(15, 23, 42, 0.05);
}

body.style-classic .instrument-switch label,
body.style-classic .control-bar label {
  font-size: 0.78rem;
  color: #555;
}

body.style-classic .board-panel {
  width: min(1400px, 100%);
  min-height: 62vh;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  background: #fff;
  border: 1px solid rgba(32, 41, 57, 0.12);
  border-radius: 16px;
  box-shadow: 0 22px 54px rgba(15, 23, 42, 0.08);
  padding: 1.6rem 1.2rem 0.85rem;
}

body.style-classic .board-stack {
  flex: 1;
  justify-content: center;
}

body.style-classic .string-line {
  stroke: rgba(32, 41, 57, 0.72);
  stroke-width: 1.45;
}

body.style-classic .fret-line {
  stroke: rgba(32, 41, 57, 0.32);
  stroke-width: 1.25;
}

body.style-classic .nut-line {
  stroke: #172033;
  stroke-width: 3;
}

body.style-classic .fret-num,
body.style-classic .string-name {
  fill: rgba(32, 41, 57, 0.62);
  font-size: 13px;
  font-family: Inter, ui-sans-serif, system-ui, sans-serif;
}

body.style-classic .inlay {
  fill: none;
  stroke: rgba(32, 41, 57, 0.28);
  stroke-width: 1.2;
}

body.style-classic .control-bar {
  align-self: flex-start;
  margin-top: 0.4rem;
  justify-content: flex-start;
  border-radius: 14px;
  padding: 0.45rem 0.65rem;
  gap: 0.35rem 0.5rem;
  background: #fff;
}

body.style-classic .control-bar input[type="number"] {
  width: 64px;
  min-width: 64px;
  border-radius: 8px;
  padding: 0.28rem 0.4rem;
}

body.style-classic .control-bar select {
  border-radius: 8px;
  padding: 0.28rem 0.5rem;
  font-size: 0.92rem;
}

body.style-classic .block-btn,
body.style-classic .choice {
  border-radius: 10px;
  padding: 0.32rem 0.72rem;
  font-size: 0.92rem;
  box-shadow: none;
}

body.style-classic .status-line {
  font-size: 0.85rem;
}

body.style-classic .modal__panel,
body.style-classic .drawer {
  background: #fff;
  border-radius: 16px;
  box-shadow: 0 18px 44px rgba(15, 23, 42, 0.08);
}

.instrument-switch {
  position: relative;
  display: inline-flex;
  flex-direction: column;
  gap: 0.28rem;
  padding: 0.34rem 0.5rem;
  border-radius: 12px;
  border: 1px dashed var(--line);
  background: var(--paper);
  transform: rotate(0.35deg);
}

.instrument-switch::after {
  content: "";
  position: absolute;
  inset: 3px;
  border-radius: 9px;
  border: 1px solid rgba(17, 17, 17, 0.1);
  transform: rotate(-0.7deg);
  pointer-events: none;
}

.instrument-switch__row { display: flex; align-items: center; gap: 0.4rem; position: relative; z-index: 1; }
.instrument-switch label { font-size: 0.95rem; color: var(--muted); }

select, input[type="number"] {
  appearance: none;
  border: 1px dashed var(--line);
  background: #fff;
  border-radius: 8px;
  padding: 0.12rem 0.45rem;
  font-size: 0.95rem;
}

input[type="number"] { width: 3.3rem; text-align: center; }

.app__body { display: flex; flex-direction: column; align-items: center; gap: 0.7rem; }

.board-panel {
  width: min(1360px, 100%);
  background: #fff;
  border-radius: 22px;
  box-shadow: var(--shadow);
  border: 1px solid rgba(17, 17, 17, 0.06);
  padding: 0.8rem 0.7rem 0.7rem;
}

.board-stack { display: flex; flex-direction: column; gap: 0.8rem; }

.board-svg { width: 100%; height: auto; display: block; touch-action: none; }
.board-svg.is-active { outline: none; }

.open-area { fill: #fafafa; }
.fret-wood { fill: #fff; }
.string-line { fill: none; stroke: #2a2a2a; stroke-linecap: round; }
.fret-line { stroke: rgba(17, 17, 17, 0.55); stroke-width: 1.4; }
.nut-line { stroke: #111; stroke-width: 7; stroke-linecap: butt; }
.fret-num, .string-name { fill: rgba(17, 17, 17, 0.72); font-size: 20px; }
.inlay { fill: #d9d9d9; stroke: #bfbfbf; }
.hit { fill: transparent; cursor: pointer; }
.note-dot { fill: #fff; stroke: #111; stroke-width: 1.6; }
.note-dot--root { fill: #111; stroke: #111; }
.note-text { font-size: 16px; fill: #111; pointer-events: none; }
.note-text--root { fill: #fff; }
.note-text--pair { font-size: 11px; }
.arrow-line { stroke: #c4522a; stroke-width: 2.2; fill: none; }

.control-bar {
  margin-top: 0.35rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem 0.7rem;
  align-items: end;
  justify-content: center;
  padding: 0.45rem 0.55rem 0.35rem;
  border: 1px dashed var(--line);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.88);
}

.control-bar label {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  font-size: 0.95rem;
  color: var(--muted);
}

.tool-row { display: flex; gap: 0.35rem; }

.block-btn, .choice, .pop-menu button {
  border: 1px dashed var(--line);
  background: #fff;
  border-radius: 10px;
  padding: 0.28rem 0.7rem;
  font-size: 0.95rem;
}

.block-btn.is-on, .choice.is-on { background: var(--gold); border-style: solid; }

.status-line { margin: 0; color: var(--muted); font-size: 1rem; min-height: 1.3em; }

.practice-stack {
  width: min(720px, 100%);
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.practice-card {
  background: #fff;
  border: 1px solid rgba(32, 41, 57, 0.12);
  border-radius: 16px;
  box-shadow: 0 18px 44px rgba(15, 23, 42, 0.06);
  padding: 0.6rem 1rem 1.3rem;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.practice-card__title {
  margin: 0.6rem 0 0;
  font-size: 1rem;
  font-weight: 600;
  color: rgba(23, 32, 51, 0.72);
}

.practice-note {
  font-size: 72px;
  margin: 28px 0 8px;
  color: #8a8a8a;
  white-space: nowrap;
  cursor: pointer;
  user-select: none;
  min-width: 3ch;
  text-align: center;
  line-height: 1;
}

.practice-note.is-answer { color: #1a1a1a; }

.practice-note--name {
  margin: 24px 0 28px;
  color: #1a1a1a;
  cursor: default;
}

.practice-hint {
  margin: 0 0 22px;
  font-size: 14px;
  color: #b0b0b0;
}

.practice-controls {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: center;
}

.practice-controls input,
.practice-select {
  padding: 12px;
  font-size: 16px;
  border: 2px solid #1a1a1a;
  border-radius: 8px;
  text-align: center;
  background: #fff;
  color: inherit;
  outline: none;
}

.practice-controls input:focus,
.practice-select:focus,
body.style-classic .practice-controls input,
body.style-classic .practice-select,
body.style-sketch .practice-controls input,
body.style-sketch .practice-select {
  border: 2px solid #1a1a1a;
  outline: none;
}

.practice-controls input { width: 120px; }

.practice-select {
  margin-top: 16px;
  width: min(420px, 92%);
}

.practice-btn {
  padding: 12px 24px;
  font-size: 16px;
  color: #fff;
  border: none;
  border-radius: 8px;
  cursor: pointer;
}

.practice-btn--black { background: #1a1a1a; }
.practice-btn--gray { background: #8a8a8a; }
.practice-btn--black:active { background: #000; }
.practice-btn--gray:active { background: #6e6e6e; }

.backdrop {
  position: fixed;
  inset: 0;
  background: rgba(17, 17, 17, 0.08);
  z-index: 30;
}

.drawer {
  position: fixed;
  z-index: 40;
  top: 0;
  left: 0;
  height: 100dvh;
  width: min(420px, 92vw);
  background: #fffdf8;
  border-right: 1px dashed rgba(17, 17, 17, 0.2);
  box-shadow: 8px 0 30px rgba(17, 17, 17, 0.06);
  display: flex;
  flex-direction: column;
}

.drawer__head, .modal__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.8rem 0.9rem 0.4rem;
}

.drawer__head h2, .modal__head h2 { margin: 0; font-size: 1.45rem; font-weight: 400; }

.drawer__head button, .modal__head button {
  border: 0;
  background: transparent;
  font-size: 1.6rem;
  line-height: 1;
}

.drawer__body { overflow: auto; padding: 0.2rem 0.85rem 1.4rem; }

.family { border-top: 1px dashed rgba(17, 17, 17, 0.16); padding: 0.35rem 0 0.6rem; }
.family summary, .group summary {
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  gap: 0.6rem;
  font-size: 1.15rem;
  list-style: none;
}
.family summary::-webkit-details-marker,
.group summary::-webkit-details-marker { display: none; }
.count { color: var(--muted); font-size: 0.92rem; }
.group { margin: 0.35rem 0 0.2rem 0.2rem; }
.shape-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0.45rem; margin-top: 0.4rem; }

.shape-card {
  text-align: left;
  border: 1px dashed var(--line);
  background: #fff;
  border-radius: 12px;
  padding: 0.35rem 0.4rem 0.45rem;
}

.shape-card.is-on { background: var(--gold); border-style: solid; }
.shape-card strong { display: block; font-weight: 400; font-size: 0.98rem; margin-bottom: 0.2rem; }
.shape-card svg { width: 100%; height: 54px; display: block; }

.modal {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: rgba(17, 17, 17, 0.18);
  display: grid;
  place-items: center;
  padding: 1rem;
}

.modal__panel {
  width: min(460px, 100%);
  background: #fffdf8;
  border-radius: 16px;
  border: 1px dashed rgba(17, 17, 17, 0.2);
  padding: 0.3rem 0.9rem 1rem;
}

.modal__panel h3 { margin: 0.7rem 0 0.2rem; font-weight: 400; font-size: 1.15rem; }
.modal__panel p, .modal__panel li { margin: 0.2rem 0; line-height: 1.45; }
.modal__label { color: var(--muted); margin-bottom: 0.35rem; }
.choice-row { display: flex; gap: 0.45rem; }
.pop-menu {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  z-index: 5;
  background: #fff;
  border: 1px dashed var(--line);
  border-radius: 12px;
  padding: 0.3rem;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  min-width: 7.2rem;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 1.2rem;
  transform: translateX(-50%);
  background: #8d3b2a;
  color: #fff;
  border-radius: 12px;
  padding: 0.7rem 0.9rem;
  max-width: min(420px, 90vw);
  z-index: 70;
  box-shadow: var(--shadow);
}

@media (max-width: 720px) {
  .header-grid { grid-template-columns: 1fr; grid-template-areas: "left" "right"; }
  .header-right { justify-content: flex-start; }
  .shape-grid { grid-template-columns: 1fr; }
}
