:root {
  --bg: #f6f3fb;
  --panel: #ffffff;
  --panel-soft: #fbf9ff;
  --ink: #2f2a3c;
  --ink-soft: #5f5870;
  --muted: #948ca5;
  --line: #ebe5f4;
  --primary: #7b68b5;
  --primary-deep: #65539f;
  --primary-soft: #f0ebfc;
  --accent: #e88b8f;
  --green: #55a985;
  --blue: #5b8fd6;
  --orange: #dd9754;
  --shadow: 0 20px 50px rgba(82, 61, 128, 0.10);
  --shadow-soft: 0 8px 24px rgba(82, 61, 128, 0.07);
  --radius: 18px;
}

* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  min-height: 100%;
}

body {
  font-family: "PingFang SC", "Microsoft YaHei", "Segoe UI", system-ui, -apple-system, sans-serif;
  color: var(--ink);
  background:
    radial-gradient(circle at 88% 4%, rgba(213, 198, 245, 0.55), transparent 32%),
    radial-gradient(circle at 4% 92%, rgba(248, 216, 220, 0.4), transparent 30%),
    var(--bg);
  -webkit-font-smoothing: antialiased;
}

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

button {
  cursor: pointer;
}

[hidden] {
  display: none !important;
}

.muted {
  color: var(--muted);
}

.eyebrow {
  font-size: 11px;
  letter-spacing: 0.18em;
  font-weight: 700;
  color: var(--primary);
  text-transform: uppercase;
}

/* ---------- Login ---------- */
.login-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 1.05fr 1fr;
}

.login-art {
  position: relative;
  overflow: hidden;
  padding: 64px;
  color: #fff;
  background:
    radial-gradient(circle at 30% 20%, rgba(255, 255, 255, 0.28), transparent 34%),
    radial-gradient(circle at 78% 80%, rgba(248, 190, 196, 0.32), transparent 36%),
    linear-gradient(145deg, #8d7ac4 0%, #6f5aa9 48%, #5a477f 100%);
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.login-art h1 {
  font-size: 44px;
  letter-spacing: 0.06em;
  margin: 18px 0 12px;
}

.login-art p {
  margin: 0;
  max-width: 380px;
  line-height: 1.9;
  color: rgba(255, 255, 255, 0.82);
}

.login-art-foot {
  position: absolute;
  bottom: 54px;
  font-size: 13px;
  letter-spacing: 0.22em;
  color: rgba(255, 255, 255, 0.62);
}

.brand-mark {
  width: 76px;
  height: 76px;
  border-radius: 26px;
  background: rgba(255, 255, 255, 0.16);
  border: 1px solid rgba(255, 255, 255, 0.28);
  display: grid;
  place-items: center;
  backdrop-filter: blur(8px);
}

.brand-mark svg {
  width: 46px;
  height: 46px;
  color: #fff;
}

.art-orbit {
  position: absolute;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 50%;
}

.orbit-a {
  width: 520px;
  height: 520px;
  top: -180px;
  right: -140px;
}

.orbit-b {
  width: 760px;
  height: 760px;
  bottom: -420px;
  left: -220px;
}

.art-star {
  position: absolute;
  width: 10px;
  height: 10px;
  background: rgba(255, 255, 255, 0.75);
  transform: rotate(45deg);
  border-radius: 3px;
}

.star-a { top: 18%; right: 22%; }
.star-b { bottom: 26%; left: 18%; width: 7px; height: 7px; }
.star-c { top: 46%; right: 8%; width: 6px; height: 6px; }

.login-panel {
  display: grid;
  place-items: center;
  padding: 40px;
}

.login-card {
  width: min(420px, 100%);
  background: rgba(255, 255, 255, 0.9);
  border: 1px solid rgba(255, 255, 255, 0.88);
  border-radius: 26px;
  box-shadow: var(--shadow);
  padding: 42px;
  backdrop-filter: blur(16px);
}

.login-card h2 {
  margin: 10px 0 8px;
  font-size: 26px;
}

.login-card p {
  margin: 0 0 26px;
  font-size: 14px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 18px;
  font-size: 13px;
  color: var(--ink-soft);
}

.field > span {
  font-weight: 600;
}

.field input,
.field select,
.field textarea {
  width: 100%;
  border: 1px solid var(--line);
  background: var(--panel-soft);
  border-radius: 12px;
  padding: 12px 14px;
  font-size: 14px;
  outline: none;
  transition: border-color 0.18s ease, box-shadow 0.18s ease, background 0.18s ease;
}

.field input:focus,
.field select:focus,
.field textarea:focus {
  border-color: rgba(123, 104, 181, 0.6);
  background: #fff;
  box-shadow: 0 0 0 4px rgba(123, 104, 181, 0.11);
}

.field textarea {
  min-height: 120px;
  resize: vertical;
  line-height: 1.7;
}

.field.compact {
  margin: 0;
  min-width: 150px;
}

.field.compact > span {
  font-size: 12px;
}

.field.grow {
  flex: 1;
}

.form-error {
  margin-top: 12px;
  padding: 10px 12px;
  border-radius: 10px;
  background: #fff1f1;
  color: #b4575b;
  font-size: 13px;
}

/* ---------- Buttons ---------- */
.btn {
  border: none;
  border-radius: 12px;
  padding: 11px 18px;
  font-size: 14px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  transition: transform 0.16s ease, box-shadow 0.16s ease, background 0.16s ease, opacity 0.16s ease;
  white-space: nowrap;
}

.btn:active {
  transform: translateY(1px);
}

.btn-primary {
  color: #fff;
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-deep) 100%);
  box-shadow: 0 10px 24px rgba(123, 104, 181, 0.28);
}

.btn-primary:hover {
  box-shadow: 0 14px 30px rgba(123, 104, 181, 0.34);
}

.btn-soft {
  color: var(--primary-deep);
  background: var(--primary-soft);
}

.btn-ghost {
  color: var(--ink-soft);
  background: #fff;
  border: 1px solid var(--line);
}

.btn-danger {
  color: #b4575b;
  background: #fff0f1;
}

.btn-block {
  width: 100%;
  justify-content: center;
}

.btn-sm {
  padding: 7px 12px;
  font-size: 12px;
  border-radius: 10px;
}

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  box-shadow: none;
}

.text-btn {
  border: none;
  background: none;
  color: var(--muted);
  font-size: 12px;
  padding: 0;
}

.text-btn:hover {
  color: var(--primary);
}

.icon-btn {
  width: 36px;
  height: 36px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
  color: var(--muted);
  display: grid;
  place-items: center;
}

.icon-btn svg,
.nav-icon svg,
.btn svg {
  width: 17px;
  height: 17px;
  display: block;
}

/* ---------- App shell ---------- */
.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 236px 1fr;
}

.sidebar {
  background: rgba(255, 255, 255, 0.78);
  border-right: 1px solid rgba(235, 229, 244, 0.9);
  backdrop-filter: blur(18px);
  padding: 30px 22px;
  display: flex;
  flex-direction: column;
  gap: 30px;
  position: sticky;
  top: 0;
  height: 100vh;
}

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

.sidebar-brand strong {
  display: block;
  font-size: 15px;
  letter-spacing: 0.02em;
}

.sidebar-brand span {
  display: block;
  font-size: 11px;
  color: var(--muted);
  margin-top: 3px;
}

.brand-dot {
  width: 42px;
  height: 42px;
  border-radius: 14px;
  display: grid;
  place-items: center;
  color: var(--primary);
  background: var(--primary-soft);
}

.brand-dot svg {
  width: 27px;
  height: 27px;
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 11px;
  border: none;
  background: transparent;
  color: var(--ink-soft);
  padding: 12px 14px;
  border-radius: 13px;
  font-size: 14px;
  font-weight: 600;
  text-align: left;
  transition: background 0.16s ease, color 0.16s ease;
}

.nav-item:hover {
  background: var(--panel-soft);
}

.nav-item.active {
  color: var(--primary-deep);
  background: var(--primary-soft);
}

.sidebar-foot {
  margin-top: auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 12px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
}

.main {
  padding: 34px 42px 60px;
  min-width: 0;
}

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

.topbar h1 {
  margin: 6px 0 0;
  font-size: 30px;
  letter-spacing: 0.02em;
}

.topbar-actions {
  display: flex;
  gap: 10px;
}

/* ---------- Cards & tables ---------- */
.card {
  background: var(--panel);
  border: 1px solid rgba(235, 229, 244, 0.9);
  border-radius: var(--radius);
  box-shadow: var(--shadow-soft);
}

.toolbar {
  padding: 18px;
  margin-bottom: 18px;
}

.toolbar-row {
  display: flex;
  align-items: flex-end;
  gap: 14px;
  flex-wrap: wrap;
}

.table-card {
  overflow: hidden;
}

.table-wrap {
  width: 100%;
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 880px;
}

th, td {
  text-align: left;
  padding: 15px 18px;
  font-size: 13px;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
}

th {
  color: var(--muted);
  font-weight: 600;
  font-size: 12px;
  letter-spacing: 0.04em;
  background: var(--panel-soft);
}

tbody tr:hover {
  background: #fcfbff;
}

tbody tr:last-child td {
  border-bottom: none;
}

.cell-title {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.cell-title strong {
  font-size: 14px;
}

.cell-title span {
  color: var(--muted);
  font-size: 12px;
}

.cover-thumb {
  width: 76px;
  height: 44px;
  border-radius: 9px;
  object-fit: cover;
  background: var(--primary-soft);
}

.tag {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 9px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
}

.tag-purple { color: #6a55a2; background: #f0eafc; }
.tag-green { color: #3e8b6b; background: #e9f7f0; }
.tag-blue { color: #4275b8; background: #eaf2fd; }
.tag-orange { color: #a86c2e; background: #fdf2e7; }
.tag-gray { color: #7c748a; background: #f3f1f6; }
.tag-red { color: #b4575b; background: #fff0f1; }

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

.table-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.empty-block {
  padding: 54px 20px;
  text-align: center;
  color: var(--muted);
  font-size: 14px;
}

.empty-block strong {
  display: block;
  color: var(--ink-soft);
  font-size: 16px;
  margin-bottom: 6px;
}

.pager {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 10px;
  padding: 14px 18px;
  font-size: 12px;
  color: var(--muted);
}

/* ---------- Modals ---------- */
.modal-shell {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  padding: 24px;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(43, 34, 62, 0.38);
  backdrop-filter: blur(4px);
}

.modal-card {
  position: relative;
  width: min(760px, 100%);
  max-height: 88vh;
  display: flex;
  flex-direction: column;
  background: #fff;
  border-radius: 24px;
  box-shadow: 0 30px 80px rgba(43, 34, 62, 0.25);
  animation: modal-in 0.2s ease;
}

.modal-card.wide {
  width: min(980px, 100%);
}

@keyframes modal-in {
  from { opacity: 0; transform: translateY(12px) scale(0.985); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.modal-head {
  padding: 24px 28px 18px;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  border-bottom: 1px solid var(--line);
}

.modal-head h2 {
  margin: 6px 0 0;
  font-size: 22px;
}

.modal-body {
  padding: 22px 28px;
  overflow-y: auto;
}

.modal-foot {
  padding: 16px 28px 22px;
  border-top: 1px solid var(--line);
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  flex-wrap: wrap;
}

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

.form-grid .span-2 {
  grid-column: span 2;
}

.section-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--ink-soft);
  margin: 8px 0 14px;
  padding-top: 6px;
  border-top: 1px dashed var(--line);
}

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

.segmented {
  display: flex;
  gap: 8px;
  background: var(--panel-soft);
  padding: 5px;
  border-radius: 13px;
  border: 1px solid var(--line);
}

.segmented button {
  flex: 1;
  border: none;
  background: transparent;
  border-radius: 9px;
  padding: 9px 12px;
  font-size: 13px;
  font-weight: 600;
  color: var(--ink-soft);
}

.segmented button.active {
  background: #fff;
  color: var(--primary-deep);
  box-shadow: 0 4px 12px rgba(82, 61, 128, 0.10);
}

.radio-row {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  padding: 5px 0;
}

.radio-row label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--ink-soft);
}

.upload-box {
  border: 1px dashed #d9cfea;
  border-radius: 14px;
  background: var(--panel-soft);
  padding: 14px;
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
}

.upload-preview {
  width: 132px;
  height: 76px;
  border-radius: 10px;
  object-fit: cover;
  background: #fff;
  border: 1px solid var(--line);
}

.upload-meta {
  flex: 1;
  min-width: 180px;
}

.upload-meta p {
  margin: 0 0 8px;
  font-size: 12px;
  color: var(--muted);
}

input[type="file"] {
  font-size: 12px;
  color: var(--muted);
}

/* ---------- Word groups ---------- */
.hint-card {
  padding: 18px 22px;
  margin-bottom: 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
}

.hint-card p {
  margin: 6px 0 0;
  font-size: 13px;
  line-height: 1.7;
}

.group-list {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.group-card {
  padding: 20px 22px;
}

.group-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.group-title {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.group-title strong {
  font-size: 16px;
}

.group-meta {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  color: var(--muted);
  font-size: 12px;
  margin-top: 8px;
}

.group-body {
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px dashed var(--line);
}

.word-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(215px, 1fr));
  gap: 10px;
}

.word-card-mini {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 11px 13px;
  background: var(--panel-soft);
}

.word-card-mini strong {
  display: block;
  font-size: 13px;
  margin-bottom: 5px;
}

.word-card-mini p {
  margin: 0;
  font-size: 11px;
  color: var(--muted);
  line-height: 1.6;
}

.word-card-mini .tag-row {
  margin-top: 7px;
}

.word-rows {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.word-row {
  display: grid;
  grid-template-columns: 1.2fr 0.8fr 0.6fr 1.4fr 1.6fr 40px;
  gap: 8px;
  align-items: end;
}

.word-row .field {
  margin: 0;
}

.word-row .field textarea {
  min-height: 42px;
  height: 42px;
  padding: 10px 12px;
}

.word-row-remove {
  height: 42px;
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 11px;
  color: var(--muted);
  display: grid;
  place-items: center;
}

.detail-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}

.detail-item {
  background: var(--panel-soft);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px 14px;
}

.detail-item span {
  display: block;
  font-size: 11px;
  color: var(--muted);
  margin-bottom: 5px;
}

.detail-item strong {
  font-size: 13px;
  font-weight: 600;
  word-break: break-all;
}

.detail-content {
  white-space: pre-wrap;
  line-height: 1.8;
  font-size: 13px;
  color: var(--ink-soft);
  background: var(--panel-soft);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 16px;
  max-height: 220px;
  overflow-y: auto;
}

.modal-subtitle {
  font-size: 14px;
  font-weight: 700;
  margin: 20px 0 10px;
}

.code-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 360px;
  overflow-y: auto;
}

.code-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: 11px;
  padding: 10px 13px;
  background: var(--panel-soft);
  font-size: 12px;
}

.code-item code {
  font-family: "SFMono-Regular", Consolas, monospace;
  font-size: 12px;
  word-break: break-all;
}

.code-item .muted {
  font-size: 11px;
}

/* ---------- Toast ---------- */
.toast-root {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 200;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.toast {
  min-width: 220px;
  max-width: 360px;
  padding: 12px 16px;
  border-radius: 12px;
  background: #2f2a3c;
  color: #fff;
  font-size: 13px;
  line-height: 1.6;
  box-shadow: 0 16px 40px rgba(43, 34, 62, 0.28);
  animation: toast-in 0.2s ease;
}

.toast.error {
  background: #a94f54;
}

@keyframes toast-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ---------- Responsive ---------- */
@media (max-width: 1024px) {
  .login-shell {
    grid-template-columns: 1fr;
  }
  .login-art {
    display: none;
  }
  .app-shell {
    grid-template-columns: 1fr;
  }
  .sidebar {
    position: static;
    height: auto;
    flex-direction: row;
    align-items: center;
    gap: 16px;
    padding: 14px 18px;
    overflow-x: auto;
    white-space: nowrap;
  }
  .sidebar-brand {
    flex-shrink: 0;
  }
  .sidebar-brand span {
    display: none;
  }
  .sidebar-nav {
    flex-direction: row;
    flex-shrink: 0;
  }
  .nav-item {
    white-space: nowrap;
    padding: 10px 12px;
  }
  .sidebar-foot {
    margin-left: auto;
    border-top: none;
    padding-top: 0;
    gap: 12px;
    flex-shrink: 0;
  }
  .main {
    padding: 24px 20px 50px;
  }
}

@media (max-width: 720px) {
  .sidebar-brand strong {
    font-size: 13px;
  }
  .brand-dot {
    width: 34px;
    height: 34px;
    border-radius: 11px;
  }
  .brand-dot svg {
    width: 22px;
    height: 22px;
  }
  .nav-item {
    font-size: 13px;
    gap: 7px;
  }
  .sidebar-foot #admin-name {
    display: none;
  }
  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }
  .topbar-actions {
    width: 100%;
  }
  .topbar-actions .btn {
    flex: 1;
    justify-content: center;
  }
  .form-grid {
    grid-template-columns: 1fr;
  }
  .form-grid .span-2 {
    grid-column: span 1;
  }
  .word-row {
    grid-template-columns: 1fr 1fr;
  }
  .word-row-remove {
    height: 42px;
  }
  .modal-card {
    max-height: 94vh;
  }
  .login-card {
    padding: 30px 24px;
  }
  .toast-root {
    left: 16px;
    right: 16px;
    bottom: 16px;
  }
  .toast {
    max-width: none;
  }
}
