:root {
  --bg: #ffbe0b;
  --bg-2: #ffd95a;
  --text: #14213d;
  --card: rgba(255, 255, 255, 0.88);
  --line: rgba(20, 33, 61, 0.12);
  --primary: #1d4ed8;
  --primary-2: #3b82f6;
  --danger: #ef4444;
  --shadow: 0 20px 40px rgba(20, 33, 61, 0.16);
  --surface-strong: rgba(255, 255, 255, 0.86);
  --surface-soft: rgba(255, 255, 255, 0.72);
  --surface-border: rgba(20, 33, 61, 0.16);
  --focus-ring: #111827;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  font-family: "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  color: var(--text);
}

body {
  background: linear-gradient(120deg, var(--bg), var(--bg-2));
  transition: background 0.4s ease;
}

.bg-glow {
  position: fixed;
  inset: 0;
  pointer-events: none;
  background-image:
    linear-gradient(var(--line) 1px, transparent 1px),
    linear-gradient(90deg, var(--line) 1px, transparent 1px);
  background-size: 36px 36px;
  opacity: 0.5;
}

.app-shell {
  position: relative;
  z-index: 1;
  max-width: 1200px;
  margin: 0 auto;
  padding: 20px;
}

.seo-intro {
  max-width: 900px;
  margin: 0 0 14px;
}

.seo-intro h2 {
  margin: 0 0 6px;
  font-size: 20px;
}

.seo-intro p {
  margin: 0;
  opacity: 0.9;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 16px;
  margin-bottom: 14px;
}

h1 {
  font-size: clamp(32px, 5vw, 52px);
  margin: 0;
}

.subtitle {
  margin: 0;
  letter-spacing: 0.15em;
  opacity: 0.8;
}

.visitor-tip {
  margin: 8px 0 0;
  font-size: 14px;
  opacity: 0.9;
}

.theme-box {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  flex-wrap: wrap;
}

.control-toggle {
  border: 1px solid var(--surface-border);
  background: var(--surface-strong);
  color: var(--text);
  border-radius: 999px;
  padding: 8px 14px;
  cursor: pointer;
  font-size: 14px;
  transition: all 0.2s ease;
  font-weight: 600;
}

.control-toggle:hover {
  transform: translateY(-1px);
  filter: brightness(1.05);
}

.ghost-toggle {
  background: var(--surface-soft);
}

.control-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
  align-items: flex-start;
}

.control-group span,
.control-group label {
  font-size: 13px;
  opacity: 0.85;
}

.theme-switches {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-start;
}

.mode-switches {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.theme-btn {
  border: 0;
  border-radius: 999px;
  padding: 8px 14px;
  cursor: pointer;
  color: #fff;
  font-size: 13px;
  box-shadow: var(--shadow);
  transition: transform 0.2s ease, filter 0.2s ease;
  font-weight: 600;
}

.theme-btn:hover {
  transform: translateY(-2px);
  filter: brightness(1.08);
}

.theme-btn.active {
  outline: 2px solid #fff;
}

.mode-btn {
  border: 1px solid var(--surface-border);
  border-radius: 999px;
  padding: 7px 12px;
  background: var(--surface-soft);
  color: var(--text);
  cursor: pointer;
  transition: all 0.2s ease;
  font-weight: 600;
}

.mode-btn:hover {
  transform: translateY(-1px);
}

.mode-btn.active {
  color: #fff;
  border-color: transparent;
  background: linear-gradient(120deg, var(--primary), var(--primary-2));
}

.content {
  display: grid;
  grid-template-columns: 280px 1fr 320px;
  gap: 16px;
}

.panel {
  background: var(--card);
  border: 1px solid rgba(255, 255, 255, 0.4);
  border-radius: 18px;
  padding: 16px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(6px);
}

.panel h2 {
  margin-top: 0;
}

.panel-title-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.category-list {
  list-style: none;
  margin: 12px 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 430px;
  overflow: auto;
}

.category-item {
  border: 1px solid transparent;
  border-radius: 12px;
  padding: 10px 12px;
  display: flex;
  justify-content: space-between;
  gap: 12px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.category-item:hover {
  background: var(--surface-soft);
}

.category-item.active {
  border-color: var(--surface-border);
  background: var(--surface-strong);
}

.category-main {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.category-meta {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.count-badge {
  min-width: 28px;
  text-align: center;
  border-radius: 999px;
  padding: 2px 8px;
  background: var(--surface-soft);
  font-size: 12px;
}

.cat-delete-btn {
  width: 20px;
  height: 20px;
  border: none;
  border-radius: 999px;
  display: grid;
  place-items: center;
  font-size: 14px;
  line-height: 1;
  cursor: pointer;
  color: var(--text);
  background: transparent;
  opacity: 0.45;
  transition: all 0.2s ease;
}

.category-item:hover .cat-delete-btn,
.category-item.active .cat-delete-btn {
  opacity: 1;
}

.cat-delete-btn:hover {
  color: #fff;
  background: rgba(239, 68, 68, 0.85);
}

.picker-panel {
  position: relative;
  overflow: hidden;
  min-height: 500px;
}

.result-box {
  text-align: center;
  margin-top: 48px;
}

.result-label {
  margin: 0;
  opacity: 0.7;
}

#resultText {
  font-size: clamp(40px, 7vw, 84px);
  margin: 12px 0;
}

.hidden {
  display: none !important;
}

.wheel-stage {
  position: relative;
  width: 180px;
  height: 180px;
  margin: 14px auto 0;
}

.wheel-disc {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  border: 8px solid rgba(255, 255, 255, 0.72);
  background: conic-gradient(#f43f5e 0deg 90deg, #f97316 90deg 180deg, #22c55e 180deg 270deg, #3b82f6 270deg 360deg);
  box-shadow: 0 12px 24px rgba(20, 33, 61, 0.18);
  transition: transform 2.3s cubic-bezier(0.2, 0.85, 0.18, 1);
}

.wheel-pointer {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  top: -14px;
  width: 0;
  height: 0;
  border-left: 12px solid transparent;
  border-right: 12px solid transparent;
  border-top: 18px solid #ef4444;
}

.slot-stage {
  width: min(340px, 100%);
  margin: 14px auto 0;
}

.slot-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

.slot-col {
  border: 1px solid var(--surface-border);
  border-radius: 12px;
  min-height: 58px;
  display: grid;
  place-items: center;
  font-size: 20px;
  font-weight: 600;
  background: var(--surface-strong);
  color: var(--text);
}

.slot-col.spin span {
  animation: slotBlink 0.12s linear infinite;
}

@keyframes slotBlink {
  0% {
    transform: translateY(-1px);
    opacity: 0.7;
  }
  100% {
    transform: translateY(1px);
    opacity: 1;
  }
}

.result-pop {
  animation: pop 0.45s ease;
}

@keyframes pop {
  0% {
    transform: scale(0.8);
    opacity: 0.4;
  }
  60% {
    transform: scale(1.08);
  }
  100% {
    transform: scale(1);
    opacity: 1;
  }
}

.result-hint {
  min-height: 24px;
}

.float-area {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.float-chip {
  position: absolute;
  font-size: 20px;
  animation: floatUp 1s ease forwards;
}

@keyframes floatUp {
  0% {
    transform: translateY(0) scale(0.8);
    opacity: 0;
  }
  20% {
    opacity: 1;
  }
  100% {
    transform: translateY(-140px) scale(1.2) rotate(16deg);
    opacity: 0;
  }
}

label {
  display: block;
  margin-bottom: 8px;
}

textarea,
input {
  width: 100%;
  border: 1px solid var(--surface-border);
  border-radius: 12px;
  padding: 10px;
  resize: vertical;
  font: inherit;
  background: var(--surface-strong);
  color: var(--text);
}

button:focus-visible,
select:focus-visible,
input:focus-visible,
textarea:focus-visible {
  outline: 3px solid var(--focus-ring);
  outline-offset: 2px;
}

.editor-actions {
  margin-top: 12px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.autosave-tip {
  margin: 10px 0 0;
  font-size: 13px;
  opacity: 0.7;
}

.btn {
  border: none;
  border-radius: 999px;
  padding: 10px 18px;
  font-size: 16px;
  cursor: pointer;
  transition: all 0.2s ease;
  font-weight: 600;
}

.btn:hover {
  transform: translateY(-1px);
}

.btn.primary {
  color: #fff;
  background: linear-gradient(120deg, var(--primary), var(--primary-2));
}

.btn.soft {
  width: 100%;
  color: var(--text);
  background: var(--surface-soft);
  border: 1px solid var(--surface-border);
}

.btn.ghost {
  color: var(--text);
  background: var(--surface-soft);
  border: 1px solid var(--surface-border);
}

.btn.danger {
  color: #fff;
  background: var(--danger);
}

.pulse {
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0%,
  100% {
    box-shadow: 0 0 0 0 rgba(59, 130, 246, 0.5);
  }
  70% {
    box-shadow: 0 0 0 15px rgba(59, 130, 246, 0);
  }
}

dialog {
  border: none;
  border-radius: 16px;
  padding: 0;
  width: min(560px, calc(100vw - 24px));
}

dialog::backdrop {
  background: rgba(0, 0, 0, 0.35);
}

.dialog-card {
  padding: 18px;
}

menu {
  margin: 12px 0 0;
  padding: 0;
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

#settingsDialog .dialog-card {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.help-list p {
  margin: 6px 0;
  line-height: 1.6;
}

.help-tip {
  margin: 8px 0 0;
  font-size: 13px;
  opacity: 0.8;
}

/* 主题模板 */
body.theme-sunrise {
  --bg: #ffbe0b;
  --bg-2: #ffd95a;
  --text: #14213d;
  --card: rgba(255, 255, 255, 0.88);
  --line: rgba(20, 33, 61, 0.12);
  --primary: #2563eb;
  --primary-2: #60a5fa;
  --surface-strong: rgba(255, 255, 255, 0.9);
  --surface-soft: rgba(255, 255, 255, 0.74);
  --surface-border: rgba(20, 33, 61, 0.18);
  --focus-ring: #0f172a;
}

body.theme-aurora {
  --bg: #6a11cb;
  --bg-2: #2575fc;
  --text: #f9fbff;
  --card: rgba(9, 15, 40, 0.72);
  --line: rgba(255, 255, 255, 0.12);
  --primary: #22d3ee;
  --primary-2: #6366f1;
  --surface-strong: rgba(255, 255, 255, 0.2);
  --surface-soft: rgba(255, 255, 255, 0.16);
  --surface-border: rgba(255, 255, 255, 0.34);
  --focus-ring: #f8fafc;
}

body.theme-mint {
  --bg: #84fab0;
  --bg-2: #8fd3f4;
  --text: #0f172a;
  --card: rgba(255, 255, 255, 0.82);
  --line: rgba(15, 23, 42, 0.1);
  --primary: #059669;
  --primary-2: #10b981;
  --surface-strong: rgba(255, 255, 255, 0.88);
  --surface-soft: rgba(255, 255, 255, 0.7);
  --surface-border: rgba(15, 23, 42, 0.16);
  --focus-ring: #0f172a;
}

body.theme-night {
  --bg: #111827;
  --bg-2: #1f2937;
  --text: #f3f4f6;
  --card: rgba(31, 41, 55, 0.82);
  --line: rgba(243, 244, 246, 0.09);
  --primary: #f59e0b;
  --primary-2: #f97316;
  --surface-strong: rgba(255, 255, 255, 0.2);
  --surface-soft: rgba(255, 255, 255, 0.15);
  --surface-border: rgba(255, 255, 255, 0.34);
  --focus-ring: #f8fafc;
}

/* 深色主题下的按钮对比度增强 */
body.theme-aurora .control-toggle,
body.theme-night .control-toggle,
body.theme-aurora .btn.ghost,
body.theme-night .btn.ghost,
body.theme-aurora .btn.soft,
body.theme-night .btn.soft,
body.theme-aurora .mode-btn,
body.theme-night .mode-btn {
  color: #0f172a;
  background: rgba(255, 255, 255, 0.9);
  border-color: rgba(255, 255, 255, 0.6);
}

body.theme-aurora .mode-btn {
  border-color: rgba(129, 140, 248, 0.55);
  background: rgba(238, 242, 255, 0.95);
  color: #1e1b4b;
}

body.theme-night .mode-btn {
  border-color: rgba(148, 163, 184, 0.55);
  background: rgba(241, 245, 249, 0.95);
  color: #0f172a;
}

body.theme-aurora .mode-btn:hover {
  border-color: rgba(99, 102, 241, 0.78);
  background: rgba(224, 231, 255, 0.98);
}

body.theme-night .mode-btn:hover {
  border-color: rgba(100, 116, 139, 0.8);
  background: rgba(226, 232, 240, 0.98);
}

body.theme-aurora .mode-btn.active,
body.theme-night .mode-btn.active,
body.theme-aurora .btn.primary,
body.theme-night .btn.primary {
  color: #ffffff;
}

body.theme-aurora .mode-btn.active {
  border-color: rgba(255, 255, 255, 0.75);
  background: linear-gradient(120deg, #4f46e5, #7c3aed);
}

body.theme-night .mode-btn.active {
  border-color: rgba(255, 255, 255, 0.75);
  background: linear-gradient(120deg, #f59e0b, #ea580c);
}

@media (max-width: 1080px) {
  .content {
    grid-template-columns: 1fr 1fr;
  }

  .editor-panel {
    grid-column: 1 / -1;
  }
}

@media (max-width: 760px) {
  .topbar {
    flex-direction: column;
    align-items: flex-start;
  }

  .theme-box {
    width: 100%;
  }

  .content {
    grid-template-columns: 1fr;
  }

  .picker-panel {
    min-height: 380px;
  }

  .result-box {
    margin-top: 20px;
  }
}
