:root {
  color-scheme: light;
  --bg: #f6f8f5;
  --surface: #ffffff;
  --surface-soft: #f0f6f2;
  --ink: #1d2823;
  --muted: #6c7770;
  --line: #d9e3dc;
  --blue: #2d6cdf;
  --blue-soft: #e9f1ff;
  --green: #23785c;
  --green-soft: #e7f5ee;
  --amber: #9f6b16;
  --amber-soft: #fff5df;
  --coral: #c96343;
  --shadow: 0 16px 36px rgba(28, 42, 34, 0.08);
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: var(--bg);
}

body {
  margin: 0;
  min-height: 100%;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.82), rgba(246, 248, 245, 0.94) 280px),
    var(--bg);
  color: var(--ink);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  font-size: 16px;
  line-height: 1.55;
}

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

button,
a,
select,
input[type="checkbox"],
input[type="file"] {
  cursor: pointer;
}

.app-shell {
  width: min(960px, calc(100% - 32px));
  margin: 0 auto;
  padding: 28px 0 40px;
}

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

.topbar h1,
.panel-heading h2,
.detail-title h2 {
  margin: 0;
  letter-spacing: 0;
}

.topbar h1 {
  font-size: 30px;
  line-height: 1.2;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--green);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

.top-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 10px;
}

.primary-link,
.ghost-button,
.solid-button,
.quiet-button,
.danger-button {
  display: inline-flex;
  min-height: 40px;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border-radius: 8px;
  border: 1px solid transparent;
  padding: 9px 14px;
  text-decoration: none;
  white-space: nowrap;
  transition:
    background 0.16s ease,
    border-color 0.16s ease,
    color 0.16s ease,
    transform 0.16s ease;
}

.primary-link,
.solid-button {
  background: var(--ink);
  color: #ffffff;
}

.primary-link:hover,
.solid-button:hover {
  background: #263931;
  transform: translateY(-1px);
}

.ghost-button,
.quiet-button {
  background: rgba(255, 255, 255, 0.76);
  border-color: var(--line);
  color: var(--ink);
}

.ghost-button:hover,
.quiet-button:hover {
  background: #ffffff;
  border-color: #bfcfc5;
}

.danger-button {
  background: #fff2ef;
  border-color: #f0c2b5;
  color: #8f321f;
}

.danger-button:hover {
  background: #ffe8e2;
}

button:disabled,
.solid-button:disabled,
.quiet-button:disabled {
  cursor: not-allowed;
  opacity: 0.48;
  transform: none;
}

.status-strip {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 12px;
}

.metric {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.86);
  padding: 12px;
  box-shadow: 0 8px 20px rgba(28, 42, 34, 0.04);
}

.metric span {
  display: block;
  margin-bottom: 4px;
  color: var(--muted);
  font-size: 12px;
}

.metric strong {
  display: block;
  overflow-wrap: anywhere;
  font-size: 16px;
  line-height: 1.35;
}

.progress-track {
  height: 8px;
  overflow: hidden;
  border-radius: 999px;
  background: #e4ebe6;
  margin-bottom: 18px;
}

.progress-track > div {
  height: 100%;
  width: 0;
  background: var(--green);
  transition: width 0.25s ease;
}

.cloud-panel {
  margin-bottom: 18px;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.48);
  padding: 12px 2px;
}

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

.cloud-copy {
  min-width: 0;
}

.cloud-title {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0;
  font-weight: 800;
}

.cloud-copy p {
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.sync-dot {
  width: 9px;
  height: 9px;
  flex: 0 0 auto;
  border-radius: 999px;
  background: #9aa49e;
}

.sync-dot.connecting,
.sync-dot.saving {
  background: var(--amber);
}

.sync-dot.synced {
  background: var(--green);
}

.sync-dot.error {
  background: var(--coral);
}

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

.cloud-mode {
  color: var(--muted);
  font-size: 13px;
  white-space: nowrap;
}

.workspace-grid {
  display: grid;
  grid-template-columns: 330px minmax(0, 1fr);
  gap: 18px;
  align-items: start;
}

.task-panel,
.detail-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.92);
  box-shadow: var(--shadow);
}

.task-panel {
  position: sticky;
  top: 18px;
  padding: 16px;
}

.detail-panel {
  min-width: 0;
  padding: 20px;
}

.panel-heading {
  margin-bottom: 14px;
}

.panel-heading h2,
.detail-title h2 {
  font-size: 20px;
  line-height: 1.25;
}

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

.task-card {
  min-height: 126px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  padding: 13px;
  transition:
    border-color 0.16s ease,
    box-shadow 0.16s ease,
    background 0.16s ease;
}

.task-card:hover,
.task-card.is-selected {
  border-color: #b7c8bd;
  box-shadow: 0 10px 22px rgba(28, 42, 34, 0.08);
}

.task-card.is-current {
  border-color: #9bbbf7;
  background: var(--blue-soft);
}

.task-card.is-completed {
  border-color: #b9ddcd;
  background: var(--green-soft);
}

.task-card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.task-index {
  display: inline-flex;
  width: 28px;
  height: 28px;
  flex: 0 0 auto;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  background: var(--surface-soft);
  color: var(--green);
  font-weight: 800;
}

.task-main {
  min-width: 0;
  flex: 1;
}

.task-main h3 {
  margin: 0;
  font-size: 16px;
  line-height: 1.35;
}

.task-main p {
  margin: 3px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.status-pill {
  display: inline-flex;
  min-height: 26px;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  border: 1px solid var(--line);
  padding: 3px 9px;
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
  justify-self: start;
}

.status-pill.completed {
  border-color: #a5d7c3;
  background: #f4fbf8;
  color: var(--green);
}

.status-pill.in_progress {
  border-color: #b8cdf6;
  background: #f7fbff;
  color: var(--blue);
}

.task-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: 14px;
}

.duration {
  color: var(--muted);
  font-size: 13px;
}

.mini-button {
  min-height: 32px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  color: var(--ink);
  padding: 5px 10px;
}

.mini-button:hover:not(:disabled) {
  border-color: #abc0b4;
}

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

.detail-title p {
  margin: 5px 0 0;
  color: var(--muted);
}

.detail-stack {
  display: grid;
  gap: 18px;
}

.section-block {
  border-top: 1px solid var(--line);
  padding-top: 16px;
}

.section-block:first-child {
  border-top: 0;
  padding-top: 0;
}

.section-block h3 {
  margin: 0 0 10px;
  font-size: 17px;
}

.steps-list,
.check-list,
.material-list {
  display: grid;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.steps-list li {
  display: grid;
  grid-template-columns: 28px minmax(0, 1fr);
  gap: 10px;
  align-items: start;
  color: #34433c;
}

.step-number {
  display: inline-flex;
  width: 24px;
  height: 24px;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  background: var(--surface-soft);
  color: var(--green);
  font-size: 12px;
  font-weight: 700;
}

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

.field {
  display: grid;
  gap: 6px;
}

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

.field span,
.field legend {
  color: #394941;
  font-size: 13px;
  font-weight: 700;
}

.field input,
.field select,
.field textarea {
  width: 100%;
  min-width: 0;
  border: 1px solid #cfdcd3;
  border-radius: 8px;
  background: #ffffff;
  color: var(--ink);
  padding: 10px 11px;
}

.field textarea {
  min-height: 92px;
  resize: vertical;
}

.field textarea.tall {
  min-height: 360px;
  overflow: hidden;
  resize: none;
  font-size: 16px;
  line-height: 1.75;
}

.field input:focus,
.field select:focus,
.field textarea:focus {
  border-color: var(--blue);
  outline: 3px solid rgba(45, 108, 223, 0.13);
}

.inline-options,
.audio-tools {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}

.check-row,
.radio-row {
  display: inline-flex;
  min-height: 34px;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  padding: 7px 10px;
}

.check-row input,
.radio-row input {
  width: 16px;
  height: 16px;
  accent-color: var(--green);
}

.audio-box {
  display: grid;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfdfb;
  padding: 14px;
}

audio {
  width: 100%;
  min-height: 42px;
}

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

.section-heading-row h3 {
  margin-bottom: 2px;
}

.vocabulary-note {
  margin-bottom: 12px;
}

.vocabulary-form {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  align-items: end;
}

.vocabulary-context {
  grid-column: 1 / -1;
}

.vocabulary-context textarea {
  min-height: 84px;
}

.vocabulary-add {
  justify-self: start;
}

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

.vocabulary-item {
  position: relative;
  display: grid;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  padding: 12px 46px 12px 12px;
}

.vocabulary-word {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 8px 14px;
}

.vocabulary-word strong {
  color: var(--green);
  font-size: 18px;
}

.vocabulary-word span {
  color: #34433c;
}

.vocabulary-item p {
  margin: 0;
  color: #47554e;
}

.vocabulary-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 14px;
  color: var(--muted);
  font-size: 12px;
}

.icon-delete {
  position: absolute;
  top: 9px;
  right: 9px;
  width: 30px;
  height: 30px;
  border: 1px solid #f0c2b5;
  border-radius: 8px;
  background: #fff5f2;
  color: #8f321f;
  font-size: 20px;
  line-height: 1;
}

.icon-delete:hover {
  background: #ffe8e2;
}

.empty-state {
  margin: 0;
  border: 1px dashed #c8d6cd;
  border-radius: 8px;
  background: #fbfdfb;
  padding: 18px;
  color: var(--muted);
  text-align: center;
}

.sentence-heading {
  align-items: center;
}

.sentence-navigation {
  display: flex;
  gap: 10px;
  margin-bottom: 10px;
}

.sentence-list {
  display: grid;
  gap: 8px;
}

.sentence-row {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr) auto;
  gap: 10px;
  align-items: start;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  color: var(--ink);
  padding: 11px;
  text-align: left;
  transition: border-color 0.16s ease, background 0.16s ease;
}

.sentence-row:hover {
  border-color: #aebfb4;
  background: #fbfdfb;
}

.sentence-row.is-active {
  border-color: #88b49f;
  background: var(--green-soft);
}

.sentence-number {
  color: var(--green);
  font-size: 12px;
  font-weight: 800;
  line-height: 1.7;
}

.sentence-text {
  line-height: 1.7;
}

.sentence-action {
  color: var(--blue);
  font-size: 12px;
  font-weight: 700;
  line-height: 1.7;
  white-space: nowrap;
}

.speaking-text-panel {
  display: block;
}

.chip-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.chip {
  display: inline-flex;
  max-width: 100%;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #ffffff;
  padding: 6px 10px;
  color: #35463e;
  font-size: 13px;
}

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

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

.expression-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr)) auto;
  gap: 10px;
  align-items: end;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  padding: 12px;
}

.expression-row .wide {
  grid-column: span 2;
}

.detail-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border-top: 1px solid var(--line);
  padding-top: 18px;
}

.task-lock {
  color: var(--amber);
  background: var(--amber-soft);
  border: 1px solid #f0dbab;
  border-radius: 8px;
  padding: 10px 12px;
}

.xdf-callout {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border: 1px solid #c8d7e8;
  border-radius: 8px;
  background: #f7fbff;
  padding: 12px;
}

.xdf-callout strong {
  display: block;
}

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

.hidden {
  display: none !important;
}

@media (max-width: 860px) {
  .app-shell {
    width: min(100% - 24px, 720px);
    padding-top: 18px;
  }

  .topbar,
  .detail-title,
  .xdf-callout,
  .cloud-layout {
    display: grid;
  }

  .top-actions {
    justify-content: stretch;
  }

  .top-actions > * {
    flex: 1 1 150px;
  }

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

  .status-strip .metric:nth-child(3) {
    grid-column: 1 / -1;
  }

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

  .task-panel {
    position: static;
  }

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

@media (max-width: 640px) {
  body {
    font-size: 15px;
  }

  .topbar h1 {
    font-size: 24px;
  }

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

  .task-list,
  .form-grid,
  .expression-row,
  .vocabulary-form {
    grid-template-columns: 1fr;
  }

  .vocabulary-context {
    grid-column: auto;
  }

  .section-heading-row {
    display: grid;
  }

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

  .sentence-navigation .quiet-button {
    width: auto;
  }

  .sentence-row {
    grid-template-columns: 30px minmax(0, 1fr);
  }

  .sentence-action {
    grid-column: 2;
  }

  .cloud-actions {
    display: grid;
    grid-template-columns: 1fr;
  }

  .expression-row .wide {
    grid-column: auto;
  }

  .detail-panel,
  .task-panel {
    padding: 14px;
  }

  .task-card {
    min-height: auto;
  }

  .task-card-header,
  .task-footer,
  .detail-actions {
    align-items: stretch;
  }

  .task-card-header,
  .task-footer {
    display: grid;
  }

  .mini-button,
  .solid-button,
  .quiet-button,
  .danger-button,
  .primary-link,
  .ghost-button {
    width: 100%;
  }
}
