/* ========================================
   CSS Variables & Reset
   ======================================== */
:root {
  --primary: #f97316;
  --primary-dark: #ea580c;
  --primary-light: #fed7aa;
  --bg: #faf7f2;
  --surface: #ffffff;
  --surface-2: #f5f0ea;
  --text: #1c1917;
  --text-2: #78716c;
  --text-3: #a8a29e;
  --border: #e7e0d8;
  --border-2: #d4cbc3;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
  --shadow: 0 4px 12px rgba(0,0,0,0.08), 0 2px 4px rgba(0,0,0,0.04);
  --shadow-lg: 0 12px 32px rgba(0,0,0,0.12), 0 4px 8px rgba(0,0,0,0.06);
  --radius: 16px;
  --radius-sm: 8px;
  --radius-full: 999px;
  --transition: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-spring: 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);

  /* Rating colors */
  --hang-bg: #ef4444; --hang-text: #fff;
  --dingji-bg: #f97316; --dingji-text: #fff;
  --renshangren-bg: #eab308; --renshangren-text: #fff;
  --npc-bg: #fde68a; --npc-text: #713f12;
  --la-bg: #f5f5f4; --la-text: #78716c;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  font-family: 'Inter', 'PingFang SC', 'Microsoft YaHei', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-2); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-3); }

::selection { background: var(--primary-light); color: var(--primary-dark); }

.hidden { display: none !important; }

/* ========================================
   Layout
   ======================================== */
.container {
  max-width: 1280px;
  margin: 0 auto;
  padding: 0 1.5rem;
}

/* ========================================
   Toast
   ======================================== */
.toast {
  position: fixed;
  bottom: 2rem;
  left: 50%;
  transform: translateX(-50%) translateY(120px);
  background: var(--text);
  color: #fff;
  padding: 0.75rem 1.5rem;
  border-radius: var(--radius-full);
  font-size: 0.9rem;
  font-weight: 500;
  z-index: 9999;
  transition: transform var(--transition-spring), opacity var(--transition);
  opacity: 0;
  pointer-events: none;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  box-shadow: var(--shadow-lg);
  white-space: nowrap;
}

.toast.show {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
  pointer-events: auto;
}

.toast.success { background: #16a34a; }
.toast.error { background: var(--hang-bg); }
.toast.info { background: var(--primary); }

/* ========================================
   Header
   ======================================== */
header {
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
}

header .container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: 0.875rem;
  padding-bottom: 0.875rem;
  gap: 1rem;
}

.logo-link {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  text-decoration: none;
  color: var(--text);
  flex-shrink: 0;
}

.logo-icon {
  width: 42px;
  height: 42px;
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 1.1rem;
  box-shadow: 0 4px 12px rgba(249, 115, 22, 0.3);
  transition: transform var(--transition);
}

.logo-link:hover .logo-icon { transform: rotate(-6deg) scale(1.05); }

.logo-title {
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.02em;
  line-height: 1.2;
}

.logo-sub {
  font-size: 0.7rem;
  color: var(--text-3);
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: lowercase;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

/* ========================================
   Buttons
   ======================================== */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.5rem 1rem;
  border-radius: var(--radius-full);
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: all var(--transition);
  white-space: nowrap;
  line-height: 1;
  outline: none;
}

.btn:focus-visible {
  box-shadow: 0 0 0 3px var(--primary-light);
}

.btn:active { transform: scale(0.96); }

.btn-primary {
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: #fff;
  box-shadow: 0 2px 8px rgba(249, 115, 22, 0.25);
}

.btn-primary:hover {
  box-shadow: 0 4px 16px rgba(249, 115, 22, 0.35);
  transform: translateY(-1px);
}

.btn-secondary {
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--border);
}

.btn-secondary:hover { background: var(--border); }

.btn-ghost {
  background: transparent;
  color: var(--text-2);
  padding: 0.5rem;
  width: 38px;
  height: 38px;
  justify-content: center;
  border-radius: 10px;
}

.btn-ghost:hover { background: var(--surface-2); color: var(--text); }
.btn-ghost.active { background: var(--primary-light); color: var(--primary); }

.btn-white {
  background: var(--surface);
  color: var(--text);
  border: 1.5px solid var(--border);
}

.btn-white:hover { background: var(--surface-2); border-color: var(--border-2); }

.btn-danger {
  background: var(--hang-bg);
  color: #fff;
}

.btn-danger:hover { background: #dc2626; }

.btn-link-add {
  background: transparent;
  color: var(--primary);
  border: none;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  padding: 0.25rem 0.5rem;
  border-radius: var(--radius-sm);
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  transition: all var(--transition);
}

.btn-link-add:hover { background: var(--primary-light); }

/* ========================================
   View Toggle
   ======================================== */
.view-toggle {
  display: flex;
  background: var(--surface-2);
  border-radius: 10px;
  padding: 3px;
  gap: 2px;
}

.view-btn {
  padding: 0.375rem 0.6rem;
  border: none;
  background: transparent;
  border-radius: 7px;
  cursor: pointer;
  color: var(--text-3);
  font-size: 0.85rem;
  transition: all var(--transition);
  display: flex;
  align-items: center;
}

.view-btn.active {
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-sm);
}

.view-btn:hover:not(.active) { color: var(--text-2); }

/* ========================================
   Main
   ======================================== */
main {
  padding: 1.5rem 0 2rem;
}

/* ========================================
   Stats Bar
   ======================================== */
.stats-bar {
  display: flex;
  align-items: center;
  gap: 0;
  background: var(--surface);
  border-radius: var(--radius);
  padding: 0.5rem 0.75rem;
  box-shadow: var(--shadow-sm);
  margin-bottom: 1rem;
  overflow-x: auto;
}

.stat-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 0.4rem 1rem;
  min-width: 60px;
  flex-shrink: 0;
  border: none;
  background: transparent;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all var(--transition);
  position: relative;
}

.stat-item:hover { background: var(--surface-2); }

.stat-item.active {
  background: var(--surface-2);
}

.stat-item.active::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 24px;
  height: 3px;
  border-radius: 2px;
  background: var(--primary);
}

.stat-hang.active::after { background: var(--hang-bg); }
.stat-dingji.active::after { background: var(--dingji-bg); }
.stat-renshangren.active::after { background: var(--renshangren-bg); }
.stat-npc.active::after { background: #d97706; }
.stat-la.active::after { background: var(--la-bg); }

.stat-value {
  font-size: 1.4rem;
  font-weight: 800;
  color: var(--text);
  line-height: 1;
  letter-spacing: -0.03em;
  transition: transform var(--transition);
}

.stat-item:hover .stat-value,
.stat-item.active .stat-value { transform: scale(1.1); }

.stat-label {
  font-size: 0.7rem;
  color: var(--text-3);
  font-weight: 500;
  margin-top: 0.2rem;
}

.stat-divider {
  width: 1px;
  height: 28px;
  background: var(--border);
  flex-shrink: 0;
}

/* ========================================
   Filter Bar
   ======================================== */
.filter-bar {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.filter-bar-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.filter-bar-row.rating-row {
  flex-wrap: nowrap;
  overflow-x: auto;
  padding-bottom: 0.25rem;
}

@media (min-width: 768px) {
  .filter-bar {
    flex-direction: row;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.75rem 1rem;
  }
  .filter-bar-row {
    flex: 1;
  }
  .filter-bar-row.rating-row {
    flex: none;
    overflow-x: visible;
    padding-bottom: 0;
  }
}

.search-box {
  position: relative;
  flex: 1;
  max-width: 420px;
}

.search-icon {
  position: absolute;
  left: 1rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-3);
  font-size: 0.9rem;
  pointer-events: none;
}

.search-input {
  width: 100%;
  padding: 0.625rem 2.75rem 0.625rem 2.75rem;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-full);
  background: var(--surface);
  font-size: 0.9rem;
  color: var(--text);
  transition: all var(--transition);
  outline: none;
}

.search-input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(249, 115, 22, 0.1);
}

.search-input::placeholder { color: var(--text-3); }

.clear-search {
  position: absolute;
  right: 0.75rem;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  color: var(--text-3);
  cursor: pointer;
  padding: 0.25rem;
  font-size: 0.9rem;
  line-height: 1;
  transition: color var(--transition);
}

.clear-search:hover { color: var(--text-2); }

.filter-controls {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.rating-chips {
  display: flex;
  gap: 0.375rem;
  flex-wrap: wrap;
}

.chip {
  padding: 0.3rem 0.75rem;
  border-radius: var(--radius-full);
  font-size: 0.78rem;
  font-weight: 600;
  border: 1.5px solid var(--border);
  background: var(--surface);
  color: var(--text-2);
  cursor: pointer;
  transition: all var(--transition);
  outline: none;
}

.chip:hover { border-color: var(--text-3); color: var(--text); }

.chip-active {
  border-color: var(--primary);
  color: var(--primary);
  background: var(--primary-light);
}

.chip-hang.chip-active { border-color: var(--hang-bg); color: var(--hang-bg); background: #fee2e2; }
.chip-dingji.chip-active { border-color: var(--dingji-bg); color: var(--dingji-bg); background: #ffedd5; }
.chip-renshangren.chip-active { border-color: var(--renshangren-bg); color: #a16207; background: #fef9c3; }
.chip-npc.chip-active { border-color: #d97706; color: #92400e; background: #fef3c7; }
.chip-la.chip-active { border-color: var(--la-bg); color: var(--la-text); background: var(--la-bg); }

.sort-box {
  position: relative;
  display: flex;
  align-items: center;
}

.sort-select {
  appearance: none;
  -webkit-appearance: none;
  padding: 0.45rem 2rem 0.45rem 0.875rem;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-full);
  background: var(--surface);
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text);
  cursor: pointer;
  outline: none;
  transition: all var(--transition);
}

.sort-select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(249, 115, 22, 0.1);
}

.sort-arrow {
  position: absolute;
  right: 0.625rem;
  pointer-events: none;
  color: var(--text-3);
  font-size: 0.7rem;
}

/* ========================================
   Results Meta
   ======================================== */
.results-meta {
  font-size: 0.82rem;
  color: var(--text-3);
  margin-bottom: 0.875rem;
  min-height: 1.2rem;
  font-weight: 500;
}

/* ========================================
   Records Grid
   ======================================== */
.records-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 1rem;
}

.records-grid.list-view {
  grid-template-columns: 1fr;
}

/* ========================================
   Record Card
   ======================================== */
.record-card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border);
  overflow: hidden;
  cursor: pointer;
  transition: all var(--transition);
  animation: fadeInUp 0.3s ease-out both;
}

.record-card:hover {
  box-shadow: var(--shadow);
  border-color: var(--border-2);
  transform: translateY(-2px);
}

.record-card:active { transform: scale(0.99); }

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

/* List view variant */
.records-grid.list-view {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1rem;
}

.records-grid.list-view .record-card {
  display: flex;
  flex-direction: row;
  align-items: stretch;
  min-height: 100px;
}

.records-grid.list-view .record-card-left {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  width: 180px;
  flex-shrink: 0;
  padding: 1.5rem 1rem;
  border-right: 3px solid var(--border);
  background: var(--surface-2);
  text-align: center;
}

.records-grid.list-view .record-card-actions {
  display: flex;
  gap: 0.25rem;
  margin-top: auto;
}

.records-grid.list-view .record-card-actions .action-btn span {
  display: none;
}

.records-grid.list-view .record-card-right {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 0.375rem;
  padding: 0.75rem 1rem;
  min-width: 0;
}

.records-grid.list-view .record-card-meta {
  font-size: 0.82rem;
  color: var(--text-2);
}

.records-grid.list-view .record-card-price {
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--primary);
}

.records-grid:not(.list-view) .record-card-left {
  display: contents;
}

@media (max-width: 900px) {
  .records-grid.list-view {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 600px) {
  .records-grid.list-view .record-card {
    flex-direction: column;
  }
  .records-grid.list-view .record-card-left {
    width: 100%;
    flex-direction: row;
    flex-wrap: wrap;
    border-right: none;
    border-bottom: 2px solid var(--border);
    justify-content: space-between;
  }
  .records-grid.list-view .record-card-name {
    flex: 1;
  }
  .records-grid.list-view .record-card-actions {
    margin-top: 0;
  }
  .records-grid.list-view .record-card-actions .action-btn span {
    display: inline;
  }
}

.records-grid.list-view .record-card-name {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text);
  line-height: 1.3;
  word-break: break-word;
  text-align: center;
  margin-top: auto;
}

/* Card header */
.record-card-header {
  padding: 1rem 1rem 0.5rem;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.5rem;
}

.record-card-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text);
  line-height: 1.3;
  flex: 1;
  word-break: break-word;
}

.record-card-body {
  padding: 0 1rem 0.5rem;
}

.record-card-meta {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.82rem;
  color: var(--text-2);
  margin-bottom: 0.375rem;
}

.record-card-meta i {
  color: var(--text-3);
  width: 14px;
  text-align: center;
  flex-shrink: 0;
}

.record-card-price {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--primary);
  margin: 0.375rem 0;
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.price-main {
  font-size: 1.15rem;
  letter-spacing: -0.02em;
}

.price-sub {
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--text-3);
}

/* Links */
.record-card-links {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 0.375rem;
  margin: 0.5rem 0;
  max-width: 100%;
}

.record-card-links a {
  display: inline-flex;
  align-items: center;
  width: fit-content;
  gap: 0.3rem;
  padding: 0.2rem 0.6rem;
  border-radius: var(--radius-full);
  font-size: 0.72rem;
  font-weight: 600;
  text-decoration: none;
  transition: all var(--transition);
  color: #fff;
}

.record-card-links a:hover {
  transform: scale(1.06);
  box-shadow: 0 2px 8px rgba(0,0,0,0.15);
  filter: brightness(1.08);
}

/* Link pills (homepage cards) */
.record-card-link-pill {
  display: inline-flex;
  align-items: center;
  width: fit-content;
  padding: 0.2rem 0.6rem;
  border-radius: var(--radius-full);
  font-size: 0.72rem;
  font-weight: 600;
  text-decoration: none;
  transition: all var(--transition);
  color: #fff;
}

.record-card-link-pill:hover {
  transform: scale(1.06);
  box-shadow: 0 2px 8px rgba(0,0,0,0.15);
  filter: brightness(1.08);
}

.link-bg-1 { background: #ef4444; }
.link-bg-2 { background: #f97316; }
.link-bg-3 { background: #eab308; color: #1f2937; }
.link-bg-4 { background: #22c55e; }
.link-bg-5 { background: #3b82f6; }
.link-bg-6 { background: #6366f1; }
.link-bg-7 { background: #8b5cf6; }

/* Note */
.record-card-note {
  font-size: 0.8rem;
  color: var(--text-3);
  font-style: italic;
  margin-top: 0.375rem;
  line-height: 1.5;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* Card actions */
.record-card-actions {
  border-top: 1px solid var(--border);
  padding: 0.5rem 0.75rem;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.25rem;
}

.action-btn {
  background: none;
  border: none;
  cursor: pointer;
  padding: 0.4rem 0.6rem;
  border-radius: var(--radius-sm);
  font-size: 0.8rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 0.3rem;
  transition: all var(--transition);
  color: var(--text-2);
  position: relative;
}

.action-btn-edit:hover { color: var(--primary); background: var(--primary-light); }
.action-btn-delete:hover { color: var(--hang-bg); background: #fee2e2; }
.action-btn-recover:hover { color: #16a34a; background: #dcfce7; }

.action-btn::after {
  content: attr(title);
  position: absolute;
  bottom: 100%;
  left: 50%;
  transform: translateX(-50%);
  padding: 0.3rem 0.6rem;
  background: var(--text);
  color: white;
  font-size: 0.75rem;
  border-radius: var(--radius-sm);
  white-space: nowrap;
  opacity: 0;
  visibility: hidden;
  transition: all var(--transition);
  pointer-events: none;
  margin-bottom: 0.5rem;
  z-index: 100;
}

.action-btn:hover::after {
  opacity: 1;
  visibility: visible;
}

.action-btn::before {
  content: '';
  position: absolute;
  bottom: 100%;
  left: 50%;
  transform: translateX(-50%);
  border: 6px solid transparent;
  border-top-color: var(--text);
  opacity: 0;
  visibility: hidden;
  transition: all var(--transition);
  margin-bottom: -1px;
}

.action-btn:hover::before {
  opacity: 1;
  visibility: visible;
}

/* Rating badge */
.rating {
  display: inline-flex;
  align-items: center;
  gap: 0.2rem;
  padding: 0.2rem 0.55rem;
  border-radius: var(--radius-full);
  font-size: 0.7rem;
  font-weight: 700;
  flex-shrink: 0;
  line-height: 1;
}

.rating-hang { background: var(--hang-bg); color: var(--hang-text); }
.rating-dingji { background: var(--dingji-bg); color: var(--dingji-text); }
.rating-renshangren { background: var(--renshangren-bg); color: var(--renshangren-text); }
.rating-npc { background: var(--npc-bg); color: var(--npc-text); }
.rating-la { background: var(--la-bg); color: var(--la-text); }

/* ========================================
   Empty State
   ======================================== */
.empty-state {
  text-align: center;
  padding: 4rem 2rem;
  background: var(--surface);
  border-radius: var(--radius);
  border: 1px dashed var(--border-2);
  margin-top: 1rem;
}

.empty-icon {
  font-size: 3.5rem;
  color: var(--border-2);
  margin-bottom: 1rem;
}

.empty-state h3 {
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 0.5rem;
}

.empty-state p {
  color: var(--text-3);
  font-size: 0.9rem;
  margin-bottom: 1.5rem;
}

/* ========================================
   Modal
   ======================================== */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(28, 25, 23, 0.5);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  padding: 1rem;
  opacity: 0;
  transition: opacity var(--transition);
}

.modal:not(.hidden) { opacity: 1; }

.modal-panel {
  background: var(--surface);
  border-radius: 20px;
  width: 100%;
  max-width: 540px;
  max-height: 92vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
  transform: scale(0.94) translateY(20px);
  transition: transform var(--transition-spring);
}

@media (max-height: 700px) {
  .modal-panel {
    max-height: 85vh;
  }
}

.modal:not(.hidden) .modal-panel {
  transform: scale(1) translateY(0);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.25rem 1.5rem 0;
}

.modal-header h2 {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text);
}

.modal-close {
  width: 32px;
  height: 32px;
  border: none;
  background: var(--surface-2);
  border-radius: 8px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text);
  font-size: 0.9rem;
  transition: all var(--transition);
}

.modal-close:hover { background: #fee2e2; color: var(--hang-bg); }

.modal-body {
  padding: 1.25rem 1.5rem 1.5rem;
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 0.75rem;
  margin-top: 0.5rem;
}

/* ========================================
   Form
   ======================================== */
.form-row-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
  margin-bottom: 0.875rem;
}

.form-row-3 {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 0.75rem;
  margin-bottom: 0.875rem;
}

@media (max-width: 640px) {
  .form-row-2, .form-row-3 { grid-template-columns: 1fr; }
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  margin-bottom: 0.875rem;
}

.form-group label {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-2);
}

.required { color: var(--hang-bg); }

input, textarea, select {
  padding: 0.625rem 0.875rem;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  font-family: inherit;
  color: var(--text);
  background: var(--surface);
  transition: all var(--transition);
  outline: none;
  width: 100%;
}

input:focus, textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(249, 115, 22, 0.1);
}

input::placeholder, textarea::placeholder { color: var(--text-3); }

textarea { resize: vertical; min-height: 80px; }

/* Range inputs */
.range-inputs {
  display: flex;
  align-items: center;
  gap: 0.375rem;
}

.range-inputs input {
  width: 80px;
  text-align: center;
  flex-shrink: 0;
}

.range-inputs span {
  color: var(--text-3);
  font-size: 0.8rem;
  flex-shrink: 0;
  white-space: nowrap;
}

/* Unit input */
.unit-input {
  display: flex;
  align-items: center;
  gap: 0.375rem;
}

.unit-input input {
  width: 60px;
  text-align: center;
  box-sizing: border-box;
  flex-shrink: 0;
}

.unit-input span {
  color: var(--text-3);
  font-size: 0.8rem;
  white-space: nowrap;
  flex-shrink: 0;
}

/* Rating picker */
.rating-picker {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.rating-opt {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.4rem 0.875rem;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-full);
  background: var(--surface);
  cursor: pointer;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-2);
  transition: all var(--transition);
}

.rating-opt:hover { border-color: var(--text-3); }

.rating-opt.active {
  border-color: var(--primary);
  color: var(--primary);
  background: var(--primary-light);
}

.rating-opt[data-value="hang"].active { border-color: var(--hang-bg); color: var(--hang-bg); background: #fee2e2; }
.rating-opt[data-value="dingji"].active { border-color: var(--dingji-bg); color: var(--dingji-bg); background: #ffedd5; }
.rating-opt[data-value="renshangren"].active { border-color: var(--renshangren-bg); color: #a16207; background: #fef9c3; }
.rating-opt[data-value="npc"].active { border-color: #d97706; color: #92400e; background: #fef3c7; }
.rating-opt[data-value="la"].active { border-color: var(--la-bg); color: var(--la-text); background: var(--la-bg); }

.dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.dot-hang { background: var(--hang-bg); }
.dot-dingji { background: var(--dingji-bg); }
.dot-renshangren { background: var(--renshangren-bg); }
.dot-npc { background: var(--npc-bg); }
.dot-la { background: var(--la-bg); }

/* Links header */
.links-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.75rem;
}

.links-header label {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-2);
}

.links-container {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  max-height: 250px;
  overflow-y: auto;
  padding: 0.5rem;
  background: var(--surface-2);
  border-radius: var(--radius);
  border: 1px dashed var(--border);
  width: 100%;
  box-sizing: border-box;
}

.links-container:empty::before {
  content: '暂无链接';
  color: var(--text-3);
  font-size: 0.85rem;
  text-align: center;
  padding: 0.5rem;
  display: block;
}

/* Link item - each on its own line */
.link-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem;
  background: var(--surface);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  transition: all 0.15s ease;
  width: 100%;
  box-sizing: border-box;
  flex-shrink: 0;
}

.link-item:hover { border-color: var(--primary); }

/* Links container in edit/add mode */
#linksContainer:not(.view-mode) {
  display: flex;
  flex-direction: column;
}

/* View mode links container */
#linksContainer.view-mode {
  display: flex;
  flex-wrap: wrap;
  gap: 0.375rem;
  background: transparent;
  border: none;
  padding: 0;
  max-height: none;
  overflow: visible;
  border-radius: 0;
}

#linksContainer.view-mode .link-item { display: none; }

/* Links in edit/add mode */
#linksContainer:not(.view-mode) {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  padding: 0.5rem;
  background: var(--surface-2);
  border-radius: var(--radius);
  border: 1px dashed var(--border);
  width: 100%;
  box-sizing: border-box;
  max-height: 250px;
  overflow-y: auto;
}

/* Each link item in edit mode */
#linksContainer:not(.view-mode) .link-item {
  display: grid;
  grid-template-columns: 22px 120px 1fr 28px;
  align-items: center;
  gap: 0.375rem;
  padding: 0.375rem 0.5rem;
  background: var(--surface);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  transition: border-color 0.15s ease;
  flex-shrink: 0;
  width: auto;
  box-sizing: border-box;
}

.link-item:hover { border-color: var(--primary); }
.link-item.editing { border-color: var(--primary); }

/* Link number badge */
.link-number {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--primary);
  color: white;
  font-size: 0.72rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

/* Link label input */
.link-label-input {
  width: 100px;
  padding: 0.3rem 0.5rem;
  border: 1px solid var(--border);
  border-radius: 4px;
  font-size: 0.85rem;
  background: var(--surface);
  transition: border-color 0.15s ease;
  box-sizing: border-box;
  flex-shrink: 0;
}

.link-label-input:focus {
  border-color: var(--primary);
  outline: none;
}

/* Link URL input */
.link-url-input {
  min-width: 200px;
  flex: 1;
  padding: 0.3rem 0.5rem;
  border: 1px solid var(--border);
  border-radius: 4px;
  font-size: 0.85rem;
  background: var(--surface);
  transition: border-color 0.15s ease;
  box-sizing: border-box;
}

.link-url-input:focus {
  border-color: var(--primary);
  outline: none;
}

/* Remove button */
.link-remove {
  width: 28px;
  height: 28px;
  border: none;
  background: transparent;
  border-radius: 4px;
  cursor: pointer;
  color: var(--text-3);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s ease;
  flex-shrink: 0;
}

.link-remove:hover {
  background: #fee2e2;
  color: var(--hang-bg);
}

/* View mode links container - removed duplicate, uses first definition at line 1194 */

.modal:not(.hidden) .confirm-panel { transform: scale(1); }

.confirm-icon {
  width: 56px;
  height: 56px;
  background: #fee2e2;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 1rem;
  font-size: 1.5rem;
  color: var(--hang-bg);
}

.confirm-panel h3 {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 0.5rem;
}

.confirm-panel p {
  font-size: 0.9rem;
  color: var(--text);
  margin-bottom: 1.5rem;
}

.confirm-actions { display: flex; gap: 0.75rem; justify-content: center; }

/* Trash header */
.trash-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.5rem;
}

.trash-header h2 {
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

/* Trash meta info */
.trash-meta {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  font-size: 0.75rem;
  color: var(--text-3);
  margin-top: 0.375rem;
}

/* Active nav button */
.btn-ghost.active {
  background: var(--primary-light);
  color: var(--primary);
}

/* Record card in trash - slight fade */
#trashContainer .record-card {
  opacity: 0.9;
}

#trashContainer .records-grid {
  gap: 1rem;
}

#trashContainer .record-card-left {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  width: 180px;
  flex-shrink: 0;
  padding: 1.5rem 1rem;
  border-right: 3px solid var(--border);
  background: var(--surface-2);
  text-align: center;
}

#trashContainer .record-card-actions {
  display: flex;
  gap: 0.25rem;
  margin-top: auto;
}

#trashContainer .record-card-right {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 0.375rem;
  padding: 0.75rem 1rem;
  min-width: 0;
}

#trashContainer .record-card-name {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text);
  line-height: 1.3;
}

@media (max-width: 600px) {
  #trashContainer .record-card {
    flex-direction: column;
  }
  #trashContainer .record-card-left {
    width: 100%;
    flex-direction: row;
    flex-wrap: wrap;
    border-right: none;
    border-bottom: 2px solid var(--border);
    justify-content: space-between;
  }
  #trashContainer .record-card-name {
    flex: 1;
  }
  #trashContainer .record-card-actions {
    margin-top: 0;
  }
}

/* ========================================
   Footer
   ======================================== */
footer {
  background: var(--surface-2);
  border-top: 1px solid var(--border);
  text-align: center;
  padding: 1.25rem;
  margin-top: auto;
}

footer p {
  font-size: 0.82rem;
  color: var(--text-3);
}

footer span { opacity: 0.7; }

/* ========================================
   Responsive
   ======================================== */
@media (max-width: 768px) {
  .logo-title { font-size: 1.05rem; }
  .logo-sub { display: none; }
  .header-actions .btn span { display: none; }
  .records-grid { grid-template-columns: 1fr; }
  .stats-bar { gap: 0; }
  .stat-item { padding: 0 0.75rem; min-width: 48px; }
  .stat-value { font-size: 1.1rem; }
  .rating-chips { overflow-x: auto; flex-wrap: nowrap; padding-bottom: 0.25rem; }
  .chip { flex-shrink: 0; }
}

@media (max-width: 480px) {
  .container { padding: 0 1rem; }
  .btn-primary span { display: none; }
  .btn-primary { padding: 0.5rem; }
}

/* ========================================
   Turnstile Badge (unused - now on verify page)
   ======================================== */

/* ========================================
   Turnstile Loading Animation
   ======================================== */
#turnstileLoading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  padding: 1.5rem;
  color: var(--text-2);
  font-size: 0.9rem;
}

.loading-spinner {
  width: 32px;
  height: 32px;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}