:root {
  color-scheme: light;
  --bg: #f6f3ed;
  --surface: #fffdf8;
  --surface-strong: #ffffff;
  --ink: #242424;
  --muted: #6d6a64;
  --line: #ddd5c7;
  --teal: #167c7a;
  --teal-dark: #0f5957;
  --coral: #d95f43;
  --gold: #ba8430;
  --mint: #dcefe9;
  --soft-coral: #f6dfd8;
  --shadow: 0 18px 60px rgba(53, 48, 39, 0.12);
  font-family: "Segoe UI", "Microsoft YaHei", Arial, sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 1120px;
  min-height: 100vh;
  background:
    linear-gradient(135deg, rgba(22, 124, 122, 0.08), transparent 38%),
    linear-gradient(225deg, rgba(217, 95, 67, 0.08), transparent 34%),
    var(--bg);
  color: var(--ink);
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  display: grid;
  grid-template-columns: 280px minmax(540px, 1fr) 390px;
  min-height: 100vh;
}

.sidebar,
.recommendations {
  background: rgba(255, 253, 248, 0.88);
  backdrop-filter: blur(20px);
  border-color: var(--line);
  border-style: solid;
}

.sidebar {
  border-width: 0 1px 0 0;
  padding: 28px 24px;
}

.recommendations {
  border-width: 0 0 0 1px;
  padding: 28px 22px;
  overflow-y: auto;
}

.workspace {
  padding: 28px;
  overflow: hidden;
}

.brand-row,
.topbar,
.recommend-header,
.test-controls,
.prompt-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
}

.brand-row {
  justify-content: flex-start;
  margin-bottom: 34px;
}

.brand-mark {
  display: grid;
  grid-template-columns: repeat(3, 7px);
  align-items: end;
  gap: 4px;
  width: 44px;
  height: 44px;
  padding: 10px;
  border: 1px solid rgba(22, 124, 122, 0.35);
  border-radius: 8px;
  background: var(--mint);
}

.brand-mark span {
  display: block;
  width: 7px;
  border-radius: 6px;
  background: var(--teal);
}

.brand-mark span:nth-child(1) {
  height: 14px;
}

.brand-mark span:nth-child(2) {
  height: 24px;
  background: var(--coral);
}

.brand-mark span:nth-child(3) {
  height: 18px;
  background: var(--gold);
}

h1,
h2,
h3,
p {
  margin: 0;
}

h1 {
  font-size: 22px;
  line-height: 1.1;
}

.brand-row p,
.eyebrow,
.metric-panel span,
.metric-panel small,
.profile-list dt,
.privacy-note,
.empty-state span,
.song-meta,
.song-reason {
  color: var(--muted);
}

.eyebrow {
  margin-bottom: 4px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

.field-label {
  display: block;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.text-input {
  width: 100%;
  height: 42px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--surface-strong);
  color: var(--ink);
  outline: none;
}

.text-input:focus {
  border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(22, 124, 122, 0.14);
}

.profile-panel {
  margin-top: 22px;
  padding-top: 22px;
  border-top: 1px solid var(--line);
}

.profile-panel h2 {
  margin-bottom: 16px;
  font-size: 17px;
}

.profile-list {
  margin: 0;
}

.profile-list div {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 14px;
  padding: 13px 0;
  border-bottom: 1px solid rgba(221, 213, 199, 0.7);
}

.profile-list dt {
  font-size: 13px;
}

.profile-list dd {
  margin: 0;
  text-align: right;
  font-size: 14px;
  font-weight: 700;
}

.privacy-note {
  margin-top: 28px;
  padding: 12px;
  border: 1px solid rgba(22, 124, 122, 0.18);
  border-radius: 7px;
  background: rgba(220, 239, 233, 0.65);
  font-size: 12px;
  line-height: 1.5;
}

.topbar {
  margin-bottom: 24px;
}

.topbar h2,
.recommend-header h2 {
  font-size: 24px;
}

.status-pill {
  min-width: 128px;
  padding: 9px 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface-strong);
  color: var(--muted);
  text-align: center;
  font-size: 13px;
  font-weight: 700;
}

.status-pill.active {
  border-color: rgba(217, 95, 67, 0.35);
  background: var(--soft-coral);
  color: #8c321f;
}

.test-area {
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.test-controls {
  align-items: stretch;
}

.mode-tabs {
  display: grid;
  grid-template-columns: repeat(3, 92px);
  gap: 6px;
  padding: 5px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f1eadf;
}

.mode-button {
  height: 38px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  font-weight: 700;
}

.mode-button.active {
  background: var(--surface-strong);
  color: var(--teal-dark);
  box-shadow: 0 4px 14px rgba(64, 58, 47, 0.1);
}

.record-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.primary-button,
.icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 0;
  border-radius: 7px;
  font-weight: 800;
}

.primary-button {
  gap: 9px;
  min-width: 134px;
  height: 48px;
  padding: 0 16px;
  background: var(--teal);
  color: #fff;
}

.primary-button:hover {
  background: var(--teal-dark);
}

.primary-button.recording {
  background: var(--coral);
}

.icon-button {
  width: 48px;
  height: 48px;
  border: 1px solid var(--line);
  background: var(--surface-strong);
  color: var(--ink);
}

.icon-button:hover:not(:disabled) {
  border-color: var(--teal);
  color: var(--teal-dark);
}

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

svg {
  width: 19px;
  height: 19px;
  fill: currentColor;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.icon-button svg path {
  fill: none;
}

.prompt-row {
  margin: 22px 0 16px;
  align-items: flex-end;
}

.prompt-row h3 {
  margin-bottom: 6px;
  font-size: 18px;
}

.prompt-row p {
  color: var(--muted);
  line-height: 1.5;
}

.timer {
  min-width: 96px;
  color: var(--coral);
  text-align: right;
  font-size: 30px;
  font-variant-numeric: tabular-nums;
  font-weight: 800;
}

#waveCanvas {
  display: block;
  width: 100%;
  height: 260px;
  border: 1px solid rgba(22, 124, 122, 0.18);
  border-radius: 8px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.7), rgba(220, 239, 233, 0.45)),
    repeating-linear-gradient(90deg, rgba(36, 36, 36, 0.05) 0, rgba(36, 36, 36, 0.05) 1px, transparent 1px, transparent 54px);
}

.metrics-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin-top: 18px;
}

.metric-panel {
  min-height: 126px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 253, 248, 0.9);
}

.metric-panel span,
.metric-panel small {
  display: block;
}

.metric-panel span {
  font-size: 13px;
  font-weight: 700;
}

.metric-panel strong {
  display: block;
  margin: 15px 0 8px;
  font-size: 28px;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

.metric-panel small {
  font-size: 12px;
  line-height: 1.45;
}

.metric-detail-number {
  color: #000;
  font-size: 28px;
  font-weight: 900;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

.share-section {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  margin-top: 18px;
  padding: 18px 20px;
  border: 1px solid rgba(22, 124, 122, 0.28);
  border-radius: 8px;
  background: rgba(220, 239, 233, 0.72);
}

.share-section[hidden],
.share-modal[hidden] {
  display: none;
}

.share-section h3 {
  margin-bottom: 5px;
  font-size: 16px;
}

.share-section p,
.share-privacy {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

.share-button,
.share-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  min-height: 48px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--surface-strong);
  color: var(--ink);
  font-weight: 800;
}

.share-button {
  flex: 0 0 auto;
  padding: 0 20px;
  border-color: var(--teal);
  background: var(--teal);
  color: #fff;
}

.share-button:hover,
.share-action-primary:hover {
  background: var(--teal-dark);
}

.share-button:disabled {
  cursor: wait;
  opacity: 0.7;
}

.modal-open {
  overflow: hidden;
}

.share-modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  padding: 24px;
}

.share-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(20, 22, 20, 0.58);
  backdrop-filter: blur(5px);
}

.share-sheet {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: minmax(260px, 420px) minmax(300px, 380px);
  grid-template-rows: auto 1fr;
  gap: 20px 24px;
  width: min(880px, 100%);
  max-height: calc(100vh - 48px);
  padding: 22px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: 0 28px 90px rgba(20, 22, 20, 0.28);
}

.share-sheet-header {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.share-sheet-header h2 {
  font-size: 22px;
}

.share-preview-wrap {
  align-self: start;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #eee9df;
}

.share-preview {
  display: block;
  width: 100%;
  max-height: calc(100vh - 190px);
  object-fit: contain;
  border-radius: 4px;
}

.share-actions-grid {
  display: grid;
  align-content: start;
  gap: 10px;
}

.share-action {
  width: 100%;
  padding: 0 16px;
}

.share-action:hover {
  border-color: var(--teal);
  color: var(--teal-dark);
}

.share-action-primary {
  border-color: var(--teal);
  background: var(--teal);
  color: #fff;
}

.share-action-primary:hover {
  color: #fff;
}

.share-privacy {
  margin-top: 4px;
  padding: 12px;
  border: 1px solid rgba(22, 124, 122, 0.18);
  border-radius: 7px;
  background: rgba(220, 239, 233, 0.55);
}

.recommend-header {
  margin-bottom: 20px;
}

.song-list {
  display: grid;
  gap: 12px;
}

.empty-state {
  display: grid;
  gap: 8px;
  padding: 24px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.5);
}

.song-item {
  padding: 15px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-strong);
}

.song-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.song-title {
  font-size: 16px;
  font-weight: 800;
}

.song-meta {
  margin-top: 4px;
  font-size: 12px;
}

.song-score {
  min-width: 52px;
  color: var(--teal-dark);
  text-align: right;
  font-size: 18px;
  font-weight: 900;
}

.score-track {
  height: 7px;
  margin: 13px 0 12px;
  overflow: hidden;
  border-radius: 999px;
  background: #efe5d6;
}

.score-fill {
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--teal), var(--gold));
}

.song-reason {
  font-size: 13px;
  line-height: 1.5;
}

.song-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 12px;
}

.song-tags span {
  padding: 4px 8px;
  border-radius: 999px;
  background: rgba(220, 239, 233, 0.8);
  color: var(--teal-dark);
  font-size: 12px;
  font-weight: 700;
}

@media (max-width: 1240px) {
  body {
    min-width: 980px;
  }

  .app-shell {
    grid-template-columns: 250px minmax(480px, 1fr) 330px;
  }

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

@media (max-width: 900px) {
  body {
    min-width: 0;
    overflow-x: hidden;
  }

  .app-shell {
    grid-template-columns: 1fr;
    grid-template-areas:
      "workspace"
      "sidebar"
      "recommendations";
    min-height: auto;
  }

  .workspace {
    grid-area: workspace;
    padding: 18px 14px;
    overflow: visible;
  }

  .sidebar {
    grid-area: sidebar;
    border-width: 1px 0 0;
    padding: 22px 18px;
  }

  .recommendations {
    grid-area: recommendations;
    border-width: 1px 0 0;
    padding: 22px 14px 32px;
    overflow: visible;
  }

  .topbar,
  .test-controls {
    align-items: stretch;
    flex-direction: column;
  }

  .topbar {
    gap: 12px;
    margin-bottom: 16px;
  }

  .status-pill {
    min-width: 0;
    width: 100%;
  }

  .test-area {
    padding: 14px;
  }

  .mode-tabs {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    width: 100%;
  }

  .record-actions {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 52px;
    width: 100%;
  }

  .primary-button {
    min-width: 0;
    width: 100%;
  }

  .icon-button {
    width: 52px;
  }

  .prompt-row {
    align-items: flex-start;
    gap: 12px;
  }

  .timer {
    min-width: 84px;
    font-size: 26px;
  }

  #waveCanvas {
    height: 190px;
  }

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

  .share-sheet {
    grid-template-columns: minmax(230px, 0.9fr) minmax(260px, 1.1fr);
  }
}

@media (max-width: 520px) {
  .workspace {
    padding: 14px 10px;
  }

  .topbar h2,
  .recommend-header h2 {
    font-size: 22px;
  }

  .test-controls {
    gap: 12px;
  }

  .mode-tabs {
    gap: 4px;
    padding: 4px;
  }

  .mode-button {
    height: 40px;
  }

  .record-actions {
    grid-template-columns: minmax(0, 1fr) 50px;
  }

  .primary-button,
  .icon-button {
    height: 50px;
  }

  .icon-button {
    width: 50px;
  }

  .prompt-row {
    flex-direction: column;
  }

  .timer {
    min-width: 0;
    text-align: left;
  }

  #waveCanvas {
    height: 170px;
  }

  .metrics-grid {
    gap: 10px;
  }

  .metric-panel {
    min-height: 132px;
    padding: 14px;
  }

  .metric-detail-number {
    font-size: 24px;
  }

  .share-section {
    align-items: stretch;
    flex-direction: column;
    padding: 16px;
  }

  .share-button {
    width: 100%;
  }

  .share-modal {
    align-items: end;
    padding: 0;
  }

  .share-sheet {
    grid-template-columns: 1fr;
    grid-template-rows: auto auto auto;
    gap: 14px;
    width: 100%;
    max-height: 92vh;
    padding: 18px 14px calc(18px + env(safe-area-inset-bottom));
    border-width: 1px 0 0;
    border-radius: 8px 8px 0 0;
  }

  .share-sheet-header {
    grid-column: 1;
  }

  .share-preview-wrap {
    width: min(260px, 72vw);
    margin: 0 auto;
  }

  .share-preview {
    max-height: 40vh;
  }

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

  .share-action-primary {
    grid-column: 1 / -1;
  }

  .share-action {
    min-width: 0;
    padding: 0 10px;
    font-size: 13px;
  }

  .sidebar,
  .recommendations {
    padding-left: 14px;
    padding-right: 14px;
  }
}
