/* Leaf Box — Ultra layer: intrinsic layout engine, type system, button/tag system, performance.
 * Loaded last. Presentation only. Every animation here is compositor-only (transform/opacity)
 * so it renders at the display's native refresh rate (60/90/120/144 Hz). */
:root{
  --t-xs:12px;--t-sm:13.5px;--t-md:15px;--t-lg:17px;--t-xl:clamp(20px,2.4vw,26px);--t-2xl:clamp(28px,4.2vw,42px);
  --lb-gold-1:#fbe7a8;--lb-gold-2:#e6b955;--lb-gold-3:#a8741f;
}
/* ---- 1. Layout engine: cards never get squeezed into tall, narrow columns ---- */
.grid.two{--col:340px}.grid.three{--col:290px}.pricing-grid{--col:290px}
.grid.two,.grid.three,.pricing-grid{grid-template-columns:repeat(auto-fit,minmax(min(100%,var(--col)),1fr))}
.grid:has(>.stat),.grid:has(>.card.stat){--col:190px}
.grid:has(>.quick-item){--col:230px}
.form-row{grid-template-columns:repeat(auto-fit,minmax(min(100%,220px),1fr))!important;gap:0 14px}
.grid.three>.card:first-child{grid-column:auto}
.card,.panel-content,.page-heading,.content{overflow-wrap:break-word;word-break:normal}
.card{min-width:0}
.card :where(p,li,small,span,strong){hyphens:manual}
@media (max-width:560px){
  .grid:has(>.stat),.grid:has(>.card.stat){--col:150px}
  .grid:has(>.quick-item){--col:150px}
  .grid>.card.stat:last-child:nth-child(odd),.grid>.quick-item:last-child:nth-child(odd){grid-column:1/-1}
  .spread>:first-child{flex:1 1 200px}
  .button-row>.btn,.button-row>button{flex:1 1 auto}
  .room-entry{align-items:flex-start;flex-wrap:wrap}
  .room-entry>:first-child{flex:1 1 180px}
}
@media (min-width:1360px){ /* bento rhythm only where three real columns exist */
  .grid.three:not(:has(>.stat)):not(:has(>.quick-item)):has(>:nth-child(4))>:first-child{grid-column:span 2}
  .grid.three:not(:has(>.stat)):not(:has(>.quick-item)):has(>:nth-child(5))>:nth-child(4){grid-column:span 2}
}
.extra-sections{margin-top:clamp(16px,2.4vw,28px)}
.section-title{font-size:var(--t-xl);margin:clamp(26px,4vw,40px) 0 14px;letter-spacing:-.02em}

/* ---- 2. Typography ---- */
body{font-size:var(--t-md);line-height:1.55}
.page-heading h1{font-size:var(--t-2xl);line-height:1.08;font-weight:600;letter-spacing:-.03em;text-wrap:balance}
.page-heading p,.card p{text-wrap:pretty}
.card h3{display:flex;align-items:center;gap:9px;font-size:var(--t-lg);line-height:1.25;text-wrap:balance}
.card h3 .icon{color:var(--brand);opacity:.9}
.muted.tiny,.tiny{font-size:var(--t-xs);line-height:1.5}
label{display:block;margin:0 0 7px;font-size:var(--t-sm);font-weight:650;color:#cfe5d7}
.field{margin-bottom:16px}
.field small{display:block;margin-top:6px}
.stat strong,.plan-price,.owner-table td,.count-pill{font-variant-numeric:tabular-nums lining-nums}

/* ---- 3. Buttons v3 ---- */
.btn{min-height:48px;padding:12px 20px;font-size:14.5px;gap:10px;white-space:nowrap}
.btn .icon{width:18px;height:18px;transition:transform .3s var(--lb-spring)}
.btn:hover:not(:disabled) .icon{transform:translateX(1px) scale(1.08)}
.btn.small{min-height:38px;padding:8px 14px;font-size:13px;gap:7px}
.btn.small .icon{width:16px;height:16px}
.btn.full{white-space:normal}
.btn.primary{
  background:linear-gradient(168deg,#c3f7cd 0%,#86e0a6 42%,#4fb67b 100%);
  box-shadow:0 1px 0 rgba(255,255,255,.7) inset,0 -3px 8px rgba(8,80,45,.28) inset,0 2px 4px rgba(0,30,15,.3),0 14px 32px rgba(60,170,105,.32)}
.btn.primary:active:not(:disabled){box-shadow:0 2px 8px rgba(8,80,45,.4) inset,0 4px 12px rgba(60,170,105,.25)}
.btn.outline{backdrop-filter:blur(8px);-webkit-backdrop-filter:blur(8px)}
.btn.icon-btn{width:48px;padding:0;border-radius:50%}
.btn.icon-btn.small{width:38px}
.btn:focus-visible{outline:none;box-shadow:0 0 0 2px #06120d,0 0 0 4.5px #d8f39b}

/* ---- 4. Role & plan tags ---- */
.tag,.permission-tag{white-space:nowrap;line-height:1;font-feature-settings:"tnum";position:relative;overflow:hidden}
.tag[data-tone="free"]{color:#b7cdbf;background:rgba(255,255,255,.05);border-color:rgba(255,255,255,.14)}
.tag[data-tone="basic"]{color:#9fe3ff;background:linear-gradient(135deg,rgba(70,180,235,.18),rgba(70,180,235,.06));border-color:rgba(120,210,255,.38)}
.tag[data-tone="plus"]{color:#d6c8ff;background:linear-gradient(135deg,rgba(150,120,255,.24),rgba(150,120,255,.07));border-color:rgba(176,154,255,.45)}
.tag[data-tone="pro"],.tag[data-tone="premium"]{color:#3a2603;font-weight:800;border-color:rgba(255,240,190,.6);
  background:linear-gradient(135deg,var(--lb-gold-1),var(--lb-gold-2) 55%,#d49a35);box-shadow:0 1px 0 rgba(255,255,255,.5) inset,0 6px 16px rgba(230,185,85,.28)}
.tag[data-tone="owner"]{color:#fff2d2;font-weight:800;border-color:rgba(255,215,130,.55);
  background:linear-gradient(135deg,#8a5a12,#c8892a 50%,#7a4a0c);box-shadow:0 1px 0 rgba(255,235,180,.35) inset,0 6px 16px rgba(200,137,42,.26)}
.tag[data-tone="admin"],.tag[data-tone="staff"]{color:#e0d6ff;background:linear-gradient(135deg,rgba(130,100,240,.3),rgba(130,100,240,.1));border-color:rgba(170,150,255,.5)}
.tag[data-tone="mod"]{color:#a7f3e4;background:rgba(40,190,160,.14);border-color:rgba(70,220,190,.4)}
.tag[data-tone="teacher"]{color:#ffd9a0;background:rgba(240,160,60,.14);border-color:rgba(250,190,100,.42)}
.tag[data-tone="pro"]::before,.tag[data-tone="premium"]::before,.tag[data-tone="owner"]::before{border-radius:0;clip-path:polygon(50% 0,62% 38%,100% 50%,62% 62%,50% 100%,38% 62%,0 50%,38% 38%);width:9px;height:9px;transform:none;opacity:1}
.tag[data-tone="pro"]::after,.tag[data-tone="owner"]::after{content:"";position:absolute;inset:0 auto 0 -60%;width:45%;background:linear-gradient(100deg,transparent,rgba(255,255,255,.55),transparent);transform:translateX(0) skewX(-20deg)}
@media (prefers-reduced-motion:no-preference){
  .tag[data-tone="pro"]::after,.tag[data-tone="owner"]::after{animation:lb-tag-sheen 5.5s ease-in-out infinite}
  .plan-card.highlight::after{content:"";position:absolute;inset:-30% auto -30% -50%;width:34%;pointer-events:none;background:linear-gradient(100deg,transparent,rgba(255,255,255,.1),transparent);transform:skewX(-18deg);animation:lb-card-sheen 7s ease-in-out infinite}
}
@keyframes lb-tag-sheen{0%,70%{transform:translateX(0) skewX(-20deg)}100%{transform:translateX(520%) skewX(-20deg)}}
@keyframes lb-card-sheen{0%,60%{transform:translateX(0) skewX(-18deg)}100%{transform:translateX(480%) skewX(-18deg)}}
.plan-card.highlight{animation:none;overflow:hidden}
.badge-line{display:flex;flex-wrap:wrap;gap:8px;align-items:center;margin-top:14px}

/* ---- 5. Notes, accounts and list surfaces ---- */
.note{display:flex;flex-direction:column;gap:6px;padding:20px;border-radius:22px;border:1px solid var(--line);
  background:linear-gradient(160deg,rgba(255,255,255,.05),rgba(255,255,255,.015));box-shadow:var(--lb-lift-1);
  transition:border-color .25s,transform .35s var(--lb-ease),box-shadow .35s var(--lb-ease);content-visibility:auto;contain-intrinsic-size:auto 220px}
.note>.tag{align-self:flex-start}
.note h3{font-family:var(--font-display);font-size:19px;font-weight:620;letter-spacing:-.015em;margin:6px 0 2px;line-height:1.25}
.note p{font-size:var(--t-sm);line-height:1.7;margin:4px 0 6px;overflow-wrap:break-word}
.note small{display:flex;align-items:center;gap:6px;margin-top:auto}
@media (hover:hover){.note:hover{border-color:var(--line-strong);transform:translateY(-3px)}}
.profile-head{margin-left:clamp(14px,3vw,24px);gap:clamp(12px,2.4vw,20px);flex-wrap:wrap}
.profile-head h2{font-size:clamp(22px,3.4vw,30px);line-height:1.1}
.profile-cover{border-radius:20px}
.notice-item,.status-post,.ai-history-entry,.online-member-row{content-visibility:auto;contain-intrinsic-size:auto 76px}
.spread{row-gap:10px}
.spread>h3{margin:0}
.page-heading{flex-wrap:wrap;row-gap:12px}
@media (max-width:560px){
  .page-heading h1{font-size:clamp(26px,8vw,32px)}
  .card{padding:clamp(16px,4.6vw,22px)}
  .profile-head{margin-top:-30px}
}

/* ---- 6. Native-refresh-rate performance (no feature or effect removed) ---- */
.mobile-nav{contain:layout style}
body::before{contain:strict}
html[data-scrolling] body::before,html[data-scrolling] .plan-card.highlight::after,html[data-scrolling] .tag::after{animation-play-state:paused}
@media (pointer:coarse){
  .glass,.mobile-nav,.sidebar,.toast,.lb-toast,:root[data-scrolled="true"] .topbar{backdrop-filter:blur(14px) saturate(1.2);-webkit-backdrop-filter:blur(14px) saturate(1.2)}
}
/* Safety net: if a low-end device cannot hold its refresh rate, only ambient loops pause. */
:root[data-perf="eco"] body::before,:root[data-perf="eco"] .plan-card.highlight::after,:root[data-perf="eco"] .tag::after,:root[data-perf="eco"] .skeleton-line{animation-play-state:paused}
:root[data-perf="eco"] .glass,:root[data-perf="eco"] .mobile-nav,:root[data-perf="eco"] .sidebar{backdrop-filter:blur(8px);-webkit-backdrop-filter:blur(8px)}
.lb-ripple>i,.lb-ripple{will-change:transform,opacity}
img,video,canvas{content-visibility:visible}
@media (prefers-reduced-motion:reduce){.tag::after,.plan-card.highlight::after{animation:none!important;display:none}}
