:root {
  --bg: #f4fbf6;
  --surface: #ffffff;
  --ink: #14201c;
  --muted: #5b686d;
  --brand: #1f8f6e;
  --brand-dark: #156a52;
  --accent: #f2b24a;
  --stroke: rgba(20, 32, 28, 0.12);
  --shadow: 0 24px 60px rgba(20, 32, 28, 0.12);
  --radius: 20px;
  --font-body: "Manrope", "Noto Sans SC", sans-serif;
  --font-display: "ZCOOL XiaoWei", "Noto Serif SC", serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: linear-gradient(135deg, #f3fbf6 0%, #f7f0e8 50%, #eef4ff 100%);
  color: var(--ink);
  font-family: var(--font-body);
}

a {
  color: inherit;
  text-decoration: none;
}

.page {
  min-height: 100vh;
  padding: 32px 24px 40px;
  position: relative;
  overflow: hidden;
  animation: fadeUp 0.6s ease both;
}

.page::before,
.page::after {
  content: "";
  position: absolute;
  width: 420px;
  height: 420px;
  border-radius: 50%;
  background: radial-gradient(circle at 30% 30%, rgba(31, 143, 110, 0.18), transparent 65%);
  filter: blur(0);
  z-index: 0;
  animation: float 12s ease-in-out infinite;
}

.page::before {
  top: -120px;
  right: -120px;
}

.page::after {
  bottom: -160px;
  left: -120px;
  background: radial-gradient(circle at 30% 30%, rgba(242, 178, 74, 0.18), transparent 65%);
  animation-delay: 2s;
}

.topbar {
  position: relative;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 32px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 42px;
  height: 42px;
  border-radius: 14px;
  background: linear-gradient(135deg, var(--brand), #43c29a);
  color: #fff;
  font-weight: 700;
  letter-spacing: 0.04em;
  box-shadow: 0 10px 30px rgba(31, 143, 110, 0.3);
}

.brand-text strong {
  display: block;
  font-size: 18px;
  font-family: var(--font-display);
}

.brand-text small {
  display: block;
  font-size: 12px;
  color: var(--muted);
}

.topnav {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.user-chip {
  background: rgba(31, 143, 110, 0.12);
  color: var(--brand-dark);
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 13px;
}

.link-btn {
  padding: 8px 14px;
  border-radius: 999px;
  border: 1px solid transparent;
  background: rgba(255, 255, 255, 0.7);
  transition: all 0.2s ease;
  font-size: 14px;
}

.link-btn:hover {
  transform: translateY(-1px);
  border-color: rgba(20, 32, 28, 0.1);
}

.link-btn.solid {
  background: var(--brand);
  color: #fff;
}

.link-btn.ghost {
  border-color: rgba(20, 32, 28, 0.18);
}

.flash-stack {
  position: relative;
  z-index: 2;
  display: grid;
  gap: 10px;
  margin-bottom: 24px;
}

.flash {
  padding: 12px 16px;
  border-radius: 12px;
  background: #fff;
  border: 1px solid var(--stroke);
  box-shadow: var(--shadow);
  font-size: 14px;
}

.flash-success {
  border-color: rgba(31, 143, 110, 0.4);
  background: rgba(31, 143, 110, 0.08);
}

.flash-danger {
  border-color: rgba(200, 70, 70, 0.4);
  background: rgba(200, 70, 70, 0.08);
}

.flash-warning {
  border-color: rgba(242, 178, 74, 0.5);
  background: rgba(242, 178, 74, 0.12);
}

.flash-info {
  border-color: rgba(82, 126, 202, 0.5);
  background: rgba(82, 126, 202, 0.1);
}

.main {
  position: relative;
  z-index: 2;
}

.hero {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 32px;
  align-items: center;
}

.hero-copy h1 {
  font-family: var(--font-display);
  font-size: 42px;
  margin: 12px 0 16px;
}

.eyebrow {
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.2em;
  color: var(--brand-dark);
}

.lead {
  font-size: 17px;
  color: var(--muted);
  line-height: 1.6;
}

.hero-tags {
  display: flex;
  gap: 12px;
  margin-top: 20px;
  flex-wrap: wrap;
}

.tag {
  padding: 6px 12px;
  border-radius: 999px;
  background: rgba(20, 32, 28, 0.08);
  font-size: 13px;
}

.card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border: 1px solid rgba(255, 255, 255, 0.6);
  padding: 28px;
  animation: fadeUp 0.7s ease both;
}

.form-card h2 {
  margin: 0 0 8px;
  font-family: var(--font-display);
}

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

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

.field {
  display: grid;
  gap: 6px;
  font-size: 14px;
}

.input {
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid var(--stroke);
  background: rgba(248, 250, 249, 0.9);
  font-size: 15px;
  outline: none;
  transition: border 0.2s ease, box-shadow 0.2s ease;
}

.input:focus {
  border-color: rgba(31, 143, 110, 0.6);
  box-shadow: 0 0 0 3px rgba(31, 143, 110, 0.15);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 12px 18px;
  border-radius: 14px;
  border: none;
  font-size: 15px;
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.btn.primary {
  background: linear-gradient(135deg, var(--brand), #35b58b);
  color: #fff;
  box-shadow: 0 14px 30px rgba(31, 143, 110, 0.28);
}

.btn.primary:hover {
  transform: translateY(-1px);
}

.btn-small {
  padding: 9px 14px;
  font-size: 14px;
  border-radius: 10px;
}

.btn-subtle {
  background: rgba(148, 163, 184, 0.14);
  color: #1e293b;
  border: 1px solid rgba(100, 116, 139, 0.24);
}

.btn-warn {
  background: rgba(245, 158, 11, 0.14);
  color: #9a3412;
  border: 1px solid rgba(245, 158, 11, 0.3);
}

.btn-danger {
  background: rgba(220, 38, 38, 0.12);
  color: #b91c1c;
  border: 1px solid rgba(220, 38, 38, 0.26);
}

.btn-subtle:hover,
.btn-warn:hover,
.btn-danger:hover {
  transform: translateY(-1px);
}

.btn.disabled {
  background: rgba(20, 32, 28, 0.12);
  color: var(--muted);
  cursor: not-allowed;
}

.form-footer {
  margin-top: 18px;
  font-size: 14px;
  color: var(--muted);
}

.form-footer a {
  color: var(--brand-dark);
  font-weight: 600;
}

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

.header-action .hint {
  color: var(--muted);
  font-size: 14px;
}

.header-stack {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 8px;
}

.subscription-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 20px;
}

.project-card {
  background: var(--surface);
  border-radius: 18px;
  overflow: hidden;
  border: 1px solid rgba(20, 32, 28, 0.06);
  box-shadow: 0 18px 40px rgba(20, 32, 28, 0.08);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  animation: fadeUp 0.7s ease both;
}

.project-card:nth-child(2) { animation-delay: 0.05s; }
.project-card:nth-child(3) { animation-delay: 0.1s; }
.project-card:nth-child(4) { animation-delay: 0.15s; }

.project-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 24px 50px rgba(20, 32, 28, 0.15);
}

.project-cover {
  height: 140px;
  background: linear-gradient(135deg, rgba(31, 143, 110, 0.15), rgba(82, 126, 202, 0.15));
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.project-cover img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.cover-placeholder span {
  font-size: 48px;
  font-family: var(--font-display);
  color: var(--brand-dark);
}

.project-body {
  padding: 18px;
}

.project-body h3 {
  margin: 0 0 8px;
  font-family: var(--font-display);
}

.project-body p {
  margin: 0 0 14px;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.5;
}

.project-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 12px;
  color: var(--muted);
}

.project-meta .cta {
  color: var(--brand-dark);
  font-weight: 600;
}

.empty-state {
  padding: 48px;
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.8);
  text-align: center;
  border: 1px dashed rgba(20, 32, 28, 0.2);
}

.detail-actions {
  text-align: right;
}

.detail-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 20px;
}

.info-card h3 {
  margin-top: 0;
  font-family: var(--font-display);
}

.info-card dl {
  display: grid;
  gap: 12px;
  margin: 0;
}

.info-card dt {
  font-size: 13px;
  color: var(--muted);
}

.info-card dd {
  margin: 4px 0 0;
  font-size: 15px;
}

.info-card ul {
  margin: 0;
  padding-left: 18px;
  color: var(--muted);
  display: grid;
  gap: 8px;
}

.favorites-panel {
  display: grid;
  gap: 16px;
}

.favorites-toolbar {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}

.favorites-toolbar .input {
  flex: 1;
  min-width: 220px;
}

.favorites-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.check-inline {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  color: var(--muted);
}

.favorites-action-buttons {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.favorite-message {
  border-radius: 12px;
  padding: 10px 12px;
  font-size: 14px;
}

.favorite-message.success {
  background: rgba(31, 143, 110, 0.11);
  border: 1px solid rgba(31, 143, 110, 0.28);
  color: #166534;
}

.favorite-message.error {
  background: rgba(220, 38, 38, 0.1);
  border: 1px solid rgba(220, 38, 38, 0.3);
  color: #991b1b;
}

.favorite-message.info {
  background: rgba(82, 126, 202, 0.1);
  border: 1px solid rgba(82, 126, 202, 0.28);
  color: #1d4ed8;
}

.favorite-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 10px;
}

.favorite-item {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 12px;
  align-items: flex-start;
  padding: 12px;
  border-radius: 14px;
  background: rgba(248, 250, 249, 0.9);
  border: 1px solid rgba(20, 32, 28, 0.1);
}

.favorite-check {
  margin-top: 4px;
}

.favorite-word-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 4px;
}

.favorite-word {
  font-size: 18px;
  color: #0f172a;
}

.favorite-lang {
  font-size: 12px;
  color: var(--muted);
  background: rgba(20, 32, 28, 0.08);
  border-radius: 999px;
  padding: 3px 8px;
}

.favorite-preview {
  margin: 0;
  font-size: 14px;
  color: #334155;
  line-height: 1.5;
}

.favorite-meta {
  margin-top: 8px;
  font-size: 12px;
  color: var(--muted);
}

.favorite-item-actions {
  display: flex;
  gap: 8px;
}

.favorite-loading {
  border: 1px dashed rgba(20, 32, 28, 0.2);
  padding: 14px;
  border-radius: 12px;
  color: var(--muted);
  text-align: center;
}

.empty-state.compact {
  padding: 32px 24px;
}

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

.pager-btn {
  border: 1px solid rgba(20, 32, 28, 0.14);
  background: rgba(255, 255, 255, 0.8);
  border-radius: 10px;
  padding: 8px 12px;
  font-size: 13px;
  cursor: pointer;
}

.pager-btn:hover {
  transform: translateY(-1px);
}

.pager-btn.active {
  background: var(--brand);
  color: #fff;
  border-color: var(--brand);
}

.pager-btn[disabled] {
  opacity: 0.55;
  cursor: not-allowed;
}

.favorite-modal {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  z-index: 30;
}

.favorite-modal-inner {
  width: min(700px, 96vw);
  max-height: calc(100vh - 40px);
  overflow-y: auto;
  background: #fff;
  border-radius: 16px;
  box-shadow: 0 16px 45px rgba(2, 6, 23, 0.28);
  border: 1px solid rgba(20, 32, 28, 0.1);
}

.favorite-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1px solid rgba(20, 32, 28, 0.1);
}

.favorite-modal-header h3 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 22px;
}

.favorite-modal-header .word-close {
  border: none;
  background: transparent;
  color: #475569;
  font-size: 24px;
  cursor: pointer;
  line-height: 1;
}

.favorite-modal-body {
  padding: 16px;
  display: grid;
  gap: 12px;
}

.favorite-detail-status {
  color: var(--muted);
  font-size: 14px;
}

.favorite-detail-word {
  font-size: 34px;
  font-weight: 700;
  color: #0f172a;
}

.favorite-detail-meta {
  font-size: 13px;
  color: var(--muted);
}

.favorite-detail-phonetic {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 14px;
}

.audio-btn {
  border: none;
  background: transparent;
  cursor: pointer;
  color: #ef4444;
  padding: 0 4px;
}

.favorite-detail-phonetic > span:last-child .audio-btn {
  color: #2563eb;
}

.favorite-detail-translation {
  border: 1px solid rgba(20, 32, 28, 0.1);
  border-radius: 10px;
  padding: 10px 12px;
  background: #f8fafc;
  line-height: 1.6;
}

.favorite-detail-card {
  border: 1px solid rgba(20, 32, 28, 0.1);
  border-radius: 10px;
  background: #f8fafc;
  padding: 10px 12px;
}

.favorite-detail-card h4 {
  margin: 0 0 8px;
  font-size: 14px;
}

.favorite-detail-card p {
  margin: 0;
  white-space: pre-wrap;
  line-height: 1.55;
}

.favorite-modal-footer {
  padding: 14px 16px 16px;
  border-top: 1px solid rgba(20, 32, 28, 0.1);
  display: flex;
  justify-content: flex-end;
}

.spacer {
  flex: 1;
}

.footer {
  margin-top: 48px;
  font-size: 13px;
  color: var(--muted);
  text-align: center;
}

@keyframes fadeUp {
  from {
    opacity: 0;
    transform: translateY(14px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes float {
  0% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(18px);
  }
  100% {
    transform: translateY(0);
  }
}

@media (max-width: 960px) {
  .hero {
    grid-template-columns: 1fr;
  }

  .detail-header,
  .page-header {
    flex-direction: column;
  }

  .header-stack {
    align-items: flex-start;
  }

  .detail-actions {
    text-align: left;
  }

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

  .favorite-item-actions {
    grid-column: 1 / -1;
    margin-left: 28px;
  }
}

@media (max-width: 600px) {
  .page {
    padding: 24px 16px 32px;
  }

  .hero-copy h1 {
    font-size: 32px;
  }

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

  .topnav {
    width: 100%;
    justify-content: flex-start;
  }

  .favorites-toolbar .input {
    min-width: 100%;
  }

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

  .favorite-check {
    margin: 0;
  }

  .favorite-item-actions {
    margin-left: 0;
    justify-content: flex-start;
  }

  .favorite-modal {
    padding: 10px;
  }

  .favorite-detail-word {
    font-size: 28px;
  }
}
