/* ---------- Mobile toolbar ---------- */
.mobile-bar {
  display: none;
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 20;
  background: var(--wall);
  border-top: 1px solid var(--line);
  padding: 0 12px calc(12px + env(safe-area-inset-bottom));
}

.mb-progress {
  height: 2px;
  background: var(--line);
  margin: 0 -12px;
}

.mb-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 0 8px;
}

.mb-icon {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--ink);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  cursor: pointer;
}

.mb-help {
  font-family: var(--serif);
  font-size: 1.15rem;
}

.mb-icon svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.mb-icon .i-play path { fill: currentColor; stroke: none; }
.mb-icon .i-play,
.mb-icon .i-pause { display: none; }

#mbTrack[data-state="playing"] { background: var(--ink); color: var(--wall); border-color: var(--ink); }
#mbTrack[data-state="playing"] .i-note,
#mbTrack[data-state="paused"] .i-note { display: none; }
#mbTrack[data-state="playing"] .i-pause { display: block; }
#mbTrack[data-state="paused"] .i-play { display: block; }

#mbMic.active { border-color: var(--accent); color: var(--accent); }

.mb-info {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  line-height: 1.25;
}

.mb-time { font-family: var(--serif); font-size: 1rem; }

.mb-note {
  font-size: 0.7rem;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.mb-dots { display: flex; }

.mb-dots span {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  margin-left: -3px;
  border: 1px solid var(--wall);
}

.mb-dots span:first-child { margin-left: 0; }

.mb-brushes {
  display: flex;
  gap: 4px;
  overflow-x: auto;
  scroll-snap-type: x proximity;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}

.mb-brushes::-webkit-scrollbar { display: none; }

.mb-brushes .pick {
  flex: 0 0 auto;
  min-width: 64px;
  min-height: 36px;
  justify-content: center;
  scroll-snap-align: center;
  font-size: 0.8rem;
  padding: 0.4rem 0.7rem;
}

/* ---------- Mobile sheet ---------- */
.sheet-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(31, 31, 31, 0.3);
  z-index: 30;
}

.sheet {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 31;
  background: var(--wall);
  border-top: 1px solid var(--line);
  border-radius: 18px 18px 0 0;
  padding: 10px 16px calc(16px + env(safe-area-inset-bottom));
  max-height: 85vh;
  overflow-y: auto;
  transform: translateY(105%);
  transition: transform 0.28s ease;
}

.sheet.open { transform: none; }

.sheet-handle {
  width: 36px;
  height: 4px;
  border-radius: 2px;
  background: #d3cfc4;
  margin: 0 auto 12px;
}

.sheet-title {
  font-family: var(--serif);
  font-size: 1.35rem;
  margin-bottom: 14px;
}

.sheet-section + .sheet-section { margin-top: 18px; }

.sheet-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 10px;
}

.sheet-note {
  font-family: var(--serif);
  font-style: italic;
  color: var(--muted);
  font-size: 0.9rem;
}

.sheet-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 6px;
}

.sheet-list .pick {
  justify-content: flex-start;
  min-height: 44px;
  font-family: var(--serif);
  font-size: 1rem;
}

.sheet-size {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 18px;
}

.sheet-size .tool-label {
  width: 6.5rem;
  flex-shrink: 0;
}

.sheet-done {
  width: 100%;
  margin-top: 16px;
  min-height: 44px;
  background: var(--ink);
  color: var(--wall);
  border: none;
  font-family: var(--serif);
  font-size: 1.05rem;
  cursor: pointer;
}

/* ---------- Screen-size rules ---------- */
@media (max-width: 899px) {
  body.view-studio .mobile-bar { display: block; }
  body.view-studio { padding-bottom: calc(132px + env(safe-area-inset-bottom)); }
  body.view-studio .toast { bottom: calc(140px + env(safe-area-inset-bottom)); }
  .tools,
  .hint,
  .desktop-only { display: none !important; }
  .swipe-hint.show { display: block; }
}

@media (min-width: 900px) {
  .sheet,
  .sheet-backdrop { display: none !important; }
}

@media (max-width: 480px) {
  .actions { gap: 0 1.25rem; }
}