/* =========================================================
   十二神大圣堂 · 粉白婚礼风界面
   主题（data-theme）：chapel 晨光粉白 / rose 玫瑰园 / lily 百合白 / dusk 黄昏礼拜
   背景（data-bg）：halo 柔光 / petal 花瓣 / plain 素净
   ========================================================= */

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

/* ---------- 默认主题：晨光粉白（四改：微粉白底 + 低饱和玫瑰灰主色） ---------- */
:root {
  --bg: #fdf8f9;
  --card: #ffffff;
  --card-2: #fdf7f9;
  --ink: #3a3438;
  --ink-soft: #665c63;
  --ink-faint: #756a72;
  --accent: #a35c73;
  --accent-deep: #88445a;
  --accent-ink: #7f3f57;
  --accent-soft: #f7e9ee;
  --accent-line: #e3bcc8;
  --line: #efe4e8;
  --field-line: #9f8794;   /* 表单控件描边：对填充 ≥3:1，控件边界看得清 */
  --gold: #a97f47;
  --deco-1: #ffe9ef;
  --deco-2: #fbe7f0;
  --petal: rgba(203, 154, 176, 0.26);
  --shadow: 0 8px 24px rgba(150, 110, 125, 0.08);
}

html[data-theme="rose"] {
  --bg: #fbeef2;
  --card: #fffbfc;
  --card-2: #fdf6f9;
  --ink: #3a2f35;
  --ink-soft: #685961;
  --ink-faint: #766570;
  --accent: #a4566f;
  --accent-deep: #873d57;
  --accent-ink: #7e3951;
  --accent-soft: #f6e4ea;
  --accent-line: #e1b3c2;
  --line: #f0dde4;
  --field-line: #9f8794;
  --gold: #a5763f;
  --deco-1: #ffddea;
  --deco-2: #f8d7e6;
  --petal: rgba(198, 128, 158, 0.22);
  --shadow: 0 8px 24px rgba(150, 100, 125, 0.08);
}

html[data-theme="lily"] {
  --bg: #fbfafb;
  --card: #ffffff;
  --card-2: #f9f7f9;
  --ink: #353036;
  --ink-soft: #625a64;
  --ink-faint: #6f6674;
  --accent: #96637a;
  --accent-deep: #7a4257;
  --accent-ink: #734053;
  --accent-soft: #f2e7ed;
  --accent-line: #cdb2bf;
  --line: #eae5eb;
  --field-line: #9a8791;
  --gold: #96703d;
  --deco-1: #f4eef2;
  --deco-2: #eef0f6;
  --petal: rgba(140, 124, 138, 0.16);
  --shadow: 0 8px 24px rgba(120, 108, 122, 0.07);
}

html[data-theme="dusk"] {
  --bg: #faf4ee;
  --card: #fffdfb;
  --card-2: #fdf8f3;
  --ink: #3d342e;
  --ink-soft: #6a5b53;
  --ink-faint: #786860;
  --accent: #9d6055;
  --accent-deep: #834740;
  --accent-ink: #7c4740;
  --accent-soft: #f7e8e0;
  --accent-line: #e0bfb3;
  --line: #efe3da;
  --field-line: #9d8981;
  --gold: #9c7038;
  --deco-1: #ffe9dc;
  --deco-2: #f9e6ea;
  --petal: rgba(190, 145, 125, 0.20);
  --shadow: 0 8px 24px rgba(150, 118, 100, 0.08);
}

html {
  background: var(--bg);
}

body {
  font-family: "Microsoft YaHei", "Segoe UI", system-ui, -apple-system, sans-serif;
  font-size: 16px;
  line-height: 1.75;
  color: var(--ink);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

/* ---------- 背景层（可选：柔光 / 花瓣 / 素净） ---------- */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
}

html[data-bg="halo"] body::before {
  background:
    radial-gradient(1100px 640px at 50% -10%, var(--deco-1) 0%, transparent 62%),
    radial-gradient(820px 560px at 100% 108%, var(--deco-2) 0%, transparent 58%);
}

html[data-bg="petal"] body::before {
  background-image:
    radial-gradient(circle at 14px 18px, var(--petal) 0 2.5px, transparent 3px),
    radial-gradient(circle at 66px 78px, var(--petal) 0 1.8px, transparent 2.4px),
    radial-gradient(900px 520px at 50% -12%, var(--deco-1) 0%, transparent 65%);
  background-size: 104px 104px, 148px 148px, 100% 100%;
}

html[data-bg="plain"] body::before {
  background: none;
}

/* ---------- 版心 ---------- */
.app {
  max-width: 720px;
  margin: 0 auto;
  padding: 22px 16px 32px;
}

header {
  text-align: center;
  padding: 20px 0 18px;
}

h1 {
  font-family: "Noto Serif SC", "Source Han Serif SC", "Songti SC", "STSong", "SimSun", serif;
  font-size: 32px;
  font-weight: 700;
  line-height: 1.35;
  letter-spacing: 0.18em;
  text-indent: 0.18em;
  color: var(--accent-ink);
}

.ornament {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin: 10px 0 8px;
}

.ornament span {
  display: block;
  width: 58px;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--accent-line));
}

.ornament span:last-child {
  background: linear-gradient(90deg, var(--accent-line), transparent);
}

.ornament i {
  display: block;
  width: 7px;
  height: 7px;
  background: var(--accent-line);
  transform: rotate(45deg);
}

.sub {
  color: var(--ink-faint);
  font-size: 13.5px;
  letter-spacing: 0.02em;
}

/* ---------- 会场风格选择条 ---------- */
.style-bar {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 16px; /* 与卡片圆角统一（四改：圆角/间距收敛） */
  padding: 12px 14px;
  margin-bottom: 18px;
  box-shadow: 0 6px 18px rgba(150, 110, 125, 0.07);
  display: grid;
  gap: 8px;
}

.style-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.style-label {
  min-width: 66px;
  font-size: 13px;
  color: var(--ink-soft);
  letter-spacing: 0.04em;
}

.style-opts {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.style-note {
  font-size: 12px;
  color: var(--ink-faint);
  margin-left: auto;
}

button.opt {
  margin: 0;
  padding: 6px 13px;
  font-size: 13.5px;
  font-weight: 500;
  border-radius: 999px;
  background: var(--card-2);
  color: var(--ink-soft);
  border: 1px solid var(--line);
  box-shadow: none;
  transition: background 0.18s, border-color 0.18s, color 0.18s;
}

button.opt:hover {
  border-color: var(--accent-line);
  color: var(--accent-ink);
  filter: none;
}

button.opt[aria-pressed="true"] {
  background: var(--accent-soft);
  border-color: var(--accent-line);
  color: var(--accent-ink);
  font-weight: 600;
}

/* ---------- 卡片 ---------- */
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 20px 18px;
  margin: 0 0 18px;
  box-shadow: var(--shadow);
}

h2 {
  position: relative;
  padding-left: 12px;
  font-size: 18px;
  font-weight: 700;
  line-height: 1.5;
  letter-spacing: 0.03em;
  color: var(--ink);
  margin-bottom: 12px;
}

h2::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0.32em;
  width: 3px;
  height: 1.05em;
  border-radius: 2px;
  background: linear-gradient(180deg, var(--accent-line), var(--accent-soft));
}

.tip,
.muted {
  color: var(--ink-faint);
  font-size: 13.5px;
  line-height: 1.8;
}

.tip {
  margin: 4px 0 10px;
}

.tip b {
  color: var(--ink-soft);
}

/* ---------- 表单 ---------- */
input[type=text],
input[type=password],
select,
textarea {
  width: 100%;
  padding: 12px 13px;
  border: 1px solid var(--field-line); /* 四改：表单描边提到 ≥3:1，控件边界看得清但仍细 */
  border-radius: 10px;
  background: var(--card-2);
  color: var(--ink);
  margin: 8px 0;
  font-family: inherit;
  font-size: 15px;
  line-height: 1.6;
  transition: border-color 0.18s, box-shadow 0.18s;
}

input[type=text]::placeholder,
textarea::placeholder {
  color: var(--ink-faint);
  opacity: 0.85;
}

input[type=text]:focus,
input[type=password]:focus,
select:focus,
textarea:focus {
  border-color: var(--accent-line);
  box-shadow: 0 0 0 3px var(--accent-soft);
  outline: none;
}

textarea {
  resize: vertical;
  min-height: 108px;
}

select {
  cursor: pointer;
}

select option {
  background: var(--card);
  color: var(--ink);
}

button {
  font-family: inherit;
  font-size: 15px;
  font-weight: 600;
  line-height: 1.4;
  padding: 11px 20px;
  border: 0;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--accent), var(--accent-deep));
  color: #fff;
  cursor: pointer;
  margin: 10px 8px 0 0;
  box-shadow: 0 4px 12px rgba(136, 68, 90, 0.14); /* 四改：阴影调淡，主色降饱和 */
  transition: filter 0.18s, transform 0.12s;
}

button:hover {
  filter: brightness(1.04);
}

button:active {
  transform: translateY(1px);
}

button.danger {
  background: linear-gradient(135deg, #a8564e, #8a3f38);
  box-shadow: 0 4px 12px rgba(138, 63, 56, 0.14);
}

button:focus-visible,
.opt:focus-visible,
a:focus-visible {
  outline: 2px solid var(--accent-deep);
  outline-offset: 2px;
}

/* ---------- 标签胶囊 ---------- */
.tags {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 8px 0 2px;
}

.tag {
  display: inline-block;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 7px 14px;
  font-size: 13.5px;
  line-height: 1.5;
  color: var(--ink-soft);
  background: var(--card-2);
  cursor: pointer;
  user-select: none;
  transition: background 0.18s, border-color 0.18s, color 0.18s;
}

.tag:hover {
  border-color: var(--accent-line);
  color: var(--accent-ink);
}

/* 四改需求 3：TAG 选中态必须「看得见」——
   .tag.on 负责整颗胶囊的高亮填充；input 复选框本身从 display:none 改为可见，
   :checked 时主色填充 + 白色勾；键盘 Tab 走 :focus-visible 焦点环。 */
.tag.on {
  background: var(--accent-soft);
  border-color: var(--accent-line);
  color: var(--accent-ink);
  font-weight: 600;
  box-shadow: inset 0 0 0 1px var(--accent-line);
}

.tags .tag {
  margin-bottom: 0;   /* 抵消 .field-group label 的下边距，胶囊行距统一 */
  font-size: 13.5px;
  line-height: 1.5;
}

.tag input[type="checkbox"] {
  appearance: none;
  -webkit-appearance: none;
  display: inline-block;
  vertical-align: -2px;
  width: 15px;
  height: 15px;
  margin: 0 6px 0 0;
  padding: 0;
  border: 1.5px solid var(--field-line); /* 未选中也要看得见（≥3:1），选中改主色填充 */
  border-radius: 4px;
  background: var(--card);
  cursor: pointer;
  transition: background-color 0.15s, border-color 0.15s;
}

.tag input[type="checkbox"]:hover {
  border-color: var(--accent);
}

.tag input[type="checkbox"]:checked {
  background-color: var(--accent-deep);
  border-color: var(--accent-deep);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12'%3E%3Cpath d='M2.4 6.3l2.4 2.4 4.8-5.2' fill='none' stroke='%23ffffff' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-size: 12px 12px;
  background-position: center;
  background-repeat: no-repeat;
}

.tag input[type="checkbox"]:focus {
  outline: none;
}

.tag input[type="checkbox"]:focus-visible {
  outline: 2px solid var(--accent-deep);
  outline-offset: 2px;
}

.field-group {
  margin: 18px 0;
}

.field-group label {
  display: block;
  font-size: 14px;
  line-height: 1.65;
  color: var(--ink-soft);
  margin-bottom: 6px;
}

.field-group label.muted {
  font-size: 13px;
  color: var(--ink-faint);
  margin: 8px 0 0;
}

/* ---------- 信息行（行距与对比度重点优化） ---------- */
#status-box p {
  font-size: 15px;
  line-height: 1.9;
  margin: 0 0 6px;
  color: var(--ink);
  word-break: break-word;
}

#status-box p:last-child {
  margin-bottom: 0;
}

#status-box strong {
  color: var(--accent-ink);
}

.row {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  border-top: 1px solid var(--line);
  padding: 15px 0;
  font-size: 15px;
  line-height: 1.85;
}

.row > div {
  flex: 1 1 auto;
  min-width: 0;
  word-break: break-word;
}

.row > button {
  flex: 0 0 auto;
  margin: 2px 0 0;
}

.row:first-child {
  border-top: 0;
  padding-top: 2px;
}

.code {
  display: inline-block;
  font-weight: 600;
  font-size: 15px;
  line-height: 1.6;
  letter-spacing: 0.04em;
  color: var(--accent-ink);
}

/* ---------- 候选卡 ---------- */
.candidate {
  padding: 15px 0;
  line-height: 1.85;
}

.candidate:first-child {
  padding-top: 4px;
}

.candidate p {
  margin: 0 0 6px;
  font-size: 15px;
}

.candidate p.code {
  margin-bottom: 8px;
}

.candidate .muted {
  font-size: 14px;
  color: var(--ink-soft);
}

.candidate .warn {
  margin-bottom: 8px;
}

.candidate button {
  margin-top: 4px;
}

.warn {
  color: #9a541b;
  font-size: 14px;
  line-height: 1.8;
  margin: 6px 0;
}

.ok {
  color: #2c7442;
  font-size: 14px;
  line-height: 1.8;
  margin-top: 10px;
}

.err {
  color: #a8332a;
  font-size: 14px;
  line-height: 1.8;
}

.hidden {
  display: none !important;
}

/* ---------- 折叠区 ---------- */
details {
  margin-top: 14px;
}

details summary {
  cursor: pointer;
  color: var(--accent-ink);
  font-size: 15px;
  font-weight: 600;
  line-height: 1.8;
  padding: 6px 0;
  list-style-position: inside;
}

details summary:hover {
  text-decoration: underline;
  text-underline-offset: 3px;
}

details[open] summary {
  margin-bottom: 6px;
}

/* ---------- 公告条 ---------- */
.ann {
  border-color: var(--accent-line);
  background: var(--card-2);
}

#ann-title {
  color: var(--accent-ink);
  font-size: 16px;
  margin-bottom: 8px;
}

.ann-body {
  color: var(--ink);
  font-size: 15px;
  line-height: 1.85;
  white-space: pre-line; /* body 换行还原（内容已由 JS 用 textContent 写入，无注入风险） */
}

/* ---------- 翻页控件 ---------- */
.pager {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  margin-top: 14px;
}

.pager button.pg {
  padding: 7px 12px;
  font-size: 13.5px;
  margin: 0;
  background: var(--card-2);
  color: var(--ink-soft);
  border: 1px solid var(--line);
  box-shadow: none;
}

.pager button.pg:hover {
  border-color: var(--accent-line);
  color: var(--accent-ink);
}

.pager button.pg.pg-cur {
  background: var(--accent-deep);
  border-color: var(--accent-deep);
  color: #fff;
}

.pager button.pg[disabled] {
  opacity: 0.45;
  cursor: not-allowed;
}

.pg-info {
  margin-left: 6px;
  font-size: 13px;
  color: var(--ink-faint);
}

.candidate + hr,
hr {
  border: 0;
  border-top: 1px solid var(--line);
  margin: 12px 0;
}

/* ---------- 页脚 ---------- */
.foot {
  text-align: center;
  padding: 8px 2px 22px;
  font-size: 12.5px;
}

.foot-note {
  color: var(--ink-faint);
  letter-spacing: 0.02em;
  line-height: 1.9;
}

.foot a {
  color: var(--ink-faint);
  text-decoration: none;
}

.foot a:hover {
  color: var(--accent-ink);
}

/* ---------- 管理控制台 ---------- */
.admin-grid {
  display: grid;
  gap: 10px;
}

table.adm {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
  line-height: 1.7;
}

table.adm th,
table.adm td {
  border-bottom: 1px solid var(--line);
  padding: 9px 6px;
  text-align: left;
  vertical-align: top;
  word-break: break-all;
}

table.adm th {
  color: var(--ink-soft);
  font-weight: 600;
}

.chk {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  line-height: 1.7;
  color: var(--ink-soft);
  cursor: pointer;
}

.chk input {
  width: auto;
  margin: 0;
}

/* 公告正文字数计数器（四改需求 2：与后端 1000 字上限实时同步，超限变红） */
.ann-count {
  margin-top: -2px;
  font-size: 13px;
  letter-spacing: 0.02em;
}

/* 额外标签库里的删除按钮（嵌在标签胶囊内） */
.tag-del {
  background: transparent;
  color: var(--ink-soft);
  padding: 0 0 0 6px;
  margin: 0;
  font-size: 14px;
  line-height: 1;
  border-radius: 0;
  box-shadow: none;
}

/* ---------- 两栏布局（UI 二改）：宽屏两栏 / <1024px 回落单列 ---------- */
.layout {
  display: grid;
  gap: 18px; /* 与卡片上下间距一致 */
}

.col {
  min-width: 0;
}

/* 使用人数统计行（GET /api/stats），只是一行文案 */
.stats-line {
  margin-top: 10px;
  padding: 9px 12px;
  background: var(--card-2);
  border: 1px solid var(--line);
  border-radius: 10px;
  color: var(--ink-soft);
}

@media (min-width: 1024px) {
  .app {
    max-width: 1080px; /* 两栏需要更宽的版心 */
  }

  .layout {
    grid-template-columns: 52fr 48fr;
    align-items: start; /* 让右栏 sticky 生效 */
  }

  .col-right {
    position: sticky;
    top: 12px;
  }
}

/* ---------- 窄屏 ---------- */
@media (max-width: 560px) {
  .app {
    padding: 14px 12px 26px;
  }

  h1 {
    font-size: 26px;
    letter-spacing: 0.12em;
    text-indent: 0.12em;
  }

  .card {
    padding: 17px 14px;
    border-radius: 14px;
  }

  .style-bar {
    border-radius: 14px;
  }

  .style-label {
    min-width: auto;
  }

  .style-note {
    margin-left: 0;
  }

  .row {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
  }

  .row > button {
    align-self: flex-start;
    margin-top: 0;
  }

  .row > .row > button {
    margin-top: 0;
  }
}
