/* UPSC CRAFT workspace: unified Syllabus view, in-page Explore frame, reader panel and mobile polish.
 * Loaded last in workspace.html so it can refine the shared styles. */

/* ------------------------------------------------------------------ status colours */
:root {
  --st-none: #cbd5e1; --st-studying: #3b82f6; --st-notes: #f59e0b; --st-rev1: #10b981; --st-rev2: #7c3aed;
  --ok: #047857; --danger: #b91c1c; --danger-bg: #fef2f2;
}
body.dark-mode { --st-none: #3a3a52; --st-studying: #60a5fa; --st-notes: #fbbf24; --st-rev1: #34d399; --st-rev2: #a78bfa; --ok: #34d399; --danger: #fca5a5; --danger-bg: rgba(220,38,38,.16); }

/* ------------------------------------------------------------------ header */
.btn-signin { display: inline-flex; align-items: center; gap: 8px; text-decoration: none; background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 700; }
.btn-signin:hover { color: #fff; filter: brightness(1.07); }
body.dark-mode .btn-secondary.btn-signin { color: #fff; border-color: var(--accent); }
#user-profile .btn-secondary { padding: 8px 11px; }
#syllabus-progress > h2, #syllabus-progress > .syp-intro { display: none; }

/* ------------------------------------------------------------------ SYLLABUS: master + detail */
.sx { display: grid; grid-template-columns: minmax(0, 1fr); gap: 18px; height: calc(100vh - 152px); height: calc(100dvh - 152px); min-height: 520px; }
.sx-left, .sx-pane { min-height: 0; min-width: 0; background: var(--surface); border: 1px solid var(--border); border-radius: 18px; }
.sx-left { display: flex; flex-direction: column; overflow: hidden; position: relative; }
.sx-pane { overflow-y: auto; overscroll-behavior: contain; position: relative; scroll-behavior: smooth; }
/* On desktop the list owns the full width; the detail pane replaces it once a topic is opened. */
@media (min-width: 1001px) {
  .sx-pane { display: none; }
  .sx.sx-open .sx-left { display: none; }
  .sx.sx-open .sx-pane { display: block; }
}
.sx-scroll { flex: 1 1 auto; min-height: 0; overflow-y: auto; overscroll-behavior: contain; position: relative; scrollbar-gutter: stable; }
.sx-head { padding: 12px 16px 6px; display: flex; flex-direction: column; gap: 9px; background: var(--surface); }
.sx-hero { display: flex; align-items: center; gap: 12px; }
.sx-hero-text h2 { font-size: 18px; font-weight: 800; letter-spacing: -.02em; line-height: 1.2; }
.sx-hero-text p { font-size: 12.5px; color: var(--text-soft); margin-top: 1px; line-height: 1.35; }
.sx-hero-text p b { color: var(--text); }
.sx-ring { --p: 0; flex: 0 0 auto; width: 46px; height: 46px; border-radius: 50%; display: grid; place-items: center; position: relative;
  background: conic-gradient(var(--accent) calc(var(--p) * 1%), var(--surface-2) 0); }
.sx-ring::before { content: ''; position: absolute; inset: 5px; border-radius: 50%; background: var(--surface); }
.sx-ring span { position: relative; font-weight: 800; font-size: 13px; }
.sx-ring small { font-size: 9px; font-weight: 700; color: var(--text-soft); }
.sx-duebtn { margin-top: 6px; border: 0; background: var(--accent-soft); color: var(--accent); font-weight: 700; font-size: 12px; padding: 5px 11px; border-radius: 99px; cursor: pointer; }
.sx-duebtn:hover { filter: brightness(.97); }

.sx-papers { display: flex; gap: 8px; overflow-x: auto; padding: 1px 2px 4px; margin: 0 -2px; scrollbar-width: thin; -webkit-overflow-scrolling: touch; scroll-snap-type: x proximity; }
.sx-pchip { flex: 0 0 auto; scroll-snap-align: start; min-width: 86px; text-align: left; background: var(--surface-2); border: 1px solid transparent; border-radius: 11px; padding: 6px 10px; display: grid; gap: 2px; color: var(--text); transition: border-color .15s, background .15s; }
.sx-pchip:hover { border-color: var(--accent); }
.sx-pchip.active { background: var(--accent-soft); border-color: var(--accent); }
.sx-pname { font-size: 10.5px; font-weight: 800; letter-spacing: .04em; text-transform: uppercase; color: var(--text-soft); }
.sx-pchip.active .sx-pname { color: var(--accent); }
.sx-pnum { font-size: 11.5px; color: var(--text-soft); } .sx-pnum b { font-size: 15px; color: var(--text); }
.sx-pchip .syp-bar { height: 4px; }

/* The search and filters stay pinned while the header above scrolls away and the topics scroll beneath. */
.sx-tools { display: flex; flex-direction: column; gap: 8px; position: sticky; top: 0; z-index: 4; padding: 8px 16px 10px; background: var(--surface); border-bottom: 1px solid var(--border); }
.sx-search { display: flex; align-items: center; gap: 10px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 12px; padding: 0 12px; }
.sx-search:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.sx-search i { color: var(--text-soft); font-size: 14px; }
.sx-search input { flex: 1; min-width: 0; border: 0; background: transparent; color: var(--text); font: inherit; font-size: 14px; padding: 9px 0; outline: none; }
.sx-fchips { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 2px; scrollbar-width: none; -webkit-overflow-scrolling: touch; }
.sx-fchips::-webkit-scrollbar, .sx-papers::-webkit-scrollbar { display: none; }
/* The count rides along with the status chips instead of claiming a row of its own. */
.sx-fbar { display: flex; align-items: center; gap: 10px; }
.sx-fbar .sx-fchips { flex: 1 1 auto; min-width: 0; }
.sx-fchip { flex: 0 0 auto; background: transparent; border: 1px solid var(--border); color: var(--text-soft); border-radius: 99px; padding: 5px 12px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.sx-fchip:hover { border-color: var(--accent); color: var(--text); }
.sx-fchip.active { background: var(--accent); border-color: var(--accent); color: #fff; }
.sx-tools-row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; font-size: 12.5px; color: var(--text-soft); }
.sx-sel { display: inline-flex; align-items: center; gap: 6px; }
.sx-sel select { background: var(--surface-2); border: 1px solid var(--border); color: var(--text); border-radius: 8px; padding: 5px 8px; font-size: 12.5px; }
.sx-check { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; }
.sx-check input { accent-color: var(--accent); width: 16px; height: 16px; }
.sx-count { margin-left: auto; font-weight: 600; }

.sx-list { padding: 4px 10px 62px; }
.sx-totop { position: absolute; right: 18px; bottom: 18px; z-index: 5; width: 40px; height: 40px; border-radius: 50%; border: 1px solid var(--border); background: var(--surface); color: var(--text); display: grid; place-items: center; font-size: 15px; cursor: pointer; box-shadow: 0 6px 18px rgba(0,0,0,.18); }
.sx-totop:hover { border-color: var(--accent); color: var(--accent); }
.sx-totop[hidden] { display: none; }
.sx-paper { position: sticky; top: var(--sx-tools-h, 0px); z-index: 3; background: var(--surface); font-size: 11px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; color: var(--accent); padding: 12px 6px 5px; }
.sx-group { display: flex; gap: 8px; align-items: baseline; flex-wrap: wrap; padding: 8px 6px 3px; }
.sx-group-title { font-size: 12.5px; font-weight: 800; color: var(--text); }
.sx-group-ref { font-size: 11.5px; color: var(--text-soft); }

.sx-row { scroll-margin-top: calc(var(--sx-tools-h, 0px) + 40px); position: relative; display: flex; align-items: center; gap: 10px; padding: 8px 10px 8px 16px; margin: 2px 0; border: 1px solid transparent; border-radius: 12px; cursor: pointer; transition: background .15s, border-color .15s; }
.sx-row:hover { background: var(--surface-2); }
.sx-row.sel { background: var(--accent-soft); border-color: var(--accent); }
.sx-stripe { position: absolute; left: 5px; top: 8px; bottom: 8px; width: 4px; border-radius: 4px; background: var(--st-none); }
.sx-row[data-status="studying"] .sx-stripe { background: var(--st-studying); }
.sx-row[data-status="notes_ready"] .sx-stripe { background: var(--st-notes); }
.sx-row[data-status="revision_1"] .sx-stripe { background: var(--st-rev1); }
.sx-row[data-status="revision_2"] .sx-stripe { background: var(--st-rev2); }
.sx-main { flex: 1; min-width: 0; }
.sx-title { font-size: 14px; font-weight: 700; line-height: 1.35; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.sx-meta { display: flex; flex-wrap: wrap; gap: 4px 10px; align-items: center; margin-top: 4px; font-size: 11.5px; color: var(--text-soft); }
.sx-ref { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 150px; }
.sx-prio { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 6px; vertical-align: 1px; background: var(--text-soft); }
.sx-prio-high { background: #dc2626; } .sx-prio-medium { background: #f59e0b; } .sx-prio-low { background: #10b981; }
.sx-side { display: flex; align-items: center; gap: 10px; flex: 0 0 auto; }
.sx-status { max-width: 118px; background: var(--surface); border: 1px solid var(--border); color: var(--text); border-radius: 99px; padding: 5px 8px; font-size: 11.5px; font-weight: 700; }
.sx-row[data-status="studying"] .sx-status { border-color: var(--st-studying); }
.sx-row[data-status="notes_ready"] .sx-status { border-color: var(--st-notes); }
.sx-row[data-status="revision_1"] .sx-status { border-color: var(--st-rev1); }
.sx-row[data-status="revision_2"] .sx-status { border-color: var(--st-rev2); }
.sx-go { background: transparent; border: 0; color: var(--accent); font-size: 12px; font-weight: 700; padding: 2px 2px; display: inline-flex; align-items: center; gap: 5px; border-radius: 6px; }
.sx-go i { font-size: 10px; transition: transform .15s; }
.sx-row:hover .sx-go i { transform: translateX(3px); }
.sx-row:focus-within, .sx-go:focus-visible, .sx-fchip:focus-visible, .sx-pchip:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ------------------------------------------------------------------ TOPIC DETAIL */
#sx-detail { padding: 0 0 28px; }
.td-bar { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 14px 20px 0; }
.td-back { display: inline-flex; }
.td-head { padding: 12px 20px 4px; }
.td-title { font-size: 24px; font-weight: 800; letter-spacing: -.025em; line-height: 1.25; margin: 8px 0 4px; }
#sx-detail .th-kicker { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; font-size: 12.5px; color: var(--text-soft); }
#sx-detail .th-ref { font-size: 13px; color: var(--text-soft); margin: 2px 0 0; line-height: 1.5; }

.td-stepper { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; margin: 16px 0 14px; position: relative; }
.td-step { background: transparent; border: 0; display: flex; flex-direction: column; align-items: center; gap: 6px; font-size: 11px; font-weight: 700; color: var(--text-soft); padding: 4px 2px; position: relative; text-align: center; line-height: 1.2; }
.td-step i { font-style: normal; width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; background: var(--surface-2); border: 2px solid var(--border); font-size: 12px; font-weight: 800; color: var(--text-soft); position: relative; z-index: 1; transition: all .15s; }
.td-step::before { content: ''; position: absolute; top: 18px; right: 50%; width: 100%; height: 2px; background: var(--border); z-index: 0; }
.td-step:first-child::before { display: none; }
.td-step.done::before, .td-step.on::before { background: var(--accent); }
.td-step.done i { background: var(--accent); border-color: var(--accent); color: #fff; }
.td-step.on i { background: var(--surface); border-color: var(--accent); color: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); }
.td-step.on { color: var(--text); }
.td-step:hover i { border-color: var(--accent); }
.td-step:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 8px; }

.td-controls { display: flex; align-items: flex-end; gap: 12px; flex-wrap: wrap; padding-bottom: 14px; }
.td-controls select, .td-controls input[type="date"] { background: var(--surface-2); border: 1px solid var(--border); color: var(--text); border-radius: 9px; padding: 7px 10px; font-size: 13px; min-height: 36px; }
.td-controls .pq-btn { min-height: 36px; margin-left: auto; }

.td-tabs { position: sticky; top: 0; z-index: 6; display: flex; gap: 4px; overflow-x: auto; padding: 8px 14px; background: var(--surface); border-top: 1px solid var(--border); border-bottom: 1px solid var(--border); scrollbar-width: none; -webkit-overflow-scrolling: touch; }
.td-tabs::-webkit-scrollbar { display: none; }
.td-tab { flex: 0 0 auto; display: inline-flex; align-items: center; gap: 7px; border: 0; background: transparent; color: var(--text-soft); font-size: 13px; font-weight: 700; padding: 8px 13px; border-radius: 10px; white-space: nowrap; }
.td-tab i { font-size: 13px; }
.td-tab em { font-style: normal; font-size: 11px; font-weight: 800; background: var(--surface-2); color: var(--text-soft); border-radius: 99px; padding: 1px 7px; }
.td-tab:hover { background: var(--surface-2); color: var(--text); }
.td-tab.active { background: var(--accent-soft); color: var(--accent); }
.td-tab.active em { background: var(--accent); color: #fff; }
.td-tab:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

.td-panel { padding: 16px 20px 0; display: grid; gap: 14px; align-content: start; }
.td-panel .th-card { margin: 0; }
.td-jlist { list-style: none; display: grid; gap: 8px; padding: 0; }
.td-jlist li { display: flex; align-items: center; justify-content: space-between; gap: 10px; border: 1px solid var(--border); border-radius: 12px; padding: 10px 12px; }
.td-jlist li:hover { border-color: var(--accent); }
.td-jlink { color: var(--text); font-weight: 600; font-size: 14px; text-decoration: none; line-height: 1.4; }
.td-jlink small { color: var(--text-soft); font-weight: 500; }
.td-jlink:hover { color: var(--accent); }
.td-rel { color: var(--text-soft); font-size: 11px; text-transform: uppercase; letter-spacing: .05em; flex: 0 0 auto; }
#sx-detail a.syp-chip { text-decoration: none; cursor: pointer; }
#sx-detail a.syp-chip:hover { border-color: var(--accent); color: var(--accent); }

/* ------------------------------------------------------------------ EXPLORE (frame inside the workspace) */
#explore.active { display: flex; flex-direction: column; min-height: 0; flex: 1 1 auto; }
.xp-head { display: none; }
.xp-shell { position: relative; flex: 1; min-height: 0; border: 1px solid var(--border); border-radius: 18px; overflow: hidden; background: var(--bg); }
#explore-frame { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; background: var(--bg); }
.xp-loading { position: absolute; inset: 0; z-index: 2; display: flex; align-items: center; justify-content: center; gap: 12px; background: var(--bg); color: var(--text-soft); font-weight: 600; transition: opacity .2s; }
.xp-loading.done { opacity: 0; pointer-events: none; }
.xp-spin { width: 22px; height: 22px; border-radius: 50%; border: 3px solid var(--border); border-top-color: var(--accent); animation: xpspin .8s linear infinite; }
@keyframes xpspin { to { transform: rotate(360deg); } }
#explore .xp-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.xp-newtab span { white-space: nowrap; }
@media (min-width: 901px) {
  body.xp-active .content { display: flex; flex-direction: column; overflow: hidden; padding-bottom: 22px; }
  body.xp-active .topbar { padding: 16px 0 12px; margin-bottom: 14px; flex: 0 0 auto; }
  body.xp-active .content > #explore.active { flex: 1 1 auto; min-height: 0; }
  body.xp-active #explore .xp-head { display: flex; margin-bottom: 10px; flex: 0 0 auto; }
  body.xp-active #explore .xp-head h2 { font-size: 20px; font-weight: 800; }
}

/* Syllabus owns the viewport: the page itself never scrolls, only the topic list does.
   Without this the section was taller than the space left under the topbar, so the page
   scrolled on load and clipped the heading, and the list only had room for a couple of rows. */
@media (min-width: 1001px) {
  body.syl-active .content { display: flex; flex-direction: column; overflow: hidden; padding-bottom: 22px; }
  body.syl-active .topbar { flex: 0 0 auto; }
  body.syl-active #syllabus-progress.active { display: flex; flex-direction: column; flex: 1 1 auto; min-height: 0; }
  body.syl-active #syllabus-progress > #syp-root { display: flex; flex-direction: column; flex: 1 1 auto; min-height: 0; }
  body.syl-active .sx { flex: 1 1 auto; height: auto; min-height: 0; }
}
/* Very short windows cannot give the list a usable viewport, so let the page scroll
   instead and keep the section at its natural height. */
@media (min-width: 1001px) and (max-height: 620px) {
  body.syl-active .content { display: block; overflow-y: auto; }
  body.syl-active #syllabus-progress.active,
  body.syl-active #syllabus-progress > #syp-root { display: block; }
  body.syl-active .sx { display: block; height: auto; min-height: 0; }
  body.syl-active .sx-left { overflow: visible; }
  body.syl-active .sx-scroll { overflow: visible; flex: 0 0 auto; }
  body.syl-active .sx-tools { position: static; }
  body.syl-active .sx-paper { position: static; }
  body.syl-active .sx-totop { display: none !important; }
  /* Keep the topbar in view when the browser jumps to the #syllabus-progress fragment. */
  body.syl-active #syllabus-progress { scroll-margin-top: 141px; }
}

/* ------------------------------------------------------------------ READER PANEL */
.rd-backdrop { position: fixed; inset: 0; z-index: 1190; background: rgba(10, 12, 20, .5); opacity: 0; pointer-events: none; transition: opacity .2s; }
.rd-backdrop.open { opacity: 1; pointer-events: auto; }
.rd { position: fixed; top: 0; right: 0; bottom: 0; z-index: 1200; width: min(980px, 94vw); background: var(--bg); border-left: 1px solid var(--border); box-shadow: -18px 0 50px rgba(0,0,0,.25); display: flex; flex-direction: column; transform: translateX(104%); visibility: hidden; transition: transform .28s ease, visibility 0s .28s; }
.rd.open { transform: none; visibility: visible; transition: transform .28s ease; }
.rd-bar { display: flex; align-items: center; gap: 12px; padding: 10px 14px; background: var(--surface); border-bottom: 1px solid var(--border); }
.rd-bar h3 { flex: 1; min-width: 0; font-size: 15px; font-weight: 800; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#rd-frame { flex: 1; width: 100%; border: 0; background: var(--bg); }
body.rd-lock .content { overflow: hidden; }

/* ------------------------------------------------------------------ DESKTOP polish */

/* ------------------------------------------------------------------ TABLET / PHONE */
@media (max-width: 1000px) {
  .sx { display: block; height: auto; min-height: 0; }
  .sx-left { border: 0; background: transparent; overflow: visible; }
  .sx-scroll { overflow: visible; flex: none; scrollbar-gutter: auto; }
  .sx-head { border: 1px solid var(--border); border-radius: 18px 18px 0 0; border-bottom: 0; }
  .sx-tools { top: 0; z-index: 20; border: 1px solid var(--border); border-top: 0; border-radius: 0 0 18px 18px; margin-bottom: 10px; }
  .sx-list { padding: 0 0 24px; }
  .sx-paper { top: var(--sx-tools-h, 0px); background: var(--bg); }
  .sx-pane { position: fixed; inset: 0; z-index: 320; border: 0; border-radius: 0; background: var(--bg); transform: translateY(100%); visibility: hidden; transition: transform .28s ease, visibility 0s .28s; padding-bottom: env(safe-area-inset-bottom); }
  .sx-open .sx-pane { transform: none; visibility: visible; transition: transform .28s ease; }
  .td-bar { position: sticky; top: 0; z-index: 8; background: var(--bg); padding: 10px 14px; border-bottom: 1px solid var(--border); }
  .td-head { padding: 12px 16px 4px; }
  .td-title { font-size: 21px; }
  .td-tabs { top: 56px; }
  .td-panel { padding: 14px 16px 0; }
  .sx-totop { display: none !important; }
}
@media (max-width: 900px) {
  /* header: compact, labels collapse to icons */
  .topbar { padding: 14px 0 10px; margin-bottom: 14px; gap: 10px; flex-wrap: wrap; }
  .topbar h1 { font-size: 20px; line-height: 1.25; }
  .topbar p { font-size: 12.5px; margin-top: 1px; }
  .topbar-actions { gap: 8px; flex-wrap: nowrap; }
  .topbar-actions .btn-secondary { padding: 8px 11px; font-size: 13px; }
  .topbar-actions .btn-secondary .lbl, .btn-signin span { display: none; }
  .btn-signin span { display: inline; }
  .mobile-nav { padding: 12px 16px !important; }
  /* bottom nav: roomy touch targets and safe area */
  .bottom-nav { height: auto !important; min-height: 58px; padding: 4px 6px calc(4px + env(safe-area-inset-bottom)) !important; box-shadow: 0 -6px 20px rgba(0,0,0,.06); }
  .bottom-nav-btn { min-height: 48px; font-size: 10.5px !important; }
  .bottom-nav-btn i { font-size: 19px !important; }
  .content { padding-bottom: calc(86px + env(safe-area-inset-bottom)) !important; }
  .toast { bottom: calc(80px + env(safe-area-inset-bottom)); max-width: calc(100vw - 32px); text-align: center; }
  /* touch friendliness: 16px fields stop iOS zooming in, comfortable tap size */
  input, select, textarea { font-size: 16px; }
  .sx-search input { font-size: 16px; }
  .btn-secondary, .btn-primary, .pq-btn, .pq-pill { min-height: 40px; }
  img, video, canvas, svg { max-width: 100%; }
  table { display: block; overflow-x: auto; max-width: 100%; }
  /* explore frame fills the screen above the bottom bar */
  body.xp-active .content { display: flex; flex-direction: column; overflow: hidden; padding: 0 0 calc(62px + env(safe-area-inset-bottom)) !important; }
  body.xp-active .topbar { display: none; }
  body.xp-active .mobile-nav { flex: 0 0 auto; }
  body.xp-active .content > #explore.active { flex: 1 1 auto; min-height: 0; }
  body.xp-active #explore .xp-head { display: block; position: absolute; top: calc(10px + env(safe-area-inset-top)); right: 10px; left: auto; z-index: 5; width: auto; margin: 0; }
  body.xp-active #explore .xp-head h2 { display: none; }
  body.xp-active #explore .xp-head .xp-newtab { box-shadow: 0 2px 10px rgba(0,0,0,.18); }
  body.xp-active #explore .xp-head .xp-newtab span { display: none; }
  body.xp-active .xp-shell { position: relative; border: 0; border-radius: 0; }
  .rd { width: 100vw; border-left: 0; }
  .rd-bar { padding-top: calc(10px + env(safe-area-inset-top)); }
  .rd-bar .pq-btn span { display: none; }
}
@media (max-width: 560px) {
  .sx-row { padding: 11px 8px 11px 14px; gap: 8px; }
  .sx-status { max-width: 108px; }
  .td-step { font-size: 10px; }
  .td-step i { width: 26px; height: 26px; }
  .td-step::before { top: 17px; }
  .td-controls .pq-btn { margin-left: 0; width: 100%; justify-content: center; }
  .td-controls .syp-f { flex: 1 1 140px; }
  .td-controls select, .td-controls input[type="date"] { width: 100%; font-size: 16px; }
  .stats-row { grid-template-columns: 1fr 1fr !important; }
}
@media (prefers-reduced-motion: reduce) {
  .sx-pane, .rd, .xp-spin, .sx-row, .td-step i { transition: none !important; animation: none !important; }
}

/* ------------------------------------------------------------------ SYLLABUS declutter: collapsed filter row + plain-text link */
.sx-hero { position: relative; }
.sx-textbtn { position: absolute; top: 0; right: 0; display: inline-flex; align-items: center; gap: 6px; background: var(--surface-2); border: 1px solid var(--border); color: var(--text-soft); font-size: 11.5px; font-weight: 700; padding: 6px 10px; border-radius: 99px; white-space: nowrap; }
.sx-textbtn:hover { border-color: var(--accent); color: var(--accent); }
.sx-toprow { display: flex; gap: 8px; align-items: center; }
.sx-toprow .sx-search { flex: 1; }
.sx-filtbtn { flex: 0 0 auto; width: 38px; height: 38px; border-radius: 10px; border: 1px solid var(--border); background: var(--surface); color: var(--text-soft); display: grid; place-items: center; font-size: 14px; }
.sx-filtbtn:hover { border-color: var(--accent); color: var(--accent); }
.sx-filtbtn.on { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }
.sx-tools-row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; font-size: 12.5px; color: var(--text-soft); background: var(--surface-2); border-radius: 10px; padding: 9px 10px; margin-top: 2px; }
.sx-tools-row[hidden] { display: none; }
.sx-count { font-size: 11.5px; color: var(--text-soft); font-weight: 600; flex: 0 0 auto; white-space: nowrap; }
@media (max-width: 1000px) {
  .sx-textbtn span { display: none; }
  .sx-textbtn { padding: 6px; width: 30px; height: 30px; justify-content: center; }
}

/* ------------------------------------------------------------------ PDF download: icon button + popover menu */
.pdfbtn-wrap { position: relative; }
.pdfbtn { width: 40px; padding: 0 !important; display: inline-flex; align-items: center; justify-content: center; }
.pdfmenu { position: absolute; top: calc(100% + 6px); right: 0; z-index: 40; min-width: 240px; background: var(--surface); border: 1px solid var(--border); border-radius: 14px; box-shadow: 0 14px 34px rgba(0,0,0,.16); padding: 6px; display: none; flex-direction: column; gap: 2px; }
.pdfmenu.open { display: flex; }
.pdfmenu button { display: flex; align-items: center; gap: 10px; text-align: left; background: transparent; border: 0; border-radius: 10px; padding: 9px 10px; color: var(--text); }
.pdfmenu button:hover { background: var(--surface-2); }
.pdfmenu button i { width: 18px; color: var(--accent); font-size: 15px; flex: 0 0 auto; }
.pdfmenu button b { display: block; font-size: 13.5px; font-weight: 700; }
.pdfmenu button small { display: block; font-size: 11px; color: var(--text-soft); font-weight: 500; margin-top: 1px; }

/* ------------------------------------------------------------------ Customize PDF modal */
.pdfcust-content { max-width: 440px; }
.pdfcust-sub { font-size: 13px; color: var(--text-soft); margin-bottom: 14px; }
.pdfcust-row { display: flex; align-items: flex-start; gap: 10px; padding: 10px 4px; border-top: 1px solid var(--border); cursor: pointer; }
.pdfcust-row:first-of-type { border-top: 0; }
.pdfcust-row input { margin-top: 3px; width: 17px; height: 17px; accent-color: var(--accent); flex: 0 0 auto; }
.pdfcust-row b { display: block; font-size: 13.5px; font-weight: 700; }
.pdfcust-row small { display: block; font-size: 12px; color: var(--text-soft); margin-top: 1px; line-height: 1.4; }

/* ------------------------------------------------------------------ Sidebar account card (moved out of the topbar so the header stays slim) */
.sb-account { margin-top: auto; padding-top: 14px; border-top: 1px solid var(--border); }
.sb-signin { display: flex; align-items: center; justify-content: center; gap: 8px; background: var(--accent); color: #fff; font-weight: 700; font-size: 13.5px; padding: 10px 12px; border-radius: 12px; text-decoration: none; }
.sb-signin:hover { color: #fff; filter: brightness(1.06); }
.sb-user { display: flex; align-items: center; gap: 8px; }
.sb-user-main { flex: 1; min-width: 0; display: flex; align-items: center; gap: 10px; background: transparent; border: 0; padding: 6px; border-radius: 12px; text-align: left; }
.sb-user-main:hover { background: var(--surface-2); }
.sb-user-main img { width: 34px; height: 34px; border-radius: 50%; flex: 0 0 auto; object-fit: cover; background: var(--surface-2); }
.sb-user-text { display: flex; flex-direction: column; line-height: 1.25; min-width: 0; }
.sb-user-text #user-name { font-size: 13.5px; font-weight: 700; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sb-user-text .sync-status { font-size: 11px; color: var(--text-soft); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sb-signout { flex: 0 0 auto; width: 32px; height: 32px; border-radius: 9px; border: 1px solid var(--border); background: var(--surface); color: var(--text-soft); display: grid; place-items: center; }
.sb-signout:hover { border-color: var(--accent); color: var(--accent); }
@media (max-width: 1000px) {
  .sb-account { padding-bottom: env(safe-area-inset-bottom, 0px); }
}

/* ------------------------------------------------------------------ Overview: guest sign-in banner */
.guest-banner { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap;
  background: var(--accent-soft); border: 1px solid var(--accent); border-radius: 14px; padding: 13px 18px;
  margin-bottom: 20px; text-decoration: none; color: var(--text); transition: filter .15s; }
.guest-banner:hover { filter: brightness(0.98); color: var(--text); }
.guest-banner-text { font-size: 13.5px; line-height: 1.5; }
.guest-banner-text i { color: var(--accent); margin-right: 4px; }
.guest-banner-cta { flex: 0 0 auto; display: inline-flex; align-items: center; gap: 6px; background: var(--accent); color: #fff; font-weight: 700; font-size: 13px; padding: 8px 14px; border-radius: 10px; white-space: nowrap; }
@media (max-width: 640px) { .guest-banner { padding: 12px 14px; } .guest-banner-cta { width: 100%; justify-content: center; } }

/* ------------------------------------------------------------------ Topic detail: "Your material & notes" */
.th-material .th-card-head span { font-size: 12px; color: var(--text-soft); font-weight: 600; }
.mat-add-btn { margin: 8px 0 4px; }
.mat-form { margin-top: 12px; padding: 14px; background: var(--surface-2); border-radius: 12px; display: grid; gap: 10px; }
.mat-form.hidden { display: none; }
.mat-form textarea { width: 100%; resize: vertical; min-height: 80px; border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; background: var(--surface); color: var(--text); font: inherit; font-size: 14px; }
.mat-form-row { display: flex; align-items: center; gap: 10px; }
.mat-upload { display: inline-flex; align-items: center; gap: 7px; background: var(--surface); border: 1px solid var(--border); border-radius: 9px; padding: 7px 12px; font-size: 13px; font-weight: 600; cursor: pointer; color: var(--text); }
.mat-upload:hover { border-color: var(--accent); color: var(--accent); }
.mat-file-count { font-size: 12px; color: var(--text-soft); }
.mat-previews { display: flex; flex-wrap: wrap; gap: 8px; }
.mat-preview { position: relative; width: 64px; height: 64px; border-radius: 8px; overflow: hidden; border: 1px solid var(--border); }
.mat-preview img { width: 100%; height: 100%; object-fit: cover; display: block; }
.mat-preview button { position: absolute; top: 2px; right: 2px; width: 18px; height: 18px; border-radius: 50%; background: rgba(0,0,0,.6); color: #fff; border: 0; display: grid; place-items: center; font-size: 10px; }
.mat-form-actions { display: flex; gap: 8px; justify-content: flex-end; }
.mat-list { display: grid; gap: 10px; margin-top: 12px; }
.mat-item { border: 1px solid var(--border); border-radius: 12px; padding: 12px 14px; }
.mat-item-top { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; }
.mat-date { font-size: 11.5px; color: var(--text-soft); font-weight: 600; }
.mat-del { background: transparent; border: 0; color: var(--text-soft); width: 26px; height: 26px; border-radius: 7px; display: grid; place-items: center; }
.mat-del:hover { background: var(--danger-bg); color: var(--danger); }
.mat-text { font-size: 13.5px; line-height: 1.6; white-space: pre-wrap; margin: 0 0 8px; }
.mat-imgs { display: flex; flex-wrap: wrap; gap: 8px; }
.mat-thumb { padding: 0; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; width: 72px; height: 72px; }
.mat-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.mat-thumb:hover { border-color: var(--accent); }
.mat-lightbox { position: fixed; inset: 0; z-index: 10020; background: rgba(0,0,0,.82); display: flex; align-items: center; justify-content: center; padding: 30px; }
.mat-lightbox img { max-width: 100%; max-height: 100%; border-radius: 6px; }
.mat-lightbox-close { position: absolute; top: 18px; right: 18px; width: 40px; height: 40px; border-radius: 50%; background: rgba(255,255,255,.12); border: 0; color: #fff; display: grid; place-items: center; font-size: 16px; }

/* Shared study material (permanent, visible to everyone) */
.sm-input { width: 100%; border: 1px solid var(--border); border-radius: 10px; padding: 9px 12px; background: var(--surface); color: var(--text); font: inherit; font-size: 14px; }
.sm-input:focus, .mat-form textarea:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
.sm-title { font-size: 15px; font-weight: 800; margin: 0 0 6px; line-height: 1.35; }
.sm-link { display: inline-flex; align-items: center; gap: 7px; font-size: 13px; font-weight: 700; color: var(--accent); text-decoration: none; padding: 6px 12px; border: 1px solid var(--border); border-radius: 99px; background: var(--surface-2); }
.sm-link:hover { border-color: var(--accent); }
.sm-link small { font-weight: 600; color: var(--text-soft); font-size: 11.5px; }
