:root {
  --bg: #fff;
  --text: #000;
  --link: #3366bb;
  --link-hover: #663366;
  --menu-bg: #eee;
  --hr-color: #ddd;
  --toc-border: #eee;
  --pre-border: #ddd;
  --pre-shadow: #eee;
  --code-bg: #f9f9f9;
  --blockquote-bg: #f9f9f9;
  --blockquote-border: #ccc;
  --table-border: #666;
  --table-head-border: #ddd;
  --table-stripe: #eee;
}

[data-theme="dark"] {
  --bg: #1a1a1a;
  --text: #e0e0e0;
  --link: #6699ff;
  --link-hover: #cc99cc;
  --menu-bg: #333;
  --hr-color: #444;
  --toc-border: #444;
  --pre-border: #444;
  --pre-shadow: #111;
  --code-bg: #2d2d2d;
  --blockquote-bg: #252525;
  --blockquote-border: #666;
  --table-border: #999;
  --table-head-border: #555;
  --table-stripe: #2a2a2a;
}

body {
  max-width: 800px;
  margin: auto;
  padding: 1em;
  line-height: 1.5;
  background: var(--bg);
  color: var(--text);
}

a:link {
  color: var(--link);
}
a:visited {
  color: var(--link);
}
a:hover {
  color: var(--link-hover);
}
a:active {
  color: var(--link-hover);
}

/* header and footer areas */
.menu {
  padding: 0;
  position: relative;
}
.menu li {
  display: inline-block;
}
.article-meta,
.menu a {
  text-decoration: none;
  background: var(--menu-bg);
  padding: 5px;
  border-radius: 5px;
}
.menu a {
  display: inline-block;
  vertical-align: middle;
}
.terms {
  font-size: 0.9em;
}
.menu,
.article-meta,
footer {
  text-align: center;
}
.title {
  font-size: 1.1em;
}
footer a {
  text-decoration: none;
}
hr {
  border-style: dashed;
  color: var(--hr-color);
}

#TableOfContents,
#TOC {
  border: 1px solid var(--toc-border);
  border-radius: 5px;
}

/* code */
pre {
  border: 1px solid var(--pre-border);
  box-shadow: 5px 5px 5px var(--pre-shadow);
  padding: 1em;
  overflow-x: auto;
}
code {
  background: var(--code-bg);
}
pre code {
  background: none;
}

/* misc elements */
img,
iframe,
video {
  max-width: 100%;
}
img {
  height: auto;
  display: block;
  margin: auto;
}
main {
  hyphens: auto;
}
blockquote {
  background: var(--blockquote-bg);
  border-left: 5px solid var(--blockquote-border);
  padding: 3px 1em 3px;
}

table {
  margin: auto;
  border-top: 1px solid var(--table-border);
  border-bottom: 1px solid var(--table-border);
}
table thead th {
  border-bottom: 1px solid var(--table-head-border);
}
th,
td {
  padding: 5px;
}
thead,
tfoot,
tr:nth-child(even) {
  background: var(--table-stripe);
}

.theme-toggle-item {
  position: absolute;
  right: 0;
  top: 50%;
  transform: translateY(-50%);
}

#theme-checkbox {
  display: none;
}

.toggle-pill {
  display: inline-flex;
  align-items: center;
  position: relative;
  width: 3.8rem;
  height: 1.6rem;
  background: var(--menu-bg);
  border: 1px solid var(--hr-color);
  border-radius: 0.8rem;
  cursor: pointer;
  box-sizing: border-box;
  vertical-align: middle;
}

.toggle-knob {
  position: absolute;
  width: 1.3rem;
  height: 1.3rem;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
  left: 0.28rem;
  transition: left 0.2s ease;
  z-index: 0;
}

#theme-checkbox:checked ~ .toggle-pill .toggle-knob {
  left: calc(100% - 1.3rem - 0.28rem);
}

.toggle-icon {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  z-index: 1;
}

.toggle-icon svg {
  width: 0.85rem;
  height: 0.85rem;
}

#back-to-top {
  position: fixed;
  bottom: 2rem;
  right: 2rem;
  width: 2.5rem;
  height: 2.5rem;
  border: 1px solid var(--hr-color);
  border-radius: 50%;
  background: var(--menu-bg);
  color: var(--text);
  font-size: 1.4rem;
  line-height: 1;
  cursor: pointer;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
}

#back-to-top.visible {
  opacity: 0.75;
  pointer-events: auto;
}

#back-to-top:hover {
  opacity: 1;
}
