/* notes-review: inline comments on Flatnotes' rendered notes. */
:root {
  --nr-bg: #fffdf7;
  --nr-fg: #1f2328;
  --nr-muted: #6b7280;
  --nr-border: #e5e7eb;
  --nr-mark: #fde68a;
  --nr-mark-resolved: #e5e7eb;
  --nr-primary: #f8a66b;
  --nr-danger: #dc2626;
  --nr-shadow: 0 8px 28px rgba(0, 0, 0, 0.18);
}
@media (prefers-color-scheme: dark) {
  :root {
    --nr-bg: #1f2428;
    --nr-fg: #e6edf3;
    --nr-muted: #9aa4af;
    --nr-border: #3a424a;
    --nr-mark: #7a5a0a;
    --nr-mark-resolved: #3a424a;
    --nr-shadow: 0 8px 28px rgba(0, 0, 0, 0.5);
  }
}

mark.nr-mark {
  background: var(--nr-mark);
  color: inherit;
  border-radius: 2px;
  cursor: pointer;
  padding: 0 1px;
}
mark.nr-mark.nr-resolved { background: var(--nr-mark-resolved); }
mark.nr-mark:hover { outline: 2px solid var(--nr-primary); }

.nr-ui { font-family: Poppins, system-ui, sans-serif; font-size: 14px; color: var(--nr-fg); box-sizing: border-box; }
.nr-ui * { box-sizing: border-box; }

#nr-bubble {
  position: fixed; z-index: 10000;
  background: var(--nr-fg); color: var(--nr-bg);
  border: 0; border-radius: 999px; padding: 6px 14px;
  font-weight: 600; cursor: pointer; box-shadow: var(--nr-shadow);
}

.nr-card {
  position: fixed; z-index: 10001; width: 360px; max-width: calc(100vw - 16px);
  background: var(--nr-bg); border: 1px solid var(--nr-border); border-radius: 10px;
  padding: 10px; box-shadow: var(--nr-shadow);
}
.nr-quote {
  font-size: 12px; color: var(--nr-muted); border-left: 3px solid var(--nr-primary);
  padding: 2px 8px; margin-bottom: 8px; white-space: pre-wrap; word-break: break-word;
}
.nr-body { margin-bottom: 6px; white-space: pre-wrap; word-break: break-word; }
.nr-text {
  width: 100%; font: inherit; color: inherit; background: transparent;
  border: 1px solid var(--nr-border); border-radius: 6px; padding: 6px; resize: vertical;
}
.nr-text:focus { outline: 2px solid var(--nr-primary); border-color: transparent; }
.nr-row { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 8px; }
.nr-btn {
  font: inherit; font-size: 13px; cursor: pointer; border-radius: 6px; padding: 5px 10px;
  background: transparent; color: var(--nr-fg); border: 1px solid var(--nr-border);
}
.nr-btn:hover { border-color: var(--nr-primary); }
.nr-primary { background: var(--nr-primary); border-color: var(--nr-primary); color: #1f2328; font-weight: 600; }
.nr-danger { color: var(--nr-danger); }
.nr-replies { margin: 4px 0; }
.nr-reply { font-size: 13px; padding: 4px 0 4px 10px; border-left: 2px solid var(--nr-border); margin: 4px 0; white-space: pre-wrap; word-break: break-word; }
.nr-reply.nr-agent { border-left-color: var(--nr-primary); }
.nr-muted { color: var(--nr-muted); font-size: 12px; }

#nr-badge {
  position: fixed; right: 16px; bottom: 16px; z-index: 9999;
  background: var(--nr-bg); color: var(--nr-fg); border: 1px solid var(--nr-border);
  border-radius: 999px; padding: 8px 14px; cursor: pointer; box-shadow: var(--nr-shadow); font-size: 14px;
}
#nr-panel {
  position: fixed; right: 16px; bottom: 64px; z-index: 9998;
  width: 340px; max-width: calc(100vw - 32px); max-height: min(70vh, 640px); overflow: auto;
  background: var(--nr-bg); border: 1px solid var(--nr-border); border-radius: 10px;
  padding: 10px; box-shadow: var(--nr-shadow);
}
.nr-panel-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px; }
.nr-item { padding: 8px; border: 1px solid var(--nr-border); border-radius: 8px; margin: 6px 0; cursor: pointer; }
.nr-item:hover { border-color: var(--nr-primary); }
.nr-item-resolved { opacity: 0.6; }

#nr-toast {
  position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 20px); z-index: 10002;
  background: var(--nr-fg); color: var(--nr-bg); padding: 8px 14px; border-radius: 8px;
  opacity: 0; transition: opacity 0.2s, transform 0.2s; pointer-events: none; font-size: 13px;
}
#nr-toast.nr-show { opacity: 1; transform: translate(-50%, 0); }
#nr-revision {
  position: fixed; left: 50%; bottom: 72px; transform: translateX(-50%); z-index: 10002;
  display: flex; gap: 10px; align-items: center; max-width: calc(100vw - 32px);
  background: var(--nr-fg); color: var(--nr-bg); padding: 8px 10px 8px 14px; border-radius: 8px;
  box-shadow: var(--nr-shadow); font-size: 13px;
}
#nr-toast.nr-error { background: var(--nr-danger); color: #fff; }

/* The SVG keeps mermaid's width 100% and max-width (natural width); review.js adds a
   min-width of 90% of the natural width, so a wide diagram scrolls instead of shrinking. */
.nr-mermaid { position: relative; margin: 1em 0; }
.nr-mermaid-scroll { overflow-x: auto; }
.nr-mermaid svg { display: block; height: auto; }
.nr-zoom-btn { position: absolute; top: 4px; right: 4px; font-size: 12px; padding: 2px 8px; background: var(--nr-bg); opacity: 0.7; }
.nr-zoom-btn:hover, .nr-zoom-btn:focus { opacity: 1; }
/* The diagram's theme follows Flatnotes' setting (review.js isDark), not the OS scheme;
   these classes re-scope our colours so the Zoom button and overlay match the diagram. */
.nr-light { --nr-bg: #fffdf7; --nr-fg: #1f2328; --nr-border: #e5e7eb; }
.nr-dark { --nr-bg: #1f2428; --nr-fg: #e6edf3; --nr-border: #3a424a; }
#nr-zoom { position: fixed; inset: 0; z-index: 10003; overflow: auto; overscroll-behavior: contain; background: var(--nr-bg); color: var(--nr-fg); padding: 48px 16px 16px; }
.nr-zoom-inner { width: max-content; min-width: 100%; }
#nr-zoom svg { display: block; margin: 0 auto; height: auto; }
.nr-zoom-close { position: fixed; top: 10px; right: 10px; background: var(--nr-bg); }
pre.nr-mermaid-error { outline: 2px dashed var(--nr-danger); }

@media (max-width: 640px) {
  #nr-panel { left: 8px; right: 8px; width: auto; bottom: 60px; }
  .nr-card { width: calc(100vw - 16px); }
}
@media print {
  .nr-ui, #nr-badge, #nr-panel, #nr-toast { display: none !important; }
  mark.nr-mark { background: transparent; }
  /* paper cannot scroll: fit the diagram to the column again */
  .nr-mermaid-scroll { overflow: visible; }
  .nr-mermaid svg { min-width: 0 !important; max-width: 100% !important; }
}
