:root {
  color-scheme: light;
  --ink: #12191f;
  --paper: #e8ecef;
  --board: #c7cdd1;
  --board-edge: #9ba4aa;
  --fret: rgba(35, 39, 41, 0.58);
  --accent: #176da3;
  --accent-dark: #0b456b;
  --accent-ring: rgba(23, 109, 163, 0.25);
  --accidental: #e1e5e7;
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
}

body {
  min-width: 320px;
  position: relative;
  background: transparent;
  color: var(--ink);
  font-family: "Segoe UI", Arial, sans-serif;
}

body::before {
  content: "";
  position: fixed;
  z-index: 0;
  inset: 0;
  background:
    linear-gradient(rgba(232, 236, 239, 0.84), rgba(232, 236, 239, 0.84)),
    url("https://upload.wikimedia.org/wikipedia/commons/b/bd/Flag_of_Cuba.svg") center / cover no-repeat;
}

button {
  font: inherit;
}

input {
  font: inherit;
}

.workspace {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: minmax(220px, 290px) minmax(300px, 370px) minmax(330px, 390px);
  gap: clamp(8px, 1.6vw, 22px);
  width: min(1100px, 100%);
  height: 100dvh;
  margin: 0 auto;
  padding: clamp(6px, 1.2vh, 12px);
}

.brand {
  position: static;
  align-self: start;
  transform: translateX(clamp(-38px, -2vw, -24px));
  min-width: 0;
  width: auto;
  padding-top: clamp(26px, 8vh, 86px);
  text-align: left;
}

.brand-mark {
  margin: 0 0 clamp(10px, 1.6vh, 16px) 0.34em;
  color: var(--accent);
  font-size: clamp(1rem, 1.35vw, 1.25rem);
  font-weight: 900;
  letter-spacing: 0.035em;
  line-height: 1;
}

.brand h1 {
  margin: 0 0 clamp(18px, 3vh, 30px);
  font-family: inherit;
  font-size: clamp(4.25rem, 7vw, 6rem);
  font-weight: 900;
  letter-spacing: -0.07em;
  line-height: 0.8;
}

.brand h1 span {
  display: block;
}

.brand #brandSubtitle {
  margin: 0 0 0 0.34em;
  font-size: clamp(1.45rem, 2vw, 2rem);
  font-weight: 900;
  letter-spacing: -0.045em;
  line-height: 1.05;
}

.mode-instructions {
  display: grid;
  gap: 5px;
  max-width: 350px;
  margin: clamp(18px, 3vh, 30px) 0 0 0.55em;
  color: rgba(18, 25, 31, 0.82);
  font-size: clamp(0.9rem, 1.15vw, 1.05rem);
  font-weight: 600;
  letter-spacing: -0.01em;
  line-height: 1.35;
}

.mode-instructions strong {
  font-size: 1.05em;
  font-weight: 850;
}

.site-copyright {
  margin: clamp(18px, 3vh, 30px) 0 0 0.55em;
  color: rgba(18, 25, 31, 0.72);
  font-size: 0.74rem;
  font-weight: 600;
  line-height: 1.35;
}

.site-copyright a {
  color: inherit;
}

.app-version {
  display: inline-block;
  margin-top: 3px;
  font-size: 0.92em;
  letter-spacing: 0.02em;
}

.brand-language {
  width: max-content;
  margin: 0 0 clamp(12px, 2vh, 20px) 0.34em;
}

.volume-control {
  display: grid;
  gap: 3px;
  min-width: 0;
  font-size: 0.78rem;
  font-weight: 800;
}

.volume-control input {
  width: 100%;
  accent-color: var(--accent);
  cursor: pointer;
}

.setting-toggle {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  padding: 2px;
  border: 1px solid rgba(18, 25, 31, 0.22);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.68);
}

.setting-button {
  min-width: 31px;
  min-height: 27px;
  padding: 2px 5px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: #4c5961;
  cursor: pointer;
  font-size: 0.72rem;
  font-weight: 850;
}

.setting-button.active {
  background: var(--ink);
  color: white;
}

.note-spelling-toggle .setting-button {
  font-size: 1rem;
  line-height: 1;
}

.neck-area {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr);
  gap: 7px;
  min-width: 0;
  min-height: 0;
}

.fret-numbers,
.fretboard {
  display: grid;
  grid-template-rows: repeat(17, minmax(0, 1fr));
  min-height: 0;
}

.fret-numbers {
  color: var(--ink);
  font-size: clamp(0.68rem, 1.45vh, 0.8rem);
  font-weight: 800;
}

.fretboard {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  overflow: hidden;
  border: 1px solid rgba(18, 25, 31, 0.34);
  border-radius: 14px;
  background: linear-gradient(90deg, var(--board-edge), var(--board) 9%, #d6dade 50%, var(--board) 91%, var(--board-edge));
  box-shadow: 0 12px 34px rgba(20, 24, 27, 0.14);
}

.fret-number,
.note-cell {
  display: grid;
  place-items: center;
}

.fret-number {
  text-align: right;
}

.note-cell {
  position: relative;
  min-height: 0;
  border-bottom: 1px solid var(--fret);
}

.note-cell::before {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  left: 50%;
  width: 2px;
  background: rgba(245, 241, 229, 0.8);
  box-shadow: 1px 0 rgba(50, 44, 37, 0.28);
}

.note-cell.position-marker::after {
  --marker-size: clamp(7px, 1.1vh, 10px);
  content: "";
  position: absolute;
  z-index: 0;
  top: 50%;
  left: clamp(5px, 1vw, 9px);
  width: var(--marker-size);
  height: var(--marker-size);
  border-radius: 50%;
  background: #050607;
  transform: translateY(-50%);
}

.note-cell.double-position-marker::after {
  top: calc(50% - var(--marker-size) - 2px);
  box-shadow: 0 calc(var(--marker-size) + 4px) #050607;
  transform: none;
}

.open-cell {
  border-bottom: 4px solid rgba(18, 25, 31, 0.82);
  background: rgba(239, 235, 224, 0.48);
}

.mute-cell {
  border-bottom: 1px solid var(--fret);
  background: rgba(247, 249, 250, 0.72);
}

.mute-cell::before {
  display: none;
}

.mute-label {
  font-size: 0.72rem;
}

.note-button {
  position: relative;
  z-index: 1;
  display: grid;
  place-items: center;
  width: clamp(26px, 4.4vh, 38px);
  height: clamp(26px, 4.4vh, 38px);
  padding: 0;
  border: 1.5px solid var(--ink);
  border-radius: 50%;
  background: #fffefa;
  color: var(--ink);
  cursor: pointer;
  font-size: clamp(0.66rem, 1.45vh, 0.8rem);
  font-weight: 850;
  line-height: 1;
  transition: transform 100ms ease, background 100ms ease, box-shadow 100ms ease;
}

.note-button.accidental {
  background: var(--accidental);
  font-size: clamp(0.55rem, 1.2vh, 0.68rem);
}

.note-button:hover {
  transform: scale(1.08);
}

.note-button:focus-visible {
  outline: 3px solid rgba(23, 109, 163, 0.5);
  outline-offset: 2px;
}

.note-button.selected {
  border-color: var(--accent-dark);
  background: var(--accent);
  color: white;
  box-shadow: 0 0 0 4px var(--accent-ring);
}

.results {
  grid-row: 2;
  display: flex;
  flex-direction: column;
  width: calc(100% - 41px);
  height: min(680px, calc(100dvh - 150px));
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.84);
  box-shadow: 0 12px 34px rgba(20, 24, 27, 0.1);
}

.results-column {
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto minmax(0, 1fr);
  min-width: 0;
  min-height: 0;
}

.below-results-controls {
  grid-row: 3;
  align-self: start;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: end;
  gap: 10px;
  width: calc(100% - 41px);
  margin-top: 12px;
  padding-inline: 4px;
}

.result-controls {
  flex: 0 0 auto;
  padding: clamp(7px, 1.1vw, 12px) clamp(8px, 1.2vw, 14px) 0;
}

.mode-toggle {
  display: grid;
  grid-template-columns: 1fr 1fr;
  padding: 3px;
  border: 1px solid rgba(18, 25, 31, 0.2);
  border-radius: 999px;
  background: rgba(199, 205, 209, 0.72);
}

.mode-button {
  min-width: 0;
  padding: clamp(5px, 0.8vh, 8px) 6px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: #4c5961;
  cursor: pointer;
  font-size: clamp(0.72rem, 1.45vh, 0.86rem);
  font-weight: 800;
}

.mode-button.active {
  background: var(--accent);
  color: white;
  box-shadow: 0 2px 7px rgba(11, 69, 107, 0.25);
}

.secondary-controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: 6px;
}

.replay-button {
  min-height: 31px;
  padding: 3px 12px;
  border: 1px solid var(--accent);
  border-radius: 999px;
  background: var(--accent);
  color: white;
  cursor: pointer;
  font-size: 0.76rem;
  font-weight: 850;
}

.feedback-button {
  display: inline-grid;
  min-height: 31px;
  place-items: center;
  padding: 3px 12px;
  border: 1px solid var(--accent);
  border-radius: 999px;
  background: transparent;
  color: var(--accent-dark);
  cursor: pointer;
  font-size: 0.76rem;
  font-weight: 850;
  text-decoration: none;
}

.feedback-button:hover,
.feedback-button:focus-visible {
  background: var(--accent);
  color: white;
}

.feedback-button:focus-visible {
  outline: 3px solid rgba(23, 109, 163, 0.42);
  outline-offset: 2px;
}

.feedback-dock {
  position: absolute;
  z-index: 2;
  bottom: calc(clamp(6px, 1.2vh, 12px) + 12px);
  left: calc(clamp(6px, 1.2vh, 12px) + 0.55em);
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0;
}

.feedback-dock .app-version {
  margin: 0;
  color: rgba(18, 25, 31, 0.72);
  font-size: 0.68rem;
  font-weight: 700;
  white-space: nowrap;
}

.feedback-dialog {
  width: min(440px, calc(100% - 28px));
  padding: 0;
  border: 1px solid rgba(23, 109, 163, 0.3);
  border-radius: 18px;
  background: #fff;
  color: var(--ink);
  box-shadow: 0 24px 80px rgba(16, 24, 32, 0.28);
}

.feedback-dialog::backdrop {
  background: rgba(16, 24, 32, 0.48);
  backdrop-filter: blur(2px);
}

.feedback-form {
  display: grid;
  gap: 12px;
  padding: 22px;
}

.feedback-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.feedback-heading h2,
.feedback-form p {
  margin: 0;
}

.feedback-heading h2 {
  font-size: 1.35rem;
  letter-spacing: -0.03em;
}

.feedback-form > p:not(.feedback-status) {
  color: #52616c;
  font-size: 0.86rem;
  line-height: 1.45;
}

.feedback-form > .feedback-version {
  margin-top: -8px;
  font-size: 0.74rem;
  font-weight: 700;
}

.feedback-form label {
  font-size: 0.82rem;
  font-weight: 850;
}

.feedback-form input[type="email"],
.feedback-form textarea {
  padding: 12px;
  border: 1px solid #aebbc3;
  border-radius: 10px;
  color: var(--ink);
  font: inherit;
  line-height: 1.45;
}

.feedback-form textarea {
  min-height: 150px;
  resize: vertical;
}

.feedback-form input[type="email"]:focus-visible,
.feedback-form textarea:focus-visible {
  border-color: var(--accent);
  outline: 3px solid rgba(23, 109, 163, 0.25);
  outline-offset: 1px;
}

.feedback-close {
  width: 34px;
  height: 34px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: #edf3f6;
  color: var(--ink);
  cursor: pointer;
  font-size: 1.35rem;
  line-height: 1;
}

.feedback-actions {
  display: flex;
  justify-content: flex-end;
  gap: 9px;
}

.feedback-cancel,
.feedback-submit {
  min-height: 36px;
  padding: 6px 15px;
  border-radius: 999px;
  cursor: pointer;
  font: inherit;
  font-size: 0.82rem;
  font-weight: 850;
}

.feedback-cancel {
  border: 1px solid #aebbc3;
  background: white;
  color: var(--ink);
}

.feedback-submit {
  border: 1px solid var(--accent);
  background: var(--accent);
  color: white;
}

.feedback-submit:disabled {
  cursor: wait;
  opacity: 0.62;
}

.feedback-status {
  min-height: 1.25em;
  color: #52616c;
  font-size: 0.8rem;
  font-weight: 700;
}

.feedback-status.success {
  color: #19733b;
}

.feedback-status.error {
  color: #a52b2b;
}

.feedback-trap {
  position: fixed;
  left: -10000px;
  width: 1px;
  height: 1px;
  overflow: hidden;
}

.replay-button:hover,
.replay-button:focus-visible {
  background: var(--accent-dark);
}

.replay-button:focus-visible {
  outline: 3px solid rgba(23, 109, 163, 0.42);
  outline-offset: 2px;
}

.replay-button:disabled {
  border-color: #aeb7bd;
  background: #aeb7bd;
  cursor: default;
  opacity: 0.65;
}

.mode-button:focus-visible,
.lookup-form input:focus-visible {
  outline: 3px solid rgba(23, 109, 163, 0.42);
  outline-offset: 2px;
}

.lookup-form {
  margin-top: clamp(6px, 0.9vh, 9px);
}

.lookup-form input {
  width: 100%;
  height: clamp(34px, 5vh, 44px);
  padding: 4px 11px;
  border: 1.5px solid rgba(18, 25, 31, 0.32);
  border-radius: 9px;
  background: rgba(255, 255, 255, 0.94);
  color: var(--ink);
  font-size: clamp(1rem, 2.3vh, 1.25rem);
  font-weight: 800;
}

.lookup-form input.invalid {
  border-color: #a51e2d;
}

.lookup-form input::placeholder {
  color: #aeb5ba;
  opacity: 1;
}

.no-conventional-chord {
  color: #59656d;
  font-weight: 750;
}

.advanced-chord {
  color: var(--accent-dark);
  font-weight: 850;
}

.lookup-status {
  margin-top: clamp(5px, 0.7vh, 7px);
  padding-inline: 2px;
  font-size: clamp(0.72rem, 1.4vh, 0.84rem);
  font-weight: 800;
  line-height: 1.1;
}

.lookup-status.error {
  color: #8d1725;
}

.candidate-list {
  display: grid;
  align-content: start;
  gap: clamp(4px, 0.75vh, 8px);
  flex: 1 1 auto;
  min-height: 0;
  margin: 0;
  padding: clamp(8px, 1.2vw, 14px);
  overflow: hidden;
  list-style: none;
}

.lookup-list {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: clamp(3px, 0.55vh, 6px);
}

.shape-candidate {
  min-height: clamp(31px, 4.5vh, 41px);
  padding: 3px 6px;
  cursor: pointer;
  font-size: clamp(0.74rem, 1.65vh, 0.92rem);
}

.shape-candidate.active {
  border-color: var(--accent);
  background: #eef7fc;
  box-shadow: inset 0 0 0 1px var(--accent);
}

.shape-copy {
  min-width: 0;
}

.shape-frets,
.shape-notes,
.shape-intervals {
  display: block;
  white-space: nowrap;
}

.shape-frets {
  font-weight: 850;
}

.shape-intervals {
  margin-top: 2px;
  color: #4c5961;
  font-size: clamp(0.72rem, 1.35vh, 0.84rem);
  font-weight: 800;
}

.shape-notes {
  margin-top: 2px;
  color: var(--accent-dark);
  font-size: clamp(0.72rem, 1.35vh, 0.84rem);
  font-weight: 850;
}

.shape-rootless {
  color: var(--accent-dark);
}

.note-label {
  position: relative;
  z-index: 30;
  pointer-events: none;
}

.note-button.lookup-member {
  border-color: var(--accent-dark);
  background: var(--accent);
  color: white;
  box-shadow: 0 0 0 4px var(--accent-ring);
}

.lookup-mode .note-button {
  cursor: default;
}

.lookup-mode .note-button.lookup-member {
  cursor: default;
}

.candidate {
  display: flex;
  align-items: center;
  min-height: clamp(34px, 4.8vh, 44px);
  padding: 4px clamp(7px, 1.1vw, 12px);
  border: 1px solid rgba(18, 25, 31, 0.14);
  border-radius: 10px;
  background: rgba(252, 251, 247, 0.95);
  font-family: inherit;
  font-size: clamp(1rem, 2.5vh, 1.35rem);
  font-weight: 700;
  line-height: 1.05;
}

.candidate-list:not(.lookup-list) .candidate:first-child {
  border-color: rgba(23, 109, 163, 0.52);
  background: #eef7fc;
}

.qualifier {
  color: var(--accent-dark);
  font-family: inherit;
  font-size: 0.58em;
  font-weight: 800;
  white-space: nowrap;
}

.played-intervals {
  margin-left: 9px;
  color: #4c5961;
  font-family: inherit;
  font-size: 0.68em;
  font-weight: 800;
  white-space: nowrap;
}

@media (max-width: 1150px) {
  .workspace {
    grid-template-columns: minmax(170px, 220px) minmax(280px, 340px) minmax(300px, 370px);
    width: min(970px, 100%);
  }

  .brand {
    position: static;
    align-self: start;
    transform: none;
    width: auto;
    padding-top: clamp(14px, 4vh, 42px);
  }
}

@media (max-width: 620px) {
  .workspace {
    grid-template-columns: minmax(64px, 82px) minmax(116px, 1fr) minmax(116px, 1fr);
    gap: 5px;
    padding: 4px;
  }

  .brand {
    position: static;
    width: auto;
    padding-top: 10px;
  }

  .brand h1 {
    margin-bottom: 14px;
    font-size: clamp(2rem, 10vw, 3rem);
    font-weight: 900;
  }

  .brand-mark {
    margin-bottom: 8px;
    font-size: clamp(0.68rem, 3vw, 0.86rem);
  }

  .brand #brandSubtitle {
    font-size: clamp(0.7rem, 3vw, 0.9rem);
    overflow-wrap: anywhere;
  }

  .mode-instructions {
    display: none;
  }

  .brand-language {
    margin: 0 0 10px;
  }

  .feedback-dock {
    bottom: 8px;
    left: clamp(6px, 1.2vh, 12px);
    gap: 5px;
    margin: 0;
  }

  .feedback-dock .feedback-button {
    min-height: 24px;
    padding: 2px 5px;
    font-size: 0.58rem;
  }

  .feedback-dock .app-version {
    font-size: 0.52rem;
  }

  .volume-control {
    font-size: 0.58rem;
  }

  .setting-button {
    min-width: 0;
    min-height: 24px;
    padding-inline: 2px;
    font-size: 0.58rem;
  }

  .fretboard,
  .results {
    border-radius: 8px;
  }

  .results {
    width: calc(100% - 29px);
    height: min(680px, calc(100dvh - 126px));
  }

  .below-results-controls {
    grid-template-columns: 1fr;
    gap: 4px;
    width: calc(100% - 29px);
    margin-top: 7px;
    padding-inline: 1px;
  }

  .neck-area {
    grid-template-columns: 25px minmax(0, 1fr);
    gap: 4px;
  }

  .candidate-list {
    padding: 5px;
  }

  .result-controls {
    padding: 5px 5px 0;
  }

  .mode-button {
    padding-inline: 2px;
    font-size: clamp(0.58rem, 2vw, 0.7rem);
  }

  .lookup-list {
    grid-template-columns: 1fr;
  }

  .shape-candidate {
    min-height: 27px;
  }

  .candidate {
    padding-inline: 5px;
    border-radius: 6px;
    font-size: clamp(0.72rem, 2.15vh, 1rem);
  }

  .qualifier {
    display: block;
    margin-top: 2px;
    white-space: normal;
  }
}

@media (prefers-reduced-motion: reduce) {
  .note-button {
    transition: none;
  }
}
