:root {
  --bg: #f7f6f3;
  --fg: #201f1c;
  --muted: #8a8578;
  --line: rgba(32, 31, 28, 0.14);
  --hover-bg: rgba(32, 31, 28, 0.035);

  --perso: #7c6f9e;
  --utils: #5f8f85;
  --dataviz: #b17f57;

  --font-serif: Georgia, "Iowan Old Style", "Times New Roman", Times, serif;
  --font-mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #171613;
    --fg: #eeece6;
    --muted: #8e897c;
    --line: rgba(238, 236, 230, 0.14);
    --hover-bg: rgba(238, 236, 230, 0.04);
  }
}

:root[data-theme="dark"] {
  --bg: #171613;
  --fg: #eeece6;
  --muted: #8e897c;
  --line: rgba(238, 236, 230, 0.14);
  --hover-bg: rgba(238, 236, 230, 0.04);
}

:root[data-theme="light"] {
  --bg: #f7f6f3;
  --fg: #201f1c;
  --muted: #8a8578;
  --line: rgba(32, 31, 28, 0.14);
  --hover-bg: rgba(32, 31, 28, 0.035);
}

* {
  box-sizing: border-box;
}

html, body {
  height: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font-serif);
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.5rem 2rem;
  font-family: var(--font-mono);
  font-size: 0.7rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
}

.bar .mark {
  color: var(--fg);
}

.theme-toggle {
  font-family: inherit;
  font-size: inherit;
  letter-spacing: inherit;
  text-transform: inherit;
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  padding: 0;
}

.theme-toggle:hover {
  color: var(--fg);
}

main {
  flex: 1;
  display: flex;
  align-items: center;
  width: 100%;
  padding: 1rem 2rem;
}

.index-groups {
  width: 100%;
  max-width: 880px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 4rem;
}

.index-list {
  list-style: none;
  margin: 0;
  padding: 0;
  border-top: 1px solid var(--line);
}

.index-list li {
  border-bottom: 1px solid var(--line);
}

.index-list a {
  display: grid;
  grid-template-columns: 2.5rem 1fr 5.5rem;
  align-items: baseline;
  column-gap: 1.5rem;
  padding: 1.4rem 0.5rem;
  text-decoration: none;
  color: var(--fg);
  transition: background-color 0.15s ease;
}

.index-list a:hover {
  background: var(--hover-bg);
}

.index-list .num {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  color: var(--muted);
  align-self: start;
  padding-top: 0.35rem;
}

.index-list .main {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  min-width: 0;
}

.index-list .title {
  font-size: clamp(1.3rem, 2.6vw, 1.9rem);
  font-weight: 400;
  line-height: 1.15;
}

.index-list a:hover .title {
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 5px;
}

.index-list .desc {
  font-size: 0.8rem;
  font-style: italic;
  color: var(--muted);
}

.index-list .tag {
  font-family: var(--font-mono);
  font-size: 0.65rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  text-align: right;
  align-self: start;
  padding-top: 0.35rem;
}

.index-list[data-group="perso"] .tag { color: var(--perso); }
.index-list[data-group="utils"] .tag { color: var(--utils); }
.index-list[data-group="dataviz"] .tag { color: var(--dataviz); }

@media (max-width: 640px) {
  .bar {
    padding: 1.25rem 1.25rem;
  }

  main {
    padding: 1rem 1.25rem;
  }

  .index-groups {
    gap: 3rem;
  }

  .index-list a {
    grid-template-columns: 1.75rem 1fr;
    grid-template-areas:
      "num tag"
      "main main";
    row-gap: 0.5rem;
  }

  .index-list .num { grid-area: num; }
  .index-list .tag { grid-area: tag; }
  .index-list .main { grid-area: main; }
}
