:root {
  color-scheme: dark;
  font-family: "Instrument Sans", "Geist", "Inter", "Hiragino Sans", "Yu Gothic", "Meiryo", system-ui, sans-serif;
  --canvas: #080e1c;
  --panel: #101a2e;
  --field: #0a1325;
  --line: #304060;
  --text: #f3f6ff;
  --muted: #b5c4df;
  --accent: #f0c98e;
  --accent-hover: #ffe0af;
  --accent-line: #96764f;
  --accent-shade: #40332a;
  --green: #a1e1cf;
  --error: #ffb4b5;
  --round: 15px;
  --hero-height: 364px;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html { min-width: 280px; min-height: 100%; background: var(--canvas); }
body {
  position: relative;
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  background: radial-gradient(ellipse at 86% 330px, #131f3d 0%, transparent 58%), var(--canvas);
}
.hero-backdrop {
  position: absolute;
  inset: 0 0 auto;
  height: var(--hero-height);
  pointer-events: none;
  background-color: #0f214b;
  background-image: linear-gradient(0deg, var(--canvas) 0%, #080e1c99 15%, #080e1c00 48%),
    linear-gradient(90deg, #070c1aef 0%, #091329c7 31%, #0c1a3754 56%, #09142b16 76%, #080d1e4f 100%),
    url("./sky-lounge.webp");
  background-position: center, center, center 52%;
  background-repeat: no-repeat;
  background-size: cover;
}
a { color: inherit; }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: default; opacity: .48; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
::selection { background: var(--accent); color: #241b0c; }
h1, h2, h3, p { margin: 0; }
legend { padding: 0; }

.shell { position: relative; width: min(100% - 72px, 1150px); margin-inline: auto; }
.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  min-height: 72px;
  border-bottom: 1px solid #d4e1ff29;
}
.brand { display: inline-flex; align-items: center; font-size: 24px; font-weight: 800; text-decoration: none; letter-spacing: -.052em; }
.brand > span:last-child { color: var(--accent); }
.brand-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 3px;
  width: 34px;
  height: 34px;
  margin-right: 10px;
  border: 1px solid #cfa9758f;
  border-radius: 9px;
  color: var(--accent);
  background: #9a74462e;
  box-shadow: 0 0 17px #ebb47729;
}
.brand-mark i { width: 3px; height: 14px; border-radius: 2px; background: currentColor; }
.brand-mark i:nth-child(1), .brand-mark i:nth-child(4) { height: 7px; }
.brand-mark i:nth-child(3) { height: 19px; }
.header-nav { display: flex; flex-wrap: wrap; gap: 14px; align-items: center; }
.header-link { color: #e0e9fb; font-size: 13px; font-weight: 700; text-decoration: none; }
.header-link:hover { color: var(--text); text-decoration: underline; }
.site-header .secondary { border-color: #bacbfd45; background: #0b1528a8; color: #e0e9fb; }

main { padding: 0 0 64px; }
.heading {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: flex-start;
  min-height: 244px;
  margin-bottom: 15px;
  padding-top: 12px;
}
.heading h1 {
  font-size: clamp(32px, 4.52vw, 57px);
  line-height: 1.2;
  letter-spacing: .012em;
  font-weight: 760;
  text-wrap: balance;
  text-shadow: 0 3px 29px #020610e6;
}
.heading p {
  max-width: 34em;
  margin-top: 13px;
  color: #dbe6fb;
  line-height: 1.7;
  text-shadow: 0 2px 16px #020610;
}
.workspace { display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr); align-items: start; gap: 20px; }
.panel {
  min-width: 0;
  padding: clamp(17px, 2.5vw, 26px);
  border: 1px solid var(--line);
  border-radius: var(--round);
  background: linear-gradient(145deg, #172544 0%, var(--panel) 45%, #0c1528 100%);
  box-shadow: inset 0 1px #e1ecff0a, 0 13px 30px #02061147;
}
.panel-heading { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.panel-heading h2 { font-size: 19px; letter-spacing: .02em; }
.generator > .panel-heading { margin-bottom: 21px; flex-wrap: wrap; }
.sidebar { display: grid; gap: 20px; min-width: 0; }
.segmented { display: flex; gap: 2px; padding: 3px; border: 1px solid var(--line); border-radius: 9px; background: var(--field); }
.segmented button { padding: 7px 11px; border: 1px solid transparent; border-radius: 6px; background: transparent; color: var(--muted); font-size: 13px; font-weight: 700; white-space: nowrap; }
.segmented button[aria-pressed=true] { border-color: #a383574f; color: var(--accent); background: var(--accent-shade); }
.segmented button:hover { color: var(--accent-hover); }

.fields, .formats { min-width: 0; margin: 0; padding: 0; border: 0; }
.fields > legend, .formats > legend, .field, .tempo-heading label { font-size: 13px; font-weight: 700; }
.fields > legend, .formats > legend { margin-bottom: 9px; }
.moods { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; margin-bottom: 16px; }
.mood {
  position: relative;
  display: grid;
  min-height: 68px;
  grid-template-rows: 20px auto;
  justify-items: center;
  align-content: center;
  gap: 7px;
  padding: 9px 4px;
  border: 1px solid var(--line);
  border-radius: 10px;
  color: var(--muted);
  background: var(--field);
  font-size: clamp(11px, 1.16vw, 13px);
  text-align: center;
  cursor: pointer;
}
.mood:hover { border-color: #7d95bd; color: var(--text); }
.mood:has(input:checked) { border-color: var(--accent-line); color: var(--accent); background: linear-gradient(145deg, #49382f, #302a31); font-weight: 700; }
.mood:has(input:focus-visible) { outline: 2px solid var(--accent); outline-offset: 3px; }
.mood input { position: absolute; clip-path: inset(50%); width: 1px; height: 1px; }
.mood-icon { width: 17px; height: 17px; align-self: center; color: currentColor; }
.mood-icon.calm { width: 20px; height: 9px; border-bottom: 2px solid; border-radius: 50%; box-shadow: 0 4px 0 -2px currentColor; }
.mood-icon.bright { background: currentColor; clip-path: polygon(50% 0%, 60% 34%, 83% 17%, 67% 42%, 100% 50%, 67% 59%, 83% 83%, 60% 65%, 50% 100%, 40% 65%, 17% 83%, 33% 59%, 0 50%, 33% 42%, 17% 17%, 40% 34%); }
.mood-icon.mystery { border-radius: 50%; border-left: 7px solid; transform: rotate(-28deg); }
.mood-icon.dramatic { background: currentColor; clip-path: polygon(53% 0, 96% 0, 68% 42%, 91% 42%, 20% 100%, 42% 52%, 14% 52%); }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.bgm-form-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.phrase-options { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.phrase-options .unit-field input { padding-right: 46px; }
.phrase-toolbar { display: flex; align-items: end; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
.phrase-toolbar .button { min-height: 42px; }
.phrase-scroll {
  max-width: 100%;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--field);
  overscroll-behavior-inline: contain;
  scroll-padding-inline-start: 63px;
}
.phrase-grid {
  width: 100%;
  min-width: calc(63px + var(--phrase-steps, 8) * 27px);
  border-collapse: separate;
  border-spacing: 0;
  table-layout: fixed;
  text-align: center;
  font-size: 11px;
}
.phrase-grid col:first-child { width: 63px; }
.phrase-grid thead th { height: 21px; color: var(--muted); background: #212d41; }
.phrase-grid .pitch-label {
  position: sticky;
  left: 0;
  z-index: 1;
  padding-inline: 4px;
  border-right: 1px solid #43526c;
  background: #1d283a;
  color: var(--text);
  white-space: nowrap;
}
.phrase-grid .pitch-label small { margin-left: 3px; color: var(--muted); font-size: 9px; font-weight: 400; }
.phrase-grid tbody td, .phrase-grid tbody th { border-top: 1px solid #29364b; }
.phrase-grid tbody td { height: 24px; padding: 0; border-right: 1px solid #29364b; }
.phrase-grid .bar-start { border-left: 2px solid #586d8a; }
.phrase-grid .beat-start:not(.bar-start) { border-left: 1px solid #3e506b; }
.phrase-grid .is-sharp td { background: #182131; }
.phrase-cell { display: block; width: 100%; min-height: 23px; padding: 0; border: 0; border-radius: 0; color: var(--text); background: transparent; }
.phrase-cell:hover, .phrase-grid .is-play-position { background: #2e4660; }
.phrase-cell.is-hold { background: #a47749; }
.phrase-cell.is-head { background: var(--accent); }
.phrase-cell.is-play-position:is(.is-head,.is-hold) { box-shadow: inset 0 0 0 2px #ffffffc9; }
.phrase-cell:focus-visible { position: relative; z-index: 1; outline-offset: -2px; }
#reopen-phrase { margin-top: 10px; }
.mix-add-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: stretch; gap: 8px; }
.mix-tracks { display: grid; gap: 8px; list-style: none; margin: 0; padding: 0; }
.mix-track {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(75px, .45fr) minmax(75px, .45fr) auto;
  align-items: end;
  gap: 8px;
  padding: 9px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--field);
}
.mix-track-name { align-self: center; font-size: 13px; line-height: 1.5; overflow-wrap: anywhere; }
.mix-track .button { min-height: 42px; }
.mix-track .field { gap: 4px; }
.mix-track .unit-field input { padding-right: 28px; }
.mix-track .unit-field > span { right: 9px; }
.advanced.mix-title-only .form-grid { grid-template-columns: minmax(0, 1fr); }
.field { display: grid; min-width: 0; align-content: start; gap: 8px; }
input[type=text], input[type=password], input[type=number], select, textarea {
  appearance: auto;
  width: 100%;
  min-width: 0;
  min-height: 42px;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 9px;
  color: var(--text);
  background: var(--field);
  font-size: 14px;
  font-weight: 500;
}
input::placeholder, textarea::placeholder { color: #8c9cb6; }
.lyria-quota { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 8px; margin: 0 0 16px; padding: 12px; border: 1px solid var(--accent-line); border-radius: 9px; background: var(--accent-shade); }
.lyria-quota p { color: var(--accent-hover); font-size: 13px; line-height: 1.6; }
.lyria-controls { display: grid; gap: 16px; }
.lyria-controls .hint { margin: 0; }
.lyria-controls textarea { resize: vertical; line-height: 1.6; }
.lyria-voices { display: flex; flex-wrap: wrap; gap: 8px; }
.lyria-voices label { padding: 8px 12px; border: 1px solid var(--line); border-radius: 8px; background: var(--field); cursor: pointer; font-size: 13px; }
.lyria-voices label:has(input:checked) { border-color: var(--accent-line); color: var(--accent); }
.lyria-voices input { margin: 0; accent-color: var(--accent); }
.unit-field { position: relative; }
.unit-field input { padding-right: 34px; }
.unit-field > span { position: absolute; right: 12px; top: 50%; transform: translateY(-50%); color: var(--muted); font-weight: 400; pointer-events: none; }
.tempo { margin-top: 17px; }
.tempo-heading, .range-labels { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.tempo output { color: var(--accent); font-family: "IBM Plex Mono", ui-monospace, monospace; font-size: 13px; font-weight: 700; }
input[type=range] { width: 100%; height: 22px; margin: 7px 0 0; accent-color: var(--accent); }
.range-labels { color: var(--muted); font-size: 11px; }
.switch-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 16px;
  padding: 11px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--field);
  cursor: pointer;
}
.switch-row strong { display: block; font-size: 13px; }
.switch-row small { display: block; color: var(--muted); margin-top: 2px; line-height: 1.5; }
input[type=checkbox] { margin: 0; accent-color: var(--accent); }
.switch-row input {
  appearance: none;
  position: relative;
  width: 39px;
  height: 22px;
  flex: 0 0 39px;
  border: 1px solid #60708c;
  border-radius: 16px;
  background: #334257;
  cursor: pointer;
}
.switch-row input::after { content: ""; position: absolute; width: 14px; height: 14px; left: 3px; top: 3px; border-radius: 50%; background: #e5eefc; }
.switch-row input:checked { border-color: #4caf94; background: #275b50; }
.switch-row input:checked::after { left: 20px; background: var(--green); }
.formats { margin-top: 18px; }
.format-options { display: flex; gap: 8px; flex-wrap: wrap; }
.format-options label {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--field);
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
}
.format-options label:has(input:checked) { border-color: var(--accent-line); color: var(--accent); }
.advanced { margin-top: 13px; border-top: 1px solid var(--line); }
.advanced summary { padding: 10px 0; color: var(--muted); font-size: 13px; font-weight: 700; cursor: pointer; }
.advanced summary:hover { color: var(--text); }
.hint { margin: 8px 0; color: var(--muted); font-size: 12px; }
.inline-error { color: var(--error); font-size: 13px; margin-top: 10px; line-height: 1.6; }
.inline-error:empty { display: none; }
.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 34px;
  padding: 6px 12px;
  border: 1px solid transparent;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 750;
  text-decoration: none;
  white-space: nowrap;
}
.primary {
  border-color: #e4b879;
  color: #21170d;
  background: linear-gradient(115deg, #f6d7a1, #d8a568);
  box-shadow: inset 0 1px #ffffff47, 0 4px 16px #dda76325;
}
.primary:hover:not(:disabled) { background: var(--accent-hover); border-color: var(--accent-hover); }
.secondary { border-color: var(--line); color: var(--muted); background: var(--field); }
.secondary:hover:not(:disabled) { color: var(--text); border-color: #6e819c; }
.generate-button { width: 100%; min-height: 48px; margin-top: 9px; font-size: 15px; }

.access-panel {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(220px, 1fr);
  align-items: center;
  gap: 10px 16px;
  margin-bottom: 20px;
  padding: 16px 20px;
  border: 1px solid #80664b;
  border-radius: 12px;
  background: linear-gradient(120deg, #252330, #141d33);
  box-shadow: inset 0 1px #ead5b616;
}
.access-panel h2 { font-size: 16px; }
.access-panel p { color: #dcd4ca; margin-top: 4px; font-size: 13px; line-height: 1.65; }
.access-panel .inline-error { grid-column: 1/-1; color: var(--error); }
.access-form { display: flex; gap: 8px; }
.access-form .button { min-width: 67px; }
.member-login { justify-self: end; text-align: center; }
.admin-access { grid-column: 1/-1; color: var(--muted); font-size: 13px; }
.admin-access summary { cursor: pointer; width: fit-content; }
.admin-access .access-form { max-width: 470px; margin-top: 10px; }
.member-name { max-width: 14em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); font-size: 12px; }
.member-limits { margin: 0 0 13px; color: var(--muted); font-size: 12px; line-height: 1.7; }
.result-empty { display: grid; justify-items: center; align-content: center; gap: 11px; min-height: 144px; color: var(--muted); text-align: center; font-size: 13px; }
.sound-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 3px;
  width: 49px;
  height: 49px;
  border-radius: 12px;
  border: 1px solid #b4906261;
  background: linear-gradient(155deg, #453440, #293248);
  box-shadow: 0 5px 16px #bea66718;
}
.sound-icon i { width: 3px; height: 19px; border-radius: 2px; background: #c09d77; }
.sound-icon i:nth-child(1), .sound-icon i:nth-child(5) { height: 9px; }
.sound-icon i:nth-child(3) { height: 28px; background: var(--accent); }
.status { padding: 4px 8px; border: 1px solid #665334; border-radius: 6px; color: var(--accent); background: #342a20; font-size: 11px; font-weight: 750; white-space: nowrap; }
.status[data-status=ready] { border-color: #416455; color: var(--green); background: #213a32; }
.status[data-status=failed] { border-color: #805661; color: var(--error); background: #3c272f; }
#result-track { margin-top: 16px; }
#track-title { font-size: 19px; overflow-wrap: anywhere; }
.track-meta, .track-message, .history-message { color: var(--muted); font-size: 13px; line-height: 1.6; }
.track-meta { margin-top: 5px; overflow-wrap: anywhere; }
.track-message { margin-top: 9px; }
.track-message.is-error { color: var(--error); }
.track-message:empty, .history-message:empty { display: none; }
#track-audio { display: block; width: 100%; height: 42px; margin-top: 15px; }
.downloads { display: flex; flex-wrap: wrap; gap: 6px; }
.downloads:not(:empty) { margin-top: 13px; }
.downloads a { color: var(--green); }
#poll-retry { margin-top: 10px; }
#lyria-clip { margin-top: 16px; }
.history { scroll-margin-top: 15px; }
.history-message { margin-top: 12px; }
.history-list { list-style: none; margin: 0; padding: 0; }
.history-list:not(:empty) { margin-top: 9px; }
.history-item + .history-item { border-top: 1px solid var(--line); }
.history-button {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 7px;
  width: 100%;
  padding: 9px 8px;
  border: 1px solid transparent;
  border-radius: 7px;
  color: var(--text);
  background: transparent;
  text-align: left;
}
.history-button:hover, .history-button[aria-current=true] { background: #233553; border-color: #455d83; }
.history-name { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; }
.history-detail { display: block; margin-top: 3px; color: var(--muted); font-size: 11px; overflow-wrap: anywhere; }
.history-button .status { justify-self: end; }
.sr-only { position: absolute; width: 1px; height: 1px; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

@media (max-width: 800px) {
  .workspace { grid-template-columns: minmax(0, 1fr); }
  .shell { width: calc(100% - 36px); }
  .mood { font-size: 13px; }
  .hero-backdrop { background-position: center, center, 68% 53%; }
}
@media (max-width: 540px) {
  :root { --hero-height: 326px; }
  .shell { width: calc(100% - 24px); }
  .site-header { min-height: 65px; }
  .header-nav { gap: 8px; }
  .hero-backdrop {
    background-image: linear-gradient(0deg, var(--canvas) 0%, #080e1c9c 24%, #080e1c00 66%),
      linear-gradient(90deg, #081224d4, #101d3a82 64%, #0a132358), url("./sky-lounge.webp");
    background-position: center, center, 82% center;
  }
  .heading { min-height: 219px; margin-bottom: 10px; padding-top: 6px; }
  .heading h1 { max-width: 13em; font-size: 32px; }
  .heading p { font-size: 14px; }
  .workspace, .sidebar { gap: 13px; }
  .access-panel { grid-template-columns: minmax(0, 1fr); padding: 13px; }
  .access-panel .inline-error { grid-column: auto; }
  .member-login { justify-self: stretch; }
  .member-name { max-width: 5em; }
  .panel-heading h2 { font-size: 16px; }
  .segmented { max-width: 100%; flex-wrap: wrap; }
  .segmented button { padding-inline: 8px; }
  .mood { font-size: 11px; }
  .bgm-form-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .bgm-form-grid > .field:last-child { grid-column: 1/-1; }
  .phrase-options { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .phrase-options > .field:last-child { grid-column: 1/-1; }
  .mix-track { grid-template-columns: repeat(2, minmax(0, 1fr)) auto; }
  .mix-track-name { grid-column: 1/-1; }
}
@media (max-width: 340px) {
  .heading h1 { font-size: 29px; }
  .moods { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .form-grid { grid-template-columns: minmax(0, 1fr); }
}
