/*
 * 見た目の方針：機材のパネル。
 * 録音の赤・メーターの琥珀・目盛のオフホワイトという、
 * スタジオのハードウェアが持っている色だけで作る。
 */
:root {
  --bg: #0b0b0d;
  --panel: #15161a;
  --panel-2: #1c1e23;
  --line: #2b2e36;
  --text: #ece9e3;
  --muted: #948e83;
  --accent: #ff3d57;
  --accent-2: #4dd8c0;
  --accent-3: #e0a33f;
  --accent-3-ink: #1a1408;
  --radius: 14px;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  height: 100%;
}

body {
  background: radial-gradient(1100px 520px at 12% -12%, #241a08 0%, transparent 62%),
    radial-gradient(760px 420px at 108% -4%, #2a0d12 0%, transparent 58%), var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, 'Hiragino Sans', 'Noto Sans JP', system-ui,
    sans-serif;
  font-size: 14px;
  line-height: 1.6;
  display: flex;
  flex-direction: column;
}

h1,
h2,
h3 {
  margin: 0;
  letter-spacing: 0.01em;
}

/* ---- トップバー ---- */
.topbar {
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 12px 20px;
  border-bottom: 1px solid var(--line);
  background: rgba(10, 12, 17, 0.85);
  backdrop-filter: blur(12px);
  flex-wrap: wrap;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 240px;
}

.brand-mark {
  font-size: 28px;
  filter: drop-shadow(0 0 12px rgba(255, 61, 87, 0.5));
}

.topbar h1 {
  font-size: 18px;
  font-weight: 800;
  letter-spacing: 0.12em;
}

.brand-sub {
  margin: 0;
  font-size: 11px;
  color: var(--muted);
}

.topbar-fields {
  display: flex;
  gap: 10px;
  align-items: flex-end;
  flex: 1;
}

.topbar-actions {
  display: flex;
  gap: 8px;
}

/* ---- 汎用 ---- */
.field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 11px;
  color: var(--muted);
}

.field-narrow {
  max-width: 130px;
}

input[type='text'],
input[type='search'],
input[type='number'],
input[type='password'],
select,
textarea {
  background: var(--panel-2);
  border: 1px solid var(--line);
  color: var(--text);
  border-radius: 9px;
  padding: 8px 10px;
  font: inherit;
  width: 100%;
  outline: none;
  transition: border-color 0.15s ease;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--accent-3);
}

.btn {
  background: var(--panel-2);
  border: 1px solid var(--line);
  color: var(--text);
  border-radius: 10px;
  padding: 8px 14px;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.08s ease, border-color 0.15s ease, background 0.15s ease;
  white-space: nowrap;
}

.btn:hover {
  border-color: #3b445c;
  background: #1d2230;
}

.btn:active {
  transform: translateY(1px);
}

.btn-primary {
  background: var(--accent-3);
  border-color: #f2bc63;
  color: var(--accent-3-ink);
}

.btn-primary:hover {
  background: #f0b355;
  border-color: #f7cd85;
}

.btn-ghost {
  background: transparent;
}

.btn-sm {
  padding: 5px 10px;
  font-size: 12px;
}

.btn-lg {
  padding: 11px 18px;
}

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.hint {
  color: var(--muted);
  font-size: 12px;
  margin: 6px 0;
}

.hint-inline {
  color: var(--muted);
  font-size: 12px;
}

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

.row-end {
  justify-content: flex-end;
}

.hidden {
  display: none !important;
}

.check {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 13px;
  cursor: pointer;
  user-select: none;
}

.check input {
  width: 16px;
  height: 16px;
  accent-color: var(--accent-3);
}

.slider {
  display: block;
  font-size: 12px;
  color: var(--muted);
}

.slider input[type='range'] {
  width: 100%;
  accent-color: var(--accent-3);
}

.slider em {
  font-style: normal;
  color: var(--text);
  font-weight: 700;
}

/* ---- レイアウト ---- */
.layout {
  flex: 1;
  display: grid;
  grid-template-columns: 340px 1fr;
  gap: 16px;
  padding: 16px 20px 28px;
  align-items: start;
  min-height: 0;
}

.panel {
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.02), transparent), var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
}

.panel-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
  gap: 10px;
}

.panel-head h2 {
  font-size: 14px;
}

/* ---- タブ ---- */
.tabs {
  display: flex;
  gap: 4px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 4px;
  margin-bottom: 14px;
  width: fit-content;
}

.tabs-sm {
  margin-bottom: 0;
}

.tab {
  background: transparent;
  border: 0;
  color: var(--muted);
  font: inherit;
  font-weight: 700;
  padding: 7px 14px;
  border-radius: 9px;
  cursor: pointer;
}

.tabs-sm .tab {
  padding: 4px 10px;
  font-size: 12px;
}

.tab.is-active {
  background: #262c3c;
  color: var(--text);
}

.tab-panel {
  display: none;
}

.tab-panel.is-active {
  display: block;
}

/* ---- ビートパネル ---- */
.yt-search,
.yt-paste {
  display: flex;
  gap: 6px;
  margin-bottom: 8px;
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 10px;
}

.chip {
  background: var(--panel-2);
  border: 1px solid var(--line);
  color: var(--muted);
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 11px;
  cursor: pointer;
}

.chip:hover {
  color: var(--text);
  border-color: var(--accent-3);
}

.yt-results {
  display: grid;
  gap: 8px;
  max-height: 260px;
  overflow-y: auto;
  margin-bottom: 10px;
}

.yt-item {
  display: grid;
  grid-template-columns: 84px 1fr;
  gap: 9px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 7px;
  cursor: pointer;
  text-align: left;
  color: inherit;
  font: inherit;
}

.yt-item:hover {
  border-color: var(--accent-3);
}

.yt-item img {
  width: 84px;
  height: 47px;
  object-fit: cover;
  border-radius: 6px;
}

.yt-item-title {
  font-size: 12px;
  font-weight: 600;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.yt-item-channel {
  font-size: 11px;
  color: var(--muted);
}

.yt-player-wrap {
  position: relative;
  border-radius: 10px;
  overflow: hidden;
  background: #000;
  aspect-ratio: 16 / 9;
  margin-bottom: 10px;
}

#ytPlayer,
#ytPlayer iframe {
  width: 100%;
  height: 100%;
  border: 0;
}

.yt-loaded {
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px;
  font-size: 12px;
  display: grid;
  gap: 8px;
  margin-bottom: 10px;
}

.dropzone {
  border: 2px dashed var(--line);
  border-radius: 12px;
  padding: 26px 14px;
  text-align: center;
  transition: border-color 0.15s ease, background 0.15s ease;
}

.dropzone.is-over {
  border-color: var(--accent-2);
  background: rgba(77, 216, 192, 0.06);
}

.dropzone p {
  margin: 0 0 6px;
}

.beat-info {
  margin-top: 12px;
  display: grid;
  gap: 8px;
  justify-items: start;
}

.wave {
  width: 100%;
  height: 56px;
  display: block;
  background: var(--panel-2);
  border-radius: 8px;
}

.wave-beat {
  height: 70px;
}

/* ---- トランスポート ---- */
.transport {
  display: flex;
  gap: 20px;
  align-items: center;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 16px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}

.rec-btn {
  width: 118px;
  height: 118px;
  border-radius: 50%;
  border: 3px solid rgba(255, 61, 87, 0.35);
  background: radial-gradient(circle at 50% 35%, #2a1520, #14161f);
  color: var(--text);
  cursor: pointer;
  display: grid;
  place-items: center;
  gap: 6px;
  font: inherit;
  font-weight: 800;
  transition: transform 0.1s ease, box-shadow 0.2s ease;
}

.rec-btn:hover {
  box-shadow: 0 0 0 6px rgba(255, 61, 87, 0.08);
}

.rec-dot {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 18px rgba(255, 61, 87, 0.7);
}

.rec-btn.is-recording {
  border-color: var(--accent);
  animation: recPulse 1.1s ease-in-out infinite;
}

.rec-btn.is-recording .rec-dot {
  border-radius: 6px;
}

@keyframes recPulse {
  0%,
  100% {
    box-shadow: 0 0 0 0 rgba(255, 61, 87, 0.45);
  }
  50% {
    box-shadow: 0 0 0 14px rgba(255, 61, 87, 0);
  }
}

.transport-side {
  flex: 1;
  min-width: 260px;
  display: grid;
  gap: 10px;
}

.transport-buttons {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.time-readout {
  font-variant-numeric: tabular-nums;
  font-size: 26px;
  font-weight: 700;
  display: flex;
  align-items: baseline;
  gap: 8px;
}

.time-sep,
#durTime {
  color: var(--muted);
  font-size: 16px;
  font-weight: 500;
}

.bar-count {
  margin-left: auto;
  font-size: 13px;
  color: var(--accent-2);
  font-weight: 600;
}

.meter-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.meter-label {
  font-size: 12px;
  color: var(--muted);
  min-width: 34px;
}

.level-meter {
  flex: 1;
  height: 12px;
  border-radius: 6px;
  overflow: hidden;
}

.rec-options {
  display: flex;
  gap: 16px;
  align-items: flex-end;
  flex-wrap: wrap;
  margin-bottom: 12px;
}

.callout {
  background: rgba(77, 216, 192, 0.07);
  border: 1px solid rgba(77, 216, 192, 0.25);
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 13px;
  color: #cfe9e3;
  margin: 0 0 16px;
}

.callout.is-warn {
  background: rgba(255, 61, 87, 0.08);
  border-color: rgba(255, 61, 87, 0.3);
  color: #ffd7dc;
}

/* ---- トラック ---- */
.tracklist-head {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
}

.tracklist-head h3 {
  font-size: 13px;
}

.tracklist {
  display: grid;
  gap: 8px;
}

.track {
  display: grid;
  grid-template-columns: 150px 1fr auto;
  gap: 10px;
  align-items: center;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 11px;
  padding: 9px 11px;
}

.track.is-selected {
  border-color: var(--accent-3);
}

.track-name {
  background: transparent;
  border: 0;
  border-bottom: 1px dashed transparent;
  font-weight: 700;
  padding: 2px 0;
}

.track-name:hover {
  border-bottom-color: var(--line);
}

.track-meta {
  font-size: 11px;
  color: var(--muted);
}

.track-lane {
  position: relative;
  cursor: crosshair;
}

.track-wave {
  height: 46px;
  width: 100%;
  display: block;
  background: #0e1119;
  border-radius: 7px;
}

.playhead {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 2px;
  margin-left: -1px;
  background: var(--accent);
  box-shadow: 0 0 8px rgba(255, 61, 87, 0.8);
  pointer-events: none;
  opacity: 0.9;
}

.track-actions {
  display: flex;
  gap: 4px;
  align-items: center;
}

.icon-btn {
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--muted);
  cursor: pointer;
  padding: 4px 8px;
  font: inherit;
  font-size: 12px;
  font-weight: 700;
}

.icon-btn:hover {
  color: var(--text);
  border-color: #3b445c;
}

.icon-btn.is-on {
  background: var(--accent-3);
  border-color: var(--accent-3);
  color: #12101c;
}

.icon-btn.is-danger:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.empty {
  text-align: center;
  color: var(--muted);
  padding: 26px;
  border: 1px dashed var(--line);
  border-radius: 11px;
  font-size: 13px;
}

/* ---- ミックス ---- */
.mix-head {
  display: flex;
  gap: 12px;
  align-items: flex-end;
  margin-bottom: 14px;
  flex-wrap: wrap;
}

.mix-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(215px, 1fr));
  gap: 14px;
}

.mix-item {
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 11px;
  padding: 11px 12px;
}

.mix-item .slider span {
  display: flex;
  justify-content: space-between;
}

.mix-item .desc {
  font-size: 11px;
  color: var(--muted);
  margin-top: 4px;
}

.master-row {
  margin-top: 18px;
  border-top: 1px solid var(--line);
  padding-top: 14px;
}

/* ---- 歌詞 ---- */
.lyrics-wrap {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  min-height: 380px;
}

#lyricsInput {
  min-height: 380px;
  resize: vertical;
  line-height: 1.9;
  font-size: 15px;
}

.lyrics-analysis {
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 11px;
  padding: 12px;
  overflow-y: auto;
  max-height: 460px;
}

.lyrics-meta {
  display: flex;
  gap: 12px;
  font-size: 12px;
  color: var(--muted);
  border-bottom: 1px solid var(--line);
  padding-bottom: 8px;
  margin-bottom: 8px;
}

.reading-status {
  margin-left: auto;
  padding: 1px 8px;
  border-radius: 999px;
  border: 1px solid var(--line);
  cursor: help;
}

.reading-status.is-on {
  color: var(--accent-2);
  border-color: rgba(77, 216, 192, 0.4);
}

.rhyme-line {
  display: flex;
  gap: 8px;
  align-items: baseline;
  padding: 2px 0;
  font-size: 14px;
  line-height: 1.8;
}

.rhyme-line .num {
  color: #4a5266;
  font-size: 11px;
  min-width: 20px;
  text-align: right;
}

.rhyme-line .vowels {
  margin-left: auto;
  font-size: 11px;
  letter-spacing: 0.14em;
  color: var(--muted);
}

.rhyme-line.has-rhyme .vowels {
  font-weight: 800;
}

/* 2音だけそろっている「惜しい韻」は控えめに見せる */
.rhyme-line.is-weak span:not(.num) {
  opacity: 0.55;
}

/* ---- 書き出し ---- */
.export-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 14px;
}

.export-card {
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 14px;
  display: grid;
  gap: 10px;
  align-content: start;
}

.export-card h3 {
  font-size: 14px;
}

.export-card textarea {
  font-size: 12px;
  line-height: 1.7;
  resize: vertical;
}

progress {
  width: 100%;
  height: 8px;
}

/* ---- トースト・ダイアログ ---- */
.toast {
  position: fixed;
  left: 50%;
  bottom: 26px;
  transform: translateX(-50%);
  background: #1c2130;
  border: 1px solid var(--line);
  border-left: 4px solid var(--accent-2);
  border-radius: 10px;
  padding: 11px 18px;
  box-shadow: var(--shadow);
  z-index: 60;
  max-width: min(560px, 90vw);
}

.toast.is-error {
  border-left-color: var(--accent);
}

.dialog {
  background: var(--panel);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 22px;
  max-width: 560px;
  width: 92vw;
  box-shadow: var(--shadow);
}

.dialog::backdrop {
  background: rgba(0, 0, 0, 0.6);
}

.dialog h2 {
  font-size: 17px;
  margin-bottom: 12px;
}

.dialog h3 {
  font-size: 13px;
  margin-top: 16px;
}

.dialog p {
  font-size: 13px;
  color: #c3c9d8;
}

.help-list {
  padding-left: 20px;
  font-size: 13px;
  line-height: 1.9;
}

.projects-list {
  display: grid;
  gap: 8px;
  margin-bottom: 14px;
  max-height: 50vh;
  overflow-y: auto;
}

.project-row {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 9px 11px;
}

.project-row .meta {
  font-size: 11px;
  color: var(--muted);
}

.project-row .spacer {
  flex: 1;
}

@media (max-width: 1080px) {
  .layout {
    grid-template-columns: 1fr;
  }
  .lyrics-wrap {
    grid-template-columns: 1fr;
  }
}
