:root {
  color-scheme: light;
  --bg: #f7f8fb;
  --panel: #ffffff;
  --text: #18202f;
  --muted: #687386;
  --line: #dfe4ee;
  --accent: #1f6feb;
  --accent-strong: #185abc;
  --code-bg: #f1f4f8;
  --shadow: 0 16px 48px rgba(18, 31, 56, 0.12);
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button {
  border: 0;
  font: inherit;
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.app-shell {
  display: grid;
  grid-template-columns: 320px minmax(0, 1fr);
  min-height: 100%;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  overflow: auto;
  border-right: 1px solid var(--line);
  background: var(--panel);
  z-index: 20;
}

.sidebar-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 24px 20px 16px;
}

.sidebar h1 {
  margin: 0;
  font-size: 20px;
  line-height: 1.2;
}

.sidebar p,
.eyebrow {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.folder-actions {
  display: grid;
  grid-template-columns: 1fr 1fr auto;
  gap: 8px;
  padding: 0 20px 18px;
}

.primary-button,
.secondary-button,
.icon-button {
  min-height: 40px;
  border-radius: 8px;
  transition: background 160ms ease, color 160ms ease, transform 160ms ease;
}

.primary-button {
  background: var(--accent);
  color: #fff;
  font-weight: 700;
}

.primary-button:hover {
  background: var(--accent-strong);
}

.secondary-button,
.icon-button {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--text);
}

.secondary-button {
  padding: 0 14px;
}

.icon-button {
  width: 40px;
  font-size: 22px;
  line-height: 1;
}

.file-list {
  display: grid;
  gap: 4px;
  padding: 0 12px 24px;
}

.file-item {
  width: 100%;
  min-height: 42px;
  padding: 9px 10px;
  border-radius: 8px;
  background: transparent;
  color: var(--text);
  overflow-wrap: anywhere;
  text-align: left;
}

.file-item:hover {
  background: #eef4ff;
}

.file-item.active {
  background: #dceaff;
  color: #0f3f8f;
  font-weight: 700;
}

.reader {
  min-width: 0;
}

.reader-toolbar {
  position: sticky;
  top: 0;
  display: flex;
  align-items: center;
  gap: 14px;
  min-height: 76px;
  padding: 16px clamp(18px, 4vw, 48px);
  border-bottom: 1px solid var(--line);
  background: rgba(247, 248, 251, 0.92);
  backdrop-filter: blur(14px);
  z-index: 10;
}

.reader-toolbar h2 {
  margin: 2px 0 0;
  font-size: clamp(20px, 2.5vw, 30px);
  line-height: 1.2;
  overflow-wrap: anywhere;
}

.markdown-body {
  width: min(900px, 100%);
  padding: 30px clamp(18px, 4vw, 48px) 72px;
  font-size: 17px;
  line-height: 1.72;
}

.markdown-body > :first-child {
  margin-top: 0;
}

.markdown-body h1,
.markdown-body h2,
.markdown-body h3,
.markdown-body h4 {
  margin: 1.6em 0 0.5em;
  line-height: 1.25;
}

.markdown-body h1 {
  font-size: clamp(30px, 5vw, 46px);
}

.markdown-body h2 {
  padding-bottom: 8px;
  border-bottom: 1px solid var(--line);
  font-size: clamp(24px, 3vw, 34px);
}

.markdown-body h3 {
  font-size: 22px;
}

.markdown-body p {
  margin: 0 0 1em;
}

.markdown-body a {
  color: var(--accent);
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
}

.markdown-body pre {
  overflow: auto;
  padding: 16px;
  border-radius: 8px;
  background: #172033;
  color: #edf3ff;
  line-height: 1.55;
}

.markdown-body code {
  border-radius: 5px;
  background: var(--code-bg);
  padding: 2px 5px;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: 0.92em;
}

.markdown-body pre code {
  background: transparent;
  padding: 0;
  color: inherit;
}

.markdown-body blockquote {
  margin: 1.2em 0;
  padding: 4px 0 4px 16px;
  border-left: 4px solid var(--accent);
  color: #465369;
}

.markdown-body img {
  max-width: 100%;
  border-radius: 8px;
}

.markdown-body table {
  display: block;
  width: 100%;
  overflow-x: auto;
  border-collapse: collapse;
}

.markdown-body th,
.markdown-body td {
  padding: 8px 10px;
  border: 1px solid var(--line);
}

.empty-state {
  margin-top: 12vh;
  padding: 24px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.empty-state h3 {
  margin: 0 0 8px;
}

.empty-state p {
  margin: 0;
  color: var(--muted);
}

.mobile-only {
  display: none;
}

.scrim {
  position: fixed;
  inset: 0;
  background: rgba(12, 18, 30, 0.42);
  z-index: 15;
}

@media (max-width: 780px) {
  .app-shell {
    display: block;
  }

  .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: min(86vw, 340px);
    transform: translateX(-102%);
    transition: transform 180ms ease;
    box-shadow: var(--shadow);
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .mobile-only {
    display: inline-grid;
    place-items: center;
    flex: 0 0 auto;
  }

  .reader-toolbar {
    min-height: 70px;
    align-items: flex-start;
  }

  .markdown-body {
    padding-top: 22px;
    font-size: 16px;
  }

  .empty-state {
    margin-top: 6vh;
    padding: 18px;
  }
}
