/* ==========================================================================
   Torah Book — component library (class-name contract for map-core blocks).
   Documented in projects/map/context/design-system.md. RTL-first: logical
   properties only (inline-start = right in Hebrew).
   ========================================================================== */

/* ---- Card ------------------------------------------------------------------ */
.tb-card {
	position: relative; display: flex; flex-direction: column; gap: 12px;
	background: var(--tb-surface); color: var(--tb-ink);
	border: 1px solid var(--tb-border); border-radius: var(--tb-r-lg);
	padding: 20px; box-shadow: var(--tb-shadow-sm);
	transition: box-shadow var(--tb-base) var(--tb-ease), transform var(--tb-base) var(--tb-ease), border-color var(--tb-base);
	min-width: 0;
}
@media (min-width: 640px) { .tb-card { padding: 24px; } }
.tb-card--link { cursor: pointer; }
@media (hover: hover) { .tb-card--link:hover, a.tb-card:hover, .tb-card:has(.tb-card__title a):hover { box-shadow: var(--tb-shadow-md); transform: translateY(-2px); border-color: color-mix(in srgb, var(--tb-border), var(--tb-accent) 30%); } }
.tb-card--link:active, a.tb-card:active, .tb-card:has(.tb-card__title a):active, .tb-path:active { transform: scale(.985); transition-duration: 80ms; }
a.tb-card { text-decoration: none; }
.tb-card__head { display: flex; align-items: center; gap: 12px; }
.tb-card__icon {
	display: grid; place-items: center; width: 40px; height: 40px; flex: none;
	border-radius: 12px; background: var(--tb-primary-soft); color: var(--tb-primary);
}
.tb-card__icon .tb-icon { width: 22px; height: 22px; }
.tb-card__kicker { margin: 0; font-size: .8125rem; font-weight: 600; color: var(--tb-muted); letter-spacing: .01em; }
.tb-card__title { margin: 0; font-family: var(--tb-serif); font-weight: 700; font-size: 1.375rem; line-height: 1.3; color: var(--tb-ink); }
.tb-card__title a { color: inherit; text-decoration: none; }
.tb-card__title a::after { content: ""; position: absolute; inset: 0; border-radius: inherit; } /* stretched link */
.tb-card__body { margin: 0; color: var(--tb-muted); font-size: 1.0625rem; line-height: 1.7; }
@media (min-width: 960px) { .tb-card__body { font-size: 1rem; } }
.tb-card__foot { margin-top: auto; padding-top: 4px; display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.tb-card__more { margin-inline-start: auto; display: inline-flex; align-items: center; gap: 4px; font-weight: 600; font-size: .9375rem; color: var(--tb-primary); text-decoration: none; }
.tb-card__more .tb-icon { width: 18px; height: 18px; transition: transform var(--tb-fast) var(--tb-ease); }
.tb-card:hover .tb-card__more .tb-icon, .tb-card__more:hover .tb-icon { transform: translateX(-3px); }
/* category tints */
.tb-card--sage .tb-card__icon { background: var(--tb-sage-soft); color: var(--tb-sage); }
.tb-card--clay .tb-card__icon { background: var(--tb-clay-soft); color: var(--tb-clay); }
.tb-card--gold .tb-card__icon { background: var(--tb-accent-soft); color: var(--tb-accent-ink); }
.tb-card--flat { box-shadow: none; background: var(--tb-surface-2); border-color: transparent; }

/* Feature card — ink-blue, gold detail */
.tb-card--feature {
	background: var(--tb-feature-bg); color: var(--tb-feature-ink); border-color: transparent;
	box-shadow: var(--tb-shadow-md); overflow: hidden; isolation: isolate;
}
.tb-card--feature {
	background: linear-gradient(155deg, color-mix(in srgb, var(--tb-feature-bg), #fff 9%) 0%, var(--tb-feature-bg) 55%, color-mix(in srgb, var(--tb-feature-bg), #000 18%) 100%);
}
.tb-card--feature::before { /* gold hairline crown */
	content: ""; position: absolute; z-index: -1; inset-inline: 24px; top: 0; height: 2px; border-radius: 0 0 2px 2px;
	background: linear-gradient(90deg, transparent, rgb(217 174 95 / .85), transparent);
}
.tb-card--feature::after { /* faint arc, like a page edge */
	content: ""; position: absolute; z-index: -1; inset-inline-end: -90px; top: -150px; width: 300px; height: 300px; border-radius: 50%;
	border: 1px solid rgb(217 174 95 / .11); box-shadow: 0 0 0 28px rgb(217 174 95 / .025), 0 0 0 56px rgb(217 174 95 / .015);
}
.tb-card--feature .tb-card__title { color: var(--tb-feature-ink); }
.tb-card--feature .tb-card__kicker, .tb-card--feature .tb-card__body { color: var(--tb-feature-muted); }
.tb-card--feature .tb-card__icon { background: rgb(217 174 95 / .16); color: #E3BD77; }
.tb-card--feature .tb-card__more { color: #E3BD77; }
.tb-card--feature .tb-btn--ghost { color: var(--tb-feature-ink); border-color: rgb(255 255 255 / .25); }
.tb-card--feature .tb-btn--ghost:hover { background: rgb(255 255 255 / .08); }

/* ---- Grid + slots (front page) ------------------------------------------ */
.tb-grid { display: grid; gap: 16px; grid-template-columns: minmax(0, 1fr); }
@media (min-width: 720px) { .tb-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; } }
@media (min-width: 1100px) { .tb-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 24px; } }
.tb-slot { display: flex; flex-direction: column; min-width: 0; }
.tb-slot > * { flex: 1 1 auto; }
.tb-slot:empty { display: none; }
.tb-slot--wide { grid-column: 1 / -1; }
@media (min-width: 1100px) { .tb-slot--two { grid-column: span 2; } }
.tb-section-head { display: flex; align-items: end; justify-content: space-between; gap: 16px; margin: 0 0 16px; }
.tb-section-head h2 { margin: 0; font-size: 1.5rem; }

/* Skeleton (loading state for mounted blocks) */
.tb-skel { display: block; height: .9em; border-radius: 6px; background: linear-gradient(90deg, var(--tb-surface-2) 0, color-mix(in srgb, var(--tb-surface-2), var(--tb-surface) 60%) 50%, var(--tb-surface-2) 100%); background-size: 200% 100%; animation: tb-shimmer 1.6s linear infinite; }
.tb-skel + .tb-skel { margin-top: 10px; }
.tb-skel--title { height: 1.4em; width: 55%; }
.tb-skel--w80 { width: 80%; } .tb-skel--w60 { width: 60%; } .tb-skel--w40 { width: 40%; }
.tb-card--feature .tb-skel { background: rgb(255 255 255 / .1); animation: none; }
@keyframes tb-shimmer { to { background-position: -200% 0; } }

/* Zmanim strip (inside today card) */
.tb-zmanim { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1px; margin: 4px 0 0; padding: 0; list-style: none; border-radius: var(--tb-r-md); overflow: hidden; background: rgb(255 255 255 / .1); border: 1px solid rgb(255 255 255 / .1); }
.tb-zmanim li { padding: 12px 14px; background: color-mix(in srgb, var(--tb-feature-bg), #000 8%); display: flex; flex-direction: column; gap: 2px; }
.tb-zmanim dt, .tb-zmanim__label { font-size: .8125rem; color: var(--tb-feature-muted); }
.tb-zmanim dd, .tb-zmanim__time { margin: 0; font-size: 1.25rem; font-weight: 600; font-variant-numeric: tabular-nums; color: var(--tb-feature-ink); direction: ltr; text-align: end; unicode-bidi: isolate; }
.tb-zmanim li.is-next { background: color-mix(in srgb, var(--tb-feature-bg), #fff 7%); box-shadow: inset 0 2px 0 #D9AE5F; }
.tb-zmanim li.is-next .tb-zmanim__label { color: #E3BD77; }
.tb-zmanim__time.is-loading { color: transparent; position: relative; }
.tb-zmanim__time.is-loading::after { content: ""; position: absolute; inset-inline-end: 0; top: 50%; width: 3.2em; height: .62em; margin-top: -.31em; border-radius: 4px; background: rgb(255 255 255 / .12); }
@media (min-width: 720px) { .tb-zmanim { grid-template-columns: repeat(6, minmax(0, 1fr)); } }

/* ---- Chips (posture / voice / minyan) ----------------------------------- */
.tb-chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 0; padding: 0; list-style: none; }
.tb-chip {
	display: inline-flex; align-items: center; gap: 5px; height: 28px; padding-inline: 9px 11px;
	border-radius: var(--tb-r-pill); border: 1px solid transparent;
	background: var(--tb-surface-2); color: var(--tb-ink);
	font-size: .8125rem; font-weight: 600; line-height: 1; white-space: nowrap;
}
.tb-chip .tb-icon { width: 16px; height: 16px; }
.tb-chip--stand  { background: var(--tb-primary-soft); color: var(--tb-primary); }
.tb-chip--sit    { background: var(--tb-sage-soft); color: var(--tb-sage); }
.tb-chip--bow    { background: var(--tb-accent-soft); color: var(--tb-accent-ink); }
.tb-chip--aloud  { background: var(--tb-clay-soft); color: var(--tb-clay); }
.tb-chip--silent { background: transparent; color: var(--tb-muted); border-color: var(--tb-border); }
.tb-chip--minyan { background: transparent; color: var(--tb-primary); border: 1px dashed color-mix(in srgb, var(--tb-primary), transparent 45%); }
.tb-chip--sm { height: 24px; font-size: .75rem; padding-inline: 7px 9px; }

/* ---- Buttons ------------------------------------------------------------- */
.tb-btn {
	display: inline-flex; align-items: center; justify-content: center; gap: 8px;
	min-height: 48px; padding: 0 22px; border-radius: var(--tb-r-pill); position: relative;
	font: 600 .9375rem/1 var(--tb-sans); text-decoration: none; white-space: nowrap; cursor: pointer;
	border: 1px solid transparent; transition: background-color var(--tb-fast), color var(--tb-fast), border-color var(--tb-fast), transform var(--tb-fast);
}
.tb-btn:active { transform: scale(.97); }
.tb-btn--sm::after, .tb-chip-btn::after { content: ""; position: absolute; inset: -4px; } /* 48px hit area */
.tb-btn .tb-icon { width: 18px; height: 18px; }
.tb-btn--primary { background: var(--tb-primary); color: var(--tb-on-primary); }
.tb-btn--primary:hover { background: color-mix(in srgb, var(--tb-primary), #000 14%); }
:root[data-theme="dark"] .tb-btn--primary:hover { background: color-mix(in srgb, var(--tb-primary), #fff 14%); }
.tb-btn--gold { background: var(--tb-accent); color: #1B1405; }
.tb-btn--gold:hover { background: color-mix(in srgb, var(--tb-accent), #fff 12%); }
.tb-btn--ghost { background: transparent; color: var(--tb-ink); border-color: var(--tb-border); }
.tb-btn--ghost:hover { background: var(--tb-hover); border-color: color-mix(in srgb, var(--tb-border), var(--tb-ink) 18%); }
.tb-btn--sm { min-height: 40px; padding: 0 16px; font-size: .875rem; }
.tb-btn--lg { min-height: 52px; padding: 0 26px; font-size: 1rem; }
.tb-btn--block { width: 100%; }
.tb-btn[disabled], .tb-btn[aria-disabled="true"] { opacity: .5; pointer-events: none; }

/* ---- Tabs ------------------------------------------------------------------ */
.tb-tabs { display: flex; gap: 4px; overflow-x: auto; scroll-snap-type: x proximity; scrollbar-width: none; border-block-end: 1px solid var(--tb-border); margin: 0 0 20px; padding: 0; list-style: none; }
.tb-tabs::-webkit-scrollbar { display: none; }
.tb-tabs__tab {
	position: relative; flex: none; display: inline-flex; align-items: center; min-height: 48px; padding: 0 14px; border: 0; background: none; cursor: pointer; scroll-snap-align: start;
	font: 500 .9375rem/1.2 var(--tb-sans); color: var(--tb-muted); text-decoration: none; white-space: nowrap;
	transition: color var(--tb-fast);
}
.tb-tabs__tab:hover { color: var(--tb-ink); }
.tb-tabs__tab[aria-selected="true"], .tb-tabs__tab.is-active { color: var(--tb-ink); font-weight: 700; }
.tb-tabs__tab[aria-selected="true"]::after, .tb-tabs__tab.is-active::after {
	content: ""; position: absolute; inset-inline: 10px; bottom: -1px; height: 2.5px; border-radius: 2px; background: var(--tb-accent);
}
.tb-tabs--pills { border: 0; gap: 8px; }
.tb-tabs--pills .tb-tabs__tab { border-radius: var(--tb-r-pill); min-height: 44px; padding: 0 16px; background: var(--tb-surface); border: 1px solid var(--tb-border); }
.tb-tabs--pills .tb-tabs__tab[aria-selected="true"] { background: var(--tb-ink); color: var(--tb-bg); border-color: var(--tb-ink); }
.tb-tabs--pills .tb-tabs__tab[aria-selected="true"]::after { display: none; }

/* ---- Toggle (segmented — nusach switch) ---------------------------------- */
.tb-toggle { display: inline-flex; padding: 4px; gap: 2px; border-radius: var(--tb-r-pill); background: var(--tb-surface-2); border: 1px solid var(--tb-border); }
.tb-toggle > button, .tb-toggle__opt {
	min-height: 40px; padding: 0 16px; border: 0; border-radius: var(--tb-r-pill); background: transparent; cursor: pointer;
	font: 500 .9375rem/1 var(--tb-sans); color: var(--tb-muted); display: inline-flex; align-items: center; gap: 6px;
	transition: background-color var(--tb-fast), color var(--tb-fast), box-shadow var(--tb-fast);
}
.tb-toggle > button[aria-pressed="true"], .tb-toggle input:checked + .tb-toggle__opt, .tb-toggle__opt.is-active {
	background: var(--tb-surface); color: var(--tb-ink); font-weight: 700; box-shadow: var(--tb-shadow-sm);
}
.tb-toggle input { position: absolute; opacity: 0; pointer-events: none; }
.tb-toggle input:focus-visible + .tb-toggle__opt { outline: 2.5px solid var(--tb-focus); outline-offset: 1px; }
.tb-toggle__note { font-size: .6875rem; font-weight: 500; color: var(--tb-muted); }

/* ---- Prayer flow map ------------------------------------------------------- */
.tb-flow { --node: 34px; list-style: none; margin: 0; padding: 0; counter-reset: tb-flow; }
.tb-flow__step { position: relative; padding-inline-start: calc(var(--node) + 14px); padding-bottom: 10px; counter-increment: tb-flow; }
.tb-flow__step::before { /* connector */
	content: ""; position: absolute; inset-inline-start: calc(var(--node) / 2 - 1px); top: calc(var(--node) + 4px); bottom: -4px; width: 2px;
	background: var(--tb-border); border-radius: 2px;
}
.tb-flow__step:last-child::before { display: none; }
.tb-flow__step.is-done::before { background: color-mix(in srgb, var(--tb-sage), transparent 40%); }
.tb-flow__node {
	position: absolute; inset-inline-start: 0; top: 10px; width: var(--node); height: var(--node);
	display: grid; place-items: center; border-radius: 50%;
	background: var(--tb-surface); border: 2px solid var(--tb-border); color: var(--tb-muted);
	font: 700 .875rem/1 var(--tb-sans); font-variant-numeric: tabular-nums;
}
.tb-flow__node:empty::before { content: counter(tb-flow); }
.tb-flow__step.is-done .tb-flow__node { background: var(--tb-sage); border-color: var(--tb-sage); color: var(--tb-surface); }
.tb-flow__step.is-current .tb-flow__node { background: var(--tb-primary); border-color: var(--tb-primary); color: var(--tb-on-primary); box-shadow: 0 0 0 5px var(--tb-primary-soft); }
.tb-flow__step.is-optional .tb-flow__node { border-style: dashed; }
.tb-flow__card { background: var(--tb-surface); border: 1px solid var(--tb-border); border-radius: var(--tb-r-md); transition: box-shadow var(--tb-base), border-color var(--tb-base); }
.tb-flow__step.is-current .tb-flow__card { border-color: color-mix(in srgb, var(--tb-primary), transparent 55%); box-shadow: var(--tb-shadow-md); }
.tb-flow__head {
	display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 6px 12px; padding: 14px 16px; cursor: pointer;
	list-style: none; border-radius: inherit; min-height: 56px;
}
.tb-flow__head::-webkit-details-marker { display: none; }
@media (hover: hover) { .tb-flow__head:hover { background: var(--tb-hover); } }
.tb-flow__head:active { background: var(--tb-hover); }
.tb-flow__title { font-family: var(--tb-serif); font-size: 1.1875rem; font-weight: 700; line-height: 1.3; color: var(--tb-ink); margin: 0; }
.tb-flow__sub { grid-column: 1; font-size: .875rem; color: var(--tb-muted); }
.tb-flow__head .tb-chips { grid-column: 1 / -1; }
.tb-flow__chev { grid-row: 1; grid-column: 2; width: 20px; height: 20px; color: var(--tb-muted); transform: rotate(-90deg); transition: transform var(--tb-base) var(--tb-ease); }
details[open] > .tb-flow__head .tb-flow__chev, .tb-flow__head[aria-expanded="true"] .tb-flow__chev { transform: rotate(90deg); }
.tb-flow__body { padding: 0 16px 16px; color: var(--tb-ink); font-size: 1rem; line-height: 1.75; animation: tb-fade-up var(--tb-base) var(--tb-ease); }
.tb-flow__body > :first-child { margin-top: 0; }
.tb-flow__why { margin: 12px 0 0; padding: 12px 14px; border-radius: var(--tb-r-sm); background: var(--tb-accent-soft); font-size: .9375rem; }
.tb-flow__why strong { color: var(--tb-accent-ink); }
.tb-flow__group { margin: 18px 0 8px; padding-inline-start: calc(var(--node) + 14px); font-size: .8125rem; font-weight: 700; color: var(--tb-accent-ink); letter-spacing: .02em; }

/* ---- Timeline ------------------------------------------------------------- */
.tb-timeline { list-style: none; margin: 0; padding: 0; position: relative; }
.tb-timeline::before { content: ""; position: absolute; inset-inline-start: 7px; top: 8px; bottom: 8px; width: 2px; background: linear-gradient(var(--tb-accent), var(--tb-border)); border-radius: 2px; }
.tb-timeline__item { position: relative; padding-inline-start: 32px; padding-bottom: 24px; }
.tb-timeline__item::before {
	content: ""; position: absolute; inset-inline-start: 2px; top: 6px; width: 12px; height: 12px; border-radius: 50%;
	background: var(--tb-bg); border: 2.5px solid var(--tb-accent);
}
.tb-timeline__item.is-era::before { width: 16px; height: 16px; inset-inline-start: 0; top: 4px; background: var(--tb-accent); }
.tb-timeline__when { display: block; font-size: .8125rem; font-weight: 700; color: var(--tb-accent-ink); font-variant-numeric: tabular-nums; }
.tb-timeline__title { margin: 2px 0 4px; font-family: var(--tb-serif); font-size: 1.1875rem; font-weight: 700; }
.tb-timeline__text { margin: 0; color: var(--tb-muted); font-size: .9375rem; }

/* ---- Source (citation pill) ---------------------------------------------- */
.tb-source {
	display: inline-flex; align-items: center; gap: 6px; max-width: 100%; vertical-align: middle;
	padding: 3px 10px 3px 8px; border-radius: var(--tb-r-pill);
	background: var(--tb-surface); border: 1px solid color-mix(in srgb, var(--tb-accent), transparent 55%);
	color: var(--tb-ink); font: 500 .8125rem/1.5 var(--tb-sans); text-decoration: none; white-space: nowrap;
	transition: background-color var(--tb-fast), border-color var(--tb-fast);
}
.tb-source .tb-icon { width: 15px; height: 15px; color: var(--tb-accent-ink); }
.tb-source__book { font-weight: 700; overflow: hidden; text-overflow: ellipsis; }
.tb-source__sep { color: var(--tb-accent); }
.tb-source__ref { color: var(--tb-muted); }
a.tb-source { position: relative; }
a.tb-source::after { content: ""; position: absolute; inset: -10px -2px; } /* 48px tap height */
a.tb-source:hover, a.tb-source:active { background: var(--tb-accent-soft); border-color: var(--tb-accent); }
.tb-sources { display: flex; flex-wrap: wrap; gap: 6px; margin: 10px 0 0; padding: 0; list-style: none; }

/* ---- Term (glossary) ------------------------------------------------------- */
.tb-term {
	position: relative; display: inline; padding: 0; margin: 0; border: 0; background: none; font: inherit; color: inherit; cursor: help;
	text-decoration: underline dotted color-mix(in srgb, var(--tb-accent), transparent 20%); text-decoration-thickness: 1.5px; text-underline-offset: .28em;
}
.tb-term__tip {
	position: absolute; z-index: 40; bottom: calc(100% + 10px); inset-inline-start: 50%; transform: translate(50%, 4px);
	width: max-content; max-width: min(280px, 80vw); padding: 10px 12px; border-radius: var(--tb-r-sm);
	background: var(--tb-ink); color: var(--tb-bg); box-shadow: var(--tb-shadow-lg);
	font: 400 .875rem/1.55 var(--tb-sans); text-align: start; white-space: normal; cursor: auto;
	opacity: 0; visibility: hidden; pointer-events: none; transition: opacity var(--tb-fast), transform var(--tb-fast), visibility var(--tb-fast);
}
.tb-term__tip b, .tb-term__tip strong { display: block; font-family: var(--tb-serif); font-size: 1rem; margin-bottom: 2px; }
.tb-term__tip::after { content: ""; position: absolute; top: 100%; inset-inline-start: 50%; margin-inline-start: -6px; border: 6px solid transparent; border-top-color: var(--tb-ink); }
.tb-term:hover .tb-term__tip, .tb-term:focus-visible .tb-term__tip, .tb-term[aria-expanded="true"] .tb-term__tip { opacity: 1; visibility: visible; transform: translate(50%, 0); pointer-events: auto; }

/* ---- Audio ------------------------------------------------------------------ */
.tb-audio {
	display: flex; align-items: center; gap: 12px; padding: 8px 14px 8px 8px;
	border-radius: var(--tb-r-pill); background: var(--tb-surface-2); border: 1px solid var(--tb-border); min-width: 0;
}
.tb-audio__play {
	display: grid; place-items: center; width: 48px; height: 48px; flex: none; padding: 0; border: 0; border-radius: 50%;
	background: var(--tb-primary); color: var(--tb-on-primary); cursor: pointer; transition: transform var(--tb-fast), background-color var(--tb-fast);
}
.tb-audio__play:active { transform: scale(.94); }
.tb-audio__play[disabled] { opacity: .45; cursor: default; }
.tb-audio__play .tb-icon { width: 20px; height: 20px; }
.tb-audio__play .tb-icon--play { transform: scaleX(-1); } /* RTL: point to reading direction */
.tb-audio__play .tb-icon--pause, .tb-audio.is-playing .tb-audio__play .tb-icon--play { display: none; }
.tb-audio.is-playing .tb-audio__play .tb-icon--pause { display: block; }
.tb-audio__main { flex: 1; min-width: 0; display: grid; gap: 6px; }
.tb-audio__title { font-size: .875rem; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tb-audio__bar { position: relative; height: 4px; border-radius: 4px; background: color-mix(in srgb, var(--tb-ink), transparent 85%); overflow: hidden; }
.tb-audio__bar > span { position: absolute; inset-block: 0; inset-inline-start: 0; width: var(--p, 0%); background: var(--tb-accent); border-radius: inherit; transition: width .2s linear; }
.tb-audio__time { flex: none; font-size: .8125rem; color: var(--tb-muted); font-variant-numeric: tabular-nums; direction: ltr; unicode-bidi: isolate; }
.tb-audio__rate { flex: none; min-width: 48px; height: 40px; border-radius: var(--tb-r-pill); border: 1px solid var(--tb-border); background: var(--tb-surface); color: var(--tb-ink); font: 600 .75rem/1 var(--tb-sans); cursor: pointer; }
.tb-card--feature .tb-audio { background: rgb(255 255 255 / .07); border-color: rgb(255 255 255 / .12); }
.tb-card--feature .tb-audio__play { background: var(--tb-accent); color: #1B1405; }
.tb-card--feature .tb-audio__time { color: var(--tb-feature-muted); }
.tb-card--feature .tb-audio__bar { background: rgb(255 255 255 / .15); }

/* ---- Progress ---------------------------------------------------------------- */
.tb-progress { --p: 0%; position: relative; height: 6px; border-radius: 6px; background: var(--tb-surface-2); overflow: hidden; }
.tb-progress__bar, .tb-progress > span { position: absolute; inset-block: 0; inset-inline-start: 0; width: var(--p); border-radius: inherit; background: var(--tb-sage); transition: width var(--tb-base) var(--tb-ease); }
.tb-progress--gold .tb-progress__bar { background: var(--tb-accent); }
.tb-progress-label { display: flex; justify-content: space-between; font-size: .8125rem; color: var(--tb-muted); margin-bottom: 6px; }
.tb-progress-label b { color: var(--tb-ink); font-variant-numeric: tabular-nums; }
.tb-ring { --p: 0; --size: 44px; width: var(--size); height: var(--size); border-radius: 50%; display: grid; place-items: center; flex: none;
	background: conic-gradient(var(--tb-sage) calc(var(--p) * 1%), var(--tb-surface-2) 0); font: 700 .75rem/1 var(--tb-sans); }
.tb-ring::before { content: ""; grid-area: 1/1; width: calc(100% - 8px); height: calc(100% - 8px); border-radius: 50%; background: var(--tb-surface); }
.tb-ring > span { grid-area: 1/1; position: relative; }

/* ---- Streak ---------------------------------------------------------------- */
.tb-streak { display: inline-flex; align-items: center; gap: 10px; padding: 6px 14px 6px 8px; border-radius: var(--tb-r-pill); background: var(--tb-accent-soft); color: var(--tb-accent-ink); }
.tb-streak > .tb-icon { width: 22px; height: 22px; }
.tb-streak__n { font: 800 1.125rem/1 var(--tb-sans); font-variant-numeric: tabular-nums; color: var(--tb-ink); }
.tb-streak__label { font-size: .8125rem; font-weight: 600; }
.tb-streak__week { display: flex; gap: 4px; margin: 0; padding: 0; list-style: none; }
.tb-streak__week li { width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; font-size: .6875rem; font-weight: 700; background: var(--tb-surface); color: var(--tb-muted); border: 1px solid var(--tb-border); }
.tb-streak__week li.is-done { background: var(--tb-accent); border-color: var(--tb-accent); color: #1B1405; }
.tb-streak__week li.is-today { border: 1.5px solid var(--tb-accent-ink); color: var(--tb-ink); }

/* ---- Badge ------------------------------------------------------------------- */
.tb-badge {
	display: inline-flex; align-items: center; gap: 4px; height: 22px; padding: 0 8px; border-radius: 6px;
	font: 700 .75rem/1 var(--tb-sans); letter-spacing: .01em; white-space: nowrap;
	background: var(--tb-primary-soft); color: var(--tb-primary);
}
.tb-badge--gold { background: var(--tb-accent-soft); color: var(--tb-accent-ink); }
.tb-badge--sage { background: var(--tb-sage-soft); color: var(--tb-sage); }
.tb-badge--clay { background: var(--tb-clay-soft); color: var(--tb-clay); }
.tb-badge--outline { background: transparent; border: 1px solid var(--tb-border); color: var(--tb-muted); }
.tb-badge--dot { width: 8px; height: 8px; padding: 0; border-radius: 50%; background: var(--tb-clay); }

/* ---- Sheet (bottom sheet mobile / side panel desktop) ------------------------ */
dialog.tb-sheet, .tb-sheet {
	position: fixed; inset: auto 0 0 0; margin: 0; width: 100%; max-width: 100%; max-height: 88dvh;
	padding: 0; border: 0; border-radius: var(--tb-r-xl) var(--tb-r-xl) 0 0;
	background: var(--tb-surface); color: var(--tb-ink); box-shadow: var(--tb-shadow-lg);
	display: flex; flex-direction: column; overflow: hidden; z-index: 100;
}
dialog.tb-sheet:not([open]) { display: none; }
dialog.tb-sheet[open] { animation: tb-sheet-up var(--tb-base) var(--tb-ease); }
dialog.tb-sheet::backdrop { background: rgb(8 12 20 / .45); -webkit-backdrop-filter: blur(2px); backdrop-filter: blur(2px); animation: tb-fade var(--tb-base) var(--tb-ease); }
.tb-sheet__handle { width: 40px; height: 4px; border-radius: 4px; background: var(--tb-border); margin: 10px auto 0; flex: none; }
.tb-sheet__head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 16px 6px 12px; flex: none; }
.tb-sheet__title { margin: 0; font-family: var(--tb-serif); font-size: 1.375rem; }
.tb-sheet__body { padding: 8px 16px calc(24px + env(safe-area-inset-bottom, 0px)); overflow-y: auto; overscroll-behavior: contain; }
@keyframes tb-sheet-up { from { transform: translateY(24px); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes tb-panel-in { from { transform: translateX(-24px); opacity: 0; } to { transform: none; opacity: 1; } }
@media (min-width: 960px) {
	dialog.tb-sheet, .tb-sheet { inset: 0 auto 0 0; inset-inline-start: auto; inset-inline-end: 0; width: 400px; max-height: 100dvh; height: 100dvh; border-radius: 0; }
	[dir="rtl"] dialog.tb-sheet { left: 0; right: auto; border-radius: 0 var(--tb-r-xl) var(--tb-r-xl) 0; }
	dialog.tb-sheet[open] { animation-name: tb-panel-in; }
	.tb-sheet__handle { display: none; }
	.tb-sheet__head { padding: 20px 20px 8px 16px; }
	.tb-sheet__body { padding: 8px 20px 32px; }
}

/* Menu sheet contents */
.tb-menu { list-style: none; margin: 0 0 20px; padding: 0; display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.tb-menu a {
	display: flex; align-items: center; gap: 10px; min-height: 56px; padding: 0 14px; border-radius: var(--tb-r-md);
	background: var(--tb-bg); border: 1px solid var(--tb-border); color: var(--tb-ink); text-decoration: none; font-weight: 600;
	transition: border-color var(--tb-fast), background-color var(--tb-fast);
}
.tb-menu a:active { border-color: var(--tb-accent); background: var(--tb-surface-2); }
.tb-menu a[aria-current="page"] { background: var(--tb-primary-soft); border-color: transparent; color: var(--tb-primary); }
.tb-menu .tb-icon { width: 22px; height: 22px; color: var(--tb-accent-ink); }
.tb-menu a[aria-current="page"] .tb-icon { color: var(--tb-primary); }
.tb-settings { border-top: 1px solid var(--tb-border); padding-top: 8px; }
.tb-setting { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 64px; padding: 8px 0; }
.tb-setting + .tb-setting { border-top: 1px solid var(--tb-border); }
.tb-setting__label { font-weight: 600; display: flex; align-items: center; gap: 10px; }
.tb-setting__label .tb-icon { color: var(--tb-muted); }
.tb-stepper { display: inline-flex; align-items: center; gap: 2px; padding: 3px; border-radius: var(--tb-r-pill); background: var(--tb-surface-2); border: 1px solid var(--tb-border); }
.tb-stepper button { width: 48px; height: 40px; border: 0; border-radius: var(--tb-r-pill); background: transparent; color: var(--tb-ink); cursor: pointer; font: 700 1rem/1 var(--tb-serif); }
.tb-stepper button:active { background: var(--tb-surface); }
.tb-stepper button[disabled] { opacity: .35; cursor: default; }
.tb-stepper output { min-width: 44px; text-align: center; font: 600 .8125rem/1 var(--tb-sans); color: var(--tb-muted); font-variant-numeric: tabular-nums; }

/* ---- Notice / callout -------------------------------------------------------- */
.tb-callout { display: flex; gap: 12px; padding: 14px 16px; border-radius: var(--tb-r-md); background: var(--tb-primary-soft); color: var(--tb-ink); font-size: .9375rem; }
.tb-callout .tb-icon { color: var(--tb-primary); width: 22px; height: 22px; margin-top: 1px; }
.tb-callout--gold { background: var(--tb-accent-soft); } .tb-callout--gold .tb-icon { color: var(--tb-accent-ink); }

/* ---- Rail: horizontal snap carousel (mobile), grid from 640px --------------- */
.tb-rail { display: flex; gap: 12px; overflow-x: auto; scroll-snap-type: x mandatory; overscroll-behavior-x: contain;
	margin-inline: -16px; padding: 4px 16px 12px; scroll-padding-inline: 16px; scrollbar-width: none; list-style: none; }
.tb-rail::-webkit-scrollbar { display: none; }
.tb-rail > * { flex: 0 0 min(80%, 300px); scroll-snap-align: start; }
.tb-section-head--sticky { position: sticky; top: calc(var(--tb-header-h) + env(safe-area-inset-top, 0px)); z-index: 5; background: var(--tb-bg); padding-block: 10px; margin-block-end: 6px; }

/* ---- Path card ------------------------------------------------------------------ */
.tb-paths { margin: 0; padding: 0; list-style: none; }
@media (max-width: 639.98px) { .tb-paths { display: flex; gap: 12px; overflow-x: auto; scroll-snap-type: x mandatory; overscroll-behavior-x: contain; margin-inline: -16px; padding: 4px 16px 12px; scroll-padding-inline: 16px; scrollbar-width: none; } .tb-paths::-webkit-scrollbar { display: none; } .tb-paths > * { flex: 0 0 min(78%, 300px); scroll-snap-align: start; } }
@media (min-width: 640px) { .tb-paths { display: grid; gap: 12px; grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (min-width: 1100px) { .tb-paths { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.tb-path { position: relative; display: flex; flex-direction: column; gap: 10px; padding: 18px; border-radius: var(--tb-r-md); background: var(--tb-surface); border: 1px solid var(--tb-border); transition: transform var(--tb-base) var(--tb-ease), box-shadow var(--tb-base), border-color var(--tb-base); }
@media (hover: hover) { .tb-path:hover { transform: translateY(-2px); box-shadow: var(--tb-shadow-md); border-color: color-mix(in srgb, var(--tb-border), var(--tb-accent) 35%); } }
.tb-path__top { display: flex; align-items: center; justify-content: space-between; }
.tb-path__icon { width: 44px; height: 44px; border-radius: 14px; display: grid; place-items: center; background: var(--tb-primary-soft); color: var(--tb-primary); }
.tb-path__icon .tb-icon { width: 24px; height: 24px; }
.tb-path--sage .tb-path__icon { background: var(--tb-sage-soft); color: var(--tb-sage); }
.tb-path--clay .tb-path__icon { background: var(--tb-clay-soft); color: var(--tb-clay); }
.tb-path--gold .tb-path__icon { background: var(--tb-accent-soft); color: var(--tb-accent-ink); }
.tb-path__title { margin: 4px 0 0; font-family: var(--tb-serif); font-size: 1.1875rem; font-weight: 700; line-height: 1.3; }
.tb-path__title a { color: var(--tb-ink); text-decoration: none; }
.tb-path__title a::after { content: ""; position: absolute; inset: 0; border-radius: inherit; }
.tb-path__meta { margin: 0; font-size: .875rem; color: var(--tb-muted); }
.tb-path .tb-progress { margin-top: auto; }

/* ---- Search form ---------------------------------------------------------------- */
.tb-search { display: flex; align-items: center; gap: 8px; padding: 6px 6px 6px 6px; padding-inline-start: 16px; border-radius: var(--tb-r-pill); background: var(--tb-surface); border: 1px solid var(--tb-border); box-shadow: var(--tb-shadow-sm); }
.tb-search:focus-within { border-color: var(--tb-primary); box-shadow: 0 0 0 4px var(--tb-primary-soft); }
.tb-search .tb-icon { color: var(--tb-muted); }
.tb-search input { flex: 1; min-width: 0; border: 0; background: transparent; font: 400 1rem/1.4 var(--tb-sans); color: var(--tb-ink); padding: 8px 0; outline: none; }
.tb-search input::placeholder { color: var(--tb-muted); }

/* ---- Core block polish ---------------------------------------------------------- */
.wp-block-search__inside-wrapper { border-radius: var(--tb-r-pill) !important; border: 1px solid var(--tb-border) !important; background: var(--tb-surface); padding: 5px !important; }
.wp-block-search__input { border: 0 !important; background: transparent !important; padding-inline: 14px !important; font-size: 1rem; color: var(--tb-ink); }
.wp-block-search__button { border-radius: var(--tb-r-pill) !important; margin: 0 !important; }
.wp-block-post-template.tb-list { display: grid; gap: 16px; }
.wp-block-query-pagination { margin-top: 32px; gap: 8px; font-weight: 600; }
.wp-block-post-terms a { display: inline-flex; padding: 2px 10px; border-radius: var(--tb-r-pill); background: var(--tb-accent-soft); color: var(--tb-accent-ink); text-decoration: none; font-size: .8125rem; font-weight: 600; }
