* {
  box-sizing: border-box;
}

body {
  --blue-preview-duration: 3200ms;
  margin: 0;
  min-height: 100vh;
  font-family: "Trebuchet MS", Helvetica, sans-serif;
  background: linear-gradient(180deg, #f1f3f5 0%, #d9dde2 100%);
  color: #1f2933;
}

.page {
  display: flex;
  width: 100%;
  padding: 0;
}

.panel {
  width: 100%;
  min-height: 100vh;
  padding: 20px;
  border: 1px solid #b8c0c7;
  border-radius: 0;
  background: rgba(255, 255, 255, 0.9);
  box-shadow: 0 18px 45px rgba(54, 68, 79, 0.12);
}

.panel__intro {
  min-width: 0;
}

.panel__content {
  display: flex;
  align-items: flex-start;
  gap: 24px;
  margin-top: 30px;
}

.panel__header h1 {
  margin: 0 0 8px;
  font-size: clamp(2rem, 4vw, 2.8rem);
}

.panel__header p {
  margin: 0;
  color: #52606d;
}

.controls {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
}

.panel__footer-controls {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  align-items: flex-end;
  gap: 16px;
  margin-top: 24px;
}

.control {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 180px;
  font-weight: 600;
}

.control-button {
  padding: 12px 18px;
  border: 1px solid #98a6b3;
  border-radius: 12px;
  background: linear-gradient(180deg, #ffffff 0%, #edf2f7 100%);
  color: #102a43;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

.control-button:hover {
  background: linear-gradient(180deg, #f8fbfd 0%, #e3ebf2 100%);
}

.control span {
  font-size: 0.95rem;
}

.control select {
  appearance: none;
  padding: 12px 14px;
  border: 1px solid #98a6b3;
  border-radius: 12px;
  background: #fff;
  color: #102a43;
  font: inherit;
}

.control input[type="number"] {
  padding: 12px 14px;
  border: 1px solid #98a6b3;
  border-radius: 12px;
  background: #fff;
  color: #102a43;
  font: inherit;
}

.control--toggle {
  justify-content: flex-end;
}

.control--toggle input[type="checkbox"] {
  width: 24px;
  height: 24px;
  margin: 0;
  accent-color: #0f609b;
}

.degree-table-card {
  flex: 0 1 25%;
  width: 25%;
  max-width: 25%;
  min-width: 260px;
  padding: 16px;
  border: 1px solid #b8c0c7;
  border-radius: 16px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.98) 0%, rgba(243, 246, 248, 0.98) 100%);
}

.degree-table-card h2 {
  margin: 0 0 12px;
  font-size: 1rem;
  color: #243b53;
}

.degree-table {
  width: 100%;
  border-collapse: collapse;
}

.degree-table td {
  padding: 8px 0;
  border-top: 1px solid #d9e2ec;
  font-size: 0.92rem;
}

.degree-table tr {
  cursor: pointer;
}

.degree-table tr:hover td {
  color: #0f609b;
}

.degree-table tr.priority-level-1 td {
  background: rgba(118, 205, 129, 0.95);
  color: #10381b;
}

.degree-table tr.priority-level-2 td {
  background: rgba(171, 224, 177, 0.93);
  color: #1d4b2a;
}

.degree-table tr.priority-level-3 td {
  background: rgba(221, 239, 224, 0.95);
  color: #345740;
}

.degree-table tr.is-selected-row td {
  background: rgba(159, 226, 255, 0.65);
  color: #0b4f79;
}

.degree-table tr.is-selected-row td:last-child {
  color: #0b4f79;
}

.degree-table tr.is-table-preview-row td {
  animation: degree-row-preview var(--blue-preview-duration) ease-out forwards;
}

.degree-table tr:first-child td {
  border-top: 0;
}

.degree-table td:last-child {
  text-align: right;
  font-weight: 700;
  color: #102a43;
}

.keyboard-wrapper {
  flex: 1 1 75%;
  min-width: 0;
  overflow-x: auto;
  overflow-y: visible;
  padding-top: 44px;
  padding-bottom: 10px;
}

.keyboard {
  --white-key-count: 15;
  --black-key-width-ratio: 0.64;
  position: relative;
  width: max(750px, 100%);
  height: 260px;
  margin: 0;
}

.white-keys {
  display: flex;
  height: 100%;
}

.white-key,
.black-key {
  border: 1px solid #8a8f96;
  cursor: pointer;
  transition: background-color 0.2s ease, box-shadow 0.2s ease, transform 0.2s ease;
}

.white-key {
  position: relative;
  width: calc(100% / var(--white-key-count));
  height: 100%;
  background: linear-gradient(180deg, #ffffff 0%, #f1f1f1 100%);
  border-radius: 0 0 8px 8px;
}

.black-key {
  position: absolute;
  top: 0;
  width: calc((100% / var(--white-key-count)) * var(--black-key-width-ratio));
  height: 155px;
  background: linear-gradient(180deg, #2d2d2d 0%, #111111 100%);
  border-radius: 0 0 6px 6px;
  transform: translateX(-50%);
  z-index: 2;
}

.white-key.is-scale-key,
.black-key.is-scale-key {
  cursor: pointer;
}

.white-key.is-highlighted {
  background: linear-gradient(180deg, #ffe18f 0%, #f8c74d 100%);
  box-shadow: inset 0 0 0 2px rgba(135, 84, 0, 0.15);
}

.black-key.is-highlighted {
  background: linear-gradient(180deg, #ffd769 0%, #c38700 100%);
  box-shadow: 0 0 0 2px rgba(255, 228, 164, 0.45);
}

.white-key.is-table-preview-highlighted {
  animation: white-key-preview-highlighted var(--blue-preview-duration) ease-out forwards;
}

.white-key.is-table-preview-unhighlighted {
  animation: white-key-preview-unhighlighted var(--blue-preview-duration) ease-out forwards;
}

.black-key.is-table-preview-highlighted {
  animation: black-key-preview-highlighted var(--blue-preview-duration) ease-out forwards;
}

.black-key.is-table-preview-unhighlighted {
  animation: black-key-preview-unhighlighted var(--blue-preview-duration) ease-out forwards;
}

.key-label {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  font-size: 0.9rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  user-select: none;
}

.degree-label {
  position: absolute;
  left: 50%;
  top: -36px;
  transform: translateX(-50%);
  padding: 4px 8px;
  border: 1px solid #8a8f96;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.96);
  color: #243b53;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.01em;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
}

.has-degree-label .degree-label {
  opacity: 1;
}

.priority-degree-1 .degree-label {
  background: rgba(118, 205, 129, 0.98);
  border-color: #4f9860;
  color: #10381b;
}

.priority-degree-2 .degree-label {
  background: rgba(171, 224, 177, 0.98);
  border-color: #82b08d;
  color: #1d4b2a;
}

.priority-degree-3 .degree-label {
  background: rgba(221, 239, 224, 0.98);
  border-color: #a9c7b0;
  color: #345740;
}

body.hide-green-highlighting .degree-table tr.priority-level-1 td,
body.hide-green-highlighting .degree-table tr.priority-level-2 td,
body.hide-green-highlighting .degree-table tr.priority-level-3 td {
  background: transparent;
  color: inherit;
}

body.hide-green-highlighting .priority-degree-1 .degree-label,
body.hide-green-highlighting .priority-degree-2 .degree-label,
body.hide-green-highlighting .priority-degree-3 .degree-label {
  background: rgba(255, 255, 255, 0.96);
  border-color: #8a8f96;
  color: #243b53;
}

.key-dot {
  position: absolute;
  left: 50%;
  top: 12px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #1f9d55;
  border: 2px solid rgba(255, 255, 255, 0.95);
  transform: translateX(-50%);
  opacity: 0;
  pointer-events: none;
  box-shadow: 0 0 0 1px rgba(16, 42, 67, 0.08);
}

.black-key .key-dot {
  top: 10px;
}

.is-reference-key .key-dot {
  opacity: 1;
}

.white-key .key-label {
  bottom: 14px;
  color: #52606d;
}

.black-key .key-label {
  bottom: 12px;
  color: #f5f7fa;
  font-size: 0.75rem;
}

.black-key .degree-label {
  top: -34px;
}

.keyboard.hide-note-names .key-label {
  opacity: 0;
}

@keyframes white-key-preview-highlighted {
  0% {
    background: linear-gradient(180deg, #cfeeff 0%, #92d8ff 100%);
    box-shadow: 0 0 0 3px rgba(106, 190, 255, 0.65);
  }

  100% {
    background: linear-gradient(180deg, #ffe18f 0%, #f8c74d 100%);
    box-shadow: inset 0 0 0 2px rgba(135, 84, 0, 0.15);
  }
}

@keyframes white-key-preview-unhighlighted {
  0% {
    background: linear-gradient(180deg, #cfeeff 0%, #92d8ff 100%);
    box-shadow: 0 0 0 3px rgba(106, 190, 255, 0.65);
  }

  100% {
    background: linear-gradient(180deg, #ffffff 0%, #f1f1f1 100%);
    box-shadow: none;
  }
}

@keyframes black-key-preview-highlighted {
  0% {
    background: linear-gradient(180deg, #9fe2ff 0%, #4aaef2 100%);
    box-shadow: 0 0 0 3px rgba(160, 223, 255, 0.72);
  }

  100% {
    background: linear-gradient(180deg, #ffd769 0%, #c38700 100%);
    box-shadow: 0 0 0 2px rgba(255, 228, 164, 0.45);
  }
}

@keyframes black-key-preview-unhighlighted {
  0% {
    background: linear-gradient(180deg, #9fe2ff 0%, #4aaef2 100%);
    box-shadow: 0 0 0 3px rgba(160, 223, 255, 0.72);
  }

  100% {
    background: linear-gradient(180deg, #2d2d2d 0%, #111111 100%);
    box-shadow: none;
  }
}

@keyframes degree-row-preview {
  0% {
    background: rgba(174, 226, 255, 0.85);
    color: #0b4f79;
  }

  100% {
    background: transparent;
    color: inherit;
  }
}

@media (max-width: 760px) {
  .panel {
    padding: 16px;
  }

  .panel__content {
    flex-direction: column;
  }

  .degree-table-card {
    width: 100%;
    max-width: 100%;
    flex-basis: auto;
  }

  .keyboard {
    width: 750px;
  }
}
