/* ── Reset & base ─────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --sidebar-w: 220px;
  --topbar-h: 48px;

  --bg:         #ffffff;
  --bg-sidebar: #f7f7f5;
  --bg-hover:   #eeede9;
  --bg-active:  #e8e6e0;

  --text:       #1a1a1a;
  --text-muted: #6b6b6b;
  --text-light: #9a9a9a;

  --border:     #e2e0d8;
  --accent:     #1a1a1a;

  --radius:     6px;
  --font:       -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --font-mono:  "SF Mono", "Fira Code", Consolas, monospace;
}

html, body {
  height: 100%;
  font-family: var(--font);
  font-size: 15px;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

/* ── Layout ───────────────────────────────────────────────── */
#app {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

/* ── Sidebar ──────────────────────────────────────────────── */
#sidebar {
  width: var(--sidebar-w);
  min-width: var(--sidebar-w);
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: width 0.2s ease, min-width 0.2s ease;
}

#sidebar.collapsed {
  width: 0;
  min-width: 0;
  border-right: none;
}

#sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 14px;
  height: var(--topbar-h);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.site-title {
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0.01em;
  color: var(--text);
}

#sidebar-toggle {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-muted);
  font-size: 16px;
  padding: 4px;
  border-radius: var(--radius);
  line-height: 1;
}
#sidebar-toggle:hover { background: var(--bg-hover); }

/* Date list */
#date-list {
  overflow-y: auto;
  flex: 1;
  padding: 8px 0;
}

.date-group {
  margin-bottom: 4px;
}

.date-btn {
  width: 100%;
  background: none;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 7px 14px;
  font-size: 13px;
  color: var(--text-muted);
  text-align: left;
  border-radius: 0;
  transition: background 0.1s;
}
.date-btn:hover { background: var(--bg-hover); color: var(--text); }
.date-btn.active { background: var(--bg-active); color: var(--text); font-weight: 500; }

.date-btn .date-label { font-family: var(--font-mono); font-size: 12px; }
.date-btn .date-arrow { font-size: 10px; color: var(--text-light); }

.page-links {
  display: none;
  flex-direction: column;
  padding: 2px 0 6px 0;
}
.page-links.open { display: flex; }

.page-link {
  background: none;
  border: none;
  cursor: pointer;
  text-align: left;
  padding: 5px 14px 5px 26px;
  font-size: 12.5px;
  color: var(--text-muted);
  transition: background 0.1s;
  border-radius: 0;
}
.page-link:hover { background: var(--bg-hover); color: var(--text); }
.page-link.active {
  color: var(--text);
  font-weight: 500;
  background: var(--bg-active);
}

/* ── Main ─────────────────────────────────────────────────── */
#main {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* Topbar */
#topbar {
  height: var(--topbar-h);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 20px;
  gap: 16px;
  flex-shrink: 0;
  background: var(--bg);
}

#menu-btn {
  display: none;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-muted);
  font-size: 16px;
  padding: 4px;
  border-radius: var(--radius);
  line-height: 1;
}
#menu-btn:hover { background: var(--bg-hover); }

#page-tabs {
  display: flex;
  gap: 2px;
  overflow-x: auto;
  scrollbar-width: none;
}
#page-tabs::-webkit-scrollbar { display: none; }

.tab-btn {
  background: none;
  border: none;
  cursor: pointer;
  padding: 6px 12px;
  font-size: 13px;
  color: var(--text-muted);
  border-radius: var(--radius);
  white-space: nowrap;
  transition: background 0.1s, color 0.1s;
}
.tab-btn:hover { background: var(--bg-hover); color: var(--text); }
.tab-btn.active {
  background: var(--bg-active);
  color: var(--text);
  font-weight: 500;
}

/* Content */
#content {
  flex: 1;
  overflow-y: auto;
  padding: 0;
}

#content-inner {
  max-width: 720px;
  margin: 0 auto;
  padding: 36px 32px 80px;
}

/* Loading / error states */
.state-loading, .state-error, .state-index {
  padding: 60px 32px;
  text-align: center;
  color: var(--text-muted);
  font-size: 14px;
}
.state-error { color: #c0392b; }

/* Index page */
.index-page { max-width: 480px; margin: 60px auto; padding: 0 24px; }
.index-page h1 { font-size: 22px; font-weight: 600; margin-bottom: 6px; }
.index-page .subtitle { color: var(--text-muted); font-size: 14px; margin-bottom: 32px; }
.index-date-list { list-style: none; }
.index-date-list li { border-bottom: 1px solid var(--border); }
.index-date-list li:first-child { border-top: 1px solid var(--border); }
.index-date-link {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 4px;
  text-decoration: none;
  color: var(--text);
  font-size: 14px;
  cursor: pointer;
  transition: color 0.1s;
}
.index-date-link:hover { color: var(--accent); }
.index-date-link .idx-date { font-family: var(--font-mono); font-size: 13px; }
.index-date-link .idx-arrow { color: var(--text-light); font-size: 13px; }

/* ── Markdown content ────────────────────────────────────── */
#content-inner h1 {
  font-size: 20px;
  font-weight: 600;
  margin-bottom: 20px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
  color: var(--text);
}

#content-inner h2 {
  font-size: 14px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  margin: 28px 0 10px;
}

#content-inner h3 {
  font-size: 15px;
  font-weight: 600;
  margin: 20px 0 8px;
}

#content-inner p {
  line-height: 1.7;
  margin-bottom: 12px;
  color: var(--text);
}

#content-inner ul, #content-inner ol {
  padding-left: 20px;
  margin-bottom: 12px;
}
#content-inner li {
  line-height: 1.7;
  margin-bottom: 4px;
}
#content-inner li strong { color: var(--text); }

/* Tables */
#content-inner table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
  margin-bottom: 16px;
}
#content-inner th {
  text-align: left;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  padding: 6px 10px;
  border-bottom: 2px solid var(--border);
}
#content-inner td {
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}
#content-inner tr:last-child td { border-bottom: none; }
#content-inner tr:hover td { background: var(--bg-sidebar); }

/* Code */
#content-inner code {
  font-family: var(--font-mono);
  font-size: 12.5px;
  background: var(--bg-sidebar);
  padding: 2px 5px;
  border-radius: 3px;
}
#content-inner pre code {
  display: block;
  padding: 14px;
  overflow-x: auto;
  line-height: 1.5;
}

#content-inner strong { font-weight: 600; }
#content-inner em { font-style: italic; color: var(--text-muted); }
#content-inner hr { border: none; border-top: 1px solid var(--border); margin: 20px 0; }

#content-inner blockquote {
  border-left: 3px solid #e8a838;
  background: #fffbf0;
  color: #7a5800;
  padding: 8px 14px;
  margin: 0 0 20px;
  border-radius: 0 var(--radius) var(--radius) 0;
  font-size: 13px;
}

/* ── Mobile ───────────────────────────────────────────────── */
@media (max-width: 640px) {
  #sidebar {
    position: fixed;
    top: 0; left: 0; bottom: 0;
    z-index: 100;
    width: var(--sidebar-w);
    min-width: var(--sidebar-w);
    transform: translateX(-100%);
    transition: transform 0.2s ease;
    box-shadow: 2px 0 12px rgba(0,0,0,0.08);
  }
  #sidebar.open {
    transform: translateX(0);
  }
  #sidebar-toggle { display: none; }
  #menu-btn { display: block; }

  #content-inner {
    padding: 24px 18px 60px;
  }
}
