:root {
  color-scheme: light;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: #edf1f4;
  color: #2f2924;
}

:root[data-theme="dark"] {
  color-scheme: dark;
  background: #161412;
  color: #eee8df;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  min-height: 100vh;
  margin: 0;
  padding: 28px;
  background:
    radial-gradient(circle at 88% 0%, rgba(255, 255, 255, .92), transparent 30%),
    linear-gradient(135deg, #8fc0d6, #f5f1ea 48%, #9dbf86);
}

body.auth-view {
  padding: 0;
  background: #fff;
}

:root[data-theme="dark"] body.auth-view {
  background: #0c0a09;
}

:root[data-theme="dark"] body {
  background: linear-gradient(135deg, #15171a, #24201d 52%, #18251d);
}

main {
  min-height: calc(100vh - 56px);
}

#auth {
  min-height: 100vh;
}

.auth-shell {
  width: min(980px, 100%);
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(340px, 420px);
  gap: 34px;
  align-items: center;
}

.auth-copy {
  display: grid;
  gap: 18px;
  color: white;
}

.auth-copy h1 {
  max-width: 620px;
  margin: 0;
  color: white;
  font-size: clamp(36px, 6vw, 64px);
  line-height: .98;
}

.auth-copy .sub,
.auth-copy .crumb {
  max-width: 520px;
  color: rgba(255, 255, 255, .82);
}

.auth-card {
  display: grid;
  gap: 16px;
  padding: 28px;
  border: 1px solid rgba(88, 73, 58, .12);
  border-radius: 14px;
  background: rgba(255, 255, 255, .96);
  box-shadow: 0 28px 80px rgba(34, 47, 58, .22);
}

.auth-card h2 {
  margin: 0 0 6px;
  font-size: 24px;
}

.auth-card label {
  display: grid;
  gap: 7px;
  color: #3b312a;
  font-weight: 650;
}

.auth-card label span {
  font-size: 14px;
}

.auth-card input {
  width: 100%;
}

.auth-card button {
  width: 100%;
}

.auth-card #register {
  background: white;
  color: #3b312a;
  border-color: #d8d0c8;
}

#app {
  min-height: calc(100vh - 56px);
  overflow: hidden;
  border: 1px solid rgba(88, 73, 58, .12);
  border-radius: 18px;
  background: #fbfaf8;
  box-shadow: 0 28px 80px rgba(34, 47, 58, .22);
}

:root[data-theme="dark"] #app,
:root[data-theme="dark"] .workspace,
:root[data-theme="dark"] .paper,
:root[data-theme="dark"] .library-item,
:root[data-theme="dark"] .annotation-editor,
:root[data-theme="dark"] .page-label-editor,
:root[data-theme="dark"] .comment-card,
:root[data-theme="dark"] .menu-popover {
  background: #211d1a;
  color: #eee8df;
  border-color: #403832;
}

:root[data-theme="dark"] header,
:root[data-theme="dark"] .stats,
:root[data-theme="dark"] .label-cloud {
  border-color: #403832;
  background: #211d1a;
}

:root[data-theme="dark"] button,
:root[data-theme="dark"] input,
:root[data-theme="dark"] select,
:root[data-theme="dark"] textarea {
  background: #2b2622;
  color: #eee8df;
  border-color: #514840;
}

:root[data-theme="dark"] .crumb,
:root[data-theme="dark"] .sub,
:root[data-theme="dark"] .stats span,
:root[data-theme="dark"] .stats small,
:root[data-theme="dark"] .library-open span,
:root[data-theme="dark"] .page-head,
:root[data-theme="dark"] .reader-text {
  color: #c8bdb2;
}

.brand {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: #ef6f1a;
  color: white;
  font-weight: 800;
}

.workspace {
  position: relative;
  min-width: 0;
  background: #fff;
}

header {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: start;
  justify-content: space-between;
  gap: 22px;
  padding: 30px 34px 24px;
  border-bottom: 1px solid #ece7e1;
}

.titlebar {
  display: flex;
  gap: 10px;
  align-items: center;
}

#libraryToggle {
  background: #fff;
  color: #3b312a;
  border-color: #e0d8cf;
}

.headline {
  min-width: 0;
}

.crumb, .sub {
  margin: 0;
  color: #7a716a;
}

h1, h2, h3, p {
  margin: 0;
}

h1 {
  margin-top: 26px;
  font-size: 30px;
}

button, input, select {
  font: inherit;
  border: 1px solid #d8d0c8;
  border-radius: 7px;
  background: white;
}

input:focus,
select:focus,
textarea:focus,
button:focus-visible {
  outline: 2px solid rgba(239, 111, 26, .38);
  outline-offset: 2px;
}

button {
  cursor: pointer;
}

.top-actions, #app form {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.top-actions {
  align-items: flex-start;
}

input, select {
  padding: 10px 12px;
}

button {
  padding: 10px 12px;
  background: #3b312a;
  color: white;
  border-color: #3b312a;
}

.stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  border-bottom: 1px solid #ece7e1;
}

.stats div {
  padding: 20px 30px;
  border-right: 1px solid #ece7e1;
}

.stats span, .stats small {
  display: block;
  color: #716963;
}

.stats strong {
  display: block;
  margin: 8px 0 2px;
  font-size: 25px;
}

.library-panel {
  padding: 30px 34px 34px;
}

.recent-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 0 18px;
}

.recent-head button {
  background: transparent;
  color: #4a4039;
  text-decoration: underline;
  border: 0;
}

#notebooks {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  align-content: start;
  gap: 14px;
}

.library-item {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  width: 100%;
  min-height: 132px;
  padding: 18px;
  color: #3f3730;
  border: 1px solid #ebe5dc;
  border-radius: 8px;
  background: #fbfaf7;
}

.library-item.active {
  background: white;
  border-color: #d2c6b9;
  box-shadow: 0 8px 22px rgba(48, 39, 31, .08);
}

.library-open {
  display: grid;
  gap: 10px;
  align-content: start;
  min-width: 0;
  padding: 0;
  text-align: left;
  color: inherit;
  border: 0;
  background: transparent;
}

.library-open span {
  color: #7c736a;
  font-size: 13px;
}

.notebook-menu {
  position: relative;
}

.menu-trigger {
  width: 32px;
  height: 32px;
  padding: 0;
  color: #62584f;
  background: #fff;
  border-color: #e6ddd4;
}

.menu-popover {
  position: absolute;
  top: 38px;
  right: 0;
  z-index: 8;
  display: grid;
  gap: 4px;
  min-width: 150px;
  padding: 6px;
  border: 1px solid #e1d7cc;
  border-radius: 8px;
  background: white;
  box-shadow: 0 14px 34px rgba(48, 39, 31, .16);
}

.menu-popover button {
  padding: 8px 10px;
  text-align: left;
  color: #3b312a;
  background: transparent;
  border: 0;
}

.menu-popover .danger {
  color: #9b2f24;
}

.mini-chips, .chips {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.mini-chips small, .chip {
  padding: 4px 7px;
  border-radius: 999px;
  background: #f1ece5;
  color: #685d54;
  font-size: 12px;
}

.chip {
  border: 0;
}

.chip.active {
  background: #3b312a;
  color: white;
}

.label-cloud {
  display: flex;
  gap: 12px;
  align-items: center;
  padding: 14px 34px;
  border-bottom: 1px solid #ece7e1;
  background: #fdfbf8;
}

.label-cloud span {
  color: #756b62;
  font-weight: 650;
}

.label-cloud div {
  display: flex;
  gap: 7px;
  flex-wrap: wrap;
}

#reader {
  min-width: 0;
  max-width: 1280px;
  padding: 30px 34px 34px;
}

.graph-panel {
  position: relative;
  display: block;
  padding: 30px 34px 34px;
}

.insight-graph {
  width: 100%;
  min-height: 520px;
  border: 1px solid #ece5dd;
  border-radius: 12px;
  background: #fffdf9;
  box-shadow: 0 18px 45px rgba(51, 42, 34, .08);
}

.insight-graph line {
  stroke-linecap: round;
}

.insight-graph line.soft {
  stroke: #d9cbbd;
  stroke-width: 1.5;
  opacity: .75;
}

.insight-graph line.strong {
  stroke: #ef6f1a;
  stroke-width: 3;
}

.graph-node circle {
  fill: #fff4c2;
  stroke: #d6b85d;
  stroke-width: 2;
}

.graph-node.selected circle {
  stroke: #ef6f1a;
  stroke-width: 4;
}

.graph-node circle.safe {
  fill: #dff8df;
  stroke: #85bc85;
}

.graph-node circle.sensitive {
  fill: #ffe3c7;
  stroke: #d49355;
}

.graph-node circle.private {
  fill: #eadff8;
  stroke: #a78ad1;
}

.graph-node text {
  fill: #302b26;
  font: 13px Inter, system-ui, sans-serif;
  pointer-events: none;
}

.graph-node {
  cursor: pointer;
}

.graph-node text.theme {
  font-size: 11px;
  opacity: .7;
}

.graph-detail {
  position: absolute;
  right: 58px;
  top: 58px;
  z-index: 2;
  display: grid;
  gap: 12px;
  width: min(420px, calc(100% - 116px));
  max-height: calc(100% - 116px);
  overflow: auto;
  padding: 18px;
  border: 1px solid #ece5dd;
  border-radius: 12px;
  background: rgba(255, 253, 249, .94);
  box-shadow: 0 18px 45px rgba(51, 42, 34, .12);
}

.graph-detail blockquote {
  margin: 0;
  padding-left: 14px;
  border-left: 3px solid #f0c94d;
  color: #302b26;
  font: 18px/1.55 Georgia, "Times New Roman", serif;
}

.graph-detail button {
  justify-self: start;
}

.reader-head {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 14px;
  padding: 4px 0 12px;
  border-bottom: 1px solid #efe9e1;
}

.reader-head h2 {
  margin: 6px 0 10px;
  font-size: 24px;
}

.page-tabs {
  display: flex;
  gap: 8px;
  overflow: auto;
  padding-bottom: 14px;
}

.page-tabs button {
  background: #f7f3ee;
  color: #4c443e;
  border-color: #e1d8ce;
  white-space: nowrap;
}

.page-tabs button.active {
  background: #3b312a;
  color: white;
}

.paper {
  position: relative;
  display: block;
  max-width: 1160px;
  min-height: 720px;
  padding: clamp(30px, 5vw, 68px);
  border: 1px solid #ece5dd;
  border-radius: 12px;
  background: #fffdf9;
  box-shadow: 0 18px 45px rgba(51, 42, 34, .08);
}

.page-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 30px;
  color: #73695f;
}

.page-head h3 {
  color: #2f2924;
}

.page-note {
  max-width: 560px;
  margin-top: 6px;
  color: #8a5a00;
  font-size: 14px;
  line-height: 1.45;
}

.page-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.note-page {
  background: #f7f3ee;
  color: #3b312a;
  border-color: #e1d8ce;
}

.delete-page {
  background: #fff;
  color: #8f3327;
  border-color: #ead7d3;
}

.reader-text {
  min-height: 560px;
  padding: 6px 2px;
  white-space: pre-wrap;
  color: #302b26;
  font: 20px/1.85 Georgia, "Times New Roman", serif;
  user-select: text;
}

.highlight {
  position: relative;
  display: inline;
  padding: 2px 3px;
  border-radius: 4px;
  background: linear-gradient(transparent 32%, var(--mark-color, #ffe779) 32%);
  color: inherit;
  line-height: inherit;
  -webkit-box-decoration-break: clone;
  box-decoration-break: clone;
}

.sticker {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  vertical-align: baseline;
  white-space: nowrap;
  margin-left: 6px;
  padding: 2px 6px;
  border-radius: 999px;
  background: #fff;
  color: #8a5a00;
  border: 1px solid #f0d276;
  font: 11px/1.2 Inter, system-ui, sans-serif;
}

.remove-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-left: 6px;
  padding: 0 4px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: #8f3327;
  font: inherit;
}

.comment-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-left: 6px;
  padding: 1px 5px;
  border: 0;
  border-radius: 999px;
  background: #f7f3ee;
  color: #3b312a;
  font: 10px/1.2 Inter, system-ui, sans-serif;
}

.annotation-editor {
  position: fixed;
  z-index: 20;
  right: 28px;
  bottom: 28px;
  display: grid;
  gap: 12px;
  width: min(420px, calc(100vw - 56px));
  padding: 18px;
  border: 1px solid #ded3c7;
  border-radius: 12px;
  background: #fff;
  box-shadow: 0 22px 58px rgba(44, 35, 27, .2);
}

.page-label-editor {
  position: fixed;
  z-index: 22;
  right: 28px;
  bottom: 28px;
  display: grid;
  gap: 12px;
  width: min(420px, calc(100vw - 56px));
  padding: 18px;
  border: 1px solid #ded3c7;
  border-radius: 12px;
  background: #fff;
  box-shadow: 0 22px 58px rgba(44, 35, 27, .2);
}

.annotation-trigger {
  position: fixed;
  z-index: 25;
  padding: 7px 10px;
  border-radius: 999px;
  background: #3b312a;
  color: white;
  box-shadow: 0 10px 24px rgba(44, 35, 27, .18);
}

.annotation-editor blockquote {
  margin: 0;
  max-height: 120px;
  overflow: auto;
  padding: 10px 12px;
  border-left: 3px solid #f0c94d;
  background: #fffaf0;
  color: #3b312a;
  font: 16px/1.55 Georgia, "Times New Roman", serif;
}

.annotation-editor input,
.annotation-editor textarea {
  width: 100%;
  padding: 8px 10px;
  border-radius: 8px;
}

.annotation-editor textarea {
  min-height: 94px;
  resize: vertical;
}

.label-menu {
  display: grid;
  gap: 6px;
  max-height: 150px;
  overflow: auto;
  padding: 8px;
  border: 1px solid #e7ded4;
  border-radius: 8px;
  background: #fbfaf7;
}

.label-option {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 8px;
  color: #3b312a;
  text-align: left;
  background: white;
  border-color: #eee6dd;
}

.label-option:hover {
  border-color: #d4c7ba;
  background: #f7f3ee;
}

.label-option span {
  width: 12px;
  height: 12px;
  flex: 0 0 12px;
  border-radius: 999px;
  border: 1px solid rgba(0, 0, 0, .12);
}

.add-label-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
}

.color-row {
  display: flex;
  gap: 8px;
  align-items: center;
}

.color-swatch,
.annotation-editor input[type="color"] {
  width: 42px;
  height: 34px;
  padding: 0;
  border-radius: 8px;
}

.annotation-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.annotation-editor button {
  padding: 8px 10px;
  border-radius: 8px;
}

.annotation-actions button:first-child {
  background: #f7f3ee;
  color: #3b312a;
}

.comment-card {
  position: fixed;
  z-index: 24;
  display: grid;
  gap: 10px;
  width: min(280px, calc(100vw - 32px));
  padding: 14px;
  border: 1px solid #ded3c7;
  border-radius: 10px;
  background: white;
  box-shadow: 0 16px 36px rgba(44, 35, 27, .18);
}

.comment-card p {
  color: #3b312a;
  line-height: 1.45;
}

.comment-card button {
  justify-self: end;
  padding: 7px 10px;
}
.filtered-passages {
  display: grid;
  gap: 14px;
}

.filtered-card {
  display: grid;
  gap: 12px;
  padding: 18px;
  border: 1px solid #ece5dd;
  border-radius: 10px;
  background: #fffdf9;
  box-shadow: 0 12px 32px rgba(51, 42, 34, .07);
}

.filtered-card blockquote {
  margin: 0;
  padding: 2px 0 2px 14px;
  border-left: 3px solid #f0c94d;
  color: #302b26;
  font: 18px/1.65 Georgia, "Times New Roman", serif;
}

.page-embed {
  max-height: 460px;
  overflow: auto;
  margin: 0;
  padding: 14px;
  white-space: pre-wrap;
  border: 1px solid #ece5dd;
  border-radius: 8px;
  background: #fffaf0;
  color: #302b26;
  font: 17px/1.65 Georgia, "Times New Roman", serif;
}

:root[data-theme="dark"] .page-embed,
:root[data-theme="dark"] .annotation-editor blockquote,
:root[data-theme="dark"] .label-menu,
:root[data-theme="dark"] .label-option,
:root[data-theme="dark"] .insight-graph,
:root[data-theme="dark"] .graph-detail {
  background: #2b2622;
  color: #eee8df;
  border-color: #514840;
}

:root[data-theme="dark"] .graph-detail blockquote {
  color: #eee8df;
}

:root[data-theme="dark"] .insight-graph line.soft {
  stroke: #62564d;
}

:root[data-theme="dark"] .graph-node text {
  fill: #211d1a;
}

.filtered-card button {
  justify-self: start;
}

.empty {
  padding: 34px 0;
  color: #766d65;
}

@media (max-width: 980px) {
  body {
    padding: 0;
  }

  #app {
    min-height: 100vh;
    border-radius: 0;
  }

  header {
    grid-template-columns: 1fr;
  }

  header, .recent-head, #reader {
    padding-inline: 20px;
  }

  .stats {
    grid-template-columns: repeat(2, 1fr);
  }

  .paper {
    padding-inline: 20px;
  }

  .graph-detail {
    position: static;
    width: auto;
    max-height: none;
    margin-top: 14px;
  }
}
