/* ============================================================
   灵光岛 · 界面样式（v3 重新设计）
   移动端优先：所有尺寸先按 375px 宽度设计，桌面端仅居中限宽
   设计语言：海青色调 · 晨光质感 · 克制干净
   ============================================================ */

/* ---------- 设计变量 ---------- */
:root {
  --bg: #f4f5f7;
  --card: #ffffff;
  --card-soft: #f7f8fa;
  --text: #1a1d21;
  --text-2: #5f6673;
  --text-3: #8f96a3;
  --line: #e7e9ee;
  --primary: #2563eb;
  --primary-deep: #1e40af;
  --primary-ink: #ffffff;
  --primary-soft: #eef3ff;
  --grad-primary: linear-gradient(180deg, #3b82f6 0%, #2563eb 100%);
  --warn-bg: #fff7e6;
  --warn-line: #ffe0a3;
  --warn-ink: #8a5a00;
  --pend: #b45309;
  --ok: #15803d;
  --ok-soft: #e6f6ec;
  --danger: #dc2626;
  --danger-soft: #fdecec;
  --radius: 16px;
  --radius-sm: 12px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .04), 0 1px 3px rgba(16, 24, 40, .06);
  --shadow-btn: 0 6px 16px rgba(37, 99, 235, .25);
  --maxw: 640px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0e1013;
    --card: #171a1f;
    --card-soft: #1d2127;
    --text: #e9ebee;
    --text-2: #a3aab7;
    --text-3: #767e8c;
    --line: #272b33;
    --primary: #5b8def;
    --primary-deep: #9db8f6;
    --primary-ink: #0b1220;
    --primary-soft: #1b2637;
    --grad-primary: linear-gradient(180deg, #6ea1f2 0%, #5b8def 100%);
    --warn-bg: #2a2213;
    --warn-line: #4a3c1c;
    --warn-ink: #e0b95f;
    --pend: #fbbf24;
    --ok: #4ade80;
    --ok-soft: #16281c;
    --danger: #f87171;
    --danger-soft: #2c1618;
    --shadow: none;
    --shadow-btn: 0 6px 18px rgba(0, 0, 0, .35);
  }
}

/* ---------- 基础重置 ---------- */
*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
               "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  font-size: 16px;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

h1, h2, h3, p, ul, ol { margin: 0; }
ul, ol { padding: 0; list-style: none; }
a { color: inherit; text-decoration: none; }
button, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; padding: 0; }
:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; border-radius: 8px; }

/* hidden 属性必须真正生效（作者样式的 display 会覆盖浏览器默认） */
[hidden] { display: none !important; }

.icon { width: 20px; height: 20px; flex: none; display: block; }

/* ---------- 布局容器 ---------- */
.app {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 0 16px calc(48px + env(safe-area-inset-bottom));
}

/* ---------- 顶部品牌 ---------- */
.topbar {
  display: flex;
  align-items: center;
  gap: 8px;
  height: 56px;
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  font-size: 18px;
  font-weight: 800;
  letter-spacing: .5px;
}
.brand-mark {
  width: 28px;
  height: 28px;
  border-radius: 9px;
  background: var(--primary-soft);
  box-shadow: 0 3px 8px rgba(37, 99, 235, .28);
  display: block;
  object-fit: cover;
}

/* ---------- 吸顶搜索栏 ---------- */
.searchbar-wrap {
  position: sticky;
  top: 0;
  z-index: 20;
  margin: 0 -16px;
  padding: 8px 16px 12px;
  background: var(--bg);
  transition: box-shadow .2s, border-color .2s;
  border-bottom: 1px solid transparent;
}
.searchbar-wrap.is-stuck {
  border-bottom-color: var(--line);
  box-shadow: 0 4px 14px rgba(18, 46, 41, .07);
}

.searchbar {
  display: flex;
  align-items: center;
  gap: 8px;
  height: 50px;
  padding: 0 12px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 999px;
  box-shadow: var(--shadow);
  transition: border-color .15s, box-shadow .15s;
}
.searchbar:focus-within {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-soft);
}
.searchbar .icon { color: var(--text-3); width: 19px; height: 19px; }
.searchbar input {
  flex: 1;
  min-width: 0;
  border: 0;
  background: none;
  outline: none;
  font-size: 16px; /* 必须 ≥16px，否则 iOS 聚焦时会自动放大页面 */
}
.searchbar input::placeholder { color: var(--text-3); }
.searchbar input::-webkit-search-cancel-button { display: none; }
.searchbar-clear {
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--card-soft);
  color: var(--text-3);
  font-size: 15px;
}
.searchbar-clear[hidden] { display: none; }

/* ---------- 卡片 ---------- */
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

/* ---------- 欢迎语（签名元素：海面晨光） ---------- */
.welcome {
  position: relative;
  overflow: hidden;
  padding: 22px 18px 20px;
  margin-bottom: 16px;
  border-radius: 20px;
  background:
    radial-gradient(130% 100% at 100% 0%, rgba(37, 99, 235, .10) 0%, rgba(37, 99, 235, 0) 52%),
    linear-gradient(165deg, #e8f0fe 0%, #f5f8fe 55%, var(--card) 100%);
}
@media (prefers-color-scheme: dark) {
  .welcome {
    background:
      radial-gradient(130% 100% at 100% 0%, rgba(91, 141, 239, .12) 0%, rgba(91, 141, 239, 0) 52%),
      linear-gradient(165deg, #1b2637 0%, #1d2127 55%, var(--card) 100%);
  }
}
.welcome-art {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 112px;
  height: auto;
  pointer-events: none;
}
.welcome-title {
  font-size: 20px;
  font-weight: 800;
  letter-spacing: .2px;
  line-height: 1.5;
  margin-bottom: 8px;
  padding-right: 96px;
}
.welcome-text {
  font-size: 14.5px;
  color: var(--text-2);
  padding-right: 40px;
}
.welcome-hint {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  margin-top: 12px;
  padding: 11px 13px;
  background: var(--primary-soft);
  border-radius: var(--radius-sm);
  color: var(--primary-deep);
  font-size: 13.5px;
  line-height: 1.6;
}
.welcome-hint .icon {
  width: 17px;
  height: 17px;
  margin-top: 2px;
  flex: none;
}

/* ---------- 区块标题 ---------- */
.section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin: 0 2px 10px;
}
.section-head h2 {
  font-size: 15px;
  font-weight: 800;
  letter-spacing: .3px;
}
.section-head .count {
  font-size: 13px;
  color: var(--text-3);
}

/* ---------- 资源列表 ---------- */
.list { display: flex; flex-direction: column; gap: 12px; }

.res { padding: 14px 14px 15px; }

.res-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 9px;
}
.res-tags {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}
.res-clicks {
  font-size: 12.5px;
  color: var(--text-3);
  white-space: nowrap;
}

/* ---------- 推荐标记 ---------- */
.badge-featured {
  display: inline-flex;
  align-items: center;
  height: 18px;
  padding: 0 7px;
  border-radius: 999px;
  background: linear-gradient(135deg, var(--primary), var(--primary-deep));
  color: #fff;
  font-size: 11.5px;
  font-weight: 600;
  line-height: 1;
  white-space: nowrap;
  flex-shrink: 0;
}
.res-name {
  font-size: 16.5px;
  font-weight: 650;
  line-height: 1.45;
  word-break: break-word;
  margin-bottom: 9px;
}
.res-name a { display: block; }

.chip {
  display: inline-flex;
  align-items: center;
  height: 24px;
  padding: 0 10px;
  border-radius: 8px;
  background: var(--primary-soft);
  color: var(--primary-deep);
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}
.chip.is-none {
  background: var(--card-soft);
  color: var(--text-3);
  font-weight: 500;
}

/* 链接行（点按复制） */
.res-url {
  display: flex;
  align-items: center;
  gap: 7px;
  width: 100%;
  min-height: 38px;
  padding: 0 10px;
  border-radius: var(--radius-sm);
  background: var(--card-soft);
  border: 1px solid var(--line);
  color: var(--text-2);
  font-size: 12.5px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  text-align: left;
}
.res-url .icon { width: 14px; height: 14px; color: var(--text-3); flex: none; }
.res-url-text {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.res-copy {
  flex: none;
  font-size: 12px;
  font-weight: 600;
  color: var(--primary-deep);
  font-family: inherit;
}
@media (prefers-color-scheme: dark) {
  .res-copy { color: var(--primary); }
}

/* 打开按钮（全宽，拇指友好） */
.btn-open { margin-top: 10px; }

/* ---------- 按钮 ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 44px;          /* iOS 最小触摸尺寸 */
  padding: 0 18px;
  border-radius: var(--radius-sm);
  font-size: 15px;
  font-weight: 700;
  border: 1px solid transparent;
  transition: opacity .15s, transform .06s, box-shadow .15s;
}
.btn:active { transform: scale(.985); }
.btn:disabled { opacity: .55; }

.btn-primary {
  background: var(--grad-primary);
  color: var(--primary-ink);
  box-shadow: var(--shadow-btn);
}
.btn-outline { background: var(--card); border-color: var(--line); color: var(--text); }
.btn-ghost { background: var(--card-soft); border-color: var(--line); color: var(--text-2); }
.btn-block { width: 100%; margin-top: 12px; }
.btn-sm { min-height: 44px; padding: 0 16px; font-size: 14px; flex: none; }

/* ---------- 空状态 ---------- */
.empty {
  padding: 32px 20px;
  text-align: center;
  color: var(--text-3);
  font-size: 14.5px;
  line-height: 1.7;
}
.empty strong { display: block; color: var(--text-2); font-size: 15px; margin-bottom: 4px; }

/* ---------- 留言栏 ---------- */
.guestbook { margin-top: 26px; padding: 16px; }

.guestbook-intro {
  font-size: 14px;
  color: var(--text-2);
  margin-bottom: 12px;
}

/* 蜜罐字段：对真人不可见。用移出视口而非 display:none，
   因为部分机器人会主动跳过隐藏元素 */
.hp {
  position: absolute !important;
  left: -9999px !important;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.msg-form { margin-top: 4px; }
.msg-form input,
.msg-form textarea {
  display: block;
  width: 100%;
  padding: 11px 12px;
  background: var(--card-soft);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  outline: none;
  font-size: 16px; /* 防 iOS 缩放 */
  line-height: 1.6;
  resize: none;
  transition: border-color .15s, background .15s;
}
.msg-form input:focus,
.msg-form textarea:focus { border-color: var(--primary); background: var(--card); }
.msg-form input::placeholder,
.msg-form textarea::placeholder { color: var(--text-3); }
.msg-form input { margin-bottom: 8px; }
.msg-form textarea { min-height: 84px; }

.msg-form-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 10px;
}
.msg-counter { font-size: 12.5px; color: var(--text-3); }

.msg-list { margin-top: 16px; border-top: 1px solid var(--line); }
.msg {
  display: flex;
  gap: 10px;
  padding: 13px 0;
  border-bottom: 1px solid var(--line);
}
.msg:last-child { border-bottom: 0; padding-bottom: 0; }
.msg-ava {
  flex: none;
  width: 30px;
  height: 30px;
  margin-top: 1px;
  border-radius: 50%;
  background: var(--primary-soft);
  color: var(--primary-deep);
  display: grid;
  place-items: center;
  font-size: 13px;
  font-weight: 700;
}
.msg-main { flex: 1; min-width: 0; }
.msg-head {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin-bottom: 3px;
}
.msg-nick { font-size: 13.5px; font-weight: 600; color: var(--primary-deep); }
.msg-time { font-size: 12px; color: var(--text-3); margin-left: auto; }
.msg-body {
  font-size: 14.5px;
  color: var(--text-2);
  white-space: pre-wrap;
  word-break: break-word;
}
.msg-list-empty {
  padding: 20px 0 4px;
  text-align: center;
  color: var(--text-3);
  font-size: 14px;
}

/* ---------- 站长回复 ---------- */
.msg-reply {
  margin-top: 8px;
  padding: 8px 10px;
  background: rgba(37, 99, 235, .06);
  border-left: 3px solid var(--primary);
  border-radius: 6px;
}
.msg-reply-label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--primary-deep);
  margin-bottom: 2px;
}
.msg-reply-body {
  font-size: 14px;
  color: var(--text-2);
  white-space: pre-wrap;
  word-break: break-word;
  margin: 0;
}

/* ---------- 已处理标记 ---------- */
.msg-badge {
  display: inline-flex;
  align-items: center;
  height: 18px;
  padding: 0 7px;
  border-radius: 6px;
  background: var(--ok-soft);
  color: var(--ok);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .2px;
  white-space: nowrap;
}

/* ---------- 返回 ---------- */
.backlink {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  min-height: 44px;
  margin-left: -4px;
  padding: 0 4px;
  color: var(--text-2);
  font-size: 14.5px;
}

/* ---------- 详情页 ---------- */
.detail-head { padding: 2px 0 16px; }
.detail-meta { margin-top: 10px; }
.detail-title {
  font-size: 22px;
  font-weight: 800;
  line-height: 1.45;
  word-break: break-word;
}

.linkbox { padding: 18px; margin-top: 4px; border-radius: 20px; }
.linkbox-label {
  font-size: 13px;
  color: var(--text-3);
  margin-bottom: 8px;
  font-weight: 600;
}
.linkbox-value {
  display: flex;
  align-items: flex-start;
  width: 100%;
  text-align: left;
  gap: 8px;
  padding: 11px 12px;
  background: var(--card-soft);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  color: var(--text-2);
  word-break: break-all;
  line-height: 1.6;
}
.linkbox-value .icon { width: 15px; height: 15px; margin-top: 2px; color: var(--text-3); }

.linkbox-remark {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 10px;
  font-size: 13.5px;
  color: var(--text-2);
}
.linkbox-remark b {
  padding: 2px 8px;
  border-radius: 6px;
  background: var(--warn-bg);
  color: var(--warn-ink);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  letter-spacing: .5px;
}

.linkbox .btn-block { margin-top: 14px; }
.linkbox-clicks {
  margin-top: 10px;
  text-align: center;
  font-size: 13px;
  color: var(--text-3);
}

/* ---------- 相关资源 ---------- */
.related { margin-top: 26px; }
.related-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.related-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 44px;
  padding: 10px 14px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  font-size: 14.5px;
  transition: border-color .15s;
}
.related-item:active { border-color: var(--primary); }
.related-item span:first-child {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.related-item .icon { width: 16px; height: 16px; color: var(--text-3); }

/* ---------- 页脚 ---------- */
.footer {
  margin-top: 32px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
  font-size: 12.5px;
  line-height: 1.9;
  color: var(--text-3);
}
.footer a { color: var(--text-2); text-decoration: underline; text-underline-offset: 2px; }
.footer-links { display: flex; flex-wrap: wrap; gap: 4px 14px; margin-bottom: 8px; }

/* ---------- 轻提示 ---------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(28px + env(safe-area-inset-bottom));
  z-index: 100;
  max-width: 80vw;
  padding: 11px 18px;
  border-radius: 999px;
  background: rgba(12, 24, 21, .94);
  color: #fff;
  font-size: 14px;
  text-align: center;
  transform: translate(-50%, 12px);
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s, transform .2s;
}
.toast.is-on { opacity: 1; transform: translate(-50%, 0); }

/* ---------- 分类筛选条 ---------- */
.filterbar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px 10px;
  padding-top: 9px;
}
.filterbar-hint {
  font-size: 12px;
  color: var(--text-3);
}

/* 整块筛选条都是「清除筛选」按钮，比只点一个小叉好按得多 */
.filter-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 40px;
  padding: 0 10px 0 13px;
  border-radius: 999px;
  background: var(--primary-soft);
  color: var(--primary-deep);
  font-size: 13.5px;
  font-weight: 700;
  border: 1px solid transparent;
  transition: border-color .15s;
}
.filter-chip:active { border-color: var(--primary); }
.filter-chip-label { font-weight: 400; opacity: .7; }
.filter-chip-x {
  width: 22px;
  height: 22px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: rgba(37, 99, 235, .14);
  font-size: 15px;
  line-height: 1;
}

/* ---------- 管理端 ---------- */
.brand-sub {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-3);
  margin-left: 2px;
}
.topbar { justify-content: space-between; }
.topbar-link {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 0 2px;
  font-size: 14px;
  color: var(--primary-deep);
}
@media (prefers-color-scheme: dark) {
  .topbar-link { color: var(--primary); }
}

.admin-note {
  padding: 10px 12px;
  margin-bottom: 14px;
  border-radius: var(--radius-sm);
  background: var(--warn-bg);
  border: 1px solid var(--warn-line);
  color: var(--warn-ink);
  font-size: 13px;
  line-height: 1.6;
}

.stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-bottom: 14px;
}
.stat {
  padding: 14px 6px 12px;
  border-radius: var(--radius);
  background: var(--card);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  text-align: center;
}
.stat-num {
  display: block;
  font-size: 22px;
  font-weight: 800;
  line-height: 1.3;
  font-variant-numeric: tabular-nums;
}
.stat-label {
  display: block;
  font-size: 12px;
  color: var(--text-3);
  margin-top: 3px;
}
.stat.is-pending .stat-num { color: var(--pend); }
.stat.is-done .stat-num { color: var(--ok); }

.tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 12px;
  padding: 4px;
  border-radius: 999px;
  background: var(--card-soft);
  border: 1px solid var(--line);
}
.tab {
  flex: 1;
  min-height: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  border-radius: 999px;
  font-size: 14px;
  font-weight: 700;
  color: var(--text-2);
  white-space: nowrap;
}
.tab.is-active {
  background: var(--card);
  color: var(--primary-deep);
  box-shadow: var(--shadow);
}
@media (prefers-color-scheme: dark) {
  .tab.is-active { color: var(--primary); }
}
.tab-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 9px;
  background: var(--pend);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
}
@media (prefers-color-scheme: dark) {
  .tab-badge { color: #241a02; }
}

.admin-hint {
  margin-bottom: 12px;
  font-size: 13px;
  line-height: 1.75;
  color: var(--text-3);
}
.admin-hint b { color: var(--ok); }

.admin-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 18px;
}

.admin-msg {
  padding: 14px;
  border-left: 3px solid transparent;
  border-radius: var(--radius);
}
.admin-msg.is-done { border-left-color: var(--ok); }

.admin-msg-head {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 6px;
}
.admin-msg-body {
  font-size: 14.5px;
  line-height: 1.7;
  color: var(--text-2);
  white-space: pre-wrap;
  word-break: break-word;
}
.admin-msg-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: 12px;
}
.admin-msg-src {
  flex: 1;
  min-width: 0;
  font-size: 12.5px;
  color: var(--text-3);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.admin-msg-src a { color: var(--primary-deep); }
@media (prefers-color-scheme: dark) {
  .admin-msg-src a { color: var(--primary); }
}

.status-pill {
  display: inline-flex;
  align-items: center;
  height: 18px;
  padding: 0 7px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
}
.status-pill.is-pending { background: var(--warn-bg); color: var(--pend); }
.status-pill.is-done { background: var(--ok-soft); color: var(--ok); }

.btn-ok { background: var(--ok); color: #fff; }
@media (prefers-color-scheme: dark) {
  .btn-ok { color: #08150d; }
}

/* ---------- 页面进入动画 ---------- */
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}
.res, .related-item, .msg { animation: fadeUp .22s ease both; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
