:root {
  --fg: #111;
  --muted: #5a5a5a;
  --line: #e8e8e8;
  --line-strong: #d9d9d9;
  --soft: #f7f7f7;
  --soft-2: #fafafa;
  --bg: #ffffff;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--fg);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  font-size: 16px;
  line-height: 1.7;
}

a,
a:visited,
a:hover,
a:active {
  color: var(--fg);
}

button, select, input {
  font: inherit;
}

.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 20px 16px 24px;
}

.hero {
  margin-bottom: 16px;
}

.eyebrow {
  margin: 0 0 8px;
  font-size: 12px;
  letter-spacing: 0.14em;
  color: var(--muted);
}

h1 {
  margin: 0;
  font-size: 36px;
  line-height: 1.15;
  letter-spacing: -0.02em;
}

.manifesto {
  margin: 14px 0 0;
  padding: 12px 14px;
  border-left: 3px solid var(--line-strong);
  background: var(--soft-2);
}

.manifesto-en {
  margin: 0 0 4px;
  font-family: Charter, "Iowan Old Style", "Times New Roman", Georgia, serif;
  font-size: 17px;
  line-height: 1.55;
  color: #1d1d1d;
}

.manifesto-zh {
  margin: 0;
  font-size: 13px;
  line-height: 1.75;
  color: var(--muted);
}

.section-rule {
  border: 0;
  border-top: 1px solid var(--line);
  margin: 20px 0 0;
}

.workspace-grid {
  display: grid;
  grid-template-columns: 380px minmax(0, 1fr);
  gap: 16px;
  align-items: start;
  margin-top: 18px;
}

.panel {
  border: 1px solid var(--line);
  background: #fff;
  min-height: 620px;
}

.controls-panel,
.result-panel,
.chart-panel {
  padding: 16px;
}

.chart-panel {
  min-height: auto;
  margin-top: 18px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

.chart-head-inline {
  margin-bottom: 10px;
}

.chart-panel .chart-preview {
  margin-top: 0;
}

.hidden {
  display: none;
}

.panel-head {
  margin-bottom: 14px;
}

.panel-title {
  margin: 0;
  font-size: 22px;
  line-height: 1.3;
}

.panel-note {
  margin: 6px 0 0;
  font-size: 13px;
  color: var(--muted);
}

.controls-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
}

label span {
  display: block;
  margin-bottom: 6px;
  font-size: 14px;
  color: var(--muted);
}

select,
input[type="text"] {
  width: 100%;
  padding: 10px 11px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--fg);
  border-radius: 0;
  outline: none;
}

select:focus,
input[type="text"]:focus {
  border-color: #cfcfcf;
}

.full-span {
  grid-column: 1 / -1;
}

.actions {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-top: 16px;
}

.btn {
  appearance: none;
  border: 1px solid var(--fg);
  background: #fff;
  color: var(--fg);
  padding: 10px 12px;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.btn:hover {
  background: #f2f2f2;
}

.btn-primary {
  background: #111;
  color: #fff;
}

.btn-primary:hover {
  background: #2b2b2b;
}

.result-empty {
  color: var(--muted);
}

.result-kicker {
  margin: 0 0 6px;
  font-size: 12px;
  letter-spacing: 0.14em;
  color: var(--muted);
}

.result-title {
  margin: 0;
  font-size: 26px;
  line-height: 1.25;
  font-weight: 600;
}

.result-summary {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 15px;
  line-height: 1.65;
}

.routine-block,
.tune-block {
  margin-top: 18px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

h4 {
  margin: 0 0 8px;
  font-size: 16px;
}

ol {
  padding-left: 20px;
  margin: 0;
}

li {
  margin: 10px 0;
}

.step-title {
  font-weight: 600;
}

.step-meta {
  display: block;
  color: var(--muted);
  font-size: 13px;
}

.step-note {
  display: block;
  margin-top: 3px;
  font-size: 14px;
}

.tune-actions {
  margin-top: 8px;
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
}

.metronome-panel {
  margin-top: 18px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

.metronome-embed {
  margin-top: 8px;
  border: 1px solid var(--line);
  background: #fff;
  overflow: hidden;
}

.metronome-embed iframe {
  display: block;
  width: 100%;
  height: 760px;
  border: 0;
}

.link-btn {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--fg);
  padding: 0;
  cursor: pointer;
  text-decoration: underline;
  font-size: 14px;
}

.chart-preview {
  margin-top: 12px;
  border: 1px solid var(--line);
  background: #fff;
}


.embedded-ireal {
  padding: 16px;
  background: #f5f5f5;
}

.embedded-hero {
  background: #fff;
  border: 1px solid #cfcfcf;
  border-radius: 18px;
  padding: 18px 18px 14px;
  margin-bottom: 14px;
}

.embedded-hero h1 {
  margin: 0 0 8px;
  font-size: 2.1rem;
  line-height: 1.08;
  letter-spacing: -0.02em;
}

.embedded-hero .meta {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(112px, 1fr));
  gap: 8px;
  margin-top: 14px;
}

.embedded-hero .meta-item {
  padding: 10px 11px;
  border: 1px solid #cfcfcf;
  border-radius: 10px;
  background: #fff;
}

.embedded-hero .meta-label {
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #555;
  margin-bottom: 4px;
}

.embedded-hero .meta-value {
  font-size: 0.95rem;
  font-weight: 600;
}

.embedded-chart {
  background: #fff;
  border: 1px solid #cfcfcf;
  border-radius: 18px;
  padding: 14px;
}

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

.embedded-chart .measure {
  min-height: 78px;
  border: 1px solid #cfcfcf;
  border-radius: 10px;
  background: #fff;
  padding: 18px 10px 8px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  position: relative;
  overflow: visible;
}

.embedded-chart .block-start { box-shadow: inset 3px 0 0 #111; }
.embedded-chart .repeat-start { border-left: 3px solid #111; }
.embedded-chart .repeat-end { border-right: 3px solid #111; }
.embedded-chart .heavy-left { box-shadow: inset 3px 0 0 #111; }
.embedded-chart .heavy-right { box-shadow: inset -3px 0 0 #111; }
.embedded-chart .repeat-glyph {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  font-size: 0.95rem;
  font-weight: 700;
  color: #111;
  background: #fff;
  padding: 0 2px;
  line-height: 1;
}
.embedded-chart .repeat-glyph.left { left: -11px; }
.embedded-chart .repeat-glyph.right { right: -11px; }
.embedded-chart .ending-bracket {
  position: absolute;
  left: 6px;
  right: 6px;
  top: 4px;
  height: 10px;
  border-top: 2px solid #111;
}
.embedded-chart .ending-bracket.start {
  border-left: 2px solid #111;
  border-top-left-radius: 4px;
}
.embedded-chart .ending-label {
  position: absolute;
  left: 4px;
  top: -11px;
  font-size: 0.62rem;
  color: #111;
  background: #fff;
  padding: 0 3px;
}
.embedded-chart .mhead {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  align-items: flex-start;
  margin-bottom: 4px;
}
.embedded-chart .mnum {
  font-size: 0.68rem;
  color: #555;
  font-variant-numeric: tabular-nums;
}
.embedded-chart .mflags {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
  justify-content: flex-end;
}
.embedded-chart .flag {
  display: inline-block;
  padding: 2px 6px;
  border-radius: 999px;
  font-size: 0.62rem;
  line-height: 1.3;
  border: 1px solid #cfcfcf;
  background: #f3f3f3;
  color: #111;
}
.embedded-chart .mbody {
  font-size: 1rem;
  line-height: 1.3;
  font-weight: 600;
  letter-spacing: 0.01em;
  word-break: break-word;
}
.embedded-chart .chord-main,
.embedded-chart .chord-bass {
  white-space: nowrap;
  color: #111;
}
.embedded-chart .sep { color: #999; font-weight: 400; }
.embedded-chart .rest { color: #777; }
.embedded-chart .repeat-mark {
  color: #111;
  font-size: 1.35rem;
  font-weight: 700;
  letter-spacing: 0.04em;
}

@media (max-width: 980px) {
  .container {
    max-width: 860px;
  }

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

  .panel {
    min-height: auto;
  }

  .desktop-only {
    display: none;
  }

  .embedded-chart .grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}

@media (max-width: 640px) {
  body {
    font-size: 15px;
  }

  .tune-actions {
    gap: 10px;
  }

  .container {
    padding: 14px 12px 28px;
  }

  h1 {
    font-size: 32px;
  }

  .panel-title {
    font-size: 20px;
  }

  .result-title {
    font-size: 23px;
  }

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

  .manifesto {
    padding: 12px 12px;
  }

  .manifesto-en {
    font-size: 16px;
  }

  .manifesto-zh {
    font-size: 13px;
  }

  .embedded-hero h1 {
    font-size: 1.8rem;
  }

  .embedded-hero .meta {
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 4px;
  }

  .embedded-hero .meta-item {
    padding: 6px 5px;
  }

  .embedded-hero .meta-label {
    font-size: 0.5rem;
    letter-spacing: 0.03em;
  }

  .embedded-hero .meta-value {
    font-size: 0.64rem;
    line-height: 1.1;
  }

  .embedded-chart .grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .embedded-chart .measure {
    min-height: 58px;
    padding: 12px 5px 5px;
  }

  .embedded-chart .mbody {
    font-size: 0.72rem;
    line-height: 1.15;
  }

  .embedded-chart .mnum {
    font-size: 0.56rem;
  }

  .embedded-chart .flag {
    font-size: 0.5rem;
    padding: 1px 3px;
  }

  .embedded-chart .repeat-mark {
    font-size: 0.95rem;
  }
}
