:root {
  --bg: #f4f7fc;
  --bg2: #ffffff;
  --bg3: #eef3fb;
  --line: #e3eaf5;
  --text: #1a2b4a;
  --muted: #7a8ba8;
  --accent: #3478f6;
  --accent-soft: rgba(52, 120, 246, 0.1);
  --danger: #e5484d;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  font-size: 15px;
  min-height: 100%;
}
button, input, textarea { font: inherit; color: inherit; }
button { border: 0; background: none; cursor: pointer; }
[hidden] { display: none !important; }

.page {
  min-height: 100vh;
  padding-bottom: calc(32px + var(--safe-bottom));
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: calc(8px + var(--safe-top)) 12px 10px;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
}
.title {
  margin: 0;
  font-size: 17px;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--text);
}
.btn-icon {
  width: 40px;
  height: 36px;
  color: var(--text);
  display: flex;
  align-items: center;
  justify-content: center;
}
.btn-publish {
  min-width: 68px;
  height: 32px;
  padding: 0 16px;
  border-radius: 16px;
  background: var(--accent);
  color: #fff;
  font-size: 14px;
  font-weight: 600;
  transition: opacity .15s;
}
.btn-publish:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.main { padding: 12px 14px 24px; }

.contest-banner {
  margin: 0 0 12px;
  padding: 12px 14px;
  border-radius: 12px;
  background: linear-gradient(135deg, #fff1f5, #fff7ed);
  border: 1px solid #fbcfe8;
  color: #9d174d;
}
.contest-banner .contest-kicker {
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .08em;
  color: #db2777;
  margin-bottom: 4px;
}
.contest-banner strong { display: block; font-size: 15px; color: #831843; margin-bottom: 4px; }
.contest-banner p { margin: 0; font-size: 12px; line-height: 1.5; color: #9d174d; }
.contest-banner em { font-style: normal; font-weight: 700; }
.contest-banner.closed { opacity: .78; }

.guide {
  margin: 0 0 12px;
  padding: 10px 12px;
  border-radius: 10px;
  background: var(--accent-soft);
  color: #2f6fe0;
  font-size: 12px;
  line-height: 1.45;
}
.guide.ok {
  background: rgba(52, 199, 89, 0.12);
  color: #1f9d4d;
}

.card {
  margin-bottom: 12px;
  padding: 14px;
  border-radius: 14px;
  background: var(--bg2);
  border: 1px solid var(--line);
  box-shadow: 0 2px 8px rgba(40, 80, 160, 0.04);
}
.section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 6px;
}
.label { font-size: 15px; font-weight: 600; color: var(--text); }
.label em { color: var(--danger); font-style: normal; margin-left: 3px; }
.label em.soft { color: #f08c3a; }
.hint { font-size: 12px; color: var(--muted); }
.section-desc {
  margin: 0 0 12px;
  font-size: 12px;
  color: var(--muted);
  line-height: 1.4;
}

.image-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}
.image-item, .image-add {
  position: relative;
  aspect-ratio: 1;
  border-radius: 10px;
  overflow: hidden;
  background: var(--bg3);
}
.image-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.image-item .remove {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: rgba(26, 43, 74, 0.65);
  color: #fff;
  font-size: 14px;
  line-height: 22px;
  text-align: center;
}
.image-item .badge-up {
  position: absolute;
  left: 4px;
  bottom: 4px;
  padding: 2px 6px;
  border-radius: 8px;
  background: rgba(52, 120, 246, 0.9);
  color: #fff;
  font-size: 10px;
}
.image-add {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  color: var(--muted);
  border: 1px dashed #b8c9e6;
  font-size: 12px;
  background: #f8fbff;
}
.image-add .plus { font-size: 26px; line-height: 1; color: var(--accent); }

.picker-row {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  border-radius: 12px;
  background: var(--bg3);
  text-align: left;
}
.picker-icon {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: #fff;
  border: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--accent);
  font-weight: 700;
  flex-shrink: 0;
}
.picker-icon.hash { font-size: 18px; }
.picker-body {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.picker-text {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--muted);
  font-size: 14px;
}
.picker-text.has-value { color: var(--text); font-weight: 500; }
.picker-sub {
  font-size: 11px;
  color: #9aa9c2;
}
.picker-arrow { color: #a8b6ce; font-size: 22px; line-height: 1; }

.field-block { margin-top: 12px; }
.field-block:first-of-type { margin-top: 10px; }
.field-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 6px;
}
.field-name { font-size: 13px; color: #4a5d7a; }
.char-count { font-size: 11px; color: #9aa9c2; }
.field {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  outline: none;
}
.field:focus {
  border-color: rgba(52, 120, 246, 0.55);
  box-shadow: 0 0 0 3px rgba(52, 120, 246, 0.12);
}
.field::placeholder { color: #a8b6ce; }
.field.area {
  resize: vertical;
  min-height: 120px;
  line-height: 1.55;
}

.topic-selected {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 10px;
}
.topic-selected:empty { display: none; }
.topic-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border-radius: 8px;
  background: var(--accent-soft);
  color: #2f6fe0;
  font-size: 13px;
}
.topic-chip .x {
  color: #2f6fe0;
  font-size: 14px;
  opacity: 0.85;
}
.topic-chip .plays {
  color: var(--muted);
  font-size: 11px;
}

.sheet {
  position: fixed;
  inset: 0;
  z-index: 50;
}
.sheet-mask {
  position: absolute;
  inset: 0;
  z-index: 1;
  background: rgba(26, 43, 74, 0.35);
}
.sheet-panel {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 2;
  max-height: 78vh;
  display: flex;
  flex-direction: column;
  background: #fff;
  border-radius: 16px 16px 0 0;
  padding-bottom: var(--safe-bottom);
  animation: slideUp .22s ease;
  color: var(--text);
  /* 避免点按钮时事件落到下层遮罩 */
  touch-action: manipulation;
}
.sheet-handle {
  width: 36px;
  height: 4px;
  margin: 10px auto 0;
  border-radius: 2px;
  background: #d5deee;
}
@keyframes slideUp {
  from { transform: translateY(24px); opacity: .6; }
  to { transform: translateY(0); opacity: 1; }
}
.sheet-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px 8px;
  font-weight: 600;
  color: var(--text);
}
.btn-text { color: var(--accent); font-size: 14px; padding: 6px; font-weight: 500; }
.search-box { padding: 8px 16px 12px; }
.search-box input {
  width: 100%;
  height: 40px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--bg3);
  outline: none;
  color: var(--text);
}
.search-box input:focus {
  border-color: rgba(52, 120, 246, 0.55);
  background: #fff;
}
.topic-create {
  display: flex;
  align-items: center;
  gap: 8px;
}
.topic-create .hash {
  color: var(--accent);
  font-weight: 700;
  font-size: 18px;
}
.topic-create input { flex: 1; }
.btn-add-topic {
  height: 36px;
  padding: 0 12px;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  font-size: 13px;
  white-space: nowrap;
}
.sheet-list {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 0 8px 16px;
}
.list-item {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 12px 10px;
  border-radius: 10px;
  text-align: left;
  color: var(--text);
}
.list-item:active, .list-item.active { background: var(--bg3); }
.list-item .cover {
  width: 48px;
  height: 48px;
  border-radius: 8px;
  object-fit: cover;
  background: var(--bg3);
  flex-shrink: 0;
}
.list-item .meta { flex: 1; min-width: 0; }
.list-item .name {
  font-size: 15px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.list-item .sub {
  margin-top: 4px;
  font-size: 12px;
  color: var(--muted);
}
.list-item .check {
  color: var(--accent);
  font-size: 18px;
  width: 24px;
  text-align: center;
}
.empty {
  padding: 40px 16px;
  text-align: center;
  color: var(--muted);
  font-size: 13px;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(80px + var(--safe-bottom));
  transform: translateX(-50%);
  z-index: 80;
  max-width: 80%;
  padding: 10px 16px;
  border-radius: 8px;
  background: rgba(26, 43, 74, 0.9);
  color: #fff;
  font-size: 13px;
  text-align: center;
}
.loading {
  position: fixed;
  inset: 0;
  z-index: 90;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  background: rgba(244, 247, 252, 0.72);
  color: var(--text);
}
.spinner {
  width: 36px;
  height: 36px;
  border: 3px solid rgba(52, 120, 246, 0.2);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
