* {
  box-sizing: border-box;
}

body.notes-lab-page {
  margin: 0;
  min-height: 100vh;
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  background: #f4f6f2;
  color: #1a2e28;
}

.notes-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  padding: 16px 24px;
  background: #fff;
  border-bottom: 1px solid #d9e0d7;
}

.notes-brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.notes-brand-mark {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  font-weight: 800;
  background: #176b5d;
  color: #fff;
}

.notes-header h1 {
  margin: 0;
  font-size: 20px;
}

.notes-header p {
  margin: 2px 0 0;
  font-size: 13px;
  color: #5c6f66;
}

.notes-header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.notes-user {
  font-size: 13px;
  color: #5c6f66;
  max-width: 200px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.notes-main {
  max-width: 1100px;
  margin: 0 auto;
  padding: 24px;
}

.notes-intro {
  margin: 0 0 20px;
  padding: 14px 16px;
  border-radius: 12px;
  background: #e8f3ef;
  border: 1px solid #c5ddd4;
  font-size: 14px;
  line-height: 1.6;
}

.notes-grid {
  display: grid;
  grid-template-columns: minmax(280px, 360px) 1fr;
  gap: 20px;
  align-items: start;
}

@media (max-width: 860px) {
  .notes-grid {
    grid-template-columns: 1fr;
  }
}

.notes-compose,
.notes-list-panel {
  background: #fff;
  border: 1px solid #d9e0d7;
  border-radius: 14px;
  padding: 18px;
  box-shadow: 0 8px 24px rgba(23, 107, 93, 0.06);
}

.notes-compose h2,
.notes-list-panel h2 {
  margin: 0 0 14px;
  font-size: 16px;
}

.notes-field {
  margin-bottom: 12px;
}

.notes-field label {
  display: block;
  font-size: 12px;
  font-weight: 700;
  margin-bottom: 6px;
  color: #3d5249;
}

.notes-field input,
.notes-field textarea,
.notes-field select {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid #cfd9d4;
  border-radius: 10px;
  font: inherit;
}

.notes-field textarea {
  min-height: 100px;
  resize: vertical;
}

.notes-btn {
  border: 0;
  border-radius: 10px;
  padding: 10px 16px;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

.notes-btn.primary {
  background: #176b5d;
  color: #fff;
}

.notes-btn.ghost {
  background: #eef4f1;
  color: #176b5d;
}

.notes-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.notes-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 12px;
}

.note-card {
  text-align: left;
  border: 1px solid #e2ebe6;
  border-radius: 12px;
  padding: 14px;
  background: #fafcfb;
  cursor: pointer;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.note-card:focus-visible {
  outline: 2px solid #176b5d;
  outline-offset: 2px;
}

.note-card.is-open {
  border-color: #176b5d;
  background: #f0f9f6;
  box-shadow: 0 6px 16px rgba(23, 107, 93, 0.12);
}

.note-card.is-deleting {
  opacity: 0.65;
  pointer-events: none;
}

.note-card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
}

.note-card-head h3 {
  margin: 0;
  flex: 1;
  min-width: 0;
}

.note-card-delete {
  flex-shrink: 0;
  border: 1px solid #e8c4c4;
  border-radius: 8px;
  padding: 4px 10px;
  font: inherit;
  font-size: 11px;
  font-weight: 700;
  color: #a33;
  background: #fff5f5;
  cursor: pointer;
}

.note-card-delete:hover:not(:disabled) {
  background: #ffe8e8;
  border-color: #d99;
}

.note-card-delete:disabled {
  opacity: 0.7;
  cursor: wait;
}

.note-card:hover {
  border-color: #9ec5b8;
  box-shadow: 0 6px 16px rgba(23, 107, 93, 0.1);
}

.note-card.active {
  border-color: #176b5d;
  background: #f0f9f6;
}

.note-card h3 {
  font-size: 15px;
  line-height: 1.35;
}

.note-card p {
  margin: 0 0 8px;
  font-size: 13px;
  color: #5c6f66;
  line-height: 1.5;
}

.note-card p:last-of-type {
  margin-bottom: 0;
}

.note-preview {
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.note-commentary,
.note-summary,
.note-value,
.note-why {
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.note-value {
  color: #263b34;
  font-weight: 650;
}

.note-key-points {
  margin: 8px 0 0;
  padding-left: 18px;
  font-size: 12px;
  line-height: 1.55;
  color: #52675f;
}

.note-label {
  display: inline-block;
  margin-right: 6px;
  padding: 1px 6px;
  border-radius: 4px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: #176b5d;
  background: #e8f4f0;
  vertical-align: baseline;
}

.note-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
}

.note-tag {
  display: inline-block;
  padding: 3px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  color: #2d5a50;
  background: #e8f4f0;
  border: 1px solid #c5ddd4;
}

.note-card-meta {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  margin-top: 10px;
  font-size: 11px;
  color: #7a8b84;
}

.note-status {
  font-weight: 700;
  text-transform: uppercase;
}

.notes-empty {
  padding: 24px;
  text-align: center;
  color: #7a8b84;
  font-size: 14px;
}

.runtime-log-panel {
  margin-top: 12px;
  padding: 10px 12px;
  border: 1px solid #d4e5de;
  border-radius: 10px;
  background: #f4faf7;
  max-height: 220px;
  overflow: auto;
}

.runtime-log-head {
  font-size: 12px;
  font-weight: 700;
  color: #3d5249;
  margin-bottom: 8px;
}

.runtime-log-list {
  margin: 0;
  padding: 0;
  list-style: none;
}

.runtime-log-item {
  display: grid;
  grid-template-columns: 72px 1fr;
  gap: 8px;
  padding: 4px 0;
  font-size: 12px;
  line-height: 1.45;
  border-bottom: 1px dashed #dbe8e2;
}

.runtime-log-item:last-child {
  border-bottom: 0;
}

.runtime-log-time {
  color: #7a8b84;
  font-variant-numeric: tabular-nums;
}

.runtime-log-msg {
  color: #2f463c;
  word-break: break-word;
}

.runtime-log-warn .runtime-log-msg {
  color: #9a6b00;
}

.runtime-log-error .runtime-log-msg {
  color: #a33;
}

.notes-hint {
  margin-top: 10px;
  font-size: 12px;
  color: #7a8b84;
}

.notes-status-bar {
  font-size: 13px;
  font-weight: 600;
  color: #176b5d;
}

body.note-detail-open {
  overflow: hidden;
}

.note-detail-modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
  box-sizing: border-box;
}

.note-detail-modal.is-open {
  display: flex;
}

.note-detail-modal[hidden] {
  display: none !important;
}

.note-detail-backdrop {
  position: absolute;
  inset: 0;
  z-index: 0;
  background: rgba(15, 35, 30, 0.45);
}

.note-detail-dialog {
  position: relative;
  z-index: 1;
  width: min(640px, 100%);
  max-height: min(88vh, 900px);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  margin: auto;
  background: #fff;
  border-radius: 16px;
  box-shadow: 0 24px 64px rgba(15, 35, 30, 0.22);
  overflow: hidden;
}

.note-detail-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 18px 20px 14px;
  border-bottom: 1px solid #e2ebe6;
  background: #fafcfb;
}

.note-detail-head h2 {
  margin: 0;
  font-size: 18px;
  line-height: 1.4;
  color: #1a2e28;
}

.note-detail-close {
  flex-shrink: 0;
  width: 36px;
  height: 36px;
  border: 0;
  border-radius: 10px;
  background: #eef4f1;
  color: #176b5d;
  font-size: 24px;
  line-height: 1;
  cursor: pointer;
}

.note-detail-close:hover {
  background: #e0ece8;
}

.note-detail-body {
  flex: 1;
  min-height: 0;
  padding: 16px 20px 20px;
  overflow: auto;
}

.note-detail-meta-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 10px 16px;
  margin-bottom: 18px;
  padding: 12px 14px;
  border-radius: 12px;
  background: #f4faf7;
  border: 1px solid #d9e8e2;
  font-size: 13px;
  color: #3d5249;
}

.note-detail-label {
  display: block;
  margin-bottom: 2px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: #7a8b84;
}

.note-detail-section {
  margin-bottom: 18px;
}

.note-detail-section:last-child {
  margin-bottom: 0;
}

.note-detail-section h3 {
  margin: 0 0 8px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: #176b5d;
}

.note-detail-section p {
  margin: 0;
  font-size: 14px;
  line-height: 1.65;
  color: #3d5249;
}

.note-detail-lead {
  font-size: 15px !important;
  font-weight: 700;
  color: #1f352e !important;
}

.note-detail-pre {
  white-space: pre-wrap;
  word-break: break-word;
}

.note-detail-raw {
  margin-top: 10px;
  max-height: 220px;
  overflow: auto;
  padding: 10px 12px;
  border-radius: 10px;
  background: #f8faf9;
  border: 1px solid #e2ebe6;
  font-size: 13px;
}

.note-detail-collapse summary {
  cursor: pointer;
  font-size: 13px;
  font-weight: 700;
  color: #176b5d;
}

.note-detail-link {
  color: #176b5d;
  word-break: break-all;
}

.note-detail-list {
  margin: 0;
  padding-left: 18px;
  font-size: 14px;
  line-height: 1.6;
  color: #3d5249;
}

.note-detail-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.note-detail-keyword {
  display: inline-block;
  padding: 3px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  color: #4a5c55;
  background: #eef4f1;
  border: 1px solid #d4e0db;
}

.note-detail-empty {
  margin: 0;
  padding: 16px;
  text-align: center;
  font-size: 14px;
  color: #7a8b84;
  background: #f8faf9;
  border-radius: 10px;
}
