:root {
  --ink: #1e2528;
  --muted: #6f7778;
  --paper: #f4f1eb;
  --panel: #fffefa;
  --line: #d9d2c7;
  --accent: #4f6f3e;
  --accent-dark: #314a2d;
  --warn: #9b6a3c;
  --danger: #c75252;
  --shadow: 0 16px 42px rgba(31, 37, 39, 0.1);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--paper);
  color: var(--ink);
  font-family: "Avenir Next", "Helvetica Neue", "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
}

button,
input,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  min-height: 100vh;
  padding: 18px;
}

.topbar {
  display: flex;
  justify-content: space-between;
  gap: 24px;
  align-items: center;
  width: min(1680px, 100%);
  margin: 0 auto 14px;
  padding: 22px 24px;
  border: 1px solid rgba(221, 212, 195, 0.9);
  border-radius: 8px;
  background: linear-gradient(135deg, #fffefa 0%, #f5efe6 100%);
  box-shadow: var(--shadow);
}

.eyebrow,
h1,
h2,
p {
  margin-top: 0;
}

.eyebrow {
  margin-bottom: 6px;
  color: var(--accent-dark);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1 {
  margin-bottom: 8px;
  font-family: "Songti SC", "STSong", "Noto Serif CJK SC", serif;
  font-weight: 800;
  font-size: clamp(1.8rem, 3vw, 3rem);
  line-height: 1.08;
  letter-spacing: 0;
}

.topbar p,
.panel p,
.method-strip span,
.empty-text {
  color: var(--muted);
  line-height: 1.6;
}

.topbar__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: flex-end;
}

.topbar__actions button,
.file-action {
  display: inline-grid;
  place-items: center;
  min-height: 42px;
  border: 0;
  border-radius: 999px;
  padding: 0 16px;
  background: #4f6f3e;
  color: #fff;
  font-weight: 800;
  text-align: center;
  cursor: pointer;
}

.topbar__actions button:first-child {
  background: #e8e1d5;
  color: #283530;
}

.topbar__actions .danger-action {
  background: #8f342f;
}

.topbar__actions .utility-action {
  display: none;
}

.hidden-file {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.method-strip {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  width: min(1680px, 100%);
  margin: 0 auto 14px;
}

.method-strip article {
  min-height: 82px;
  padding: 14px;
  border: 1px solid rgba(221, 212, 195, 0.9);
  border-radius: 8px;
  background: rgba(255, 253, 248, 0.88);
}

.method-strip strong,
.method-strip span {
  display: block;
}

.method-strip strong {
  margin-bottom: 4px;
}

.view-tabs {
  display: flex;
  gap: 8px;
  width: min(1680px, 100%);
  margin: 0 auto 14px;
}

.view-tabs button {
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0 16px;
  background: #fffefb;
  color: #2f3a35;
  font-weight: 900;
}

.view-tabs button.is-active {
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
}

.app-view.is-hidden {
  display: none;
}

.workspace {
  display: grid;
  grid-template-columns: 300px minmax(620px, 1fr) 360px;
  gap: 14px;
  width: min(1680px, 100%);
  margin: 0 auto;
  align-items: start;
}

.side-panel {
  display: grid;
  gap: 14px;
}

.right-panel {
  align-content: start;
}

.panel,
.score-workbench {
  border: 1px solid rgba(221, 212, 195, 0.95);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.panel {
  padding: 16px;
}

.panel__header {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.panel__header.compact {
  margin-bottom: 10px;
}

.panel h2 {
  margin-bottom: 4px;
  font-size: 1.05rem;
}

.panel p {
  margin-bottom: 0;
  font-size: 0.9rem;
}

.form-grid {
  display: grid;
  gap: 12px;
}

label {
  display: block;
  color: #35413c;
  font-size: 0.9rem;
  font-weight: 800;
}

input,
textarea {
  width: 100%;
  margin-top: 7px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fffefb;
  color: var(--ink);
  outline: none;
}

input {
  min-height: 42px;
  padding: 0 12px;
}

textarea {
  resize: vertical;
  padding: 10px 12px;
  line-height: 1.65;
}

input:focus,
textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(31, 122, 103, 0.12);
}

.drop-zone {
  display: grid;
  place-items: center;
  gap: 6px;
  min-height: 124px;
  border: 1.5px dashed #b9ac99;
  border-radius: 8px;
  background: #fbf8f0;
  text-align: center;
}

.drop-zone.is-dragging {
  border-color: #4f6f3e;
  background: #edf5ea;
  box-shadow: inset 0 0 0 3px rgba(79, 111, 62, 0.12);
}

.drop-zone input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
}

.drop-zone span {
  font-weight: 900;
}

.drop-zone small {
  color: var(--muted);
}

.page-controls {
  display: grid;
  grid-template-columns: 42px 1fr 42px;
  gap: 8px;
  align-items: center;
  margin-top: 12px;
}

.page-controls button {
  height: 38px;
  border: 0;
  border-radius: 8px;
  background: #17201d;
  color: #fffaf2;
  font-size: 1.4rem;
  line-height: 1;
}

.page-controls span {
  text-align: center;
  color: #34413c;
  font-weight: 900;
}

.unlock-list {
  display: grid;
  gap: 9px;
}

.unlock-item {
  display: grid;
  grid-template-columns: 18px 1fr;
  gap: 10px;
  align-items: center;
  min-height: 32px;
  font-weight: 700;
}

.unlock-item input {
  width: 18px;
  min-height: 18px;
  margin: 0;
  accent-color: var(--accent);
}

.unlock-item span {
  position: relative;
  padding-left: 10px;
}

.unlock-item span::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0.3em;
  width: 4px;
  height: 1em;
  border-radius: 8px;
  background: var(--pattern-color);
}

.score-workbench {
  overflow: hidden;
}

.score-template-dock {
  border-top: 1px solid rgba(221, 212, 195, 0.95);
  padding: 14px;
  background: #fffaf0;
}

.score-template-dock .panel__header {
  margin-bottom: 10px;
}

.score-template-dock .template-list {
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}

.toolbar {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  padding: 12px;
  border-bottom: 1px solid rgba(221, 212, 195, 0.95);
  background: #fffaf0;
}

.tool-group {
  display: flex;
  gap: 8px;
}

.tool-button {
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0 12px;
  background: #fffdf8;
  color: #26332e;
  font-weight: 900;
}

.tool-button.is-active {
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
}

.tool-hint {
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.5;
  text-align: right;
}

.recent-patterns {
  display: flex;
  gap: 10px;
  align-items: center;
  border-bottom: 1px solid rgba(221, 212, 195, 0.95);
  padding: 10px 12px;
  background: #fffdf8;
}

.recent-patterns__label {
  flex: 0 0 auto;
  color: #6b5f55;
  font-size: 0.82rem;
  font-weight: 900;
}

.recent-patterns__empty {
  color: var(--muted);
  font-size: 0.84rem;
}

.recent-patterns__list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.recent-patterns button {
  display: inline-flex;
  gap: 6px;
  align-items: center;
  min-height: 32px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0 10px;
  background: #fffaf0;
  color: #27342f;
  font-size: 0.82rem;
  font-weight: 900;
}

.recent-patterns button.is-selected {
  border-color: #17201d;
  background: #17201d;
  color: #fffaf2;
}

.recent-patterns small {
  min-width: 18px;
  border-radius: 999px;
  padding: 1px 5px;
  background: rgba(23, 32, 29, 0.08);
  color: inherit;
  font-size: 0.72rem;
  text-align: center;
}

.pattern-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--pattern-color);
}

.detail-tags {
  display: flex;
  gap: 10px;
  align-items: center;
  border-bottom: 1px solid rgba(221, 212, 195, 0.95);
  padding: 10px 12px;
  background: #fbf6ed;
}

.detail-tags__label {
  flex: 0 0 auto;
  color: #6b5f55;
  font-size: 0.82rem;
  font-weight: 900;
}

.detail-tags__list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.detail-tags button {
  min-height: 32px;
  border: 1px solid rgba(23, 32, 29, 0.16);
  border-radius: 999px;
  padding: 0 12px;
  background: color-mix(in srgb, var(--detail-color) 12%, #fffdf8);
  color: #27342f;
  font-size: 0.82rem;
  font-weight: 900;
}

.detail-tags button.is-selected {
  border-color: var(--detail-color);
  background: var(--detail-color);
  color: var(--detail-text);
}

.score-stage {
  position: relative;
  display: grid;
  place-items: start center;
  min-height: 720px;
  overflow: auto;
  padding: 14px;
  background:
    linear-gradient(90deg, rgba(79, 111, 62, 0.055) 1px, transparent 1px),
    linear-gradient(0deg, rgba(79, 111, 62, 0.055) 1px, transparent 1px),
    #ebe6dc;
  background-size: 28px 28px;
}

#pdfCanvas {
  display: block;
  background: #fff;
  box-shadow: 0 12px 32px rgba(25, 28, 24, 0.16);
}

.annotation-layer {
  position: absolute;
  top: 14px;
  left: 50%;
  transform: translateX(-50%);
  overflow: visible;
}

.empty-score {
  position: absolute;
  inset: 14px;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 8px;
  border: 1.5px dashed #b7ab98;
  border-radius: 8px;
  background: #f8f4eb;
  color: #38433e;
  text-align: center;
  z-index: 2;
}

.empty-score.is-hidden {
  display: none;
}

.annotation {
  position: absolute;
  transform: translate(-8px, -50%);
  border: 0;
  user-select: none;
  touch-action: none;
}

.pattern-label {
  min-width: 88px;
  min-height: 34px;
  border: 2px solid rgba(255, 255, 255, 0.72);
  border-radius: 999px;
  padding: 6px 12px 6px 15px;
  background: var(--pattern-color);
  color: #fff;
  box-shadow: 0 7px 14px rgba(18, 22, 20, 0.16);
  font-family: "Avenir Next", "PingFang SC", sans-serif;
  font-size: 0.9rem;
  font-weight: 800;
  white-space: nowrap;
  transform: translate(-8px, -50%) scale(var(--label-scale, 1));
  transform-origin: left center;
}

.pattern-label::before {
  content: "";
  display: inline-block;
  width: 6px;
  height: 6px;
  margin-right: 7px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.82);
  vertical-align: 0.08em;
}

.pattern-label.is-selected {
  outline: 3px solid rgba(23, 32, 29, 0.24);
  outline-offset: 2px;
}

.detail-label.is-selected {
  outline: 3px solid rgba(23, 32, 29, 0.24);
  outline-offset: 2px;
}

.detail-label {
  min-width: 92px;
  min-height: 32px;
  border: 2px solid rgba(255, 255, 255, 0.74);
  border-radius: 999px;
  padding: 6px 12px;
  background: var(--detail-color);
  color: var(--detail-text);
  box-shadow: 0 7px 14px rgba(18, 22, 20, 0.14);
  font-family: "Avenir Next", "PingFang SC", sans-serif;
  font-size: 0.86rem;
  font-weight: 900;
  white-space: nowrap;
  transform: translate(-8px, -50%) scale(var(--label-scale, 1));
  transform-origin: left center;
}

.annotation-scale-popover {
  position: absolute;
  z-index: 4;
  display: grid;
  grid-template-columns: 28px 46px 28px;
  gap: 4px;
  align-items: center;
  transform: translateX(-8px);
  border: 1px solid rgba(217, 210, 199, 0.95);
  border-radius: 999px;
  padding: 4px;
  background: rgba(255, 253, 248, 0.96);
  box-shadow: 0 8px 18px rgba(18, 22, 20, 0.16);
}

.annotation-scale-popover button {
  width: 28px;
  height: 28px;
  border: 0;
  border-radius: 50%;
  background: #17201d;
  color: #fffaf2;
  font-weight: 900;
  line-height: 1;
}

.annotation-scale-popover span {
  color: #27342f;
  font-size: 0.78rem;
  font-weight: 900;
  text-align: center;
}

.teacher-note {
  max-width: 220px;
  min-height: 34px;
  border: 1px solid #3b352b;
  border-radius: 8px;
  padding: 7px 10px;
  background: rgba(255, 253, 239, 0.96);
  color: #1f2a26;
  box-shadow: 0 5px 12px rgba(18, 22, 20, 0.13);
  font-weight: 800;
  line-height: 1.35;
  text-align: left;
}

.circle-annotation {
  transform: none;
  border: 4px solid var(--danger);
  border-radius: 50%;
  background: transparent;
  box-shadow: none;
}

.pattern-grid {
  display: grid;
  gap: 10px;
}

.pattern-filter {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin-bottom: 12px;
}

.pattern-filter button {
  min-height: 32px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0 10px;
  background: #fffefb;
  color: #2f3a35;
  font-size: 0.84rem;
  font-weight: 800;
}

.pattern-filter button.is-selected {
  border-color: var(--accent);
  background: #edf2e9;
  color: var(--accent-dark);
}

.pattern-filter span {
  margin-left: 5px;
  color: #8a6a48;
  font-weight: 900;
}

.pattern-detail {
  display: grid;
  gap: 9px;
  margin-bottom: 12px;
  border: 1px solid rgba(217, 210, 199, 0.95);
  border-radius: 8px;
  padding: 12px;
  background: #fbf7ef;
}

.pattern-detail__top {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: center;
}

.pattern-detail > strong {
  font-size: 1rem;
}

.pattern-detail__meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.pattern-detail__meta span {
  border-radius: 999px;
  padding: 4px 8px;
  background: #eee6d9;
  color: #5b5047;
  font-size: 0.76rem;
  font-weight: 900;
}

.pattern-detail p {
  margin-bottom: 0;
  color: #505a56;
  font-size: 0.9rem;
  line-height: 1.6;
}

.pattern-media {
  display: grid;
  grid-template-columns: 94px 1fr;
  gap: 10px;
  align-items: stretch;
}

.pattern-media img,
.media-placeholder {
  width: 100%;
  aspect-ratio: 4 / 3;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f1eadf;
}

.pattern-media img {
  object-fit: contain;
}

.media-placeholder {
  display: grid;
  place-items: center;
  align-content: center;
  gap: 2px;
  color: #6b5f55;
}

.media-placeholder span {
  font-weight: 900;
}

.media-placeholder small {
  color: #8a8177;
  font-size: 0.76rem;
  line-height: 1.35;
}

.pattern-media__actions {
  display: grid;
  gap: 7px;
  align-content: center;
}

.image-preview-button {
  min-height: 34px;
  border: 0;
  border-radius: 999px;
  background: #4f6f3e;
  color: #fff;
  font-size: 0.84rem;
  font-weight: 900;
}

.image-bind-status {
  color: #8a8177;
  font-size: 0.84rem;
  font-weight: 900;
}

.pattern-detail dl {
  display: grid;
  gap: 7px;
  margin: 0;
}

.pattern-detail dl div {
  display: grid;
  grid-template-columns: 42px 1fr;
  gap: 8px;
}

.pattern-detail dt {
  color: var(--accent-dark);
  font-weight: 900;
}

.pattern-detail dd {
  margin: 0;
  color: var(--muted);
  font-size: 0.86rem;
  line-height: 1.55;
}

.pattern-card {
  display: grid;
  gap: 6px;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  background: #fffdf8;
  color: var(--ink);
  text-align: left;
}

.pattern-card__top {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  align-items: center;
}

.pattern-card.is-selected {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(49, 95, 102, 0.14);
}

.pattern-card.is-locked {
  background: #f3eee5;
  color: #77716a;
}

.pattern-card.is-locked .pattern-chip {
  filter: grayscale(0.75);
  opacity: 0.52;
}

.pattern-card.is-locked em,
.pattern-card.is-locked small {
  color: #8d857d;
}

.pattern-chip {
  justify-self: start;
  border-radius: 999px;
  padding: 5px 10px;
  background: var(--pattern-color);
  color: #fff;
  font-size: 0.85rem;
  font-weight: 800;
}

.level-badge,
.lock-note {
  border-radius: 999px;
  padding: 4px 8px;
  background: #eee6d9;
  color: #5b5047;
  font-size: 0.76rem;
  font-weight: 900;
}

.lock-note {
  justify-self: start;
  background: #e5ded3;
  color: #7a5544;
}

.pattern-card strong {
  font-size: 0.96rem;
}

.pattern-card small {
  color: var(--accent-dark);
  font-weight: 900;
}

.pattern-card em {
  color: var(--muted);
  font-size: 0.86rem;
  font-style: normal;
  line-height: 1.5;
}

.voicing-tools {
  display: grid;
  gap: 10px;
  margin-bottom: 12px;
}

.voicing-tools input {
  margin-top: 0;
}

.voicing-filter {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  max-height: 112px;
  overflow: auto;
  padding-right: 2px;
}

.voicing-filter button {
  min-height: 30px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0 9px;
  background: #fffefb;
  color: #2f3a35;
  font-size: 0.78rem;
  font-weight: 800;
}

.voicing-filter button.is-selected {
  border-color: #8a6a48;
  background: #f0e6d7;
  color: #523f2b;
}

.voicing-filter span {
  margin-left: 4px;
  color: #8a6a48;
  font-weight: 900;
}

.voicing-summary {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.voicing-summary span {
  border-radius: 999px;
  padding: 4px 8px;
  background: #eee6d9;
  color: #5b5047;
  font-size: 0.76rem;
  font-weight: 900;
}

.voicing-grid {
  display: grid;
  gap: 9px;
  max-height: 760px;
  overflow: auto;
  padding-right: 2px;
}

.voicing-card {
  display: grid;
  gap: 7px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  background: #fffdf8;
}

.voicing-card.is-high {
  border-color: rgba(79, 111, 62, 0.65);
  background: #f4f8ef;
}

.voicing-card.is-low {
  border-color: rgba(154, 86, 56, 0.65);
  background: #fbf3ed;
}

.voicing-card.is-song-used {
  border-color: rgba(49, 74, 45, 0.72);
  box-shadow: 0 0 0 3px rgba(79, 111, 62, 0.1);
}

.voicing-card strong {
  color: #1f2a26;
  font-size: 0.95rem;
  line-height: 1.35;
}

.voicing-card small {
  color: var(--muted);
  font-weight: 800;
}

.voicing-card__actions {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 6px;
}

.voicing-card__actions button {
  min-height: 30px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fffefb;
  color: #27342f;
  font-size: 0.78rem;
  font-weight: 900;
}

.voicing-card__actions button.is-active {
  border-color: #4f6f3e;
  background: #4f6f3e;
  color: #fff;
}

.comment-bank {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.comment-bank button {
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0 12px;
  background: #fffefb;
  color: #27342f;
  font-size: 0.86rem;
  font-weight: 800;
}

.comment-bank button.is-selected {
  border-color: var(--accent);
  background: #e5f0eb;
  color: var(--accent-dark);
}

.teacher-text {
  margin-top: 12px;
}

.template-list {
  display: grid;
  gap: 10px;
}

.template-card {
  display: grid;
  grid-template-columns: 86px 1fr;
  gap: 10px;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 9px;
  background: #fffdf8;
  color: var(--ink);
  text-align: left;
}

.template-card:hover {
  border-color: #8a6a48;
  box-shadow: 0 0 0 3px rgba(138, 106, 72, 0.1);
}

.template-card img,
.template-thumb {
  width: 100%;
  aspect-ratio: 4 / 3;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f1eadf;
}

.template-card img {
  object-fit: cover;
}

.template-thumb {
  display: grid;
  place-items: center;
  align-content: center;
  gap: 2px;
  color: #6b5f55;
}

.template-thumb span {
  font-weight: 900;
}

.template-thumb small {
  color: #8a8177;
  font-size: 0.76rem;
}

.template-card__body {
  display: grid;
  gap: 4px;
  align-content: center;
}

.template-card__body strong {
  font-size: 0.92rem;
}

.template-card__body small {
  color: var(--accent-dark);
  font-weight: 900;
}

.template-card__body em {
  color: var(--muted);
  font-size: 0.82rem;
  font-style: normal;
  line-height: 1.45;
}

.template-list button {
  width: 100%;
}

.training-center {
  width: min(1680px, 100%);
  margin: 0 auto;
}

.training-hero {
  margin-bottom: 14px;
  border: 1px solid rgba(221, 212, 195, 0.95);
  border-radius: 8px;
  padding: 18px;
  background: linear-gradient(135deg, #fffefa 0%, #f3eadf 100%);
  box-shadow: var(--shadow);
}

.training-hero h2 {
  margin: 0 0 6px;
  font-size: 1.45rem;
}

.training-hero p:last-child {
  margin: 0;
  color: var(--muted);
  line-height: 1.6;
}

.training-grid {
  display: grid;
  grid-template-columns: minmax(360px, 0.72fr) minmax(620px, 1.28fr);
  gap: 14px;
  align-items: start;
}

.voicing-panel,
.ear-training-panel {
  min-width: 0;
}

.ear-training-panel {
  border: 1px solid rgba(221, 212, 195, 0.95);
  border-radius: 8px;
  padding: 18px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.ear-training-panel .panel__header {
  align-items: flex-start;
}

.ear-training-panel h2 {
  margin: 0 0 4px;
  font-size: 1.35rem;
}

.ear-summary {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.ear-summary span {
  border-radius: 999px;
  padding: 7px 10px;
  background: #eee6d9;
  color: #5b5047;
  font-size: 0.82rem;
  font-weight: 900;
}

.ear-summary button {
  min-height: 34px;
  border: 0;
  border-radius: 999px;
  padding: 0 12px;
  background: #4f6f3e;
  color: #fff;
  font-size: 0.82rem;
  font-weight: 900;
}

.ear-layout {
  display: grid;
  grid-template-columns: minmax(250px, 0.62fr) minmax(420px, 1.38fr);
  gap: 14px;
  align-items: start;
}

.ear-level-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 9px;
}

.ear-level-card {
  display: grid;
  gap: 6px;
  min-height: 118px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  background: #fffdf8;
  color: var(--ink);
  text-align: left;
}

.ear-level-card.is-selected {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(79, 111, 62, 0.14);
}

.ear-level-card.is-completed {
  background: #f4f8ef;
}

.ear-level-card strong {
  font-size: 0.94rem;
  line-height: 1.35;
}

.ear-level-card small {
  color: var(--accent-dark);
  font-weight: 900;
}

.ear-level-card em {
  color: var(--muted);
  font-size: 0.82rem;
  font-style: normal;
  line-height: 1.45;
}

.ear-detail {
  display: grid;
  gap: 12px;
  border: 1px solid rgba(217, 210, 199, 0.95);
  border-radius: 8px;
  padding: 14px;
  background: #fbf7ef;
}

.ear-detail__head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
}

.ear-detail__head h3 {
  margin: 7px 0 4px;
  font-size: 1.18rem;
  line-height: 1.3;
}

.ear-detail__head p {
  margin: 0;
  color: var(--muted);
  line-height: 1.55;
}

.ear-detail__head > strong {
  flex: 0 0 auto;
  border-radius: 999px;
  padding: 6px 10px;
  background: #e9dfd0;
  color: #6f5741;
  font-size: 0.82rem;
}

.ear-detail__head > strong.is-done {
  background: #dfeada;
  color: var(--accent-dark);
}

.ear-audio-placeholder {
  display: grid;
  gap: 4px;
  min-height: 76px;
  border: 1.5px dashed #b9ac99;
  border-radius: 8px;
  padding: 14px;
  background: #fffdf8;
  color: #38433e;
}

.ear-audio-placeholder span {
  color: var(--muted);
  line-height: 1.5;
}

.ear-detail audio {
  width: 100%;
}

.ear-prompt,
.ear-reveal {
  border-radius: 8px;
  padding: 12px;
  background: #fffdf8;
}

.ear-prompt strong,
.ear-reveal strong {
  display: block;
  margin-bottom: 4px;
}

.ear-prompt p,
.ear-reveal p {
  margin: 0;
  color: #4e5954;
  line-height: 1.65;
}

.ear-answer textarea {
  min-height: 104px;
}

.ear-answer textarea[readonly] {
  background: #f1eadf;
  color: #62594e;
}

.ear-answer small {
  display: block;
  margin-top: 6px;
  color: var(--muted);
  font-size: 0.78rem;
  line-height: 1.45;
}

.ear-answer + .ear-answer textarea {
  min-height: 82px;
}

.ear-actions {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}

.ear-actions button {
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0 10px;
  background: #fffefb;
  color: #27342f;
  font-size: 0.86rem;
  font-weight: 900;
}

.ear-actions button:first-child,
.ear-actions button:last-child {
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
}

.ear-actions button:disabled {
  border-color: #cfc6b8;
  background: #d9d1c4;
  color: #7b7166;
  cursor: not-allowed;
}

.ear-reveal {
  display: none;
}

.ear-reveal.is-visible {
  display: block;
}

.ear-reveal.answer {
  border: 1px solid rgba(154, 86, 56, 0.28);
  background: #fff7ef;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  z-index: 20;
  transform: translateX(-50%) translateY(18px);
  max-width: min(460px, calc(100% - 32px));
  border-radius: 8px;
  padding: 12px 16px;
  background: #17201d;
  color: #fffaf2;
  opacity: 0;
  pointer-events: none;
  transition: opacity 180ms ease, transform 180ms ease;
}

.toast.is-visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.image-modal {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: none;
  place-items: center;
  padding: 24px;
  background: rgba(22, 26, 24, 0.76);
}

.image-modal.is-visible {
  display: grid;
}

.image-modal__panel {
  position: relative;
  display: grid;
  gap: 12px;
  width: min(980px, 100%);
  max-height: calc(100vh - 48px);
  border-radius: 8px;
  padding: 18px;
  background: #fffdf8;
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.28);
}

.image-modal__panel img {
  width: 100%;
  max-height: calc(100vh - 150px);
  object-fit: contain;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.image-modal__panel strong {
  color: #1f2a26;
  font-size: 1rem;
}

.image-modal__close {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 34px;
  height: 34px;
  border: 0;
  border-radius: 50%;
  background: #17201d;
  color: #fffaf2;
  font-size: 1.35rem;
  line-height: 1;
}

.pdf-modal {
  position: fixed;
  inset: 0;
  z-index: 32;
  display: none;
  place-items: center;
  padding: 24px;
  background: rgba(22, 26, 24, 0.76);
}

.pdf-modal.is-visible {
  display: grid;
}

.pdf-modal__panel {
  display: grid;
  grid-template-rows: auto minmax(320px, 1fr);
  width: min(1120px, 100%);
  height: min(860px, calc(100vh - 48px));
  overflow: hidden;
  border-radius: 8px;
  background: #fffdf8;
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.28);
}

.pdf-modal__bar {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  border-bottom: 1px solid var(--line);
  padding: 12px 14px;
}

.pdf-modal__bar > div {
  display: flex;
  gap: 8px;
  align-items: center;
}

.pdf-modal__bar a {
  display: inline-grid;
  place-items: center;
  min-height: 34px;
  border-radius: 999px;
  padding: 0 12px;
  background: var(--accent);
  color: #fff;
  font-size: 0.86rem;
  font-weight: 900;
  text-decoration: none;
}

.pdf-modal__close {
  width: 34px;
  height: 34px;
  border: 0;
  border-radius: 50%;
  background: #17201d;
  color: #fffaf2;
  font-size: 1.35rem;
  line-height: 1;
}

.pdf-modal img {
  width: 100%;
  height: 100%;
  border: 0;
  object-fit: contain;
  background: #ebe6dc;
}

.pdf-modal__empty {
  display: grid;
  place-items: center;
  align-content: center;
  gap: 8px;
  padding: 24px;
  color: #38433e;
  text-align: center;
}

.pdf-modal__empty span {
  color: var(--muted);
}

.is-hidden {
  display: none !important;
}

@media (max-width: 1220px) {
  .workspace {
    grid-template-columns: 280px minmax(520px, 1fr);
  }

  .right-panel {
    grid-column: 1 / -1;
    grid-template-columns: repeat(3, 1fr);
  }

  .training-grid {
    grid-template-columns: 1fr;
  }

  .voicing-grid {
    max-height: 520px;
  }
}

@media (max-width: 920px) {
  .topbar,
  .toolbar {
    align-items: stretch;
    flex-direction: column;
  }

  .topbar__actions,
  .tool-hint {
    justify-content: flex-start;
    text-align: left;
  }

  .recent-patterns {
    align-items: flex-start;
    flex-direction: column;
  }

  .detail-tags {
    align-items: flex-start;
    flex-direction: column;
  }

  .method-strip,
  .workspace,
  .right-panel,
  .training-grid,
  .ear-layout {
    grid-template-columns: 1fr;
  }

  .ear-training-panel .panel__header,
  .ear-detail__head {
    align-items: stretch;
    flex-direction: column;
  }

  .ear-summary {
    justify-content: flex-start;
  }

  .score-stage {
    min-height: 560px;
  }
}

@media (max-width: 560px) {
  .app-shell {
    padding: 10px;
  }

  .topbar,
  .panel,
  .training-hero {
    padding: 14px;
  }

  .view-tabs {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }

  .tool-group {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
  }

  .tool-button {
    padding: 0 8px;
  }

  .ear-training-panel {
    padding: 14px;
  }

  .ear-level-list,
  .ear-actions {
    grid-template-columns: 1fr;
  }

  .voicing-card__actions {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .ear-level-card {
    min-height: auto;
  }
}
