:root {
  color-scheme: dark;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: #fbf3f8;
  background: #171019;
  --panel: #211824;
  --border: #49364b;
  --muted: #cbb9cb;
  --accent: #efbfd9;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body {
  margin: 0;
  min-height: 100dvh;
  background: radial-gradient(ellipse at 50% 0, #302033 0, #171019 29rem);
}
.shell {
  max-width: 52rem;
  margin: auto;
  padding: 0 max(1rem, env(safe-area-inset-right))
    max(1.75rem, env(safe-area-inset-bottom)) max(1rem, env(safe-area-inset-left));
}
.topbar, .section-heading { display: flex; align-items: center; gap: .75rem; }
.topbar {
  position: sticky;
  top: 0;
  z-index: 3;
  padding: max(.7rem, env(safe-area-inset-top)) 0 .65rem;
  background: #211624;
  border-bottom: 1px solid var(--border);
}
.topbar img { border-radius: .7rem; }
.brand { flex: 1; min-width: 0; }
.brand h1 { margin: 0; font-size: 1.06rem; line-height: 1.1; letter-spacing: .13em; }
.brand p, #connection { color: var(--muted); font-size: .8rem; }
.brand p { margin: .25rem 0 0; }
#connection { margin: .65rem 0 .85rem; }
#connection[data-paired="true"]::before {
  content: "";
  display: inline-block;
  width: .45rem;
  height: .45rem;
  margin-right: .45rem;
  border-radius: 50%;
  background: #b9deb9;
  vertical-align: .06rem;
}
.panel {
  padding: clamp(.9rem, 4vw, 1.4rem);
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 1.2rem;
}
h2, h3 { margin: 0; letter-spacing: -.04em; }
h2 { font-size: clamp(1.35rem, 5.5vw, 1.85rem); line-height: 1.08; }
h3 { font-size: 1.08rem; }
.pairing { max-width: 32rem; }
.pairing p, #studio-status, #player-status { color: var(--muted); line-height: 1.4; }
form { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: .45rem; align-items: end; }
label { grid-column: 1 / -1; font-size: .83rem; color: var(--muted); }
button, input, summary {
  min-height: 44px;
  border: 1px solid var(--border);
  border-radius: .7rem;
  font: inherit;
}
input { min-width: 0; color: inherit; background: #170f1a; padding: .55rem .65rem; }
input::placeholder { color: #bca9bd; }
button { color: inherit; cursor: pointer; }
.primary { color: #231523; background: var(--accent); padding: .5rem .9rem; font-weight: 700; }
.quiet { color: #f3dce9; background: transparent; font-size: .84rem; padding: .4rem .7rem; }
button:disabled { opacity: .65; cursor: wait; }
button:focus-visible, input:focus-visible, summary:focus-visible, [tabindex="0"]:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
#messages {
  max-height: min(14rem, 35svh);
  overflow-y: auto;
  overscroll-behavior-y: contain;
  margin: .65rem 0;
}
#messages:empty { margin: 0 0 .55rem; }
#messages p {
  margin: .4rem 0;
  padding: .6rem .7rem;
  background: #38263c;
  border-radius: .7rem;
  line-height: 1.4;
  overflow-wrap: anywhere;
}
#messages strong { color: var(--accent); margin-right: .25rem; }
.inbox summary { list-style: none; display: flex; align-items: center; cursor: pointer; }
.inbox summary::-webkit-details-marker { display: none; }
.inbox[open] summary { border-color: var(--accent); }
.inbox-panel {
  position: absolute;
  top: calc(100% + .4rem);
  right: 0;
  width: min(25rem, 100%);
  box-shadow: 0 .9rem 2rem #0d070fc9;
}
.inbox-panel h2 { font-size: 1.12rem; }
#inbox-status { color: var(--muted); font-size: .85rem; margin: .65rem 0 0; }
#inbox-status:empty { display: none; }
#inbox-items {
  max-height: min(20rem, 42svh);
  overflow-y: auto;
  overscroll-behavior-y: contain;
  list-style: none;
  margin: .65rem 0 0;
  padding: 0 .35rem 0 0;
}
#inbox-items li { border-top: 1px solid var(--border); padding: .65rem 0; line-height: 1.3; }
#inbox-items time { display: block; color: var(--muted); font-size: .76rem; margin-top: .2rem; }
.studio { min-width: 0; margin-top: 1.25rem; }
.section-heading { justify-content: space-between; margin-bottom: .45rem; }
.studio-actions, .visual-actions { display: flex; gap: .45rem; }
.visual-actions { flex-wrap: wrap; }
.show-rose { margin-top: .65rem; border-top: 1px solid var(--border); }
.show-rose summary { display: list-item; width: fit-content; border: 0; padding: .7rem 0; cursor: pointer; }
#visual-form { margin-top: .6rem; }
.batch-choice { display: flex; align-items: center; gap: .5rem; min-height: 44px; cursor: pointer; }
.batch-choice input { min-height: 0; width: 1.1rem; height: 1.1rem; accent-color: var(--accent); }
#visual-photos {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: .5rem;
}
#visual-photos.is-set { grid-template-columns: repeat(3, minmax(0, 1fr)); }
#visual-photos img {
  display: block;
  width: auto;
  max-width: 100%;
  max-height: 11rem;
  border-radius: .6rem;
  margin-bottom: .3rem;
}
#visual-photos.is-set img { width: 100%; aspect-ratio: 1; object-fit: cover; }
#visual-photos .quiet { width: 100%; padding: .3rem; }
#visual-status, #snapshot-status { font-size: .84rem; color: var(--muted); }
#visual-status:empty, #snapshot-status:empty, #snapshot-shelf:empty { display: none; }
#snapshot-shelf { margin-top: .65rem; }
.snapshot-card { min-width: 0; scroll-snap-align: start; }
.snapshot-card img { display: block; width: 100%; aspect-ratio: 16 / 10; object-fit: contain; background: #160f1a; border-radius: .5rem; }
.snapshot-card h4 { margin: .3rem 0; font-size: .9rem; overflow-wrap: anywhere; }
.snapshot-card p { color: var(--muted); margin: .25rem 0; font-size: .74rem; }
.snapshot-card a { color: var(--accent); font-size: .82rem; }
.rose-heading { margin-bottom: .2rem; }
#voice-start[data-active] { color: #251321; background: var(--accent); font-weight: 700; }
.reply-strip {
  display: flex;
  align-items: center;
  gap: .65rem;
  min-height: 3.25rem;
  margin-top: .65rem;
  padding: .3rem .65rem;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: .9rem;
}
#voice-meter { width: 4.25rem; height: 1.75rem; flex: none; }
#voice-playback-status { flex: 1; margin: 0; font-size: .88rem; font-weight: 650; }
.shelf {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(0, calc((100% - .7rem) / 2));
  gap: .7rem;
  overflow-x: auto;
  scroll-snap-type: x proximity;
  padding: .25rem .15rem .5rem;
}
.media-card {
  min-width: 0;
  display: block;
  padding: 0;
  overflow: hidden;
  text-align: left;
  background: var(--panel);
  border-radius: .95rem;
  scroll-snap-align: start;
}
.media-card[aria-expanded="true"] { border-color: var(--accent); }
.cover { position: relative; display: grid; place-items: center; aspect-ratio: 16 / 10; overflow: hidden; }
.video-cover { background: #302239; }
.video-cover img { position: absolute; width: 100%; height: 100%; object-fit: cover; }
.play-mark {
  display: grid;
  place-items: center;
  width: 2.2rem;
  height: 2.2rem;
  border-radius: 50%;
  background: #1a1021df;
  z-index: 1;
  font-size: .75rem;
}
.music-cover { background: radial-gradient(ellipse at 42% 32%, #713b68, #34233e 72%); }
.music-cover span {
  display: grid;
  place-items: center;
  width: 3rem;
  height: 3rem;
  color: #ffe1f0;
  border: 1px solid #e6aec977;
  border-radius: 50%;
  font-size: 1.6rem;
}
.media-caption { display: grid; gap: .3rem; padding: .7rem; }
.media-caption strong { font-size: .98rem; line-height: 1.15; }
.media-caption small { font-size: .74rem; color: var(--muted); }
.preview { margin-top: .55rem; }
.studio, .preview { scroll-margin-top: 5rem; }
.download {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  margin-top: .2rem;
  color: var(--accent);
  font-weight: 650;
  text-underline-offset: .18em;
}
.loudness-result { border-top: 1px solid var(--border); margin-top: .4rem; }
.loudness-result h4 { margin: .9rem 0 .6rem; }
.loudness-values { display: flex; flex-wrap: wrap; gap: .75rem 1.1rem; margin: 0; }
.loudness-values dt, .loudness-result figcaption, #research-sources p { color: var(--muted); font-size: .8rem; }
.loudness-values dd { margin: .25rem 0 0; font-weight: 700; font-variant-numeric: tabular-nums; }
.loudness-result figure { margin: .9rem 0 .25rem; }
#loudness-chart { display: block; width: 100%; height: auto; margin-top: .4rem; }
.chart-data summary { display: list-item; width: fit-content; padding: .55rem; cursor: pointer; }
.chart-data ul { columns: 2; padding-left: 1.25rem; font-size: .82rem; }
.research-result { margin-top: .8rem; scroll-margin-top: 5rem; }
#research-sources { list-style: none; padding: 0; margin: .6rem 0 0; }
#research-sources li + li { border-top: 1px solid var(--border); padding-top: .6rem; }
#research-sources a { color: var(--accent); overflow-wrap: anywhere; text-underline-offset: .16em; }
#research-sources p { margin: .3rem 0 .6rem; line-height: 1.4; overflow-wrap: anywhere; }
video, audio { display: block; width: 100%; margin-top: .55rem; }
video { background: #100b12; max-height: 56dvh; border-radius: .65rem; }
#player-status { font-size: .85rem; }
@media (max-width: 350px) {
  .topbar { gap: .45rem; }
  .shelf { grid-auto-columns: minmax(8.7rem, calc((100% - .7rem) / 2)); }
  .media-caption { padding: .55rem; }
  #pair-form { grid-template-columns: 1fr; }
}

#memo-form, .memo-entry-body, .memo-entry form { display: grid; gap: .5rem; }
#memo-form { margin-top: .7rem; }
#memo-preview, .memo-entry audio { width: 100%; }
#memo-library h3 { margin: .85rem 0 .4rem; }
.memo-entry { border-top: 1px solid var(--border); }
.memo-entry-body { padding: 0 0 .65rem; }
.memo-entry time { font-size: .8rem; }
.memo-entry p { margin: 0; overflow-wrap: anywhere; }
.memo-entry details form { margin-top: .4rem; }
#memo-song-help { margin: 0; font-size: .875rem; }
.song-folder { border-top: 1px solid var(--border); }
.song-writing { margin-top: .4rem; }
.song-editor { display: grid; gap: .45rem; margin-bottom: .75rem; }
.song-editor textarea {
  width: 100%;
  padding: .55rem;
  border: 1px solid var(--border);
  border-radius: .45rem;
  background: var(--panel);
  color: inherit;
  font: inherit;
  resize: vertical;
}
.song-editor p { margin: 0; }
.memo-entry .download { justify-self: start; }
#business-memo-form { display: grid; gap: .5rem; margin-top: .7rem; }
#business-memo-preview { width: 100%; }
#business-memo-song-help { margin: 0; font-size: .875rem; }
.idea-gallery { margin-top: .9rem; }
.idea-gallery h3, .idea-gallery h4 { margin: .65rem 0 .35rem; }
.idea-card { padding: .65rem; }
.idea-card strong, .idea-card small { display: block; overflow-wrap: anywhere; }
.idea-card small { color: var(--muted); margin-top: .25rem; }
.memo-entry p { white-space: pre-wrap; }

#memo-form, #business-memo-form, .memo-entry form, .song-editor {
  grid-template-columns: minmax(0, 1fr);
  align-items: start;
}
.memo-transport { align-items: center; }
.memo-transport button { min-height: 44px; }
.record-button {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  flex: 0 0 44px;
  padding: 0;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 50%;
}
.record-button span { display: block; width: 20px; height: 20px; border-radius: 50%; background: #ff556a; }
.record-button.is-recording { border-color: #ff556a; }
.memo-entry-body > button { justify-self: start; }
.memo-playback-stop { justify-self: start; }

.song-actions { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; padding-bottom: .6rem; }

.companion-navigation { margin:0 0 .85rem; }
.creator-studio-link {
  display:inline-flex;
  align-items:center;
  justify-content:space-between;
  gap:1rem;
  min-height:44px;
  text-decoration:none;
  padding:.5rem .8rem;
}
.creator-studio-link:focus-visible {
  outline:2px solid var(--accent);
  outline-offset:2px;
}
