:root {
  --bg: #f7f8fa;
  --surface: #ffffff;
  --text: #1c2430;
  --muted: #5b6676;
  --border: #e3e7ee;
  --accent: #2457d6;
  --accent-soft: #e8eefc;
  --code-bg: #f1f3f7;
  --shadow: 0 6px 24px rgb(20 30 50 / 7%);
  --max: 760px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #12151b;
    --surface: #1a1f27;
    --text: #e6e9ef;
    --muted: #9aa4b4;
    --border: #2b323d;
    --accent: #7ea2ff;
    --accent-soft: #1f2a44;
    --code-bg: #222833;
    --shadow: none;
  }
}
:root[data-theme="dark"] {
  --bg: #12151b;
  --surface: #1a1f27;
  --text: #e6e9ef;
  --muted: #9aa4b4;
  --border: #2b323d;
  --accent: #7ea2ff;
  --accent-soft: #1f2a44;
  --code-bg: #222833;
  --shadow: none;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Pretendard", "Apple SD Gothic Neo", "Malgun Gothic", system-ui, sans-serif;
  font-size: 17px;
  line-height: 1.75;
  word-break: keep-all;
  overflow-wrap: anywhere;
}
a { color: var(--accent); }
a:hover { text-decoration-thickness: 2px; }
img { max-width: 100%; height: auto; }

.skip { position: absolute; left: -9999px; }
.skip:focus { left: 16px; top: 8px; background: var(--surface); padding: 8px 12px; z-index: 10; }

/* Header */
.site-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.site-header .inner {
  max-width: 1040px;
  margin: 0 auto;
  padding: 14px 16px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px 20px;
}
.logo {
  font-weight: 800;
  font-size: 20px;
  color: var(--text);
  text-decoration: none;
  letter-spacing: -0.02em;
}
.logo span { color: var(--accent); }
.site-nav ul {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 4px 18px;
}
.site-nav a {
  color: var(--muted);
  text-decoration: none;
  font-size: 15px;
  font-weight: 600;
}
.site-nav a:hover, .site-nav a[aria-current="page"] { color: var(--accent); }

/* Layout */
main { max-width: var(--max); margin: 0 auto; padding: 36px 16px 56px; }
main.wide { max-width: 1040px; }

.hero { padding: 8px 0 28px; }
.hero h1 { font-size: clamp(28px, 5vw, 38px); line-height: 1.3; margin: 0 0 12px; letter-spacing: -0.02em; }
.hero p { color: var(--muted); margin: 0; max-width: 640px; }

.section-title { font-size: 20px; margin: 36px 0 14px; }

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
}
.card {
  display: block;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 20px;
  text-decoration: none;
  color: var(--text);
  box-shadow: var(--shadow);
  transition: border-color .15s;
}
.card:hover { border-color: var(--accent); }
.card .tag { font-size: 13px; font-weight: 700; color: var(--accent); }
.card h3 { margin: 6px 0 8px; font-size: 18px; line-height: 1.45; }
.card p { margin: 0; color: var(--muted); font-size: 15px; line-height: 1.6; }

.path {
  background: var(--accent-soft);
  border-radius: 14px;
  padding: 18px 22px;
}
.path ol { margin: 8px 0 0; padding-left: 22px; }

/* Article */
.breadcrumb { font-size: 14px; color: var(--muted); margin-bottom: 14px; }
.breadcrumb a { color: var(--muted); }
article h1 { font-size: clamp(26px, 5vw, 34px); line-height: 1.35; margin: 0 0 10px; letter-spacing: -0.02em; }
.meta { color: var(--muted); font-size: 14px; margin-bottom: 28px; }
article h2 { font-size: 23px; margin: 44px 0 12px; line-height: 1.4; }
article h3 { font-size: 19px; margin: 30px 0 8px; }
article p, article li { margin: 0 0 14px; }
article ul, article ol { padding-left: 22px; }
.lead { font-size: 18px; color: var(--muted); }

.toc {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px 20px;
  margin: 0 0 28px;
  font-size: 15px;
}
.toc strong { display: block; margin-bottom: 4px; }
.toc ol { margin: 0; padding-left: 20px; }
.toc li { margin: 2px 0; }

.note, .tip {
  border-left: 4px solid var(--accent);
  background: var(--accent-soft);
  padding: 12px 16px;
  border-radius: 0 10px 10px 0;
  margin: 18px 0;
}
.note p:last-child, .tip p:last-child { margin-bottom: 0; }

code {
  font-family: "JetBrains Mono", Consolas, "D2Coding", monospace;
  font-size: 0.88em;
  background: var(--code-bg);
  padding: 2px 6px;
  border-radius: 5px;
}
pre {
  background: var(--code-bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px 16px;
  overflow-x: auto;
  line-height: 1.6;
  font-size: 15px;
}
pre code { background: none; padding: 0; font-size: inherit; }

.table-wrap { overflow-x: auto; margin: 16px 0; }
table { border-collapse: collapse; width: 100%; font-size: 15px; background: var(--surface); }
th, td { border: 1px solid var(--border); padding: 8px 12px; text-align: left; vertical-align: top; }
th { background: var(--code-bg); }

.formula {
  text-align: center;
  font-family: "Cambria Math", "Times New Roman", serif;
  font-size: 19px;
  padding: 10px;
  margin: 14px 0;
  overflow-x: auto;
}

.post-nav {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  border-top: 1px solid var(--border);
  margin-top: 48px;
  padding-top: 20px;
  font-size: 15px;
}
.post-nav a { text-decoration: none; font-weight: 600; }

/* Forms */
.form label { display: block; margin: 16px 0 6px; font-weight: 600; }
.form input, .form textarea {
  width: 100%;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
}
.form textarea { min-height: 150px; resize: vertical; }
.form input:focus, .form textarea:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
.btn {
  margin-top: 20px;
  padding: 12px 22px;
  border: 0;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}
:root[data-theme="dark"] .btn { color: #0e1320; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .btn { color: #0e1320; } }

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 24px;
  box-shadow: var(--shadow);
}

/* Footer */
.site-footer {
  border-top: 1px solid var(--border);
  background: var(--surface);
  color: var(--muted);
  font-size: 14px;
}
.site-footer .inner {
  max-width: 1040px;
  margin: 0 auto;
  padding: 24px 16px;
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 10px 20px;
}
.site-footer a { color: var(--muted); margin-right: 14px; }

@media (max-width: 520px) {
  body { font-size: 16px; }
  article h2 { font-size: 21px; }
}
