/* Edit history (static/edit_history.js, templates/edit_log.html). */

/* ── Header chip: a quiet label, no hover or open state ───────────────── */
.eh-chip {
  display: inline-flex; align-items: center; gap: 6px;
  height: 32px; padding: 0 11px; border: 0; background: none;
  font-size: 12.5px; color: var(--fg-dim); white-space: nowrap; cursor: pointer;
}
.eh-chip svg { width: 14px; height: 14px; }
.eh-chip b { color: var(--fg); font-weight: 700; }
[data-theme="light"] .eh-chip { color: #55534e; }
[data-theme="light"] .eh-chip b { color: #1a1a1a; }

/* ── Avatars ──────────────────────────────────────────────────────────── */
.eh-avatar {
  flex: none; width: 28px; height: 28px; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 600; color: #fff;
  background: linear-gradient(135deg, hsl(var(--eh-hue, 30) 45% 58%), hsl(var(--eh-hue, 30) 40% 38%));
}
.eh-avatar--sm { width: 26px; height: 26px; font-size: 11px; }

/* ── Dark popover: hover card and history panel ───────────────────────── */
.eh-pop {
  position: fixed; z-index: 80; background: #24221f; color: #f2f0ed;
  border-radius: 12px; box-shadow: 0 18px 50px -12px rgba(0, 0, 0, .55), 0 2px 6px rgba(0, 0, 0, .25);
  font-size: 12.5px; line-height: 1.35;
}
.eh-pop::before {
  content: ""; position: absolute; top: -6px; left: calc(var(--eh-arrow, 40px) - 6px);
  width: 12px; height: 12px; background: #24221f; transform: rotate(45deg); border-radius: 2px;
}
.eh-pop .eh-muted { color: #a8a49c; font-size: 11.5px; }
.eh-pop--hover { padding: 16px 16px 12px; }
.eh-pop-head { display: flex; align-items: flex-start; gap: 10px; }
.eh-who { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.eh-who b { font-size: 13px; }
.eh-when { display: flex; flex-direction: column; align-items: flex-end; text-align: right; font-size: 12px; }
.eh-eyebrow {
  margin: 14px 0 6px; font-size: 10.5px; letter-spacing: .08em; text-transform: uppercase;
  color: #a8a49c; font-weight: 600;
}
.eh-sec { margin-top: 10px; }
.eh-sec-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 5px; }
.eh-sec-title b { font-weight: 600; }
.eh-show, .eh-pop .eh-link-btn { color: #9fbcf7; font-size: 11.5px; font-weight: 700; white-space: nowrap; text-decoration: none; }
.eh-show:hover, .eh-link-btn:hover { text-decoration: underline; }
.eh-row {
  display: grid; grid-template-columns: 150px 1fr 18px minmax(80px, auto); align-items: center;
  gap: 4px; padding: 5px 10px; margin-top: 3px; border-radius: 5px; background: rgba(255, 255, 255, .05);
}
.eh-row-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.eh-before { color: #8a8680; text-align: right; }
.eh-arrow { color: #8a8680; text-align: center; }
.eh-after { color: #9fbcf7; font-weight: 700; }
.eh-pop-foot {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  margin-top: 14px; padding-top: 10px; border-top: 1px solid rgba(255, 255, 255, .08);
}
.eh-pop .eh-link-btn { background: none; border: 0; padding: 0; cursor: pointer; color: #f2f0ed; }
.eh-pop--panel { padding: 0; }
.eh-pop--panel .eh-pop-foot { margin: 0; padding: 12px 16px; }
.eh-panel-head {
  display: flex; justify-content: space-between; align-items: flex-start; gap: 12px;
  padding: 16px 16px 12px; border-bottom: 1px solid rgba(255, 255, 255, .08);
}
.eh-panel-title { font-size: 14px; }
.eh-pop-count { font-size: 11px; letter-spacing: .08em; text-transform: uppercase; color: #a8a49c; font-weight: 600; white-space: nowrap; }
.eh-list {
  max-height: min(640px, calc(100vh / var(--zf, 1) - 200px)); overflow-y: auto;
  -webkit-mask-image: linear-gradient(to bottom, #000 calc(100% - 40px), transparent);
  mask-image: linear-gradient(to bottom, #000 calc(100% - 40px), transparent);
}
.eh-entry { display: flex; gap: 10px; padding: 14px 16px; border-bottom: 1px solid rgba(255, 255, 255, .08); }
.eh-entry:first-child { background: rgba(255, 255, 255, .025); }
.eh-entry-main { flex: 1; min-width: 0; }
.eh-entry-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.eh-name { display: flex; align-items: center; gap: 7px; }
.eh-page { font-size: 11.5px; color: #c9c5bd; margin-top: 1px; }
.eh-tag {
  font-size: 9.5px; letter-spacing: .08em; text-transform: uppercase; font-weight: 700;
  color: #9fbcf7; border: 1px solid rgba(159, 188, 247, .6); border-radius: 4px; padding: 1px 6px;
}
.eh-live { padding-top: 2px; }
.eh-error { padding: 14px 16px; color: #f2a1a1; }
.eh-revert {
  display: inline-flex; align-items: center; gap: 6px; flex: none;
  padding: 6px 10px; border-radius: 7px; border: 0; cursor: pointer;
  background: #f2f0ed; color: #1a1a1a; font-size: 12px; font-weight: 600; white-space: nowrap;
}
.eh-revert svg { width: 13px; height: 13px; }
.eh-revert:disabled { opacity: .6; cursor: default; }

/* ── Revert confirmation ──────────────────────────────────────────────── */
.eh-modal {
  position: fixed; inset: 0; z-index: 90; background: rgba(10, 9, 8, .45);
  display: flex; align-items: center; justify-content: center; padding: 20px;
}
.eh-modal-box {
  width: min(440px, 100%); background: #24221f; color: #f2f0ed; border-radius: 12px;
  padding: 20px; box-shadow: 0 24px 60px -12px rgba(0, 0, 0, .6); font-size: 13px;
}
.eh-modal-title { display: block; font-size: 14.5px; margin-bottom: 8px; }
.eh-modal-box p { color: #c9c5bd; }
.eh-modal-error { color: #f2a1a1 !important; margin-top: 8px; }
.eh-modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; }
.eh-modal-cancel {
  padding: 6px 12px; border-radius: 7px; border: 1px solid rgba(255, 255, 255, .18);
  background: none; color: #f2f0ed; font-size: 12px; font-weight: 600; cursor: pointer;
}

/* ── Arriving from an edit: toast and marked cells ────────────────────── */
.eh-toast {
  display: flex; align-items: center; gap: 12px; width: fit-content; max-width: 100%;
  margin: 14px 0 6px; padding: 9px 12px; border-radius: 9px; font-size: 13px;
  background: rgba(79, 123, 232, .1); border: 1px solid rgba(79, 123, 232, .45); color: var(--fg);
}
.eh-toast-body { min-width: 0; }
.eh-toast-line { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 6px; }
.eh-jump { color: #4f7be8; font-weight: 600; text-decoration: underline; text-underline-offset: 3px; }
[data-theme="dark"] .eh-jump, :root:not([data-theme="light"]) .eh-jump { color: #9fbcf7; }
.eh-toast-note { font-size: 11.5px; color: var(--fg-faint); margin-top: 2px; }
.eh-toast-btn {
  flex: none; padding: 5px 10px; border-radius: 7px; border: 0; cursor: pointer;
  background: #1a1a1a; color: #f2f0ed; font-size: 12px; font-weight: 600; white-space: nowrap;
}

.eh-hl {
  /* An outline over the page's own styling, a glow animated on top: the
     animation shows over a box-shadow the page sets, an !important one
     would hide it. */
  outline: 2px solid #4f7be8 !important; outline-offset: -1px;
  background-color: rgba(79, 123, 232, .2) !important;
  border-radius: 5px; scroll-margin: 96px 48px;
  animation: eh-pulse 1.5s ease-in-out 4;
}
@keyframes eh-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(79, 123, 232, 0); }
  50% { box-shadow: 0 0 0 5px rgba(79, 123, 232, .35), 0 0 22px rgba(79, 123, 232, .55); }
}
/* After the first seconds: steady until the toast is dismissed. */
.eh-hl--settled { animation: none; background-color: rgba(79, 123, 232, .14) !important; }
:root:not([data-theme="light"]) .eh-hl { outline-color: #7ea0f2 !important; }
.eh-hl-row { position: relative; }
.eh-was { font-size: 11px; color: #4f7be8; margin-left: 8px; white-space: nowrap; }
:root:not([data-theme="light"]) .eh-was { color: #9fbcf7; }

/* ── Edit log page ────────────────────────────────────────────────────── */
.el-crumb { font-size: 13px; color: var(--fg-faint); }
.el-crumb a { color: var(--fg); }
.el-title { font-size: 24px; font-weight: 600; margin-top: 4px; }
.el-blurb { color: var(--fg-dim); font-size: 14px; margin-top: 6px; }
.el-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 20px; }
.el-btn {
  display: inline-flex; align-items: center; gap: 7px; padding: 7px 13px; border-radius: 8px;
  border: 1px solid var(--line); background: var(--panel); color: var(--fg); font-size: 13px; font-weight: 600;
}
.el-btn svg { width: 15px; height: 15px; }
.el-filters { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 12px; margin-top: 22px; }
.el-filters label { font-size: 11px; letter-spacing: .08em; text-transform: uppercase; color: var(--fg-faint); }
.el-filters select, .el-filters input[type="search"] {
  border: 1px solid var(--line); background: var(--panel); color: var(--fg); border-radius: 8px;
  padding: 6px 10px; font-size: 13px;
}
.el-filters input[type="search"] { width: 290px; }
.el-toggle { margin-left: auto; display: inline-flex; align-items: center; gap: 8px; font-size: 13px; color: var(--fg-dim); cursor: pointer; text-transform: none !important; letter-spacing: 0 !important; }
.el-toggle input { accent-color: #4f7be8; width: 15px; height: 15px; }
.el-stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; margin-top: 20px; }
.el-stat { background: var(--panel); border: 1px solid var(--grid-line); border-radius: 12px; padding: 16px 20px; }
.el-stat-label { font-size: 11px; letter-spacing: .08em; text-transform: uppercase; color: var(--fg-dim); font-weight: 600; }
.el-stat-value { font-size: 22px; font-weight: 600; margin-top: 6px; }
.el-stat-sub { font-size: 12.5px; color: var(--fg-dim); margin-top: 4px; }
.el-day { display: flex; align-items: center; gap: 12px; margin: 30px 0 12px; font-size: 11px; letter-spacing: .1em; text-transform: uppercase; color: var(--fg-dim); font-weight: 600; }
.el-day::after { content: ""; flex: 1; height: 1px; background: var(--grid-line); }
.el-card {
  display: grid; grid-template-columns: 260px minmax(0, 1fr) 220px; gap: 24px;
  background: var(--panel); border: 1px solid var(--grid-line); border-radius: 12px; padding: 18px 22px; margin-bottom: 12px;
}
.el-card--current { border: 1.5px solid rgba(79, 123, 232, .55); box-shadow: 0 0 0 3px rgba(79, 123, 232, .08); }
.el-who { display: flex; gap: 10px; }
.el-who b { font-size: 14px; }
.el-who .el-when { font-size: 12.5px; color: var(--fg-dim); }
.el-who .el-page { font-size: 13px; color: var(--fg-dim); margin-top: 8px; }
.el-tag {
  font-size: 9.5px; letter-spacing: .08em; text-transform: uppercase; font-weight: 700; margin-left: 6px;
  color: #4f7be8; border: 1px solid rgba(79, 123, 232, .6); border-radius: 4px; padding: 1px 6px; vertical-align: 2px;
}
.el-sec + .el-sec { margin-top: 12px; }
.el-sec-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; margin-bottom: 5px; font-size: 13.5px; }
.el-sec-head b { font-weight: 600; }
.el-sec-head .el-n { color: var(--fg-faint); font-size: 11.5px; }
.el-show { color: #4f7be8; font-size: 12.5px; font-weight: 600; white-space: nowrap; }
.el-row {
  display: grid; grid-template-columns: minmax(150px, 1fr) minmax(0, 1fr) 30px minmax(0, 1fr); align-items: center;
  padding: 6px 12px; margin-top: 4px; border-radius: 6px; border: 1px solid var(--grid-line); font-size: 13px;
  background: var(--fc-zebra, transparent);
}
.el-row s { color: var(--fg-faint); text-align: right; }
.el-row .el-arrow { color: var(--fg-faint); text-align: center; }
.el-row .el-after { color: #4f7be8; font-weight: 600; }
:root:not([data-theme="light"]) .el-row .el-after, :root:not([data-theme="light"]) .el-show { color: #9fbcf7; }
.el-actions { display: flex; flex-direction: column; align-items: flex-end; gap: 10px; text-align: right; font-size: 12px; color: var(--fg-faint); }
.el-actions .eh-revert { background: #1a1a1a; color: #f2f0ed; padding: 8px 14px; font-size: 13px; }
:root:not([data-theme="light"]) .el-actions .eh-revert { background: #f2f0ed; color: #1a1a1a; }
.el-refresh { display: flex; align-items: center; gap: 10px; margin: 8px 0 14px; font-size: 12px; color: var(--fg-faint); }
.el-refresh::before, .el-refresh::after { content: ""; flex: 1; height: 1px; background: var(--grid-line); border-top: 1px dashed var(--grid-line); }
.el-empty { margin-top: 30px; padding: 40px; text-align: center; color: var(--fg-dim); border: 1px dashed var(--line); border-radius: 12px; }
.el-foot { display: flex; gap: 20px; margin: 18px 0 40px; font-size: 12.5px; color: var(--fg-faint); }
.el-foot a { color: var(--fg-dim); text-decoration: underline; }
.el-foot .el-utc { margin-left: auto; }
@media (max-width: 1100px) {
  .el-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .el-card { grid-template-columns: 1fr; }
  .el-actions { align-items: flex-start; text-align: left; }
}
