@font-face {
  font-family: "JigmoParts";
  src: url("fonts/Jigmo-parts.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "Jigmo2Parts";
  src: url("fonts/Jigmo2-parts.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "Jigmo3Parts";
  src: url("fonts/Jigmo3-parts.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

:root {
  --paper: #faf9f6;
  --surface: #ffffff;
  --ink: #111111;
  --muted: #76736c;
  --line: #d6d3cb;

  --serif: "JigmoParts", "Jigmo2Parts", "Jigmo3Parts", "Hiragino Mincho ProN", "Yu Mincho", "YuMincho", "Noto Serif JP", Georgia, serif;
  --sans: "Helvetica Neue", "Hiragino Kaku Gothic ProN", "Yu Gothic", system-ui, -apple-system, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}

* {
  box-sizing: border-box;
  border-radius: 0;
}

html, body {
  margin: 0;
  padding: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

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

.hidden {
  display: none !important;
}

/* Layout */
.page {
  width: 100%;
  max-width: 920px;
  margin: 0 auto;
  padding: 56px 32px 80px;
}

/* Header */
.masthead {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  padding-bottom: 16px;
  border-bottom: 2px solid var(--ink);
  margin-bottom: 28px;
}

.masthead-title {
  margin: 0;
  font-family: var(--serif);
  font-size: 28px;
  font-weight: 700;
  letter-spacing: 0.12em;
}

.text-btn {
  appearance: none;
  background: none;
  border: none;
  border-bottom: 1px solid var(--ink);
  padding: 2px 0;
  font-size: 14px;
  cursor: pointer;
  letter-spacing: 0.04em;
  transition: opacity 0.12s ease;
  white-space: nowrap;
}

.text-btn:hover {
  opacity: 0.55;
}

.text-btn:disabled {
  opacity: 0.25;
  cursor: default;
}

/* Input */
.input-section {
  margin-bottom: 18px;
}

.input-bar {
  display: flex;
  align-items: stretch;
  height: 62px;
  border: 2px solid var(--ink);
  background: var(--surface);
}

.kanji-input {
  flex: 1;
  min-width: 0;
  width: 100%;
  border: none;
  background: transparent;
  padding: 0 18px;
  font-family: var(--serif);
  font-size: 28px;
  letter-spacing: 0.1em;
  outline: none;
}

.kanji-input::placeholder {
  font-family: var(--sans);
  font-size: 16px;
  letter-spacing: 0.02em;
  color: var(--muted);
}

.btn-play {
  appearance: none;
  cursor: pointer;
  flex: 0 0 auto;
  border: none;
  border-left: 2px solid var(--ink);
  background: var(--ink);
  color: #ffffff;
  width: 72px;
  font-size: 19px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.12s ease;
}

.btn-play:hover {
  background: #2e2e2e;
}

.btn-play:disabled {
  opacity: 0.3;
  cursor: default;
}

/* Sequence Strip */
.seq-section {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  height: 70px;
  padding-bottom: 16px;
  margin-bottom: 32px;
  border-bottom: 1px solid var(--line);
}

.seq-strip {
  display: flex;
  flex-wrap: nowrap;
  gap: 8px;
  flex: 1;
  min-width: 0;
  height: 52px;
  align-items: center;
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-width: thin;
}

.seq-empty {
  font-size: 14px;
  color: var(--muted);
}

.seq-tile {
  appearance: none;
  cursor: pointer;
  flex: 0 0 auto;
  width: 50px;
  height: 50px;
  padding: 0;
  border: 1px solid var(--line);
  background: var(--surface);
  font-family: var(--serif);
  font-size: 24px;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: border-color 0.1s ease, background 0.1s ease;
}

.seq-tile:hover {
  border-color: var(--ink);
}

.seq-tile.is-active {
  border: 2px solid var(--ink);
}

.seq-tile.is-playing {
  background: var(--ink);
  border-color: var(--ink);
  color: #ffffff;
}

.seq-tile.is-unknown {
  opacity: 0.32;
  cursor: default;
}

.tempo-select {
  flex: 0 0 auto;
  border: 1px solid var(--line);
  background: var(--surface);
  height: 34px;
  padding: 0 10px;
  font-size: 13px;
  color: var(--muted);
  cursor: pointer;
}

.tempo-select:hover {
  border-color: var(--ink);
  color: var(--ink);
}

.tempo-select.is-inactive {
  visibility: hidden;
  pointer-events: none;
}

/* Main Stage */
.stage {
  display: grid;
  grid-template-columns: 300px minmax(0, 1fr);
  gap: 40px;
  align-items: start;
}

.kanji-stage {
  width: 300px;
  height: 300px;
  border: 1px solid var(--line);
  background: var(--surface);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  user-select: none;
  transition: border-color 0.12s ease;
}

.kanji-stage:hover {
  border-color: var(--ink);
}

.kanji-stage.is-empty {
  cursor: default;
}

.kanji-stage.is-empty:hover {
  border-color: var(--line);
}

.kanji-stage svg {
  width: 88%;
  height: 88%;
  display: block;
}

.music-stage {
  display: flex;
  flex-direction: column;
  gap: 10px;
  height: 300px;
  min-width: 0;
}

.notes-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  height: 50px;
  border-bottom: 1px solid var(--line);
  flex-shrink: 0;
}

.notes-line {
  display: flex;
  align-items: baseline;
  gap: 12px;
  min-width: 0;
  overflow-x: auto;
  white-space: nowrap;
  cursor: pointer;
  font-family: var(--sans);
  font-size: 32px;
  font-weight: 700;
  letter-spacing: 0.01em;
  line-height: 1;
  scrollbar-width: none;
}

.notes-line::-webkit-scrollbar {
  display: none;
}

.notes-sep {
  color: var(--line);
  font-weight: 400;
}

.notes-empty {
  color: var(--muted);
  font-weight: 400;
}

/* Parts */
.parts-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 14px;
  align-items: flex-start;
  align-content: flex-start;
  height: 112px;
  padding: 4px 0;
  overflow-y: auto;
  flex-shrink: 0;
  scrollbar-width: thin;
}

.part-item {
  appearance: none;
  background: none;
  border: none;
  border-left: 3px solid var(--ink);
  height: 28px;
  padding: 0 2px 0 7px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  transition: opacity 0.1s ease;
}

.part-item.is-dim {
  opacity: 0.25;
}

.part-svg {
  width: 22px;
  height: 22px;
  display: block;
  flex-shrink: 0;
}

.part-note-jp {
  font-family: var(--serif);
  font-size: 13px;
  font-weight: 700;
  line-height: 1;
}

.part-note-en {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--muted);
  line-height: 1;
}

.bass-dot {
  display: inline-block;
  width: 0;
  height: 0;
  border-left: 4px solid transparent;
  border-right: 4px solid transparent;
  border-top: 6px solid var(--ink);
  margin-left: 1px;
}

/* Piano Keyboard */
.piano-kb {
  position: relative;
  width: 100%;
  height: 118px;
  flex-shrink: 0;
  display: flex;
  border: 1.5px solid var(--ink);
  background: #ffffff;
  user-select: none;
}

.pk-white {
  position: relative;
  flex: 1;
  min-width: 0;
  height: 100%;
  border: none;
  border-right: 1px solid var(--line);
  background: #ffffff;
  cursor: pointer;
  padding: 0 0 9px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  transition: background 0.1s ease;
}

.pk-white:last-of-type {
  border-right: none;
}

.pk-white:hover {
  background: #f3f1eb;
}

.pk-white .pk-jp {
  font-family: var(--serif);
  font-size: 14px;
  font-weight: 700;
  line-height: 1.1;
}

.pk-white .pk-en {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--muted);
  margin-top: 2px;
}

.pk-white.is-lit .pk-jp,
.pk-white.is-lit .pk-en {
  color: #ffffff;
}

.pk-black {
  position: absolute;
  top: 0;
  width: 9.2%;
  height: 58%;
  background: var(--ink);
  border: 1.5px solid var(--ink);
  border-top: none;
  z-index: 3;
  cursor: pointer;
  padding: 0 0 5px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  color: #ffffff;
  transition: background 0.1s ease;
}

.pk-black:hover {
  background: #333333;
}

.pk-black .pk-en {
  font-family: var(--mono);
  font-size: 10px;
  color: #cfcfcf;
}

.pk-black.is-lit .pk-en {
  color: #ffffff;
  font-weight: 700;
}

.pk-bass-tri {
  position: absolute;
  top: 6px;
  left: 50%;
  transform: translateX(-50%);
  width: 0;
  height: 0;
  border-left: 5px solid transparent;
  border-right: 5px solid transparent;
  border-top: 7px solid #ffffff;
}

.pk-key.is-flash {
  filter: brightness(0.84);
}

.pk-key.is-dim {
  opacity: 0.3;
}

/* Footer */
.site-footer {
  margin-top: 56px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
  font-size: 11.5px;
  line-height: 1.7;
  color: var(--muted);
}

.site-footer a {
  color: var(--muted);
  text-decoration: underline;
  text-underline-offset: 2px;
  transition: color 0.12s ease;
}

.site-footer a:hover {
  color: var(--ink);
}

/* Reference Modal */
.modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(17, 17, 17, 0.45);
}

.modal-dialog {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 720px;
  max-height: 88vh;
  background: var(--surface);
  border: 2px solid var(--ink);
  display: flex;
  flex-direction: column;
}

.modal-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  padding: 16px 22px;
  border-bottom: 2px solid var(--ink);
}

.modal-title {
  margin: 0;
  font-family: var(--serif);
  font-size: 19px;
  letter-spacing: 0.08em;
}

.ref-list {
  overflow-y: auto;
  padding: 18px 22px 22px;
}

.ref-table {
  border-top: 2px solid var(--ink);
  border-bottom: 2px solid var(--ink);
}

.ref-row {
  display: grid;
  grid-template-columns: 108px 1fr;
  border-bottom: 1px solid #c5c2b9;
  background: #ffffff;
  color: var(--ink);
  cursor: pointer;
}

.ref-row:last-child {
  border-bottom: none;
}

.ref-row:hover {
  background: #f4f2ec;
}

.ref-row.is-black {
  background: #141414;
  color: #ffffff;
  border-bottom-color: #2c2c2c;
}

.ref-row.is-black:hover {
  background: #222222;
}

.ref-key-cell {
  padding: 10px 14px;
  border-right: 1px solid #d0cec7;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.ref-row.is-black .ref-key-cell {
  border-right-color: #444444;
}

.ref-note-jp {
  font-family: var(--serif);
  font-size: 14px;
  font-weight: 700;
  line-height: 1.25;
}

.ref-note-sub {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--muted);
}

.ref-row.is-black .ref-note-sub {
  color: #bbbbbb;
}

.ref-parts-cell {
  padding: 8px 16px;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
}

.ref-g {
  width: 32px;
  height: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-family: var(--serif);
  font-size: 24px;
  font-weight: 400;
  line-height: 1;
}

.ref-sep {
  width: 1.5px;
  height: 22px;
  background: #888888;
  margin: 0 6px;
  flex-shrink: 0;
}

/* Responsive */
@media (max-width: 760px) {
  .page {
    padding: 24px 16px 48px;
  }

  .masthead {
    padding-bottom: 12px;
    margin-bottom: 20px;
  }

  .masthead-title {
    font-size: 22px;
  }

  .input-bar {
    height: 54px;
  }

  .kanji-input {
    font-size: 22px;
    padding: 0 14px;
  }

  .btn-play {
    width: 58px;
    font-size: 17px;
  }

  .seq-section {
    height: 62px;
    padding-bottom: 12px;
    margin-bottom: 22px;
  }

  .seq-tile {
    width: 44px;
    height: 44px;
    font-size: 21px;
  }

  .stage {
    grid-template-columns: minmax(0, 1fr);
    gap: 22px;
  }

  .kanji-stage {
    margin: 0 auto;
    width: 232px;
    height: 232px;
  }

  .music-stage {
    height: auto;
    gap: 10px;
  }

  .notes-head {
    height: 50px;
  }

  .notes-line {
    font-size: 26px;
  }

  .parts-list {
    height: 112px;
    gap: 8px 12px;
  }

  .piano-kb {
    height: 112px;
  }

  .pk-black .pk-en {
    font-size: 8.5px;
  }

  .site-footer {
    margin-top: 36px;
    padding-top: 14px;
    font-size: 11px;
  }

  .modal {
    padding: 12px;
  }

  .modal-head {
    padding: 12px 16px;
  }

  .ref-list {
    padding: 12px 14px 16px;
  }

  .ref-row {
    grid-template-columns: 86px 1fr;
  }

  .ref-key-cell {
    padding: 8px 10px;
  }

  .ref-parts-cell {
    padding: 8px 10px;
    gap: 4px;
  }

  .ref-g {
    width: 28px;
    height: 30px;
    font-size: 21px;
  }
}
