:root {
  --accent: #9575e8;
  --accent-dark: #7b5ed4;
  --accent-deep: #5f46ad;
  --accent-soft: #c9baf5;
  --banner-bg: #e4dbf7;
  --banner-pattern: rgba(255, 255, 255, 0.42);
  --surface-tint: #f7f4fd;
  --surface-border: #e2daf2;
  --input-border: #d4c8ec;
  --text: #1f1833;
  --muted: #5c5470;
  --radius-lg: 22px;
  --radius-md: 16px;
  --radius-sm: 14px;
  --shadow-soft: 0 8px 24px rgba(110, 86, 180, 0.14);
  --sfx-cell-height: 72px;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-tap-highlight-color: transparent;
}

body {
  margin: 0;
  min-height: 100dvh;
  font-family: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  color: var(--text);
  background: #faf8ff;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}

/* 表单内仍允许选中、复制、粘贴 */
input,
textarea,
select {
  -webkit-user-select: text;
  user-select: text;
  -webkit-touch-callout: default;
}

.login-gate {
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px max(20px, env(safe-area-inset-right)) max(24px, env(safe-area-inset-bottom))
    max(20px, env(safe-area-inset-left));
  background: linear-gradient(165deg, #ede8fc 0%, #faf8ff 45%, #e4dbf7 100%);
}

.login-gate[hidden] {
  display: none !important;
}

.login-card {
  width: 100%;
  max-width: 360px;
  padding: 28px 22px 26px;
  border-radius: var(--radius-lg);
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid var(--surface-border);
  box-shadow: var(--shadow-soft);
  text-align: center;
}

.login-brand {
  margin: 0 0 8px;
  font-size: 1.5rem;
  font-weight: 800;
  color: var(--accent-dark);
}

.login-desc {
  margin: 0 0 18px;
  font-size: 0.82rem;
  color: var(--muted);
}

.login-field {
  display: block;
  margin-bottom: 14px;
}

.login-input {
  width: 100%;
  box-sizing: border-box;
  padding: 13px 14px;
  font: inherit;
  font-size: 1rem;
  border-radius: 12px;
  border: 1px solid var(--input-border);
  background: #fff;
}

.login-submit {
  width: 100%;
  margin-top: 4px;
  padding: 13px;
  border: none;
  border-radius: 14px;
  font: inherit;
  font-size: 1rem;
  font-weight: 800;
  color: #fff;
  cursor: pointer;
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-dark) 100%);
  box-shadow: 0 4px 14px rgba(123, 94, 212, 0.35);
}

.login-submit:active {
  transform: scale(0.99);
}

.login-error {
  margin: 12px 0 0;
  font-size: 0.82rem;
  color: #c0392b;
}

.main-app[hidden] {
  display: none !important;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.app {
  max-width: 420px;
  margin: 0 auto;
  padding: 16px 18px 32px;
  padding-bottom: max(32px, env(safe-area-inset-bottom));
}

.site-title {
  text-align: center;
  font-size: 1.65rem;
  font-weight: 800;
  color: var(--accent-dark);
  letter-spacing: 0.02em;
  margin: 8px 0 18px;
}

.hero {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 18px 20px;
  border-radius: var(--radius-lg);
  background-color: var(--banner-bg);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='28' height='28' viewBox='0 0 28 28'%3E%3Ctext x='4' y='20' font-size='14' fill='%23ffffff' opacity='0.5' font-family='sans-serif'%3E?%3C/text%3E%3C/svg%3E");
  background-size: 28px 28px;
  box-shadow: var(--shadow-soft);
  margin-bottom: 16px;
}

.hero-text {
  flex: 1;
  min-width: 0;
}

.hero-name {
  font-size: 1.75rem;
  font-weight: 900;
  color: #fff;
  text-shadow: 0 1px 0 rgba(0, 0, 0, 0.12), 0 0 1px rgba(60, 40, 100, 0.35);
  line-height: 1.15;
}

.hero-sub {
  margin-top: 6px;
  font-size: 0.95rem;
  font-weight: 700;
  color: #fff;
  text-shadow: 0 1px 0 rgba(0, 0, 0, 0.1), 0 0 1px rgba(60, 40, 100, 0.3);
}

.hero-photo-wrap {
  flex-shrink: 0;
  width: 108px;
  height: 108px;
  border-radius: 20px;
  overflow: hidden;
  background: linear-gradient(145deg, #f2edfc, #ddd3f5);
  border: 3px solid rgba(255, 255, 255, 0.9);
  box-shadow: 0 4px 12px rgba(95, 70, 150, 0.12);
  -webkit-user-drag: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}

.hero-photo {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  -webkit-user-drag: none;
  pointer-events: auto;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}

.sfx-heading,
.add-heading {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 1.05rem;
  font-weight: 800;
  color: var(--accent-dark);
  margin: 0 0 12px;
}

.note-icon {
  font-size: 1.1rem;
  opacity: 0.9;
}

.sfx-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  align-items: start;
}

.sfx-empty {
  grid-column: 1 / -1;
  margin: 0;
  padding: 20px 14px;
  text-align: center;
  font-size: 0.9rem;
  line-height: 1.55;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.65);
  border: 1px dashed var(--input-border);
  border-radius: var(--radius-md);
}

.sfx-btn-wrap {
  position: relative;
  width: 100%;
  max-width: 100%;
}

.sfx-btn {
  border: none;
  box-sizing: border-box;
  width: 100%;
  height: var(--sfx-cell-height);
  min-height: var(--sfx-cell-height);
  max-height: var(--sfx-cell-height);
  padding: 8px 10px;
  border-radius: 14px;
  font: inherit;
  font-size: 0.76rem;
  font-weight: 700;
  color: #fff;
  text-align: center;
  line-height: 1.25;
  cursor: pointer;
  background: linear-gradient(180deg, var(--accent-soft) 0%, var(--accent) 100%);
  box-shadow: 0 3px 0 var(--accent-deep), 0 4px 10px rgba(95, 70, 173, 0.18);
  transition: transform 0.08s ease, filter 0.12s ease, box-shadow 0.12s ease;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.sfx-btn-label {
  min-width: 0;
  width: 100%;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  overflow: hidden;
  word-break: break-word;
  overflow-wrap: anywhere;
  max-width: 100%;
  text-align: center;
  hyphens: auto;
}

.sfx-btn:active {
  transform: translateY(2px);
  box-shadow: 0 2px 0 var(--accent-deep), 0 3px 8px rgba(95, 70, 173, 0.18);
}

.sfx-edit-mode .sfx-btn:active {
  transform: none;
}

.sfx-btn.is-playing {
  filter: brightness(0.94);
  box-shadow: 0 2px 0 var(--accent-deep), inset 0 0 0 2px rgba(255, 255, 255, 0.35);
}

@keyframes sfx-wiggle {
  0% {
    transform: rotate(-2.2deg) translateZ(0);
  }
  100% {
    transform: rotate(2.2deg) translateZ(0);
  }
}

.sfx-edit-mode .sfx-btn-wrap {
  animation: sfx-wiggle 0.22s ease-in-out infinite alternate;
  touch-action: none;
}

.sfx-edit-mode .sfx-btn-wrap:nth-child(3n + 1) {
  animation-duration: 0.27s;
}

.sfx-edit-mode .sfx-btn-wrap:nth-child(3n + 2) {
  animation-delay: 0.05s;
}

.sfx-edit-mode .app {
  padding-bottom: 104px;
}

.sfx-edit-dock {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 200;
  display: flex;
  align-items: stretch;
  gap: 10px;
  padding: 10px 14px;
  padding-bottom: max(10px, env(safe-area-inset-bottom));
  background: rgba(255, 255, 255, 0.94);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  border-top: 1px solid var(--surface-border);
  box-shadow: 0 -6px 24px rgba(70, 50, 120, 0.12);
}

.sfx-edit-dock[hidden] {
  display: none !important;
}

.sfx-trash-drop {
  flex: 1;
  min-height: 56px;
  border: 2px dashed var(--input-border);
  border-radius: 16px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  background: rgba(255, 245, 248, 0.95);
  transition: border-color 0.15s ease, background 0.15s ease, transform 0.15s ease;
}

.sfx-trash-icon {
  font-size: 1.35rem;
  line-height: 1;
}

.sfx-trash-text {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--muted);
}

body.sfx-trash-hover .sfx-trash-drop {
  border-color: #e07a8a;
  background: rgba(255, 230, 235, 0.98);
  transform: scale(1.02);
}

.sfx-edit-done-btn {
  flex-shrink: 0;
  min-width: 76px;
  padding: 0 16px;
  border: none;
  border-radius: 14px;
  font: inherit;
  font-size: 0.95rem;
  font-weight: 800;
  color: #fff;
  cursor: pointer;
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-dark) 100%);
  box-shadow: 0 4px 12px rgba(123, 94, 212, 0.35);
}

.sfx-edit-done-btn:active {
  transform: scale(0.98);
}

.sortable-ghost {
  opacity: 0.45 !important;
}

.sortable-drag {
  opacity: 0.96;
}

.sfx-tips {
  margin: 14px 0 0;
  font-size: 0.72rem;
  color: var(--muted);
  line-height: 1.45;
  text-align: center;
}

.fab-add {
  position: fixed;
  right: max(18px, env(safe-area-inset-right));
  bottom: max(22px, env(safe-area-inset-bottom));
  z-index: 150;
  width: 56px;
  height: 56px;
  padding: 0;
  padding-bottom: 2px;
  border: none;
  border-radius: 50%;
  font-size: 2.1rem;
  font-weight: 300;
  line-height: 1;
  color: #fff;
  cursor: pointer;
  background: linear-gradient(145deg, var(--accent-soft) 0%, var(--accent) 55%, var(--accent-dark) 100%);
  box-shadow: 0 6px 22px rgba(123, 94, 212, 0.42);
  transition: transform 0.12s ease, box-shadow 0.12s ease;
}

.fab-add:active {
  transform: scale(0.94);
}

body.modal-open .fab-add,
body.sfx-edit-mode .fab-add {
  visibility: hidden;
  pointer-events: none;
}

.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 260;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: max(16px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right))
    max(16px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
  background: rgba(28, 22, 48, 0.48);
  -webkit-backdrop-filter: blur(4px);
  backdrop-filter: blur(4px);
}

.modal-overlay[hidden] {
  display: none !important;
}

.modal-sheet {
  width: 100%;
  max-width: 400px;
  max-height: min(88vh, 640px);
  overflow-x: hidden;
  overflow-y: auto;
  padding: 18px 18px 22px;
  border-radius: var(--radius-lg);
  background: var(--surface-tint);
  border: 1px solid var(--surface-border);
  box-shadow: var(--shadow-soft);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.modal-title {
  margin: 0;
  font-size: 1.15rem;
  font-weight: 800;
  color: var(--accent-dark);
}

.modal-close {
  flex-shrink: 0;
  width: 40px;
  height: 40px;
  margin: -6px -8px -6px 0;
  border: none;
  border-radius: 12px;
  font-size: 1.5rem;
  line-height: 1;
  color: var(--muted);
  background: transparent;
  cursor: pointer;
}

.modal-close:active {
  background: rgba(149, 117, 232, 0.12);
}

.add-hint {
  margin: 0 0 14px;
  font-size: 0.8rem;
  color: var(--muted);
  line-height: 1.5;
}

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

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.field-label {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--accent-dark);
}

.field input[type="text"],
.field input[type="url"],
.field input[type="file"] {
  font: inherit;
  font-size: 0.9rem;
  padding: 11px 12px;
  border-radius: 12px;
  border: 1px solid var(--input-border);
  background: #fff;
}

.field input[type="file"] {
  padding: 9px 10px;
}

.add-modal-status {
  margin: 0;
  padding: 12px 12px;
  border-radius: 12px;
  background: rgba(149, 117, 232, 0.1);
  border: 1px solid var(--surface-border);
}

.add-modal-status.is-error {
  background: rgba(192, 57, 43, 0.08);
  border-color: rgba(192, 57, 43, 0.35);
}

.add-modal-status-text {
  margin: 0 0 8px;
  font-size: 0.78rem;
  line-height: 1.5;
  color: var(--accent-dark);
  word-break: break-word;
  white-space: pre-wrap;
}

.add-modal-status.is-error .add-modal-status-text {
  color: #a12c20;
}

.add-modal-status-text:only-child {
  margin-bottom: 0;
}

.add-modal-progress-wrap {
  margin-top: 2px;
}

.add-modal-progress-wrap.is-indeterminate .add-modal-progress-track {
  animation: add-modal-progress-pulse 1.1s ease-in-out infinite;
}

.add-modal-progress-wrap.is-indeterminate .add-modal-progress-bar {
  width: 100% !important;
  opacity: 0.85;
  animation: add-modal-progress-shimmer 1.2s linear infinite;
}

.add-modal-progress-track {
  height: 8px;
  border-radius: 999px;
  background: rgba(149, 117, 232, 0.2);
  overflow: hidden;
}

.add-modal-progress-bar {
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--accent-soft), var(--accent) 60%, var(--accent-dark));
  transition: width 0.12s ease-out;
}

@keyframes add-modal-progress-pulse {
  0%,
  100% {
    opacity: 0.75;
  }
  50% {
    opacity: 1;
  }
}

@keyframes add-modal-progress-shimmer {
  0% {
    filter: brightness(1);
  }
  50% {
    filter: brightness(1.12);
  }
  100% {
    filter: brightness(1);
  }
}

.btn-primary {
  margin-top: 4px;
  border: none;
  border-radius: var(--radius-sm);
  padding: 14px;
  font: inherit;
  font-size: 1rem;
  font-weight: 800;
  color: #fff;
  cursor: pointer;
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-dark) 100%);
  box-shadow: 0 4px 14px rgba(123, 94, 212, 0.38);
}

.btn-primary:active {
  transform: scale(0.99);
}

.btn-primary:disabled {
  opacity: 0.65;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.footer {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 6px 10px;
  margin-top: 24px;
  font-size: 0.8rem;
  color: #9a94b0;
}

.footer-role {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--accent-dark);
}

.footer-logout {
  margin: 0;
  padding: 4px 8px;
  border: none;
  border-radius: 8px;
  font: inherit;
  font-size: 0.72rem;
  color: var(--muted);
  background: transparent;
  cursor: pointer;
  text-decoration: underline;
}

.footer-logout:active {
  color: var(--accent-dark);
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%) translateY(120%);
  max-width: min(360px, calc(100% - 32px));
  padding: 12px 18px;
  border-radius: 14px;
  background: rgba(42, 32, 72, 0.92);
  color: #fff;
  font-size: 0.88rem;
  text-align: center;
  line-height: 1.4;
  pointer-events: none;
  opacity: 0;
  transition: transform 0.25s ease, opacity 0.25s ease;
  z-index: 100;
}

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

@media (min-width: 480px) {
  .app {
    padding-top: 24px;
  }
}
