body.notes-page {
  --primary: #0e7490;
  --primary-strong: #16a34a;
  --chat-ink: #12313d;
  --chat-muted: #667085;
  --chat-line: rgba(14, 116, 144, 0.15);
  --chat-panel: rgba(255, 255, 255, 0.86);
  --chat-soft: rgba(240, 253, 250, 0.78);
  --border-strong: rgba(14, 116, 144, 0.28);
}

.notes-icon-box {
  background: linear-gradient(135deg, rgba(14, 165, 233, 0.16) 0%, rgba(34, 197, 94, 0.2) 100%);
  color: #0e7490;
}

.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;
}

.notes-chat-shell {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(300px, 380px);
  gap: 24px;
  align-items: stretch;
  min-height: clamp(620px, calc(100vh - 190px), 860px);
}

.notes-chat-panel,
.notes-pinned-panel,
.notes-side-card {
  border: 1px solid rgba(226, 232, 240, 0.9);
  background: var(--chat-panel);
  box-shadow: var(--shadow-sm);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
}

.notes-chat-panel {
  min-width: 0;
  display: flex;
  flex-direction: column;
  min-height: 0;
  height: clamp(620px, calc(100vh - 190px), 860px);
  border-radius: 28px;
  overflow: hidden;
}

.notes-kicker,
.notes-side-kicker {
  display: inline-flex;
  margin-bottom: 10px;
  color: var(--primary);
  font-size: 0.94rem;
  font-weight: 800;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.notes-pinned-head h2 {
  margin: 0;
  color: var(--chat-ink);
  font-size: clamp(2rem, 3vw, 3.1rem);
  line-height: 1.08;
}

.notes-auth-btn,
.notes-submit-btn,
.notes-secondary-btn,
.notes-icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: 44px;
  padding: 11px 16px;
  border-radius: 999px;
  border: 1px solid transparent;
  font: inherit;
  font-size: 1.04rem;
  font-weight: 800;
  cursor: pointer;
  transition: transform 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease, background-color 0.2s ease, color 0.2s ease;
}

.notes-auth-btn:hover,
.notes-submit-btn:hover,
.notes-secondary-btn:hover,
.notes-icon-btn:hover {
  transform: translateY(-1px);
}

.notes-auth-btn,
.notes-submit-btn {
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-strong) 100%);
  color: #ffffff;
  box-shadow: 0 14px 24px rgba(13, 148, 136, 0.18);
}

.notes-secondary-btn,
.notes-icon-btn {
  background: rgba(255, 255, 255, 0.86);
  color: #115e59;
  border-color: rgba(15, 118, 110, 0.14);
  box-shadow: none;
}

.notes-submit-btn:disabled,
.notes-auth-btn:disabled {
  opacity: 0.56;
  cursor: not-allowed;
  transform: none;
}

.notes-feedback {
  margin: 16px 20px 0;
  padding: 13px 16px;
  border-radius: 18px;
  border: 1px solid transparent;
  font-size: 1.08rem;
  font-weight: 700;
  line-height: 1.5;
}

.notes-feedback.is-hidden {
  display: none;
}

.notes-feedback.is-success {
  background: rgba(34, 197, 94, 0.12);
  border-color: rgba(34, 197, 94, 0.22);
  color: #166534;
}

.notes-feedback.is-info {
  background: rgba(15, 118, 110, 0.12);
  border-color: rgba(15, 118, 110, 0.22);
  color: #115e59;
}

.notes-feedback.is-error {
  background: rgba(239, 68, 68, 0.12);
  border-color: rgba(239, 68, 68, 0.18);
  color: #b91c1c;
}

.notes-auth-callout {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin: 0;
  padding: 14px 20px;
  border: 0;
  border-bottom: 1px solid var(--chat-line);
  border-radius: 0;
  background: rgba(255, 255, 255, 0.68);
}

.notes-auth-callout[hidden] {
  display: none;
}

.notes-auth-callout.is-active-user {
  background: linear-gradient(135deg, rgba(240, 253, 250, 0.74) 0%, rgba(255, 255, 255, 0.88) 100%);
}

.notes-auth-callout strong {
  display: block;
  margin-bottom: 5px;
  color: var(--chat-ink);
  font-size: 1.24rem;
}

.notes-auth-callout p {
  color: var(--chat-muted);
  font-size: 1.06rem;
  line-height: 1.55;
}

.notes-chat-window {
  flex: 1 1 auto;
  min-height: 0;
  max-height: none;
  overflow-y: auto;
  padding: 22px 20px 24px;
  scroll-behavior: smooth;
}

.notes-chat-list {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.notes-chat-message {
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr);
  gap: 12px;
  align-items: end;
  max-width: min(760px, 92%);
}

.notes-chat-message.is-mine {
  align-self: flex-end;
  grid-template-columns: minmax(0, 1fr) 44px;
}

.notes-chat-message.is-mine .notes-message-avatar {
  order: 2;
}

.notes-chat-message.is-mine .notes-message-bubble {
  align-items: flex-end;
  background: linear-gradient(135deg, rgba(14, 116, 144, 0.94) 0%, rgba(22, 163, 74, 0.88) 100%);
  color: #ffffff;
  border-color: rgba(14, 116, 144, 0.32);
}

.notes-chat-message.is-mine .notes-message-meta,
.notes-chat-message.is-mine .notes-message-content {
  color: rgba(255, 255, 255, 0.92);
}

.notes-chat-message.is-pinned .notes-message-bubble {
  box-shadow: 0 18px 38px rgba(245, 158, 11, 0.13);
  border-color: rgba(245, 158, 11, 0.28);
}

.notes-message-avatar {
  align-self: end;
}

.notes-avatar,
.notes-avatar-sm {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 16px;
  background: linear-gradient(135deg, rgba(14, 116, 144, 0.94) 0%, rgba(34, 197, 94, 0.88) 100%);
  color: #ffffff;
  font-size: 1.12rem;
  font-weight: 800;
}

.notes-avatar-sm {
  width: 34px;
  height: 34px;
  border-radius: 12px;
  font-size: 0.92rem;
}

.notes-message-bubble {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 9px;
  padding: 16px;
  border-radius: 22px 22px 22px 8px;
  background: rgba(255, 255, 255, 0.94);
  border: 1px solid rgba(226, 232, 240, 0.92);
  color: var(--chat-ink);
  box-shadow: 0 14px 28px rgba(15, 23, 42, 0.06);
}

.notes-chat-message.is-mine .notes-message-bubble {
  border-radius: 22px 22px 8px 22px;
}

.notes-message-meta {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 7px;
  color: var(--chat-muted);
  font-size: 0.88rem;
  line-height: 1.35;
}

.notes-message-meta strong {
  color: currentColor;
  font-size: 0.96rem;
}

.notes-message-content {
  color: var(--chat-ink);
  font-size: 1.14rem;
  line-height: 1.72;
  word-break: break-word;
}

.notes-pin-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 8px;
  border-radius: 999px;
  background: rgba(245, 158, 11, 0.16);
  color: #b45309;
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
}

.notes-message-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.notes-icon-btn {
  min-height: 34px;
  padding: 7px 10px;
  font-size: 0.9rem;
}

.notes-icon-btn.is-danger {
  color: #dc2626;
  border-color: rgba(239, 68, 68, 0.14);
}

.notes-chat-composer {
  display: grid;
  gap: 12px;
  padding: 18px 20px 20px;
  border-top: 1px solid var(--chat-line);
  background: rgba(248, 250, 252, 0.72);
}

.notes-chat-composer textarea {
  width: 100%;
  min-height: 72px;
  max-height: 180px;
  padding: 15px 16px;
  border: 1px solid rgba(14, 116, 144, 0.16);
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.94);
  color: var(--chat-ink);
  font: inherit;
  font-size: 1.12rem;
  line-height: 1.55;
  resize: vertical;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.notes-chat-composer textarea:focus {
  outline: none;
  border-color: rgba(14, 116, 144, 0.42);
  box-shadow: 0 0 0 4px rgba(14, 116, 144, 0.12);
}

.notes-chat-composer.is-disabled textarea {
  opacity: 0.64;
  cursor: not-allowed;
}

.notes-chat-composer-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  flex-wrap: wrap;
}

.notes-chat-edit-indicator {
  margin-right: auto;
  color: #b45309;
  font-size: 0.98rem;
  font-weight: 800;
}

.notes-active-viewers {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 20px 16px;
  border-top: 1px solid rgba(14, 116, 144, 0.12);
  background: rgba(255, 255, 255, 0.7);
}

.notes-active-viewers-label {
  color: var(--chat-muted);
  font-size: 0.92rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  white-space: nowrap;
}

.notes-active-viewers-list {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 8px;
  min-width: 0;
}

.notes-active-viewer-chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 32px;
  padding: 6px 11px;
  border-radius: 999px;
  border: 1px solid rgba(22, 163, 74, 0.16);
  background: rgba(240, 253, 244, 0.82);
  color: #166534;
  font-size: 0.98rem;
  font-weight: 800;
  line-height: 1.2;
}

.notes-active-dot {
  width: 9px;
  height: 9px;
  flex: 0 0 9px;
  border-radius: 50%;
  background: #22c55e;
  box-shadow: 0 0 0 4px rgba(34, 197, 94, 0.14);
}

.notes-pinned-panel {
  position: sticky;
  top: 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  height: clamp(620px, calc(100vh - 190px), 860px);
  max-height: calc(100vh - 48px);
  padding: 20px;
  border-radius: 28px;
  overflow: hidden;
}

.notes-pinned-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
}

.notes-pinned-head h2 {
  font-size: 1.7rem;
}

.notes-pinned-count {
  display: grid;
  place-items: center;
  min-width: 42px;
  height: 42px;
  padding: 0 12px;
  border-radius: 999px;
  background: rgba(15, 118, 110, 0.1);
  color: var(--primary);
  font-size: 1.2rem;
  font-weight: 900;
}

.notes-pinned-list {
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  gap: 14px;
  min-height: 0;
  overflow-y: auto;
  padding-right: 4px;
}

.notes-pinned-list .notes-empty-state {
  min-height: 100%;
}

.notes-pinned-card,
.notes-side-card,
.notes-empty-state {
  border-radius: 22px;
  border: 1px solid rgba(226, 232, 240, 0.9);
  background: rgba(255, 255, 255, 0.84);
}

.notes-pinned-card {
  display: grid;
  gap: 12px;
  padding: 16px;
  box-shadow: 0 14px 28px rgba(15, 23, 42, 0.05);
}

.notes-pinned-card-head {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.notes-pinned-card-head strong,
.notes-pinned-card-head span {
  display: block;
}

.notes-pinned-card-head strong {
  color: var(--chat-ink);
  font-size: 1.02rem;
}

.notes-pinned-card-head span {
  color: var(--chat-muted);
  font-size: 0.88rem;
}

.notes-pinned-card p {
  color: var(--chat-ink);
  font-size: 1.02rem;
  line-height: 1.65;
  word-break: break-word;
}

.notes-side-card {
  display: grid;
  gap: 10px;
  padding: 16px;
}

.notes-user-status strong {
  display: block;
  margin-bottom: 5px;
  color: var(--chat-ink);
  font-size: 1.16rem;
}

.notes-user-status p,
.notes-rule-list {
  color: var(--chat-muted);
  font-size: 1rem;
  line-height: 1.65;
}

.notes-rule-list {
  display: grid;
  gap: 8px;
  padding-left: 18px;
}

.notes-empty-state {
  display: grid;
  place-items: center;
  gap: 10px;
  padding: 28px 22px;
  text-align: center;
  border-style: dashed;
  background: rgba(248, 250, 252, 0.76);
}

.notes-empty-icon {
  display: grid;
  place-items: center;
  width: 52px;
  height: 52px;
  border-radius: 18px;
  background: rgba(15, 118, 110, 0.12);
  color: var(--primary);
  font-size: 1.7rem;
}

.notes-empty-state strong {
  color: var(--chat-ink);
  font-size: 1.24rem;
}

.notes-empty-state p {
  max-width: 380px;
  color: var(--chat-muted);
  font-size: 1rem;
  line-height: 1.65;
}

body.notes-page.theme-dark {
  --chat-ink: #e5f9f6;
  --chat-muted: #a8c6c0;
  --chat-line: rgba(94, 234, 212, 0.14);
  --chat-panel: rgba(15, 23, 42, 0.78);
  --chat-soft: rgba(19, 78, 74, 0.32);
}

body.notes-page.theme-dark .notes-chat-panel,
body.notes-page.theme-dark .notes-pinned-panel,
body.notes-page.theme-dark .notes-side-card,
body.notes-page.theme-dark .notes-pinned-card,
body.notes-page.theme-dark .notes-empty-state {
  border-color: rgba(94, 234, 212, 0.12);
  background: rgba(15, 23, 42, 0.82);
}

body.notes-page.theme-dark .notes-message-bubble,
body.notes-page.theme-dark .notes-chat-composer textarea {
  background: rgba(15, 23, 42, 0.94);
  border-color: rgba(94, 234, 212, 0.12);
}

body.notes-page.theme-dark .notes-chat-composer {
  background: rgba(2, 6, 23, 0.34);
}

body.notes-page.theme-dark .notes-active-viewers {
  border-color: rgba(94, 234, 212, 0.12);
  background: rgba(2, 6, 23, 0.28);
}

body.notes-page.theme-dark .notes-active-viewer-chip {
  border-color: rgba(74, 222, 128, 0.18);
  background: rgba(20, 83, 45, 0.5);
  color: #bbf7d0;
}

body.notes-page.theme-dark .notes-secondary-btn,
body.notes-page.theme-dark .notes-icon-btn {
  background: rgba(15, 23, 42, 0.72);
  border-color: rgba(94, 234, 212, 0.14);
  color: #99f6e4;
}

body.notes-page.theme-dark .notes-icon-btn.is-danger {
  color: #fca5a5;
}

body.notes-page.theme-dark .notes-pin-chip {
  background: rgba(245, 158, 11, 0.18);
  color: #fcd34d;
}

@media (max-width: 1180px) {
  .notes-chat-shell {
    grid-template-columns: 1fr;
    min-height: 0;
  }
  .notes-chat-panel,
  .notes-pinned-panel {
    position: static;
    height: auto;
    max-height: none;
  }
  .notes-pinned-panel {
    min-height: 460px;
    overflow: visible;
  }
}
@media (max-width: 720px) {
  .notes-chat-shell {
    gap: 18px;
  }
  .notes-chat-panel,
  .notes-pinned-panel {
    border-radius: 22px;
  }
  .notes-auth-callout {
    align-items: stretch;
    flex-direction: column;
  }
  .notes-auth-btn {
    width: 100%;
  }
  .notes-chat-window {
    max-height: none;
    min-height: 420px;
    padding: 18px 14px;
  }
  .notes-chat-message,
  .notes-chat-message.is-mine {
    max-width: 100%;
    grid-template-columns: 38px minmax(0, 1fr);
  }
  .notes-chat-message.is-mine {
    grid-template-columns: minmax(0, 1fr) 38px;
  }
  .notes-avatar {
    width: 38px;
    height: 38px;
    border-radius: 14px;
  }
  .notes-message-actions {
    width: 100%;
  }
  .notes-icon-btn {
    flex: 1 1 auto;
  }
  .notes-chat-composer-actions {
    align-items: stretch;
    flex-direction: column;
  }
  .notes-active-viewers {
    align-items: flex-start;
    flex-direction: column;
  }
  .notes-active-viewers-list {
    justify-content: flex-start;
  }
  .notes-chat-edit-indicator {
    margin-right: 0;
  }
  .notes-submit-btn,
  .notes-secondary-btn {
    width: 100%;
  }
}
