/* Taggy demo UI — overlay only; never changes page layout. */
:root {
  --tg-bg: #fbfaf7;
  --tg-paper: #ffffff;
  --tg-ink: #1f2937;
  --tg-muted: #6b7280;
  --tg-line: #e5e7eb;
  --tg-accent: #1f6feb;
  --tg-accent-soft: #e8f0fe;
  --tg-danger: #dc2626;
  --tg-shadow: 0 18px 50px rgba(17, 24, 39, .18);
  --tg-radius: 14px;
}

#taggy-root, #taggy-layer, .tg-composer, .tg-thread, .tg-toast, .tg-selection-bar {
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  -webkit-font-smoothing: antialiased;
}

#taggy-root {
  position: fixed;
  inset: 0;
  z-index: 100;
  pointer-events: none;
  color: var(--tg-ink);
}
#taggy-root button, #taggy-root input, #taggy-root select, #taggy-root textarea { font: inherit; }
#taggy-root [data-taggy-ui], #taggy-root .tg-clickable { pointer-events: auto; }

.tg-pill {
  position: fixed;
  left: 16px;
  bottom: 16px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 11px;
  background: rgba(255, 255, 255, .93);
  border: 1px solid rgba(17, 24, 39, .12);
  border-radius: 999px;
  box-shadow: 0 8px 24px rgba(17, 24, 39, .10);
  font-size: 12px;
  color: var(--tg-muted);
  backdrop-filter: blur(12px);
}
.tg-pill strong { color: var(--tg-ink); font-weight: 650; letter-spacing: .01em; }
.tg-dot { width: 7px; height: 7px; border-radius: 50%; background: #16a34a; box-shadow: 0 0 0 3px rgba(22, 163, 74, .13); }
.tg-dot.is-warn { background: #d97706; box-shadow: 0 0 0 3px rgba(217, 119, 6, .13); }
.tg-dot.is-memory { background: #6b7280; box-shadow: 0 0 0 3px rgba(107, 114, 128, .13); }

.tg-dock {
  position: fixed;
  right: 16px;
  top: 14px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 6px;
  background: rgba(255, 255, 255, .94);
  border: 1px solid rgba(17, 24, 39, .12);
  border-radius: 16px;
  box-shadow: 0 12px 34px rgba(17, 24, 39, .12);
  backdrop-filter: blur(14px);
}
.tg-dock .tg-dock-sep { height: 1px; background: var(--tg-line); margin: 3px 4px; }
.tg-tool {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 11px;
  background: transparent;
  color: #374151;
  cursor: pointer;
  position: relative;
}
.tg-tool:hover { background: #f3f4f6; }
.tg-tool.is-active { background: var(--tg-accent-soft); color: var(--tg-accent); }
.tg-tool svg { width: 19px; height: 19px; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.tg-tool[data-tip]::after {
  content: attr(data-tip);
  position: absolute;
  right: calc(100% + 10px);
  top: 50%;
  transform: translateY(-50%);
  white-space: nowrap;
  background: #111827;
  color: #fff;
  font-size: 11px;
  padding: 5px 8px;
  border-radius: 7px;
  opacity: 0;
  pointer-events: none;
  transition: opacity .12s;
}
.tg-tool:hover::after { opacity: 1; }

.tg-style-panel {
  position: fixed;
  right: 76px;
  top: 14px;
  width: 246px;
  display: none;
  flex-direction: column;
  gap: 8px;
  padding: 11px;
  background: rgba(255, 255, 255, .97);
  border: 1px solid rgba(17, 24, 39, .12);
  border-radius: 14px;
  box-shadow: 0 14px 36px rgba(17, 24, 39, .16);
  backdrop-filter: blur(14px);
}
.tg-style-panel.is-open { display: flex; }
.tg-style-head { display: flex; align-items: center; justify-content: space-between; }
.tg-style-head strong { font-size: 12px; letter-spacing: .01em; }
.tg-style-close { border: 0; background: transparent; color: var(--tg-muted); font-size: 16px; line-height: 1; cursor: pointer; padding: 0 2px; }
.tg-style-close:hover { color: var(--tg-ink); }
.tg-style-hint { font-size: 10.5px; color: var(--tg-muted); margin-top: -4px; }
.tg-style-label { font-size: 10px; font-weight: 650; letter-spacing: .06em; color: #9ca3af; }
.tg-swatches { display: grid; grid-template-columns: repeat(6, 1fr); gap: 8px; padding: 1px 0; }
.tg-swatch { width: 28px; height: 28px; border-radius: 50%; border: 2px solid #fff; box-shadow: 0 0 0 1px rgba(17, 24, 39, .16); cursor: pointer; padding: 0; justify-self: center; }
.tg-swatch.is-active { box-shadow: 0 0 0 2px var(--tg-accent), 0 0 0 4px #fff; }
.tg-widths { display: flex; gap: 6px; }
.tg-width { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 5px; padding: 6px 3px; border: 1px solid var(--tg-line); border-radius: 9px; background: #fff; color: #4b5563; font-size: 10px; cursor: pointer; }
.tg-width:hover { background: #f9fafb; }
.tg-width.is-active { border-color: #bfdbfe; background: var(--tg-accent-soft); color: var(--tg-accent); }
.tg-width-line { display: block; width: 28px; background: currentColor; border-radius: 999px; }
.tg-width-custom { display: flex; align-items: center; gap: 7px; padding-top: 1px; }
.tg-width-range { flex: 1; min-width: 0; height: 18px; accent-color: var(--tg-accent); cursor: pointer; }
.tg-width-number { width: 52px; height: 26px; border: 1px solid var(--tg-line); border-radius: 7px; background: #fff; color: var(--tg-ink); font: 11px/1 -apple-system, BlinkMacSystemFont, sans-serif; text-align: center; padding: 0 4px; }
.tg-width-number:focus { outline: 2px solid var(--tg-accent-soft); border-color: var(--tg-accent); }
.tg-width-unit { font-size: 10px; color: var(--tg-muted); }
.tg-style-foot { font-size: 10px; line-height: 1.5; color: var(--tg-muted); border-top: 1px solid var(--tg-line); padding-top: 7px; }
.tg-badge-dot {
  position: absolute;
  top: 5px;
  right: 5px;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--tg-accent);
}

.tg-panel {
  position: fixed;
  right: 76px;
  top: 70px;
  bottom: 16px;
  width: min(380px, calc(100vw - 32px));
  display: none;
  flex-direction: column;
  background: var(--tg-bg);
  border: 1px solid rgba(17, 24, 39, .12);
  border-radius: 18px;
  box-shadow: var(--tg-shadow);
  overflow: hidden;
  pointer-events: auto;
}
.tg-panel.is-open { display: flex; }
.tg-panel-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 12px 0;
}
.tg-tabs { display: flex; gap: 2px; flex: 1; background: #eef0f3; padding: 3px; border-radius: 10px; }
.tg-tab {
  flex: 1;
  border: 0;
  background: transparent;
  color: #4b5563;
  border-radius: 8px;
  padding: 6px 8px;
  font-size: 12px;
  cursor: pointer;
}
.tg-tab.is-active { background: #fff; color: var(--tg-ink); box-shadow: 0 1px 3px rgba(17, 24, 39, .10); font-weight: 600; }
.tg-panel-body { padding: 12px; overflow: auto; flex: 1; }
.tg-panel-foot { padding: 10px 12px; border-top: 1px solid var(--tg-line); font-size: 11px; color: var(--tg-muted); display: flex; gap: 8px; align-items: center; justify-content: space-between; }
.tg-panel-foot button { border: 0; background: transparent; color: var(--tg-accent); cursor: pointer; font-size: 11px; }

.tg-section-title { display: flex; align-items: baseline; justify-content: space-between; margin: 2px 2px 10px; }
.tg-section-title strong { font-size: 13px; letter-spacing: .01em; }
.tg-muted { color: var(--tg-muted); font-size: 11px; }

.tg-filters { display: flex; gap: 4px; flex-wrap: wrap; margin-bottom: 10px; }
.tg-chip {
  border: 1px solid var(--tg-line);
  background: #fff;
  color: #4b5563;
  border-radius: 999px;
  padding: 4px 8px;
  font-size: 11px;
  cursor: pointer;
}
.tg-chip.is-active { border-color: #bfdbfe; background: var(--tg-accent-soft); color: var(--tg-accent); }

.tg-ann-card {
  background: #fff;
  border: 1px solid var(--tg-line);
  border-radius: 12px;
  padding: 10px 11px;
  margin-bottom: 8px;
  cursor: pointer;
  transition: border-color .12s, box-shadow .12s, transform .12s;
}
.tg-ann-card:hover { border-color: #bfdbfe; box-shadow: 0 6px 18px rgba(31, 111, 235, .08); transform: translateY(-1px); }
.tg-ann-card.is-resolved { opacity: .62; }
.tg-ann-card.is-orphan { border-left: 3px solid #b45309; }
.tg-ann-top { display: flex; align-items: center; gap: 7px; }
.tg-ann-no { width: 19px; height: 19px; border-radius: 50%; display: grid; place-items: center; color: #fff; font-size: 10px; flex: 0 0 auto; }
.tg-ann-author { font-size: 12px; font-weight: 650; color: #111827; }
.tg-ann-time { margin-left: auto; font-size: 10px; color: var(--tg-muted); }
.tg-ann-body { margin: 6px 0 4px; font-size: 12.5px; line-height: 1.55; color: #374151; white-space: pre-wrap; overflow-wrap: anywhere; }
.tg-ann-meta { display: flex; gap: 5px; flex-wrap: wrap; align-items: center; }
.tg-kind { font-size: 10px; color: #6b7280; background: #f3f4f6; border-radius: 5px; padding: 2px 5px; }
.tg-tag { font-size: 10px; color: #1d4ed8; background: #eff6ff; border-radius: 5px; padding: 2px 5px; }
.tg-orphan-label { font-size: 10px; color: #92400e; background: #fffbeb; border-radius: 5px; padding: 2px 5px; }
.tg-resolved-label { font-size: 10px; color: #047857; background: #ecfdf5; border-radius: 5px; padding: 2px 5px; }

.tg-empty { padding: 22px 10px; text-align: center; color: var(--tg-muted); font-size: 12px; line-height: 1.7; }
.tg-empty strong { display: block; color: #374151; margin-bottom: 2px; }

.tg-version {
  background: #fff;
  border: 1px solid var(--tg-line);
  border-radius: 12px;
  padding: 9px 10px;
  margin-bottom: 7px;
}
.tg-version.is-current { border-color: #bfdbfe; box-shadow: inset 3px 0 0 var(--tg-accent); }
.tg-version-top { display: flex; align-items: center; gap: 7px; }
.tg-version-no { font-size: 12px; font-weight: 700; }
.tg-version-hash { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 10px; color: var(--tg-muted); }
.tg-version-time { margin-left: auto; font-size: 10px; color: var(--tg-muted); }
.tg-version-actions { display: flex; gap: 5px; margin-top: 7px; }
.tg-btn {
  border: 1px solid var(--tg-line);
  background: #fff;
  color: #374151;
  border-radius: 8px;
  padding: 5px 8px;
  font-size: 11px;
  cursor: pointer;
}
.tg-btn:hover { background: #f9fafb; }
.tg-btn:disabled { opacity: .45; cursor: default; }
.tg-btn-primary { background: var(--tg-accent); border-color: var(--tg-accent); color: #fff; }
.tg-btn-primary:hover { background: #1a5fd0; }
.tg-btn-ghost { background: transparent; }
.tg-btn-danger { background: #fff; border-color: #fecaca; color: var(--tg-danger); }
.tg-btn-danger:hover { background: #fef2f2; }

.tg-log-row {
  display: grid;
  grid-template-columns: 48px 1fr;
  gap: 8px;
  padding: 7px 2px;
  border-bottom: 1px dashed var(--tg-line);
  font-size: 11px;
}
.tg-log-seq { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; color: var(--tg-muted); }
.tg-log-kind { color: #111827; font-weight: 600; }
.tg-log-meta { color: var(--tg-muted); margin-top: 2px; }
.tg-timeline { padding: 8px 2px 4px; }
.tg-timeline input[type="range"] { width: 100%; accent-color: var(--tg-accent); }
.tg-timeline-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; font-size: 11px; color: var(--tg-muted); }
.tg-timeline-row strong { color: var(--tg-ink); }

.tg-layer {
  position: absolute;
  left: 0;
  top: 0;
  width: 100%;
  min-height: 100%;
  z-index: 40;
  pointer-events: none;
  overflow: visible;
}
.tg-svg { position: absolute; left: 0; top: 0; width: 100%; height: 100%; overflow: visible; pointer-events: none; }
.tg-highlights, .tg-markers, .tg-ui { position: absolute; inset: 0; pointer-events: none; }
.tg-ui { position: fixed; inset: 0; }
.tg-highlight {
  position: absolute;
  border-radius: 2px;
  pointer-events: none;
  mix-blend-mode: multiply;
  transition: background .15s;
}
.tg-highlight.is-underline { background: transparent !important; border-bottom: 2px solid #eab308; }
.tg-highlight.is-strike { background: transparent !important; text-decoration: line-through; border-bottom: 1px solid #ef4444; }
.tg-geom-highlight { background: rgba(31, 111, 235, .10); border: 1px dashed rgba(31, 111, 235, .35); }
.tg-marker {
  position: absolute;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  color: #fff;
  border: 2px solid #fff;
  box-shadow: 0 2px 8px rgba(17, 24, 39, .26);
  display: grid;
  place-items: center;
  font-size: 10px;
  font-weight: 700;
  cursor: pointer;
  pointer-events: auto;
  user-select: none;
  z-index: 3;
}
.tg-marker.is-resolved { opacity: .40; }
.tg-marker.is-orphan { border-style: dashed; }
.tg-marker.is-pulse { animation: tg-pulse 1.1s ease-out; }
@keyframes tg-pulse { 0% { box-shadow: 0 0 0 0 rgba(31, 111, 235, .5); } 100% { box-shadow: 0 0 0 18px rgba(31, 111, 235, 0); } }

.tg-svg .tg-shape { pointer-events: all; cursor: move; }
.tg-svg .tg-handle { pointer-events: all; cursor: nwse-resize; }
.tg-layer.drawing { pointer-events: auto; cursor: crosshair; }
.tg-layer.drawing .tg-marker, .tg-layer.drawing .tg-highlights { pointer-events: none; }
.tg-layer.drawing .tg-ui { pointer-events: none; }

.tg-text {
  position: absolute;
  background: rgba(255, 255, 255, .96);
  border-left: 3px solid var(--tg-accent);
  border-radius: 4px;
  padding: 5px 8px;
  font-size: 12.5px;
  line-height: 1.55;
  color: #1f2937;
  box-shadow: 0 4px 16px rgba(17, 24, 39, .12);
  pointer-events: auto;
  cursor: move;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.tg-image-wrap {
  position: absolute;
  border: 2px solid rgba(31, 111, 235, .55);
  border-radius: 8px;
  overflow: hidden;
  background: #fff;
  box-shadow: 0 8px 24px rgba(17, 24, 39, .14);
  pointer-events: auto;
}
.tg-image { display: block; width: 100%; height: 100%; object-fit: cover; }

.tg-selection-bar {
  position: fixed;
  z-index: 120;
  display: none;
  align-items: center;
  gap: 4px;
  background: #111827;
  color: #fff;
  border-radius: 10px;
  padding: 5px;
  box-shadow: 0 10px 30px rgba(17, 24, 39, .30);
  pointer-events: auto;
}
.tg-selection-bar[data-visible="1"] { display: flex; }
.tg-mini-btn {
  border: 0;
  background: transparent;
  color: #e5e7eb;
  border-radius: 7px;
  padding: 5px 8px;
  font-size: 11px;
  cursor: pointer;
}
.tg-mini-btn:hover { background: rgba(255, 255, 255, .12); color: #fff; }
.tg-mini-btn.is-primary { background: #fff; color: #111827; }
.tg-mini-quote { max-width: 160px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: #9ca3af; font-size: 10px; padding: 0 4px; }

.tg-composer, .tg-thread {
  position: fixed;
  z-index: 130;
  width: min(340px, calc(100vw - 32px));
  background: #fff;
  border: 1px solid rgba(17, 24, 39, .14);
  border-radius: 14px;
  box-shadow: var(--tg-shadow);
  padding: 11px;
  pointer-events: auto;
}
.tg-composer-head { display: flex; justify-content: space-between; gap: 8px; align-items: baseline; margin-bottom: 7px; }
.tg-composer-title { font-size: 12px; font-weight: 700; color: #111827; }
.tg-textarea {
  width: 100%;
  min-height: 68px;
  resize: vertical;
  border: 1px solid var(--tg-line);
  border-radius: 9px;
  padding: 8px 9px;
  font-size: 12.5px;
  line-height: 1.55;
  outline: none;
  box-sizing: border-box;
  background: #fcfcfd;
}
.tg-textarea:focus, .tg-input:focus { border-color: #93c5fd; box-shadow: 0 0 0 3px rgba(31, 111, 235, .10); }
.tg-input {
  width: 100%;
  margin-top: 6px;
  border: 1px solid var(--tg-line);
  border-radius: 8px;
  padding: 6px 8px;
  font-size: 11.5px;
  outline: none;
  box-sizing: border-box;
  background: #fcfcfd;
}
.tg-composer-actions { display: flex; justify-content: flex-end; gap: 6px; margin-top: 8px; }
.tg-thread-head { display: flex; align-items: center; gap: 8px; }
.tg-avatar { width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; color: #fff; font-size: 11px; font-weight: 700; flex: 0 0 auto; }
.tg-thread-meta { display: flex; flex-direction: column; line-height: 1.3; flex: 1; min-width: 0; }
.tg-author { font-size: 12px; }
.tg-icon-btn { border: 0; background: transparent; font-size: 18px; line-height: 1; color: #9ca3af; cursor: pointer; padding: 2px 4px; }
.tg-icon-btn:hover { color: #111827; }
.tg-thread-body { padding-top: 8px; }
.tg-thread-text { margin: 0 0 7px; font-size: 12.5px; line-height: 1.6; color: #374151; white-space: pre-wrap; overflow-wrap: anywhere; }
.tg-tags { display: flex; gap: 4px; flex-wrap: wrap; margin: 4px 0 8px; }
.tg-replies { border-top: 1px dashed var(--tg-line); margin-top: 6px; padding-top: 6px; }
.tg-reply { margin-bottom: 7px; font-size: 11.5px; }
.tg-reply p { margin: 2px 0 0; color: #374151; line-height: 1.55; }
.tg-reply-author { font-weight: 650; }
.tg-reply-time { color: var(--tg-muted); margin-left: 6px; font-size: 10px; }
.tg-reply-box { display: flex; gap: 6px; align-items: flex-end; border-top: 1px dashed var(--tg-line); padding-top: 7px; margin-top: 7px; }
.tg-reply-input { min-height: 40px; }
.tg-thread-actions { display: flex; flex-wrap: wrap; gap: 5px; border-top: 1px solid var(--tg-line); padding-top: 8px; margin-top: 8px; }

.tg-toast {
  position: fixed;
  left: 50%;
  bottom: 26px;
  transform: translate(-50%, 12px);
  background: #111827;
  color: #fff;
  font-size: 12px;
  padding: 8px 13px;
  border-radius: 999px;
  box-shadow: 0 10px 30px rgba(17, 24, 39, .26);
  opacity: 0;
  transition: opacity .2s, transform .2s;
  z-index: 200;
  pointer-events: none;
}
.tg-toast.is-on { opacity: 1; transform: translate(-50%, 0); }

.tg-modal {
  position: fixed;
  inset: 0;
  z-index: 150;
  background: rgba(17, 24, 39, .46);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 18px;
  pointer-events: auto;
}
.tg-modal-card {
  width: min(1100px, 100%);
  height: min(86vh, 900px);
  background: #fff;
  border-radius: 18px;
  box-shadow: 0 30px 80px rgba(0, 0, 0, .34);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.tg-modal-head { display: flex; align-items: center; gap: 10px; padding: 12px 14px; border-bottom: 1px solid var(--tg-line); }
.tg-modal-head strong { font-size: 13px; }
.tg-modal-body { flex: 1; overflow: auto; background: #f7f7f5; }
.tg-modal-body iframe { width: 100%; height: 100%; border: 0; background: #fff; }
.tg-diff { display: grid; grid-template-columns: 1fr 1fr; gap: 0; height: 100%; }
.tg-diff-col { overflow: auto; padding: 12px; background: #fff; }
.tg-diff-col + .tg-diff-col { border-left: 1px solid var(--tg-line); }
.tg-diff-block { font-size: 12.5px; line-height: 1.65; padding: 6px 8px; margin-bottom: 4px; border-radius: 6px; white-space: pre-wrap; }
.tg-diff-block.is-add { background: #ecfdf5; border-left: 3px solid #10b981; }
.tg-diff-block.is-del { background: #fef2f2; border-left: 3px solid #ef4444; }
.tg-diff-block.is-eq { color: #4b5563; }
.tg-diff-muted { color: #9ca3af; font-size: 11px; padding: 3px 8px; background: #f9fafb; }
.tg-diff-label { font-size: 11px; color: var(--tg-muted); margin-bottom: 8px; }

.tg-user-dialog { position: fixed; z-index: 180; right: 76px; top: 64px; width: min(320px, calc(100vw - 32px)); background: #fff; border: 1px solid var(--tg-line); border-radius: 14px; box-shadow: var(--tg-shadow); padding: 12px; pointer-events: auto; }
.tg-user-dialog h3 { margin: 0 0 8px; font-size: 13px; }
.tg-user-row { display: flex; align-items: center; gap: 8px; padding: 6px 4px; border-radius: 8px; cursor: pointer; }
.tg-user-row:hover { background: #f9fafb; }
.tg-user-row .tg-avatar { width: 22px; height: 22px; font-size: 10px; }
.tg-user-self { font-size: 10px; color: var(--tg-accent); margin-left: auto; }
.tg-user-note { margin-top: 8px; font-size: 10.5px; color: var(--tg-muted); line-height: 1.6; }

@media (max-width: 720px) {
  .tg-dock { top: auto; bottom: 14px; right: 12px; flex-direction: row; flex-wrap: wrap; max-width: calc(100vw - 24px); justify-content: flex-end; }
  .tg-dock .tg-dock-sep { width: 1px; height: 28px; margin: 4px 2px; }
  .tg-pill { left: 12px; bottom: 74px; max-width: calc(100vw - 90px); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .tg-panel { top: 64px; bottom: 74px; right: 12px; width: calc(100vw - 24px); }
  .tg-user-dialog { right: 12px; }
  .tg-diff { grid-template-columns: 1fr; }
  .tg-diff-col + .tg-diff-col { border-left: 0; border-top: 1px solid var(--tg-line); }
}
