:root {
  color-scheme: light;
  --ink: #17191c;
  --muted: #66717f;
  --paper: #f4f0e8;
  --card: #fffdf8;
  --line: #ddd5c8;
  --accent: #0e7c66;
  --accent-strong: #075f50;
  --danger: #bd3b2b;
  --shadow: 0 18px 54px rgba(23, 25, 28, 0.13);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  color: var(--ink);
  background:
    linear-gradient(135deg, rgba(14, 124, 102, 0.14), transparent 32%),
    linear-gradient(315deg, rgba(189, 59, 43, 0.11), transparent 28%),
    var(--paper);
}

button,
input {
  font: inherit;
}

button {
  border: 0;
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.48;
}

.app-shell {
  width: min(720px, 100%);
  min-height: 100vh;
  margin: 0 auto;
  padding: max(18px, env(safe-area-inset-top)) 16px max(24px, env(safe-area-inset-bottom));
}

.topbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 8px 0 18px;
}

.top-actions {
  display: flex;
  gap: 8px;
}

.kicker {
  margin: 0 0 6px;
  color: var(--accent-strong);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

h1 {
  margin: 0;
  font-size: 32px;
  letter-spacing: 0;
}

.icon-button {
  width: 42px;
  height: 42px;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: rgba(255, 253, 248, 0.75);
  color: var(--accent-strong);
  font-size: 22px;
}

.identity-card,
.session-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 253, 248, 0.92);
  box-shadow: var(--shadow);
  padding: 18px;
}

.identity-card label {
  display: block;
  margin-bottom: 10px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 700;
}

.name-row {
  display: grid;
  grid-template-columns: 1fr 96px;
  gap: 10px;
}

input[type="text"],
input[type="search"] {
  width: 100%;
  min-height: 48px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: white;
  padding: 0 14px;
  outline: none;
}

input[type="text"]:focus,
input[type="search"]:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(14, 124, 102, 0.14);
}

.name-row button,
#saveButton,
.secondary {
  min-height: 48px;
  border-radius: 6px;
  padding: 0 16px;
  background: var(--accent);
  color: white;
  font-weight: 850;
}

.progress-head {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  align-items: center;
}

.progress-head div {
  display: grid;
  gap: 4px;
}

.progress-head span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 750;
}

.progress-head strong {
  font-size: 22px;
}

#exportLink {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 8px 13px;
  color: var(--accent-strong);
  background: white;
  font-size: 14px;
  font-weight: 800;
  text-decoration: none;
}

.progress-track {
  height: 9px;
  margin: 16px 0 20px;
  overflow: hidden;
  border-radius: 999px;
  background: #e8e0d2;
}

#progressBar {
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--accent), #d65a3e);
  transition: width 220ms ease;
}

.prompt-card {
  min-height: 236px;
  display: grid;
  align-content: center;
  gap: 14px;
  border: 1px solid #d8cfbf;
  border-radius: 8px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.84), rgba(255, 253, 248, 0.96)),
    repeating-linear-gradient(0deg, transparent, transparent 38px, rgba(14, 124, 102, 0.08) 39px);
  padding: 28px 22px;
}

.prompt-card p {
  margin: 0;
  color: var(--accent-strong);
  font-size: 13px;
  font-weight: 900;
  letter-spacing: 0.12em;
}

.prompt-card h2 {
  margin: 0;
  font-size: clamp(28px, 9vw, 48px);
  line-height: 1.35;
  letter-spacing: 0;
}

.current-recording {
  display: grid;
  gap: 10px;
  margin-top: 12px;
  border: 1px solid #e3dacd;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.68);
  padding: 12px;
}

.current-recording div {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.current-recording strong {
  font-size: 15px;
}

.current-recording span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.current-recording audio {
  margin: 0;
}

.meter {
  height: 42px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  margin: 12px 0;
}

.meter span {
  width: 7px;
  height: 12px;
  border-radius: 999px;
  background: rgba(14, 124, 102, 0.24);
}

.record-button.recording ~ .meter span,
.session-card:has(.record-button.recording) .meter span {
  animation: pulse 720ms ease-in-out infinite alternate;
  background: var(--danger);
}

.meter span:nth-child(2),
.meter span:nth-child(6) {
  animation-delay: 80ms;
}

.meter span:nth-child(3),
.meter span:nth-child(5) {
  animation-delay: 150ms;
}

.meter span:nth-child(4) {
  animation-delay: 220ms;
}

@keyframes pulse {
  from {
    height: 10px;
  }
  to {
    height: 38px;
  }
}

.record-actions {
  display: grid;
  grid-template-columns: 78px 1fr 78px;
  gap: 10px;
  align-items: stretch;
}

.record-button {
  min-height: 72px;
  border-radius: 8px;
  background: var(--danger);
  color: white;
  font-size: 20px;
  font-weight: 900;
  box-shadow: 0 12px 24px rgba(189, 59, 43, 0.22);
}

.record-button.recording {
  background: #17191c;
}

.secondary {
  background: #efe7d8;
  color: var(--ink);
}

audio {
  width: 100%;
  margin-top: 16px;
}

.save-row {
  display: grid;
  grid-template-columns: 1fr 92px;
  gap: 10px;
  margin-top: 14px;
}

.empty-history {
  margin: 0;
  border: 1px dashed var(--line);
  border-radius: 8px;
  padding: 14px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.52);
}

.sentence-drawer {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: flex;
  justify-content: flex-end;
  background: rgba(23, 25, 28, 0.34);
  padding: max(12px, env(safe-area-inset-top)) 12px max(12px, env(safe-area-inset-bottom));
}

.drawer-panel {
  width: min(420px, 100%);
  display: grid;
  grid-template-rows: auto auto 1fr auto;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--card);
  box-shadow: var(--shadow);
  padding: 14px;
}

.drawer-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.drawer-head h3 {
  margin: 0;
  font-size: 20px;
}

.sentence-list {
  min-height: 0;
  display: grid;
  align-content: start;
  gap: 10px;
  overflow: auto;
  padding-right: 2px;
}

.sentence-item {
  display: grid;
  grid-template-columns: 1fr 74px;
  gap: 10px;
  align-items: center;
  border: 1px solid #e3dacd;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.7);
  padding: 10px;
}

.sentence-item[data-active="true"] {
  border-color: rgba(14, 124, 102, 0.58);
  box-shadow: 0 0 0 3px rgba(14, 124, 102, 0.1);
}

.sentence-main {
  min-width: 0;
  display: grid;
  gap: 4px;
  border: 0;
  background: transparent;
  padding: 0;
  text-align: left;
}

.sentence-main strong {
  color: var(--accent-strong);
  font-size: 13px;
  letter-spacing: 0.08em;
}

.sentence-main span {
  overflow: hidden;
  color: var(--ink);
  font-weight: 750;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sentence-action {
  min-height: 38px;
  padding: 0 10px;
  border-radius: 6px;
  background: #efe7d8;
  color: var(--ink);
  font-weight: 850;
}

.sentence-action.pending {
  background: #f6f1e8;
  color: var(--muted);
}

.load-more {
  min-height: 44px;
  border-radius: 6px;
  background: var(--accent);
  color: white;
  font-weight: 850;
}

.status-line {
  min-height: 44px;
  margin: 16px 0 0;
  border: 1px solid #e5ddcf;
  border-radius: 8px;
  background: #fcf8ef;
  padding: 12px;
  color: var(--muted);
  line-height: 1.5;
}

[hidden] {
  display: none !important;
}

@media (max-width: 420px) {
  .app-shell {
    padding-left: 12px;
    padding-right: 12px;
  }

  h1 {
    font-size: 28px;
  }

  .identity-card,
  .session-card {
    padding: 14px;
  }

  .prompt-card {
    min-height: 210px;
    padding: 24px 18px;
  }

  .record-actions {
    grid-template-columns: 68px 1fr 68px;
  }
}
