/* ============================================================
   Savant — Templates
   Starter app screens, composed only from Savant tokens and
   components. Every value is a token, so each screen themes with
   the rest of the system. .tpl is a fixed-height app "window";
   inner scroll regions are clipped to show the primary view.
   ============================================================ */
.sv-demo--tpl { padding: 0; overflow: hidden; }
.tpl {
  height: 564px; overflow: hidden; display: grid;
  background: var(--surface-page); color: var(--text-primary);
  font: 400 13.5px/1.45 var(--font-sans);
}
.tpl a { text-decoration: none; color: inherit; cursor: pointer; }
.tpl input { font: inherit; }
.tpl ::-webkit-scrollbar { width: 8px; height: 8px; }
.tpl ::-webkit-scrollbar-thumb { background: var(--border-hairline); border-radius: 9999px; }

/* ---------------------------------------------------------
   1. Finance dashboard
   --------------------------------------------------------- */
.tpl--fin { grid-template-columns: 190px 1fr; }
.tplf-rail { display: flex; flex-direction: column; gap: 6px; padding: 18px 14px; background: var(--surface-raised); border-right: 1px solid var(--border-hairline); }
.tplf-brand { display: flex; align-items: center; gap: 9px; font: 700 16px/1 var(--font-sans); padding: 4px 8px 16px; }
.tplf-logo { width: 24px; height: 24px; border-radius: 7px; background: var(--color-primary); color: #fff; display: grid; place-items: center; font: 800 13px/1 var(--font-sans); }
.tplf-nav { display: flex; flex-direction: column; gap: 2px; }
.tplf-nav a { display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: 8px; color: var(--text-secondary); font-weight: 500; }
.tplf-nav a svg { width: 17px; height: 17px; }
.tplf-nav a:hover { background: var(--surface-inset); color: var(--text-primary); }
.tplf-nav a.is-active { background: rgba(106,71,209,.16); color: var(--text-primary); }
.tplf-me { margin-top: auto; display: flex; align-items: center; gap: 9px; padding: 8px; border-top: 1px solid var(--border-hairline); }
.tplf-me div { display: flex; flex-direction: column; line-height: 1.3; }
.tplf-me b { font-size: 13px; } .tplf-me span { font-size: 11.5px; color: var(--text-muted); }
.tplf-main { padding: 24px 26px; overflow: hidden; }
.tplf-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; }
.tplf-eyebrow { font: 600 12px/1 var(--font-sans); color: var(--text-muted); }
.tplf-balance { font: 700 38px/1.05 var(--font-sans); letter-spacing: -1px; margin-top: 10px; }
.tplf-balance span { color: var(--text-muted); }
.tplf-change { font: 600 13px/1 var(--font-sans); margin-top: 9px; }
.tplf-up { color: var(--green-500); } .tplf-down { color: var(--red-500); } .tplf-flat { color: var(--text-muted); }
.tplf-actions { display: flex; gap: 8px; }
.tplf-rangebar { margin: 18px 0 4px; }
.tplf-chart { height: 150px; }
.tplf-chart svg { width: 100%; height: 100%; display: block; }
.tplf-holdings { margin-top: 8px; }
.tplf-hhead, .tplf-row { display: grid; grid-template-columns: 2fr 1fr 1fr 1.4fr; align-items: center; gap: 10px; }
.tplf-hhead { font: 600 11.5px/1 var(--font-sans); color: var(--text-muted); padding: 0 4px 10px; }
.tplf-row { padding: 11px 4px; border-top: 1px solid var(--border-hairline); }
.tplf-r { text-align: right; }
.tplf-asset { display: flex; align-items: center; gap: 10px; }
.tplf-asset b { font-size: 13.5px; } .tplf-asset i { font-style: normal; color: var(--text-muted); font-size: 12px; }
.tplf-coin { width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; color: #fff; font: 700 13px/1 var(--font-sans); flex: none; }
.tplf-row > span:nth-child(2) { font-variant-numeric: tabular-nums; }
.tplf-r b { display: block; font-size: 13.5px; font-variant-numeric: tabular-nums; } .tplf-r i { font-style: normal; color: var(--text-muted); font-size: 12px; }

/* ---------------------------------------------------------
   2. Video streaming
   --------------------------------------------------------- */
.tpl--vid { grid-template-rows: 56px 1fr; }
.tplv-top { display: grid; grid-template-columns: 180px 1fr auto; align-items: center; gap: 16px; padding: 0 20px; border-bottom: 1px solid var(--border-hairline); background: var(--surface-raised); }
.tplv-brand { display: flex; align-items: center; gap: 8px; font: 700 16px/1 var(--font-sans); }
.tplv-brand svg { width: 26px; height: 26px; color: var(--color-primary); }
.tplv-search { display: flex; align-items: center; gap: 9px; height: 38px; padding: 0 14px; max-width: 460px; background: var(--surface-inset); border: 1px solid var(--border-hairline); border-radius: 9999px; color: var(--text-muted); }
.tplv-search svg { width: 17px; height: 17px; } .tplv-search input { flex: 1; background: none; border: 0; outline: none; color: var(--text-primary); }
.tplv-right { display: flex; align-items: center; gap: 12px; }
.tplv-body { display: grid; grid-template-columns: 178px 1fr; overflow: hidden; }
.tplv-side { display: flex; flex-direction: column; gap: 2px; padding: 14px 12px; border-right: 1px solid var(--border-hairline); }
.tplv-side a { display: flex; align-items: center; gap: 12px; padding: 9px 10px; border-radius: 8px; color: var(--text-secondary); font-weight: 500; }
.tplv-side a svg { width: 18px; height: 18px; }
.tplv-side a:hover { background: var(--surface-inset); color: var(--text-primary); }
.tplv-side a.is-active { background: rgba(106,71,209,.16); color: var(--text-primary); }
.tplv-main { padding: 16px 20px; overflow: hidden; }
.tplv-chips { display: flex; gap: 8px; margin-bottom: 16px; }
.tplv-chips span { padding: 6px 13px; border-radius: 9999px; background: var(--surface-inset); border: 1px solid var(--border-hairline); font: 600 12.5px/1 var(--font-sans); color: var(--text-secondary); }
.tplv-chips span.is-active { background: var(--text-primary); color: var(--surface-page); border-color: var(--text-primary); }
.tplv-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 18px 16px; }
.tplv-thumb { position: relative; display: block; aspect-ratio: 16/9; border-radius: 12px; overflow: hidden; background: var(--surface-inset); }
.tplv-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.tplv-dur { position: absolute; right: 8px; bottom: 8px; font: 600 11px/1 var(--font-sans); color: #fff; background: rgba(0,0,0,.78); padding: 3px 6px; border-radius: 5px; font-style: normal; }
.tplv-meta { display: flex; gap: 10px; margin-top: 10px; }
.tplv-meta b { display: block; font-size: 13.5px; line-height: 1.3; }
.tplv-meta span { font-size: 12px; color: var(--text-muted); }

/* ---------------------------------------------------------
   3. AI chat
   --------------------------------------------------------- */
.tpl--chat { grid-template-columns: 222px 1fr; }
.tplc-rail { display: flex; flex-direction: column; padding: 14px 12px; background: var(--surface-raised); border-right: 1px solid var(--border-hairline); }
.tplc-new { display: flex; align-items: center; justify-content: center; gap: 8px; height: 40px; border: 1px solid var(--border-hairline); border-radius: 9px; background: var(--surface-inset); color: var(--text-primary); font: 600 13px/1 var(--font-sans); cursor: pointer; }
.tplc-new svg { width: 16px; height: 16px; }
.tplc-hist { display: flex; flex-direction: column; gap: 2px; margin-top: 16px; overflow: hidden; flex: 1; }
.tplc-lbl { font: 600 11px/1 var(--font-sans); color: var(--text-muted); padding: 12px 8px 6px; }
.tplc-hist a { padding: 8px 10px; border-radius: 7px; color: var(--text-secondary); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tplc-hist a:hover { background: var(--surface-inset); color: var(--text-primary); }
.tplc-hist a.is-active { background: rgba(106,71,209,.16); color: var(--text-primary); }
.tplc-me { display: flex; align-items: center; gap: 9px; padding: 10px 8px 2px; border-top: 1px solid var(--border-hairline); font-weight: 600; font-size: 13px; }
.tplc-main { display: flex; flex-direction: column; overflow: hidden; }
.tplc-head { padding: 12px 20px; border-bottom: 1px solid var(--border-hairline); }
.tplc-model { display: inline-flex; align-items: center; gap: 6px; }
.tplc-model svg { width: 15px; height: 15px; }
.tplc-thread { flex: 1; overflow: hidden; padding: 22px 24px; display: flex; flex-direction: column; gap: 22px; }
.tplc-msg { display: flex; gap: 12px; max-width: 92%; }
.tplc-msg--user { align-self: flex-end; flex-direction: row-reverse; }
.tplc-ai { width: 30px; height: 30px; border-radius: 8px; flex: none; background: var(--color-primary); display: grid; place-items: center; }
.tplc-ai img { width: 18px; height: 18px; }
.tplc-bubble { padding: 12px 15px; border-radius: 13px; background: var(--surface-raised); border: 1px solid var(--border-hairline); }
.tplc-msg--user .tplc-bubble { background: var(--color-primary); border-color: var(--color-primary); color: #fff; }
.tplc-bubble p + p { margin-top: 9px; }
.tplc-actions { display: flex; gap: 8px; margin-top: 12px; }
.tplc-actions button { font: 600 12px/1 var(--font-sans); color: var(--text-muted); background: none; border: 0; padding: 4px 8px; border-radius: 6px; cursor: pointer; }
.tplc-actions button:hover { background: var(--surface-inset); color: var(--text-primary); }
.tplc-composer { margin: 0 24px; display: flex; align-items: center; gap: 10px; height: 48px; padding: 0 8px 0 16px; background: var(--surface-raised); border: 1px solid var(--border-hairline); border-radius: 13px; }
.tplc-composer input { flex: 1; background: none; border: 0; outline: none; color: var(--text-primary); }
.tplc-send { width: 34px; height: 34px; border-radius: 9px; border: 0; background: var(--color-primary); color: #fff; display: grid; place-items: center; cursor: pointer; flex: none; }
.tplc-send svg { width: 17px; height: 17px; }
.tplc-fine { text-align: center; font-size: 11.5px; color: var(--text-muted); padding: 10px 0 14px; }

/* ---------------------------------------------------------
   4. Email client
   --------------------------------------------------------- */
.tpl--mail { grid-template-columns: 182px 300px 1fr; }
.tplm-rail { display: flex; flex-direction: column; gap: 4px; padding: 16px 12px; background: var(--surface-raised); border-right: 1px solid var(--border-hairline); }
.tplm-compose { justify-content: center; margin-bottom: 12px; }
.tplm-compose svg { width: 16px; height: 16px; }
.tplm-folders { display: flex; flex-direction: column; gap: 2px; }
.tplm-folders a { display: flex; align-items: center; gap: 11px; padding: 9px 10px; border-radius: 8px; color: var(--text-secondary); font-weight: 500; }
.tplm-folders a svg { width: 17px; height: 17px; }
.tplm-folders a:hover { background: var(--surface-inset); color: var(--text-primary); }
.tplm-folders a.is-active { background: rgba(106,71,209,.16); color: var(--text-primary); }
.tplm-count { margin-left: auto; font: 700 11px/1 var(--font-sans); color: var(--text-muted); }
.tplm-folders a.is-active .tplm-count { color: var(--color-primary); }
.tplm-list { border-right: 1px solid var(--border-hairline); overflow: hidden; display: flex; flex-direction: column; }
.tplm-listhead { display: flex; align-items: baseline; justify-content: space-between; padding: 16px 16px 12px; border-bottom: 1px solid var(--border-hairline); }
.tplm-listhead b { font-size: 15px; } .tplm-listhead span { font-size: 12px; color: var(--text-muted); }
.tplm-item { display: flex; gap: 11px; padding: 12px 15px; border-bottom: 1px solid var(--border-hairline); border-left: 3px solid transparent; }
.tplm-item:hover { background: var(--surface-raised); }
.tplm-item.is-active { background: var(--surface-raised); border-left-color: var(--color-primary); }
.tplm-body { min-width: 0; flex: 1; }
.tplm-l1 { display: flex; justify-content: space-between; gap: 8px; }
.tplm-l1 b, .tplm-l1 span:first-child { font-size: 13.5px; color: var(--text-primary); }
.tplm-l1 > span:last-child { font-size: 11.5px; color: var(--text-muted); flex: none; }
.tplm-item.is-unread .tplm-l1 b { font-weight: 700; }
.tplm-subj { font-size: 13px; margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tplm-item.is-unread .tplm-subj { font-weight: 600; }
.tplm-prev { font-size: 12.5px; color: var(--text-muted); margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tplm-read { overflow: hidden; display: flex; flex-direction: column; padding: 22px 26px; }
.tplm-rhead h4 { font: 700 20px/1.25 var(--font-sans); letter-spacing: -.3px; }
.tplm-from { display: flex; align-items: center; gap: 10px; margin: 16px 0; padding-bottom: 16px; border-bottom: 1px solid var(--border-hairline); }
.tplm-from b { display: block; font-size: 13.5px; } .tplm-from span { font-size: 12px; color: var(--text-muted); }
.tplm-rbody { color: var(--text-secondary); overflow: hidden; }
.tplm-rbody p + p { margin-top: 12px; }
.tplm-rfoot { display: flex; gap: 8px; margin-top: auto; padding-top: 16px; }

/* ---------------------------------------------------------
   5. Project board  (top bar; the board itself is .sv-kanban)
   --------------------------------------------------------- */
.tpl--board { grid-template-rows: 60px 1fr; }
.tplb-top { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 0 22px; border-bottom: 1px solid var(--border-hairline); background: var(--surface-raised); }
.tplb-title { display: flex; align-items: center; gap: 10px; font: 700 16px/1 var(--font-sans); }
.tplb-logo { width: 24px; height: 24px; border-radius: 7px; background: var(--color-primary); color: #fff; display: grid; place-items: center; font-size: 12px; }
.tplb-tools { display: flex; align-items: center; gap: 12px; }

/* ---------------------------------------------------------
   6. Social feed
   --------------------------------------------------------- */
.tpl--social { grid-template-columns: 204px 1fr 300px; }
.tpls-nav { display: flex; flex-direction: column; gap: 3px; padding: 16px 12px; border-right: 1px solid var(--border-hairline); }
.tpls-logo { width: 34px; height: 34px; display: grid; place-items: center; margin: 0 8px 10px; }
.tpls-logo img { width: 30px; height: 30px; }
.tpls-nav nav { display: flex; flex-direction: column; gap: 3px; }
.tpls-nav nav a { display: flex; align-items: center; gap: 13px; padding: 10px 12px; border-radius: 9999px; font: 500 15px/1 var(--font-sans); color: var(--text-secondary); }
.tpls-nav nav a svg { width: 20px; height: 20px; }
.tpls-nav nav a:hover { background: var(--surface-inset); color: var(--text-primary); }
.tpls-nav nav a.is-active { color: var(--text-primary); font-weight: 700; }
.tpls-post { margin: 12px 6px; justify-content: center; }
.tpls-me { display: flex; align-items: center; gap: 9px; margin-top: auto; padding: 8px; border-radius: 9999px; }
.tpls-me:hover { background: var(--surface-inset); }
.tpls-me b { display: block; font-size: 13.5px; } .tpls-me span { font-size: 12.5px; color: var(--text-muted); }
.tpls-feed { border-right: 1px solid var(--border-hairline); overflow: hidden; }
.tpls-feedhead { padding: 12px 16px; border-bottom: 1px solid var(--border-hairline); }
.tpls-compose { display: flex; gap: 12px; padding: 16px; border-bottom: 8px solid var(--surface-raised); }
.tpls-compose > div { flex: 1; }
.tpls-compose input { width: 100%; background: none; border: 0; outline: none; color: var(--text-primary); font-size: 17px; padding: 8px 0; }
.tpls-composefoot { display: flex; align-items: center; justify-content: space-between; margin-top: 6px; }
.tpls-side { display: flex; flex-direction: column; gap: 14px; padding: 14px 16px; overflow: hidden; }
.tpls-search { display: flex; align-items: center; gap: 9px; height: 40px; padding: 0 14px; background: var(--surface-inset); border: 1px solid var(--border-hairline); border-radius: 9999px; color: var(--text-muted); }
.tpls-search svg { width: 17px; height: 17px; } .tpls-search input { flex: 1; background: none; border: 0; outline: none; color: var(--text-primary); }
.tpls-card { background: var(--surface-raised); border: 1px solid var(--border-hairline); border-radius: 14px; padding: 14px 16px; }
.tpls-card h5 { font: 700 16px/1 var(--font-sans); margin-bottom: 12px; }
.tpls-trend { padding: 7px 0; }
.tpls-trend span { font-size: 11.5px; color: var(--text-muted); display: block; }
.tpls-trend b { font-size: 14px; display: block; margin: 1px 0; } .tpls-trend i { font-style: normal; font-size: 11.5px; color: var(--text-muted); }
.tpls-follow { display: flex; align-items: center; gap: 10px; padding: 8px 0; }
.tpls-follow div { flex: 1; min-width: 0; } .tpls-follow b { display: block; font-size: 13.5px; } .tpls-follow span { font-size: 12.5px; color: var(--text-muted); }

/* ---------------------------------------------------------
   Shared: brain app-logo, icon slots, view panels
   --------------------------------------------------------- */
.tpl-logo { width: 26px; height: 26px; border-radius: 7px; background: var(--color-primary); display: grid; place-items: center; flex: none; }
.tpl-logo img { width: 16px; height: 16px; }
.tpl-ic { display: inline-flex; align-items: center; justify-content: center; flex: none; }
.tpl-ic svg { width: 17px; height: 17px; }
/* A hidden tab panel stays hidden even when its own rule sets grid/flex. */
[data-panel][hidden] { display: none !important; }
/* View heading shared by the finance and video secondary screens. */
.tplf-vhead { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 18px; }
.tplf-vhead h4 { font: 700 22px/1 var(--font-sans); letter-spacing: -.3px; }
.tplf-vsub { font-size: 12.5px; color: var(--text-muted); }

/* ---- Finance: Markets ---- */
.tplf-coin--sm { width: 18px; height: 18px; font-size: 10px; }
.tplf-mhead, .tplf-mrow { display: grid; grid-template-columns: 22px 2fr 1fr 0.8fr 1.1fr 1fr; align-items: center; gap: 10px; }
.tplf-mhead { font: 600 11.5px/1 var(--font-sans); color: var(--text-muted); padding: 0 4px 10px; }
.tplf-mrow { padding: 10px 4px; border-top: 1px solid var(--border-hairline); font-variant-numeric: tabular-nums; }
.tplf-mrow > span:first-child { color: var(--text-muted); }
.tplf-spark svg { width: 80px; height: 24px; display: block; }
.tplf-markets .tplf-r { text-align: right; }

/* ---- Finance: Trade ---- */
.tplf-trade { display: grid; grid-template-columns: 1.1fr 0.9fr; gap: 18px; align-items: start; }
.tplf-ticket { background: var(--surface-raised); border: 1px solid var(--border-hairline); border-radius: 14px; padding: 16px; display: flex; flex-direction: column; gap: 12px; }
.tplf-side { align-self: flex-start; }
.tplf-field { display: flex; flex-direction: column; gap: 6px; }
.tplf-field > span { font-size: 12px; color: var(--text-muted); }
.tplf-fieldrow { display: flex; align-items: center; gap: 10px; background: var(--surface-inset); border: 1px solid var(--border-hairline); border-radius: 10px; padding: 0 12px; height: 46px; }
.tplf-fieldrow input { flex: 1; min-width: 0; background: none; border: 0; outline: none; color: var(--text-primary); font: 700 18px/1 var(--font-sans); }
.tplf-fieldcur { display: flex; align-items: center; gap: 6px; font-weight: 600; color: var(--text-secondary); }
.tplf-swap { display: flex; justify-content: center; margin: -4px 0; }
.tplf-swap .tpl-ic { width: 30px; height: 30px; border-radius: 50%; background: var(--surface-inset); border: 1px solid var(--border-hairline); color: var(--text-secondary); }
.tplf-swap svg { width: 15px; height: 15px; }
.tplf-summary { display: flex; flex-direction: column; gap: 7px; padding-top: 2px; }
.tplf-summary div { display: flex; justify-content: space-between; font-size: 12.5px; }
.tplf-summary span { color: var(--text-muted); }
.tplf-summary b { font-variant-numeric: tabular-nums; }
.tplf-review { justify-content: center; }
.tplf-book { background: var(--surface-raised); border: 1px solid var(--border-hairline); border-radius: 14px; padding: 14px; }
.tplf-bookhead { display: flex; justify-content: space-between; font: 600 12px/1 var(--font-sans); color: var(--text-muted); margin-bottom: 10px; }
.tplf-bookrows { display: flex; flex-direction: column; gap: 5px; }
.tplf-bookrow { display: grid; grid-template-columns: 1fr 1fr 1fr; font: 500 12px/1 var(--font-sans); font-variant-numeric: tabular-nums; }
.tplf-bookrow .tplf-r { text-align: right; color: var(--text-muted); }
.tplf-bookmid { display: flex; align-items: center; gap: 8px; font: 700 15px/1 var(--font-sans); padding: 9px 0; margin: 6px 0; border-top: 1px solid var(--border-hairline); border-bottom: 1px solid var(--border-hairline); font-variant-numeric: tabular-nums; }
.tplf-bookmid .tplf-up { font-size: 12px; }

/* ---- Finance: Earn ---- */
.tplf-earn { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.tplf-ecard { background: var(--surface-raised); border: 1px solid var(--border-hairline); border-radius: 14px; padding: 16px; display: flex; flex-direction: column; gap: 12px; }
.tplf-etop { display: flex; align-items: center; gap: 10px; }
.tplf-etop > div { display: flex; flex-direction: column; }
.tplf-etop b { font-size: 14px; }
.tplf-etop i { font-style: normal; font-size: 11.5px; color: var(--text-muted); }
.tplf-eicon { width: 38px; height: 38px; border-radius: 10px; background: var(--surface-inset); border: 1px solid var(--border-hairline); color: var(--color-primary); }
.tplf-eicon svg { width: 20px; height: 20px; }
.tplf-apy { display: flex; align-items: baseline; gap: 6px; font: 700 30px/1 var(--font-sans); color: var(--green-500); }
.tplf-apy span { font-size: 12px; color: var(--text-muted); font-weight: 600; }
.tplf-ecard .sv-btn { margin-top: auto; }
.tplf-ecard--wide { grid-column: span 3; flex-direction: row; align-items: center; justify-content: space-between; }
.tplf-ecard--wide .sv-btn { margin: 0; }

/* ---- Finance: Activity ---- */
.tplf-acts { display: flex; flex-direction: column; }
.tplf-act { display: flex; align-items: center; gap: 12px; padding: 13px 4px; border-top: 1px solid var(--border-hairline); }
.tplf-act:first-child { border-top: 0; }
.tplf-actic { width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center; flex: none; }
.tplf-actic svg { width: 18px; height: 18px; }
.tplf-actic--in { background: rgba(46, 160, 92, .16); color: var(--green-500); }
.tplf-actic--out { background: var(--surface-inset); color: var(--text-secondary); }
.tplf-actic--trade { background: rgba(106, 71, 209, .18); color: var(--purple-400); }
.tplf-actic--rew { background: rgba(23, 145, 148, .18); color: var(--teal-500); }
.tplf-actbody { flex: 1; }
.tplf-actbody b { display: block; font-size: 13.5px; }
.tplf-actbody i { font-style: normal; font-size: 12px; color: var(--text-muted); }
.tplf-actamt { text-align: right; }
.tplf-actamt b { display: block; font-size: 13.5px; font-variant-numeric: tabular-nums; }
.tplf-actamt i { font-style: normal; font-size: 11.5px; color: var(--text-muted); }

/* ---- Video: secondary screens ---- */
.tplv-vh { font: 700 17px/1 var(--font-sans); margin-bottom: 14px; }
.tplv-trend, .tplv-watch { display: flex; flex-direction: column; gap: 12px; }
.tplv-trow, .tplv-wrow { display: flex; align-items: center; gap: 14px; }
.tplv-rank { width: 20px; flex: none; text-align: center; font: 700 20px/1 var(--font-sans); color: var(--text-muted); }
.tplv-tthumb { position: relative; width: 150px; flex: none; aspect-ratio: 16/9; border-radius: 10px; overflow: hidden; background: var(--surface-inset); }
.tplv-tthumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.tplv-tmeta { flex: 1; min-width: 0; }
.tplv-tmeta b { display: block; font-size: 14px; line-height: 1.3; }
.tplv-tmeta span { font-size: 12px; color: var(--text-muted); }
.tplv-new { position: absolute; left: 8px; top: 8px; background: var(--color-primary); color: #fff; font: 700 10px/1 var(--font-sans); font-style: normal; padding: 3px 6px; border-radius: 5px; }
.tplv-wrow .tplv-tthumb { width: 160px; }
.tplv-wremove { background: none; border: 0; color: var(--text-muted); cursor: pointer; padding: 6px; border-radius: 8px; }
.tplv-wremove:hover { background: var(--surface-inset); color: var(--text-primary); }
.tplv-wremove svg { width: 18px; height: 18px; }
.tplv-libsec { margin-bottom: 22px; }
.tplv-libhead { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.tplv-libhead .tplv-vh { margin: 0; }
.tplv-seeall { font: 600 12.5px/1 var(--font-sans); color: var(--color-primary); }
.tplv-hrow { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); gap: 14px; }
.tplv-hcard b, .tplv-plcard b { display: block; font-size: 13px; line-height: 1.3; margin-top: 8px; }
.tplv-plcard span { font-size: 12px; color: var(--text-muted); }
.tplv-hcard .tplv-thumb, .tplv-plcard .tplv-thumb { aspect-ratio: 16/9; }
.tplv-plcount { position: absolute; right: 8px; bottom: 8px; display: flex; align-items: center; gap: 5px; background: rgba(0,0,0,.78); color: #fff; font: 600 11px/1 var(--font-sans); font-style: normal; padding: 3px 7px; border-radius: 5px; }
.tplv-plcount svg { width: 12px; height: 12px; }

/* ---- Chat: brand, thread stack, empty state ---- */
.tplc-brand { display: flex; align-items: center; gap: 9px; font: 700 15px/1 var(--font-sans); padding: 2px 6px 14px; }
.tplc-threads { flex: 1; display: flex; flex-direction: column; overflow: hidden; }
.tplc-empty { align-items: center; justify-content: center; text-align: center; gap: 14px; }
.tplc-emptylogo { width: 52px; height: 52px; border-radius: 15px; background: var(--color-primary); display: grid; place-items: center; }
.tplc-emptylogo img { width: 30px; height: 30px; }
.tplc-empty h4 { font: 700 22px/1 var(--font-sans); }
.tplc-empty p { color: var(--text-muted); font-size: 13.5px; max-width: 340px; }
.tplc-suggest { display: flex; flex-direction: column; gap: 8px; width: 100%; max-width: 384px; margin-top: 4px; }
.tplc-chip { display: flex; align-items: center; gap: 10px; text-align: left; padding: 12px 14px; border: 1px solid var(--border-hairline); border-radius: 11px; background: var(--surface-raised); color: var(--text-secondary); font: 500 13px/1.3 var(--font-sans); cursor: pointer; }
.tplc-chip:hover { background: var(--surface-inset); color: var(--text-primary); }
.tplc-chip svg { width: 16px; height: 16px; color: var(--color-primary); }

/* ---- Email: brand, per-folder two-pane views ---- */
/* Folders now host their own list + reader, so the app frame is rail + view. */
.tpl--mail { grid-template-columns: 182px 1fr; }
.tplm-brand { display: flex; align-items: center; gap: 9px; font: 700 15px/1 var(--font-sans); padding: 2px 6px 14px; }
.tplm-folder { display: grid; grid-template-columns: 300px 1fr; overflow: hidden; }
.tplm-draft { color: var(--red-400); font-weight: 700; }
.sv-avatar--ghost { display: grid; place-items: center; background: var(--surface-inset); color: var(--text-muted); }
.sv-avatar--ghost svg { width: 15px; height: 15px; }
.tplm-compose-fields { display: flex; flex-direction: column; margin: 8px 0 4px; }
.tplm-cfield { display: flex; align-items: center; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--border-hairline); }
.tplm-cfield span { width: 52px; flex: none; font-size: 12px; color: var(--text-muted); }
.tplm-cfield input { flex: 1; min-width: 0; background: none; border: 0; outline: none; color: var(--text-primary); font: inherit; }
.tplm-cbody { margin-top: 14px; }

/* ---- Board: brand, view host, timeline, list ---- */
.tplb-logo img { width: 15px; height: 15px; }
.tplb-view { height: 100%; overflow: hidden; }
.tplb-view > .sv-kanban { height: 100%; }
.tplb-timeline, .tplb-list { height: 100%; overflow: auto; padding: 16px 22px; }
.tplb-tlhead, .tplb-tlrow { display: grid; grid-template-columns: 200px repeat(5, 1fr); align-items: center; }
.tplb-tlhead { padding-bottom: 10px; border-bottom: 1px solid var(--border-hairline); font: 600 12px/1 var(--font-sans); color: var(--text-muted); }
.tplb-tlhead span { text-align: center; }
.tplb-tlhead .tplb-tllabel { text-align: left; }
.tplb-tlrow { padding: 9px 0; border-bottom: 1px solid var(--border-hairline); }
.tplb-tllabel { display: flex; align-items: center; gap: 8px; padding-right: 12px; font-size: 12.5px; }
.tplb-bar { height: 26px; border-radius: 7px; display: flex; align-items: center; padding: 0 6px; margin: 0 3px; }
.tplb-bar img { width: 20px; height: 20px; border-radius: 50%; object-fit: cover; margin-left: auto; box-shadow: 0 0 0 2px rgba(0,0,0,.25); }
.tplb-bar--primary { background: var(--purple-500); }
.tplb-bar--teal { background: var(--teal-600); }
.tplb-bar--amber { background: var(--amber-500); }
.tplb-bar--red { background: var(--red-500); }
.tplb-bar--grey { background: var(--grey-500); }
.tplb-lhead, .tplb-lrow { display: grid; grid-template-columns: 80px 2.2fr 1fr 0.9fr 60px; align-items: center; gap: 12px; }
.tplb-lhead { padding: 12px 4px; border-bottom: 1px solid var(--border-hairline); font: 600 11.5px/1 var(--font-sans); color: var(--text-muted); }
.tplb-lhead .tplb-r { text-align: right; }
.tplb-lrow { padding: 12px 4px; border-bottom: 1px solid var(--border-hairline); }
.tplb-ltitle { font-size: 13.5px; }
.tplb-pri { font: 600 12.5px/1 var(--font-sans); }
.tplb-pri--hi { color: var(--red-500); }
.tplb-pri--md { color: var(--amber-500); }
.tplb-pri--lo { color: var(--text-muted); }
.tplb-lrow .tplb-r { display: flex; justify-content: flex-end; }

/* ---- Social: explore, notifications, messages, profile ---- */
.tpls-vh { font: 700 16px/1 var(--font-sans); padding: 14px 16px 6px; }
.tpls-feedhead--plain { padding: 14px 16px; font: 700 16px/1 var(--font-sans); }
.tpls-explore { border-bottom: 8px solid var(--surface-raised); padding-bottom: 6px; }
.tpls-topic { display: block; padding: 11px 16px; border-bottom: 1px solid var(--border-hairline); }
.tpls-topic:hover { background: var(--surface-raised); }
.tpls-topic span { display: block; font-size: 11.5px; color: var(--text-muted); }
.tpls-topic b { display: block; margin: 2px 0; font-size: 14.5px; }
.tpls-topic i { font-style: normal; font-size: 11.5px; color: var(--text-muted); }
.tpls-notif { display: flex; gap: 12px; padding: 14px 16px; border-bottom: 1px solid var(--border-hairline); }
.tpls-notif-ic { width: 24px; flex: none; display: flex; justify-content: center; padding-top: 2px; }
.tpls-notif-ic svg { width: 20px; height: 20px; }
.tpls-notif-ic--like { color: var(--red-500); }
.tpls-notif-ic--follow { color: var(--color-primary); }
.tpls-notif-ic--reply { color: var(--teal-500); }
.tpls-notif-ic--repost { color: var(--green-500); }
.tpls-notif > div { flex: 1; min-width: 0; }
.tpls-notif .sv-avatar { margin-bottom: 8px; }
.tpls-notif p { font-size: 13.5px; }
.tpls-notif-sub { display: block; margin-top: 2px; font-size: 12.5px; color: var(--text-muted); }
.tpls-dm { display: flex; align-items: center; gap: 12px; padding: 13px 16px; border-bottom: 1px solid var(--border-hairline); }
.tpls-dm:hover { background: var(--surface-raised); }
.tpls-dmbody { flex: 1; min-width: 0; }
.tpls-dml1 { display: flex; justify-content: space-between; gap: 8px; }
.tpls-dml1 b { font-size: 13.5px; }
.tpls-dml1 span { font-size: 11.5px; color: var(--text-muted); }
.tpls-dmbody p { margin-top: 2px; font-size: 12.5px; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tpls-profile { border-bottom: 8px solid var(--surface-raised); }
.tpls-banner { height: 92px; background: linear-gradient(120deg, var(--purple-700), var(--teal-700)); }
.tpls-phead { display: flex; align-items: flex-end; justify-content: space-between; padding: 0 16px; margin-top: -32px; }
.tpls-pavatar { box-shadow: 0 0 0 4px var(--surface-page); }
.tpls-pedit { margin-bottom: 4px; }
.tpls-pname { padding: 10px 16px 0; }
.tpls-pname b { display: block; font: 700 18px/1.2 var(--font-sans); }
.tpls-pname span { font-size: 13px; color: var(--text-muted); }
.tpls-pbio { padding: 8px 16px 0; font-size: 13.5px; color: var(--text-secondary); }
.tpls-pstats { display: flex; gap: 18px; padding: 12px 16px 16px; font-size: 13px; color: var(--text-muted); }
.tpls-pstats b { color: var(--text-primary); }

/* Templates collapse gracefully on narrow screens */
@media (max-width: 900px) {
  .tpl { height: auto; min-height: 480px; }
  .tpl--fin, .tpl--chat { grid-template-columns: 1fr; }
  .tpl--mail { grid-template-columns: 1fr; }
  .tpl--mail .tplm-read, .tplf-rail, .tplc-rail, .tplm-rail { display: none; }
  .tplm-folder { grid-template-columns: 1fr; }
  .tplf-trade, .tplf-earn { grid-template-columns: 1fr; }
  .tplf-ecard--wide { grid-column: auto; }
  .tpl--social { grid-template-columns: 1fr; }
  .tpls-nav, .tpls-side { display: none; }
  .tplv-body { grid-template-columns: 1fr; } .tplv-side { display: none; }
  .tplv-grid { grid-template-columns: 1fr; }
}
