/* Noa Prim vault viewer */

:root {
  --sidebar-width: 320px;
  --header-height: 64px;
  --content-max: 980px;
  --font-ui: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --font-body: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, serif;
  --radius: 14px;
  --radius-sm: 10px;
  --shadow: 0 8px 28px rgba(0,0,0,.18);
}

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

body {
  font-family: var(--font-ui);
  overflow: hidden;
}

body.theme-dark {
  --bg: #141619;
  --bg-elev: #1b1f24;
  --bg-elev-2: #20252c;
  --bg-soft: #101214;
  --line: rgba(255,255,255,.08);
  --line-strong: rgba(255,255,255,.12);
  --text: #d7ddd0;
  --text-soft: #9ca38f;
  --text-dim: #76807a;
  --accent: #6dd7f2;
  --accent-soft: rgba(109,215,242,.12);
  --active: rgba(255,255,255,.06);
  --hero-frame: rgba(255,255,255,.12);
  --callout-bg: rgba(255,255,255,.035);
  --code-bg: #0f1215;
  --blockquote: #b9c3b6;
  --link: #86d9ff;
  --placeholder-bg: #191d22;
}

body.theme-light {
  --bg: #f4f0e7;
  --bg-elev: #f9f6ef;
  --bg-elev-2: #f1ebe1;
  --bg-soft: #e9e2d4;
  --line: rgba(44,36,24,.10);
  --line-strong: rgba(44,36,24,.18);
  --text: #2a241b;
  --text-soft: #5e5446;
  --text-dim: #817667;
  --accent: #0f78b4;
  --accent-soft: rgba(15,120,180,.10);
  --active: rgba(44,36,24,.05);
  --hero-frame: rgba(44,36,24,.16);
  --callout-bg: rgba(44,36,24,.03);
  --code-bg: #efe8dd;
  --blockquote: #51483d;
  --link: #0a70ac;
  --placeholder-bg: #f8f2e8;
}

body {
  background: var(--bg);
  color: var(--text);
}

a { color: var(--link); text-decoration: none; }
a:hover { text-decoration: underline; }

.app-shell {
  display: flex;
  height: 100%;
}

.sidebar {
  width: var(--sidebar-width);
  min-width: 260px;
  max-width: 36vw;
  border-right: 1px solid var(--line);
  background:
    linear-gradient(180deg, rgba(255,255,255,.03), rgba(255,255,255,0)),
    linear-gradient(180deg, var(--bg-soft), var(--bg-elev));
  display: flex;
  flex-direction: column;
  min-height: 0;
  box-shadow: inset -1px 0 0 rgba(255,255,255,.03);
}

.sidebar-top {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 18px 16px 12px;
}

.brand {
  min-width: 0;
  flex: 1;
}

.brand-eyebrow {
  font-size: 11px;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--text-dim);
  margin-bottom: 4px;
}

.brand-title {
  font-size: 20px;
  font-weight: 700;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.icon-button {
  border: 1px solid var(--line-strong);
  background: var(--bg-elev-2);
  color: var(--text);
  width: 38px;
  height: 38px;
  border-radius: 12px;
  cursor: pointer;
  box-shadow: var(--shadow);
}

.icon-button:hover {
  background: var(--bg-soft);
}

.sidebar-search {
  padding: 0 16px 14px;
  border-bottom: 1px solid var(--line);
}

.sidebar-search input {
  width: 100%;
  box-sizing: border-box;
  background: var(--bg-elev-2);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 11px 12px;
  outline: none;
}

.sidebar-search input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.tree {
  padding: 8px 8px 16px;
  overflow: auto;
  min-height: 0;
}

.nav-folder, .nav-file {
  margin: 0;
}

.nav-folder-title, .nav-file-link {
  display: flex;
  align-items: center;
  gap: 4px;
  min-height: 24px;
  border-radius: 0;
  color: var(--text-soft);
}

.nav-folder-title {
  padding: 0;
}

.nav-folder-label, .nav-file-link {
  flex: 1;
  min-width: 0;
  padding: 3px 6px;
  border-radius: 0;
}

.nav-folder-label {
  cursor: pointer;
}

.nav-folder-label, .nav-file-link {
  line-height: 1.2;
}

.nav-file-link {
  display: block;
  margin-left: 22px;
}

.nav-folder-label:hover, .nav-file-link:hover {
  background: var(--active);
  color: var(--text);
  text-decoration: none;
}

.nav-folder-toggle:hover {
  color: var(--text);
  text-decoration: none;
}

.nav-folder-toggle {
  width: 18px;
  height: 18px;
  border: 0;
  background: transparent;
  color: var(--text-dim);
  border-radius: 0;
  cursor: pointer;
  flex: 0 0 auto;
}

.nav-folder.is-open > .nav-folder-title .nav-folder-toggle {
  color: var(--text);
}

.nav-folder-children {
  display: none;
  margin-left: 8px;
  padding-left: 4px;
  border-left: 1px solid var(--line);
}

.nav-folder.is-open > .nav-folder-children {
  display: block;
}

.is-active {
  background: transparent;
  color: var(--text) !important;
  box-shadow: none;
  border-radius: 0;
  font-weight: 500;
}

.nav-folder-label.is-active,
.nav-file-link.is-active {
  position: relative;
}

.nav-folder-label.is-active::before,
.nav-file-link.is-active::before {
  content: "";
  position: absolute;
  left: 0;
  top: 4px;
  bottom: 4px;
  width: 1px;
  border-radius: 0;
  background: var(--accent);
}

.hidden-by-filter {
  display: none !important;
}

.main-pane {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.note-header {
  min-height: var(--header-height);
  border-bottom: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(255,255,255,.03), rgba(255,255,255,0));
  padding: 12px 20px;
  display: flex;
  align-items: center;
}

.note-header-meta {
  min-width: 0;
}

.note-path {
  color: var(--text-dim);
  font-size: 12px;
  margin-bottom: 4px;
  font-family: var(--font-ui);
}

.note-title {
  margin: 0;
  font-size: 24px;
  line-height: 1.15;
  color: var(--text);
  font-weight: 700;
  font-family: var(--font-ui);
}

.content-scroll {
  overflow: auto;
  min-height: 0;
  padding: 18px 18px 36px;
}

.content {
  max-width: var(--content-max);
  margin: 0 auto;
}

.hero {
  margin: 4px auto 22px;
  border: 1px solid var(--hero-frame);
  border-radius: 20px;
  overflow: hidden;
  background: var(--bg-elev);
  box-shadow: var(--shadow);
}

.hero img {
  display: block;
  width: 100%;
  max-height: 310px;
  object-fit: cover;
  object-position: center;
}

.hidden {
  display: none !important;
}

.note-body {
  font-family: var(--font-body);
  font-size: 19px;
  line-height: 1.65;
  color: var(--text);
}

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

.note-body h1,
.note-body h2,
.note-body h3,
.note-body h4,
.note-body h5,
.note-body h6 {
  font-family: var(--font-body);
  color: var(--text);
  line-height: 1.15;
  margin: 1.2em 0 .45em;
}

.note-body h1 { font-size: 2.2rem; }
.note-body h2 { font-size: 1.75rem; border-bottom: 1px solid var(--line); padding-bottom: .18em; }
.note-body h3 { font-size: 1.4rem; }
.note-body h4 { font-size: 1.18rem; }

.note-body p, .note-body li, .note-body td, .note-body th {
  color: var(--text);
}

.note-body ul, .note-body ol {
  padding-left: 1.35em;
}

.note-body li + li {
  margin-top: .28em;
}

.note-body blockquote {
  margin: 1.1em 0;
  padding: .5em 1em;
  border-left: 4px solid var(--line-strong);
  color: var(--blockquote);
  background: var(--callout-bg);
  border-radius: 0 12px 12px 0;
}

.note-body pre, .note-body code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
}

.note-body pre {
  background: var(--code-bg);
  padding: 14px 16px;
  border-radius: 14px;
  overflow: auto;
  border: 1px solid var(--line);
}

.note-body code {
  background: var(--code-bg);
  padding: .12em .32em;
  border-radius: 6px;
}

.note-body pre code {
  background: transparent;
  padding: 0;
}

.note-body hr {
  border: 0;
  border-top: 1px solid var(--line);
  margin: 1.8em 0;
}

.note-body table {
  width: 100%;
  border-collapse: collapse;
  margin: 1em 0 1.2em;
  background: color-mix(in srgb, var(--bg-elev), transparent 15%);
}

.note-body th, .note-body td {
  border: 1px solid var(--line);
  padding: .55em .65em;
  text-align: left;
}

.note-body th {
  background: color-mix(in srgb, var(--bg-elev-2), transparent 10%);
}

.note-body img {
  max-width: 100%;
  height: auto;
  border-radius: 12px;
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}

.note-body .placeholder {
  border: 1px dashed var(--line-strong);
  background: var(--placeholder-bg);
  padding: 22px 24px;
  border-radius: 18px;
  font-family: var(--font-ui);
  color: var(--text-soft);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.03);
}

.note-body .placeholder strong {
  display: block;
  color: var(--text);
  margin-bottom: 6px;
  font-size: 1.05rem;
}

.note-body .callout {
  border: 1px solid var(--line);
  background: var(--callout-bg);
  border-radius: 14px;
  padding: 12px 14px;
}

.note-body .callout-title {
  font-family: var(--font-ui);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--text-dim);
  margin-bottom: 8px;
}

.note-body .internal-link {
  font-weight: 600;
}

@media (max-width: 980px) {
  .app-shell {
    flex-direction: column;
  }
  .sidebar {
    width: 100%;
    max-width: none;
    min-height: 260px;
  }
  .content-scroll {
    padding: 14px 14px 28px;
  }
}

@media (max-width: 640px) {
  .note-body {
    font-size: 17px;
  }
  .note-title {
    font-size: 22px;
  }
}


/* v12 responsive layout */
.note-header {
  gap: 12px;
}
.note-header-meta, .note-title, .note-path, .brand-title, .nav-folder-label, .nav-file-link {
  min-width: 0;
}
.note-title, .note-path, .note-body, .note-body p, .note-body li, .note-body td, .note-body th {
  overflow-wrap: anywhere;
  word-break: normal;
}
.mobile-nav-toggle,
.mobile-backdrop {
  display: none;
}
.mobile-nav-toggle {
  border: 1px solid var(--line);
  background: var(--bg-elev-2);
  color: var(--text);
  width: 38px;
  height: 38px;
  padding: 0;
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  flex: 0 0 auto;
}
.mobile-nav-toggle:hover {
  background: var(--active);
}

@media (max-width: 980px) {
  body {
    overflow: hidden;
  }
  .app-shell {
    display: block;
    position: relative;
    height: 100%;
  }
  .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: min(86vw, 360px);
    max-width: 360px;
    min-width: 0;
    min-height: 100dvh;
    height: 100dvh;
    z-index: 40;
    transform: translateX(-102%);
    transition: transform .22s ease;
    box-shadow: 16px 0 32px rgba(0,0,0,.28);
  }
  body.sidebar-open .sidebar {
    transform: translateX(0);
  }
  .main-pane {
    width: 100%;
    height: 100%;
  }
  .note-header {
    padding: 10px 14px;
    min-height: 56px;
  }
  .mobile-nav-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }
  .mobile-backdrop {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.38);
    opacity: 0;
    pointer-events: none;
    transition: opacity .18s ease;
    z-index: 30;
  }
  body.sidebar-open .mobile-backdrop {
    opacity: 1;
    pointer-events: auto;
  }
  .content-scroll {
    padding: 12px 12px 24px;
  }
  .hero {
    margin: 0 auto 16px;
    border-radius: 14px;
  }
  .hero img {
    max-height: 220px;
  }
  .note-body table {
    display: block;
    max-width: 100%;
    overflow-x: auto;
    white-space: nowrap;
    -webkit-overflow-scrolling: touch;
  }
  .note-body th, .note-body td {
    min-width: 84px;
  }
  .note-body pre {
    max-width: 100%;
    overflow-x: auto;
  }
}

@media (max-width: 640px) {
  .sidebar-top {
    padding: 14px 12px 10px;
  }
  .sidebar-search {
    padding: 0 12px 10px;
  }
  .tree {
    padding: 6px 6px 12px;
  }
  .brand-title {
    font-size: 18px;
  }
  .note-title {
    font-size: 20px;
    line-height: 1.12;
  }
  .note-path {
    font-size: 11px;
  }
  .note-body {
    font-size: 16px;
    line-height: 1.58;
  }
  .note-body h1 { font-size: 1.8rem; }
  .note-body h2 { font-size: 1.45rem; }
  .note-body h3 { font-size: 1.22rem; }
}


.md-center { display:block; width:100%; text-align:center; }
.note-body td .md-center, .note-body th .md-center { margin:0 auto; }


/* v15 markdown table and wrapping fixes */
.note-title, .note-path, .note-body, .note-body p, .note-body li {
  overflow-wrap: anywhere;
  word-break: normal;
}
.note-body td, .note-body th {
  overflow-wrap: normal;
  word-break: normal;
  hyphens: none;
}
.note-body .md-table-wrap {
  max-width: 100%;
  overflow-x: auto;
  overflow-y: hidden;
  margin: 1em 0 1.2em;
  -webkit-overflow-scrolling: touch;
}
.note-body .md-table-wrap table {
  margin: 0;
  width: max-content;
  min-width: 100%;
  table-layout: auto;
}
.note-body .md-table-wrap th, .note-body .md-table-wrap td {
  white-space: normal;
  vertical-align: top;
}


/* v16 markdown emphasis + table width fixes */
.note-body .md-table-wrap table {
  width: max-content;
  min-width: 100%;
}
.note-body .md-table-wrap th {
  white-space: nowrap;
}
.note-body .md-table-wrap th:first-child,
.note-body .md-table-wrap td:first-child {
  white-space: nowrap;
  min-width: 5.5ch;
}
.note-body .md-table-wrap td {
  white-space: normal;
  overflow-wrap: break-word;
}
