/* ===== Tokens ===== */
:root {
  --brand: #1e5d5f;
  --brand-dark: #133f41;
  --brand-soft: #e3efee;
  --accent: #b5651d;
  --accent-soft: #f6e9db;
  --paper: #f7f4ee;
  --card: #ffffff;
  --line: #e6e1d6;
  --ink: #1f2a2b;
  --muted: #6b7272;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(20, 40, 40, .06), 0 4px 16px rgba(20, 40, 40, .05);
  --font-ta: "Noto Sans Tamil", "Latha", "Nirmala UI", system-ui, sans-serif;
  --font-ta-serif: "Noto Serif Tamil", "Noto Sans Tamil", "Latha", "Nirmala UI", serif;
  --bs-body-font-family: var(--font-ta);
  --bs-link-color-rgb: 30, 93, 95;
  --bs-link-hover-color-rgb: 19, 63, 65;
  --bs-primary-rgb: 30, 93, 95;
}
html { scroll-padding-top: 80px; }
body { background: var(--paper); color: var(--ink); font-family: var(--font-ta); -webkit-font-smoothing: antialiased; }
.title-ta, .brand-ta { font-family: var(--font-ta-serif); }
a { text-underline-offset: 3px; }
.skip { position: absolute; left: 8px; top: 8px; z-index: 2000; background: #fff; padding: 6px 10px; border-radius: 8px; }

/* ===== Bootstrap tweaks ===== */
.btn-primary { --bs-btn-bg: var(--brand); --bs-btn-border-color: var(--brand); --bs-btn-hover-bg: var(--brand-dark); --bs-btn-hover-border-color: var(--brand-dark); --bs-btn-active-bg: var(--brand-dark); --bs-btn-active-border-color: var(--brand-dark); --bs-btn-disabled-bg: var(--brand); --bs-btn-disabled-border-color: var(--brand); }
.btn-outline-primary { --bs-btn-color: var(--brand); --bs-btn-border-color: var(--brand); --bs-btn-hover-bg: var(--brand); --bs-btn-hover-border-color: var(--brand); --bs-btn-active-bg: var(--brand-dark); }
.btn-light { --bs-btn-bg: #fff; --bs-btn-border-color: var(--line); --bs-btn-hover-bg: #f1eee7; --bs-btn-hover-border-color: var(--line); }
.form-control:focus, .form-select:focus { border-color: var(--brand); box-shadow: 0 0 0 .2rem rgba(30, 93, 95, .15); }
.form-check-input:checked { background-color: var(--brand); border-color: var(--brand); }
.page-link { color: var(--brand); border-color: var(--line); min-width: 40px; text-align: center; }
.page-item.active .page-link { background: var(--brand); border-color: var(--brand); }
.dropdown-item.active, .dropdown-item:active { background: var(--brand); }
.card { border-color: var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-header { background: #faf8f3; border-color: var(--line); }
.badge-urai { background: var(--accent-soft); color: #7a4310; }
.badge-en { background: #e2ecf7; color: #1d4f86; }

/* ===== Header & navigation ===== */
.site-header { position: sticky; top: 0; z-index: 1030; background: var(--brand); color: #fff; box-shadow: 0 2px 10px rgba(0, 0, 0, .08); }
.header-row { display: flex; align-items: center; justify-content: space-between; min-height: 60px; }
.brand { display: flex; align-items: center; gap: .6rem; color: #fff; text-decoration: none; }
.brand-mark { width: 36px; height: 36px; border-radius: 10px; background: rgba(255, 255, 255, .14); display: grid; place-items: center; font-family: var(--font-ta-serif); font-weight: 700; font-size: 1.15rem; }
.brand-text { display: flex; flex-direction: column; line-height: 1.1; }
.brand-ta { font-size: 1.12rem; font-weight: 700; }
.brand-text small { opacity: .7; font-size: .72rem; letter-spacing: .04em; }
.top-nav { gap: .25rem; }
.top-nav a { color: rgba(255, 255, 255, .82); text-decoration: none; padding: .45rem .8rem; border-radius: 999px; font-size: .95rem; }
.top-nav a:hover { color: #fff; background: rgba(255, 255, 255, .1); }
.top-nav a.active { color: var(--brand-dark); background: #fff; font-weight: 600; }
.bottom-nav { position: fixed; z-index: 1030; left: 0; right: 0; bottom: 0; display: grid; grid-template-columns: repeat(4, 1fr); background: #fff; border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom); box-shadow: 0 -4px 16px rgba(0, 0, 0, .06); }
.bottom-nav a { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 8px 2px 7px; color: var(--muted); text-decoration: none; font-size: .72rem; }
.bottom-nav a i { font-size: 1.25rem; }
.bottom-nav a.active { color: var(--brand); font-weight: 600; }
@media (max-width: 767.98px) { body { padding-bottom: calc(64px + env(safe-area-inset-bottom)); } }

.site-footer { border-top: 1px solid var(--line); padding: 1rem 0; font-size: .82rem; color: var(--muted); }

/* ===== Search hero (list page) ===== */
.search-hero { max-width: 760px; margin: 1.5rem auto 1.75rem; text-align: center; }
.search-hero.compact { margin: .25rem auto 1rem; }
.search-hero h1 { color: var(--brand-dark); font-size: clamp(1.7rem, 5vw, 2.6rem); font-weight: 700; margin-bottom: .35rem; }
.hero-sub { color: var(--muted); margin-bottom: 1.25rem; }
.search-box { display: flex; align-items: center; background: #fff; border: 1.5px solid var(--line); border-radius: 999px; padding: 5px 5px 5px 18px; box-shadow: var(--shadow); transition: border-color .15s, box-shadow .15s; }
.search-box:focus-within { border-color: var(--brand); box-shadow: 0 0 0 4px rgba(30, 93, 95, .12); }
.search-box > i { color: var(--muted); font-size: 1.1rem; }
.search-box input { flex: 1; min-width: 0; border: 0; outline: 0; background: transparent; padding: .6rem .75rem; font-size: 1.05rem; }
.search-go { border-radius: 999px; padding: .55rem 1.3rem; font-weight: 600; }
.search-actions { display: flex; justify-content: center; margin-top: .4rem; }
.adv-toggle { color: var(--brand); text-decoration: none; font-weight: 500; }
.adv-toggle .chev { transition: transform .2s; display: inline-block; }
.adv-toggle:not(.collapsed) .chev { transform: rotate(180deg); }
.adv-panel { text-align: left; background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 1.1rem; margin-top: .4rem; box-shadow: var(--shadow); }
.adv-panel .form-label { font-size: .82rem; color: var(--muted); margin-bottom: .25rem; }
.adv-foot { display: flex; justify-content: flex-end; gap: .5rem; margin-top: 1rem; }

/* ===== Featured ===== */
.featured { max-width: 760px; margin: 0 auto 2rem; }
.feature-kural { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: 1.1rem 1.3rem; border-radius: var(--radius); text-decoration: none; color: #fff;
  background: linear-gradient(135deg, var(--brand) 0%, #2c7a74 60%, #3b8b7a 100%); box-shadow: 0 8px 24px rgba(30, 93, 95, .25); transition: transform .15s; }
.feature-kural:hover { color: #fff; transform: translateY(-2px); }
.fk-kicker { font-size: .78rem; opacity: .85; }
.fk-title { font-size: 1.35rem; font-weight: 700; margin: .1rem 0; }
.fk-sub { font-size: .85rem; opacity: .85; }
.fk-go { font-size: 2rem; opacity: .9; flex-shrink: 0; }
.quick-chips { display: flex; flex-wrap: wrap; justify-content: center; gap: .4rem; margin-top: 1rem; }
.chip { display: inline-flex; align-items: center; gap: .25rem; padding: .3rem .75rem; border-radius: 999px; background: #fff; border: 1px solid var(--line); color: var(--ink); text-decoration: none; font-size: .88rem; }
.chip:hover { border-color: var(--brand); color: var(--brand); }
.chip-x { background: var(--brand-soft); border-color: transparent; color: var(--brand-dark); }
.chip-clear { font-size: .85rem; align-self: center; margin-left: .25rem; }
.active-chips { display: flex; flex-wrap: wrap; gap: .4rem; margin-bottom: .75rem; }

/* ===== Results list ===== */
.results-bar { display: flex; justify-content: space-between; align-items: center; gap: .5rem; margin-bottom: .6rem; }
.results-count { color: var(--muted); font-size: .92rem; }
.results-count strong { color: var(--ink); }
.work-list { list-style: none; padding: 0; margin: 0; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.work-list li + li { border-top: 1px solid var(--line); }
.work-item { display: flex; align-items: center; justify-content: space-between; gap: .75rem; padding: .85rem 1rem; color: inherit; text-decoration: none; transition: background .12s; }
.work-item:hover { background: #faf8f2; }
.wi-main { min-width: 0; }
.wi-title { font-size: 1.12rem; font-weight: 600; color: var(--brand-dark); line-height: 1.35; }
.wi-sub { color: var(--muted); font-size: .86rem; overflow: hidden; text-overflow: ellipsis; }
.wi-meta { display: flex; flex-wrap: wrap; gap: .3rem; margin-top: .35rem; }
.pill { font-size: .74rem; padding: .12rem .55rem; border-radius: 999px; background: #f1eee7; color: #555; }
.pill-type { background: var(--brand-soft); color: var(--brand-dark); }
.pill-lost { background: #ececec; color: #666; }
.pill-part { background: #fff3cd; color: #7a5b00; }
.wi-avail { display: flex; align-items: center; gap: .3rem; flex-shrink: 0; }
.av { font-size: .72rem; font-weight: 600; padding: .2rem .5rem; border-radius: 6px; }
.av-text { background: #eef2f1; color: #33605c; }
.av-urai { background: var(--accent-soft); color: #7a4310; }
.av-en { background: #e2ecf7; color: #1d4f86; }
.wi-go { color: #b9b4a8; margin-left: .2rem; }
@media (max-width: 575.98px) {
  .work-item { align-items: flex-start; padding: .8rem .85rem; }
  .wi-avail { flex-direction: column; align-items: flex-end; gap: .25rem; }
  .wi-go { display: none; }
}
.empty-state { text-align: center; padding: 3rem 1rem; color: var(--muted); }
.empty-state i { font-size: 2.4rem; display: block; margin-bottom: .5rem; opacity: .5; }

/* ===== Work detail ===== */
.meta-list dt { font-weight: 600; color: #555; }
.breadcrumb a { text-decoration: none; }
.stat-card { color: inherit; }
.stat-card:hover { border-color: var(--brand); }
.stats-table a { text-decoration: none; }
.notes-list li { margin-bottom: .5rem; }

/* ===== Thirukkural ===== */
.tk-hero { background: radial-gradient(120% 140% at 0% 0%, #2c7a74 0%, var(--brand) 45%, var(--brand-dark) 100%); color: #fff; border-radius: 20px; padding: clamp(1.5rem, 5vw, 3rem); margin-bottom: 2rem; box-shadow: 0 10px 30px rgba(19, 63, 65, .25); }
.tk-hero-inner { max-width: 680px; }
.tk-kicker { font-size: .85rem; opacity: .8; }
.tk-hero h1 { font-size: clamp(2.2rem, 8vw, 3.6rem); font-weight: 700; margin: .2rem 0 .4rem; }
.tk-hero .lead { font-size: 1rem; opacity: .9; }
.tk-quick { display: flex; flex-wrap: wrap; gap: 1rem; margin-top: 1rem; }
.tk-quick a { color: #fff; opacity: .9; font-weight: 500; }
.tk-search { display: flex; align-items: center; background: #fff; border-radius: 999px; padding: 4px 4px 4px 16px; border: 1.5px solid var(--line); margin: 1rem 0; }
.tk-search:focus-within { border-color: var(--brand); }
.tk-search i { color: var(--muted); }
.tk-search input { flex: 1; min-width: 0; border: 0; outline: 0; padding: .55rem .7rem; background: transparent; color: var(--ink); }
.tk-search .btn { border-radius: 999px; padding: .5rem 1.2rem; }
.tk-search-lg { border: 0; }

.paal { margin-bottom: 2.5rem; }
.paal-head { display: flex; align-items: center; gap: .8rem; margin-bottom: 1rem; }
.paal-icon { width: 46px; height: 46px; border-radius: 12px; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent); font-size: 1.3rem; }
.paal-head h2 { font-size: 1.6rem; font-weight: 700; color: var(--brand-dark); }
.iyal-title { font-size: 1rem; font-weight: 600; margin: 1.2rem 0 .6rem; color: var(--ink); }
.iyal-title span { font-weight: 400; color: var(--muted); font-size: .85rem; margin-left: .35rem; }
.chapter-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: .55rem; }
@media (max-width: 575.98px) { .chapter-grid { grid-template-columns: 1fr 1fr; } }
.chapter-tile { display: grid; grid-template-columns: auto 1fr; grid-template-rows: auto auto; column-gap: .6rem; padding: .65rem .75rem; border-radius: 12px; background: #fff; border: 1px solid var(--line); text-decoration: none; color: var(--ink); transition: border-color .12s, transform .12s; }
.chapter-tile:hover { border-color: var(--brand); transform: translateY(-1px); color: var(--ink); }
.ct-no { grid-row: span 2; align-self: center; width: 32px; height: 32px; border-radius: 9px; background: var(--brand-soft); color: var(--brand-dark); display: grid; place-items: center; font-size: .8rem; font-weight: 700; }
.ct-name { font-family: var(--font-ta-serif); font-weight: 600; font-size: .98rem; line-height: 1.3; }
.ct-en { font-size: .74rem; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.tk-crumbs { display: flex; flex-wrap: wrap; align-items: center; gap: .35rem; font-size: .85rem; color: var(--muted); margin-bottom: .75rem; }
.tk-crumbs a { color: var(--brand); text-decoration: none; }
.tk-crumbs i { font-size: .65rem; opacity: .6; }
.chapter-head { text-align: center; margin: .5rem auto 1.25rem; max-width: 720px; }
.chapter-head.compact { margin-bottom: 1rem; }
.ch-badge { display: inline-block; font-size: .8rem; padding: .2rem .7rem; border-radius: 999px; background: var(--accent-soft); color: #7a4310; font-weight: 600; }
.chapter-head h1 { font-size: clamp(1.9rem, 6vw, 2.8rem); font-weight: 700; color: var(--brand-dark); margin: .4rem 0 .2rem; }
.ch-sub { color: var(--muted); font-size: .92rem; }
.ch-nav { display: flex; gap: .4rem; justify-content: center; margin-top: 1rem; }
.chapter-jump { max-width: 320px; }

.reader-bar { position: sticky; top: 60px; z-index: 1020; display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .5rem .75rem; max-width: 820px; margin: 0 auto 1rem; padding: .5rem .6rem; background: rgba(247, 244, 238, .92); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); border: 1px solid var(--line); border-radius: 14px; }
.seg { display: flex; align-items: center; gap: 2px; overflow-x: auto; scrollbar-width: none; max-width: 100%; }
.seg::-webkit-scrollbar { display: none; }
.seg-label { font-size: .78rem; color: var(--muted); padding: 0 .35rem; flex-shrink: 0; }
.seg button { flex-shrink: 0; border: 0; background: transparent; padding: .35rem .7rem; border-radius: 999px; font-size: .86rem; color: var(--ink); white-space: nowrap; }
.seg button:hover { background: #ebe6db; }
.seg button[aria-pressed="true"] { background: var(--brand); color: #fff; }
.toggles { display: flex; gap: .9rem; font-size: .84rem; color: var(--muted); }
.toggles .form-check { display: flex; align-items: center; gap: .35rem; padding-left: 0; }
.toggles .form-check-input { margin: 0; float: none; }
@media (max-width: 575.98px) { .reader-bar { top: 60px; border-radius: 12px; padding: .45rem; } .seg { flex-wrap: wrap; overflow: visible; } .seg button { padding: .3rem .6rem; font-size: .82rem; } .toggles { width: 100%; justify-content: flex-end; border-top: 1px solid var(--line); padding-top: .35rem; } }

.kural-list { max-width: 820px; margin: 0 auto; display: flex; flex-direction: column; gap: 1rem; }
.kural-card { background: var(--card); border: 1px solid var(--line); border-radius: 18px; padding: 1.1rem 1.25rem 1.2rem; box-shadow: var(--shadow); scroll-margin-top: 130px; }
.kural-card.is-target { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(181, 101, 29, .18); }
.kural-head { display: flex; align-items: center; gap: .6rem; margin-bottom: .5rem; }
.kural-no { font-size: .8rem; font-weight: 700; color: var(--accent); text-decoration: none; background: var(--accent-soft); padding: .2rem .6rem; border-radius: 999px; }
.kural-ch { color: var(--muted); text-decoration: none; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.kural-tools { margin-left: auto; display: flex; gap: .15rem; }
.btn-icon { width: 34px; height: 34px; padding: 0; border-radius: 10px; color: var(--muted); }
.btn-icon:hover { background: #f1eee7; color: var(--brand); }
.kural-text { margin: .2rem 0 .7rem; padding-left: .9rem; border-left: 3px solid var(--brand); }
.kural-text p { margin: 0; font-family: var(--font-ta-serif); font-size: clamp(1.12rem, 3.6vw, 1.38rem); font-weight: 600; line-height: 1.75; color: var(--brand-dark); }
.kural-translit { font-size: .88rem; font-style: italic; color: var(--muted); margin: -.2rem 0 .6rem .95rem; }
.kural-en { font-size: .95rem; color: #3d4747; background: #f6f8f8; border-radius: 10px; padding: .55rem .75rem; margin-bottom: .75rem; }
.kural-en i { color: var(--brand); }
.urai-block { display: flex; flex-direction: column; gap: .6rem; }
.urai { border-top: 1px dashed var(--line); padding-top: .6rem; }
.urai-by { display: inline-block; font-size: .74rem; font-weight: 700; letter-spacing: .02em; color: #7a4310; background: var(--accent-soft); padding: .1rem .55rem; border-radius: 6px; margin-bottom: .3rem; }
.urai p { margin: 0; line-height: 1.85; font-size: 1rem; }
.urai-en p { font-size: .95rem; line-height: 1.6; }
.urai-en .urai-by { color: #1d4f86; background: #e2ecf7; }
/* commentary switch */
:root:not([data-urai="all"]) .urai { display: none; }
:root[data-urai="mv"] .urai[data-urai="mv"], :root[data-urai="sp"] .urai[data-urai="sp"], :root[data-urai="mk"] .urai[data-urai="mk"], :root[data-urai="en"] .urai[data-urai="en"] { display: block; }
:root:not([data-urai="all"]) .urai { border-top: 0; padding-top: 0; }
:root.hide-translit .kural-translit, :root.hide-en .kural-en { display: none; }

.pager { display: grid; grid-template-columns: 1fr 1fr; gap: .75rem; max-width: 820px; margin: 1.5rem auto 0; }
.pager-link { display: flex; flex-direction: column; padding: .8rem 1rem; border-radius: 14px; background: #fff; border: 1px solid var(--line); text-decoration: none; color: var(--ink); min-width: 0; }
.pager-link:hover { border-color: var(--brand); color: var(--ink); }
.pager-link small { color: var(--muted); font-size: .76rem; }
.pager-link .title-ta { font-weight: 600; color: var(--brand-dark); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.small-ta { font-size: .92rem; }
.tk-credit { max-width: 820px; margin: 2rem auto 0; font-size: .78rem; color: var(--muted); text-align: center; }
.toast-lite { position: fixed; left: 50%; bottom: 84px; transform: translate(-50%, 20px); background: #1f2a2b; color: #fff; padding: .5rem 1rem; border-radius: 999px; font-size: .88rem; opacity: 0; pointer-events: none; transition: all .2s; z-index: 1100; }
.toast-lite.show { opacity: 1; transform: translate(-50%, 0); }
@media (min-width: 768px) { .toast-lite { bottom: 28px; } }
