/* Bhakti Knowledge Library: warm, calm, readable.
   Devanagari text uses the fonts already on your computer (see README). */

:root {
  --bg: #f9f6f0;
  --surface: #fffdf8;
  --surface-2: #f3eee4;
  --border: #e6dccb;
  --text: #2a241d;
  --text-soft: #6b6155;
  --accent: #b8692a;        /* saffron-brown */
  --accent-strong: #97511b;
  --accent-soft: #f6e6d4;
  --ok: #3f7a4f;
  --ok-soft: #e1efe4;
  --warn: #9a6b12;
  --warn-soft: #f7ecd0;
  --danger: #a33b3b;
  --danger-soft: #f6dede;
  --focus: #2f6fb0;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(60, 40, 20, 0.06), 0 4px 14px rgba(60, 40, 20, 0.05);
  --font-body: system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", "Noto Sans Devanagari", "Nirmala UI", sans-serif;
  --font-head: Charter, Georgia, "Iowan Old Style", "Noto Serif", "Noto Serif Devanagari", serif;
  color-scheme: light;
}

:root[data-theme="dark"] {
  --bg: #1b1814;
  --surface: #242019;
  --surface-2: #2c281f;
  --border: #3d372b;
  --text: #f1eadc;
  --text-soft: #b7ab98;
  --accent: #e39a5a;
  --accent-strong: #f0b07a;
  --accent-soft: #3b2e20;
  --ok: #8fcaa0;
  --ok-soft: #22382b;
  --warn: #e7c173;
  --warn-soft: #3a3120;
  --danger: #ef9a9a;
  --danger-soft: #3d2424;
  --focus: #7fb3e8;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 4px 14px rgba(0, 0, 0, 0.2);
  color-scheme: dark;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #1b1814;
    --surface: #242019;
    --surface-2: #2c281f;
    --border: #3d372b;
    --text: #f1eadc;
    --text-soft: #b7ab98;
    --accent: #e39a5a;
    --accent-strong: #f0b07a;
    --accent-soft: #3b2e20;
    --ok: #8fcaa0;
    --ok-soft: #22382b;
    --warn: #e7c173;
    --warn-soft: #3a3120;
    --danger: #ef9a9a;
    --danger-soft: #3d2424;
    --focus: #7fb3e8;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 4px 14px rgba(0, 0, 0, 0.2);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 { font-family: var(--font-head); line-height: 1.25; margin: 0 0 0.5em; font-weight: 600; }
h1 { font-size: 1.9rem; }
h2 { font-size: 1.35rem; margin-top: 1.4em; }
h3 { font-size: 1.1rem; }
p { margin: 0 0 0.9em; }
a { color: var(--accent-strong); text-underline-offset: 3px; }
code { font-family: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace; font-size: 0.9em; background: var(--surface-2); padding: 0.1em 0.35em; border-radius: 6px; }

:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: 6px; }

.visually-hidden {
  position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.skip-link {
  position: absolute; left: 12px; top: -48px; background: var(--surface); padding: 8px 12px;
  border-radius: 8px; z-index: 100; box-shadow: var(--shadow);
}
.skip-link:focus { top: 12px; }

/* ---------- Layout ---------- */

.app-shell { display: grid; grid-template-columns: 240px 1fr; min-height: 100vh; }

.sidebar {
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: 20px 14px;
  display: flex; flex-direction: column; gap: 18px;
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
}

.brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px; }
.brand-mark {
  width: 40px; height: 40px; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--accent-soft); color: var(--accent-strong);
  font-family: var(--font-head); font-size: 1.3rem;
}
.brand-title { font-family: var(--font-head); font-weight: 600; font-size: 1.05rem; }
.brand-sub { font-size: 0.8rem; color: var(--text-soft); }

.nav { display: flex; flex-direction: column; gap: 2px; }
.nav a {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 12px; border-radius: 10px;
  color: var(--text); text-decoration: none;
}
.nav a:hover { background: var(--surface-2); }
.nav a[aria-current="page"] { background: var(--accent-soft); color: var(--accent-strong); font-weight: 600; }
.nav .nav-icon { width: 20px; text-align: center; opacity: 0.85; }
.nav .nav-badge {
  margin-left: auto; font-size: 0.75rem; background: var(--surface-2);
  color: var(--text-soft); padding: 1px 8px; border-radius: 999px;
}
.nav .nav-soon { margin-left: auto; font-size: 0.7rem; color: var(--text-soft); }

.sidebar-foot { margin-top: auto; }

.content-wrap { min-width: 0; display: flex; flex-direction: column; }

.topbar {
  display: flex; gap: 12px; align-items: center;
  padding: 16px 28px; border-bottom: 1px solid var(--border);
  background: var(--bg); position: sticky; top: 0; z-index: 5;
}
.search { flex: 1; display: flex; gap: 8px; max-width: 720px; }
.search input {
  flex: 1; min-width: 0;
}

.main { padding: 28px; max-width: 1180px; width: 100%; }

/* ---------- Form controls and buttons ---------- */

input, select, textarea, button { font: inherit; color: inherit; }

input[type="text"], input[type="url"], input[type="search"], input[type="date"], input[type="number"], select, textarea {
  background: var(--surface); border: 1px solid var(--border); border-radius: 10px;
  padding: 10px 12px; width: 100%;
}
textarea { min-height: 180px; resize: vertical; font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 0.92rem; line-height: 1.55; }
label.field { display: block; font-size: 0.9rem; color: var(--text-soft); margin-bottom: 14px; }
label.field > span { display: block; margin-bottom: 6px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 9px 16px; border-radius: 10px; border: 1px solid var(--border);
  background: var(--surface); cursor: pointer; text-decoration: none; white-space: nowrap;
  transition: background 0.15s, border-color 0.15s;
}
.btn:hover { background: var(--surface-2); }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-strong); border-color: var(--accent-strong); }
.btn-accent { background: var(--accent-soft); border-color: transparent; color: var(--accent-strong); font-weight: 600; }
.btn-ghost { background: transparent; border-color: transparent; }
.btn-danger { color: var(--danger); }
.btn-small { padding: 6px 11px; font-size: 0.88rem; border-radius: 8px; }
.btn-block { width: 100%; }

.row { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; }
.row-between { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; align-items: center; }
.stack > * + * { margin-top: 12px; }
.muted { color: var(--text-soft); }
.small { font-size: 0.88rem; }

.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; flex-wrap: wrap; margin-bottom: 22px; }
.page-head p { color: var(--text-soft); margin: 0; }

/* ---------- Cards and grids ---------- */

.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 18px; box-shadow: var(--shadow);
}
.card h2, .card h3 { margin-top: 0; }

.grid { display: grid; gap: 16px; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); }
.grid-2 { display: grid; gap: 18px; grid-template-columns: 1.4fr 1fr; }
.grid-stats { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); margin-bottom: 22px; }

.stat .stat-num { font-family: var(--font-head); font-size: 2rem; line-height: 1; color: var(--accent-strong); }
.stat .stat-label { color: var(--text-soft); font-size: 0.9rem; margin-top: 6px; }

.lecture-card { display: flex; flex-direction: column; gap: 10px; text-decoration: none; color: inherit; }
.lecture-card:hover { border-color: var(--accent); }
.thumb {
  aspect-ratio: 16 / 9; width: 100%; border-radius: 10px; overflow: hidden;
  background: var(--surface-2); display: grid; place-items: center; color: var(--text-soft);
  font-family: var(--font-head); font-size: 2rem;
}
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.lecture-title { font-family: var(--font-head); font-weight: 600; font-size: 1.05rem; line-height: 1.35; margin: 0; }
.meta-line { font-size: 0.85rem; color: var(--text-soft); display: flex; gap: 8px; flex-wrap: wrap; }

.progress { height: 8px; background: var(--surface-2); border-radius: 999px; overflow: hidden; }
.progress > span { display: block; height: 100%; background: var(--accent); border-radius: 999px; transition: width 0.3s; }

/* ---------- Badges ---------- */

.badge {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 0.78rem; padding: 2px 10px; border-radius: 999px;
  background: var(--surface-2); color: var(--text-soft); white-space: nowrap;
}
.badge::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; opacity: 0.8; }
.badge-ok { background: var(--ok-soft); color: var(--ok); }
.badge-warn { background: var(--warn-soft); color: var(--warn); }
.badge-danger { background: var(--danger-soft); color: var(--danger); }
.badge-accent { background: var(--accent-soft); color: var(--accent-strong); }

/* ---------- Tables and lists ---------- */

.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
table { width: 100%; border-collapse: collapse; font-size: 0.94rem; }
th, td { text-align: left; padding: 11px 14px; border-bottom: 1px solid var(--border); vertical-align: top; }
th { font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.04em; color: var(--text-soft); font-weight: 600; background: var(--surface-2); }
tr:last-child td { border-bottom: 0; }

.list { list-style: none; margin: 0; padding: 0; }
.list > li { border-bottom: 1px solid var(--border); padding: 12px 0; }
.list > li:last-child { border-bottom: 0; }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); overflow-x: auto; margin-bottom: 20px; }
.tabs button {
  background: none; border: 0; padding: 10px 14px; cursor: pointer;
  color: var(--text-soft); border-bottom: 2px solid transparent; white-space: nowrap;
}
.tabs button[aria-selected="true"] { color: var(--accent-strong); border-bottom-color: var(--accent); font-weight: 600; }

/* ---------- Empty states and notices ---------- */

.empty {
  text-align: center; padding: 40px 24px; border: 1px dashed var(--border);
  border-radius: var(--radius); background: var(--surface);
}
.empty .empty-icon { font-size: 2rem; opacity: 0.6; margin-bottom: 8px; }
.empty h3 { margin-bottom: 6px; }
.empty p { color: var(--text-soft); max-width: 46ch; margin: 0 auto 12px; }

.notice {
  border-radius: var(--radius); padding: 14px 16px; border: 1px solid var(--border);
  background: var(--surface-2); margin-bottom: 16px;
}
.notice strong { display: block; margin-bottom: 2px; }
.notice-warn { background: var(--warn-soft); border-color: transparent; color: var(--text); }
.notice-danger { background: var(--danger-soft); border-color: transparent; color: var(--text); }
.notice-ok { background: var(--ok-soft); border-color: transparent; color: var(--text); }
.hint { color: var(--text-soft); font-size: 0.9rem; margin-top: 6px; }

.loading { color: var(--text-soft); padding: 40px 0; }

/* ---------- Transcript reading ---------- */

.transcript-body {
  white-space: pre-wrap; font-family: var(--font-body);
  font-size: 1.02rem; line-height: 1.85; max-height: 60vh; overflow-y: auto;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 18px 20px;
}
.ts { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 0.85em; color: var(--accent-strong); }

/* ---------- Toasts ---------- */

.toast-region { position: fixed; bottom: 18px; right: 18px; display: flex; flex-direction: column; gap: 10px; z-index: 50; max-width: min(380px, calc(100vw - 36px)); }
.toast {
  background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow);
  padding: 12px 16px; border-radius: 12px; font-size: 0.95rem;
}
.toast.toast-error { border-color: var(--danger); }
.toast.toast-ok { border-color: var(--ok); }
.toast .hint { margin-top: 4px; }

/* ---------- Login page ---------- */

.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.login-card { width: min(400px, 100%); padding: 28px; }

/* ---------- Mobile ---------- */

@media (max-width: 860px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar {
    position: static; height: auto; flex-direction: column;
    border-right: 0; border-bottom: 1px solid var(--border); padding: 12px 14px;
  }
  .sidebar-foot { display: none; }
  .nav { flex-direction: row; overflow-x: auto; gap: 4px; padding-bottom: 2px; }
  .nav a { white-space: nowrap; padding: 8px 10px; }
  .nav .nav-badge, .nav .nav-soon { display: none; }
  .brand { display: none; }
  .topbar { position: static; padding: 12px 16px; flex-wrap: wrap; }
  .search { max-width: none; }
  .main { padding: 18px 16px; }
  .grid-2 { grid-template-columns: 1fr; }
  h1 { font-size: 1.6rem; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}
