:root {
  --bg: #08080b;
  --surface: #101015;
  --surface-2: #15151d;
  --surface-3: #1d1b27;
  --line: #2b2a35;
  --text: #f8fafc;
  --muted: #9ca3af;
  --dim: #6b7280;
  --orange: #ff8a3d;
  --orange-2: #ffb273;
  --purple: #8b5cf6;
  --cyan: #38bdf8;
  --green: #22c55e;
  --danger: #ef4444;
  --radius: 8px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  color-scheme: dark;
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

button,
input {
  font: inherit;
}

button {
  color: inherit;
}

#app-shell {
  display: grid;
  grid-template-rows: auto 1fr auto auto;
  height: 100%;
  max-width: 560px;
  margin: 0 auto;
  background: var(--bg);
}

.topbar {
  display: grid;
  grid-template-columns: 1fr 44px;
  align-items: center;
  gap: 12px;
  padding: calc(12px + env(safe-area-inset-top, 0px)) 14px 10px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  background: rgba(8, 8, 11, 0.92);
  backdrop-filter: blur(16px);
}

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

.brand-mark {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border-radius: var(--radius);
  color: #111111;
  font-size: 22px;
  font-weight: 900;
  background: linear-gradient(135deg, var(--orange), var(--purple));
  box-shadow: 0 10px 30px rgba(255, 138, 61, 0.22);
}

.brand-title {
  overflow: hidden;
  color: var(--text);
  font-size: 17px;
  line-height: 1.18;
  font-weight: 900;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.brand-subtitle {
  margin-top: 2px;
  color: var(--muted);
  font-size: 12px;
}

.icon-button,
.chip-button,
.action-button,
.tab-button,
.filter-chip,
.segment,
.shortcut-card,
.poet-tile,
.stack-tile,
.poem-row,
.listen-button,
.create-gradient-button,
.back-inline {
  border: 0;
  cursor: pointer;
}

.icon-button {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  border-radius: var(--radius);
  background: #14141c;
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: var(--orange-2);
  font-size: 20px;
}

.screen {
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
  padding: 14px 14px 18px;
  -webkit-overflow-scrolling: touch;
}

.section {
  margin-bottom: 18px;
}

.title-block {
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: center;
  gap: 12px;
}

.title-block > div:first-child:last-child {
  grid-column: 1 / -1;
}

.eyebrow {
  color: var(--orange-2);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.02em;
}

.page-title {
  margin: 2px 0 0;
  color: var(--text);
  font-size: 22px;
  line-height: 1.12;
  font-weight: 900;
}

.page-subtitle {
  margin-top: 4px;
  color: var(--muted);
  font-size: 13px;
}

.back-inline {
  width: 42px;
  height: 42px;
  border-radius: var(--radius);
  background: #14141c;
  color: var(--text);
  font-size: 22px;
  font-weight: 800;
}

.hero-section {
  position: relative;
  min-height: 244px;
  overflow: hidden;
  display: flex;
  align-items: flex-end;
  margin: -14px -14px 18px;
  padding: 22px 14px 20px;
  background:
    linear-gradient(180deg, rgba(8, 8, 11, 0.12), rgba(8, 8, 11, 0.78) 58%, var(--bg)),
    linear-gradient(135deg, #392219, #171735 45%, #0d2320);
}

.hero-section.has-cover::before {
  content: "";
  position: absolute;
  inset: 0;
  background-image: var(--hero-cover);
  background-size: cover;
  background-position: center;
  opacity: 0.48;
}

.hero-section::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(8, 8, 11, 0.08), rgba(8, 8, 11, 0.88) 74%, var(--bg));
}

.hero-content {
  position: relative;
  z-index: 1;
  width: 100%;
}

.hero-kicker {
  color: #ffd2b4;
  font-size: 12px;
  font-weight: 800;
}

.hero-title {
  max-width: 360px;
  margin: 6px 0 16px;
  color: var(--text);
  font-size: 34px;
  line-height: 1.02;
  font-weight: 950;
}

.hero-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.hero-actions.inline {
  margin-top: 6px;
}

.listen-button,
.create-gradient-button {
  min-height: 46px;
  padding: 0 18px;
  border-radius: var(--radius);
  font-size: 15px;
  font-weight: 900;
}

.listen-button {
  background: var(--orange);
  color: #111111;
}

.create-gradient-button {
  background: linear-gradient(90deg, #5558d4, #9050d0, #c04080);
  color: #ffffff;
}

.hero-meta {
  margin-top: 12px;
  color: var(--muted);
  font-size: 12px;
}

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

.section-title {
  margin: 0;
  color: var(--text);
  font-size: 18px;
  line-height: 1.2;
  font-weight: 850;
}

.search-row {
  position: sticky;
  top: -14px;
  z-index: 4;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  padding: 10px 0;
  background: linear-gradient(180deg, var(--bg), rgba(8, 8, 11, 0.9));
}

.search-input {
  min-width: 0;
  height: 44px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: var(--radius);
  padding: 0 12px;
  outline: none;
  background: var(--surface);
  color: var(--text);
}

.search-input::placeholder {
  color: var(--dim);
}

.chip-button {
  min-height: 44px;
  padding: 0 14px;
  border-radius: var(--radius);
  background: var(--orange);
  color: #111111;
  font-size: 14px;
  font-weight: 900;
}

.chip-row,
.segment-row {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 4px;
  scrollbar-width: none;
}

.chip-row::-webkit-scrollbar,
.segment-row::-webkit-scrollbar,
.tile-rail::-webkit-scrollbar {
  display: none;
}

.filter-chip,
.segment {
  flex: 0 0 auto;
  min-height: 34px;
  padding: 0 11px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--muted);
  font-size: 13px;
  font-weight: 750;
}

.filter-chip.active,
.segment.active {
  border-color: rgba(255, 138, 61, 0.65);
  color: var(--orange-2);
  background: rgba(255, 138, 61, 0.12);
}

.filter-chip.danger {
  color: #fca5a5;
}

.shortcut-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.shortcut-card {
  min-height: 84px;
  padding: 12px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: var(--radius);
  background: linear-gradient(160deg, rgba(21, 21, 29, 0.98), rgba(29, 27, 39, 0.94));
  text-align: left;
}

.shortcut-card.large {
  grid-column: span 1;
  min-height: 104px;
}

.shortcut-card span {
  display: block;
  color: var(--text);
  font-size: 14px;
  font-weight: 850;
}

.shortcut-card small {
  display: block;
  margin-top: 6px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.25;
}

.poet-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.poet-tile {
  min-height: 72px;
  padding: 12px;
  border-radius: var(--radius);
  text-align: left;
  background: linear-gradient(135deg, #ff6a4a, #8b5cf6);
}

.poet-tile span {
  display: block;
  color: #ffffff;
  font-size: 16px;
  font-weight: 900;
}

.poet-tile small {
  display: block;
  margin-top: 6px;
  color: rgba(255, 255, 255, 0.74);
  font-size: 12px;
}

.tone-1 { background: linear-gradient(135deg, #8b5cf6, #3730a3); }
.tone-2 { background: linear-gradient(135deg, #22c55e, #166534); }
.tone-3 { background: linear-gradient(135deg, #38bdf8, #075985); }
.tone-4 { background: linear-gradient(135deg, #f59e0b, #92400e); }
.tone-5 { background: linear-gradient(135deg, #ec4899, #831843); }

.tile-rail {
  display: flex;
  gap: 10px;
  overflow-x: auto;
  padding: 4px 2px 2px;
  scrollbar-width: none;
}

.stack-tile {
  position: relative;
  flex: 0 0 140px;
  height: 92px;
  padding: 12px;
  border-radius: var(--radius);
  background: linear-gradient(135deg, var(--tile-a), var(--tile-b));
  text-align: left;
  box-shadow: 0 10px 0 rgba(255, 255, 255, 0.04);
}

.stack-tile::before,
.stack-tile::after {
  content: "";
  position: absolute;
  left: 6px;
  right: 6px;
  height: 3px;
  border-radius: 999px;
  background: var(--tile-a);
  opacity: 0.45;
}

.stack-tile::before { top: -6px; }
.stack-tile::after { top: -11px; opacity: 0.25; }

.stack-tile span {
  display: block;
  color: #ffffff;
  font-size: 16px;
  font-weight: 900;
}

.stack-tile small {
  display: block;
  margin-top: 7px;
  color: rgba(255, 255, 255, 0.72);
  font-size: 12px;
}

.track-list {
  display: grid;
  gap: 10px;
}

.track-card {
  width: 100%;
  display: grid;
  grid-template-columns: 74px 1fr auto;
  gap: 11px;
  padding: 10px;
  border: 1px solid rgba(255, 255, 255, 0.07);
  border-radius: var(--radius);
  background: rgba(16, 16, 21, 0.92);
  text-align: left;
}

.track-card.active {
  border-color: rgba(255, 138, 61, 0.5);
  background: rgba(255, 138, 61, 0.08);
}

.cover-column {
  display: grid;
  gap: 5px;
  align-content: start;
}

.track-cover {
  width: 74px;
  aspect-ratio: 1;
  overflow: hidden;
  display: grid;
  place-items: center;
  border-radius: var(--radius);
  background: linear-gradient(135deg, rgba(255, 138, 61, 0.34), rgba(139, 92, 246, 0.32)), var(--surface-3);
}

.track-cover img,
.player-cover img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
}

.cover-placeholder {
  color: rgba(248, 250, 252, 0.55);
  font-size: 24px;
  font-weight: 900;
}

.cover-year {
  color: var(--dim);
  font-size: 11px;
  text-align: center;
}

.track-body {
  min-width: 0;
}

.track-title {
  overflow: hidden;
  color: var(--text);
  font-size: 15px;
  line-height: 1.22;
  font-weight: 850;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.genre-line {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 5px;
  color: var(--muted);
  font-size: 12px;
}

.genre-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--orange);
}

.track-source {
  display: -webkit-box;
  overflow: hidden;
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.32;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.track-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-top: 8px;
}

.track-chip {
  max-width: 100%;
  padding: 4px 7px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 999px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.03);
  font-size: 11px;
  line-height: 1;
}

.metric-stack {
  display: grid;
  gap: 7px;
  align-content: start;
  justify-items: end;
  color: var(--muted);
  font-size: 11px;
}

.metric {
  min-width: 36px;
  display: flex;
  justify-content: flex-end;
  gap: 3px;
}

.action-row {
  grid-column: 1 / -1;
  display: flex;
  gap: 6px;
  padding-top: 2px;
}

.action-button {
  flex: 1 1 0;
  min-width: 0;
  min-height: 34px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 8px;
  overflow: hidden;
  border-radius: var(--radius);
  background: var(--surface-2);
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
  line-height: 1;
}

.action-button.primary,
.action-button.active {
  color: #111111;
  background: var(--orange);
}

.status-list {
  display: grid;
  gap: 8px;
}

.status-row,
.poem-row {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  padding: 12px;
  border: 1px solid rgba(255, 255, 255, 0.07);
  border-radius: var(--radius);
  background: rgba(16, 16, 21, 0.9);
  text-align: left;
}

.poem-row {
  display: grid;
}

.poem-row span {
  color: var(--text);
  font-size: 15px;
  font-weight: 850;
}

.poem-row small {
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
}

.status-label {
  color: var(--muted);
  font-size: 13px;
}

.status-value {
  max-width: 62%;
  overflow: hidden;
  color: var(--text);
  font-size: 13px;
  font-weight: 750;
  text-align: right;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.poem-text-section {
  padding: 14px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: var(--radius);
  background: rgba(16, 16, 21, 0.9);
}

.poem-text {
  margin: 0;
  white-space: pre-wrap;
  color: #e5e7eb;
  font: inherit;
  font-size: 15px;
  line-height: 1.58;
}

.notice {
  padding: 14px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: var(--radius);
  background: rgba(21, 21, 29, 0.92);
}

.notice-title {
  margin: 0 0 7px;
  font-size: 16px;
  font-weight: 850;
}

.notice-text {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.empty-state {
  padding: 28px 14px;
  border: 1px dashed rgba(255, 255, 255, 0.1);
  border-radius: var(--radius);
  color: var(--muted);
  background: rgba(16, 16, 21, 0.58);
  text-align: center;
}

.skeleton-card {
  height: 124px;
  background: linear-gradient(90deg, rgba(255,255,255,0.04), rgba(255,255,255,0.1), rgba(255,255,255,0.04));
  background-size: 240% 100%;
  animation: shimmer 1.2s linear infinite;
}

@keyframes shimmer {
  from { background-position: 120% 0; }
  to { background-position: -120% 0; }
}

.mini-player {
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(12, 12, 16, 0.97);
  backdrop-filter: blur(18px);
}

.player-inner {
  display: grid;
  grid-template-columns: 42px 44px 1fr auto;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
}

.player-button {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 50%;
  background: var(--orange);
  color: #111111;
  font-size: 17px;
  font-weight: 900;
}

.player-cover {
  width: 44px;
  height: 44px;
  overflow: hidden;
  display: grid;
  place-items: center;
  border-radius: var(--radius);
  background: var(--surface-3);
  color: var(--muted);
}

.player-body {
  min-width: 0;
}

.player-title {
  overflow: hidden;
  color: var(--text);
  font-size: 14px;
  font-weight: 850;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.player-subtitle {
  overflow: hidden;
  margin-top: 2px;
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.progress {
  grid-column: 1 / -1;
  height: 4px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
}

.progress-fill {
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--orange), var(--purple));
}

.player-time {
  color: var(--muted);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}

.tabbar {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 2px;
  padding: 7px 6px calc(7px + var(--safe-bottom));
  border-top: 1px solid rgba(255, 255, 255, 0.07);
  background: rgba(8, 8, 11, 0.98);
}

.tab-button {
  min-width: 0;
  min-height: 50px;
  display: grid;
  place-items: center;
  gap: 2px;
  border-radius: var(--radius);
  background: transparent;
  color: var(--dim);
  font-size: 10px;
  font-weight: 750;
}

.tab-button.active {
  color: var(--orange-2);
  background: rgba(255, 138, 61, 0.1);
}

.tab-icon {
  font-size: 17px;
  line-height: 1;
}

.toast {
  position: fixed;
  left: 14px;
  right: 14px;
  bottom: calc(88px + env(safe-area-inset-bottom, 0px));
  z-index: 20;
  max-width: 520px;
  margin: 0 auto;
  padding: 12px 14px;
  border-radius: var(--radius);
  background: rgba(248, 250, 252, 0.94);
  color: #111111;
  font-size: 13px;
  font-weight: 850;
  text-align: center;
  box-shadow: 0 18px 44px rgba(0, 0, 0, 0.34);
}

@media (max-width: 390px) {
  .screen {
    padding-inline: 10px;
  }

  .hero-title {
    font-size: 30px;
  }

  .shortcut-grid {
    grid-template-columns: 1fr;
  }

  .track-card {
    grid-template-columns: 64px 1fr;
  }

  .track-cover {
    width: 64px;
  }

  .metric-stack {
    grid-column: 1 / -1;
    grid-template-columns: repeat(3, auto);
    justify-content: start;
  }
}
