/* Track cards (generated result, personal library, community gallery) and the
   prompt presets on the home page. Loaded by index.html on top of its own
   theme variables. */

.tcard-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 16px;
}
.tcard {
  display: flex; flex-direction: column;
  background: rgba(20, 24, 38, 0.62);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: var(--border-radius-lg);
  overflow: hidden;
}
.tcard-wide { flex-direction: row; }
.tcard-wide .tc-cover { width: 132px; min-width: 132px; padding-top: 0; }

.tc-cover { position: relative; padding-top: 46%; overflow: hidden; }
.tc-art {
  position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover;
  filter: saturate(1.05);
}
.tc-cover::after {
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(180deg, rgba(8,10,20,0) 40%, rgba(8,10,20,0.45));
  pointer-events: none;
}
.tc-play, .tc-dur { z-index: 1; }
.tc-play {
  position: absolute; inset: 0; margin: auto;
  width: 52px; height: 52px; border-radius: 50%;
  border: none; cursor: pointer; font-size: 22px;
  background: rgba(8, 10, 20, 0.55); color: #fff;
  display: flex; align-items: center; justify-content: center;
  backdrop-filter: blur(4px);
}
.tc-play:hover { background: rgba(8, 10, 20, 0.75); }
.tc-dur {
  position: absolute; right: 8px; bottom: 8px;
  background: rgba(8, 10, 20, 0.6); color: #fff;
  font-size: 12px; padding: 2px 7px; border-radius: 999px;
}

.tc-body { flex: 1; min-width: 0; padding: 14px 16px 12px; }
.tc-title {
  font-size: 15px; font-weight: 600; margin: 0 0 4px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.tc-meta { font-size: 12px; color: var(--color-text-secondary); margin: 0 0 10px; }
.tc-prompt {
  font-size: 12px; color: var(--color-text-secondary); margin: 10px 0 0;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  overflow: hidden; line-height: 1.5;
}

/* waveform with a progress overlay driven by the shared audio element */
.tc-wave {
  position: relative; display: flex; align-items: flex-end; gap: 2px;
  height: 34px; overflow: hidden;
}
.tc-wave span {
  flex: 1; background: var(--color-border-tertiary); border-radius: 2px; min-width: 2px;
}
.tc-prog {
  position: absolute; left: 0; top: 0; bottom: 0; width: 0;
  background: linear-gradient(90deg, rgba(91,140,255,0.45), rgba(138,107,255,0.45));
  pointer-events: none; transition: width .2s linear;
}

.tc-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-top: 12px; }
.tc-act {
  display: inline-flex; align-items: center; gap: 5px;
  font: inherit; font-size: 13px; cursor: pointer;
  padding: 6px 9px; border-radius: var(--border-radius-md);
  background: transparent; border: 1px solid var(--color-border-tertiary);
  color: var(--color-text-secondary); text-decoration: none;
}
.tc-act:hover { color: var(--color-text-primary); background: var(--color-background-secondary); }
.tc-act i { font-size: 16px; }
.tc-act-label { font-size: 12px; }

/* prompt preset cards (own section on the home page) */
.preset-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
}
@media (max-width: 640px) { .preset-grid { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 400px) { .preset-grid { grid-template-columns: 1fr; } }
.preset {
  position: relative; display: block; text-align: left;
  font: inherit; cursor: pointer; padding: 0;
  border-radius: var(--border-radius-lg); overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: var(--color-background-secondary);
  color: var(--color-text-primary);
  transition: transform .2s ease, border-color .2s ease, box-shadow .2s ease;
}
.preset:hover, .preset:focus-visible {
  transform: translateY(-3px);
  border-color: var(--color-text-info);
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.35);
  outline: none;
}
.preset.active { border-color: var(--color-text-info); }
.preset-art {
  display: block; position: relative; padding-top: 62%; overflow: hidden;
  background: linear-gradient(135deg, var(--preset-accent, #5b8cff) 0%, #1a1d2e 100%);
}
.preset-art img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.preset-art::after {
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(180deg, rgba(8,10,20,0) 45%, rgba(8,10,20,0.55));
}
.preset-art i {
  position: absolute; left: 12px; bottom: 10px; z-index: 1;
  width: 34px; height: 34px; border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  background: var(--preset-accent, var(--color-text-info)); color: #fff; font-size: 18px;
}
.preset-body { display: block; padding: 12px 14px 14px; }
.preset-title { display: block; font-size: 15px; font-weight: 600; margin: 0 0 4px; }
.preset-tags { font-size: 12px; color: var(--color-text-secondary); margin: 0; }
.preset-cta {
  display: inline-flex; align-items: center; gap: 4px; margin-top: 10px;
  font-size: 12px; color: var(--color-text-info); font-weight: 600;
}

/* visual pickers: a hidden native <select> keeps the value; the button shows
   the current choice with its artwork and the popover lists every option */
.vpick { position: relative; }
.vpick > select { position: absolute; opacity: 0; pointer-events: none; width: 1px; height: 1px; }
.vpick-btn {
  width: 100%; display: flex; align-items: center; gap: 10px;
  font: inherit; font-size: 14px; cursor: pointer; text-align: left;
  padding: 6px 10px 6px 6px; border-radius: var(--border-radius-md);
  background: var(--color-background-secondary);
  border: 1px solid var(--color-border-tertiary); color: var(--color-text-primary);
  transition: border-color .15s ease, box-shadow .15s ease;
}
.vpick-btn:hover { border-color: var(--color-text-secondary); }
.vpick.open .vpick-btn, .vpick-btn:focus-visible {
  border-color: var(--color-text-info); outline: none;
  box-shadow: 0 0 0 3px rgba(91, 140, 255, 0.18);
}
.vpick-thumb {
  width: 36px; height: 36px; border-radius: 8px; flex: none; object-fit: cover;
  background: var(--color-background-tertiary);
}
.vpick-ico {
  width: 36px; height: 36px; border-radius: 8px; flex: none;
  display: flex; align-items: center; justify-content: center; font-size: 19px;
  background: var(--pick-accent, var(--color-text-info)); color: #fff;
}
.vpick-label { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.vpick-btn > .ti-chevron-down { color: var(--color-text-secondary); transition: transform .15s ease; }
.vpick.open .vpick-btn > .ti-chevron-down { transform: rotate(180deg); }
.vpick-menu {
  display: none; position: absolute; left: 0; right: 0; top: calc(100% + 6px); z-index: 30;
  padding: 8px; border-radius: var(--border-radius-lg);
  background: rgba(18, 21, 34, 0.98); border: 1px solid rgba(255, 255, 255, 0.1);
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5);
  max-height: 340px; overflow-y: auto;
}
.vpick.open .vpick-menu { display: grid; grid-template-columns: repeat(2, 1fr); gap: 4px; }
.vpick-menu.wide { left: 0; right: auto; min-width: 100%; width: 460px; max-width: 90vw; }
.vpick.open .vpick-menu.wide { grid-template-columns: repeat(3, 1fr); }
.vpick-opt {
  display: flex; align-items: center; gap: 9px;
  font: inherit; font-size: 13px; cursor: pointer; text-align: left;
  padding: 5px 8px 5px 5px; border-radius: 10px;
  background: transparent; border: 1px solid transparent; color: var(--color-text-primary);
}
.vpick-opt:hover, .vpick-opt:focus-visible { background: rgba(255, 255, 255, 0.06); outline: none; }
.vpick-opt.selected {
  background: rgba(91, 140, 255, 0.14); border-color: rgba(91, 140, 255, 0.5);
}
.vpick-opt .vpick-thumb, .vpick-opt .vpick-ico { width: 40px; height: 40px; }
.vpick-opt .vpick-label { white-space: normal; line-height: 1.25; }
.vpick-opt .ti-check { margin-left: auto; color: var(--color-text-info); font-size: 16px; }
@media (max-width: 640px) {
  .vpick-menu.wide { width: auto; right: 0; }
  .vpick.open .vpick-menu, .vpick.open .vpick-menu.wide { grid-template-columns: repeat(2, 1fr); }
}

/* header profile control */
.avatar-btn {
  width: 34px; height: 34px; border-radius: 50%; padding: 0; cursor: pointer;
  border: 2px solid transparent; font: inherit; font-weight: 700; font-size: 14px;
  background: linear-gradient(135deg, #5b8cff, #8a6bff); color: #fff;
  display: inline-flex; align-items: center; justify-content: center;
  transition: border-color .15s ease, transform .15s ease;
}
.avatar-btn:hover { border-color: rgba(255, 255, 255, 0.55); transform: scale(1.05); }
.acct-block { margin-top: 0; }
.acct-head {
  display: flex; align-items: center; gap: 14px; margin-bottom: 14px;
}
.acct-head .avatar-big {
  width: 52px; height: 52px; border-radius: 50%; font-size: 22px; font-weight: 700;
  background: linear-gradient(135deg, #5b8cff, #8a6bff); color: #fff;
  display: flex; align-items: center; justify-content: center;
}
.acct-head .acct-who { min-width: 0; }
.acct-head .acct-who b { display: block; font-size: 16px; }
.acct-head .acct-who span { font-size: 13px; color: var(--color-text-secondary); word-break: break-all; }

/* free-track counter next to the generator */
.balance-line {
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px;
  font-size: 13px; color: var(--color-text-secondary); margin: 0 0 12px;
}
.balance-pill {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--color-background-info); color: var(--color-text-info);
  border-radius: 999px; padding: 4px 11px; font-weight: 600;
}
.balance-line a { color: var(--color-text-info); }

/* community section on the home page */
.gallery-toggle { display: flex; justify-content: center; gap: 8px; margin-bottom: 22px; }
.gallery-toggle button {
  font: inherit; font-size: 13px; cursor: pointer; padding: 7px 16px;
  border-radius: 999px; border: 1px solid var(--color-border-tertiary);
  background: transparent; color: var(--color-text-secondary);
}
.gallery-toggle button.active { background: var(--color-text-info); color: #fff; border-color: transparent; }
.gallery-empty { text-align: center; color: var(--color-text-secondary); font-size: 14px; padding: 24px 0; }

/* payment history */
.pay-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.pay-table th, .pay-table td {
  text-align: left; padding: 8px 6px;
  border-bottom: 1px solid var(--color-border-tertiary);
  color: var(--color-text-secondary);
}
.pay-table th { color: var(--color-text-primary); font-weight: 600; }
.pay-status { font-weight: 600; }
.pay-status.paid { color: #4ade80; }
.pay-status.pending { color: #fbbf24; }
.pay-status.failed { color: #ff6b6b; }
.pay-status.refunded { color: var(--color-text-secondary); }
