/* Templates library: entry details (.tl-*), the "Start from a template" panel (.tp-*,
   components/template-picker.js) and the /templates pages (.tpl-*, public and in-app).
   Theme tokens only, so it reads right in light and dark. */

/* ── entry details ── */
.tl-entry { min-width: 0; }
.tl-entry__title { font-size: 1.25rem; letter-spacing: -0.01em; margin: 0 0 0.5rem; }
.tl-sub { font-size: 0.9375rem; margin: 1.25rem 0 0.5rem; }
.tl-entry p, .tl-panel p { line-height: 1.6; margin: 0 0 0.75rem; }
.tl-muted { color: var(--fg-muted); }
.tl-note { color: var(--fg-muted); font-size: 0.875rem; }
.tl-facts { display: grid; gap: 0.5rem 1rem; grid-template-columns: repeat(auto-fill, minmax(min(100%, 13rem), 1fr)); margin: 0.75rem 0; }
.tl-facts div { min-width: 0; }
.tl-facts dt { font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--fg-muted); }
.tl-facts dd { margin: 0.15rem 0 0; overflow-wrap: anywhere; }
.tl-compare { display: grid; gap: 0.5rem; margin: 0 0 0.75rem; }
.tl-compare p { margin: 0; padding: 0.6rem 0.8rem; border-radius: 8px; border: 1px solid var(--border); }
.tl-compare span { display: block; font-size: 0.75rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em; color: var(--fg-muted); }
.tl-weak { text-decoration: line-through; text-decoration-color: var(--fg-muted); color: var(--fg-muted); }
.tl-weak span { text-decoration: none; display: block; }
.tl-good { border-color: var(--primary) !important; font-weight: 600; }
.tl-ms, .tl-agenda, .tl-outcomes, .tl-comps { margin: 0; padding-left: 1.3rem; display: grid; gap: 0.5rem; }
.tl-ms li, .tl-comps li { display: flex; justify-content: space-between; gap: 1rem; flex-wrap: wrap; }
.tl-comps { list-style: disc; }
.tl-outcomes li { display: flex; flex-direction: column; gap: 0.15rem; }
.tl-agenda__row { display: flex; justify-content: space-between; gap: 1rem; font-weight: 600; }
.tl-agenda p { margin: 0.15rem 0 0; color: var(--fg-muted); font-size: 0.9375rem; }
.tl-theme { font-size: 0.75rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em; color: var(--primary-text, var(--primary)); }
.tl-callout { padding: 0.75rem 1rem; border-left: 3px solid var(--primary); background: var(--bg-muted, transparent); border-radius: 0 8px 8px 0; }
.tl-prompts li { margin: 0.25rem 0; }
.tl-table { width: 100%; border-collapse: collapse; margin: 0 0 1rem; font-size: 0.9375rem; }
.tl-table th, .tl-table td { text-align: left; vertical-align: top; padding: 0.5rem; border-bottom: 1px solid var(--border); }

/* ── shared controls ── */
.tp-controls { display: grid; gap: 0.5rem; grid-template-columns: minmax(0, 1fr); margin-bottom: 0.75rem; }
.tp-controls--row { grid-template-columns: minmax(0, 2fr) repeat(auto-fit, minmax(10rem, 1fr)); }
@media (max-width: 640px) { .tp-controls--row { grid-template-columns: minmax(0, 1fr); } }
.tp-field { display: flex; flex-direction: column; gap: 0.25rem; font-size: 0.875rem; color: var(--fg-muted); min-width: 0; }
.tp-field input, .tp-field select {
  font: inherit; font-size: 0.9375rem; color: var(--fg); background: var(--bg-elevated);
  min-height: 40px; box-sizing: border-box; padding: 0 0.7rem; width: 100%;
  border: 1px solid var(--border-strong, var(--border)); border-radius: 8px;
}
.tp-field input:focus-visible, .tp-field select:focus-visible { outline: 2px solid var(--focus-ring, var(--primary)); outline-offset: 1px; }
.tp-count { font-size: 0.875rem; color: var(--fg-muted); margin: 0 0 0.5rem; }
.tp-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 0.5rem; }
.tp-item {
  display: flex; flex-direction: column; gap: 0.2rem; width: 100%; text-align: left; box-sizing: border-box;
  font: inherit; color: var(--fg); background: var(--bg-elevated); cursor: pointer;
  padding: 0.7rem 0.85rem; border: 1px solid var(--border); border-radius: 10px; text-decoration: none;
}
.tp-item:hover { border-color: var(--primary); }
.tp-item:focus-visible { outline: 2px solid var(--focus-ring, var(--primary)); outline-offset: 2px; }
.tp-item__title { font-weight: 600; }
.tp-item__sum { color: var(--fg-muted); font-size: 0.875rem; line-height: 1.45; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.tp-item__tag { font-size: 0.75rem; color: var(--fg-muted); }
.tp-btn {
  font: inherit; font-weight: 600; min-height: 40px; padding: 0 1rem; border-radius: 8px; cursor: pointer;
  color: var(--primary-fg, #fff); background: var(--primary); border: 1px solid var(--primary); text-decoration: none;
  display: inline-flex; align-items: center; justify-content: center;
}
.tp-btn:hover { background: var(--primary-hover, var(--primary)); }
.tp-btn--quiet { color: var(--fg); background: transparent; border-color: var(--border-strong, var(--border)); }
.tp-btn--quiet:hover { background: var(--hover, transparent); }
.tp-btn:focus-visible { outline: 2px solid var(--focus-ring, var(--primary)); outline-offset: 2px; }
.tp-link { font: inherit; background: none; border: 0; padding: 0; cursor: pointer; color: var(--primary-text, var(--primary)); text-decoration: underline; text-underline-offset: 2px; min-height: 24px; }
.tp-link:focus-visible { outline: 2px solid var(--focus-ring, var(--primary)); outline-offset: 2px; }

/* ── picker panel (inside <lc-sheet>) ── */
.tp-panel { font-size: 0.9375rem; color: var(--fg); }
.tp-panel .tl-entry__title { font-size: 1.125rem; }
.tp-preview-head { display: flex; justify-content: space-between; align-items: center; gap: 0.5rem; margin-bottom: 0.75rem; }
.tp-actions {
  position: sticky; bottom: calc(-1 * var(--space-5, 20px)); margin: 1rem calc(-1 * var(--space-6, 24px)) calc(-1 * var(--space-5, 20px));
  padding: 0.75rem var(--space-6, 24px); background: var(--bg-elevated); border-top: 1px solid var(--border);
  display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: center; justify-content: space-between;
}
.tp-actions p { margin: 0; font-size: 0.8125rem; color: var(--fg-muted); flex: 1 1 12rem; }

/* the "Start from a template" button inside forms */
.tp-start { display: flex; align-items: center; justify-content: space-between; gap: 0.5rem; flex-wrap: wrap; padding: 0.55rem 0.75rem; border: 1px dashed var(--border-strong, var(--border)); border-radius: 8px; font-size: 0.875rem; color: var(--fg-muted); }
.tp-start [data-tpl-note]:empty { display: none; }

/* ── /templates pages ── */
.tpl { padding-top: clamp(1.5rem, 4vw, 3rem); padding-bottom: 4rem; }
.tpl-head { max-width: 46rem; margin-bottom: 2rem; }
.tpl-head h1 { font-size: clamp(1.8rem, 4vw, 2.5rem); line-height: 1.15; letter-spacing: -0.03em; margin: 0 0 0.75rem; }
.tpl-lede { color: var(--fg-muted); font-size: 1.0625rem; line-height: 1.6; margin: 0 0 1rem; }
.tpl-cards { list-style: none; margin: 0 0 2rem; padding: 0; display: grid; gap: 0.75rem; grid-template-columns: repeat(auto-fill, minmax(min(100%, 16rem), 1fr)); }
.tpl-chips { list-style: none; margin: 0 0 1.5rem; padding: 0; display: flex; flex-wrap: wrap; gap: 0.5rem; }
.tpl-chips a { display: inline-flex; align-items: center; min-height: 32px; padding: 0 0.75rem; border: 1px solid var(--border); border-radius: 999px; color: var(--fg); text-decoration: none; font-size: 0.875rem; }
.tpl-chips a[aria-current="page"] { border-color: var(--primary); color: var(--primary-text, var(--primary)); font-weight: 600; }
.tpl-chips a:focus-visible { outline: 2px solid var(--focus-ring, var(--primary)); outline-offset: 2px; }
.tpl-entries { display: grid; gap: 1rem; }
.tpl-entries > .tl-entry { padding: 1.1rem 1.2rem; border: 1px solid var(--border); border-radius: 12px; background: var(--bg-elevated); }
.tpl-use { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-top: 0.75rem; }
.tpl-crumbs ol { list-style: none; display: flex; flex-wrap: wrap; gap: 0.5rem; margin: 0 0 1.25rem; padding: 0; font-size: 0.875rem; }
.tpl-crumbs li + li::before { content: '›'; margin-right: 0.5rem; color: var(--fg-muted); }
.tpl-crumbs a { color: var(--fg-muted); }
.tpl-cta { margin-top: 2.5rem; padding: 1.25rem; border: 1px solid var(--border); border-radius: 12px; }
.tpl-cta h2 { margin: 0 0 0.5rem; font-size: 1.125rem; }

/* in-app browser: list beside preview on wide screens */
.tpl-app { max-width: 1180px; margin: 0 auto; padding: var(--space-6, 24px); }
.tpl-app h1 { font-size: var(--text-2xl, 1.5rem); margin: 0; }
.tpl-tabs { display: flex; flex-wrap: wrap; gap: 0.25rem; margin: 1rem 0; padding: 0; list-style: none; }
.tpl-tabs a { display: inline-flex; align-items: center; min-height: 36px; padding: 0 0.85rem; border-radius: 999px; color: var(--fg-muted); text-decoration: none; font-size: 0.875rem; }
.tpl-tabs a[aria-current="page"] { background: var(--bg-muted, var(--hover)); color: var(--fg); font-weight: 600; }
.tpl-tabs a:focus-visible { outline: 2px solid var(--focus-ring, var(--primary)); outline-offset: 2px; }
.tpl-split { display: grid; gap: 1.25rem; grid-template-columns: minmax(0, 22rem) minmax(0, 1fr); align-items: start; }
.tpl-split .tp-list { max-height: 70vh; overflow-y: auto; padding: 2px; }
.tpl-split .tp-item[aria-current="true"] { border-color: var(--primary); box-shadow: 0 0 0 1px var(--primary); }
.tpl-detail { padding: 1.1rem 1.2rem; border: 1px solid var(--border); border-radius: 12px; background: var(--bg-elevated); position: sticky; top: 1rem; }
@media (max-width: 900px) {
  .tpl-app { padding: var(--space-4, 16px); }
  .tpl-split { grid-template-columns: minmax(0, 1fr); }
  .tpl-split .tp-list { max-height: none; }
  .tpl-detail { position: static; }
}
