:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --border: #e3e6ea;
  --border-strong: #cfd4da;
  --text: #1f2328;
  --text-muted: #6b7280;
  --accent: #3355d1;
  --accent-hover: #2a46ae;
  --accent-soft: #eef1fc;
  --danger-bg: #fdecec;
  --danger-text: #b42318;
  --radius: 10px;
  --radius-sm: 6px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .05), 0 1px 3px rgba(16, 24, 40, .06);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
               "Hiragino Sans GB", "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
  font-size: 14px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }
code {
  background: var(--accent-soft);
  color: var(--accent-hover);
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 12.5px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

/* ---------------- 顶栏 ---------------- */
.topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 20;
}
.topbar-inner {
  max-width: 1120px;
  margin: 0 auto;
  padding: 0 24px;
  height: 56px;
  display: flex;
  align-items: center;
  gap: 24px;
}
.brand { display: flex; align-items: center; gap: 10px; flex-shrink: 0; }
.brand-mark {
  width: 26px; height: 26px;
  border-radius: var(--radius-sm);
  background: var(--accent);
  color: #fff;
  font-weight: 700;
  font-size: 14px;
  display: grid;
  place-items: center;
}
.brand-text { font-weight: 600; font-size: 15px; letter-spacing: .2px; }

.topnav { display: flex; gap: 4px; flex: 1; overflow-x: auto; }
.topnav a {
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-size: 13.5px;
  white-space: nowrap;
  transition: background .12s, color .12s;
}
.topnav a:hover { background: var(--accent-soft); color: var(--accent-hover); }

.topbar-right { display: flex; align-items: center; gap: 10px; flex-shrink: 0; }
.user-name { color: var(--text-muted); font-size: 13px; }
.inline-form { display: inline; margin: 0; }

/* ---------------- 按钮 ---------------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 6px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  font-size: 13.5px;
  font-family: inherit;
  cursor: pointer;
  transition: background .12s, border-color .12s;
}
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); }
.btn-ghost { background: transparent; border-color: var(--border-strong); color: var(--text); }
.btn-ghost:hover { background: #f0f2f5; }
.btn-block { width: 100%; padding: 9px 14px; }

/* ---------------- 徽标 ---------------- */
.badge {
  display: inline-block;
  padding: 1px 8px;
  border-radius: 999px;
  font-size: 11.5px;
  line-height: 18px;
}
.badge-guest { background: #fff4e5; color: #9a5b00; }
.badge-open { background: var(--accent-soft); color: var(--accent-hover); }

/* ---------------- 页面容器 ---------------- */
.page { max-width: 1120px; margin: 0 auto; padding: 32px 24px 64px; }

.hero { margin-bottom: 28px; }
.hero h1 { margin: 0 0 6px; font-size: 22px; font-weight: 650; letter-spacing: -.2px; }
.hero-sub { margin: 0; color: var(--text-muted); font-size: 13.5px; }

/* ---------------- 工具网格 ---------------- */
.tool-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 14px;
}
.tool-card {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  display: flex;
  gap: 14px;
  align-items: flex-start;
  transition: border-color .14s, box-shadow .14s, transform .14s;
}
.tool-card:hover {
  border-color: var(--accent);
  box-shadow: var(--shadow);
  transform: translateY(-1px);
}
.tool-icon {
  width: 38px; height: 38px;
  flex-shrink: 0;
  display: grid;
  place-items: center;
  font-size: 19px;
  background: var(--accent-soft);
  border-radius: var(--radius-sm);
}
.tool-body { min-width: 0; }
.tool-name { margin: 2px 0 4px; font-size: 15px; font-weight: 600; }
.tool-desc { margin: 0; color: var(--text-muted); font-size: 13px; line-height: 1.55; }
.tool-card .badge-open { position: absolute; top: 14px; right: 14px; }

/* ---------------- 空态 ---------------- */
.empty {
  background: var(--surface);
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius);
  padding: 48px 24px;
  text-align: center;
}
.empty p { margin: 0 0 8px; }
.muted { color: var(--text-muted); font-size: 13px; }

/* ---------------- 登录页 ---------------- */
.auth-wrap { display: grid; place-items: center; min-height: 60vh; }
.auth-card {
  width: 100%;
  max-width: 360px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px 26px;
  box-shadow: var(--shadow);
}
.auth-title { margin: 0 0 20px; font-size: 17px; font-weight: 600; text-align: center; }
.auth-form { display: flex; flex-direction: column; gap: 14px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field-label { font-size: 12.5px; color: var(--text-muted); }
/* 输入类控件统一观感。textarea / select 必须和 input 一起写：
   工具被要求用 .field 组织表单，漏掉 textarea 会露出浏览器默认边框与
   拖拽角标，和整体风格格格不入。 */
.field input,
.field textarea,
.field select {
  padding: 9px 11px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-family: inherit;
  background: #fff;
  color: var(--text);
  outline: none;
  transition: border-color .12s, box-shadow .12s;
}
.field textarea { resize: vertical; min-height: 66px; line-height: 1.5; }
.field input:focus,
.field textarea:focus,
.field select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(51, 85, 209, .12);
}
.alert { padding: 9px 12px; border-radius: var(--radius-sm); font-size: 13px; margin-bottom: 16px; }
.alert-error { background: var(--danger-bg); color: var(--danger-text); }

/* ---------------- 工具内页 ---------------- */
.back {
  display: inline-block;
  margin-bottom: 14px;
  color: var(--text-muted);
  font-size: 13px;
}
.back:hover { color: var(--accent); }

.page-head { margin-bottom: 22px; }
.page-head h1 { margin: 0 0 4px; font-size: 20px; font-weight: 650; letter-spacing: -.2px; }
.page-head p { margin: 0; color: var(--text-muted); font-size: 13.5px; }

.section-title {
  margin: 30px 0 12px;
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
}

.stack-form {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  max-width: 560px;
}
.stack-form .btn { align-self: flex-start; }

.list {
  list-style: none;
  margin: 0;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  overflow: hidden;
}
.list-item {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 16px;
  padding: 11px 16px;
  border-bottom: 1px solid var(--border);
}
.list-item:last-child { border-bottom: none; }
.list-main { font-size: 13.5px; word-break: break-word; }
.list-meta { color: var(--text-muted); font-size: 12px; white-space: nowrap; }

.alert-ok { background: #e9f7ef; color: #11663a; }

/* ---------------- 页脚 ---------------- */
.footer {
  max-width: 1120px;
  margin: 0 auto;
  padding: 20px 24px 32px;
  color: var(--text-muted);
  font-size: 12.5px;
}

/* ================================================================
   以下为 v1.2.1 新增：装饰层与通用部件
   ================================================================ */

/* ---------------- 梅花飘落特效 ---------------- */
/* 纯装饰层：铺满视口但不吃任何指针事件，和内容互不干扰。
   z-index 0 + 内容层 z-index 1，保证花瓣永远在文字下面。 */
#petal-layer {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  display: block;
}
.page, .footer { position: relative; z-index: 1; }

.fx-wrap { position: relative; }
.fx-btn {
  width: 32px; height: 32px;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 15px;
  line-height: 1;
  display: grid;
  place-items: center;
  padding: 0;
  transition: border-color .12s, background .12s;
}
.fx-btn:hover { background: var(--accent-soft); border-color: var(--accent); }
.fx-btn[aria-expanded="true"] { background: var(--accent-soft); border-color: var(--accent); }

.fx-pop {
  position: absolute;
  right: 0;
  top: 40px;
  width: 236px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 8px 24px rgba(16, 24, 40, .12);
  padding: 12px 14px;
  z-index: 30;
}
.fx-pop.is-off .fx-group { opacity: .45; pointer-events: none; }
.fx-row { display: flex; align-items: center; justify-content: space-between; }
.fx-label { font-size: 12.5px; color: var(--text-muted); }
.fx-group { display: flex; align-items: center; justify-content: space-between; margin-top: 11px; }

.fx-switch {
  width: 38px; height: 21px;
  border-radius: 999px;
  border: 1px solid var(--border-strong);
  background: var(--border);
  position: relative;
  cursor: pointer;
  padding: 0;
  transition: background .15s, border-color .15s;
}
.fx-switch span {
  position: absolute;
  top: 2px; left: 2px;
  width: 15px; height: 15px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 2px rgba(16, 24, 40, .25);
  transition: transform .15s;
}
.fx-switch[aria-checked="true"] { background: var(--accent); border-color: var(--accent); }
.fx-switch[aria-checked="true"] span { transform: translateX(17px); }

.fx-seg {
  display: flex;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  overflow: hidden;
}
.fx-seg button {
  border: none;
  background: var(--surface);
  color: var(--text-muted);
  font-size: 12px;
  padding: 4px 9px;
  cursor: pointer;
  font-family: inherit;
  border-left: 1px solid var(--border);
}
.fx-seg button:first-child { border-left: none; }
.fx-seg button.on { background: var(--accent); color: #fff; }

/* ---------------- 分段控件 ---------------- */
.segmented {
  display: inline-flex;
  padding: 3px;
  gap: 2px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  margin-bottom: 18px;
}
.segmented button {
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-size: 13.5px;
  font-family: inherit;
  padding: 6px 16px;
  border-radius: 5px;
  cursor: pointer;
  transition: background .12s, color .12s;
}
.segmented button:hover { color: var(--text); }
.segmented button.on {
  background: var(--surface);
  color: var(--accent-hover);
  font-weight: 600;
  box-shadow: var(--shadow);
}

/* ---------------- 卡片 ---------------- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow);
}
.card + .card { margin-top: 12px; }

/* ---------------- 二维码登录 ---------------- */
.qr-stage {
  display: grid;
  place-items: center;
  min-height: 214px;
  background: var(--bg);
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius);
  margin: 12px 0;
  padding: 14px;
}
.qr-stage img {
  width: 188px; height: 188px;
  border-radius: var(--radius-sm);
  background: #fff;
  padding: 8px;
  box-shadow: var(--shadow);
}
.qr-spinner {
  width: 30px; height: 30px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: fxspin .8s linear infinite;
}
@keyframes fxspin { to { transform: rotate(360deg); } }

/* ---------------- 状态点 ---------------- */
.dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; margin-right: 6px; }
.dot-ok { background: #16a34a; }
.dot-off { background: #9ca3af; }
.dot-warn { background: #d97706; }

@media (prefers-reduced-motion: reduce) {
  .qr-spinner { animation: none; }
}

/* ---------------- 移动端 ---------------- */
@media (max-width: 720px) {
  .topbar-inner { height: auto; flex-wrap: wrap; padding: 10px 16px; gap: 10px; }
  .topnav { order: 3; width: 100%; flex: 1 1 100%; }
  .topbar-right { margin-left: auto; }
  .page { padding: 20px 16px 48px; }
  .tool-grid { grid-template-columns: 1fr; }
  .hero h1 { font-size: 19px; }
}
