@font-face {
  font-family: "Pretendard";
  src: url("../assets/fonts/Pretendard-Regular.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "Pretendard";
  src: url("../assets/fonts/Pretendard-Medium.woff2") format("woff2");
  font-weight: 500;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "Pretendard";
  src: url("../assets/fonts/Pretendard-SemiBold.woff2") format("woff2");
  font-weight: 600;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "Pretendard";
  src: url("../assets/fonts/Pretendard-Bold.woff2") format("woff2");
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}

/* =========================================================
   Theme tokens
========================================================= */

:root {
  --md-text-font: "Pretendard", -apple-system, BlinkMacSystemFont, "Segoe UI",
    "Apple SD Gothic Neo", "Noto Sans KR", sans-serif;
}

html[data-md-color-scheme="default"],
[data-md-color-scheme="default"] {
  --md-default-bg-color: #f4ecd8;
  --md-code-bg-color: #efe6cf;
  --md-default-fg-color: #2b2b2b;

  --archive-bg: #eadfc6;
  --archive-bg-soft: #bdb39f;
  --archive-card-bg: #bdb39f;
  --archive-text: #2f2a22;
  --archive-text-strong: #1f1a12;
  --archive-border: rgba(80, 60, 30, 0.08);
  --archive-shadow: rgba(80, 60, 30, 0.10);
  --archive-selection-bg: #fff291;
  --archive-selection-text: #1f1a12;
  --archive-active: #8f6500;
  --archive-active-bg: rgba(184, 134, 11, 0.16);
  --archive-toc-active: #b8860b;
  --archive-rank-gap-bg: var(--archive-bg);
}

html[data-md-color-scheme="slate"],
[data-md-color-scheme="slate"] {
  --md-default-bg-color: #161311;

  --archive-bg: #161311;
  --archive-bg-soft: #211d1a;
  --archive-card-bg: #211d1a;
  --archive-text: #e6dcc8;
  --archive-text-strong: #f4ead5;
  --archive-border: rgba(255, 240, 210, 0.08);
  --archive-shadow: rgba(0, 0, 0, 0.28);
  --archive-selection-bg: #6f5a2a;
  --archive-selection-text: #fff8ea;
  --archive-active: #ffcc66;
  --archive-active-bg: rgba(255, 204, 102, 0.14);
  --archive-toc-active: #ffcc66;
  --archive-rank-gap-bg: var(--archive-bg);
}

/* =========================================================
   Base layout / typography
========================================================= */

body,
button,
input,
select,
textarea,
.md-typeset,
.md-nav,
.md-header,
.md-tabs,
.md-search,
.md-ellipsis,
.md-typeset h1,
.md-typeset h2,
.md-typeset h3,
.md-typeset h4,
.md-typeset h5,
.md-typeset h6 {
  font-family: var(--md-text-font) !important;
}

body,
.md-main,
.md-main__inner,
.md-content,
.md-content__inner,
.md-sidebar,
.md-sidebar__scrollwrap,
.md-sidebar__inner,
.md-nav,
.md-nav__source,
.md-search__scrollwrap {
  background-color: var(--archive-bg) !important;
}

.md-header,
.md-tabs {
  background-color: var(--archive-bg) !important;
}

body,
.md-typeset,
.md-nav,
.md-header,
.md-tabs,
.md-ellipsis,
.md-nav__link,
.md-typeset p,
.md-typeset li,
.md-typeset td,
.md-typeset th {
  color: var(--archive-text) !important;
}

.md-typeset h1 {
  color: var(--archive-text-strong) !important;
  font-weight: 700 !important;
}

.md-typeset h2,
.md-typeset h3,
.md-typeset h4,
.md-typeset h5,
.md-typeset h6 {
  color: var(--archive-text) !important;
  font-weight: 600 !important;
}

.md-header__title,
.md-header__topic,
.md-header__button,
.md-tabs__link {
  color: var(--archive-text-strong) !important;
}

::selection {
  background: var(--archive-selection-bg);
  color: var(--archive-selection-text);
}

::-moz-selection {
  background: var(--archive-selection-bg);
  color: var(--archive-selection-text);
}

/* =========================================================
   Sidebars / header panels
========================================================= */

.md-sidebar--primary .md-nav__title,
.md-sidebar--primary .md-nav__source,
.md-sidebar--secondary .md-nav__title {
  background: var(--archive-bg) !important;
  background-image: none !important;
  box-shadow: 0 0.08rem 0.24rem var(--archive-shadow) !important;
  border-bottom: 1px solid var(--archive-border) !important;
}

.md-sidebar--primary .md-nav__title::before,
.md-sidebar--primary .md-nav__title::after,
.md-sidebar--primary .md-nav__source::before,
.md-sidebar--primary .md-nav__source::after,
.md-sidebar--secondary .md-nav__title::before,
.md-sidebar--secondary .md-nav__title::after {
  background: transparent !important;
  background-image: none !important;
  box-shadow: none !important;
}

.md-search__form,
.md-search__input,
.md-search__icon,
.md-header__option,
.md-toggle,
.md-icon {
  color: var(--archive-text-strong) !important;
}

/* =========================================================
   Content elements
========================================================= */

.md-typeset pre > code,
.md-typeset .admonition,
.md-typeset details,
.md-typeset .tabbed-set,
.md-typeset .tabbed-content,
.md-typeset blockquote {
  background-color: var(--archive-bg-soft) !important;
}

.md-typeset .admonition,
.md-typeset details,
.md-typeset blockquote {
  border-color: var(--archive-border) !important;
}

.md-typeset code,
.md-typeset pre,
.highlighttable,
.highlight {
  color: var(--archive-text) !important;
}

[data-md-color-scheme="slate"] .md-typeset pre > code {
  border: 1px solid rgba(255, 240, 210, 0.06);
}

[data-md-color-scheme="default"] .md-typeset pre > code {
  border: 1px solid rgba(80, 60, 30, 0.06);
}

[data-md-color-scheme="default"] .md-typeset a {
  color: #4b57d1 !important;
}

[data-md-color-scheme="slate"] .md-typeset a {
  color: #9db2ff !important;
}

/* Home cards */
html body .md-typeset .home-card,
html body .md-typeset a.home-card,
html body .md-typeset a.home-card:visited,
html body .md-typeset a.home-card:hover,
html body .md-typeset a.home-card:active {
  color: var(--archive-text) !important;
  text-decoration: none !important;
  background: var(--archive-card-bg) !important;
  background-color: var(--archive-card-bg) !important;
}

.home-card-title {
  color: var(--archive-text) !important;
}

/* =========================================================
   Tables
   - Tag Index keeps the current ranking-table shape.
   - Normal article tables stay compact.
========================================================= */

/* Common table colors */
.md-typeset table:not([class]) {
  background-color: var(--archive-bg-soft) !important;
  border-color: var(--archive-border) !important;
}

[data-md-color-scheme="slate"] .md-typeset table:not([class]) th {
  background-color: #2a2521 !important;
}

/* Tag Index table only */
html body .md-typeset:has(h1#tag-index) .md-typeset__scrollwrap,
html body .md-typeset:has(h1#tag-index) .md-typeset__table {
  display: block !important;
  width: 100% !important;
  overflow-x: visible !important;
}

html body .md-typeset:has(h1#tag-index) table:not([class]) {
  width: 100% !important;
  max-width: 900px !important;
  table-layout: fixed !important;
  font-size: 1.05rem;
  border-radius: 16px;
  overflow: hidden;
  background: var(--archive-rank-gap-bg) !important;
  background-color: var(--archive-rank-gap-bg) !important;
}

html body .md-typeset:has(h1#tag-index) table:not([class]) th,
html body .md-typeset:has(h1#tag-index) table:not([class]) td {
  padding: 1.15rem 1.2rem;
  vertical-align: middle;
  background: var(--archive-card-bg) !important;
  background-color: var(--archive-card-bg) !important;
  border-color: var(--archive-rank-gap-bg) !important;
  outline-color: var(--archive-rank-gap-bg) !important;
  box-shadow: none !important;
}

html body .md-typeset:has(h1#tag-index) table:not([class]) th {
  font-size: 1rem;
  font-weight: 700;
}

html body .md-typeset:has(h1#tag-index) table:not([class]) th:nth-child(1),
html body .md-typeset:has(h1#tag-index) table:not([class]) td:nth-child(1) {
  width: 15% !important;
  text-align: center !important;
}

html body .md-typeset:has(h1#tag-index) table:not([class]) th:nth-child(2),
html body .md-typeset:has(h1#tag-index) table:not([class]) td:nth-child(2) {
  width: 60% !important;
}

html body .md-typeset:has(h1#tag-index) table:not([class]) th:nth-child(3),
html body .md-typeset:has(h1#tag-index) table:not([class]) td:nth-child(3) {
  width: 25% !important;
  text-align: right !important;
}

/* Normal markdown tables */
html body .md-typeset:not(:has(h1#tag-index)) .md-typeset__scrollwrap {
  overflow-x: auto !important;
}

html body .md-typeset:not(:has(h1#tag-index)) .md-typeset__table {
  display: inline-block !important;
  max-width: 100% !important;
}

html body .md-typeset:not(:has(h1#tag-index)) table:not([class]) {
  width: auto !important;
  max-width: 100% !important;
  table-layout: auto !important;
  border-radius: 0.1rem !important;
  font-size: 0.8rem !important;
}

html body .md-typeset:not(:has(h1#tag-index)) table:not([class]) th,
html body .md-typeset:not(:has(h1#tag-index)) table:not([class]) td {
  width: auto !important;
  padding: 0.55em 1.25em !important;
  font-size: 0.8rem !important;
  line-height: 1.5 !important;
  text-align: left !important;
  white-space: normal !important;
}

/* Inline code badges inside tables */
.md-typeset table code {
  font-family: "Pretendard", "Noto Sans KR", sans-serif;
  font-size: 0.95rem;
  font-weight: 600;
  padding: 0.35rem 0.7rem;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.06);
  box-shadow: none;
}

[data-md-color-scheme="slate"] .md-typeset table code {
  background: rgba(120, 140, 255, 0.12);
  color: #dbe2ff;
}

[data-md-color-scheme="default"] .md-typeset table code {
  background: rgba(120, 100, 40, 0.10);
  color: #5f4b1f;
}

/* Existing custom tag-ranking markup, scoped to actual tag-ranking classes */
html body .md-typeset .tag-ranking,
html body .md-typeset .tag-rankings,
html body .md-typeset .tag-rank-list,
html body .md-typeset .tag-ranking-list,
html body .md-typeset .tag-table,
html body .md-typeset .tag-list {
  background: var(--archive-rank-gap-bg) !important;
  background-color: var(--archive-rank-gap-bg) !important;
}

html body .md-typeset .tag-ranking-item,
html body .md-typeset .tag-ranking-row,
html body .md-typeset .tag-ranking-card,
html body .md-typeset .tag-rank-item,
html body .md-typeset .tag-rank-row,
html body .md-typeset .tag-rank-card,
html body .md-typeset .tag-list-item,
html body .md-typeset .tag-row,
html body .md-typeset .tag-card {
  background: var(--archive-card-bg) !important;
  background-color: var(--archive-card-bg) !important;
  border-color: var(--archive-rank-gap-bg) !important;
  outline-color: var(--archive-rank-gap-bg) !important;
  box-shadow: none !important;
}

/* =========================================================
   Mobile table behavior
========================================================= */

@media screen and (max-width: 768px) {
  html,
  body {
    overflow-x: hidden !important;
  }

  .md-main__inner,
  .md-content,
  .md-content__inner,
  .md-typeset {
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
    box-sizing: border-box !important;
  }

  .md-content__inner {
    margin: 0 !important;
    padding: 1.1rem 0.85rem 2rem !important;
  }

  .md-typeset h1 {
    font-size: 2.15rem !important;
    line-height: 1.18 !important;
    letter-spacing: -0.04em !important;
    margin: 1.4rem 0 1.35rem !important;
  }

  html body .md-typeset:has(h1#tag-index) .md-typeset__scrollwrap,
  html body .md-typeset:has(h1#tag-index) .md-typeset__table {
    display: block !important;
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
    margin: 0 !important;
    padding: 0 !important;
    overflow-x: hidden !important;
    box-sizing: border-box !important;
  }

  html body .md-typeset:has(h1#tag-index) table:not([class]) {
    display: table !important;
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
    table-layout: fixed !important;
    box-sizing: border-box !important;
    font-size: 0.82rem !important;
    border-radius: 12px !important;
  }

  html body .md-typeset:has(h1#tag-index) table:not([class]) thead,
  html body .md-typeset:has(h1#tag-index) table:not([class]) tbody,
  html body .md-typeset:has(h1#tag-index) table:not([class]) tr {
    width: 100% !important;
  }

  html body .md-typeset:has(h1#tag-index) table:not([class]) th,
  html body .md-typeset:has(h1#tag-index) table:not([class]) td {
    box-sizing: border-box !important;
    padding: 0.62rem 0.32rem !important;
    font-size: 0.82rem !important;
    line-height: 1.35 !important;
    vertical-align: middle !important;
    white-space: nowrap !important;
  }

  html body .md-typeset:has(h1#tag-index) table:not([class]) th:nth-child(1),
  html body .md-typeset:has(h1#tag-index) table:not([class]) td:nth-child(1) {
    width: 20% !important;
    text-align: center !important;
  }

  html body .md-typeset:has(h1#tag-index) table:not([class]) th:nth-child(2),
  html body .md-typeset:has(h1#tag-index) table:not([class]) td:nth-child(2) {
    width: 50% !important;
    text-align: center !important;
  }

  html body .md-typeset:has(h1#tag-index) table:not([class]) th:nth-child(3),
  html body .md-typeset:has(h1#tag-index) table:not([class]) td:nth-child(3) {
    width: 30% !important;
    text-align: right !important;
    padding-right: 0.55rem !important;
  }

  .md-typeset .tag-badge,
  .md-typeset table code {
    display: inline-block !important;
    max-width: 100% !important;
    box-sizing: border-box !important;
    font-size: 0.78rem !important;
    line-height: 1.2 !important;
    font-weight: 600 !important;
    padding: 0.18rem 0.34rem !important;
    border-radius: 7px !important;
    white-space: nowrap !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
  }
}

@media screen and (max-width: 420px) {
  .md-content__inner {
    padding-left: 0.65rem !important;
    padding-right: 0.65rem !important;
  }

  .md-typeset h1 {
    font-size: 1.9rem !important;
  }

  html body .md-typeset:has(h1#tag-index) table:not([class]) th,
  html body .md-typeset:has(h1#tag-index) table:not([class]) td {
    padding: 0.56rem 0.24rem !important;
    font-size: 0.76rem !important;
  }

  .md-typeset .tag-badge,
  .md-typeset table code {
    font-size: 0.72rem !important;
    padding: 0.16rem 0.28rem !important;
  }
}

/* =========================================================
   Sidebar / TOC consistency
   Keep this block at the end so it wins over theme defaults.
========================================================= */

html body .md-sidebar .md-nav__link,
html body .md-nav--secondary .md-nav__link,
html body [data-md-component="toc"] .md-nav__link {
  color: var(--archive-text) !important;
  font-weight: 400 !important;
  border-left: 4px solid transparent !important;
  padding-left: 0.65rem !important;
  margin-left: 0 !important;
  background: transparent !important;
  box-shadow: none !important;
  border-radius: 0.2rem !important;
  text-decoration: none !important;
}

html body .md-sidebar--secondary .md-nav__link--passed,
html body .md-sidebar--secondary .md-nav__item--passed > .md-nav__link,
html body .md-nav--secondary .md-nav__link--passed,
html body .md-nav--secondary .md-nav__item--passed > .md-nav__link,
html body [data-md-component="toc"] .md-nav__link--passed,
html body [data-md-component="toc"] .md-nav__item--passed > .md-nav__link {
  color: var(--archive-text) !important;
  font-weight: 400 !important;
  border-left-color: transparent !important;
  background: transparent !important;
  box-shadow: none !important;
}

html body .md-sidebar--secondary .md-nav__item--active > .md-nav__link:not(.md-nav__link--active):not([aria-current]),
html body .md-nav--secondary .md-nav__item--active > .md-nav__link:not(.md-nav__link--active):not([aria-current]),
html body [data-md-component="toc"] .md-nav__item--active > .md-nav__link:not(.md-nav__link--active):not([aria-current]) {
  color: var(--archive-text) !important;
  font-weight: 400 !important;
  border-left-color: transparent !important;
  background: transparent !important;
}

html body .md-sidebar--primary .md-nav__link--active,
html body .md-sidebar--primary .md-nav__link[aria-current="page"],
html body .md-sidebar--primary .md-nav__link[aria-current="true"],
html body .md-sidebar--primary .md-nav__link[aria-current="location"],
html body .md-sidebar--secondary .md-nav__link--active,
html body .md-sidebar--secondary .md-nav__link[aria-current="page"],
html body .md-sidebar--secondary .md-nav__link[aria-current="true"],
html body .md-sidebar--secondary .md-nav__link[aria-current="location"],
html body .md-nav--secondary .md-nav__link--active,
html body .md-nav--secondary .md-nav__link[aria-current="page"],
html body .md-nav--secondary .md-nav__link[aria-current="true"],
html body .md-nav--secondary .md-nav__link[aria-current="location"],
html body [data-md-component="toc"] .md-nav__link--active,
html body [data-md-component="toc"] .md-nav__link[aria-current="page"],
html body [data-md-component="toc"] .md-nav__link[aria-current="true"],
html body [data-md-component="toc"] .md-nav__link[aria-current="location"] {
  color: var(--archive-active) !important;
  font-weight: 800 !important;
  border-left-color: var(--archive-active) !important;
  background: var(--archive-active-bg) !important;
}

html body .md-sidebar--secondary .md-nav__link--passed.md-nav__link--active,
html body .md-nav--secondary .md-nav__link--passed.md-nav__link--active,
html body [data-md-component="toc"] .md-nav__link--passed.md-nav__link--active {
  color: var(--archive-active) !important;
  font-weight: 800 !important;
  border-left-color: var(--archive-active) !important;
  background: var(--archive-active-bg) !important;
}

html body .md-sidebar .md-nav__link:hover,
html body .md-nav--secondary .md-nav__link:hover,
html body [data-md-component="toc"] .md-nav__link:hover {
  color: var(--archive-active) !important;
}

html body .md-typeset h1,
html body .md-typeset h2,
html body .md-typeset h3,
html body .md-typeset h4,
html body .md-typeset h5,
html body .md-typeset h6 {
  scroll-margin-top: 6.5rem;
}

html body .md-sidebar--secondary .md-sidebar__scrollwrap,
html body .md-nav--secondary .md-nav__list {
  scroll-padding-top: 6.5rem;
}
