@import url("https://fonts.googleapis.com/css2?family=IBM+Plex+Sans:wght@400;500;600;700&family=IBM+Plex+Mono:wght@400;500&display=swap");

:root {
  color-scheme: light;
  --bg: #f6f3ed;
  --panel: #ffffff;
  --panel-soft: #f9f7f2;
  --ink: #1c2327;
  --muted: #657077;
  --line: #ded8ce;
  --accent: #2f6f68;
  --accent-ink: #ffffff;
  --shadow: 0 18px 48px rgba(39, 35, 28, 0.14);
  --rail-width: 360px;
}

* {
  box-sizing: border-box;
}

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

body {
  font-family: "IBM Plex Sans", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--ink);
  overflow: hidden;
}

a {
  color: inherit;
  text-decoration: none;
}

button,
input {
  font: inherit;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.app-shell {
  display: grid;
  grid-template-columns: var(--rail-width) minmax(0, 1fr);
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  background: var(--bg);
}

.paper-rail {
  display: flex;
  min-width: 0;
  min-height: 0;
  flex-direction: column;
  border-right: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(16px);
  z-index: 5;
}

.rail-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 72px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.brand-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  border-radius: 8px;
  background: var(--accent);
  color: var(--accent-ink);
  font-weight: 700;
}

.brand strong,
.brand small {
  display: block;
  line-height: 1.1;
}

.brand strong {
  font-size: 15px;
}

.brand small {
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
}

.icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--ink);
  cursor: pointer;
}

.icon-button:hover {
  border-color: #b9aea1;
  background: var(--panel-soft);
}

.search-box {
  display: block;
  padding: 12px 16px;
}

.search-box input {
  width: 100%;
  height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 12px;
  background: var(--panel-soft);
  color: var(--ink);
  outline: none;
}

.search-box input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(47, 111, 104, 0.14);
}

.status-line {
  padding: 0 16px 10px;
  color: var(--muted);
  font-size: 13px;
}

.paper-list {
  min-height: 0;
  overflow: auto;
  padding: 0 10px 14px;
}

.paper-item {
  display: grid;
  gap: 6px;
  width: 100%;
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 12px;
  color: var(--ink);
}

.paper-item:hover {
  background: var(--panel-soft);
}

.paper-item[aria-current="page"] {
  border-color: rgba(47, 111, 104, 0.36);
  background: rgba(47, 111, 104, 0.08);
}

.paper-item strong {
  font-size: 14px;
  line-height: 1.25;
}

.paper-item span {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.reader-pane {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  min-width: 0;
  min-height: 0;
}

.reader-bar {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  min-height: 72px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--line);
  background: rgba(246, 243, 237, 0.94);
  backdrop-filter: blur(16px);
}

.reader-title {
  min-width: 0;
}

.reader-title p,
.reader-title h1 {
  margin: 0;
}

.reader-title p {
  color: var(--muted);
  font-family: "IBM Plex Mono", monospace;
  font-size: 11px;
  letter-spacing: 0;
  text-transform: uppercase;
}

.reader-title h1 {
  margin-top: 3px;
  overflow: hidden;
  font-size: 18px;
  font-weight: 700;
  line-height: 1.2;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.reader-actions {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.action-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 64px;
  height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 12px;
  background: var(--panel);
  font-weight: 600;
}

.action-link:hover {
  border-color: #b9aea1;
  background: var(--panel-soft);
}

.reader-stage {
  position: relative;
  min-width: 0;
  min-height: 0;
  background: #d9d4cc;
}

.pdf-viewer {
  width: 100%;
  height: 100%;
  overflow: auto;
  background: #d9d4cc;
}

.pdf-frame {
  display: block;
  width: 100%;
  height: 100%;
  border: 0;
  background: #ffffff;
}

.pdf-loading {
  display: grid;
  min-height: 100%;
  place-content: center;
  color: var(--muted);
  font-weight: 600;
}

.empty-state {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  gap: 8px;
  padding: 24px;
  color: var(--muted);
  text-align: center;
}

.empty-state strong {
  color: var(--ink);
}

@media (max-width: 860px) {
  .app-shell {
    grid-template-columns: minmax(0, 1fr);
  }

  .paper-rail {
    position: fixed;
    inset: 0 auto 0 0;
    width: min(88vw, var(--rail-width));
    box-shadow: var(--shadow);
    transform: translateX(-104%);
    transition: transform 0.2s ease;
  }

  .app-shell[data-sidebar-open="true"] .paper-rail {
    transform: translateX(0);
  }

  .reader-bar {
    grid-template-columns: auto minmax(0, 1fr) auto;
    min-height: 64px;
    padding: 8px 10px;
  }

  .reader-title h1 {
    font-size: 15px;
  }

  .action-link {
    min-width: 48px;
    height: 38px;
    padding: 0 9px;
    font-size: 13px;
  }

  .pdf-viewer {
    overflow: hidden;
  }
}

@media (min-width: 861px) {
  .rail-close {
    display: none;
  }

  .app-shell[data-sidebar-open="false"] {
    grid-template-columns: 0 minmax(0, 1fr);
  }

  .app-shell[data-sidebar-open="false"] .paper-rail {
    overflow: hidden;
    border-right: 0;
  }
}
