:root {
  --bg: #fbf3f2;
  --ink: #2f2a24;
  --muted: #6f675d;
  --glass: rgba(255, 250, 249, 0.80);
  --glass-border: rgba(98, 68, 76, 0.14);
  --accent: #a53459;
  --accent-ink: #ffffff;
  --shadow: 0 12px 36px rgba(54, 34, 42, 0.12);
}

body[data-theme="classic"] {
  --bg: #f6f1e7;
  --accent: #2f7a38;
}
body[data-theme="sakura"] {
  --bg: #fbf3f2;
  --accent: #a53459;
}
body[data-theme="autumn"] {
  --bg: #f7efe2;
  --accent: #9a3e1c;
}
body[data-theme="winter"] {
  --bg: #eef3f7;
  --accent: #1e4e62;
}

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

html,
body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--ink);
  font-family: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
  user-select: none;
  transition: background-color 0.35s ease;
}

.stage {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  touch-action: none;
}

/* Top HUD */
.hud-top {
  position: fixed;
  top: max(16px, env(safe-area-inset-top));
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  pointer-events: none;
  z-index: 10;
  width: min(92vw, 680px);
  text-align: center;
}

.brand-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 14px;
  border-radius: 999px;
  background: var(--glass);
  border: 1px solid var(--glass-border);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  box-shadow: 0 4px 16px rgba(47, 42, 36, 0.06);
}

.brand-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
}

.brand-title {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.14em;
  color: var(--ink);
}

.hud-hint {
  font-size: 13px;
  color: var(--muted);
  background: rgba(255, 252, 246, 0.66);
  padding: 5px 14px;
  border-radius: 999px;
  backdrop-filter: blur(8px);
}

.hud-hint strong {
  color: var(--ink);
  font-weight: 600;
}

/* Hover Tooltip Pill */
.hover-pill {
  position: fixed;
  left: 0;
  top: 0;
  padding: 6px 12px;
  border-radius: 999px;
  background: rgba(40, 35, 30, 0.88);
  color: #fffaf0;
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.02em;
  pointer-events: none;
  opacity: 0;
  transform: translate(-50%, -140%) scale(0.95);
  transition: opacity 0.16s ease, transform 0.16s ease;
  z-index: 20;
  white-space: nowrap;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.18);
}

.hover-pill.is-visible {
  opacity: 1;
  transform: translate(-50%, -145%) scale(1);
}

/* Bottom HUD */
.hud-bottom {
  position: fixed;
  bottom: max(16px, env(safe-area-inset-bottom));
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  z-index: 15;
  width: max-content;
  max-width: 95vw;
}

.scan-banner {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 8px 10px 8px 14px;
  border-radius: 16px;
  background: var(--glass);
  border: 1px solid var(--glass-border);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  box-shadow: var(--shadow);
  max-width: 94vw;
}

.scan-banner[hidden] {
  display: none;
}

.scan-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.scan-zone-tag {
  font-size: 11px;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 999px;
  background: rgba(47, 42, 36, 0.08);
  color: var(--ink);
}

.scan-site-title {
  font-size: 14px;
  font-weight: 700;
}

.scan-site-url {
  font-size: 12px;
  color: var(--muted);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}

.scan-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

/* Main Dock */
.dock {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 10px;
  border-radius: 999px;
  background: var(--glass);
  border: 1px solid var(--glass-border);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  box-shadow: var(--shadow);
  flex-wrap: wrap;
  justify-content: center;
}

.seg-group {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: rgba(47, 42, 36, 0.055);
  padding: 3px;
  border-radius: 999px;
}

.seg-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 13px;
  font-weight: 500;
  padding: 7px 12px;
  border-radius: 999px;
  cursor: pointer;
  transition: all 0.2s ease;
  white-space: nowrap;
}

.seg-btn:hover {
  color: var(--ink);
}

.seg-btn.is-active {
  background: #ffffff;
  color: var(--ink);
  font-weight: 600;
  box-shadow: 0 2px 8px rgba(47, 42, 36, 0.1);
}

.seg-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
}

.seg-top {
  background: #c84b73;
}

.seg-bottom {
  background: #7a2748;
}

.dock-divider {
  width: 1px;
  height: 20px;
  background: var(--glass-border);
}

.theme-dots {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 0 2px;
}

.theme-dot {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.9);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.18);
  cursor: pointer;
  transition: transform 0.18s ease;
}

.theme-dot[data-theme="classic"] { background: #3f9144; }
.theme-dot[data-theme="sakura"] { background: #f08cae; }
.theme-dot[data-theme="autumn"] { background: #b85324; }
.theme-dot[data-theme="winter"] { background: #275e75; }

.theme-dot:hover {
  transform: scale(1.14);
}

.theme-dot.is-active {
  transform: scale(1.2);
  outline: 2px solid var(--ink);
  outline-offset: 2px;
}

.tool-btns {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.icon-btn,
.btn-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--glass-border);
  background: rgba(255, 255, 255, 0.72);
  color: var(--ink);
  font-size: 12px;
  font-weight: 600;
  padding: 7px 12px;
  border-radius: 999px;
  cursor: pointer;
  text-decoration: none;
  transition: all 0.18s ease;
  white-space: nowrap;
}

.icon-btn:hover,
.btn-chip:hover {
  background: #ffffff;
  transform: translateY(-1px);
}

.btn-accent {
  background: var(--accent);
  color: var(--accent-ink);
  border-color: transparent;
}

.btn-accent:hover {
  background: var(--accent);
  opacity: 0.92;
  color: var(--accent-ink);
}

/* Modal */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(34, 29, 24, 0.35);
  backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 40;
}

.modal-backdrop[hidden] {
  display: none;
}

.modal-card {
  width: min(92vw, 420px);
  background: #fffcf6;
  border-radius: 20px;
  border: 1px solid var(--glass-border);
  box-shadow: 0 24px 60px rgba(34, 29, 24, 0.22);
  padding: 20px;
  user-select: text;
}

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}

.modal-head h2 {
  font-size: 16px;
  font-weight: 700;
}

.modal-close {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 0;
  background: rgba(47, 42, 36, 0.07);
  cursor: pointer;
  font-size: 13px;
}

.modal-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.field-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 12px;
  border-radius: 14px;
  background: rgba(47, 42, 36, 0.035);
}

.field-group label {
  font-size: 12px;
  color: var(--muted);
  font-weight: 600;
}

.field-group input {
  width: 100%;
  padding: 8px 10px;
  border-radius: 10px;
  border: 1px solid rgba(47, 42, 36, 0.16);
  background: #ffffff;
  font-size: 13px;
  color: var(--ink);
}

.swap-row {
  display: flex;
  justify-content: space-between;
  gap: 8px;
}

.modal-foot {
  display: flex;
  justify-content: flex-end;
  margin-top: 4px;
}

.toast {
  position: fixed;
  top: 76px;
  left: 50%;
  transform: translateX(-50%) translateY(-8px);
  background: rgba(40, 35, 30, 0.9);
  color: #fffaf0;
  padding: 8px 16px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 500;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
  z-index: 50;
}

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

/* Mobile adaptation */
@media (max-width: 720px) {
  .hud-hint {
    font-size: 12px;
    padding: 4px 10px;
  }

  .scan-banner {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
    padding: 10px 12px;
    width: 92vw;
  }

  .scan-site-url {
    display: none;
  }

  .dock {
    border-radius: 20px;
    padding: 8px 10px;
    gap: 8px;
    width: 94vw;
  }

  .dock-divider {
    display: none;
  }

  .seg-btn {
    padding: 6px 9px;
    font-size: 12px;
  }
}
