:root {
  --bg: #f1f3ef;
  --surface: #fffefa;
  --ink: #161814;
  --muted: #747a70;
  --line: #dfe3db;
  --green: #15a675;
  --green-soft: #dcf7e3;
  --blue: #23779a;
  --blue-soft: #e2f1f7;
  --dark: #1f2f38;
  --danger: #d94b40;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font-family: "Microsoft YaHei", "PingFang SC", "Segoe UI", sans-serif;
  letter-spacing: 0;
}

button,
textarea,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

.app {
  width: min(100%, 1060px);
  margin: 0 auto;
  padding: 18px;
}

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

.topbar p {
  margin: 0 0 4px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: 28px;
  line-height: 1.15;
}

h2 {
  font-size: 18px;
  margin-bottom: 12px;
}

#switchLink,
#logoutButton {
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  color: var(--green);
  padding: 8px 13px;
  text-decoration: none;
  font-weight: 900;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

#logoutButton {
  color: var(--dark);
}

.hidden {
  display: none !important;
}

.composer,
.teacher-panel,
.record-card {
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  box-shadow: 0 12px 40px rgba(33, 40, 34, 0.08);
}

.composer,
.teacher-panel {
  padding: 16px;
  margin-bottom: 16px;
}

label {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  color: var(--ink);
  padding: 12px;
  outline: none;
  resize: vertical;
  line-height: 1.55;
  overflow: hidden;
}

textarea:focus {
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(21, 166, 117, 0.13);
}

input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  color: var(--ink);
  padding: 12px;
  outline: none;
}

input:focus {
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(21, 166, 117, 0.13);
}

.login-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 18px;
}

.login-card {
  width: min(100%, 420px);
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  box-shadow: 0 12px 40px rgba(33, 40, 34, 0.08);
  padding: 22px;
}

.login-card p {
  margin-bottom: 4px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.login-form {
  display: grid;
  gap: 14px;
  margin-top: 18px;
}

.login-message {
  color: #9b3229;
  min-height: 20px;
  font-size: 14px;
  font-weight: 800;
}

.record-line {
  display: grid;
  grid-template-columns: minmax(138px, auto) auto 64px 1fr;
  align-items: center;
  gap: 12px;
  margin-top: 12px;
}

.sentence-list {
  display: grid;
  gap: 10px;
  margin-top: 12px;
}

.sentence-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto 58px;
  gap: 10px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  padding: 10px;
}

.sentence-text {
  min-width: 0;
  line-height: 1.55;
}

.sentence-index {
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
}

.record-button,
.dark-button,
.mini-button,
.drop-zone {
  border: 0;
  border-radius: 999px;
  min-height: 42px;
  padding: 9px 16px;
  color: #fff;
  font-weight: 900;
}

.sentence-item .record-button {
  min-width: 98px;
}

.sentence-item .timer {
  text-align: right;
}

.sentence-item .level-meter {
  grid-column: 1 / -1;
}

.record-button {
  background: var(--green);
}

.record-button.teacher {
  background: var(--blue);
}

.record-button.recording {
  background: var(--danger);
}

.dark-button {
  width: 100%;
  margin-top: 10px;
  background: var(--dark);
}

.mini-button {
  min-height: 34px;
  padding: 7px 11px;
  background: var(--dark);
  font-size: 13px;
}

.drop-zone {
  border: 1px dashed #9fb4a9;
  background: #fff;
  color: var(--muted);
  font-size: 13px;
}

.drop-zone.compact {
  min-height: 34px;
  padding: 7px 11px;
}

.drop-zone.dragging,
.drop-zone.uploading {
  border-color: var(--green);
  background: var(--green-soft);
  color: #08744e;
}

.mini-button.danger {
  background: #fff1ed;
  color: #9b3229;
  border: 1px solid #efc3bc;
}

.mini-button.ghost {
  min-height: 28px;
  padding: 4px 9px;
  font-size: 12px;
}

.timer {
  color: var(--muted);
  font-weight: 900;
  font-variant-numeric: tabular-nums;
}

.level-meter {
  height: 9px;
  border-radius: 999px;
  background: #dde5df;
  overflow: hidden;
}

.level-meter span {
  display: block;
  width: 4%;
  height: 100%;
  border-radius: inherit;
  background: var(--green);
  transition: width 90ms linear;
}

.level-meter.active span {
  background: var(--danger);
}

.mic-help {
  margin: 12px 0 0;
  border: 1px solid #f0d2a8;
  border-radius: 10px;
  background: #fff8ec;
  color: #8c5a10;
  padding: 10px 12px;
  font-size: 14px;
}

.records-section {
  margin-top: 4px;
}

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

.section-title h2 {
  margin: 0;
}

.section-title button {
  border: 0;
  background: transparent;
  color: var(--green);
  font-weight: 900;
}

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

.record-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(210px, 0.34fr);
  overflow: hidden;
}

.record-card.no-side {
  grid-template-columns: 1fr;
}

.record-card.active {
  outline: 3px solid rgba(21, 166, 117, 0.18);
}

.student-side,
.teacher-side {
  padding: 15px;
}

.teacher-side {
  border-left: 1px solid var(--line);
  background: #fbfcfb;
}

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

.card-title {
  margin: 0 0 4px;
  font-size: 17px;
  font-weight: 900;
}

.card-title-wrap {
  min-width: 0;
  width: 100%;
}

.title-edit-row {
  display: flex;
  align-items: flex-start;
  gap: 4px;
  color: var(--ink);
  font-size: 21px;
  font-weight: 900;
}

.title-edit-row span {
  flex: 0 0 auto;
  padding-top: 3px;
}

.title-edit {
  min-height: 34px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  padding: 2px 4px;
  color: var(--ink);
  font-size: 21px;
  font-weight: 900;
  line-height: 1.35;
  resize: none;
}

.title-edit:focus {
  border-color: transparent;
  background: #fff;
  box-shadow: 0 0 0 2px rgba(21, 166, 117, 0.16);
}

.card-meta {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.voice-pill {
  display: grid;
  grid-template-columns: 38px 1fr auto;
  align-items: center;
  gap: 10px;
  width: min(100%, 360px);
  border: 0;
  border-radius: 999px;
  padding: 8px 12px;
  background: var(--green-soft);
  color: var(--ink);
  text-align: left;
}

.voice-pill.playing .play-icon {
  background: var(--dark);
  color: #fff;
}

.teacher-side .voice-pill {
  background: var(--blue-soft);
}

.play-icon {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: #fff;
  font-size: 13px;
  font-weight: 900;
}

.voice-bar {
  height: 5px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.17);
  overflow: hidden;
}

.voice-fill {
  display: block;
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: rgba(0, 0, 0, 0.55);
}

.voice-time {
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
}

.feedback-text {
  white-space: pre-wrap;
  line-height: 1.55;
  margin: 0 0 10px;
}

.feedback-edit {
  min-height: 82px;
  margin-bottom: 10px;
  resize: vertical;
}

.muted {
  color: var(--muted);
}

.button-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-top: 10px;
}

.retry-list {
  display: grid;
  gap: 8px;
  margin-top: 10px;
}

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

.attempt-block {
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  padding: 11px;
}

.attempt-block.selected-attempt {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(35, 119, 154, 0.13);
}

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

.attempt-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.attempt-flow {
  display: grid;
  grid-template-columns: minmax(190px, 0.9fr) minmax(230px, 1.1fr);
  gap: 10px;
}

.attempt-col {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fbfcfb;
  padding: 9px;
}

.feedback-col {
  background: #fffefa;
}

.status-chip {
  flex: 0 0 auto;
  border-radius: 999px;
  background: var(--green-soft);
  color: #08744e;
  padding: 4px 9px;
  font-size: 12px;
  font-weight: 900;
}

.feedback-col .mini-button {
  margin-top: 8px;
}

.feedback-col .drop-zone {
  margin-top: 8px;
  margin-right: 8px;
}

@media (max-width: 760px) {
  .app {
    padding: 14px;
  }

  .record-card {
    grid-template-columns: 1fr;
  }

  .attempt-flow {
    grid-template-columns: 1fr;
  }

  .teacher-side {
    border-left: 0;
    border-top: 1px solid var(--line);
  }

  .record-line {
    grid-template-columns: 1fr;
  }

  .sentence-item {
    grid-template-columns: 1fr;
  }

  .sentence-item .timer {
    text-align: left;
  }

  .level-meter {
    grid-column: 1 / -1;
  }
}
