:root {
  --bg: #f6f7fb;
  --panel: #ffffff;
  --ink: #17202a;
  --muted: #647080;
  --line: #d9dee8;
  --teal: #0e7c7b;
  --teal-dark: #095f5f;
  --coral: #c94f3d;
  --blue: #3857a6;
  --gold: #a46a15;
  --shadow: 0 18px 38px rgba(24, 34, 49, 0.1);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font-family:
    "Yu Gothic UI",
    "Hiragino Sans",
    "Noto Sans JP",
    system-ui,
    sans-serif;
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  display: grid;
  grid-template-columns: 292px minmax(0, 1fr);
  min-height: 100vh;
}

.side-panel {
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  padding: 24px 18px;
  background: #101820;
  color: #f8fbff;
  border-right: 1px solid #1d2a35;
}

.brand {
  padding: 4px 2px 22px;
}

.mobile-brand {
  display: none;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--coral);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

.brand h1 {
  margin: 0;
  font-size: 2rem;
  line-height: 1;
}

.control-block {
  margin-top: 22px;
}

.control-block h2,
.builder-section h3 {
  margin: 0 0 10px;
  font-size: 0.95rem;
}

.field {
  display: grid;
  gap: 7px;
  margin-bottom: 14px;
}

.field span,
.range-field span,
.preview-box span {
  color: inherit;
  font-size: 0.8rem;
  font-weight: 700;
}

.side-panel .field span,
.side-panel .range-field span {
  color: #c7d1dc;
}

input,
select {
  width: 100%;
  min-height: 42px;
  padding: 9px 11px;
  color: var(--ink);
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: 8px;
}

input:focus,
select:focus,
button:focus-visible {
  outline: 3px solid rgba(14, 124, 123, 0.28);
  outline-offset: 2px;
}

.category-list {
  display: grid;
  gap: 8px;
}

.category-button {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 10px;
  min-height: 38px;
  padding: 8px 10px;
  color: #f8fbff;
  background: #17232d;
  border: 1px solid #2c3b48;
  border-radius: 8px;
  text-align: left;
}

.category-button.is-active {
  background: #f8fbff;
  color: #101820;
  border-color: #f8fbff;
}

.category-button b {
  min-width: 28px;
  padding: 2px 6px;
  color: #101820;
  background: #f1b247;
  border-radius: 8px;
  text-align: center;
  font-size: 0.78rem;
}

.range-field {
  display: grid;
  grid-template-columns: 44px 1fr 42px;
  align-items: center;
  gap: 8px;
  margin-bottom: 14px;
}

.range-field input {
  min-height: 26px;
  padding: 0;
}

.range-field b {
  color: #f8fbff;
  font-size: 0.84rem;
  text-align: right;
}

.segmented {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  padding: 4px;
  margin-bottom: 12px;
  background: #17232d;
  border: 1px solid #2c3b48;
  border-radius: 8px;
}

.segmented button {
  min-height: 34px;
  color: #c7d1dc;
  background: transparent;
  border: 0;
  border-radius: 6px;
}

.segmented button.is-active {
  color: #101820;
  background: #f8fbff;
}

.main-panel {
  min-width: 0;
  padding: 24px;
}

.status-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  min-height: 76px;
  padding: 16px 18px;
  margin-bottom: 20px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.status-label {
  margin: 0 0 3px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
}

.now-playing {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 800;
  overflow-wrap: anywhere;
}

.voice-status {
  flex: 0 0 auto;
  max-width: 42%;
  margin: 0;
  color: var(--muted);
  font-size: 0.84rem;
  text-align: right;
}

.workspace-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  gap: 20px;
  align-items: start;
}

.sampler-section,
.builder-section {
  min-width: 0;
}

.builder-section {
  position: sticky;
  top: 24px;
  padding: 18px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.section-heading {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 14px;
}

.section-heading h2 {
  margin: 0;
  font-size: 1.55rem;
}

.count-label {
  margin: 0;
  color: var(--muted);
  font-weight: 800;
}

.phrase-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: 12px;
}

.phrase-button {
  position: relative;
  display: grid;
  grid-template-rows: auto 1fr auto;
  gap: 9px;
  min-height: 138px;
  padding: 14px;
  color: var(--ink);
  background: var(--panel);
  border: 1px solid var(--line);
  border-top: 5px solid var(--teal);
  border-radius: 8px;
  box-shadow: 0 8px 22px rgba(24, 34, 49, 0.08);
  text-align: left;
}

.phrase-button:hover {
  transform: translateY(-1px);
  border-color: #b9c2d0;
}

.phrase-button:active {
  transform: translateY(0);
}

.phrase-button.is-playing {
  border-color: var(--coral);
  border-top-color: var(--coral);
  box-shadow: 0 12px 28px rgba(201, 79, 61, 0.18);
}

.phrase-jp,
.phrase-main {
  color: var(--ink);
  font-size: 0.96rem;
  font-weight: 800;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.phrase-hi,
.phrase-sub {
  color: #293749;
  font-size: 1.08rem;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.phrase-main {
  font-size: 1.06rem;
}

.phrase-sub {
  color: var(--muted);
  font-size: 0.95rem;
}

.phrase-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
}

.phrase-play {
  color: var(--teal-dark);
}

.phrase-button[data-color="coral"] {
  border-top-color: var(--coral);
}

.phrase-button[data-color="blue"] {
  border-top-color: var(--blue);
}

.phrase-button[data-color="gold"] {
  border-top-color: var(--gold);
}

.template-fields {
  display: grid;
  gap: 12px;
  margin: 10px 0 14px;
}

.preview-box {
  display: grid;
  gap: 5px;
  padding: 12px;
  margin: 14px 0;
  background: #f4f7f9;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.preview-box span {
  color: var(--muted);
}

.preview-box strong {
  min-height: 25px;
  font-size: 1rem;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.button-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.primary-button,
.secondary-button {
  min-height: 42px;
  padding: 9px 12px;
  border-radius: 8px;
  font-weight: 800;
}

.primary-button {
  color: #ffffff;
  background: var(--teal);
  border: 1px solid var(--teal);
}

.primary-button:hover {
  background: var(--teal-dark);
}

.secondary-button {
  color: var(--ink);
  background: #ffffff;
  border: 1px solid var(--line);
}

.side-panel .secondary-button {
  width: 100%;
  color: #f8fbff;
  background: #263545;
  border-color: #34475a;
}

.custom-form {
  display: grid;
  gap: 2px;
  margin-top: 22px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
}

.empty-state {
  padding: 22px;
  color: var(--muted);
  background: var(--panel);
  border: 1px dashed var(--line);
  border-radius: 8px;
}

@media (max-width: 980px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .side-panel {
    position: static;
    order: 2;
    height: auto;
  }

  .main-panel {
    order: 1;
  }

  .mobile-brand {
    display: block;
    margin: 0 0 16px;
  }

  .mobile-brand h1 {
    margin: 0;
    font-size: 1.85rem;
    line-height: 1;
  }

  .category-list {
    grid-template-columns: repeat(auto-fit, minmax(132px, 1fr));
  }

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

  .builder-section {
    position: static;
  }
}

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

  .status-bar {
    align-items: flex-start;
    flex-direction: column;
  }

  .voice-status {
    max-width: 100%;
    text-align: left;
  }

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