/* ============================================================
   DualStar · 通用组件
   ============================================================ */

/* —— 按钮 —— */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-2);
  padding: 12px 24px;
  border-radius: var(--r-full);
  font-size: 15px;
  font-weight: 500;
  letter-spacing: 0.3px;
  background: var(--bg-elevated);
  color: var(--text);
  box-shadow: var(--shadow-sm);
  transition: transform var(--dur-fast) var(--ease-out),
              background-color var(--dur-fast) var(--ease-out),
              box-shadow var(--dur-fast) var(--ease-out);
  min-height: 44px;
  white-space: nowrap;
}
.btn:hover {
  background: var(--surface-hover);
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}
.btn:active {
  transform: translateY(0);
  box-shadow: var(--shadow-sm);
}
.btn-primary {
  background: var(--accent);
  color: var(--text-inverse);
}
.btn-primary:hover {
  background: var(--accent-deep);
}
.btn-highlight {
  background: var(--highlight);
  color: var(--text-inverse);
}
.btn-highlight:hover {
  background: var(--highlight-deep);
}
.btn-ghost {
  background: transparent;
  box-shadow: none;
}
.btn-ghost:hover {
  background: var(--surface);
  box-shadow: none;
}
.btn-icon {
  width: 44px;
  height: 44px;
  padding: 0;
  border-radius: var(--r-full);
}
.btn-sm {
  padding: 8px 16px;
  font-size: 13px;
  min-height: 36px;
}
.btn-lg {
  padding: 16px 32px;
  font-size: 16px;
  min-height: 52px;
}
.btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  transform: none !important;
}

/* —— 卡片 —— */
.card {
  background: var(--bg-elevated);
  border-radius: var(--r-lg);
  padding: var(--sp-5);
  box-shadow: var(--shadow-md);
  border: 1px solid var(--border);
}
.card-soft {
  background: var(--bg-glass);
  border-radius: var(--r-lg);
  padding: var(--sp-5);
  border: 1px solid var(--border);
}

/* —— 输入框 —— */
.input {
  width: 100%;
  padding: 14px 18px;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  font-size: 15px;
  color: var(--text);
  transition: border-color var(--dur-fast) var(--ease-out),
              background-color var(--dur-fast) var(--ease-out);
}
.input:focus {
  border-color: var(--accent);
  background: var(--bg-elevated);
}
.input::placeholder {
  color: var(--text-tertiary);
}
textarea.input {
  resize: vertical;
  min-height: 80px;
  line-height: 1.5;
}

.field-group {
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
  margin-bottom: var(--sp-4);
}
.field-label {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  letter-spacing: 0.3px;
}
.field-row {
  display: flex;
  gap: var(--sp-3);
  margin-bottom: var(--sp-4);
}
.field-row .field-group {
  margin-bottom: 0;
}

/* —— Vision 开关 —— */
.vision-toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 0;
}
.vision-toggle-text {
  flex: 1;
  min-width: 0;
}
.vision-toggle-label {
  font-size: 14px;
  font-weight: 500;
  color: var(--text);
  letter-spacing: 0.3px;
}
.vision-toggle-hint {
  font-size: 12px;
  color: var(--text-tertiary);
  margin-top: 2px;
  line-height: 1.4;
}
.vision-switch {
  position: relative;
  display: inline-block;
  width: 44px;
  height: 24px;
  flex-shrink: 0;
}
.vision-switch input {
  opacity: 0;
  width: 0;
  height: 0;
}
.vision-switch-slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: #ccc;
  border-radius: 24px;
  transition: 0.3s;
}
.vision-switch-slider::before {
  position: absolute;
  content: "";
  height: 18px;
  width: 18px;
  left: 3px;
  bottom: 3px;
  background: white;
  border-radius: 50%;
  transition: 0.3s;
}
.vision-switch input:checked + .vision-switch-slider {
  background: var(--accent, #5a7363);
}
.vision-switch input:checked + .vision-switch-slider::before {
  transform: translateX(20px);
}

/* —— 头像 —— */
.avatar {
  width: 48px;
  height: 48px;
  border-radius: var(--r-full);
  background: var(--surface);
  object-fit: cover;
  flex-shrink: 0;
}
.avatar-lg {
  width: 72px;
  height: 72px;
}
.avatar-sm {
  width: 36px;
  height: 36px;
}

/* —— 徽章 —— */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: var(--r-full);
  font-size: 11px;
  font-weight: 500;
  background: var(--accent-soft);
  color: var(--accent-deep);
  letter-spacing: 0.3px;
}
.badge-danger {
  background: var(--danger);
  color: var(--text-inverse);
}

/* —— 浮岛（切换按钮） —— */
.float-island {
  position: fixed;
  right: 24px;
  bottom: 32px;
  width: 56px;
  height: 56px;
  border-radius: var(--r-full);
  background: var(--bg-glass);
  border: 1px solid var(--border-strong);
  box-shadow: var(--shadow-lg);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 100;
  opacity: 1;
  visibility: visible;
  transform: scale(1);
  transition: transform var(--dur-base) var(--ease-spring),
              box-shadow var(--dur-base) var(--ease-out),
              opacity var(--dur-base) var(--ease-out),
              visibility 0s linear 0s;
  color: var(--text);
}
.float-island.hidden {
  opacity: 0;
  visibility: hidden;
  transform: scale(0.8);
  transition: transform var(--dur-base) var(--ease-out),
              opacity var(--dur-base) var(--ease-out),
              visibility 0s linear var(--dur-base);
  pointer-events: none;
}
.float-island:hover {
  transform: translateY(-3px) scale(1.05);
  box-shadow: var(--shadow-xl);
}
.float-island:active {
  transform: scale(0.95);
}

/* —— 空状态 —— */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: var(--sp-12) var(--sp-6);
  text-align: center;
  color: var(--text-tertiary);
}
.empty-state-icon {
  width: 64px;
  height: 64px;
  margin-bottom: var(--sp-4);
  opacity: 0.5;
}

/* —— Toast —— */
.toast-container {
  position: fixed;
  top: 24px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
  pointer-events: none;
}
.toast {
  background: var(--bg-glass);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-full);
  padding: 10px 20px;
  font-size: 14px;
  color: var(--text);
  box-shadow: var(--shadow-lg);
  animation: toastIn var(--dur-base) var(--ease-spring);
  pointer-events: auto;
  max-width: 80vw;
}
.toast.toast-out {
  animation: toastOut var(--dur-base) var(--ease-in-out) forwards;
}
@keyframes toastIn {
  from { opacity: 0; transform: translateY(-12px) scale(0.9); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}
@keyframes toastOut {
  to { opacity: 0; transform: translateY(-12px) scale(0.9); }
}

/* —— 图标通用 —— */
.icon {
  flex-shrink: 0;
}

/* —— 模态层 —— */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  z-index: 500;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--dur-base) var(--ease-out);
}
.modal-backdrop.active {
  opacity: 1;
  pointer-events: auto;
}
.modal {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) scale(0.92);
  background: var(--bg-elevated);
  border-radius: var(--r-xl);
  padding: var(--sp-6);
  box-shadow: var(--shadow-xl);
  z-index: 501;
  opacity: 0;
  pointer-events: none;
  transition: transform var(--dur-base) var(--ease-spring),
              opacity var(--dur-base) var(--ease-out);
  max-width: 90vw;
  max-height: 85vh;
  overflow: auto;
}
.modal.active {
  transform: translate(-50%, -50%) scale(1);
  opacity: 1;
  pointer-events: auto;
}

/* —— 手机壳内弹窗约束 —— */
#phoneShell .toast-container,
#phoneShell .modal-backdrop,
.wechat-shell .toast-container,
.wechat-shell .modal-backdrop {
  position: absolute;
}
#phoneShell .modal,
.wechat-shell .modal {
  position: absolute;
}
.modal-input {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  font-family: inherit;
  outline: none;
  transition: border-color var(--dur-fast);
  box-sizing: border-box;
}
.modal-input:focus {
  border-color: var(--accent);
}
.modal-input::placeholder {
  color: var(--text-tertiary);
}

/* —— 头部导航栏 —— */
.navbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--sp-4) var(--sp-5);
  border-bottom: 1px solid var(--border);
  background: var(--bg-glass);
}
/* ============================================================
   v362: 通用图片裁剪器（openImageCropper）样式
   ============================================================ */
.cr-stage { position: relative; width: 280px; height: 280px; margin: 6px auto 0; border-radius: 14px; overflow: hidden; background: #111; }
.cr-mask { position: absolute; inset: 0; pointer-events: none; }
.cr-mask-circle::after { content: ""; position: absolute; left: 50%; top: 50%; width: 240px; height: 240px; transform: translate(-50%, -50%); border-radius: 50%; border: 2px solid #fff; box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.38); }
.cr-mask-square::after { content: ""; position: absolute; left: 50%; top: 50%; width: 250px; height: 250px; transform: translate(-50%, -50%); border: 2px solid #fff; box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.38); }
.cr-grid { position: absolute; left: 50%; top: 50%; width: 240px; height: 240px; transform: translate(-50%, -50%); border-radius: 50%; overflow: hidden; opacity: 0.35; }
.cr-mask-square .cr-grid { width: 250px; height: 250px; border-radius: 0; }
.cr-grid::before, .cr-grid::after { content: ""; position: absolute; background: rgba(255, 255, 255, 0.6); }
.cr-grid::before { left: 33.33%; top: 0; bottom: 0; width: 1px; }
.cr-grid::after { top: 33.33%; left: 0; right: 0; height: 1px; }
.cr-hint { text-align: center; font-size: 11px; color: var(--text-tertiary); margin-top: 8px; }
.cr-pos-row { display: flex; gap: 8px; justify-content: center; margin: 10px 16px 0; }
.cr-zoom-row { display: flex; align-items: center; gap: 8px; padding: 8px 20px 0; }
.cr-btn { font-size: 13px; color: #555; border: 1px solid #E0E0E0; border-radius: 999px; padding: 6px 12px; background: #fff; }
.cr-btn.on { border-color: var(--accent); color: var(--accent); font-weight: 700; }
.cr-btn-primary { background: linear-gradient(135deg, #FF6A88, #FF5000); border-color: transparent; color: #fff; font-weight: 700; }
[data-theme="dark"] .cr-btn { background: #2A2A2A; border-color: #3A3A3A; color: #DDD; }
[data-theme="dark"] .cr-btn-primary { background: linear-gradient(135deg, #E85555, #D64545); color: #fff; }
