/* Leaf Box UI Craft — incremental design-system layer.
   Keeps the app's existing green/dark identity and every API binding intact.
   This file intentionally comes after legacy styles, avoiding invasive template rewrites. */
:root {
  color-scheme: dark;
  --lb-craft-ink: #effaf2;
  --lb-craft-muted: #b3c9ba;
  --lb-craft-line: rgba(201,240,211,.14);
  --lb-craft-hover: rgba(163,232,182,.065);
  --lb-craft-focus: #c5ffcb;
  --lb-craft-radius: 18px;
  --lb-craft-radius-sm: 12px;
  --lb-craft-ease: cubic-bezier(.2,.8,.2,1);
}
html { color-scheme: dark; }
body, .app-shell, .main { color: var(--lb-craft-ink); }
body, button, input, select, textarea { font-family: "Figtree LB", Inter, "Segoe UI", system-ui, sans-serif; }
:is(p,li,small,.muted,.subtitle) { line-height: 1.56; }
.muted, .tiny.muted { color: var(--lb-craft-muted); }
:is(.content,.card,.page-heading,.mp-page,.chat-layout,.grid,.note,.mp-section) { min-width: 0; }
:is(.card,.note,.mp-card,.mp-coin-panel) { border-color: var(--lb-craft-line); }
.card { border-radius: var(--lb-craft-radius); }
:is(.card,.note,.mp-card):focus-within { border-color: rgba(192,252,206,.32); }
.content { animation:none; }
.page-heading { align-items: flex-end; gap: 18px; margin-bottom: clamp(22px,3vw,32px); }
.page-heading h1 { font-size:clamp(27px,3.1vw,39px);line-height:1.15;letter-spacing:-.042em; }
.page-heading p { color:var(--lb-craft-muted);line-height:1.6;max-width:67ch; }
.section-title { letter-spacing:-.025em;line-height:1.25; }
.eyebrow { letter-spacing:.10em;line-height:1.3; }
:where(.card) h2,:where(.card) h3 { line-height:1.27;letter-spacing:-.02em; }
:is(.input,textarea.input,select.input) { background-color:rgba(6,22,15,.78);border-color:rgba(188,234,200,.19);border-radius:var(--lb-craft-radius-sm);color:#f0fcf3; }
.input::placeholder { color:#a0b9a9;opacity:1; }
:is(.field,label):has(>.input) { min-width:0; }
.field > label, .mp-frame-filters label, .mp-coin-panel form label { color:#d8e9dd;font-weight:650;line-height:1.42; }
:is(.btn,.input,.mp-tag-chip,.mp-toggle-btn,.mp-layout-btn,.mp-variant-btn,.lb-room-filter) { transition-property:background-color,border-color,color,box-shadow,opacity,transform;transition-duration:160ms;transition-timing-function:var(--lb-craft-ease); }
:is(.btn,.mp-tag-chip,.mp-layout-btn,.mp-toggle-btn,.mp-variant-btn) { touch-action:manipulation; }
:is(.btn,.mp-layout-btn,.mp-toggle-btn,.mp-tag-chip,.lb-room-filter,.mp-variant-btn):focus-visible,
:is(.mobile-nav a,.mobile-nav button,.mp-tabs a,.nav-link,.more-link):focus-visible {
  outline:3px solid var(--lb-craft-focus);outline-offset:3px;
}
:is(.btn,.mp-layout-btn,.mp-toggle-btn,.mp-tag-chip)[disabled] { opacity:.52;cursor:not-allowed; }
.btn { border-radius:var(--lb-craft-radius-sm); }
.btn.small { min-height:42px; }
.btn.icon-btn { min-width:44px; min-height:44px; }
.nav-link .icon,.mobile-nav .icon,.more-link .icon { stroke-width:1.8; }
.sidebar .nav-label { letter-spacing:.08em; }
.sidebar .nav-link { min-height:43px; }
:is(.quick-item,.mp-tabs a,.mp-tag-chip,.mp-toggle-btn,.mp-layout-btn,.mp-variant-btn,.lb-room-filter) { min-height:44px; }
:is(.topbar,.sidebar,.mobile-nav) { color-scheme:dark; }
.topbar .heading { line-height:1.18; }
.mobile-nav a,.mobile-nav button { min-width:0; }
.mobile-nav :is(a,.more-tab) span { white-space:nowrap; }
/* Show useful content rather than white/blank space while a list is empty. */
.empty { line-height:1.6; }
.empty strong { display:block;color:var(--lb-craft-ink);font-size:15px; }
.empty p { color:var(--lb-craft-muted);margin:7px 0 15px; }
.lb-empty-actions { display:flex;justify-content:center;align-items:center;gap:10px;flex-wrap:wrap; }
.lb-study-empty { display:grid;align-content:center;justify-items:center;grid-column:1/-1;min-height:210px;padding:30px 20px;text-align:center;border:1px dashed rgba(192,244,206,.24);border-radius:var(--lb-craft-radius);background:rgba(21,50,34,.36); }
.lb-study-empty p { max-width:40ch; }
.lb-notes-result-bar { display:flex;align-items:center;justify-content:space-between;flex-wrap:wrap;gap:12px;margin:22px 0 13px; }
.lb-notes-result-bar .section-title { margin:0; }
.lb-notes-result-bar [role="status"] { color:var(--lb-craft-muted);font-size:13px;font-variant-numeric:tabular-nums; }
.lb-notes-results>.note { display:flex;flex-direction:column;gap:9px;min-height:225px; }
.lb-notes-results>.note h3 { line-height:1.28;overflow-wrap:anywhere; }
.lb-notes-results>.note p { line-height:1.6;overflow-wrap:anywhere; }
.lb-notes-results>.note .btn { align-self:flex-start;margin-top:auto; }
.lb-recent-list { display:grid;gap:0; }
.lb-recent-row { padding:13px 2px;min-width:0; }
.lb-recent-row + .lb-recent-row { border-top:1px solid var(--lb-craft-line); }
.lb-recent-row>div { display:flex;justify-content:space-between;align-items:baseline;gap:10px; }
.lb-recent-row>div>strong { font-size:14px;font-weight:720;overflow-wrap:anywhere; }
.lb-recent-row time { flex:0 0 auto;font-variant-numeric:tabular-nums; }
.lb-recent-row p { margin:5px 0 0;color:var(--lb-craft-muted);font-size:13px;line-height:1.55;overflow-wrap:anywhere; }
.lb-recent-empty { display:grid;justify-items:center;gap:7px;text-align:center;padding:24px 12px; }
.lb-recent-empty p { margin:0 0 8px; }
/* Marketplace: the artwork makes the decision; controls follow a calm hierarchy. */
.mp-frames-page .mp-section { margin-top:clamp(20px,3vw,30px); }
.mp-frames-page .mp-section-top { align-items:flex-end;gap:18px;margin-bottom:16px; }
.mp-frames-page .mp-section-top h2 { font-size:clamp(20px,2.2vw,25px);letter-spacing:-.025em; }
.mp-frames-page .mp-section-top p { font-size:13px; }
.mp-frames-page .mp-section-tools { align-items:center;gap:9px; }
.mp-layout-toggle { display:inline-flex;align-items:center;gap:3px;border:1px solid var(--lb-craft-line);background:rgba(9,27,18,.7);padding:4px;border-radius:12px; }
.mp-layout-btn { border:1px solid transparent;background:transparent;color:var(--lb-craft-muted);border-radius:9px;font:inherit;font-size:12px;font-weight:730;padding:9px 12px;cursor:pointer; }
.mp-layout-btn:hover { color:var(--lb-craft-ink);background:var(--lb-craft-hover); }
.mp-layout-btn.is-active { color:#e9fff0;background:#2b6043;border-color:rgba(165,239,185,.28); }
.mp-preview-toggle { border-radius:12px;border-color:var(--lb-craft-line); }
.mp-preview-toggle .mp-toggle-btn { min-height:42px;border-radius:9px; }
.mp-result-count { font-size:12px;font-variant-numeric:tabular-nums;font-weight:700;border-color:var(--lb-craft-line);background:rgba(158,236,181,.055); }
.mp-frame-filters { grid-template-columns:minmax(215px,1.5fr) repeat(3,minmax(105px,1fr));align-items:end;gap:12px;padding:17px;border-radius:var(--lb-craft-radius); }
.mp-frame-filters .mp-search-label { min-width:0; }
.mp-frame-filters .input { min-height:46px; }
.mp-frame-filters label { font-size:12px;letter-spacing:.005em; }
.mp-tag-bar { gap:8px;flex-wrap:wrap;margin:18px 0; }
.mp-tag-chip { border-radius:100px;padding:9px 13px;color:#d5eadd; }
.mp-tag-chip .mp-tag-count { font-variant-numeric:tabular-nums; }
.mp-tag-chip.is-active { background:rgba(101,192,128,.23);border-color:rgba(153,246,174,.6); }
.mp-grid { grid-template-columns:repeat(auto-fill,minmax(min(100%,280px),1fr));gap:18px;align-items:stretch; }
.mp-grid .mp-card { display:flex;flex-direction:column;min-width:0;min-height:360px;gap:14px;padding:14px;border-radius:var(--lb-craft-radius);content-visibility:auto;contain-intrinsic-size:auto 440px; }
.mp-card .mp-card-preview { flex:0 0 auto; }
@media(hover:none){.mp-card:hover { transform:none; }}
.mp-frame-stage { min-height:224px;padding:22px 16px 17px;gap:13px;border-radius:14px;border-color:rgba(171,239,187,.15);background:radial-gradient(circle at 50% 42%,rgba(80,146,106,.25),transparent 65%),linear-gradient(145deg,#1b3b2b,#0c2118); }
.mp-card-preview .mp-frame-art .mp-photo-stack { --mp-size:156px!important;width:156px!important;height:156px!important; }
.mp-frame-art { --mp-size:156px; }
.mp-card .mp-card-info { display:flex;flex:1 1 auto;flex-direction:column;gap:12px;padding:3px 2px 2px; }
.mp-card-info>.spread:first-child { align-items:center;gap:10px; }
.mp-frame-name { min-width:0;flex:1;margin:0;font-weight:800;font-size:16px;line-height:1.3;color:#f2fff4;overflow-wrap:anywhere; }
.mp-frame-kind { flex:0 0 auto;font-size:10px;font-weight:700;color:var(--lb-craft-muted);border:1px solid var(--lb-craft-line);padding:5px 7px;border-radius:99px; }
.mp-card-meta { align-items:flex-start;gap:9px; }
.mp-card .mp-tag-list { max-width:100%; }
.mp-card .mp-tag-pill { min-height:36px;padding:7px 11px; }
.mp-card-info>.spread:last-child { margin-top:auto;padding-top:10px;border-top:1px solid var(--lb-craft-line);align-items:center; }
.mp-card .mp-price { font-size:15px;font-weight:800;color:#f0f5c1;line-height:1.3; }
.mp-card-info>.spread:last-child .btn { flex:0 0 auto; }
.mp-variant-list { gap:7px; }
.mp-variant-btn { border-radius:10px;min-height:38px; }
.mp-frames-page .mp-filter-empty { text-align:left; }
.mp-grid.mp-list-layout { display:grid;grid-template-columns:minmax(0,1fr);gap:12px; }
.mp-list-layout .mp-card { display:grid;grid-template-columns:minmax(145px,200px) minmax(0,1fr);align-items:center;min-height:0;padding:13px;gap:18px;contain-intrinsic-size:auto 190px; }
.mp-list-layout .mp-frame-stage { min-height:165px;padding:12px; }
.mp-list-layout .mp-frame-art,.mp-list-layout .mp-card-preview .mp-frame-art .mp-photo-stack { --mp-size:110px!important;width:110px!important;height:110px!important; }
.mp-list-layout .mp-card .mp-card-info { gap:10px;align-self:stretch; }
.mp-list-layout .mp-card-info>.spread:last-child { margin-top:auto; }
.mp-list-layout .mp-card-preview .mp-profile-preview { margin:0; }
.mp-list-layout .mp-card .mp-card-info .mp-badges { justify-content:flex-start; }
.mp-list-layout .mp-card .mp-tag-list { margin-block:0; }
.mp-list-layout .mp-frame-caption { font-size:11px; }
/* Wallet: exact estimates, approval status, and nonreversible gifts. */
.mp-coin-estimate { display:block;padding:13px 14px;border-radius:12px;border:1px solid rgba(242,206,129,.25);background:rgba(239,185,77,.075);color:#f7dfae;font-weight:700;font-size:13px;line-height:1.45;font-variant-numeric:tabular-nums; }
.mp-coins-page .mp-coin-panel form { gap:13px; }
.mp-coins-page .mp-coin-panel form .btn.primary { min-height:46px; }
.mp-history-row { padding-block:13px;gap:14px; }
.mp-history-row strong,.mp-history-row .tag { flex:0 0 auto; }
.mp-wallet h2 { letter-spacing:-.025em; }
/* Chat: preserve long-thread stability while enlarging the smallest actions. */
.lb-chat-workspace .lb-message-more { min-width:44px;min-height:44px; }
.lb-chat-workspace .lb-chat-header-action { min-width:44px;min-height:44px;flex-shrink:0; }
.lb-chat-workspace .lb-room-filter { min-height:44px; }
.lb-chat-workspace .lb-chat-room-results { color:var(--lb-craft-muted);font-size:12px; }
.lb-chat-workspace .chat-room-list .conversation-item { min-height:66px; }
.lb-chat-workspace .lb-chat-header-copy strong { overflow-wrap:anywhere; }
.lb-chat-workspace .lb-thread-message .bubble p { line-height:1.6; }
.lb-chat-workspace .lb-compose-count { font-variant-numeric:tabular-nums; }
.lb-chat-workspace .lb-compose-textarea::placeholder { color:#aabfc1; }
/* Owner/Moderator tabs retain independent scroll rather than compressing text. */
.lb-admin-content,.lb-admin-layout,.lb-admin-navigation { min-width:0; }
.lb-admin-navigation .panel-link { min-height:46px; }
.lb-admin-content :is(input,select,textarea) { max-width:100%; }
.lb-admin-content :is(.owner-table,.owner-table-wrapper) { max-width:100%; }
/* Media should not cover titles or actions; existing avatar overlays remain intact. */
.feed-media,.message-image,.note-attachment { max-width:100%; }
.feed-media { object-fit:contain; }
:is(.status-post,.notice-item,.note) :is(p,strong,small) { overflow-wrap:anywhere; }
.mp-card .mp-badges { max-width:100%; }
/* Mobile: preserve independent browsing controls without folding everything into a menu. */
@media (max-width:1020px) {
  .mp-frame-filters { grid-template-columns:repeat(2,minmax(0,1fr)); }
  .mp-frame-filters .mp-search-label { grid-column:1/-1; }
  .mp-list-layout .mp-card { grid-template-columns:minmax(128px,170px) minmax(0,1fr); }
}
@media (max-width:800px) {
  .content { padding-bottom:calc(104px + env(safe-area-inset-bottom,0px)); }
  .mp-frames-page .mp-section-top { align-items:flex-start; }
  .mp-frames-page .mp-section-tools { gap:8px;width:100%;justify-content:flex-start; }
  .mp-card .mp-card-info>.spread:last-child { gap:9px; }
  .mp-tag-bar { flex-wrap:nowrap;overflow-x:auto;overscroll-behavior-x:contain;-webkit-overflow-scrolling:touch;scroll-snap-type:x proximity;scrollbar-width:thin;padding:2px 1px 10px; }
  .mp-tag-chip { flex:0 0 auto;scroll-snap-align:start; }
}
@media (max-width:580px) {
  .content { animation:none; }
.page-heading { align-items:flex-start;flex-direction:column;gap:12px; }
  .page-heading h1 { font-size:30px; }
  .mp-frame-filters { gap:11px;padding:13px; }
  .mp-frame-filters .input { min-height:45px;font-size:14px; }
  .mp-frames-page .mp-section-tools { display:grid;grid-template-columns:minmax(0,1fr) auto;align-items:center; }
  .mp-layout-toggle,.mp-preview-toggle { width:fit-content; }
  .mp-result-count { justify-self:end; }
  .mp-frames-page .mp-clear-filters { grid-column:1/-1;justify-self:start; }
  .mp-grid { grid-template-columns:minmax(0,1fr);gap:14px; }
  .mp-grid .mp-card { min-height:0; }
  .mp-frame-stage { min-height:215px; }
  .mp-list-layout .mp-card { grid-template-columns:minmax(105px,128px) minmax(0,1fr);gap:11px;padding:10px; }
  .mp-list-layout .mp-frame-stage { min-height:135px;padding:8px 5px; }
  .mp-list-layout .mp-frame-art,.mp-list-layout .mp-card-preview .mp-frame-art .mp-photo-stack { --mp-size:90px!important;width:90px!important;height:90px!important; }
  .mp-list-layout .mp-frame-caption { display:none; }
  .mp-list-layout .mp-frame-kind { display:none; }
  .mp-list-layout .mp-card-info>.spread:last-child { flex-wrap:wrap; }
  .mp-list-layout .mp-card-info>.spread:last-child>.btn { flex:1 1 auto; }
  .mp-list-layout .mp-card .mp-tag-list { display:none; }
  .lb-notes-results>.note { min-height:0; }
  .lb-recent-row>div { flex-wrap:wrap; }
}
@media (max-width:390px) {
  .mp-frames-page .mp-section-tools { grid-template-columns:1fr;justify-items:start; }
  .mp-result-count { justify-self:start; }
  .mp-frame-filters { grid-template-columns:minmax(0,1fr); }
  .mp-frame-filters .mp-search-label { grid-column:auto; }
  .mp-list-layout .mp-card { grid-template-columns:minmax(0,1fr); }
  .mp-list-layout .mp-card-preview .mp-frame-stage { min-height:132px; }
  .mp-list-layout .mp-card .mp-card-info { padding-inline:4px; }
}
@media (prefers-reduced-motion:reduce) {
  :is(.btn,.input,.mp-tag-chip,.mp-layout-btn,.mp-toggle-btn,.mp-variant-btn,.lb-room-filter) { transition:none!important; }
  .mp-card:hover { transform:none; }
}
@media (prefers-contrast:more) {
  .mp-frame-stage,.mp-card,.mp-frame-filters,.mp-layout-toggle,.mp-coin-estimate { border-color:rgba(235,255,239,.75); }
  .muted,.tiny.muted { color:#e1f4e6; }
}
