:root {
  --bg: #f4f5f3;
  --panel: #ffffff;
  --text: #1a1d1b;
  --muted: #6b726e;
  --faint: #9aa19d;
  --line: #e4e7e4;
  --hover: rgba(0, 0, 0, 0.045);
  --active: rgba(0, 0, 0, 0.07);
  --accent: #2f7d4f;
  --sidebar-w: 15rem;
  font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto,
    "Helvetica Neue", Arial, sans-serif;
}

:root[data-theme="dark"] {
  --bg: #0a0a0a;
  --panel: #121212;
  --text: #ededed;
  --muted: #a0a0a0;
  --faint: #707070;
  --line: #222;
  --hover: rgba(255, 255, 255, 0.06);
  --active: rgba(255, 255, 255, 0.1);
  --accent: #6cc28f;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0a0a0a;
    --panel: #121212;
    --text: #ededed;
    --muted: #a0a0a0;
    --faint: #707070;
    --line: #222;
    --hover: rgba(255, 255, 255, 0.06);
    --active: rgba(255, 255, 255, 0.1);
    --accent: #6cc28f;
  }
}

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-size: 1rem;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 6px;
}

svg.i {
  width: 1rem;
  height: 1rem;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* ---------- Sidebar ---------- */

.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: var(--sidebar-w);
  display: flex;
  flex-direction: column;
  padding: 1.5rem 0.5rem 0.5rem;
  overflow-y: auto;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0 0.85rem 1.5rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  text-decoration: none;
}

.brand svg { width: 1.2rem; height: 1.2rem; color: var(--accent); }

.nav-label {
  padding: 1.25rem 0 0.5rem 0.85rem;
  font-size: 0.72rem;
  font-weight: 500;
  color: var(--faint);
}

.sidebar ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }

.sidebar a.item, .sidebar button.item {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  width: 100%;
  padding: 0.45rem 0.6rem 0.45rem 0.85rem;
  border: 0;
  border-radius: 8px;
  background: none;
  color: var(--text);
  font: inherit;
  font-size: 0.92rem;
  text-align: left;
  text-decoration: none;
  cursor: pointer;
  transition: background 0.12s;
}

.sidebar .item:hover { background: var(--hover); }
.sidebar .item[aria-current="page"] { background: var(--active); }
.sidebar .item svg.i { color: var(--muted); }

.sidebar .item .end {
  margin-left: auto;
  min-width: 1.25rem;
  height: 1.25rem;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 5px;
  font-size: 0.68rem;
  color: var(--faint);
}

.sidebar .item .end.icon { border: 0; }
.sidebar .item .end svg.i { width: 0.8rem; height: 0.8rem; color: var(--faint); }

.theme {
  margin-top: auto;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 2px;
  padding: 3px;
  border-radius: 10px;
  background: var(--hover);
}

.theme button {
  padding: 0.3rem 0;
  border: 0;
  border-radius: 7px;
  background: none;
  color: var(--muted);
  font: inherit;
  font-size: 0.8rem;
  cursor: pointer;
}

.theme button[aria-pressed="true"] { background: var(--panel); color: var(--text); }

.toast {
  position: fixed;
  left: 50%;
  bottom: 1.5rem;
  transform: translate(-50%, 1rem);
  padding: 0.5rem 0.9rem;
  border-radius: 8px;
  background: var(--text);
  color: var(--bg);
  font-size: 0.85rem;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s, transform 0.15s;
}

.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- Main panel ---------- */

.panel {
  margin: 0.5rem 0.5rem 0.5rem var(--sidebar-w);
  min-height: calc(100vh - 1rem);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 4rem 2rem;
}

.content { max-width: 40rem; margin: 0 auto; }

h1 {
  margin: 0 0 1rem;
  font-size: 2.2rem;
  font-weight: 600;
  letter-spacing: -0.02em;
  line-height: 1.2;
}

h2 {
  margin: 3rem 0 1rem;
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--faint);
}

.lede { color: var(--muted); font-size: 0.95rem; margin: 0 0 1.75rem; }

.content p { color: var(--muted); }
.content p a { color: var(--text); text-underline-offset: 0.2em; text-decoration-color: var(--line); }
.content p a:hover { text-decoration-color: currentColor; }

/* Link list (like sj.land/media rows) */
.list { list-style: none; margin: 0; padding: 0; }

.list a, .list .row {
  display: flex;
  gap: 1.25rem;
  align-items: flex-start;
  padding: 1rem 0;
  border-bottom: 1px solid var(--line);
  text-decoration: none;
}

.list li:last-child a, .list li:last-child .row { border-bottom: 0; }

.list .thumb {
  flex: none;
  width: 3rem;
  height: 3rem;
  display: grid;
  place-items: center;
  border-radius: 8px;
  border: 1px solid var(--line);
  color: var(--accent);
  background: var(--bg);
}

.list .thumb svg.i { width: 1.2rem; height: 1.2rem; }
.list .title { font-size: 0.95rem; display: flex; align-items: center; gap: 0.4rem; }
.list .desc { font-size: 0.88rem; color: var(--muted); margin-top: 0.1rem; }
.list .meta { margin-left: auto; font-size: 0.8rem; color: var(--faint); white-space: nowrap; }
.list a:hover .title { text-decoration: underline; text-underline-offset: 0.2em; }

.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.05rem 0.45rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  font-size: 0.7rem;
  color: var(--muted);
}

.badge svg.i { width: 0.7rem; height: 0.7rem; }

.empty { color: var(--faint); font-size: 0.9rem; }

/* Photo grid */
.photos {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(11rem, 1fr));
  gap: 0.5rem;
}

.photos figure { margin: 0; }

.photos img, .photos .ph {
  display: block;
  width: 100%;
  aspect-ratio: 4 / 5;
  object-fit: cover;
  border-radius: 8px;
  background: var(--bg);
  border: 1px solid var(--line);
}

.photos figcaption { font-size: 0.78rem; color: var(--faint); padding: 0.35rem 0.1rem 0; }

footer.foot { margin-top: 4rem; font-size: 0.8rem; color: var(--faint); }

/* ---------- Mobile ---------- */

.menu-btn { display: none; }

@media (max-width: 760px) {
  .sidebar {
    position: sticky;
    top: 0;
    z-index: 10;
    width: auto;
    padding: 0.6rem 0.5rem;
    background: var(--bg);
    border-bottom: 1px solid var(--line);
    overflow: visible;
  }

  .sidebar .top { display: flex; align-items: center; justify-content: space-between; }
  .brand { padding: 0.3rem 0.6rem; }

  .menu-btn {
    display: grid;
    place-items: center;
    width: 2.25rem;
    height: 2.25rem;
    border: 0;
    border-radius: 8px;
    background: none;
    color: var(--text);
    cursor: pointer;
  }

  .menu-btn:hover { background: var(--hover); }
  .sidebar .drawer { display: none; padding-top: 0.5rem; }
  .sidebar.open .drawer { display: block; }
  .sidebar .item .end:not(.icon) { display: none; }
  .theme { margin-top: 1rem; }
  .sidebar:not(.open) .theme { display: none; }

  .panel { margin: 0; border: 0; border-radius: 0; min-height: auto; padding: 2.5rem 1.25rem; }
  h1 { font-size: 1.8rem; }
  .photos { grid-template-columns: repeat(2, 1fr); }
}
