﻿/* ---------- Create sheet ---------- */

.createhead {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 14px 14px 4px 20px;
}
.createhead h1 { font-size: 22px; font-weight: 800; flex: 1; }
.createhead .credits {
  font-size: 11px;
  font-weight: 700;
  color: var(--violet);
  background: rgba(139, 92, 246, 0.14);
  border: 1px solid rgba(139, 92, 246, 0.4);
  border-radius: 50px;
  padding: 6px 12px;
  white-space: nowrap;
  cursor: pointer;
}

.createbody { padding: 6px 20px calc(24px + var(--safe-bottom)); }

.formarea { margin-top: 8px; }
.promptta, .lyricsta {
  resize: none;
  border-radius: 16px;
  line-height: 1.5;
  font-size: 14px;
}
.hint { font-size: 11px; color: var(--text-2); padding: 8px 4px; line-height: 1.5; }

.modes { display: flex; gap: 8px; flex-wrap: wrap; padding: 4px 0 10px; }
.modes .chip { flex-shrink: 1; }

.formfoot { padding-top: 14px; }

/* Prompt Builder / Refine row under the prompt textarea */
.prow { display: flex; gap: 8px; margin-top: 10px; }
.prow .ghostbtn { flex: 1; padding: 11px 10px; font-size: 13px; gap: 4px; }
.prow .ghostbtn svg { width: 15px; height: 15px; flex-shrink: 0; }
.prow .ghostbtn:disabled { opacity: 0.55; }

/* ---------- Prompt Builder sheet (~48vh, prompt field above stays visible) ---------- */

/* Transparent tap-catcher: click outside closes, but the prompt above the
   sheet is NOT dimmed - it must stay readable while building. */
.pbcatcher {
  position: absolute;
  inset: 0;
  z-index: 54; /* above .sheet (53) */
  background: transparent;
}

.buildersheet {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  height: 48vh;
  display: flex;
  flex-direction: column;
  background: var(--elevated);
  border-radius: 22px 22px 0 0;
  padding: 8px 0 calc(12px + var(--safe-bottom));
  z-index: 55;
  transform: translateY(105%);
  transition: transform 0.26s cubic-bezier(0.2, 0.7, 0.3, 1);
}
.buildersheet.open { transform: translateY(0); }
.buildersheet .grab {
  width: 36px; height: 4px;
  border-radius: 2px;
  background: var(--border);
  margin: 2px auto 8px;
  flex-shrink: 0;
}

.pbhead { padding: 0 16px 8px; flex-shrink: 0; }
.pbtitle { font-size: 15px; font-weight: 800; }
.pbsub { font-size: 11px; color: var(--text-2); margin-top: 1px; }

.pb-tabs {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding: 0 16px 10px;
  flex-shrink: 0;
  scrollbar-width: none;
}
.pb-tabs::-webkit-scrollbar { display: none; }
.pbpill {
  flex-shrink: 0;
  padding: 7px 13px;
  border-radius: 50px;
  background: var(--surface);
  color: var(--text-2);
  font-size: 12px;
  font-weight: 700;
  border: 1px solid transparent;
}
.pbpill.on {
  background: rgba(139, 92, 246, 0.16);
  border-color: var(--violet);
  color: var(--text);
}

/* Horizontal pager viewport - custom transform-based paging (one page per
   swipe); pages pan vertically natively, horizontal gestures belong to JS. */
.pb-pages {
  flex: 1;
  min-height: 0;
  position: relative;
  overflow: hidden;
  touch-action: pan-y;
}
.pb-track {
  display: flex;
  height: 100%;
  will-change: transform;
  transition: transform 0.26s cubic-bezier(0.2, 0.7, 0.3, 1);
}
.pb-page {
  flex: 0 0 100%;
  width: 100%;
  overflow-y: auto;
  padding: 2px 16px 6px;
}

.pb-gname {
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-2);
  padding: 12px 2px 6px;
}
.pb-chips { display: flex; flex-wrap: wrap; gap: 7px; }
.pb-chips .chip { padding: 7px 13px; font-size: 12px; }

/* ---------- Fullscreen text editor (prompt / lyrics) ---------- */

.tawrap { position: relative; }
.tawrap .taexpand {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 32px;
  height: 32px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-2);
  background: rgba(0, 0, 0, 0.28);
}
.tawrap .taexpand svg { width: 16px; height: 16px; }

.fsedit {
  position: absolute;
  inset: 0;
  z-index: 57;
  background: var(--bg);
  display: flex;
  flex-direction: column;
  padding-top: var(--safe-top);
  transform: translateY(100%);
  transition: transform 0.28s cubic-bezier(0.2, 0.7, 0.3, 1);
}
.fsedit.open { transform: translateY(0); }
.fshead { display: flex; align-items: center; gap: 8px; padding: 12px 14px 8px 12px; }
.fstitle { font-size: 17px; font-weight: 800; flex: 1; }
.fscount { font-size: 11px; color: var(--text-2); font-weight: 600; white-space: nowrap; }
.fsdone { font-weight: 700; color: var(--violet); font-size: 14px; padding: 8px 10px; }
.fsta {
  flex: 1;
  width: auto;
  margin: 4px 16px calc(16px + var(--safe-bottom));
  font-size: 15px;
  line-height: 1.6;
  resize: none;
  border-radius: 16px;
  padding: 14px;
  background: var(--surface);
}

/* ---------- Draft Lyrics builder sheet ---------- */

.draftsheet {
  height: 56vh;
  z-index: 56; /* above the scrim (55), same layer as bubblesheets */
}

/* Compose mode (Optional idea focused): the sheet fills the visible area,
   tabs/pages hide, the text gets the whole space. */
.draftsheet.editing { height: 100%; border-radius: 0; }
.draftsheet.editing .grab,
.draftsheet.editing .pb-tabs,
.draftsheet.editing .pb-pages { display: none; }
.draftsheet .pbhead { display: flex; align-items: center; }
.draftsheet .pbheadtxt { flex: 1; min-width: 0; }
.ds-done {
  display: none;
  font-weight: 700;
  color: var(--violet);
  font-size: 14px;
  padding: 8px 10px;
}
.draftsheet.editing .ds-done { display: block; }

/* Tap-target look of the idea box on the Theme page */
.ds-idea-open {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px 12px;
  font-size: 13px;
  line-height: 1.5;
  color: var(--text);
  min-height: 58px;
  display: flex;
  align-items: flex-start;
}
.ds-idea-open.empty { color: var(--text-2); opacity: 0.7; }

/* The real textarea, only visible while composing */
.ds-idea-edit { display: none; }
.draftsheet.editing .ds-idea-edit {
  display: block;
  flex: 1;
  width: auto;
  min-height: 0;
  margin: 4px 0 8px;
  font-size: 15px;
  line-height: 1.6;
  resize: none;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 12px 14px;
  color: var(--text);
}
.draftsheet.editing .dsfoot { border-top: none; padding-top: 0; }

.ds-note { font-size: 12px; color: var(--text-2); padding: 2px 0 8px; line-height: 1.4; }
.ds-fieldlabel {
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-2);
  padding: 12px 0 6px;
}
.ds-grouplabel { font-size: 11px; font-weight: 700; color: var(--text); padding: 10px 0 4px; opacity: 0.85; }
.dschips { display: flex; flex-wrap: wrap; gap: 7px; }
.dschips .chip { padding: 7px 13px; font-size: 12px; }
.dschips .chip.off { opacity: 0.35; }

/* Structure strip: tap a tag to append, tap a strip item to remove it */
.ds-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-content: flex-start;
  margin: 0;
  padding: 8px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  min-height: 46px;
  max-height: 96px;
  overflow-y: auto;
}
.ds-stripitem {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: rgba(139, 92, 246, 0.16);
  border: 1px solid var(--violet);
  color: var(--text);
  font-size: 12px;
  font-weight: 600;
  border-radius: 50px;
  padding: 5px 10px;
}
.ds-stripitem .x { font-size: 11px; color: var(--text-2); }
.ds-striphint { font-size: 12px; color: var(--text-2); padding: 4px 2px; }
.ds-striptools { display: flex; align-items: center; justify-content: space-between; padding: 8px 0 0; }
.ds-undobtn {
  border: 1px solid var(--border);
  color: var(--text);
  font-size: 12px;
  font-weight: 700;
  border-radius: 50px;
  padding: 7px 14px;
  background: var(--surface);
}
.ds-autohint { font-size: 10px; color: var(--text-2); }

/* Sticky footer: live one-line summary + the action */
.dsfoot {
  flex-shrink: 0;
  border-top: 1px solid var(--border);
  padding: 8px 16px calc(12px + var(--safe-bottom));
}
.dssummary {
  font-size: 11px;
  color: var(--text-2);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  padding-bottom: 8px;
  min-height: 14px;
}

/* ---------- Run cards (Create progress + Profile) ---------- */
/* Row-shaped on purpose: cover disc + title + sub, so the finish transition
   folds a "row" away instead of swapping layouts. */

.runcards { display: flex; flex-direction: column; gap: 10px; margin-bottom: 6px; }
/* Profile's Songs tab always renders the container (update target for live run
   cards) - an empty one must take zero space or its rows sit lower than Liked. */
.runcards:empty { margin-bottom: 0; }

.runcard, .failcard {
  position: relative;
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 8px 12px 8px 16px;
  overflow: hidden;
}
.failcard { flex-wrap: wrap; row-gap: 2px; }
.failcard .sub.failmsg { white-space: normal; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }

.runcard.entering, .failcard.entering { animation: cardenter 0.4s cubic-bezier(0.2, 0.8, 0.3, 1); }
@keyframes cardenter {
  from { opacity: 0; transform: translateY(10px) scale(0.98); }
}

/* finished/dismissed cards fold away (height set inline by collapseCard) */
.runcard.collapse, .failcard.collapse {
  height: 0 !important;
  opacity: 0;
  padding-top: 0;
  padding-bottom: 0;
  border-top-width: 0;
  border-bottom-width: 0;
  overflow: hidden;
  pointer-events: none;
  transition:
    height 0.32s ease,
    opacity 0.26s ease 0.04s,
    padding 0.32s ease,
    border 0.32s ease,
    margin 0.32s ease;
}
.runcard.collapse.eatbelow, .failcard.collapse.eatbelow { margin-bottom: -10px; }
.runcard.collapse.eatabove, .failcard.collapse.eatabove { margin-top: -10px; }

/* cover: spinning vinyl disc while generating, the AI art fades over it */
.runcover {
  width: 52px; height: 52px;
  border-radius: 12px;
  flex-shrink: 0;
  position: relative;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--elevated);
  color: var(--text-2);
}
.runcover .discbg {
  position: absolute;
  inset: 0;
  background: var(--grad);
  opacity: 0.22;
  animation: runpulse 1.8s ease-in-out infinite;
}
.runcover > svg { width: 24px; height: 24px; position: relative; animation: runspin 3.2s linear infinite; }
.runcover img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; animation: coverfade 0.45s ease; }
.runcover.faildisc { background: rgba(248, 113, 113, 0.12); color: var(--danger); }
.runcover.faildisc .discbg, .runcover.faildisc > svg { animation: none; }
@keyframes runspin { to { transform: rotate(360deg); } }
@keyframes runpulse { 0%, 100% { opacity: 0.14; } 50% { opacity: 0.34; } }
@keyframes coverfade { from { opacity: 0; } }

/* circular progress ring (right side, where a row's play button sits) */
.runside {
  width: 40px; height: 40px;
  flex-shrink: 0;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
}
.runside .ring { position: absolute; inset: 0; transform: rotate(-90deg); }
.runside .ring circle { fill: none; stroke-width: 3; }
.runside .ring .bgc { stroke: var(--elevated); }
.runside .ring .fgc {
  stroke: var(--violet);
  stroke-linecap: round;
  stroke-dasharray: 97.4;
  stroke-dashoffset: calc(97.4 * (1 - var(--runp, 0)));
  transition: stroke-dashoffset 0.3s ease;
}
.runside .ringnum { font-size: 9px; font-weight: 700; color: var(--text-2); letter-spacing: -0.2px; }
.runside.haspreview { color: var(--violet); }
.runside.haspreview .ring .fgc { stroke: var(--pink); }
.runside .ringglyph { position: relative; display: flex; color: var(--violet); }
.runside .ringglyph svg { width: 15px; height: 15px; }

/* thin mirror of the ring along the card's bottom edge */
.runbar {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  height: 3px;
  margin: 0;
  overflow: hidden;
}
.runbar i {
  display: block;
  height: 100%;
  width: 2%;
  background: var(--grad);
  transition: width 0.3s ease;
}

.failrow { flex-basis: 100%; display: flex; gap: 10px; margin: 4px 0 6px; }
.failrow .retrybtn {
  background: var(--grad);
  color: #fff;
  font-weight: 700;
  font-size: 12px;
  border-radius: 50px;
  padding: 8px 18px;
}
.failrow .dismissbtn {
  border: 1px solid var(--border);
  color: var(--text-2);
  font-weight: 700;
  font-size: 12px;
  border-radius: 50px;
  padding: 8px 18px;
}

/* create sheet badge on the nav disc */
.navcreate .disc { position: relative; }
.navcreate .badge {
  position: absolute;
  top: -2px;
  right: -2px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--pink);
  border: 2px solid var(--bg);
}
