:root {
  --app-font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --app-mono-font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
  --app-bg: #f5f5f2;
  --app-surface: #fbfbf8;
  --app-surface-muted: #efefea;
  --app-border: #d9d8d0;
  --app-text: #24251f;
  --app-text-muted: #727066;
  --app-link: #385f7d;
  --app-link-active: #1f4f6d;
  --app-accent: #6f8377;
  --app-danger: #9b4a45;
  --app-font-size: 14px;
  --app-line-height: 1.55;
  --app-space-1: 0.25rem;
  --app-space-2: 0.5rem;
  --app-space-3: 0.75rem;
  --app-space-4: 1rem;
  --app-radius: 0.25rem;
  --main-view-padding: 1rem;
  --markdown-font-size: 0.96rem;
  --markdown-heading-color: #273735;
  --markdown-h1-size: 1.55rem;
  --markdown-h2-size: 1.28rem;
  --markdown-h3-size: 1.1rem;
  --markdown-code-bg: #f0f0eb;
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  min-height: 100%;
}

body {
  margin: 0;
  background: var(--app-bg);
  color: var(--app-text);
  font-family: var(--app-font-family);
  font-size: var(--app-font-size);
  line-height: var(--app-line-height);
}

a {
  color: var(--app-link);
}

a:hover {
  color: var(--app-link-active);
}

.app-navbar {
  background: var(--app-surface);
}

.app-navbar .navbar-brand {
  color: var(--app-text);
  font-weight: 650;
}

.app-navbar .nav-link.active {
  color: var(--app-link-active);
  font-weight: 650;
}

.app-nav-button {
  width: 100%;
  border: 0;
  background: transparent;
  color: var(--app-link);
  text-align: left;
}

.app-nav-button:hover {
  color: var(--app-link-active);
}

.main-view {
  min-width: 0;
  width: 100%;
  min-height: calc(100vh - 3.5rem);
  padding: var(--main-view-padding);
  background: var(--app-bg);
}

.main-view p {
  text-align: justify;
}

.auth-view {
  width: 100vw;
  min-height: calc(100vh - 3.5rem);
  padding: var(--main-view-padding);
}

.app-page {
  width: 100%;
}

.app-page-header {
  display: flex;
  flex-direction: column;
  gap: var(--app-space-3);
  margin-bottom: var(--app-space-3);
}

.app-page-title {
  margin-bottom: var(--app-space-1);
  font-size: 1.25rem;
  font-weight: 650;
}

.app-page-actions {
  display: flex;
  flex-direction: column;
  gap: var(--app-space-2);
}

.app-page-actions form {
  align-items: flex-start;
}

.app-page-actions .btn {
  white-space: nowrap;
}

.app-panel {
  background: var(--app-surface);
  border: 1px solid var(--app-border);
  border-radius: var(--app-radius);
}

.app-panel-body {
  padding: var(--app-space-4);
}

.app-form-panel,
.auth-panel {
  max-width: 38rem;
  margin: 0 auto;
}

.auth-panel {
  margin-top: 8vh;
}

.file-action-input {
  max-width: 12rem;
  min-width: 9rem;
}

.markdown-editor {
  min-height: calc(100vh - 14rem) !important;
  font-family: var(--app-mono-font-family);
  font-size: 0.92rem;
  line-height: 1.5;
  resize: vertical;
}

.markdown-image-input {
  max-width: 16rem;
}

.two-factor-qr {
  background: var(--app-surface);
  border: 1px solid var(--app-border);
  border-radius: var(--app-radius);
  padding: var(--app-space-2);
}

.search-form,
.search-result {
  max-width: 76rem;
}

.search-snippet {
  display: grid;
  grid-template-columns: 5.5rem minmax(0, 1fr);
  gap: var(--app-space-2);
  padding: var(--app-space-2) 0;
  border-top: 1px solid var(--app-border);
}

.search-snippet-line {
  color: var(--app-text-muted);
  font-family: var(--app-mono-font-family);
  font-size: 0.82rem;
}

.markdown-preview {
  min-height: calc(100vh - 11rem) !important;
  overflow-wrap: anywhere;
  font-size: var(--markdown-font-size);
  text-align: justify;
}

.markdown-preview-reading {
  margin: 0 auto;
}

.markdown-preview h1,
.markdown-preview h2,
.markdown-preview h3,
.markdown-preview h4 {
  color: var(--markdown-heading-color);
  font-weight: 650;
  line-height: 1.25;
}

.markdown-preview h1 {
  font-size: var(--markdown-h1-size);
}

.markdown-preview h2 {
  font-size: var(--markdown-h2-size);
}

.markdown-preview h3 {
  font-size: var(--markdown-h3-size);
}

.markdown-preview img {
  max-width: 100%;
  height: auto;
}

.markdown-preview table {
  width: 100%;
  margin-bottom: 1rem;
  border-collapse: collapse;
}

.markdown-preview th,
.markdown-preview td {
  padding: 0.45rem;
  border: 1px solid var(--app-border);
}

.code-block {
  position: relative;
  margin: 1rem 0;
  text-align: left;
}

.code-block pre {
  padding: 1rem;
  overflow: auto;
  border: 1px solid var(--app-border);
  border-radius: var(--app-radius);
  background: var(--markdown-code-bg);
}

.code-copy-button {
  position: absolute;
  top: 0.5rem;
  right: 0.5rem;
}

.clipboard-fallback-textarea {
  position: fixed;
  top: -1000px;
  left: -1000px;
}

.task-list-item {
  list-style: none;
}

.task-list-item input {
  margin-right: 0.5rem;
}

.card,
.rounded {
  border-radius: var(--app-radius) !important;
}

@media (max-width: 720px) {
  .main-view {
    padding: var(--app-space-3);
  }

  .auth-panel {
    margin-top: 0;
  }
}

@media (min-width: 992px) {
  .app-page-header {
    flex-direction: row;
    justify-content: space-between;
    align-items: flex-start;
  }

  .app-page-actions {
    flex-direction: row;
    align-items: flex-start;
  }
}

.hljs {
  background-color: transparent !important;
}

@media print {
  :root {
    --app-bg: #ffffff;
    --app-surface: #ffffff;
    --app-border: #d0d0d0;
    --app-text: #000000;
    --app-text-muted: #555555;
  }

  body {
    background: #ffffff !important;
    color: #000000 !important;
  }

  .main-view {
    min-height: 0;
    padding: 0 !important;
    background: #ffffff !important;
  }

  .container {
    max-width: none !important;
    width: 100% !important;
  }

  .app-panel {
    border: 0 !important;
    background: transparent !important;
  }

  .app-panel-body {
    padding: 0 !important;
  }

  .markdown-preview {
    min-height: 0 !important;
    font-size: 11pt;
  }

  .markdown-preview p {
    text-align: justify;
  }

  .code-block pre {
    white-space: pre-wrap;
  }
}
