:root {
  color-scheme: dark;
  --ink: #130d0b;
  --lacquer: #a91622;
  --lacquer-deep: #690c15;
  --brass: #f2c14e;
  --brass-soft: #ffe69a;
  --jade: #0e6b59;
  --jade-deep: #073b35;
  --paper: #fff5dc;
  --smoke: rgba(255, 245, 220, 0.74);
  --line: rgba(255, 230, 154, 0.24);
  --shadow: 0 24px 80px rgba(0, 0, 0, 0.38);
  --radius: 8px;
  font-family: "Avenir Next", "PingFang SC", "Microsoft YaHei", sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: var(--ink);
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--paper);
  background:
    linear-gradient(135deg, rgba(105, 12, 21, 0.94), rgba(7, 59, 53, 0.9)),
    repeating-linear-gradient(90deg, rgba(255, 230, 154, 0.08) 0 1px, transparent 1px 32px),
    var(--ink);
}

button,
input {
  font: inherit;
}

button {
  -webkit-tap-highlight-color: transparent;
}

[hidden] {
  display: none !important;
}

body.settings-open {
  overflow: hidden;
}

.app-shell {
  min-height: 100vh;
  padding: max(18px, env(safe-area-inset-top)) 16px max(18px, env(safe-area-inset-bottom));
  position: relative;
  overflow: hidden;
}

.app-shell::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(circle at 18% 16%, rgba(242, 193, 78, 0.18), transparent 30%),
    radial-gradient(circle at 92% 8%, rgba(14, 107, 89, 0.22), transparent 26%),
    linear-gradient(transparent, rgba(19, 13, 11, 0.42));
  mix-blend-mode: screen;
}

.topbar,
.layout {
  width: min(1120px, 100%);
  margin: 0 auto;
  position: relative;
  z-index: 1;
}

.topbar {
  min-height: 72px;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

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

.brand-lockup > div {
  min-width: 0;
}

.brand-seal {
  width: 52px;
  height: 52px;
  flex: 0 0 52px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(255, 230, 154, 0.72);
  border-radius: 50%;
  background: linear-gradient(145deg, #d61f2c, #7b0d19);
  box-shadow: inset 0 0 0 4px rgba(19, 13, 11, 0.28), 0 12px 28px rgba(0, 0, 0, 0.24);
  color: var(--brass-soft);
  font-family: "Songti SC", "STSong", Georgia, serif;
  font-size: 28px;
  font-weight: 700;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-family: "Songti SC", "STSong", Georgia, serif;
  font-size: clamp(24px, 6vw, 44px);
  line-height: 1;
  white-space: nowrap;
}

.topbar-actions {
  min-width: 0;
  flex: 1 1 auto;
  display: flex;
  align-items: flex-start;
  justify-content: flex-end;
  gap: 8px;
}

.current-track-pill {
  min-width: 0;
  max-width: min(58vw, 360px);
  display: block;
  margin-top: 8px;
  overflow: hidden;
  color: rgba(255, 245, 220, 0.78);
  font-size: clamp(12px, 3.2vw, 15px);
  font-weight: 800;
  line-height: 1.2;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.settings-button,
.close-button,
.play-toggle,
.mode-button,
.ghost-button,
.settings-tab,
.filter-chip,
.track-button,
.track-toggle,
.corpus-toggle {
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--paper);
  background: rgba(255, 245, 220, 0.08);
  cursor: pointer;
}

.settings-button,
.close-button {
  width: 52px;
  height: 52px;
  flex: 0 0 52px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  color: var(--brass-soft);
  background: rgba(19, 13, 11, 0.36);
}

.settings-button svg {
  width: 25px;
  height: 25px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.8;
}

.close-button {
  width: 46px;
  height: 46px;
  flex-basis: 46px;
}

.close-button span {
  font-size: 32px;
  line-height: 1;
}

.layout {
  display: grid;
  gap: 14px;
  padding-top: 14px;
}

.hero-panel,
.queue-band {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(19, 13, 11, 0.42);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

.hero-panel {
  min-height: 500px;
  padding: 18px;
  display: grid;
  grid-template-rows: 1fr auto;
  gap: 18px;
  background:
    linear-gradient(145deg, rgba(169, 22, 34, 0.78), rgba(7, 59, 53, 0.74)),
    repeating-linear-gradient(45deg, rgba(255, 230, 154, 0.08) 0 2px, transparent 2px 18px);
}

.section-title span,
.last-meta {
  color: var(--smoke);
  font-size: 13px;
}

.blessing-readout {
  align-self: center;
  max-width: 760px;
}

.blessing-readout p {
  color: var(--brass-soft);
  font-size: clamp(28px, 7vw, 46px);
  font-weight: 900;
  line-height: 1.05;
}

.fortune-oracle {
  width: fit-content;
  min-width: min(100%, 210px);
  margin-top: 14px;
  padding: 10px 18px 12px;
  border-left: 4px solid var(--brass-soft);
  background: linear-gradient(90deg, rgba(255, 230, 154, 0.16), rgba(255, 230, 154, 0));
}

.fortune-oracle span {
  display: block;
  margin: 0 0 4px;
  color: rgba(255, 245, 220, 0.72);
  font-size: clamp(13px, 3.3vw, 16px);
  font-weight: 900;
  letter-spacing: 0;
}

.fortune-oracle b {
  display: block;
  color: var(--brass-soft);
  font-family: "Songti SC", "STSong", Georgia, serif;
  font-size: clamp(48px, 16vw, 92px);
  font-weight: 900;
  line-height: 0.95;
  white-space: nowrap;
}

.blessing-readout strong {
  display: block;
  margin-top: 16px;
  font-family: "Songti SC", "STSong", Georgia, serif;
  font-size: clamp(30px, 9.2vw, 72px);
  line-height: 1.04;
  text-wrap: balance;
}

.blessing-readout > span {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 12px;
  color: var(--smoke);
  font-size: clamp(14px, 3.7vw, 18px);
  font-weight: 800;
}

.blessing-readout > span:empty {
  display: none;
}

.speaker-avatar {
  width: 38px;
  height: 38px;
  flex: 0 0 38px;
  display: block;
  border: 1px solid rgba(255, 230, 154, 0.5);
  border-radius: 50%;
  background: rgba(255, 245, 220, 0.12);
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.22);
  object-fit: cover;
}

.source-avatar {
  width: 34px;
  height: 34px;
  flex-basis: 34px;
}

.scratch-button {
  width: min(100%, 420px);
  aspect-ratio: 1 / 0.42;
  justify-self: center;
  position: relative;
  overflow: hidden;
  border: 1px solid rgba(255, 230, 154, 0.82);
  border-radius: 999px;
  color: #3b1608;
  background:
    linear-gradient(180deg, #fff0a8 0%, #f2c14e 48%, #c9821c 100%);
  box-shadow: 0 18px 46px rgba(0, 0, 0, 0.32), inset 0 2px 0 rgba(255, 255, 255, 0.58);
  cursor: pointer;
  transform: translateZ(0);
}

.scratch-button:disabled {
  cursor: wait;
  filter: saturate(0.6);
  opacity: 0.72;
}

.scratch-rim {
  position: absolute;
  inset: 7px;
  border: 1px dashed rgba(59, 22, 8, 0.28);
  border-radius: inherit;
}

.scratch-main {
  position: relative;
  z-index: 1;
  display: block;
}

.scratch-main {
  font-size: clamp(26px, 7vw, 44px);
  font-weight: 900;
}

.scratch-button.is-speaking {
  animation: blessingPulse 760ms ease-in-out infinite alternate;
}

@keyframes blessingPulse {
  from {
    transform: translateY(0) scale(1);
  }
  to {
    transform: translateY(-2px) scale(1.018);
  }
}

.filter-band {
  display: grid;
  gap: 10px;
}

.play-toggle {
  min-height: 124px;
  display: grid;
  grid-template-columns: auto 1fr;
  grid-template-areas:
    "symbol copy"
    "symbol meta";
  align-items: center;
  column-gap: 16px;
  padding: 18px;
  text-align: left;
  border-color: rgba(255, 230, 154, 0.52);
  background:
    linear-gradient(145deg, rgba(169, 22, 34, 0.76), rgba(14, 107, 89, 0.62)),
    rgba(255, 245, 220, 0.06);
}

.play-toggle.is-playing {
  border-color: rgba(242, 193, 78, 0.86);
  box-shadow: inset 0 0 0 1px rgba(242, 193, 78, 0.2), 0 16px 42px rgba(0, 0, 0, 0.22);
}

.play-symbol {
  grid-area: symbol;
  width: 64px;
  height: 64px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  color: #321106;
  background: linear-gradient(180deg, #ffe8a5, #f2c14e);
  font-size: 28px;
  font-weight: 900;
}

.play-copy {
  grid-area: copy;
  color: var(--brass-soft);
  font-family: "Songti SC", "STSong", Georgia, serif;
  font-size: 32px;
  font-weight: 900;
}

.play-meta {
  grid-area: meta;
  min-width: 0;
  overflow: hidden;
  color: var(--smoke);
  font-size: 13px;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.mode-button {
  width: 100%;
  color: #291006;
  border-color: rgba(255, 230, 154, 0.86);
  background: linear-gradient(180deg, #ffe8a5, #f2c14e);
  font-weight: 900;
}

.volume-control {
  min-height: 48px;
  display: grid;
  grid-template-columns: 58px 1fr;
  align-items: center;
  gap: 12px;
  color: var(--brass-soft);
  font-weight: 800;
}

input[type="range"] {
  width: 100%;
  accent-color: var(--brass);
}

.ghost-button {
  padding: 0 16px;
  font-weight: 800;
}

.ghost-button.is-muted {
  background: rgba(169, 22, 34, 0.54);
  border-color: rgba(255, 230, 154, 0.44);
}

.filter-band {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.filter-chip {
  padding: 0 10px;
  font-weight: 800;
}

.filter-chip.is-active,
.track-button.is-active {
  color: #291006;
  border-color: rgba(255, 230, 154, 0.86);
  background: linear-gradient(180deg, #ffe8a5, #f2c14e);
}

.queue-band {
  padding: 14px;
}

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

h2 {
  font-size: 18px;
}

.track-list {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
}

.track-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 74px;
  gap: 8px;
  opacity: 1;
}

.track-row.is-disabled {
  opacity: 0.58;
}

.track-button {
  min-height: 58px;
  padding: 10px 12px;
  display: grid;
  grid-template-columns: 1fr;
  align-items: center;
  gap: 8px;
  text-align: left;
}

.track-button strong,
.track-button span {
  min-width: 0;
}

.track-button strong {
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.track-button span {
  color: var(--smoke);
  font-size: 12px;
}

.track-button.is-active span {
  color: rgba(41, 16, 6, 0.68);
}

.track-toggle,
.corpus-toggle {
  padding: 0 8px;
  color: var(--smoke);
  font-size: 13px;
  font-weight: 900;
}

.track-toggle.is-on,
.corpus-toggle.is-on {
  color: #291006;
  border-color: rgba(255, 230, 154, 0.86);
  background: linear-gradient(180deg, #ffe8a5, #f2c14e);
}

.voice-ticker {
  min-height: 86px;
  display: grid;
  gap: 8px;
}

.voice-line {
  min-height: 42px;
  display: grid;
  grid-template-columns: auto auto minmax(0, 1fr);
  align-items: center;
  gap: 8px;
  border-bottom: 1px solid rgba(255, 230, 154, 0.16);
  color: var(--smoke);
}

.voice-line:last-child {
  border-bottom: 0;
}

.voice-line b {
  color: var(--brass-soft);
  font-size: 12px;
  white-space: nowrap;
}

.voice-line span {
  min-width: 0;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.settings-overlay {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 14px;
  background: rgba(19, 13, 11, 0.68);
  backdrop-filter: blur(14px);
}

.settings-dialog {
  width: min(720px, 100%);
  max-height: min(760px, calc(100vh - 28px));
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr);
  overflow: hidden;
  border: 1px solid rgba(255, 230, 154, 0.34);
  border-radius: 18px 18px var(--radius) var(--radius);
  background:
    linear-gradient(145deg, rgba(74, 17, 18, 0.98), rgba(9, 49, 43, 0.98)),
    repeating-linear-gradient(90deg, rgba(255, 230, 154, 0.08) 0 1px, transparent 1px 28px);
  box-shadow: 0 28px 92px rgba(0, 0, 0, 0.56);
}

.settings-header {
  min-height: 76px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 16px 16px 12px;
}

.settings-header p {
  color: var(--brass-soft);
  font-size: 12px;
  font-weight: 800;
}

.settings-header h2 {
  margin-top: 4px;
  font-family: "Songti SC", "STSong", Georgia, serif;
  font-size: 28px;
}

.settings-tabs {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  padding: 0 16px 12px;
}

.settings-tab {
  padding: 0 8px;
  font-weight: 900;
}

.settings-tab.is-active {
  color: #291006;
  border-color: rgba(255, 230, 154, 0.86);
  background: linear-gradient(180deg, #ffe8a5, #f2c14e);
}

.settings-panels {
  min-height: 0;
  overflow: hidden;
}

.settings-panel {
  height: 100%;
  min-height: 0;
  display: grid;
  align-content: start;
  gap: 12px;
  overflow: auto;
  padding: 0 16px 18px;
}

.settings-panel .play-toggle,
.settings-panel .mode-button,
.settings-panel .ghost-button {
  width: 100%;
  justify-content: center;
}

.settings-panel .track-list {
  max-height: 52vh;
  overflow: auto;
  padding-right: 2px;
}

.voice-corpus-list {
  max-height: 46vh;
  display: grid;
  gap: 8px;
  overflow: auto;
  padding-right: 2px;
}

.corpus-row {
  min-height: 58px;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) 72px;
  align-items: center;
  gap: 8px;
  border: 1px solid rgba(255, 230, 154, 0.16);
  border-radius: var(--radius);
  padding: 8px;
  background: rgba(255, 245, 220, 0.05);
}

.corpus-row.is-disabled {
  opacity: 0.56;
}

.corpus-avatar {
  width: 42px;
  height: 42px;
  flex-basis: 42px;
}

.corpus-copy {
  min-width: 0;
  display: grid;
  gap: 4px;
}

.corpus-copy strong,
.corpus-copy span {
  min-width: 0;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.corpus-copy strong {
  color: var(--paper);
}

.corpus-copy span,
.empty-line {
  color: var(--smoke);
  font-size: 12px;
}

.empty-line {
  min-height: 48px;
  display: grid;
  place-items: center;
  border: 1px dashed rgba(255, 230, 154, 0.22);
  border-radius: var(--radius);
}

.toast {
  position: fixed;
  left: 16px;
  right: 16px;
  bottom: max(16px, env(safe-area-inset-bottom));
  z-index: 20;
  min-height: 48px;
  display: none;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(255, 230, 154, 0.34);
  border-radius: var(--radius);
  padding: 12px 16px;
  color: var(--paper);
  background: rgba(19, 13, 11, 0.9);
  box-shadow: var(--shadow);
}

.toast.is-visible {
  display: flex;
}

@media (min-width: 720px) {
  .app-shell {
    padding-inline: 28px;
  }

  .layout {
    grid-template-columns: minmax(0, 1.1fr) minmax(320px, 0.9fr);
    align-items: start;
  }

  .hero-panel {
    min-height: calc(100vh - 128px);
  }

  .filter-band {
    grid-template-columns: repeat(6, minmax(0, 1fr));
  }

  .track-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .settings-overlay {
    align-items: center;
    padding: 28px;
  }

  .settings-dialog {
    border-radius: var(--radius);
  }
}

@media (min-width: 1040px) {
  .track-list {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    scroll-behavior: auto !important;
  }
}
