:root {
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: #172033;
  background: #f5f7fb;
  font-synthesis: none;
  text-rendering: optimizeLegibility;
  --ink: #172033;
  --muted: #536176;
  --line: #e2e8f0;
  --surface: #ffffff;
  --canvas: #f5f7fb;
  --blue: #265bd4;
  --blue-dark: #1746b2;
  --blue-soft: #edf3ff;
  --teal: #087f73;
  --shadow: 0 10px 30px rgb(25 45 80 / 7%);
}

* { box-sizing: border-box; }
body { margin: 0; min-width: 320px; min-height: 100vh; background: var(--canvas); }
button, input, select { font: inherit; }
button, select { color: inherit; }
a { color: var(--blue-dark); }
a:hover { color: #102f79; }
button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible, [tabindex="-1"]:focus-visible {
  outline: 3px solid #1d4ed8;
  outline-offset: 3px;
}
.visually-hidden { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
.skip-link { position: fixed; z-index: 20; top: 8px; left: 8px; padding: 10px 14px; color: #fff; background: #172033; border-radius: 8px; transform: translateY(-160%); }
.skip-link:focus { transform: translateY(0); color: #fff; }

.app-shell { max-width: 1760px; min-height: 100vh; margin: 0 auto; }
.topbar { position: sticky; z-index: 5; top: 0; display: grid; grid-template-columns: 250px minmax(240px, 1fr) auto; align-items: center; gap: 28px; min-height: 82px; padding: 14px 36px; border-bottom: 1px solid var(--line); background: rgb(255 255 255 / 94%); backdrop-filter: blur(12px); }
.brand { display: inline-flex; align-items: center; gap: 11px; width: fit-content; color: var(--ink); text-decoration: none; }
.brand-mark { display: grid; width: 42px; height: 42px; place-items: center; border-radius: 13px; color: #fff; background: linear-gradient(145deg, #3674ee, #2448a8); font-size: 15px; font-weight: 800; letter-spacing: -.06em; box-shadow: 0 6px 14px rgb(38 91 212 / 24%); }
.brand strong, .brand small { display: block; }
.brand strong { font-size: 17px; letter-spacing: -.02em; }
.brand small { margin-top: 2px; color: var(--muted); font-size: 12px; }
.search-wrap { position: relative; display: flex; align-items: center; min-height: 46px; max-width: 720px; border: 1px solid #dce3ef; border-radius: 13px; background: #f8faff; transition: border-color .15s, box-shadow .15s; }
.search-wrap:focus-within { border-color: #7799e9; box-shadow: 0 0 0 3px rgb(38 91 212 / 10%); }
.search-icon { padding-left: 15px; color: #52627a; font-size: 25px; line-height: 1; transform: rotate(-20deg); }
.search-wrap input { width: 100%; min-width: 0; height: 44px; padding: 0 12px; border: 0; outline: 0; color: var(--ink); background: transparent; }
.search-wrap input::placeholder { color: #5a677a; opacity: 1; }
.clear-search, .icon-button { display: grid; width: 36px; height: 36px; flex: 0 0 auto; place-items: center; border: 0; border-radius: 10px; color: #34445b; background: transparent; cursor: pointer; font-size: 24px; }
.clear-search { margin-right: 5px; }
.icon-button:hover { background: #edf1f7; }
.mobile-category-button { display: none; }

.content-layout { display: grid; grid-template-columns: 250px minmax(0, 1fr); gap: 36px; padding: 35px 36px 64px; }
.sidebar { position: sticky; top: 111px; align-self: start; min-height: 400px; padding: 8px 0; }
.sidebar-label { margin: 0 0 15px 13px; color: #58677d; font-size: 11px; font-weight: 750; letter-spacing: .13em; }
.category-nav { display: grid; gap: 5px; }
.category-link { display: flex; align-items: center; gap: 11px; width: 100%; min-height: 44px; padding: 9px 12px; border: 0; border-radius: 11px; color: #344158; background: transparent; text-align: left; text-decoration: none; cursor: pointer; font-size: 14px; font-weight: 600; }
.category-link:hover { color: #183b91; background: #edf2fb; }
.category-link[aria-current="page"] { color: #153eaa; background: #e8efff; }
.category-icon { display: grid; width: 24px; height: 24px; flex: 0 0 auto; place-items: center; border-radius: 8px; color: #3558a7; background: #eaf0ff; font-size: 13px; }
.category-count { margin-left: auto; color: #536176; font-size: 12px; font-weight: 500; }
.sidebar-note { display: flex; align-items: center; gap: 11px; margin: 27px 10px 0; padding: 15px 13px; border: 1px solid var(--line); border-radius: 13px; background: #fff; }
.status-dot { width: 9px; height: 9px; border-radius: 50%; background: #16a085; box-shadow: 0 0 0 4px #e5f7f1; }
.sidebar-note strong, .sidebar-note small { display: block; }
.sidebar-note strong { font-size: 14px; }
.sidebar-note small { margin-top: 2px; color: var(--muted); font-size: 11px; }
.tablet-filter { display: none; }
.main-content { min-width: 0; }
.page-heading { display: flex; align-items: end; justify-content: space-between; gap: 20px; margin: 4px 0 24px; }
.eyebrow { margin: 0 0 8px; color: #435f9d; font-size: 12px; font-weight: 750; letter-spacing: .1em; text-transform: uppercase; }
h1, h2, h3, p { overflow-wrap: anywhere; }
.page-heading h1 { margin: 0; color: #15223a; font-size: clamp(27px, 3vw, 38px); line-height: 1.14; letter-spacing: -.04em; }
.page-description { max-width: 670px; margin: 10px 0 0; color: var(--muted); font-size: 15px; line-height: 1.6; }
.result-count { flex: 0 0 auto; padding-bottom: 4px; color: var(--muted); font-size: 13px; }
.material-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; }
.material-card { display: flex; min-height: 238px; flex-direction: column; padding: 19px; border: 1px solid #e1e7f0; border-radius: 17px; color: inherit; background: var(--surface); box-shadow: 0 2px 8px rgb(33 50 80 / 3%); text-decoration: none; transition: transform .16s ease, box-shadow .16s ease, border-color .16s ease; }
.material-card:hover { transform: translateY(-3px); border-color: #c4d2f0; color: inherit; box-shadow: var(--shadow); }
.card-topline { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.card-icon { display: grid; width: 39px; height: 39px; place-items: center; border-radius: 12px; color: #2a53a9; background: var(--blue-soft); font-size: 18px; }
.card-arrow { color: #6a7890; font-size: 20px; }
.card-category { display: inline-flex; width: fit-content; margin-top: 17px; padding: 5px 9px; border-radius: 20px; color: #2450a7; background: #f0f4ff; font-size: 11px; font-weight: 700; }
.material-card h2 { margin: 12px 0 8px; color: #17233a; font-size: 17px; line-height: 1.34; letter-spacing: -.02em; }
.material-card p { margin: 0; color: #4c5b71; font-size: 13px; line-height: 1.55; }
.card-tags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: auto; padding-top: 15px; }
.tag { padding: 4px 7px; border: 1px solid #e8ecf2; border-radius: 7px; color: #526075; background: #fbfcfe; font-size: 10px; }
.load-more-wrap { display: flex; min-height: 78px; align-items: center; justify-content: center; padding: 18px; }
.primary-button, .secondary-button { min-height: 42px; padding: 10px 17px; border-radius: 11px; font-weight: 700; cursor: pointer; }
.primary-button { border: 1px solid var(--blue); color: #fff; background: var(--blue); }
.primary-button:hover { background: var(--blue-dark); }
.secondary-button { border: 1px solid #d6deea; color: #283750; background: #fff; }
.secondary-button:hover { background: #f1f5fb; }
.empty-state, .error-state, .loading-state { display: grid; justify-items: center; padding: 70px 24px; border: 1px dashed #cbd5e1; border-radius: 18px; color: var(--muted); background: #fff; text-align: center; }
.empty-icon { display: grid; width: 54px; height: 54px; place-items: center; margin-bottom: 15px; border-radius: 17px; color: #38579d; background: var(--blue-soft); font-size: 25px; }
.empty-state h2, .error-state h1 { margin: 0 0 7px; color: var(--ink); font-size: 21px; }
.empty-state p, .error-state p { max-width: 460px; margin: 0; color: var(--muted); line-height: 1.6; }
.error-state { border-style: solid; border-color: #f0d4d4; background: #fffafa; }
.error-state .error-icon { color: #a12a2a; background: #fff0f0; }
.error-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; margin-top: 20px; }
.token-form { display: flex; width: min(460px, 100%); gap: 8px; margin-top: 19px; }
.token-form input { min-width: 0; flex: 1; padding: 10px 12px; border: 1px solid #cbd5e1; border-radius: 10px; }
.loading-state { display: flex; justify-content: center; gap: 12px; border: 0; background: transparent; }
.spinner { width: 20px; height: 20px; border: 2px solid #cdd9f1; border-top-color: var(--blue); border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.search-summary { margin: -8px 0 20px; color: var(--muted); font-size: 14px; }
.search-result { margin-bottom: 13px; padding: 17px 19px; border: 1px solid var(--line); border-radius: 14px; background: #fff; }
.search-result h2 { margin: 0 0 7px; font-size: 17px; }
.search-result h2 a { color: #183b91; text-decoration: none; }
.search-result p { margin: 0; color: #46556b; font-size: 14px; line-height: 1.6; }
.search-result mark { padding: 0 2px; border-radius: 3px; color: #382b00; background: #fff0ae; }
.search-result-meta { margin-top: 8px !important; color: #5a687c !important; font-size: 12px !important; }

.material-detail { overflow: hidden; border: 1px solid var(--line); border-radius: 18px; background: #fff; box-shadow: 0 3px 14px rgb(35 54 88 / 4%); }
.detail-header { padding: 24px 27px 22px; border-bottom: 1px solid var(--line); background: linear-gradient(125deg, #fff, #f6f8ff); }
.back-link { display: inline-flex; align-items: center; gap: 7px; margin-bottom: 19px; color: #31549c; font-size: 13px; font-weight: 700; text-decoration: none; }
.detail-title-row { display: flex; align-items: start; justify-content: space-between; gap: 15px; }
.detail-title-row h1 { margin: 8px 0; color: #17233a; font-size: clamp(25px, 3vw, 34px); line-height: 1.2; letter-spacing: -.035em; }
.detail-description { max-width: 760px; margin: 0; color: var(--muted); line-height: 1.6; }
.detail-meta { display: flex; flex-wrap: wrap; gap: 8px 15px; margin-top: 15px; color: #58677d; font-size: 12px; }
.detail-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 16px; }
.article-content { max-width: 920px; padding: 25px 28px 38px; color: #263449; font-size: 15px; line-height: 1.75; overflow-wrap: anywhere; }
.article-content h1, .article-content h2, .article-content h3, .article-content h4 { margin: 1.55em 0 .55em; color: #17233a; line-height: 1.3; }
.article-content h1 { font-size: 1.75em; }
.article-content h2 { font-size: 1.45em; }
.article-content h3 { font-size: 1.2em; }
.article-content h4 { font-size: 1.05em; }
.article-content p { margin: .8em 0; }
.article-content ul, .article-content ol { padding-left: 1.5em; }
.article-content li { margin: .35em 0; }
.article-content blockquote { margin: 1em 0; padding: 10px 16px; border-left: 3px solid #6f8ed2; color: #43526a; background: #f5f8ff; }
.article-content code { padding: 2px 5px; border-radius: 5px; color: #173d80; background: #eef2f8; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .9em; }
.article-content pre { overflow: auto; padding: 14px; border-radius: 10px; background: #f0f3f8; }
.article-content pre code { padding: 0; background: transparent; }
.article-content table { width: 100%; border-collapse: collapse; font-size: 14px; }
.article-content th, .article-content td { padding: 9px 11px; border: 1px solid var(--line); text-align: left; vertical-align: top; }
.article-content th { background: #f2f5fa; }
.article-content a { overflow-wrap: anywhere; }
.toast { position: fixed; z-index: 30; right: 20px; bottom: 20px; max-width: min(380px, calc(100vw - 40px)); padding: 12px 16px; border-radius: 12px; color: #fff; background: #172033; box-shadow: var(--shadow); opacity: 0; pointer-events: none; transform: translateY(10px); transition: .18s ease; }
.toast.visible { opacity: 1; transform: translateY(0); }
.clipboard-fallback { position: fixed; left: -10000px; top: 0; width: 1px; height: 1px; opacity: 0; }
.category-drawer { display: none; }

@media (min-width: 1200px) {
  .content-layout { grid-template-columns: 250px minmax(0, 1fr); }
}

@media (min-width: 960px) and (max-width: 1199px) {
  .topbar { grid-template-columns: 220px minmax(240px, 1fr); }
  .content-layout { display: block; padding-top: 17px; }
  .sidebar { display: none; }
  .tablet-filter { display: flex; align-items: center; gap: 12px; padding: 15px 36px 0; color: #33435b; font-size: 13px; font-weight: 700; }
  .tablet-filter select { min-width: 230px; min-height: 40px; padding: 7px 35px 7px 12px; border: 1px solid #d7dfeb; border-radius: 10px; background: #fff; }
  .material-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

@media (min-width: 768px) and (max-width: 959px) {
  .topbar { grid-template-columns: 190px minmax(180px, 1fr); gap: 18px; padding-inline: 24px; }
  .content-layout { display: block; padding: 18px 24px 50px; }
  .sidebar { display: none; }
  .tablet-filter { display: flex; align-items: center; gap: 12px; padding: 15px 24px 0; color: #33435b; font-size: 13px; font-weight: 700; }
  .tablet-filter select { min-width: 220px; min-height: 40px; padding: 7px 35px 7px 12px; border: 1px solid #d7dfeb; border-radius: 10px; background: #fff; }
  .material-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 767px) {
  .topbar { position: static; grid-template-columns: 1fr auto; gap: 14px 10px; padding: 13px 16px 15px; }
  .brand-mark { width: 39px; height: 39px; }
  .brand strong { font-size: 16px; }
  .brand small { font-size: 11px; }
  .search-wrap { grid-column: 1 / -1; grid-row: 2; width: 100%; max-width: none; }
  .mobile-category-button { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 39px; padding: 7px 11px; border: 1px solid #dbe2ed; border-radius: 10px; color: #34445b; background: #fff; font-size: 13px; font-weight: 700; cursor: pointer; }
  .tablet-filter, .sidebar { display: none; }
  .content-layout { display: block; padding: 25px 16px 46px; }
  .page-heading { display: block; margin-bottom: 18px; }
  .page-heading h1 { font-size: 29px; }
  .page-description { margin-top: 8px; font-size: 14px; }
  .result-count { display: block; margin-top: 11px; }
  .material-grid { grid-template-columns: minmax(0, 1fr); gap: 11px; }
  .material-card { min-height: 0; padding: 16px; }
  .card-category { margin-top: 13px; }
  .material-card h2 { font-size: 16px; }
  .detail-header { padding: 19px 17px; }
  .detail-title-row { display: block; }
  .detail-title-row h1 { font-size: 26px; }
  .article-content { padding: 17px 17px 27px; font-size: 14px; }
  .category-drawer { position: fixed; inset: auto 0 0; width: 100%; max-width: none; max-height: min(76vh, 620px); margin: 0; padding: 10px 19px max(24px, env(safe-area-inset-bottom)); overflow: auto; border: 1px solid var(--line); border-radius: 22px 22px 0 0; color: var(--ink); background: #fff; box-shadow: 0 -12px 44px rgb(20 34 59 / 18%); }
  .category-drawer[open] { display: block; animation: drawer-in .18s ease-out; }
  .category-drawer::backdrop { background: rgb(15 23 42 / 48%); }
  .drawer-handle { width: 44px; height: 4px; margin: 1px auto 14px; border-radius: 5px; background: #c5cedb; }
  .drawer-heading { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
  .drawer-heading h2 { margin: 0; font-size: 18px; }
  .category-drawer .category-nav { gap: 3px; }
  .category-drawer .category-link { min-height: 47px; }
  .toast { right: 12px; bottom: 12px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}

@keyframes drawer-in { from { transform: translateY(18px); opacity: .7; } to { transform: translateY(0); opacity: 1; } }
