:root {
  color-scheme: light;
  --bg: #f6f7f4;
  --surface: #ffffff;
  --surface-soft: #eef3ed;
  --text: #172016;
  --muted: #60705f;
  --border: #dce5db;
  --accent: #2f7d4f;
  --accent-strong: #1d5f39;
  --shadow: 0 18px 45px rgba(38, 61, 41, 0.12);
  font-family: Inter, "Microsoft YaHei", "PingFang SC", system-ui, sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
}

button,
input,
select {
  font: inherit;
}

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

.hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 24px;
  align-items: end;
  padding: 32px 0 24px;
}

.hero h1 {
  margin: 0;
  font-size: clamp(34px, 6vw, 64px);
  line-height: 1;
  letter-spacing: 0;
}

.hero p {
  max-width: 680px;
  margin: 18px 0 0;
  color: var(--muted);
  font-size: 17px;
  line-height: 1.7;
}

.source-note {
  display: grid;
  gap: 8px;
  justify-items: end;
  color: var(--muted);
  font-size: 14px;
}

.source-note span:first-child {
  color: var(--accent-strong);
  font-size: 28px;
  font-weight: 750;
}

.search-panel {
  position: sticky;
  top: 0;
  z-index: 3;
  padding: 18px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.92);
  box-shadow: var(--shadow);
  backdrop-filter: blur(12px);
}

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

.search-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
}

input,
select {
  width: 100%;
  min-height: 46px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  outline: none;
}

input {
  padding: 0 15px;
  font-size: 17px;
}

select {
  margin-top: 8px;
  padding: 0 12px;
}

input:focus,
select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(47, 125, 79, 0.14);
}

button {
  min-height: 46px;
  border: 0;
  border-radius: 8px;
  background: var(--accent);
  color: #ffffff;
  cursor: pointer;
  font-weight: 750;
}

button:hover {
  background: var(--accent-strong);
}

#clearButton {
  padding: 0 18px;
}

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

.filters label {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.result-header {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
  margin: 28px 0 16px;
}

.result-header h2 {
  margin: 0;
  font-size: 22px;
}

#resultCount {
  color: var(--muted);
  font-weight: 700;
}

.exercise-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 14px;
}

.exercise-card {
  display: grid;
  gap: 14px;
  padding: 18px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  text-align: left;
  color: inherit;
  box-shadow: 0 10px 26px rgba(38, 61, 41, 0.07);
}

.exercise-card:hover {
  border-color: rgba(47, 125, 79, 0.45);
  transform: translateY(-1px);
}

.exercise-card h3 {
  margin: 0;
  font-size: 22px;
  line-height: 1.35;
}

.english-name {
  margin: 6px 0 0;
  color: #8a9488;
  font-size: 13px;
  font-weight: 650;
  line-height: 1.35;
}

.card-meta,
.detail-meta {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

.tag-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.tag {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--surface-soft);
  color: var(--accent-strong);
  font-size: 13px;
  font-weight: 750;
}

.media-frame {
  position: relative;
  display: grid;
  gap: 10px;
  margin: 20px 0 0;
}

.media-frame img {
  width: 100%;
  max-height: 420px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-soft);
  object-fit: contain;
}

.media-frame figcaption {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

.media-frame[data-status="loading"]::after,
.media-frame[data-status="error"]::after {
  display: grid;
  min-height: 72px;
  place-items: center;
  border: 1px dashed var(--border);
  border-radius: 8px;
  background: var(--surface-soft);
  color: var(--muted);
  font-size: 14px;
}

.media-frame[data-status="loading"]::after {
  content: "GIF 加载中...";
}

.media-frame[data-status="error"] img {
  display: none;
}

.media-frame[data-status="error"]::after {
  content: "GIF 加载失败，可能是网络或资源地址不可用。";
}

.empty-state {
  padding: 44px;
  border: 1px dashed var(--border);
  border-radius: 8px;
  background: var(--surface);
  text-align: center;
}

.empty-state h2 {
  margin: 0 0 10px;
}

.empty-state p {
  margin: 0;
  color: var(--muted);
}

.detail-dialog {
  width: min(720px, calc(100% - 28px));
  border: 0;
  border-radius: 8px;
  padding: 0;
  background: transparent;
}

.detail-dialog::backdrop {
  background: rgba(16, 26, 16, 0.48);
}

.detail-card {
  position: relative;
  padding: 28px;
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.close-button {
  position: absolute;
  top: 14px;
  right: 14px;
  width: 38px;
  min-height: 38px;
  border-radius: 50%;
  background: var(--surface-soft);
  color: var(--text);
  font-size: 24px;
  line-height: 1;
}

.close-button:hover {
  background: var(--border);
}

#detailTitle {
  display: grid;
  gap: 8px;
  margin: 8px 46px 14px 0;
  font-size: 32px;
  line-height: 1.2;
}

#detailTitle small {
  color: #8a9488;
  font-size: 15px;
  font-weight: 700;
  line-height: 1.35;
}

.steps {
  display: grid;
  gap: 10px;
  margin: 22px 0 0;
  padding-left: 22px;
}

.steps li {
  padding-left: 4px;
  line-height: 1.7;
}

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

  .hero {
    grid-template-columns: 1fr;
    align-items: start;
  }

  .source-note {
    justify-items: start;
  }

  .search-row,
  .filters {
    grid-template-columns: 1fr;
  }

  #clearButton {
    width: 100%;
  }

  .result-header {
    align-items: flex-start;
    flex-direction: column;
  }
}
