/* Lacuneo refine — 明暗双主题，靠微明度分层 */

:root,
[data-theme="light"]{
  --bg:#f5f5f3;
  --surface:#fcfcfb;
  --raised:#f0f0ee;
  --sunken:#eeedeb;
  --overlay:#fcfcfb;
  --text:#1e1e1b;
  --muted:#65655e;
  --quiet:#8b8b83;
  --line:rgba(22,22,18,.08);
  --hair:rgba(22,22,18,.06);
  --accent:#963f58;
  --accent-strong:#7d3248;
  --accent-soft:rgba(150,63,88,.10);
  --danger:#c0392b;
  --control:#e3e3df;
  --sent:#f4dfe6;
  --sent-line:#d7aebc;
  --fw-regular:400;
  --fw-medium:500;
  --fw-bold:600;
  --shadow-card:0 1px 2px rgba(20,20,16,.05),0 2px 8px rgba(20,20,16,.04);
  --shadow-pop:0 1px 2px rgba(20,20,16,.08),0 12px 32px rgba(20,20,16,.12);
  --ease-out:cubic-bezier(.215,.61,.355,1);
  --ease-pop:cubic-bezier(.34,1.56,.64,1);
  --ease-snap:cubic-bezier(.5,0,.75,.36);
  --ring:0 0 0 1px var(--accent),0 0 0 4px var(--accent-soft),0 6px 18px rgba(20,20,16,.10);
  --field-shadow:inset 0 0 0 1px rgba(22,22,18,.05);
  color-scheme:light;
}

[data-theme="dark"]{
  --bg:#0b0b0a;
  --surface:#151515;
  --raised:#1a1a19;
  --sunken:#10100f;
  --overlay:#20201e;
  --text:#e9e9e3;
  --muted:#a2a29a;
  --quiet:#7d7d75;
  --line:rgba(255,255,255,.08);
  --hair:rgba(255,255,255,.06);
  --accent:#de819c;
  --accent-strong:#ec9fb5;
  --accent-soft:rgba(222,129,156,.16);
  --danger:#f0867a;
  --control:#262624;
  --sent:#3a2730;
  --sent-line:#5a3a46;
  --fw-regular:360;
  --fw-medium:460;
  --fw-bold:560;
  --shadow-card:0 1px 2px rgba(0,0,0,.5);
  --shadow-pop:0 1px 0 rgba(255,255,255,.05),0 16px 44px rgba(0,0,0,.6);
  --ring:0 0 0 1px var(--accent),0 0 0 4px var(--accent-soft),0 8px 24px rgba(0,0,0,.6);
  --field-shadow:inset 0 0 0 1px rgba(255,255,255,.05);
  color-scheme:dark;
}

/* ---- 基础 ---- */
body{
  background:var(--bg);
  color:var(--text);
  font-weight:var(--fw-regular);
  -webkit-font-smoothing:antialiased;
  -moz-osx-font-smoothing:grayscale;
  text-rendering:optimizeLegibility;
}

h1,h2,h3{font-weight:var(--fw-medium)}
p,li,h2,h3{text-wrap:pretty}
h1{text-wrap:balance}
b,strong{font-weight:var(--fw-bold)}

::selection{background:var(--accent-soft);color:var(--text)}

/* 数字锁等宽 */
.meta,.stats,.eyebrow,.stats dd,.stat,.membership-price,.story-index,
.order-amount,.pagination,time,.count,.stat-value,.metric-num,
.post-count,.follow-count{font-variant-numeric:tabular-nums}

/* 行内图标对齐 */
p svg,li svg,.meta svg,.inline-icon,a svg.inline{vertical-align:-.125em}

/* ---- 顶栏 / 底栏：去硬框，靠明度 ---- */
.site-header{
  position:sticky;
  top:0;
  z-index:50;
  border-bottom:0;
  background:color-mix(in srgb,var(--bg) 86%,var(--surface));
  backdrop-filter:saturate(160%) blur(14px);
  -webkit-backdrop-filter:saturate(160%) blur(14px);
}
.site-footer{border-top:0;background:color-mix(in srgb,var(--bg) 80%,var(--surface))}
.mobile-nav{border-top:0;background:color-mix(in srgb,var(--bg) 92%,var(--surface))}

/* 列表分隔：极淡 hairline，不再是灰框 */
.story,.response,.block,.lab-entry,.collection-row,.topic-index a,
.membership-plan,.form-panel,.order-facts,.payment-instructions,
.operational-records>form,.operational-records article,.operational-records details,
.service-content article,td,th{border-color:var(--hair)}

/* ---- 卡片 / 弹层：去框 + 阴影/明度 ---- */
.dialog,dialog{
  border:0;
  background:var(--surface);
  box-shadow:var(--shadow-pop);
}

/* ---- 更多菜单：圆角浮层 + 淡入 + 条目反馈 ---- */
.site-menu nav{
  border:0;
  background:var(--overlay);
  box-shadow:var(--shadow-pop);
  border-radius:16px;
  padding:8px;
  width:min(224px, calc(100vw - 24px));
  box-sizing:border-box;
  margin-top:6px;
  font-size:14px;
  text-align:left;
  -webkit-backface-visibility:hidden;
  backface-visibility:hidden;
  animation:menu-in .18s ease-out;
}
.site-menu nav a{
  display:flex;
  align-items:center;
  justify-content:flex-start;
  gap:10px;
  position:relative;
  width:100%;
  box-sizing:border-box;
  min-height:44px;
  padding:10px 14px;
  border-radius:10px;
  font-size:14px;
  font-weight:var(--fw-medium);
  text-align:left;
  white-space:nowrap;
  transition:background .15s ease,color .15s ease;
}
.site-menu nav a:hover{background:var(--raised)}
.site-menu nav a:active{background:var(--accent-soft)}
.site-menu nav a[aria-current]{
  background:var(--accent-soft);
  color:var(--accent-strong);
}
.site-menu nav a.menu-external{color:var(--muted)}
.site-menu nav a.menu-external::before,
.site-menu nav a.menu-logout::before{
  content:'';
  position:absolute;
  top:-5px;left:14px;right:14px;
  height:1px;
  background:var(--hair);
}
.site-menu nav a.menu-external{margin-top:7px}
.site-menu nav a.menu-logout{
  margin-top:7px;
  color:var(--danger);
}
.site-menu nav a.menu-logout:hover{
  background:color-mix(in srgb,var(--danger) 10%,transparent);
}
@keyframes menu-in{
  from{opacity:0;transform:translateY(-4px)}
  to{opacity:1;transform:translateY(0)}
}

/* 移动端：固定定位的抽屉，尺寸与位置完全确定，不依赖继承 */
@media(max-width:639px){
  .site-menu[open]::before{
    content:'';
    position:fixed;
    inset:0;
    z-index:39;
    background:rgba(18,16,15,.32);
  }
  .site-menu nav{
    position:fixed;
    top:calc(env(safe-area-inset-top,0px) + 60px);
    right:12px;
    left:auto;
    z-index:41;
    width:min(280px, calc(100vw - 24px));
    max-width:calc(100vw - 24px);
    max-height:calc(100dvh - 84px);
    overflow-y:auto;
    -webkit-overflow-scrolling:touch;
  }
  .site-menu summary{position:relative;z-index:42}
}
.notice{
  border-left:0;
  background:var(--surface);
  box-shadow:var(--shadow-card);
  border-radius:10px;
  padding:16px 20px;
  position:relative;
  overflow:hidden;
}
.notice::before{
  content:"";position:absolute;left:0;top:0;bottom:0;width:3px;
  background:var(--accent);
}
.notice.danger::before{background:var(--danger)}
.badge{
  border:0;
  background:var(--accent-soft);
  color:var(--accent-strong);
  border-radius:999px;
  padding:3px 10px;
}

/* ---- 输入框：凹陷 + 聚焦双环 ---- */
input:not([type=checkbox]):not([type=radio]):not([type=hidden]),
textarea,select{
  border-color:transparent;
  background:var(--sunken);
  box-shadow:var(--field-shadow);
  border-radius:10px;
  transition:box-shadow .2s var(--ease-out),background .2s var(--ease-out);
}
input::placeholder,textarea::placeholder{color:var(--quiet)}
input:not([type=checkbox]):not([type=radio]):not([type=hidden]):focus,
textarea:focus,select:focus{
  outline:none;
  background:var(--surface);
  box-shadow:var(--ring);
}
.password-wrap{
  border:0;
  background:var(--sunken);
  box-shadow:var(--field-shadow);
  border-radius:10px;
  transition:box-shadow .2s var(--ease-out);
}
.password-wrap:focus-within{background:var(--surface);box-shadow:var(--ring)}
.password-wrap input{box-shadow:none;background:none!important}

/* 可访问性：键盘焦点仍可见，但不使用粗 outline */
a:focus-visible,button:focus-visible,summary:focus-visible{
  outline:2px solid var(--accent);
  outline-offset:2px;
  border-radius:6px;
}
input:focus-visible,textarea:focus-visible,select:focus-visible{outline:none}

/* ---- 按钮 ---- */
.button,
button:not(.icon-button):not(.password-toggle):not(.theme-toggle){
  border-color:transparent;
  background:var(--surface);
  box-shadow:var(--shadow-card);
  border-radius:10px;
  font-weight:var(--fw-medium);
  transition:transform .12s var(--ease-pop),box-shadow .2s var(--ease-out),
             background .2s var(--ease-out),filter .2s;
}
.button:hover,
button:not(.icon-button):not(.password-toggle):not(.theme-toggle):hover{
  background:var(--raised);
  border-color:transparent;
}
.button:active,
button:not(.icon-button):not(.password-toggle):not(.theme-toggle):active{transform:scale(.97)}
.primary,button.primary{
  background:var(--accent)!important;
  color:#fff!important;
  box-shadow:0 2px 10px var(--accent-soft),0 1px 2px rgba(0,0,0,.12);
}
[data-theme="dark"] .primary,[data-theme="dark"] button.primary{color:#1a0d12!important}
.primary:hover{filter:brightness(1.06);background:var(--accent)!important}
.primary:active{transform:scale(.97)}

/* ---- 丝滑折叠：Grid 0fr -> 1fr ---- */
details > .details-body{
  display:grid;
  grid-template-rows:0fr;
  opacity:.55;
  transition:grid-template-rows .34s var(--ease-out),opacity .28s var(--ease-out);
}
details[open] > .details-body{grid-template-rows:1fr;opacity:1}
details > .details-body > .details-inner{overflow:hidden;min-height:0}
details > summary{transition:color .2s}

/* ---- 流式打字 ---- */
.type-stream .ts-char{
  display:inline-block;
  filter:blur(6px);
  opacity:0;
  transform:translateY(.18em);
  transition:filter .09s var(--ease-out),opacity .09s var(--ease-out),
             transform .09s var(--ease-out);
  will-change:filter,opacity;
}
.type-stream.ts-running .ts-char{filter:blur(0);opacity:1;transform:none}

/* ---- 点赞 / 对勾：欠阻尼微弹 ---- */
@keyframes ln-pop{
  0%{transform:scale(.65)}
  55%{transform:scale(1.14)}
  100%{transform:scale(1)}
}
.ln-pop{animation:ln-pop .38s var(--ease-pop);transform-origin:center}

/* 复制对勾：默认隐藏，触发后显示，2.5s 自熄 */
.copy-btn .copy-check{display:none}
.copy-btn.copied .copy-check{display:inline-flex;animation:ln-pop .38s var(--ease-pop)}
.copy-btn.copied .copy-original{display:none}
.copy-btn.copied{color:var(--accent-strong)}

/* ---- 主题切换按钮 ---- */
.theme-toggle{
  display:inline-grid;place-items:center;
  width:40px;height:40px;min-width:40px;min-height:40px;
  border:0;background:none;border-radius:50%;
  color:var(--muted);
  transition:transform .38s var(--ease-pop),color .2s,background .2s;
}
.theme-toggle svg{width:20px;height:20px;min-width:20px;flex-shrink:0}
.theme-toggle:hover{background:var(--raised);color:var(--text)}
.theme-toggle .icon-sun{display:none}
.theme-toggle .icon-moon{display:block}
[data-theme="dark"] .theme-toggle .icon-sun{display:block}
[data-theme="dark"] .theme-toggle .icon-moon{display:none}
[data-theme="dark"] .theme-toggle{transform:rotate(0deg)}
.theme-toggle .icon-sun,.theme-toggle .icon-moon{animation:ln-pop .38s var(--ease-pop)}

/* 暗色下图片/头像框轻微提亮 */
[data-theme="dark"] img{filter:none}

/* ---- 社区首页：粉色边框统一成微明度 ---- */
.community-home{
  --community-border:var(--hair);
  --community-soft:color-mix(in srgb,var(--accent) 7%,var(--surface));
  --community-category-bg:color-mix(in srgb,var(--accent) 8%,var(--surface));
}
.community-home .community-page-title h1,
.community-home .community-feed-heading h2,
.community-home .community-panel-heading h2,
.community-home .community-topic h3,
.community-home .community-announcement h3{font-weight:var(--fw-bold)}
.community-home .community-search{
  border:0;background:var(--sunken);box-shadow:var(--field-shadow);border-radius:10px;
}
.community-home .community-welcome{
  border:0;background:var(--community-soft);
}
.community-home .community-composer{
  border:0;background:var(--surface);box-shadow:var(--shadow-card);
}
.community-home .community-navigation a[aria-current],
.community-home .community-categories a[aria-current]{
  background:var(--accent-soft);color:var(--accent-strong);
}
.community-home .community-topic-list{
  border:0;background:var(--surface);box-shadow:var(--shadow-card);
}
.community-home .community-topic+.community-topic,
.community-home .community-announcement+.community-announcement,
.community-home .community-explore-links a+a,
.community-home .community-sidebar-section,
.community-home .community-sidebar-bottom{border-color:var(--hair)}
.community-home .community-panel{
  border:0;background:var(--surface);box-shadow:var(--shadow-card);
}
.community-home .community-topic-tag{
  border:0;background:var(--accent-soft);color:var(--accent-strong);border-radius:999px;
}
.community-home .community-noticeboard{background:var(--raised);border-color:var(--hair)}

/* 尊重减少动态 */
@media (prefers-reduced-motion:reduce){
  *,*::before,*::after{
    animation-duration:.001ms!important;
    transition-duration:.001ms!important;
  }
  .type-stream .ts-char{filter:none;opacity:1;transform:none}
}
