:root {
  --ink: #18201d;
  --muted: #5c6a64;
  --faint: #849089;
  --line: #d9e0dc;
  --bg: #edf1ef;
  --paper: #ffffff;
  --accent: #0f6b5f;
  --accent-strong: #0a554c;
  --accent-soft: #e0f1ed;
  --blue: #2b6c9e;
  --amber: #a46a12;
  --danger: #b23a2e;
  --shadow: 0 1px 2px rgba(24, 32, 29, 0.08);
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: "PingFang SC", "Microsoft YaHei", "Noto Sans SC", system-ui, -apple-system, sans-serif;
  line-height: 1.45;
  padding-bottom: calc(32px + env(safe-area-inset-bottom));
}

button,
input,
select,
textarea {
  font: inherit;
  color: inherit;
}

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

.auth-overlay {
  position: fixed;
  inset: 0;
  z-index: 120;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(237, 241, 239, 0.97);
  backdrop-filter: blur(6px);
}

.auth-box {
  width: min(440px, 100%);
  max-height: calc(100vh - 40px);
  overflow: auto;
  padding: 22px;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 12px 30px rgba(24, 32, 29, 0.16);
}

.auth-box h2 {
  margin: 0 0 6px;
  font-size: 20px;
  line-height: 1.3;
  letter-spacing: 0;
}

.auth-box > p {
  margin: 0 0 14px;
  color: var(--muted);
  font-size: 13px;
}

.login-field {
  display: grid;
  gap: 6px;
  margin-bottom: 12px;
}

.login-field span {
  color: var(--muted);
  font-size: 13px;
}

.login-field input {
  width: 100%;
  min-height: 44px;
  padding: 8px 10px;
  border: 1px solid #c6d0cb;
  border-radius: 6px;
  background: #fcfdfd;
  outline: none;
}

.login-field input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(15, 107, 95, 0.15);
}

.login-error {
  margin-top: 10px !important;
  color: var(--danger);
  font-size: 13px;
}

.consent-text {
  margin: 10px 0 14px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #f7f9f8;
  font-size: 13px;
  line-height: 1.6;
}

.consent-text p {
  margin: 0 0 8px;
}

.consent-text p:last-child {
  margin-bottom: 0;
}

.consent-check {
  display: flex;
  gap: 8px;
  align-items: flex-start;
  margin-bottom: 14px;
  font-size: 14px;
  line-height: 1.5;
}

.consent-check input {
  width: 18px;
  height: 18px;
  flex: 0 0 auto;
  margin-top: 2px;
}

.mode-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(237, 241, 239, 0.96);
  backdrop-filter: blur(6px);
}

.mode-box {
  width: min(440px, 100%);
  padding: 22px;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 12px 30px rgba(24, 32, 29, 0.16);
}

.mode-box h2 {
  margin: 0 0 6px;
  font-size: 20px;
  line-height: 1.3;
  letter-spacing: 0;
}

.mode-box > p {
  margin: 0 0 16px;
  color: var(--muted);
  font-size: 13px;
}

.mode-actions {
  display: grid;
  gap: 12px;
}

.mode-btn {
  display: grid;
  gap: 5px;
  width: 100%;
  min-height: 84px;
  padding: 14px 16px;
  border: 1px solid #c6d0cb;
  border-radius: 6px;
  background: #fbfcfc;
  text-align: left;
}

.mode-btn strong {
  font-size: 17px;
  letter-spacing: 0;
}

.mode-btn span {
  color: var(--muted);
  font-size: 13px;
}

.mode-tag {
  display: inline-block;
  margin-left: 6px;
  padding: 2px 7px;
  border-radius: 999px;
  background: #fbf3df;
  border: 1px solid #e6cf9c;
  color: var(--amber);
  font-size: 11px;
  font-weight: 400;
  vertical-align: 2px;
}

.mode-btn:active,
.mode-btn:focus {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.mode-label {
  display: inline-block;
  margin-right: 6px;
  padding: 2px 7px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent-strong);
  font-size: 12px;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px calc(12px + env(safe-area-inset-top));
  background: rgba(255, 255, 255, 0.94);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(8px);
}

.topbar h1 {
  margin: 0;
  font-size: 21px;
  line-height: 1.2;
  letter-spacing: 0;
}

.subline {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.badge {
  flex: 0 0 auto;
  min-width: 72px;
  padding: 6px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--paper);
  color: var(--muted);
  font-size: 12px;
  text-align: center;
}

.badge.ok {
  border-color: #b7d8cd;
  background: var(--accent-soft);
  color: var(--accent-strong);
}

.badge.warn {
  border-color: #e6cf9c;
  background: #fbf3df;
  color: var(--amber);
}

.badge.error {
  border-color: #e3b6ae;
  background: #fae9e5;
  color: var(--danger);
}

main {
  width: min(760px, 100%);
  margin: 0 auto;
  padding: 16px;
}

.panel {
  margin: 0 0 16px;
  padding: 16px;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.panel-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.panel-head h2 {
  margin: 0;
  font-size: 17px;
  line-height: 1.3;
  letter-spacing: 0;
}

.section-note {
  margin: 4px 0 0;
  color: var(--faint);
  font-size: 12px;
}

.text-btn {
  border: 0;
  background: transparent;
  color: var(--blue);
  font-size: 13px;
  padding: 6px 0;
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
}

.field {
  display: grid;
  gap: 6px;
  min-width: 0;
}

.field > span {
  color: var(--muted);
  font-size: 13px;
}

.field input,
.field select,
.field textarea {
  width: 100%;
  min-height: 44px;
  padding: 8px 10px;
  border: 1px solid #c6d0cb;
  border-radius: 6px;
  background: #fcfdfd;
  outline: none;
}

.field input:focus,
.field select:focus,
.field textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(15, 107, 95, 0.15);
}

.field textarea {
  min-height: 84px;
  resize: vertical;
  line-height: 1.5;
}

.field-example {
  color: var(--faint);
  font-size: 12px;
  line-height: 1.4;
}

.record-panel {
  overflow: hidden;
}

.guided-panel {
  margin: 0 0 14px;
  padding: 12px;
  border: 1px solid #b7d8cd;
  border-radius: 6px;
  background: var(--accent-soft);
}

.guided-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  color: var(--accent-strong);
  font-size: 14px;
  font-weight: 600;
}

.progress-track {
  position: relative;
  height: 10px;
  margin: 8px 0 10px;
  overflow: hidden;
  border-radius: 999px;
  background: #dcebe6;
}

#taskProgressFill {
  display: block;
  width: 0;
  height: 100%;
  border-radius: 999px;
  background: var(--accent);
  transition: width 0.25s ease;
}

.task-prompt-label {
  margin: 0 0 4px;
  color: var(--muted);
  font-size: 13px;
}

.task-prompt {
  margin: 0;
  font-size: 17px;
  line-height: 1.55;
  letter-spacing: 0;
}

.record-stage {
  display: grid;
  justify-items: center;
  padding: 8px 0 4px;
}

.mic-btn {
  width: 104px;
  height: 104px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  box-shadow: 0 8px 18px rgba(15, 107, 95, 0.28);
  transition: transform 0.12s ease, background 0.12s ease;
}

.mic-btn:active {
  transform: scale(0.96);
}

.mic-btn svg {
  width: 44px;
  height: 44px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.mic-btn.recording {
  background: var(--danger);
  box-shadow: 0 0 0 0 rgba(178, 58, 46, 0.55);
  animation: pulse 1.5s ease-out infinite;
}

.record-hint {
  margin: 10px 0 6px;
  color: var(--muted);
  font-size: 14px;
}

.sentence-reminder {
  grid-column: 1 / -1;
  margin: 0 0 8px;
  padding: 7px 10px;
  border: 1px solid #e2c98f;
  border-radius: 6px;
  background: #fbf3df;
  color: var(--amber);
  font-size: 13px;
  text-align: center;
}

.auto-id-line {
  margin: 4px 0 8px;
  color: var(--muted);
  font-size: 13px;
  text-align: center;
}

.auto-id-line strong {
  color: var(--accent-strong);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

@keyframes pulse {
  70% {
    box-shadow: 0 0 0 14px rgba(178, 58, 46, 0);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(178, 58, 46, 0);
  }
}

.timer {
  min-width: 58px;
  padding: 5px 9px;
  border-radius: 6px;
  background: #f2f5f3;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
  font-size: 14px;
  text-align: center;
}

.timer.live {
  background: #fae9e5;
  color: var(--danger);
}

.meter {
  width: min(480px, 100%);
  height: 48px;
}

.audio-preview-wrap {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  margin: 8px 0 14px;
  padding: 10px 12px;
  background: var(--accent-soft);
  border-radius: 6px;
  color: var(--accent-strong);
  font-size: 13px;
}

.audio-preview-wrap audio {
  min-width: 220px;
  flex: 1;
  height: 36px;
}

.save-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px dashed var(--line);
}

.primary,
.secondary,
.ghost {
  min-height: 44px;
  padding: 10px 16px;
  border-radius: 6px;
  font-size: 15px;
}

.primary {
  border: 1px solid var(--accent);
  background: var(--accent);
  color: #fff;
}

.primary.small {
  min-height: 36px;
  padding: 6px 12px;
  font-size: 13px;
}

.secondary.small {
  min-height: 36px;
  padding: 6px 12px;
  font-size: 13px;
}

.panel-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

.secondary {
  border: 1px solid #c6d0cb;
  background: #fff;
  color: var(--ink);
}

.danger-btn {
  border: 0;
  background: transparent;
  color: var(--danger);
  font-size: 13px;
}

.empty {
  margin: 4px 0 0;
  padding: 26px 12px;
  border: 1px dashed var(--line);
  border-radius: 6px;
  color: var(--faint);
  text-align: center;
}

.recording-list {
  display: grid;
  gap: 10px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.recording-item {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fbfcfc;
}

.item-top {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 4px;
}

.item-title {
  display: flex;
  align-items: center;
  gap: 7px;
  min-width: 0;
}

.item-top strong {
  font-size: 14px;
  letter-spacing: 0;
}

.item-date {
  color: var(--faint);
  font-size: 12px;
}

.item-meta {
  display: grid;
  gap: 2px;
  margin: 2px 0 8px;
  color: var(--muted);
  font-size: 13px;
}

.transcript-line {
  color: var(--ink);
  font-size: 13px;
  line-height: 1.55;
}

.recording-item audio {
  display: block;
  width: 100%;
  height: 38px;
  margin-bottom: 8px;
}

.item-actions {
  display: flex;
  justify-content: flex-end;
  gap: 14px;
}

.item-actions button {
  min-height: 32px;
  padding: 4px 2px;
  border: 0;
  background: transparent;
  color: var(--blue);
  font-size: 13px;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(18px + env(safe-area-inset-bottom));
  z-index: 30;
  transform: translateX(-50%);
  max-width: calc(100vw - 32px);
  padding: 10px 14px;
  border-radius: 6px;
  background: rgba(24, 32, 29, 0.92);
  color: #fff;
  font-size: 14px;
  text-align: center;
}

@media (min-width: 640px) {
  .form-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

.form-grid .full {
  grid-column: 1 / -1;
}

.full-width {
  width: 100%;
}

.step-actions {
  margin-top: 16px;
}

.assignment-notice {
  margin: 12px 0 0;
  padding: 8px 10px;
  border: 1px solid #c6d0cb;
  border-radius: 6px;
  background: #f7f9f8;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

.assignment-notice.warn {
  border-color: #e6cf9c;
  background: #fbf3df;
  color: var(--amber);
}

  .record-stage {
    grid-template-columns: auto 1fr;
    align-items: center;
    column-gap: 22px;
    padding: 4px 0;
  }

  .record-hint {
    margin: 0;
    justify-self: start;
  }

  .record-stage .meter {
    grid-column: 1 / -1;
  }

  .record-stage .auto-id-line {
    grid-column: 1 / -1;
  }
}
