:root {
  font-family: Inter, "Helvetica Neue", "Hiragino Kaku Gothic ProN", "Noto Sans JP", Meiryo, sans-serif;
  color-scheme: light;
  color: #22231f;
  background: #f5f4ef;
  --ink: #22231f;
  --paper: #fcfbf6;
  --rule: #d8d9cf;
}

*, *::before, *::after { box-sizing: border-box; }
body { margin: 0; }
[hidden] { display: none !important; }
button, input { font: inherit; color: inherit; }
button { touch-action: manipulation; }
button:not(:disabled) { cursor: pointer; }
:focus-visible { outline: 3px solid #49408d; outline-offset: 4px; }
a { color: inherit; }

.site-header {
  background: #fffef9;
  border-bottom: 1px solid var(--rule);
}

.site-header-inner, .main {
  width: min(100% - clamp(24px, 7vw, 94px), 1140px);
  margin-inline: auto;
}

.site-header-inner {
  min-height: 63px;
  display: flex;
  align-items: center;
  gap: 15px;
}

.site-header h1 { margin: 0; display: flex; }
.logo, .app-name {
  display: inline-flex;
  align-items: center;
  text-decoration: none;
  color: var(--ink);
  white-space: nowrap;
}

.logo { gap: 8px; font-size: 24px; font-weight: 800; letter-spacing: -.055em; }
.logo-mark {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  color: #e7ed98;
  background: var(--ink);
}
.logo-mark svg { width: 23px; height: 23px; }

.app-name {
  min-height: 28px;
  border-left: 1px solid var(--rule);
  padding-left: 15px;
  font-size: 16px;
  font-weight: 750;
  line-height: 1.3;
}

.main { padding-block: clamp(16px, 4vh, 36px) 15px; }

.toolbar, .play-controls, .edit-controls {
  display: flex;
  gap: 9px;
  align-items: center;
}

.toolbar { justify-content: space-between; margin-bottom: 17px; flex-wrap: wrap; }
.play-controls, .edit-controls { min-width: 0; }

.volume {
  display: flex;
  align-items: center;
  min-height: 44px;
  gap: 8px;
  padding-inline: 11px;
  border: 1px solid var(--rule);
  background: var(--paper);
  border-radius: 8px;
  white-space: nowrap;
  font-size: .86rem;
  font-weight: 650;
}

.volume input {
  margin: 0;
  width: clamp(54px, 9.5vw, 107px);
  min-height: 32px;
  accent-color: var(--ink);
}

.action {
  display: inline-flex;
  justify-content: center;
  align-items: center;
  gap: .42em;
  min-height: 44px;
  padding: 5px 12px;
  border: 1px solid #aeb0a4;
  border-radius: 8px;
  background: var(--paper);
  white-space: nowrap;
  font-size: .89rem;
  font-weight: 650;
}

.action:hover:not(:disabled) { border-color: var(--ink); }
.action:active:not(:disabled) { transform: translateY(1px); }
.action:disabled { opacity: .48; }
.action[aria-pressed="true"] { background: #e8dffd; border-color: #6e5b8d; }
.action.add { background: var(--ink); color: #fffef8; border-color: var(--ink); }
.square { width: 10px; height: 10px; border-radius: 1px; background: currentColor; }

.board {
  --pad-height: clamp(105px, calc((100svh - 194px) / 3), 176px);
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: clamp(11px, 2vh, 18px) clamp(8px, 1.8vw, 18px);
  align-items: stretch;
  padding: clamp(9px, 1.5vw, 16px) clamp(9px, 1.5vw, 16px) clamp(16px, 2vw, 24px);
  border-radius: 20px;
  border: 1px solid #d5d5cb;
  background: #e9e9e0;
}

.pad {
  --face: #e5ed9e;
  --base: #a4ad65;
  --detail: #454d26;
  --depth: 6px;
  position: relative;
  min-width: 0;
  min-height: var(--pad-height);
  padding: 9px 5px 10px;
  display: grid;
  place-content: center;
  justify-items: center;
  row-gap: clamp(3px, .8vh, 9px);
  border: 1.5px solid #36362c;
  border-radius: 14px;
  background: var(--face);
  color: #25261f;
  box-shadow: 0 var(--depth) 0 var(--base), 0 calc(var(--depth) + 1px) 0 #36362c;
  transition: box-shadow .09s ease-out, transform .09s ease-out;
  -webkit-user-select: none;
  user-select: none;
}

.pad[data-tone="warm"] { --face: #ffdbc3; --base: #c58b69; --detail: #68442f; }
.pad[data-tone="cool"] { --face: #e8dffd; --base: #a99bc5; --detail: #534474; }
.pad[data-tone="custom"] { --face: #d9ecde; --base: #8aa995; --detail: #3a654a; }

.pad:active, .pad[data-playing] {
  transform: translateY(calc(var(--depth) - 1px));
  box-shadow: 0 1px 0 var(--base), 0 2px 0 #36362c;
}

.pad[data-playing] { outline: 2px solid var(--detail); outline-offset: -5px; }

.pad-icon {
  color: var(--detail);
  font-family: system-ui, sans-serif;
  font-size: clamp(1.6rem, 3.9vw, 2.8rem);
  font-weight: 650;
  line-height: .95;
}

.pad-label {
  overflow-wrap: anywhere;
  font-size: clamp(.86rem, 2.35vw, 1.6rem);
  font-weight: 690;
  line-height: 1.16;
  letter-spacing: -.035em;
}

.shortcut {
  position: absolute;
  top: 6px;
  left: 7px;
  display: grid;
  place-items: center;
  width: 24px;
  height: 22px;
  border: 1px solid #22231f27;
  border-radius: 5px;
  color: #37372d;
  background: #fffdf77d;
  font-size: .76rem;
  font-weight: 700;
  line-height: 1;
}

.edit-mark {
  position: absolute;
  top: 6px;
  right: 8px;
  color: var(--detail);
  font-size: 1rem;
  line-height: 1;
}

.board-footer {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  margin-top: 12px;
  font-size: .82rem;
  color: #514f46;
  line-height: 1.4;
}

.board-footer p { margin: 0; }
.board-footer a { margin-left: auto; white-space: nowrap; text-underline-offset: .21em; }

dialog {
  width: min(500px, calc(100% - 24px));
  max-height: calc(100dvh - 24px);
  margin: auto;
  padding: clamp(16px, 4vw, 25px);
  color: var(--ink);
  background: #fffef8;
  border: 1.5px solid var(--ink);
  border-radius: 17px;
  box-shadow: 0 13px 0 #25262025;
}

dialog::backdrop { background: #22231f78; }
.dialog-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 15px; }
.dialog-head h2 { margin: 0; line-height: 1.2; font-size: 1.38rem; }
.icon-button {
  display: inline-grid;
  place-items: center;
  min-width: 44px;
  min-height: 44px;
  border: 1px solid #adad9e;
  border-radius: 8px;
  background: var(--paper);
  padding: 0;
  font-size: 1.55rem;
  line-height: 1;
}

.name-label { display: block; font-size: .92rem; margin-bottom: 6px; font-weight: 650; }
#clip-name {
  display: block;
  width: 100%;
  min-height: 46px;
  padding: 7px 10px;
  border: 1px solid #adad9e;
  border-radius: 8px;
  background: white;
  font-size: 1rem;
}

.source-controls { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; margin-block: 13px; }
#record[data-recording] { background: #ffded7; color: #7d2525; border-color: #9f4a41; }
.source-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 7px 8px 7px 10px;
  border: 1px solid var(--rule);
  border-radius: 8px;
  background: #f6f6ee;
}
.source-summary p { margin: 0; font-size: .84rem; overflow-wrap: anywhere; line-height: 1.35; }

.editor-status, .local-note { margin: 9px 0 0; font-size: .83rem; line-height: 1.5; }
.editor-status { color: #7b3028; }
.editor-status:empty { display: none; }
.local-note { color: #58574f; }

.dialog-actions { display: flex; justify-content: space-between; gap: 10px; margin-top: 16px; }
.dialog-actions #save { margin-left: auto; min-width: 104px; }
.remove {
  min-height: 44px;
  padding-inline: 5px;
  background: transparent;
  border: 0;
  color: #7b3028;
  text-decoration: underline;
  text-underline-offset: .2em;
  font-size: .87rem;
}

.credits { max-width: 790px; line-height: 1.65; }
.credits h1 { font-size: clamp(1.5rem, 4vw, 2.15rem); margin: 0; }
.credits ul { padding-left: 1.35em; }
.credits li { margin-block: .8rem; }

@media (orientation: portrait) {
  .board {
    --pad-height: clamp(88px, calc((100svh - 228px) / 4), 210px);
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 650px) {
  .site-header-inner { gap: 10px; min-height: 54px; }
  .logo { gap: 6px; font-size: 21px; }
  .logo-mark { width: 30px; height: 30px; }
  .logo-mark svg { width: 21px; height: 21px; }
  .app-name { min-height: 26px; font-size: 14px; padding-left: 10px; }
  .toolbar { margin-bottom: 11px; }
  .pad { border-radius: 11px; --depth: 5px; }
}

@media (max-width: 550px) {
  .toolbar { align-items: stretch; gap: 7px; }
  .play-controls, .edit-controls { display: grid; grid-template-columns: 1fr 1fr; width: 100%; gap: 7px; }
  .volume { justify-content: center; }
  .action { padding-inline: 7px; }
  .edit-controls > button { min-width: 0; }
}

@media (orientation: landscape) and (max-height: 540px) {
  .main { padding-top: 8px; }
  .toolbar { margin-bottom: 8px; }
  .board { --pad-height: clamp(65px, calc((100svh - 166px) / 3), 100px); gap: 10px; }
  .pad { padding-block: 5px; }
  .pad-icon { font-size: 1.4rem; }
  .pad-label { font-size: clamp(.78rem, 2vw, 1.1rem); }
}

@media (prefers-reduced-motion: reduce) {
  .pad { transition: none; }
}
