:root {
  --notes-accent: #195f8b;
  --notes-accent-dark: #124766;
  --notes-soft: #eaf4f9;
  --notes-success: #176b4d;
  --notes-warning: #9a5a16;
  --notes-danger: #a03d35;
}

body.notes-drawer-open,
body.notes-lightbox-open { overflow: hidden; }

.notes-trigger {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  width: 100%;
  min-height: 44px;
  margin-top: 12px;
  padding: 10px 13px;
  border: 1px solid #8fb3c7;
  border-radius: 12px;
  background: linear-gradient(180deg, #f7fcff, #e8f4fa);
  color: var(--notes-accent-dark);
  cursor: pointer;
  font-weight: 800;
  box-shadow: 0 5px 14px rgba(29, 91, 126, .1);
}

.notes-entry {
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid #dde5eb;
}

.notes-entry-copy {
  display: grid;
  gap: 4px;
}

.notes-entry-kicker {
  color: var(--notes-accent);
  font-size: 11px;
  font-weight: 900;
  letter-spacing: .08em;
}

.notes-entry h3 {
  margin: 0;
  font-size: 16px;
}

.notes-entry p {
  margin: 0;
  color: #607487;
  font-size: 13px;
  line-height: 1.55;
}

.notes-trigger[hidden],
.notes-inline-host[hidden] {
  display: none;
}

.notes-entry.is-inline .notes-entry-copy p {
  color: #3f6278;
}

.notes-inline-host {
  display: block;
  margin-top: 14px;
}

.notes-inline-host .notes-card {
  padding: 14px;
  border-radius: 14px;
  background: #fbfdfe;
  box-shadow: none;
}

.notes-inline-host .notes-card + .notes-card { margin-top: 12px; }
.notes-inline-host .notes-field textarea { min-height: 180px; }
.notes-inline-host .notes-editor-head { margin-bottom: 12px; }

.notes-trigger:hover,
.notes-trigger:focus-visible {
  border-color: var(--notes-accent);
  background: #fff;
  outline: 3px solid rgba(25, 95, 139, .15);
}

.notes-trigger small {
  padding: 3px 7px;
  border-radius: 999px;
  background: #dcebf3;
  color: #4b6677;
  font-size: 11px;
  font-weight: 700;
}

.notes-trigger.is-unlocked small {
  background: #dff2e8;
  color: var(--notes-success);
}

.notes-trigger.is-offline small {
  background: #f6e9d7;
  color: var(--notes-warning);
}

.notes-overlay {
  position: fixed;
  z-index: 5000;
  inset: 0;
  display: flex;
  justify-content: flex-end;
  background: rgba(9, 25, 39, .47);
  backdrop-filter: blur(3px);
}

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

.notes-drawer {
  width: min(560px, 100%);
  height: 100%;
  overflow-y: auto;
  background: #f6f9fb;
  color: #173047;
  box-shadow: -18px 0 50px rgba(8, 28, 43, .22);
  animation: notes-slide-in .2s ease-out;
}

@keyframes notes-slide-in {
  from { transform: translateX(24px); opacity: .7; }
  to { transform: translateX(0); opacity: 1; }
}

.notes-drawer-header {
  position: sticky;
  z-index: 2;
  top: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 20px;
  border-bottom: 1px solid #cfdae2;
  background: rgba(255, 255, 255, .96);
  backdrop-filter: blur(12px);
}

.notes-drawer-header p {
  margin: 0 0 3px;
  color: #678093;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: .08em;
  text-transform: uppercase;
}

.notes-drawer-header h2 {
  margin: 0;
  font-size: 22px;
}

.notes-icon-button {
  flex: 0 0 auto;
  width: 40px;
  height: 40px;
  border: 1px solid #c3d0d9;
  border-radius: 50%;
  background: #fff;
  color: #38566d;
  cursor: pointer;
  font-size: 24px;
  line-height: 1;
}

.notes-icon-button:hover,
.notes-icon-button:focus-visible {
  border-color: var(--notes-accent);
  color: var(--notes-accent);
  outline: 3px solid rgba(25, 95, 139, .13);
}

.notes-drawer-body { padding: 20px; }

.notes-view[hidden],
.notes-read-view[hidden],
.notes-edit-view[hidden],
.notes-photo-card[hidden] { display: none; }

.notes-card {
  padding: 18px;
  border: 1px solid #d1dce4;
  border-radius: 17px;
  background: #fff;
  box-shadow: 0 8px 22px rgba(31, 61, 82, .07);
}

.notes-card + .notes-card { margin-top: 14px; }
.notes-card h3 { margin: 0 0 8px; font-size: 20px; }
.notes-card p { margin: 0; color: #607487; line-height: 1.65; }

.notes-setup-warning {
  margin: 14px 0 0 !important;
  padding: 11px 12px;
  border-left: 4px solid #d18b36;
  border-radius: 8px;
  background: #fff6e8;
  color: #80511b !important;
  font-size: 13px;
}

.notes-form {
  display: grid;
  gap: 13px;
  margin-top: 18px;
}

.notes-field {
  display: grid;
  gap: 6px;
  color: #496277;
  font-size: 13px;
  font-weight: 800;
}

.notes-field input,
.notes-field textarea {
  width: 100%;
  min-height: 44px;
  padding: 10px 12px;
  border: 1px solid #b7c7d3;
  border-radius: 10px;
  background: #fff;
  color: #173047;
  font: inherit;
}


.notes-read-content {
  margin: 0;
  padding: 12px 13px;
  border: 1px solid #efc7c3;
  border-left: 4px solid #c6534c;
  border-radius: 8px;
  background: #fff1f0;
  color: #713c38;
  line-height: 1.68;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}

.notes-read-content.is-empty {
  border-color: #cbd6dd;
  border-left-color: #b9c7d0;
  background: #f4f7f9;
  color: #718697;
}

.notes-draft-notice {
  margin: 9px 0 0;
  padding: 8px 10px;
  border-radius: 8px;
  background: #fff0dc;
  color: var(--notes-warning);
  font-size: 12px;
  line-height: 1.5;
}

.notes-draft-notice[hidden] { display: none; }
.notes-read-actions { margin-top: 12px; }

#trip-notes-editor-view:not(.is-editing) .notes-edit-only,
#trip-notes-editor-view:not(.is-editing) .notes-image-delete {
  display: none;
}

.notes-photo-count {
  color: #718697;
  font-size: 12px;
  font-weight: 800;
}

.notes-inline-host #trip-notes-editor-view:not(.is-editing) .notes-editor-head {
  align-items: center;
  margin-bottom: 10px;
}

.notes-inline-host #trip-notes-editor-view:not(.is-editing) .notes-day-title,
.notes-inline-host #trip-notes-editor-view:not(.is-editing) .notes-day-route {
  display: none;
}
.notes-field textarea {
  min-height: 230px;
  resize: vertical;
  line-height: 1.7;
}

.notes-field input:focus,
.notes-field textarea:focus {
  border-color: var(--notes-accent);
  outline: 3px solid rgba(25, 95, 139, .14);
}

.notes-button-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 9px;
}

.notes-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  padding: 8px 14px;
  border: 1px solid transparent;
  border-radius: 10px;
  cursor: pointer;
  font: inherit;
  font-weight: 800;
}

.notes-button:disabled { cursor: wait; opacity: .62; }
.notes-button.primary { background: var(--notes-accent); color: #fff; }
.notes-button.primary:hover,
.notes-button.primary:focus-visible { background: var(--notes-accent-dark); outline: 3px solid rgba(25, 95, 139, .17); }
.notes-button.secondary { border-color: #b7c8d3; background: #fff; color: #34556d; }
.notes-button.secondary:hover,
.notes-button.secondary:focus-visible { border-color: var(--notes-accent); color: var(--notes-accent); outline: none; }
.notes-button.danger { border-color: #e2b3ae; background: #fff4f2; color: var(--notes-danger); }

.notes-connection-message {
  padding: 12px;
  border-radius: 10px;
  background: #fff2e6;
  color: #82501e;
  line-height: 1.6;
}

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

.notes-day-date {
  display: block;
  margin-bottom: 4px;
  color: var(--notes-accent);
  font-size: 13px;
  font-weight: 900;
}

.notes-day-title { margin: 0; font-size: 21px; }
.notes-day-route { margin: 7px 0 0; color: #697f90; font-size: 13px; line-height: 1.5; }

.notes-save-state {
  flex: 0 0 auto;
  padding: 5px 9px;
  border-radius: 999px;
  background: #e8eef2;
  color: #5c7282;
  font-size: 12px;
  font-weight: 800;
}

.notes-save-state.dirty { background: #fff0dc; color: var(--notes-warning); }
.notes-save-state.saved { background: #def1e7; color: var(--notes-success); }
.notes-save-state.error { background: #fee9e7; color: var(--notes-danger); }

.notes-editor-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-top: 8px;
  color: #718696;
  font-size: 12px;
}

.notes-inline-message { min-height: 20px; color: #5c7282; font-size: 13px; }
.notes-inline-message.error { color: var(--notes-danger); }
.notes-inline-message.success { color: var(--notes-success); }

.notes-gallery-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.notes-gallery-head h3 { margin: 0; }
.notes-upload-input { position: absolute; inline-size: 1px; block-size: 1px; opacity: 0; overflow: hidden; }
.notes-upload-label { white-space: nowrap; }

.notes-gallery {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.notes-gallery-empty {
  grid-column: 1 / -1;
  padding: 26px 14px;
  border: 1px dashed #bdcbd5;
  border-radius: 12px;
  background: #f8fbfc;
  color: #718697;
  text-align: center;
  line-height: 1.6;
}

.notes-image-card {
  overflow: hidden;
  border: 1px solid #cfdae2;
  border-radius: 12px;
  background: #f5f8fa;
}

.notes-image-preview {
  display: block;
  width: 100%;
  padding: 0;
  border: 0;
  aspect-ratio: 4 / 3;
  background: #e2e9ee;
  cursor: zoom-in;
}
.notes-image-preview:focus-visible { outline: 3px solid var(--notes-accent); outline-offset: -3px; }
.notes-image-card img { width: 100%; height: 100%; display: block; object-fit: cover; }
.notes-image-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px;
}
.notes-image-name { overflow: hidden; color: #536a7b; font-size: 11px; text-overflow: ellipsis; white-space: nowrap; }
.notes-image-delete {
  flex: 0 0 auto;
  border: 0;
  background: transparent;
  color: var(--notes-danger);
  cursor: pointer;
  font-size: 12px;
  font-weight: 800;
}

.notes-lightbox {
  position: fixed;
  inset: 0;
  width: 100%;
  max-width: none;
  height: 100%;
  height: 100dvh;
  max-height: none;
  margin: 0;
  padding: 24px;
  border: 0;
  background: transparent;
  color: #fff;
}
.notes-lightbox::backdrop { background: rgba(7, 16, 25, .9); }
.notes-lightbox[open] { display: flex; align-items: center; justify-content: center; }
.notes-lightbox-panel {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  gap: 12px;
  width: min(1200px, 100%);
  height: 100%;
  min-height: 0;
}
.notes-lightbox-header,
.notes-lightbox-footer { display: flex; align-items: center; gap: 16px; }
.notes-lightbox-header { justify-content: space-between; }
.notes-lightbox-header h2 { margin: 0; font-size: 16px; overflow-wrap: anywhere; min-width: 0; }
.notes-lightbox-footer { justify-content: center; }
.notes-lightbox-footer .notes-button:disabled { cursor: default; }
.notes-lightbox-footer [hidden] { display: none; }
.notes-lightbox-stage { display: grid; place-items: center; min-width: 0; min-height: 0; }
.notes-lightbox-stage img { display: block; width: 100%; height: 100%; min-height: 0; object-fit: contain; }
.notes-lightbox-stage img[hidden],
.notes-lightbox-stage p[hidden] { display: none; }
.notes-lightbox-stage p { margin: 0; text-align: center; line-height: 1.7; }

.notes-settings { margin-top: 14px; }
.notes-settings summary { cursor: pointer; color: #4f687a; font-size: 13px; font-weight: 800; }
.notes-settings[open] summary { margin-bottom: 12px; }

.day-button.has-user-note { border-color: #78a9c2; }
.day-button.has-user-note small:last-child::after {
  content: " · 有备注";
  color: #1a7085;
  font-weight: 900;
}
.day-button.active.has-user-note small:last-child::after { color: #d9f5ff; }

.notes-toast {
  position: fixed;
  z-index: 5100;
  right: 22px;
  bottom: 22px;
  max-width: min(390px, calc(100% - 30px));
  padding: 12px 15px;
  border-radius: 12px;
  background: #173b53;
  color: #fff;
  box-shadow: 0 12px 34px rgba(10, 33, 48, .3);
  font-size: 14px;
}
.notes-toast.error { background: #8b332d; }
.notes-toast[hidden] { display: none; }

@media (max-width: 680px) {
  .notes-lightbox { padding: 12px; }
  .notes-lightbox-header h2 { font-size: 14px; }
  .notes-trigger { width: 100%; margin-left: 0; }
  .notes-drawer { width: 100%; }
  .notes-drawer-header, .notes-drawer-body { padding-left: 15px; padding-right: 15px; }
  .notes-gallery { grid-template-columns: 1fr; }
  .notes-editor-head { display: grid; }
  .notes-save-state { justify-self: start; }
}

@media (prefers-reduced-motion: reduce) {
  .notes-drawer { animation: none; }
}
