/* ============================================
   失恋星系 (Breakup Galaxy) - 全局样式
   ============================================ */

:root {
  --void: #050208;
  --nebula: #0a0618;
  --star: #c084fc;
  --star-bright: #e879f9;
  --star-dim: #7c3aed;
  --fg: #e2e8f0;
  --muted: #64748b;
  --accent: #f0abfc;
  --warm: #fb7185;
  --cold: #60a5fa;
  --gold: #fbbf24;
  --serif: "Kaiti SC", "STKaiti", KaiTi, "楷体", "Source Han Serif SC", "Noto Serif SC", serif;
  font-family: "PingFang SC", "Microsoft YaHei", "Noto Sans CJK SC", system-ui, sans-serif;
}

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

html, body, #root {
  background: var(--void);
  height: 100%;
  color: var(--fg);
  overscroll-behavior: none;
  overflow: hidden;
}

/* ===== 3D Canvas ===== */
.app { position: fixed; inset: 0; }
canvas { cursor: crosshair; touch-action: none; display: block; }

/* ===== 顶部栏 ===== */
.hud-top {
  pointer-events: none;
  z-index: 20;
  align-items: center;
  gap: 16px;
  padding: 16px 20px;
  display: flex;
  position: fixed;
  top: 0; left: 0; right: 0;
}
.hud-top > * { pointer-events: auto; }

.title {
  letter-spacing: 0.15em;
  color: var(--star);
  font-size: 20px;
  font-weight: 600;
  white-space: nowrap;
}
.title-sub {
  letter-spacing: 0.2em;
  color: var(--muted);
  font-size: 11px;
  margin-left: 4px;
}

.btn-light {
  color: #1a0a2e;
  cursor: pointer;
  white-space: nowrap;
  background: linear-gradient(135deg, #c084fc, #e879f9);
  border: none;
  border-radius: 10px;
  padding: 8px 20px;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.06em;
  transition: filter 0.2s, transform 0.15s;
}
.btn-light:hover { filter: brightness(1.1); transform: translateY(-1px); }
.btn-light:active { transform: scale(0.97); }

.stat {
  color: var(--muted);
  letter-spacing: 0.04em;
  margin-left: auto;
  font-size: 12px;
}
.stat b { color: var(--star); font-weight: 600; }

/* ===== 搜索栏 ===== */
.search-bar {
  z-index: 22;
  position: fixed;
  top: 62px;
  left: 20px;
  width: 280px;
}
.search-box {
  display: flex;
  align-items: center;
  -webkit-backdrop-filter: blur(16px);
  backdrop-filter: blur(16px);
  background: #0a0618e6;
  border: 1px solid #c084fc30;
  border-radius: 12px;
  padding: 0 12px;
  gap: 8px;
  transition: border-color 0.2s;
}
.search-box:focus-within {
  border-color: #c084fc80;
}
.search-icon {
  font-size: 14px;
  flex-shrink: 0;
}
.search-input {
  background: none;
  border: none;
  outline: none;
  color: var(--fg);
  font-size: 13px;
  padding: 9px 0;
  flex: 1;
  width: 0;
}
.search-input::placeholder { color: var(--muted); opacity: 0.6; }
.search-clear {
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  font-size: 14px;
  padding: 2px;
  line-height: 1;
  transition: color 0.15s;
}
.search-clear:hover { color: var(--fg); }

.btn-random {
  cursor: pointer;
  white-space: nowrap;
  background: linear-gradient(135deg, #7c3aed44, #c084fc44);
  border: 1px solid #c084fc50;
  border-radius: 10px;
  padding: 7px 14px;
  font-size: 12px;
  font-weight: 500;
  color: var(--star);
  letter-spacing: 0.04em;
  margin-top: 8px;
  width: 100%;
  transition: background 0.2s, border-color 0.2s;
}
.btn-random:hover {
  background: linear-gradient(135deg, #7c3aed66, #c084fc66);
  border-color: #c084fc90;
}

/* 搜索结果 */
.search-results {
  -webkit-backdrop-filter: blur(16px);
  backdrop-filter: blur(16px);
  background: #0a0618f0;
  border: 1px solid #c084fc30;
  border-radius: 12px;
  margin-top: 8px;
  max-height: 320px;
  overflow-y: auto;
  animation: 0.2s ease rise;
}
.search-result-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  cursor: pointer;
  transition: background 0.12s;
  border-bottom: 1px solid #ffffff0a;
}
.search-result-item:last-child { border-bottom: none; }
.search-result-item:hover { background: #c084fc14; }
.search-result-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
  box-shadow: 0 0 6px currentColor;
}
.search-result-info { flex: 1; min-width: 0; }
.search-result-name {
  color: var(--fg);
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.search-result-code {
  color: var(--muted);
  font-size: 11px;
  font-family: ui-monospace, Menlo, monospace;
}
.search-result-count {
  color: var(--muted);
  font-size: 11px;
  flex-shrink: 0;
}
.search-empty {
  color: var(--muted);
  text-align: center;
  padding: 20px 0;
  font-size: 13px;
}

/* ===== 底部栏 ===== */
.hud-bottom {
  color: var(--muted);
  pointer-events: none;
  z-index: 20;
  justify-content: space-between;
  align-items: center;
  padding: 14px 20px;
  font-size: 12px;
  display: flex;
  position: fixed;
  bottom: 0; left: 0; right: 0;
}
.hint b { color: var(--star); font-weight: 600; }

/* ===== 星辰标签(Hover) ===== */
.star-label {
  z-index: 30;
  pointer-events: none;
  white-space: nowrap;
  text-overflow: ellipsis;
  background: #0a0618e6;
  border: 1px solid #c084fc66;
  border-radius: 8px;
  max-width: 240px;
  padding: 4px 10px;
  font-size: 13px;
  position: fixed;
  overflow: hidden;
  animation: 0.18s ease label-in;
}
.star-label-name {
  color: var(--star-bright);
  font-weight: 600;
}
.star-label-code {
  color: var(--muted);
  margin-left: 6px;
  font-family: ui-monospace, Menlo, monospace;
  font-size: 11px;
}
@keyframes label-in {
  from { opacity: 0; transform: translateY(4px); }
}

/* ===== 星辰详情面板 ===== */
.star-panel {
  -webkit-backdrop-filter: blur(18px);
  backdrop-filter: blur(18px);
  z-index: 25;
  background: radial-gradient(120% 60% at 50% 0, #c084fc0f, transparent 60%),
              linear-gradient(#0e0a1cf0, #070412eb);
  border: 1px solid #c084fc2e;
  border-radius: 16px;
  width: 380px;
  max-height: 82vh;
  padding: 26px 24px 22px;
  animation: 0.32s cubic-bezier(0.2, 0.7, 0.2, 1) rise;
  position: fixed;
  top: 50%; right: 24px;
  overflow-y: auto;
  transform: translateY(-50%);
  box-shadow: 0 18px 60px #0000008c, inset 0 1px #ffffff0a;
}
.star-panel::before {
  content: "";
  background: linear-gradient(90deg, transparent, var(--star), transparent);
  opacity: 0.5;
  height: 1px;
  position: absolute;
  top: 0; left: 22%; right: 22%;
}

@keyframes rise {
  from { opacity: 0; transform: translateY(calc(14px - 50%)); }
}

.panel-close {
  color: var(--muted);
  cursor: pointer;
  background: none;
  border: none;
  font-size: 22px;
  line-height: 1;
  position: absolute;
  top: 10px; right: 14px;
}
.panel-close:hover { color: var(--fg); }

.sp-head { margin-bottom: 14px; }
.sp-name {
  font-family: var(--serif);
  letter-spacing: 0.08em;
  color: var(--star-bright);
  text-shadow: 0 1px 18px #c084fc2e;
  font-size: 26px;
  font-weight: 600;
}
.sp-code {
  font-family: ui-monospace, SF Mono, Menlo, monospace;
  color: var(--muted);
  letter-spacing: 0.15em;
  font-size: 13px;
  margin-top: 4px;
}
.sp-code span { color: var(--gold); }
.sp-time {
  color: var(--muted);
  font-size: 11px;
  margin-top: 2px;
}

/* 发布按钮区域 */
.sp-actions {
  display: flex;
  gap: 8px;
  margin-top: 14px;
}
.btn-sp-action {
  flex: 1;
  color: var(--star);
  letter-spacing: 0.04em;
  cursor: pointer;
  background: linear-gradient(#c084fc26, #c084fc10);
  border: 1px solid #c084fc6b;
  border-radius: 10px;
  padding: 9px 8px;
  font-size: 13px;
  font-weight: 500;
  transition: background 0.15s, border-color 0.15s;
}
.btn-sp-action:hover {
  background: linear-gradient(#c084fc40, #c084fc1a);
  border-color: #c084fcb3;
}
.btn-share { color: var(--gold); border-color: #fbbf2450; background: linear-gradient(#fbbf2418, #fbbf2408); }
.btn-share:hover { background: linear-gradient(#fbbf2430, #fbbf2414); border-color: #fbbf2480; }
.btn-snapshot { color: #6ee7b7; border-color: #34d39950; background: linear-gradient(#34d39918, #34d39908); }
.btn-snapshot:hover { background: linear-gradient(#34d39930, #34d39914); border-color: #34d39980; }

/* 星语列表 */
.content-list {
  border-top: 1px solid #ffffff14;
  flex-direction: column;
  gap: 12px;
  padding-top: 14px;
  margin-top: 14px;
  display: flex;
}
.content-empty {
  color: var(--muted);
  text-align: center;
  padding: 24px 0;
  font-size: 13px;
}
.content-item {
  background: #ffffff06;
  border: 1px solid #ffffff0d;
  border-radius: 10px;
  padding: 12px 14px;
  animation: 0.25s ease rise;
}
.content-ring-tag {
  color: var(--star);
  font-size: 10px;
  letter-spacing: 0.1em;
  font-family: ui-monospace, Menlo, monospace;
  margin-bottom: 6px;
  opacity: 0.7;
}
.content-ring-tag::before {
  content: '';
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--star-bright);
  box-shadow: 0 0 6px var(--star-bright);
  margin-right: 6px;
  vertical-align: middle;
}
.content-text {
  color: var(--fg);
  font-size: 14px;
  line-height: 1.75;
  word-break: break-word;
  white-space: pre-wrap;
}
.content-time {
  color: var(--muted);
  font-size: 11px;
  margin-top: 8px;
  font-family: ui-monospace, Menlo, monospace;
}

/* ===== 模态框 ===== */
.modal-overlay {
  z-index: 60;
  -webkit-backdrop-filter: blur(4px);
  backdrop-filter: blur(4px);
  background: #0203088c;
  justify-content: center;
  align-items: center;
  animation: 0.2s ease rise;
  display: flex;
  position: fixed;
  inset: 0;
}
.modal-card {
  text-align: left;
  background: radial-gradient(120% 60% at 50% 0, #c084fc14, transparent 60%),
              linear-gradient(#10101cf7, #080612f5);
  border: 1px solid #c084fc38;
  border-radius: 18px;
  width: min(420px, 90vw);
  padding: 28px 26px 22px;
  box-shadow: 0 22px 70px #0009;
}
.modal-title {
  font-family: var(--serif);
  color: var(--star);
  letter-spacing: 0.06em;
  font-size: 22px;
  font-weight: 600;
  margin-bottom: 18px;
}
.modal-title .sub {
  color: var(--muted);
  font-size: 13px;
  font-family: inherit;
  font-weight: 400;
  letter-spacing: 0.02em;
  display: block;
  margin-top: 4px;
}

.form-group {
  flex-direction: column;
  gap: 6px;
  margin-bottom: 14px;
  display: flex;
}
.form-label {
  color: var(--muted);
  letter-spacing: 0.08em;
  font-size: 12px;
}
.form-input {
  color: var(--fg);
  background: #0a0618b8;
  border: 1px solid #ffffff24;
  border-radius: 10px;
  outline: none;
  padding: 10px 14px;
  font-size: 14px;
  transition: border-color 0.2s;
}
.form-input:focus { border-color: #c084fc80; }
.form-input::placeholder { color: var(--muted); opacity: 0.6; }
textarea.form-input { resize: vertical; min-height: 100px; line-height: 1.6; }
.form-input.digits {
  letter-spacing: 0.6em;
  text-align: center;
  font-size: 20px;
  font-family: ui-monospace, Menlo, monospace;
}

.form-hint {
  color: var(--muted);
  font-size: 11px;
}

.modal-actions {
  justify-content: flex-end;
  gap: 10px;
  margin-top: 18px;
  display: flex;
}
.btn-cancel {
  color: var(--muted);
  cursor: pointer;
  background: none;
  border: 1px solid #ffffff29;
  border-radius: 9px;
  padding: 8px 20px;
  font-size: 13px;
}
.btn-cancel:hover { color: var(--fg); }
.btn-confirm {
  color: #1a0a2e;
  cursor: pointer;
  background: linear-gradient(#c084fce6, #a855f7cc);
  border: none;
  border-radius: 9px;
  padding: 8px 24px;
  font-size: 13px;
  font-weight: 600;
}
.btn-confirm:hover { filter: brightness(1.08); }
.btn-confirm:disabled { opacity: 0.4; cursor: not-allowed; }

/* 创建成功卡片 */
.create-result {
  text-align: center;
  margin-top: 16px;
}
.create-result .star-icon {
  font-size: 48px;
  display: block;
  margin-bottom: 8px;
}
.create-result .result-name {
  font-family: var(--serif);
  color: var(--star-bright);
  font-size: 24px;
  font-weight: 600;
  letter-spacing: 0.06em;
}
.create-result .result-code {
  font-family: ui-monospace, Menlo, monospace;
  color: var(--gold);
  letter-spacing: 0.2em;
  font-size: 18px;
  margin: 8px 0 16px;
}
.create-result .result-hint {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.6;
}

/* ===== 留影预览模式 ===== */
.snapshot-overlay {
  z-index: 65;
  position: fixed;
  inset: 0;
  pointer-events: none;
}

/* 取景框边框 */
.snapshot-bars { pointer-events: none; }
.snapshot-bar-t, .snapshot-bar-b {
  position: fixed;
  left: 30px; right: 30px;
  color: #c084fc99;
  text-align: center;
  font-size: 12px;
  letter-spacing: 0.3em;
}
.snapshot-bar-t { top: 24px; }
.snapshot-bar-b { bottom: 24px; }
.snapshot-bar-l, .snapshot-bar-r {
  position: fixed;
  top: 24px; bottom: 24px;
  color: #c084fc66;
  display: flex; align-items: center;
  font-size: 18px;
}
.snapshot-bar-l { left: 24px; }
.snapshot-bar-r { right: 24px; }

/* 取景框四角 */
.snapshot-corner-tl, .snapshot-corner-tr,
.snapshot-corner-bl, .snapshot-corner-br {
  position: fixed;
  width: 36px; height: 36px;
  border-color: #c084fc;
  pointer-events: none;
}
.snapshot-corner-tl { left: 28px; top: 20px; border-left: 2px solid; border-top: 2px solid; }
.snapshot-corner-tr { right: 28px; top: 20px; border-right: 2px solid; border-top: 2px solid; }
.snapshot-corner-bl { left: 28px; bottom: 20px; border-left: 2px solid; border-bottom: 2px solid; }
.snapshot-corner-br { right: 28px; bottom: 20px; border-right: 2px solid; border-bottom: 2px solid; }

/* 提示文字 */
.snapshot-hint {
  position: fixed;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  text-align: center;
  pointer-events: none;
  opacity: 1;
  transition: opacity 1s;
}
.snapshot-hint-title {
  color: var(--star-bright);
  font-family: var(--serif);
  font-size: 28px;
  letter-spacing: 0.2em;
  text-shadow: 0 0 30px #c084fc88;
  margin-bottom: 10px;
}
.snapshot-hint-sub {
  color: var(--muted);
  font-size: 14px;
  letter-spacing: 0.06em;
}

/* 底部操作按钮 */
.snapshot-actions {
  position: fixed;
  bottom: 40px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 16px;
  z-index: 66;
  pointer-events: auto;
}
.snapshot-btn-cancel, .snapshot-btn-ok {
  cursor: pointer;
  border-radius: 12px;
  padding: 12px 32px;
  font-size: 15px;
  font-weight: 600;
  letter-spacing: 0.06em;
  transition: all 0.2s;
  border: none;
}
.snapshot-btn-cancel {
  color: var(--muted);
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.15);
}
.snapshot-btn-cancel:hover { color: var(--fg); background: rgba(255,255,255,0.14); }
.snapshot-btn-ok {
  color: #1a0a2e;
  background: linear-gradient(135deg, #c084fc, #e879f9);
}
.snapshot-btn-ok:hover { filter: brightness(1.1); transform: translateY(-1px); }
.snapshot-btn-ok:active { transform: scale(0.97); }

/* ===== Toast ===== */
.toast-container {
  z-index: 70;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
  display: flex;
  position: fixed;
  top: 70px; right: 20px;
}
.toast {
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
  background: #0a0618e6;
  border: 1px solid #c084fc52;
  border-radius: 10px;
  padding: 10px 18px;
  font-size: 13px;
  color: var(--fg);
  animation: 0.3s ease toast-in;
  pointer-events: auto;
  max-width: 320px;
}
.toast.error { border-color: #fb718566; color: #fca5a5; }
.toast.success { border-color: #34d39966; color: #6ee7b7; }
@keyframes toast-in {
  from { opacity: 0; transform: translateX(20px); }
}

/* ===== 加载屏 ===== */
.loading-screen {
  z-index: 50;
  background: var(--void);
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 12px;
  display: flex;
  position: fixed;
  inset: 0;
  transition: opacity 0.6s ease;
}
.loading-screen.fade-out { opacity: 0; pointer-events: none; }
.ls-title {
  letter-spacing: 0.35em;
  color: var(--star);
  font-size: 36px;
}
.ls-sub {
  color: var(--muted);
  letter-spacing: 0.15em;
  font-size: 13px;
}

/* ===== 滚动条 ===== */
.star-panel::-webkit-scrollbar { width: 6px; }
.star-panel::-webkit-scrollbar-thumb { background: #c084fc47; border-radius: 4px; }
.star-panel::-webkit-scrollbar-thumb:hover { background: #c084fc80; }
.star-panel::-webkit-scrollbar-track { background: none; }
.star-panel { scrollbar-width: thin; scrollbar-color: #c084fc47 transparent; }

.search-results::-webkit-scrollbar { width: 5px; }
.search-results::-webkit-scrollbar-thumb { background: #c084fc30; border-radius: 4px; }
.search-results::-webkit-scrollbar-track { background: none; }

/* ===== 响应式 ===== */
@media (max-width: 640px) {
  .hud-top { padding: calc(8px + env(safe-area-inset-top)) 12px 8px; gap: 8px; flex-wrap: wrap; }
  .title { font-size: 17px; letter-spacing: 0.1em; }
  .title-sub, .stat { display: none; }
  .btn-light { padding: 7px 14px; font-size: 12px; }

  .search-bar { left: 12px; right: 12px; width: auto; }

  .star-panel {
    max-height: 78vh;
    max-height: 78dvh;
    padding-bottom: calc(18px + env(safe-area-inset-bottom));
    border-radius: 16px 16px 0 0;
    animation: 0.28s cubic-bezier(0.2, 0.7, 0.2, 1) sheet-up;
    transform: none;
    width: auto !important;
    max-width: none !important;
    inset: auto 0 0 !important;
  }
  @keyframes sheet-up {
    from { transform: translateY(100%); }
  }

  .hint { display: none; }

  .modal-card { width: 94vw; padding: 22px 20px 18px; }
  .form-input, textarea.form-input { font-size: 16px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}
