:root {
  --ink: #17211f;
  --muted: #65716c;
  --paper: #fbf8f1;
  --panel: #ffffff;
  --line: #ddd6ca;
  --green: #0f5a4e;
  --green-soft: #dceee8;
  --red: #aa3b30;
  --amber: #8a5a18;
  --amber-soft: #fff4db;
  --blue-soft: #eef3ff;
  --shadow: 0 18px 45px rgba(28, 35, 32, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background:
    linear-gradient(135deg, rgba(15, 90, 78, 0.08), transparent 35%),
    linear-gradient(315deg, rgba(138, 90, 24, 0.09), transparent 38%),
    var(--paper);
  font-family: "Microsoft YaHei", "PingFang SC", "Noto Sans SC", sans-serif;
}

button,
textarea,
a {
  font: inherit;
}

button {
  border: 0;
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
}

.app-shell {
  width: min(1120px, calc(100% - 32px));
  margin: 0 auto;
  padding: 34px 0 42px;
}

.topbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 24px;
}

.kicker,
.eyebrow {
  margin: 0 0 8px;
  color: var(--amber);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

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

h1 {
  margin-bottom: 8px;
  font-size: clamp(34px, 5vw, 64px);
  line-height: 1.02;
}

h2 {
  margin-bottom: 0;
  font-size: 24px;
  line-height: 1.25;
}

h3 {
  margin-bottom: 8px;
  font-size: 15px;
}

.subtitle,
.note,
.voice-note,
.flow-hint {
  color: var(--muted);
  line-height: 1.7;
}

.session-meter {
  min-width: 96px;
  padding: 14px 18px;
  color: var(--green);
  background: var(--green-soft);
  border: 1px solid rgba(15, 90, 78, 0.16);
  border-radius: 8px;
  text-align: center;
  box-shadow: var(--shadow);
}

.session-meter span:first-child {
  font-size: 30px;
  font-weight: 900;
}

.mode-tabs {
  display: flex;
  gap: 10px;
  margin-bottom: 18px;
}

.tab-button,
.segment-button {
  min-height: 40px;
  padding: 0 16px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.68);
  border: 1px solid var(--line);
  border-radius: 8px;
  font-weight: 800;
}

.tab-button.active,
.segment-button.active {
  color: #fff;
  background: var(--green);
  border-color: var(--green);
}

.workspace,
.practice-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.55fr) minmax(300px, 0.95fr);
  gap: 18px;
}

.copy-panel,
.brief-panel,
.sentence-card,
.tool-panel,
.feedback-panel,
.summary-panel,
.permission-banner,
.generator-panel,
.material-panel {
  background: rgba(255, 255, 255, 0.9);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.copy-panel,
.brief-panel,
.sentence-card,
.tool-panel,
.feedback-panel,
.summary-panel,
.permission-banner,
.generator-panel,
.material-panel {
  padding: 24px;
}

.generator-view {
  display: grid;
  grid-template-columns: minmax(280px, 0.72fr) minmax(0, 1.28fr);
  gap: 18px;
  align-items: start;
}

.generator-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 18px;
}

.segmented-control {
  display: flex;
  gap: 8px;
  padding: 4px;
  background: #f3eee5;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.material-panel {
  max-height: calc(100vh - 170px);
  overflow: auto;
}

.material-section {
  padding-top: 18px;
  margin-top: 18px;
  border-top: 1px solid var(--line);
}

.material-section:first-of-type {
  padding-top: 0;
  margin-top: 0;
  border-top: 0;
}

.material-section p,
.analysis-list,
.tips-list {
  color: #2b3532;
  line-height: 1.82;
}

.terms-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.term-item {
  display: grid;
  gap: 5px;
  padding: 12px;
  background: #fffdf8;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.term-item strong {
  color: var(--green);
  font-size: 14px;
}

.term-item span {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.analysis-list,
.tips-list {
  margin-bottom: 0;
  padding-left: 22px;
}

.permission-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 18px;
  background: var(--amber-soft);
  border-color: #efd3a6;
}

.permission-banner strong {
  display: block;
  margin-bottom: 6px;
}

.permission-banner p {
  margin-bottom: 0;
  color: #6f4b17;
  line-height: 1.6;
}

.permission-banner code {
  padding: 2px 6px;
  background: rgba(255, 255, 255, 0.7);
  border-radius: 5px;
}

.brief-panel {
  align-self: start;
}

.brief-panel ol {
  margin: 18px 0 0;
  padding-left: 22px;
  color: var(--muted);
  line-height: 1.9;
}

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

.compact-head {
  align-items: center;
  margin-bottom: 0;
}

.char-count,
.status-pill {
  flex: 0 0 auto;
  color: var(--muted);
  font-size: 14px;
  font-weight: 700;
}

.char-count.danger {
  color: var(--red);
}

textarea {
  width: 100%;
  min-height: 320px;
  padding: 18px;
  resize: vertical;
  color: var(--ink);
  background: #fffdf8;
  border: 1px solid var(--line);
  border-radius: 8px;
  outline: none;
  line-height: 1.65;
}

textarea:focus {
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(15, 90, 78, 0.12);
}

#answerText {
  min-height: 210px;
  margin-top: 18px;
}

.actions,
.record-strip,
.footer-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 18px;
}

.primary-button,
.secondary-button,
.record-button,
.icon-button,
.download-link {
  min-height: 44px;
  padding: 0 18px;
  border-radius: 8px;
  font-weight: 800;
  text-decoration: none;
}

.primary-button {
  color: white;
  background: var(--green);
}

.primary-button:hover:not(:disabled),
.icon-button:hover:not(:disabled) {
  background: #0b463d;
}

.primary-button:disabled,
.secondary-button:disabled {
  color: #96928a;
  background: #e7e0d5;
}

.secondary-button,
.download-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--ink);
  background: #eae3d8;
}

.transcript-note {
  margin: 14px 0 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.6;
}

.recognition-language {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-top: 14px;
  padding: 8px;
  color: var(--muted);
  background: #f3eee5;
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: 14px;
  font-weight: 800;
}

.recognition-language .segment-button {
  min-height: 34px;
  padding: 0 12px;
}

.record-button {
  color: white;
  background: var(--red);
}

.record-button.recording {
  background: #d0251c;
}

.icon-button {
  width: 52px;
  min-width: 52px;
  padding: 0;
  color: white;
  background: var(--green);
  border-radius: 50%;
}

.full {
  width: 100%;
  margin-top: 18px;
}

.sentence-card {
  margin-bottom: 18px;
}

.progress-track {
  height: 9px;
  margin-bottom: 20px;
  overflow: hidden;
  background: #eee7dc;
  border-radius: 99px;
}

.progress-fill {
  width: 0;
  height: 100%;
  background: var(--green);
  border-radius: inherit;
  transition: width 180ms ease;
}

#currentSentence {
  max-width: 850px;
  font-size: clamp(24px, 3vw, 38px);
  line-height: 1.45;
}

.feedback-block {
  padding: 16px;
  margin-top: 12px;
  border-radius: 8px;
  line-height: 1.65;
}

.feedback-block p {
  white-space: pre-line;
}

.positive {
  background: #eaf5ee;
}

.correction {
  background: #fff0ed;
}

.drill {
  background: var(--blue-soft);
}

.score {
  color: var(--green);
  font-size: 28px;
}

.rubric-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin: 14px 0 16px;
}

.rubric-item {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 4px 10px;
  padding: 12px;
  background: #fffdf8;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.rubric-item span,
.rubric-item small {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.rubric-item strong {
  font-size: 14px;
}

.rubric-item b {
  grid-row: span 2;
  color: var(--green);
  font-size: 24px;
  line-height: 1;
}

.rubric-item small {
  grid-column: 1 / -1;
}

.summary-panel {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  margin-top: 18px;
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(110px, 1fr));
  gap: 12px;
  flex: 1;
}

.summary-grid div {
  padding: 14px;
  background: #fffdf8;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.summary-grid strong,
.summary-grid span {
  display: block;
}

.summary-grid strong {
  color: var(--green);
  font-size: 30px;
}

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

.flow-hint {
  margin: 12px 0 0;
  text-align: center;
}

[hidden] {
  display: none !important;
}

@media (max-width: 820px) {
  .app-shell {
    width: min(100% - 24px, 640px);
    padding-top: 22px;
  }

  .topbar,
  .workspace,
  .practice-grid,
  .summary-panel,
  .permission-banner,
  .generator-view {
    display: block;
  }

  .session-meter {
    margin-top: 16px;
    text-align: left;
  }

  .brief-panel,
  .feedback-panel,
  .summary-panel,
  .material-panel {
    margin-top: 18px;
  }

  .mode-tabs,
  .generator-controls {
    flex-wrap: wrap;
  }

  .terms-grid {
    grid-template-columns: 1fr;
  }

  .rubric-grid {
    grid-template-columns: 1fr;
  }

  .section-head,
  .compact-head {
    align-items: flex-start;
  }

  .actions,
  .record-strip,
  .footer-actions {
    flex-wrap: wrap;
  }

  .primary-button,
  .secondary-button,
  .record-button,
  .download-link {
    flex: 1 1 140px;
  }

  .summary-grid {
    margin: 18px 0;
  }
}
