@import url("https://fonts.googleapis.com/css2?family=Lato:wght@400;700;900&family=Source+Sans+3:wght@400;600;700&display=swap");

:root {
  color-scheme: light dark;
  --sidebar: #ffffff;
  --sidebar-text: #545454;
  --sidebar-muted: #717171;
  --sidebar-active: #1d1d1d;
  --sidebar-hover: rgb(223 233 241 / 64%);
  --sidebar-border: #efefef;
  --site-title: #717171;
  --topbar-bg: rgb(255 255 255 / 70%);
  --bg: #ffffff;
  --surface: #ffffff;
  --surface-2: #f8f9fa;
  --text: #34343c;
  --heading: #2a2a2a;
  --heading-1: #d9487d;
  --heading-2: #d97706;
  --heading-3: #b08700;
  --heading-4: #2f9e44;
  --heading-5: #0c8ea0;
  --heading-6: #7c5cc4;
  --muted: #757575;
  --border: #f3f3f3;
  --border-strong: #e2e6ea;
  --accent: #0056b2;
  --accent-2: #0550ae;
  --code-bg: #f6f8fa;
  --inline-code-bg: rgb(25 25 28 / 5%);
  --shadow: rgb(104 104 104 / 5%) 0 2px 6px 0, rgb(211 209 209 / 15%) 0 0 0 1px;
  --radius: 8px;
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    "Apple SD Gothic Neo", "Noto Sans KR", sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --sidebar: rgb(27 27 30);
    --sidebar-text: #969696;
    --sidebar-muted: #868686;
    --sidebar-active: rgb(255 255 255 / 95%);
    --sidebar-hover: #262626;
    --sidebar-border: #292929;
    --site-title: #a0a0a0;
    --topbar-bg: rgb(27 27 30 / 72%);
    --bg: rgb(27 27 30);
    --surface: rgb(27 27 30);
    --surface-2: #232328;
    --text: rgb(185 186 187);
    --heading: #d2d2d2;
    --heading-1: #ff8fb3;
    --heading-2: #ffb86c;
    --heading-3: #f4d35e;
    --heading-4: #8bdc7f;
    --heading-5: #66d9e8;
    --heading-6: #c792ea;
    --muted: #949494;
    --border: rgb(44 45 45);
    --border-strong: #36373a;
    --accent: rgb(138 180 248);
    --accent-2: rgb(116 178 243);
    --code-bg: #151515;
    --inline-code-bg: rgb(255 255 255 / 5%);
    --shadow: rgb(21 21 21 / 72%) 0 6px 18px 0, rgb(137 135 135 / 24%) 0 0 0 1px;
  }
}

:root[data-theme="dark"] {
  --sidebar: rgb(27 27 30);
  --sidebar-text: #969696;
  --sidebar-muted: #868686;
  --sidebar-active: rgb(255 255 255 / 95%);
  --sidebar-hover: #262626;
  --sidebar-border: #292929;
  --site-title: #a0a0a0;
  --topbar-bg: rgb(27 27 30 / 72%);
  --bg: rgb(27 27 30);
  --surface: rgb(27 27 30);
  --surface-2: #232328;
  --text: rgb(185 186 187);
  --heading: #d2d2d2;
  --heading-1: #ff8fb3;
  --heading-2: #ffb86c;
  --heading-3: #f4d35e;
  --heading-4: #8bdc7f;
  --heading-5: #66d9e8;
  --heading-6: #c792ea;
  --muted: #949494;
  --border: rgb(44 45 45);
  --border-strong: #36373a;
  --accent: rgb(138 180 248);
  --accent-2: rgb(116 178 243);
  --code-bg: #151515;
  --inline-code-bg: rgb(255 255 255 / 5%);
  --shadow: rgb(21 21 21 / 72%) 0 6px 18px 0, rgb(137 135 135 / 24%) 0 0 0 1px;
}

:root[data-theme="light"] {
  color-scheme: light;
}

* {
  box-sizing: border-box;
}

html {
  scroll-padding-top: 76px;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
}

a {
  color: inherit;
}

button,
input {
  font: inherit;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.app-shell {
  min-height: 100vh;
  display: flex;
}

.sidebar {
  width: 268px;
  min-height: 100vh;
  padding: 28px 22px;
  background: var(--sidebar);
  border-right: 1px solid var(--sidebar-border);
  color: var(--sidebar-text);
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 40;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}

.brand {
  display: grid;
  grid-template-columns: 54px minmax(0, 1fr);
  gap: 12px;
  align-items: center;
  text-decoration: none;
  margin-bottom: 26px;
}

.brand img {
  display: block;
  width: 54px;
  height: 54px;
  border-radius: 14px;
}

.brand span {
  min-width: 0;
}

.brand strong {
  display: block;
  color: var(--site-title);
  font-weight: 900;
  font-size: 1.03rem;
  line-height: 1.25;
}

.nav-list {
  display: grid;
  gap: 3px;
}

.nav-list a {
  text-decoration: none;
  border-radius: 6px;
  color: var(--sidebar-text);
  padding: 10px 12px;
}

.nav-list a:hover,
.nav-list a.is-active {
  color: var(--sidebar-active);
  background: var(--sidebar-hover);
}

.nav-list a.is-active {
  font-weight: 800;
}

.sidebar-footer {
  display: grid;
  gap: 10px;
  margin-top: auto;
  padding: 24px 12px 0;
  color: var(--sidebar-muted);
  font-size: 0.78rem;
  line-height: 1.5;
}

.sidebar-footer a {
  color: var(--accent);
  text-decoration: none;
  font-weight: 800;
}

.app-main {
  margin-left: 268px;
  width: calc(100% - 268px);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.topbar {
  height: 64px;
  position: sticky;
  top: 0;
  z-index: 30;
  background: var(--topbar-bg);
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(14px);
  display: flex;
  align-items: center;
  gap: 14px;
  justify-content: space-between;
  padding: 0 28px;
}

.menu-button {
  display: none;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text);
  border-radius: 6px;
  width: 38px;
  height: 38px;
  cursor: pointer;
}

.search-wrap {
  width: min(620px, 100%);
  flex: 1 1 420px;
  position: relative;
}

.search-wrap input {
  width: 100%;
  height: 40px;
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  padding: 0 14px;
  background: var(--surface-2);
  color: var(--text);
  outline: none;
}

.search-wrap input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent), transparent 82%);
}

.search-results {
  position: absolute;
  top: 48px;
  left: 0;
  width: min(620px, calc(100vw - 28px));
  max-height: min(70vh, 620px);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: var(--shadow);
  overflow-y: auto;
}

.search-results a,
.search-results p {
  display: grid;
  gap: 4px;
  padding: 12px 14px;
  margin: 0;
  text-decoration: none;
  border-bottom: 1px solid var(--border);
}

.search-results a:hover {
  background: var(--surface-2);
}

.search-results small,
.search-results p {
  color: var(--muted);
  font-size: 0.84rem;
}

.topbar-theme {
  --theme-index: 0;
  position: relative;
  width: 88px;
  height: 40px;
  flex: 0 0 auto;
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  padding: 3px;
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  background: color-mix(in srgb, var(--surface-2), var(--text) 3%);
  box-shadow: inset 0 1px 2px rgb(0 0 0 / 5%);
}

.topbar-theme[data-active-theme="dark"] {
  --theme-index: 1;
}

.topbar-theme::before {
  content: "";
  position: absolute;
  z-index: 0;
  top: 3px;
  bottom: 3px;
  left: 3px;
  width: calc((100% - 6px) / 2);
  border: 1px solid color-mix(in srgb, var(--border-strong), var(--text) 7%);
  border-radius: 7px;
  background: var(--surface);
  box-shadow: 0 1px 3px rgb(0 0 0 / 12%);
  transform: translateX(calc(var(--theme-index) * 100%));
  transition: transform 180ms ease, background-color 180ms ease, border-color 180ms ease;
}

.topbar-theme button {
  position: relative;
  z-index: 1;
  min-width: 0;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  display: grid;
  place-items: center;
  padding: 0;
  transition: color 150ms ease, transform 150ms ease;
}

.topbar-theme button:hover {
  color: var(--heading);
}

.topbar-theme button:active {
  transform: scale(0.9);
}

.topbar-theme button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.topbar-theme button svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.9;
  stroke-linecap: round;
  stroke-linejoin: round;
  pointer-events: none;
}

.topbar-theme button[data-theme-option="light"].is-active {
  color: #d58b1f;
}

.topbar-theme button[data-theme-option="dark"].is-active {
  color: #7894cf;
}

.topbar-theme button::after {
  content: attr(data-tooltip);
  position: absolute;
  top: calc(100% + 12px);
  left: 50%;
  z-index: 50;
  padding: 5px 7px;
  border: 1px solid var(--border-strong);
  border-radius: 6px;
  background: var(--heading);
  color: var(--surface);
  box-shadow: var(--shadow);
  font-size: 0.72rem;
  font-weight: 700;
  line-height: 1;
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transform: translate(-50%, -4px);
  transition: opacity 120ms ease, transform 120ms ease;
}

.topbar-theme button:hover::after,
.topbar-theme button:focus-visible::after {
  opacity: 1;
  transform: translate(-50%, 0);
}

.content-shell {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 294px;
  gap: 28px;
  width: 100%;
  max-width: 1260px;
  padding: 28px;
  margin: 0 auto;
}

.primary-pane {
  min-width: 0;
}

.right-rail {
  position: sticky;
  top: 92px;
  align-self: start;
  display: grid;
  gap: 18px;
}

.rail-section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
}

.rail-section h2 {
  margin: 0 0 12px;
  color: var(--muted);
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.rail-section p,
.rail-empty {
  margin: 0;
  color: var(--muted);
  font-size: 0.86rem;
  line-height: 1.6;
}

.rail-list {
  display: grid;
  gap: 10px;
}

.rail-list a {
  display: grid;
  gap: 3px;
  color: var(--muted);
  text-decoration: none;
  font-size: 0.86rem;
}

.rail-list a:hover {
  color: var(--accent);
}

.rail-list small {
  color: var(--muted);
}

.page-stack {
  display: grid;
  gap: 22px;
}

.page-header,
.note-header,
.empty-state {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 26px 28px;
}

.home-header h1,
.page-header h1,
.note-header h1 {
  margin: 8px 0 10px;
  color: var(--heading);
  line-height: 1.2;
  letter-spacing: 0;
}

.home-header h1 {
  font-size: 2rem;
}

.page-header p,
.note-header p,
.empty-state p {
  margin-bottom: 0;
  color: var(--muted);
  line-height: 1.65;
}

.eyebrow {
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-size: 0.75rem;
  font-weight: 800;
}

.post-list {
  display: grid;
  gap: 14px;
}

.post-card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
}

.post-card__title {
  display: block;
  color: var(--heading);
  font-weight: 800;
  font-size: 1.08rem;
  line-height: 1.45;
  text-decoration: none;
}

.post-card__title:hover {
  color: var(--accent);
}

.post-card__preview {
  display: -webkit-box;
  margin: 10px 0 12px;
  color: var(--muted);
  overflow: hidden;
  line-height: 1.65;
  text-overflow: ellipsis;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
}

.post-card__meta,
.note-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  color: var(--muted);
  font-size: 0.84rem;
}

.tag-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
}

.tag-row span {
  color: var(--accent);
  background: var(--surface);
  border: 1px solid var(--border-strong);
  padding: 4px 8px;
  border-radius: 999px;
  font-size: 0.8rem;
}

.breadcrumbs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  color: var(--muted);
  font-size: 0.84rem;
}

.breadcrumbs a {
  color: var(--accent);
  text-decoration: none;
}

.breadcrumbs span::before {
  content: "/";
  margin-right: 8px;
  color: var(--border-strong);
}

.markdown-body {
  margin-top: 18px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 34px;
  font-family: "Source Sans 3", "Source Sans Pro", "Apple SD Gothic Neo", "Noto Sans KR", sans-serif;
  font-size: 1.03rem;
  line-height: 1.75;
  overflow-wrap: break-word;
}

.markdown-body h1,
.markdown-body h2,
.markdown-body h3,
.markdown-body h4,
.markdown-body h5,
.markdown-body h6 {
  padding: 0;
  font-family: Lato, "Apple SD Gothic Neo", "Noto Sans KR", sans-serif;
  font-weight: 700;
  line-height: 1.32;
  letter-spacing: 0;
}

.markdown-body h1 {
  color: var(--heading-1);
  margin: 2rem 0 1rem;
  font-size: 2rem;
}

.markdown-body h2 {
  color: var(--heading-2);
  margin: 2.5rem 0 1.25rem;
  font-size: 1.54rem;
}

.markdown-body h3 {
  color: var(--heading-3);
  margin: 2rem 0 1rem;
  font-size: 1.36rem;
}

.markdown-body h4 {
  color: var(--heading-4);
  margin: 2rem 0 1rem;
  font-size: 1.18rem;
}

.markdown-body h5 {
  color: var(--heading-5);
}

.markdown-body h6 {
  color: var(--heading-6);
}

.markdown-body h2:first-child,
.markdown-body h3:first-child {
  margin-top: 0;
}

.markdown-body p {
  margin: 0 0 1rem;
}

.markdown-body ul,
.markdown-body ol {
  margin: 0 0 1rem;
  padding-inline-start: 1.75rem;
}

.markdown-body li {
  margin: 0.25rem 0;
  padding-left: 0.25rem;
}

.markdown-body li > p:only-child {
  margin: 0;
}

.markdown-body li > ul,
.markdown-body li > ol {
  margin-top: 0.4rem;
  margin-bottom: 0.4rem;
}

.markdown-body ::marker {
  color: var(--muted);
}

.markdown-body a {
  color: var(--accent);
  text-decoration: none;
  border-bottom: 1px solid color-mix(in srgb, var(--accent), transparent 62%);
}

.markdown-body a:hover {
  color: var(--accent-2);
  border-bottom-color: var(--accent-2);
}

.markdown-body blockquote {
  margin: 0 0 1.5rem;
  border-left: 0.125rem solid var(--border-strong);
  padding-left: 1rem;
  color: var(--muted);
}

.markdown-body code {
  background: var(--inline-code-bg);
  border: 1px solid var(--border-strong);
  border-radius: 5px;
  padding: 0.12em 0.35em;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: 0.9em;
}

.markdown-body pre {
  margin: 0 0 1.5rem;
  background: var(--code-bg);
  color: var(--text);
  border: 1px solid var(--border-strong);
  padding: 18px;
  overflow: auto;
  border-radius: 8px;
}

.markdown-body pre code {
  padding: 0;
  border: 0;
  background: transparent;
}

.table-scroll {
  width: 100%;
  margin: 0 0 1.5rem;
  overflow-x: auto;
}

.markdown-body table {
  width: 100%;
  border-collapse: collapse;
}

.markdown-body th,
.markdown-body td {
  border: 1px solid var(--border);
  padding: 9px 10px;
  text-align: left;
  vertical-align: top;
}

.markdown-body th {
  background: var(--surface-2);
}

.markdown-body img {
  display: block;
  max-width: 100%;
  height: auto;
  margin: 1rem 0 1.5rem;
  border-radius: 8px;
}

.markdown-body hr {
  margin: 2rem 0;
  border: 0;
  border-top: 1px solid var(--border-strong);
}

.markdown-body del,
.markdown-body s {
  color: var(--muted);
}

.note-neighbors {
  margin-top: 18px;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.note-neighbor {
  display: grid;
  gap: 5px;
  min-width: 0;
  padding: 16px;
  text-decoration: none;
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.note-neighbor--next {
  text-align: right;
}

.note-neighbor span {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.note-neighbor strong {
  color: var(--heading);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.note-neighbor:hover strong {
  color: var(--accent);
}

.pagination {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 12px;
  color: var(--muted);
}

.pagination a {
  width: fit-content;
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  padding: 8px 14px;
  text-decoration: none;
  font-weight: 700;
}

.pagination > :last-child {
  justify-self: end;
}

.site-footer {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 14px;
  width: 100%;
  max-width: 1260px;
  margin: auto auto 0;
  padding: 24px 28px 34px;
  color: var(--muted);
  font-size: 0.82rem;
}

.site-footer nav {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
}

.site-footer a {
  color: var(--muted);
  text-decoration: none;
}

.site-footer a:hover {
  color: var(--accent);
}

.scrim {
  position: fixed;
  inset: 0;
  border: 0;
  background: rgb(0 0 0 / 42%);
  z-index: 35;
}

@media (max-width: 1120px) {
  .content-shell {
    grid-template-columns: minmax(0, 1fr);
  }

  .right-rail {
    display: none;
  }
}

@media (max-width: 820px) {
  .sidebar {
    transform: translateX(-100%);
    transition: transform 180ms ease;
  }

  .sidebar.is-open {
    transform: translateX(0);
  }

  .app-main {
    margin-left: 0;
    width: 100%;
  }

  .menu-button {
    display: block;
    flex: 0 0 auto;
  }

  .search-wrap {
    min-width: 0;
  }

  .content-shell {
    padding: 18px;
  }

  .markdown-body {
    padding: 22px;
  }
}

@media (max-width: 560px) {
  .topbar {
    padding: 0 14px;
    gap: 8px;
  }

  .topbar-theme {
    width: 80px;
    height: 38px;
  }

  .content-shell {
    padding: 14px;
  }

  .page-header,
  .note-header {
    padding: 20px;
  }

  .markdown-body {
    padding: 20px;
    font-size: 1rem;
  }

  .note-neighbors {
    grid-template-columns: 1fr;
  }

  .note-neighbor--next {
    text-align: left;
  }

  .site-footer {
    padding-inline: 14px;
  }
}
