:root {
  color-scheme: light;
  --bg: #f6f5f1;
  --panel: #ffffff;
  --line: #e3e1da;
  --hover: #f1efe8;
  --text: #1c1f24;
  --muted: #6b6f76;
  --accent: #1f4e79;
  --strip: 56px;
}

* { box-sizing: border-box; }

html, body { margin: 0; height: 100%; }

body {
  display: flex;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

/* ── Sidebar ─────────────────────────────────────────────────────────── */

.sidebar {
  position: sticky;
  top: 0;
  flex: none;
  display: flex;
  flex-direction: column;
  width: max-content;            /* as wide as the longest title: never wraps, never "…" */
  height: 100vh;
  height: 100dvh;
  background: var(--panel);
  border-right: 1px solid var(--line);
  z-index: 2;
}

.sidebar__head {
  display: flex;
  align-items: center;
  gap: 10px;
  height: 56px;
  padding: 0 8px 0 16px;
  border-bottom: 1px solid var(--line);
}

.sidebar__brand { font-weight: 700; font-size: 17px; flex: 1; }
.sidebar__logo { border-radius: 6px; }

.toggle {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  margin-left: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--text);
  cursor: pointer;
}
.toggle:hover { background: var(--hover); }

.list {
  list-style: none;
  margin: 0;
  padding: 6px 0;
  overflow-y: auto;
  flex: 1;
}

.row {
  display: flex;
  align-items: center;
  position: relative;
}

.link {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: 1;
  min-height: 40px;
  padding: 0 4px 0 16px;
  color: inherit;
  text-decoration: none;
  white-space: nowrap;
}
a.link:hover, a.link:focus-visible { background: var(--hover); }
a.link:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }

.icon {
  flex: none;
  width: 20px;
  height: 20px;
  border-radius: 4px;
  object-fit: contain;
}

/* "Read a book": a reminder, not a link. */
.row--divider .link { cursor: default; color: var(--muted); font-style: italic; }
.row--divider .label { display: flex; align-items: center; gap: 8px; }
.row--divider .label::before,
.row--divider .label::after {
  content: "";
  width: 22px;
  height: 1px;
  background: currentColor;
  opacity: .6;
}

.grip {
  display: grid;
  place-items: center;
  flex: none;
  width: 32px;
  height: 40px;
  margin-right: 4px;
  border: 0;
  background: none;
  color: var(--muted);
  opacity: .35;
  cursor: grab;
  touch-action: none;
}
.row:hover .grip, .grip:focus-visible { opacity: 1; }
.grip:focus-visible { outline: 2px solid var(--accent); outline-offset: -4px; border-radius: 6px; }
@media (hover: none) { .grip { opacity: .7; } }

.row.is-dragging { background: var(--hover); box-shadow: 0 2px 10px rgba(0,0,0,.12); z-index: 1; }
.row.is-dragging .grip { cursor: grabbing; opacity: 1; }
body.is-dragging { cursor: grabbing; user-select: none; }

.sidebar__foot {
  padding: 8px 16px 12px;
  border-top: 1px solid var(--line);
}
.reset {
  border: 0;
  background: none;
  padding: 4px 0;
  color: var(--muted);
  font: inherit;
  font-size: 13px;
  cursor: pointer;
}
.reset:hover { color: var(--text); text-decoration: underline; }

/* Collapsed: a strip of icons. The toggle stays to bring the list back. */
.sidebar.is-collapsed { width: var(--strip); }
.sidebar.is-collapsed .sidebar__head { padding: 0; justify-content: center; }
.sidebar.is-collapsed .sidebar__logo,
.sidebar.is-collapsed .sidebar__brand,
.sidebar.is-collapsed .label,
.sidebar.is-collapsed .grip,
.sidebar.is-collapsed .sidebar__foot { display: none; }
.sidebar.is-collapsed .toggle { margin: 0; }
.sidebar.is-collapsed .toggle svg { transform: rotate(180deg); }
.sidebar.is-collapsed .link { justify-content: center; padding: 0; }

/* ── Main ────────────────────────────────────────────────────────────── */

.main {
  flex: 1;
  min-width: 0;
  padding: 48px 32px;
}
.main__date { margin: 0 0 8px; color: var(--muted); font-size: 14px; }
.main__hint { margin: 0 0 6px; font-size: 20px; font-weight: 600; }
.main__sub  { margin: 0; color: var(--muted); font-size: 14px; }

/* Phones: the open list lies over the page instead of squeezing it. */
@media (max-width: 700px) {
  .sidebar { position: fixed; left: 0; top: 0; box-shadow: 0 0 24px rgba(0,0,0,.12); }
  .sidebar.is-collapsed { box-shadow: none; }
  .main { margin-left: var(--strip); padding: 32px 16px; }
}
