/* ------------------------------------------------------------------
   trip-notes.css — 旅途随笔（顶栏右上角入口 + 全屏记录面板）
   颜色一律复用 styles.css :root 里的设计令牌，不引入新的视觉语言。

   ⚠️ 类名以 trip-notes.js 实际生成的 DOM 为准：
      mountEntry()  → .topbar .primary-navigation__notes(.notes-badge)
      openPanel()   → .notes-overlay > .notes-sheet
                      .notes-head(.notes-head__title/.notes-head__actions)
                      .notes-filters(.notes-field/.notes-filter-chip)
                      .notes-composer(#notes-text/#notes-attachments/.notes-composer__bar)
                      .notes-stream > .notes-day > .note-card
                      #notes-lightbox
   ------------------------------------------------------------------ */

/* ---------------- 顶栏入口 ---------------- */
.topbar .primary-navigation__notes {
  position: relative;
  min-width: 44px;
  min-height: 44px;
  padding: 0 11px 0 7px;   /* 右侧多留一点给徽标，避免压住「随笔」两个字 */
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 3px;
  border: 0;
  color: var(--muted);
  background: transparent;
  font-size: 12px;
  font-weight: 680;
  cursor: pointer;
}
.topbar .primary-navigation__notes:hover,
.topbar .primary-navigation__notes[aria-expanded="true"] {
  color: var(--ink);
}
.primary-navigation__notes .notes-badge {
  position: absolute;
  top: 2px;
  right: 1px;
  min-width: 15px;
  height: 15px;
  padding: 0 4px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  color: #ffffff;
  background: var(--terracotta);
  font-size: 9px;
  font-weight: 780;
  font-variant-numeric: tabular-nums;
  line-height: 1;
}
.primary-navigation__notes .notes-badge[hidden] {
  display: none;
}
/* 首次进入时轻晃两下，提示这里有个新入口 */
.primary-navigation__notes.is-new {
  animation: notes-nudge 0.5s ease 1.4s 2;
}
@keyframes notes-nudge {
  0%, 100% { transform: translateX(0); }
  30% { transform: translateX(-3px); }
  65% { transform: translateX(3px); }
}

/* ---------------- 无顶栏时的右上角浮标（离线单文件版） ----------------
   离线版没有 .topbar，用 var(--paper, var(--bg)) 这种双写兜住两套主题变量。 */
.notes-fab {
  position: fixed;
  top: calc(14px + var(--safe-top, env(safe-area-inset-top, 0px)));
  right: 14px;
  z-index: 55;
  min-height: 40px;
  padding: 0 14px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1px solid var(--line, var(--border, #e6e6e6));
  border-radius: 999px;
  color: var(--ink, var(--text, #2a2a2a));
  background: var(--surface, var(--bg-card, #ffffff));
  box-shadow: var(--shadow, 0 4px 16px rgba(0, 0, 0, 0.06));
  font-size: 12.5px;
  font-weight: 720;
  cursor: pointer;
}
.notes-fab .notes-badge {
  min-width: 15px;
  height: 15px;
  padding: 0 4px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  color: #ffffff;
  background: var(--terracotta, var(--accent, #b65c3a));
  font-size: 9px;
  font-weight: 780;
  line-height: 1;
}
.notes-fab .notes-badge[hidden] {
  display: none;
}

/* ---------------- 面板外壳 ---------------- */
.notes-overlay {
  position: fixed;
  inset: 0;
  z-index: 120;   /* 要压过离线单文件版的 .theme-btn（z-index:100） */
  display: flex;
  align-items: flex-end;
  justify-content: center;
  background: rgba(19, 38, 47, 0.42);
  -webkit-backdrop-filter: blur(3px);
  backdrop-filter: blur(3px);
}
.notes-overlay[hidden] {
  display: none;
}
.notes-sheet {
  width: min(100%, 760px);
  height: min(94vh, 100dvh);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  background: var(--paper);
  box-shadow: 0 -20px 60px rgba(19, 38, 47, 0.28);
  animation: notes-sheet-in 0.22s ease-out;
}
@keyframes notes-sheet-in {
  from { opacity: 0.4; transform: translateY(26px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ---------------- 头部 ---------------- */
.notes-head {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: calc(14px + var(--safe-top)) 16px 12px;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
}
.notes-head__title {
  min-width: 0;
}
.notes-head__kicker {
  display: block;
  color: var(--lake);
  font: 750 9.5px/1 ui-monospace, SFMono-Regular, Menlo, monospace;
  letter-spacing: 0.14em;
}
.notes-head h2 {
  margin: 4px 0 0;
  font-size: 19px;
  letter-spacing: -0.03em;
}
.notes-head__actions {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 6px;
}
.notes-icon-btn {
  min-width: 34px;
  min-height: 34px;
  padding: 0 9px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  background: var(--surface);
  font-size: 13px;
  line-height: 1;
  cursor: pointer;
}
.notes-icon-btn:active {
  color: #ffffff;
  background: var(--ink);
}
.notes-icon-btn.is-busy {
  animation: notes-spin 0.9s linear infinite;
}
@keyframes notes-spin {
  to { transform: rotate(360deg); }
}
.notes-status {
  color: var(--muted);
  font-size: 10.5px;
  font-weight: 620;
  white-space: nowrap;
}
.notes-status[data-tone="warn"] { color: var(--warning); }
.notes-status[data-tone="ok"] { color: var(--forest); }

/* ---------------- 筛选行 ---------------- */
.notes-filters {
  flex: 0 0 auto;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
}
.notes-field {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 32px;
  padding: 0 8px 0 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--paper);
}
.notes-field > span {
  color: var(--muted);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.02em;
}
.notes-field select {
  max-width: 42vw;
  border: 0;
  color: var(--ink);
  background: transparent;
  font: inherit;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
}
.notes-field select:focus-visible {
  outline: 2px solid var(--lake);
  outline-offset: 2px;
  border-radius: 6px;
}
.notes-rename {
  min-width: 26px;
  min-height: 26px;
  margin-right: -2px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  color: var(--muted);
  background: transparent;
  font-size: 11px;
  cursor: pointer;
}
.notes-filter-chip {
  min-height: 32px;
  margin-left: auto;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  background: var(--paper);
  font-size: 11px;
  font-weight: 720;
  cursor: pointer;
}
.notes-filter-chip[data-scope="mine"] {
  border-color: var(--lake);
  color: #ffffff;
  background: var(--lake);
}

/* ---------------- 记录区 ---------------- */
.notes-composer {
  flex: 0 0 auto;
  padding: 12px 16px 13px;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
}
.notes-composer textarea {
  display: block;
  width: 100%;
  min-height: 62px;
  max-height: 168px;
  padding: 11px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  color: var(--ink);
  background: var(--paper);
  font: inherit;
  font-size: 13.5px;
  line-height: 1.65;
  resize: vertical;
}
.notes-composer textarea:focus {
  outline: none;
  border-color: var(--lake);
  box-shadow: 0 0 0 3px var(--lake-soft);
}
.notes-attachments {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 9px;
}
.notes-attachments:empty {
  display: none;
}
.notes-chip {
  position: relative;
  width: 68px;
  height: 68px;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: var(--paper);
  overflow: hidden;
}
.notes-chip img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.notes-chip.is-audio {
  width: auto;
  height: 42px;
  padding: 0 30px 0 12px;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  color: var(--lake);
  font-size: 11.5px;
  font-weight: 720;
}
.notes-chip__remove {
  position: absolute;
  top: 3px;
  right: 3px;
  width: 20px;
  height: 20px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  color: #ffffff;
  background: rgba(19, 38, 47, 0.72);
  font-size: 12px;
  line-height: 1;
  cursor: pointer;
}
.notes-chip.is-audio .notes-chip__remove {
  top: 50%;
  transform: translateY(-50%);
}
.notes-chip.is-busy::after {
  content: "";
  position: absolute;
  inset: 0;
  background: rgba(243, 246, 242, 0.7);
}
.notes-composer__bar {
  display: flex;
  align-items: center;
  gap: 7px;
  margin-top: 10px;
}
.notes-tool {
  min-height: 36px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--ink);
  background: var(--paper);
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
}
.notes-tool:active {
  color: #ffffff;
  background: var(--ink);
}
.notes-tool[disabled] {
  opacity: 0.45;
  cursor: default;
}
.notes-tool.is-recording {
  border-color: var(--warning);
  color: #ffffff;
  background: var(--warning);
  animation: notes-rec 1.1s ease-in-out infinite;
}
@keyframes notes-rec {
  50% { opacity: 0.62; }
}
.notes-composer .notes-time {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}
.notes-composer .notes-time > span {
  color: var(--muted);
  font-size: 10px;
  font-weight: 700;
}
.notes-composer .notes-time select {
  min-height: 36px;
  padding: 0 8px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--ink);
  background: var(--paper);
  font: inherit;
  font-size: 11.5px;
  font-weight: 700;
}
.notes-hint {
  min-width: 0;
  margin-left: auto;
  color: var(--muted);
  font-size: 10.5px;
  line-height: 1.4;
  text-align: right;
}
.notes-hint[data-tone="warn"] { color: var(--warning); }
.notes-save {
  flex: 0 0 auto;
  min-height: 38px;
  padding: 0 18px;
  border: 0;
  border-radius: 999px;
  color: #ffffff;
  background: var(--lake);
  font-size: 13px;
  font-weight: 740;
  cursor: pointer;
  box-shadow: 0 8px 20px rgba(40, 123, 144, 0.26);
}
.notes-save[disabled] {
  opacity: 0.42;
  box-shadow: none;
  cursor: default;
}

/* ---------------- 时间流 ---------------- */
.notes-stream {
  flex: 1 1 auto;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 14px 16px calc(24px + var(--safe-bottom));
}
.notes-day + .notes-day {
  margin-top: 22px;
}
.notes-day__head {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin-bottom: 10px;
  padding-bottom: 7px;
  border-bottom: 1px solid var(--line);
}
.notes-day__head strong {
  font-size: 13px;
  letter-spacing: -0.01em;
}
.notes-day__head span {
  margin-left: auto;
  color: var(--muted);
  font: 700 10px/1 ui-monospace, SFMono-Regular, Menlo, monospace;
}
.notes-day__list {
  display: grid;
  gap: 10px;
}
.note-card {
  padding: 13px 14px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--surface);
  box-shadow: var(--shadow);
}
.note-card[data-mine="true"] {
  border-color: #c9dde2;
}
.note-card.is-pending {
  border-style: dashed;
}
.note-card__head {
  display: flex;
  align-items: center;
  gap: 9px;
}
.note-avatar {
  flex: 0 0 auto;
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  color: #ffffff;
  background: var(--lake);
  font-size: 12.5px;
  font-weight: 760;
}
.note-card[data-author-index="1"] .note-avatar { background: #516b55; }
.note-card[data-author-index="2"] .note-avatar { background: #b65c3a; }
.note-card[data-author-index="3"] .note-avatar { background: #7a6ba8; }
.note-meta {
  min-width: 0;
}
.note-meta strong {
  display: block;
  font-size: 12.5px;
  letter-spacing: -0.01em;
}
.note-time {
  color: var(--muted);
  font: 640 10px/1.3 ui-monospace, SFMono-Regular, Menlo, monospace;
  font-variant-numeric: tabular-nums;
}
.note-state {
  margin-left: auto;
  color: var(--muted);
  font-size: 9.5px;
  font-weight: 700;
  white-space: nowrap;
}
.note-delete {
  min-width: 30px;
  min-height: 30px;
  padding: 0 8px;
  border: 0;
  border-radius: 999px;
  color: var(--muted);
  background: transparent;
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
}
.note-delete:hover {
  color: var(--warning);
}
.note-text {
  margin: 10px 0 0;
  color: var(--ink);
  font-size: 13.5px;
  line-height: 1.75;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.note-media {
  display: grid;
  gap: 8px;
  margin-top: 11px;
}
.note-photos {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(96px, 1fr));
  gap: 6px;
}
.note-photo {
  position: relative;
  aspect-ratio: 1 / 1;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: var(--paper);
  overflow: hidden;
  cursor: zoom-in;
}
.note-photo img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.note-photo.is-loading::after {
  content: "载入中…";
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: var(--muted);
  background: var(--paper);
  font-size: 10px;
}
/* 有缩略图顶着：轻微虚化表示大图还在路上，不挡点击 */
.note-photo.is-thumbing img {
  filter: blur(2px);
}
.note-audio {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 8px 11px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--paper);
}
.note-audio__play {
  flex: 0 0 auto;
  width: 30px;
  height: 30px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  color: #ffffff;
  background: var(--lake);
  font-size: 12px;
  line-height: 1;
  cursor: pointer;
}
.note-audio__track {
  flex: 1 1 auto;
  height: 4px;
  border-radius: 999px;
  background: var(--line);
  overflow: hidden;
}
.note-audio__fill {
  display: block;
  width: 0;
  height: 100%;
  border-radius: 999px;
  background: var(--lake);
  transition: width 0.2s linear;
}
.note-audio__time {
  flex: 0 0 auto;
  color: var(--muted);
  font: 650 10.5px/1 ui-monospace, SFMono-Regular, Menlo, monospace;
  font-variant-numeric: tabular-nums;
}
.note-audio.is-loading {
  opacity: 0.6;
}

/* ---------------- 空状态 ---------------- */
.notes-empty {
  margin: 34px 0 0;
  color: var(--muted);
  font-size: 12.5px;
  line-height: 1.8;
  text-align: center;
}
.notes-empty[hidden] {
  display: none;
}

/* ---------------- 大图 ---------------- */
.notes-lightbox {
  position: fixed;
  inset: 0;
  z-index: 130;
  display: grid;
  place-items: center;
  padding: 22px;
  border: 0;
  background: rgba(12, 24, 30, 0.88);
}
.notes-lightbox[hidden] {
  display: none;
}
.notes-lightbox img {
  max-width: 100%;
  max-height: 82vh;
  border-radius: 12px;
}
.notes-lightbox p {
  margin: 14px 0 0;
  color: rgba(255, 255, 255, 0.72);
  font-size: 11.5px;
  text-align: center;
}
.notes-lightbox__close {
  position: fixed;
  top: calc(14px + var(--safe-top));
  right: 14px;
  width: 40px;
  height: 40px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  color: #ffffff;
  background: rgba(255, 255, 255, 0.16);
  font-size: 17px;
  line-height: 1;
  cursor: pointer;
}

/* ---------------- 桌面端 ---------------- */
@media (min-width: 760px) {
  .notes-overlay {
    align-items: center;
  }
  .notes-sheet {
    height: min(90vh, 860px);
    border-radius: var(--radius-lg);
  }
  .note-photos {
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  }
}

@media (prefers-reduced-motion: reduce) {
  .notes-sheet,
  .primary-navigation__notes.is-new,
  .notes-tool.is-recording,
  .notes-icon-btn.is-busy {
    animation: none;
  }
}
