/*
 * RAP STUDIO スマホ版。
 * 幅390px・片手操作を基準に、index.html と同じ色（黒地・赤・琥珀）でまとめる。
 */
:root {
  --bg: #0b0b0d;
  --panel: #15161a;
  --panel-2: #1c1e23;
  --line: #2b2e36;
  --text: #ece9e3;
  --muted: #948e83;
  --accent: #ff3d57;
  --accent-2: #4dd8c0;
  --accent-3: #e0a33f;
  --radius: 16px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html,
body {
  margin: 0;
  width: 100%;
  overflow-x: hidden;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, 'Hiragino Sans', 'Noto Sans JP', system-ui,
    sans-serif;
  font-size: 15px;
  line-height: 1.6;
  padding-bottom: calc(24px + var(--safe-bottom));
}

h1,
h2 {
  margin: 0;
}

button {
  font: inherit;
  color: inherit;
}

/* ---- トップ ---- */
.m-top {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: calc(14px + var(--safe-top)) 18px 12px;
}

.m-top-icon {
  font-size: 22px;
}

.m-top h1 {
  font-size: 18px;
  letter-spacing: 0.02em;
}

/* ---- 共通カード ---- */
.m-main {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 0 14px;
  max-width: 480px;
  margin: 0 auto;
}

.m-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
}

.m-card-title {
  font-size: 14px;
  color: var(--muted);
  margin-bottom: 10px;
  font-weight: 600;
}

/* ---- ビート選択 ---- */
.m-beat-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-bottom: 10px;
}

.m-beat-btn {
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px 6px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  min-height: 56px;
}

.m-beat-btn.is-active {
  border-color: var(--accent);
  background: rgba(255, 61, 87, 0.14);
}

.m-beat-name {
  font-size: 13px;
  font-weight: 600;
}

.m-beat-bpm {
  font-size: 11px;
  color: var(--muted);
}

.m-file-btn {
  display: block;
  text-align: center;
  padding: 12px;
  border: 1px dashed var(--line);
  border-radius: 12px;
  color: var(--muted);
  font-size: 13px;
}

.m-beat-current {
  margin-top: 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  font-size: 13px;
  color: var(--accent-2);
}

.m-beat-current span:first-child {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ---- 録音カード ---- */
.m-record-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 24px 16px;
}

.m-rec-btn {
  width: 128px;
  height: 128px;
  border-radius: 50%;
  border: none;
  background: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 10px 26px rgba(255, 61, 87, 0.35);
}

.m-rec-btn:disabled {
  background: var(--panel-2);
  box-shadow: none;
  opacity: 0.6;
}

.m-rec-dot {
  width: 44px;
  height: 44px;
  border-radius: 10px;
  background: #fff;
}

.m-rec-btn.is-counting .m-rec-dot,
.m-rec-btn.is-recording .m-rec-dot {
  border-radius: 50%;
}

.m-rec-btn.is-recording {
  animation: m-pulse 1.1s ease-in-out infinite;
}

@keyframes m-pulse {
  0%,
  100% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.05);
  }
}

.m-rec-status {
  margin-top: 16px;
  font-size: 14px;
  min-height: 1.6em;
}

.m-rec-live {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  margin-top: 6px;
}

#mRecTimer {
  font-variant-numeric: tabular-nums;
  color: var(--accent-3);
  font-size: 18px;
  font-weight: 700;
}

.m-level-meter {
  width: 100%;
  max-width: 260px;
  height: 10px;
  border-radius: 5px;
}

/* ---- 混ざった後 ---- */
.m-done {
  width: 100%;
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

.m-done-controls {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
}

.m-pill-btn {
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 12px 18px;
  font-size: 14px;
  min-height: 44px;
}

.m-pill-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  font-weight: 600;
}

.m-nudge-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: center;
}

.m-nudge-label {
  font-size: 12px;
  color: var(--muted);
}

/* ---- 設定 ---- */
.m-settings summary {
  font-size: 14px;
  color: var(--muted);
  font-weight: 600;
  cursor: pointer;
}

.m-settings[open] summary {
  margin-bottom: 12px;
}

.m-slider,
.m-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 12px;
  font-size: 13px;
}

.m-slider input[type='range'] {
  width: 100%;
  height: 32px;
}

.m-field select,
.m-field input {
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 10px;
  color: var(--text);
  padding: 10px;
  font-size: 14px;
  min-height: 40px;
}

/* ---- テイク一覧 ---- */
.m-takes {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.m-takes-empty {
  color: var(--muted);
  font-size: 13px;
  margin: 0;
}

.m-take {
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px 12px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.m-take-info {
  flex: 1;
  min-width: 0;
}

.m-take-date {
  font-size: 12px;
  color: var(--muted);
}

.m-take-dur {
  font-size: 12px;
  color: var(--accent-3);
}

.m-take-actions {
  display: flex;
  gap: 6px;
}

.m-mini-btn {
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 12px;
  min-height: 36px;
}

/* ---- ヘルパー ---- */
.hidden {
  display: none !important;
}

.m-toast {
  position: fixed;
  left: 16px;
  right: 16px;
  bottom: calc(16px + var(--safe-bottom));
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px 14px;
  font-size: 13px;
  text-align: center;
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.5);
  z-index: 20;
}

.m-toast.is-error {
  border-color: var(--accent);
  color: #ffd7dc;
}
