:root {
  --background: #f3f5f7;
  --surface: #ffffff;
  --ink: #16202a;
  --muted: #63707c;
  --line: #dce2e7;
  --header: #12324a;
  --header-soft: #d9ecf6;
  --accent: #cf5a27;
  --accent-dark: #a94117;
  --focus: #23749b;
  --shadow: 0 10px 28px rgba(18, 50, 74, 0.08);
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  background: var(--background);
  scroll-behavior: smooth;
}

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

button,
input {
  font: inherit;
}

.site-header {
  color: #ffffff;
  background: var(--header);
  border-bottom: 4px solid var(--accent);
}

.header-inner {
  width: min(1180px, calc(100% - 32px));
  min-height: 128px;
  margin: 0 auto;
  padding: 24px 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 16px;
  min-width: 0;
}

.brand-mark {
  width: 54px;
  height: 54px;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  color: var(--header);
  background: #f2b84b;
  border-radius: 8px;
  font-size: 18px;
  font-weight: 800;
  letter-spacing: 0;
}

.eyebrow {
  margin: 0 0 5px;
  color: var(--header-soft);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0;
}

h1 {
  margin: 0;
  font-size: clamp(24px, 4vw, 38px);
  line-height: 1.15;
  letter-spacing: 0;
}

h1 span {
  color: #f2b84b;
  font-weight: 700;
}

.card-count {
  min-width: 128px;
  margin: 0;
  padding: 12px 16px;
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 6px;
  color: var(--header-soft);
  background: rgba(255, 255, 255, 0.09);
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 8px;
  font-size: 13px;
  white-space: nowrap;
}

.card-count strong {
  color: #ffffff;
  font-size: 24px;
}

main {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: 28px 0 44px;
}

.toolbar {
  position: sticky;
  top: 12px;
  z-index: 10;
  margin-bottom: 24px;
  padding: 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: rgba(243, 245, 247, 0.94);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(12px);
}

.search-field {
  min-width: 0;
  flex: 1 1 auto;
  display: flex;
  align-items: center;
  gap: 10px;
  height: 46px;
  padding: 0 12px;
  color: var(--muted);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 7px;
}

.search-field:focus-within {
  border-color: var(--focus);
  box-shadow: 0 0 0 3px rgba(35, 116, 155, 0.14);
}

.search-field input {
  min-width: 0;
  width: 100%;
  height: 100%;
  padding: 0;
  color: var(--ink);
  background: transparent;
  border: 0;
  outline: 0;
}

.search-field input::placeholder {
  color: #89939c;
}

.search-field input::-webkit-search-cancel-button {
  display: none;
}

.clear-button {
  width: 28px;
  height: 28px;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  padding: 0;
  color: var(--muted);
  background: transparent;
  border: 0;
  border-radius: 4px;
  cursor: pointer;
}

.clear-button:hover {
  color: var(--ink);
  background: #edf1f4;
}

.clear-button span,
.clear-button span::after {
  width: 14px;
  height: 2px;
  display: block;
  background: currentColor;
  border-radius: 2px;
  transform: rotate(45deg);
}

.clear-button span::after {
  content: "";
  transform: rotate(90deg);
}

.download-button {
  height: 46px;
  flex: 0 0 auto;
  padding: 0 18px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #ffffff;
  background: var(--accent);
  border: 1px solid var(--accent);
  border-radius: 7px;
  font-size: 14px;
  font-weight: 700;
  text-decoration: none;
  transition:
    background 160ms ease,
    border-color 160ms ease;
}

.download-button:hover {
  background: var(--accent-dark);
  border-color: var(--accent-dark);
}

.download-button:focus-visible,
.clear-button:focus-visible {
  outline: 3px solid rgba(35, 116, 155, 0.28);
  outline-offset: 2px;
}

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

.vocab-card {
  position: relative;
  min-width: 0;
  padding: 22px 22px 20px 64px;
  overflow: hidden;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 3px 12px rgba(18, 50, 74, 0.045);
}

.vocab-card::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 4px;
  background: #f2b84b;
}

.card-index {
  position: absolute;
  top: 23px;
  left: 21px;
  width: 28px;
  color: #8b959e;
  font-size: 12px;
  font-weight: 800;
  line-height: 1;
  text-align: center;
}

.front,
.back {
  margin: 0;
  overflow-wrap: anywhere;
}

.front {
  color: var(--ink);
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(18px, 2vw, 21px);
  font-weight: 700;
  line-height: 1.45;
}

.divider {
  height: 1px;
  margin: 16px 0;
  background: var(--line);
}

.back {
  color: #3f4d59;
  font-size: 15px;
  line-height: 1.75;
}

.empty-state {
  min-height: 240px;
  display: grid;
  place-content: center;
  gap: 8px;
  color: var(--muted);
  text-align: center;
}

.empty-state strong {
  color: var(--ink);
  font-size: 18px;
}

footer {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: 22px 0 34px;
  display: flex;
  justify-content: space-between;
  gap: 20px;
  color: var(--muted);
  border-top: 1px solid var(--line);
  font-size: 13px;
}

footer p {
  margin: 0;
}

[hidden] {
  display: none !important;
}

@media (max-width: 720px) {
  .header-inner {
    width: min(100% - 24px, 1180px);
    min-height: 112px;
    padding: 20px 0;
  }

  .brand {
    gap: 12px;
  }

  .brand-mark {
    width: 46px;
    height: 46px;
    font-size: 16px;
  }

  h1 {
    font-size: 24px;
  }

  .card-count {
    min-width: auto;
    align-self: flex-start;
    padding: 8px 10px;
  }

  .card-count strong {
    font-size: 18px;
  }

  .card-count span:nth-last-child(1) {
    display: none;
  }

  main {
    width: min(100% - 24px, 1180px);
    padding-top: 16px;
  }

  .toolbar {
    top: 8px;
    margin-bottom: 16px;
    padding: 8px;
    flex-wrap: wrap;
  }

  .search-field {
    flex-basis: 100%;
  }

  .download-button {
    width: 100%;
    height: 42px;
  }

  .card-grid {
    grid-template-columns: minmax(0, 1fr);
    gap: 12px;
  }

  .vocab-card {
    padding: 18px 18px 18px 56px;
  }

  .card-index {
    top: 19px;
    left: 16px;
  }

  .front {
    font-size: 19px;
  }

  .back {
    font-size: 15px;
    line-height: 1.7;
  }

  footer {
    width: min(100% - 24px, 1180px);
    flex-direction: column;
    gap: 6px;
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  .download-button {
    transition: none;
  }
}
