:root[data-theme="dark"] {
  --bg:        #1b1b1e;
  --bg-side:   #16161a;
  --bg-card:   #202024;
  --text:      #e8e8ea;
  --text-soft: #a5a5ad;
  --text-dim:  #6b6b75;
  --border:    #2a2a30;
  --accent:    #e0a458;
  --accent-sf: rgba(224, 164, 88, 0.12);
  --code-bg:   #26262c;
}

:root[data-theme="light"] {
  --bg:        #fbfbfd;
  --bg-side:   #f4f4f6;
  --bg-card:   #ffffff;
  --text:      #1a1a1e;
  --text-soft: #55555e;
  --text-dim:  #8a8a93;
  --border:    #e4e4e8;
  --accent:    #b06f1a;
  --accent-sf: rgba(176, 111, 26, 0.10);
  --code-bg:   #f0f0f3;
}

:root {
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto,
          "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas,
          "Liberation Mono", monospace;
  --ease: cubic-bezier(0.22, 0.61, 0.36, 1);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html { scroll-behavior: smooth; scroll-padding-top: 24px; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 15.5px;
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
  transition: background 0.35s var(--ease), color 0.35s var(--ease);
  opacity: 1;
}
body.fading { opacity: 0; transition: opacity 0.15s ease; }

a { color: var(--accent); text-decoration: none; transition: color 0.15s; }
a:hover { text-decoration: underline; text-underline-offset: 3px; }

.scroll-progress {
  position: fixed;
  top: 0; left: 0;
  height: 2px;
  width: 0;
  background: var(--accent);
  z-index: 100;
  transition: width 0.08s linear;
  will-change: width;
}

.layout {
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr) 200px;
  max-width: 1280px;
  margin: 0 auto;
  min-height: 100vh;
}

.sidebar {
  border-right: 1px solid var(--border);
  background: var(--bg-side);
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  transition: background 0.35s var(--ease), border-color 0.35s var(--ease);
}

.sidebar-inner {
  display: flex;
  flex-direction: column;
  height: 100%;
  padding: 24px 18px 18px;
  animation: sidebarIn 0.5s var(--ease) both;
}

@keyframes sidebarIn {
  from { opacity: 0; transform: translateX(-12px); }
  to   { opacity: 1; transform: translateX(0); }
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 22px;
  font-weight: 700;
  font-size: 15px;
  text-decoration: none;
  color: var(--text);
}
.brand:hover { text-decoration: none; }

.brand-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  border-radius: 6px;
  background: var(--accent-sf);
  color: var(--accent);
  transition: transform 0.3s var(--ease);
}
.brand-mark svg { display: block; }
.brand:hover .brand-mark { transform: rotate(-6deg) scale(1.1); }

.filter {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 13px;
  margin-bottom: 20px;
  outline: none;
  transition: border-color 0.2s var(--ease), background 0.35s var(--ease);
}
.filter:focus { border-color: var(--accent); }
.filter::placeholder { color: var(--text-dim); }

.nav { display: flex; flex-direction: column; gap: 2px; flex: 1; }

.nav-item {
  position: relative;
  display: flex;
  align-items: center;
  padding: 8px 12px 8px 16px;
  border-radius: 5px;
  color: var(--text-soft);
  font-size: 13.5px;
  font-weight: 700;
  letter-spacing: 0.2px;
  text-decoration: none;
  transition:
    color 0.2s var(--ease),
    background 0.25s var(--ease),
    transform 0.25s var(--ease),
    opacity 0.25s var(--ease);
}
.nav-item:hover {
  background: var(--accent-sf);
  color: var(--text);
  transform: translateX(3px);
  text-decoration: none;
}
.nav-item.active { background: var(--accent-sf); color: var(--accent); }

.nav-item::before {
  content: "";
  position: absolute;
  left: 4px; top: 50%;
  width: 2px; height: 0;
  background: var(--accent);
  border-radius: 2px;
  transform: translateY(-50%);
  transition: height 0.3s var(--ease);
}
.nav-item.active::before { height: 60%; }
.nav-item:hover::before { height: 40%; }

.nav-item.hidden {
  opacity: 0;
  transform: translateX(-8px);
  pointer-events: none;
  height: 0;
  padding-top: 0;
  padding-bottom: 0;
  margin: 0;
  overflow: hidden;
}

.sidebar-foot {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-top: 16px;
  border-top: 1px solid var(--border);
  font-size: 11.5px;
  color: var(--text-dim);
  transition: border-color 0.35s var(--ease), color 0.35s var(--ease);
}

.theme-toggle {
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 5px;
  color: var(--text-soft);
  width: 28px; height: 28px;
  cursor: pointer;
  font-size: 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: all 0.25s var(--ease);
}
.theme-toggle:hover {
  color: var(--accent);
  border-color: var(--accent);
  transform: rotate(15deg);
}
.theme-toggle .t-icon {
  display: inline-block;
  transition: transform 0.5s var(--ease);
}
.theme-toggle:active .t-icon { transform: rotate(180deg); }

.content {
  padding: 56px 56px 80px;
  max-width: 760px;
  width: 100%;
  animation: contentIn 0.55s var(--ease) both;
}

@keyframes contentIn {
  from { opacity: 0; transform: translateY(14px); }
  to   { opacity: 1; transform: translateY(0); }
}

h1 {
  font-size: 30px;
  font-weight: 700;
  letter-spacing: -0.5px;
  margin-bottom: 8px;
  color: var(--text);
  animation: fadeUp 0.5s var(--ease) both;
}

.reading-time {
  font-size: 12px;
  color: var(--text-dim);
  margin-bottom: 22px;
  letter-spacing: 0.3px;
}

@keyframes fadeUp {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}

h2 {
  position: relative;
  font-size: 20px;
  font-weight: 600;
  letter-spacing: -0.2px;
  margin: 36px 0 16px;
  color: var(--text);
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border);
  scroll-margin-top: 24px;
  transition: border-color 0.35s var(--ease);
}
h2:first-of-type { margin-top: 8px; }

h2::after {
  content: "";
  position: absolute;
  left: 0; bottom: -1px;
  height: 1px; width: 0;
  background: var(--accent);
  transition: width 0.45s var(--ease), opacity 0.35s var(--ease);
  opacity: 0;
}
h2.active::after { width: 100%; opacity: 1; }

p { margin-bottom: 14px; color: var(--text-soft); transition: color 0.35s var(--ease); }
p em { color: var(--text); font-style: normal; }
p.muted { color: var(--text-dim); font-size: 13px; }

code {
  font-family: var(--mono);
  background: var(--code-bg);
  color: var(--accent);
  padding: 1px 6px;
  border-radius: 4px;
  font-size: 13px;
  transition: background 0.35s var(--ease), color 0.35s var(--ease);
}

.skill-list {
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}
.skill-list li { animation: fadeUp 0.45s var(--ease) both; }
.skill-list li:nth-child(1) { animation-delay: 0.05s; }
.skill-list li:nth-child(2) { animation-delay: 0.10s; }
.skill-list li:nth-child(3) { animation-delay: 0.15s; }
.skill-list li:nth-child(4) { animation-delay: 0.20s; }
.skill-list li:nth-child(5) { animation-delay: 0.25s; }
.skill-list li:nth-child(6) { animation-delay: 0.30s; }

.skill-list li code {
  display: inline-block;
  padding: 5px 11px;
  font-size: 13px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text);
  transition:
    border-color 0.25s var(--ease),
    color 0.25s var(--ease),
    transform 0.25s var(--ease),
    box-shadow 0.25s var(--ease);
}
.skill-list li code:hover {
  border-color: var(--accent);
  color: var(--accent);
  transform: translateY(-3px);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.18);
}

.uses-list { list-style: none; margin-top: 12px; }
.uses-list li {
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
  display: flex;
  gap: 16px;
  align-items: baseline;
  transition: border-color 0.35s var(--ease), padding-left 0.25s var(--ease);
}
.uses-list li:hover { padding-left: 4px; }
.uses-list li:last-child { border-bottom: none; }
.uses-list .label {
  color: var(--text-dim);
  font-size: 12px;
  min-width: 90px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.uses-list .val { color: var(--text); }

.contact-list { list-style: none; }
.contact-list li {
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
  display: flex;
  gap: 16px;
  align-items: center;
  transition: border-color 0.35s var(--ease), padding-left 0.25s var(--ease);
}
.contact-list li:hover { padding-left: 4px; }
.contact-list li:last-child { border-bottom: none; }
.contact-list .label {
  color: var(--text-dim);
  font-size: 12px;
  min-width: 70px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.contact-list .mono { font-family: var(--mono); color: var(--accent); font-size: 13.5px; }

.copy-btn {
  margin-left: auto;
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-soft);
  font-family: var(--sans);
  font-size: 11px;
  padding: 3px 9px;
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.2s var(--ease);
}
.copy-btn:hover { border-color: var(--accent); color: var(--accent); }
.copy-btn.copied { border-color: var(--accent); color: var(--accent); }

.toc {
  position: sticky;
  top: 0;
  align-self: start;
  padding: 56px 24px 24px;
  height: 100vh;
  border-left: 1px solid var(--border);
  font-size: 12.5px;
  animation: sidebarIn 0.55s var(--ease) 0.05s both;
  transition: border-color 0.35s var(--ease);
}

.toc-title {
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 1px;
  font-size: 11px;
  margin-bottom: 14px;
}

.toc-link {
  display: block;
  padding: 5px 0 5px 12px;
  color: var(--text-soft);
  border-left: 1px solid var(--border);
  text-decoration: none;
  transition:
    color 0.2s var(--ease),
    border-color 0.25s var(--ease),
    transform 0.25s var(--ease);
}
.toc-link:hover { color: var(--text); transform: translateX(3px); text-decoration: none; }
.toc-link.active { color: var(--accent); border-left-color: var(--accent); }

.giscus-wrap {
  margin-top: 24px;
  min-height: 200px;
}
.giscus-note {
  font-size: 13px;
  color: var(--text-dim);
  margin-bottom: 16px;
}

.to-top {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 40px;
  height: 40px;
  border-radius: 8px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text-soft);
  cursor: pointer;
  font-size: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transform: translateY(10px);
  pointer-events: none;
  transition: all 0.25s var(--ease);
  z-index: 90;
}
.to-top.visible {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}
.to-top:hover { border-color: var(--accent); color: var(--accent); }

.page-foot {
  margin-top: 48px;
  padding-top: 20px;
  border-top: 1px solid var(--border);
  font-size: 12px;
  color: var(--text-dim);
  display: flex;
  justify-content: space-between;
  gap: 12px;
  transition: border-color 0.35s var(--ease);
}

.menu-btn {
  display: none;
  position: fixed;
  top: 14px; left: 14px;
  z-index: 50;
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text);
  width: 36px; height: 36px;
  border-radius: 6px;
  font-size: 16px;
  cursor: pointer;
  transition: transform 0.2s var(--ease);
}
.menu-btn:active { transform: scale(0.92); }

@media (max-width: 1000px) {
  .layout { grid-template-columns: 260px 1fr; }
  .toc { display: none; }
}

@media (max-width: 720px) {
  .layout { grid-template-columns: 1fr; }
  .menu-btn { display: block; }

  .sidebar {
    position: fixed;
    left: 0; top: 0;
    width: 260px;
    z-index: 40;
    transform: translateX(-100%);
    transition: transform 0.28s var(--ease);
  }
  .sidebar.open { transform: translateX(0); }

  .content { padding: 72px 22px 60px; }
  h1 { font-size: 24px; }
  h2 { font-size: 18px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
  html { scroll-behavior: auto; }
}

@media print {
  body { background: #fff; color: #000; }
  .sidebar, .toc, .to-top, .menu-btn, .scroll-progress, .copy-btn,
  .theme-toggle, .page-foot, .reading-time { display: none !important; }
  .layout { display: block; }
  .content { padding: 0; max-width: 100%; }
  a { color: #000; text-decoration: underline; }
}
