*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  background-color: #1a1a1a;
  color: #ccc;
  font-family: system-ui, sans-serif;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  padding-bottom: 48px;
}

main { flex: 1; padding: 2rem; }

/* ── Footer ── */
footer {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  height: 48px;
  background-color: #000;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding: 0 16px;
  z-index: 100;
}

.footer-meta {
  display: flex;
  align-items: center;
  background-color: #2a2a2a;
  border-radius: 6px;
  overflow: hidden;
  height: 32px;
}

.history-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 0 14px;
  height: 100%;
  background: transparent;
  border: none;
  color: #aaa;
  font-size: 13px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
  white-space: nowrap;
}
.history-btn:hover { background-color: #3a3a3a; color: #fff; }
.history-btn i { font-size: 14px; }

.footer-divider { width: 1px; height: 20px; background: #444; flex-shrink: 0; }

.doc-id {
  padding: 0 14px;
  font-size: 12px;
  color: #666;
  white-space: nowrap;
  user-select: all;
}

/* ── History Panel ── */
.history-panel {
  position: fixed;
  bottom: 48px; left: 0; right: 0;
  height: 270px;
  background: #fff;
  color: #222;
  z-index: 99;
  transform: translateY(100%);
  transition: transform 0.35s cubic-bezier(0.4, 0, 0.2, 1);
  display: flex;
  flex-direction: column;
  box-shadow: 0 -4px 24px rgba(0, 0, 0, 0.4);
}
.history-panel.open { transform: translateY(0); }

/* ── Panel Header ── */
.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px;
  border-bottom: 1px solid #eee;
  flex-shrink: 0;
  gap: 12px;
}

/* Left group: toggle + Show Differences side by side */
.header-left {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Segmented view toggle */
.view-toggle {
  display: inline-flex;
  background: #ececec;
  border-radius: 7px;
  padding: 3px;
  gap: 2px;
}
.toggle-btn {
  padding: 5px 14px;
  border: none;
  background: transparent;
  border-radius: 5px;
  font-size: 12px;
  font-weight: 500;
  color: #666;
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
}
.toggle-btn.active {
  background: #fff;
  color: #111;
  box-shadow: 0 1px 3px rgba(0,0,0,0.15);
}

.close-btn {
  background: none;
  border: none;
  cursor: pointer;
  color: #888;
  font-size: 18px;
  padding: 4px 8px;
  border-radius: 4px;
  line-height: 1;
  transition: background 0.15s, color 0.15s;
  flex-shrink: 0;
}
.close-btn:hover { background: #f0f0f0; color: #222; }

/* ── Timeline area ── */
.timeline-area {
  flex: 1;
  padding: 0 36px;
  display: flex;
  align-items: center;
  position: relative;
}

/*
  track-wrapper layout (top → bottom inside 100px box):
    0–28px  : revision pill (floats detached)
    28–44px : gap between pill and thumb top
    44–96px : thumb bar (spans through track center at 68px)
    Note: pill and thumb share the same left% but pill has extra
          top offset so there is visible air between them.
*/
.track-wrapper {
  position: relative;
  width: 100%;
  height: 132px;   /* extra room for orange pill below thumb */
}

/* Gray bar */
.track-bg {
  position: absolute;
  top: 68px;
  left: 0; right: 0;
  height: 8px;
  transform: translateY(-50%);
  background: #dedede;
  border-radius: 4px;
  cursor: pointer;
  overflow: visible;
}

/* Tick marks — children of track-bg */
.tick {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 1px;
  height: 16px;          /* taller than the 8px bar — pokes out above & below */
  background: rgba(0,0,0,0.22);
  border-radius: 1px;
  pointer-events: none;
}
.tick.dot {
  width: 5px;
  height: 8px;
  margin-left: -2px;
  border-radius: 2px;
  background: #b8b8b8;
}

/* ── Track legend ── */
.track-legend {
  position: absolute;
  bottom: 2px;
  right: 0;
  display: flex;
  align-items: center;
  gap: 5px;
  pointer-events: none;
  user-select: none;
}

.track-legend-swatch {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 2px;
  flex-shrink: 0;
}
.track-legend-swatch--published {
  background: #27ae60;
  opacity: 0.9;
}

.track-legend-label {
  font-size: 10px;
  color: #999;
  line-height: 1;
}

.track-legend-help {
  position: relative;
  display: inline-flex;
  align-items: center;
  pointer-events: auto;
  cursor: default;
  color: #aaa;
  font-size: 11px;
  line-height: 1;
}
.track-legend-help:hover { color: #666; }

.track-legend-tooltip {
  display: none;
  position: absolute;
  bottom: calc(100% + 6px);
  right: 0;
  width: 210px;
  background: #333;
  color: #ddd;
  font-size: 11px;
  line-height: 1.45;
  padding: 7px 9px;
  border-radius: 6px;
  box-shadow: 0 2px 10px rgba(0,0,0,0.35);
  white-space: normal;
  pointer-events: none;
  z-index: 200;
}
/* small arrow pointing down */
.track-legend-tooltip::after {
  content: '';
  position: absolute;
  top: 100%;
  right: 4px;
  border: 5px solid transparent;
  border-top-color: #333;
}
.track-legend-help:hover .track-legend-tooltip {
  display: block;
}

/* Number label sitting above a tall tick mark */
.tick-label {
  position: absolute;
  bottom: calc(100% + 3px);  /* 3px gap above the tick top */
  left: 50%;
  transform: translateX(-50%);
  font-size: 9px;
  font-variant-numeric: tabular-nums;
  color: #aaa;
  white-space: nowrap;
  pointer-events: none;
  user-select: none;
  line-height: 1;
}

/* Draggable green thumb */
.thumb {
  position: absolute;
  top: 36px;           /* leaves ~8px gap below the pill's bottom (pill bottom ≈28px) */
  height: 64px;
  width: 20px;
  transform: translateX(-50%);
  cursor: grab;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: center;
}
.thumb:active { cursor: grabbing; }

.thumb-bar {
  width: 6px;
  height: 100%;
  background: #2ecc71;
  border-radius: 3px;
  box-shadow: 0 0 10px rgba(46,204,113,0.55);
  pointer-events: none;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Revision pill — detached above the thumb bar */
.rev-pill {
  position: absolute;
  top: 0;
  height: 26px;
  transform: translateX(-50%);
  background: #2ecc71;
  border-radius: 13px;
  display: flex;
  align-items: center;
  padding: 0 8px;        /* tight symmetric padding — fits text only */
  box-shadow: 0 2px 8px rgba(46,204,113,0.4);
  cursor: grab;
  white-space: nowrap;
  user-select: none;
  z-index: 11;
  transition: padding 0.15s;
}
.rev-pill:active { cursor: grabbing; }
.rev-pill:focus-within { cursor: text; }
/* expand to fit arrows when focused */
.rev-pill:focus-within {
  padding: 0 4px 0 10px;
}

.pill-input {
  font-size: 12px;
  font-weight: 700;
  background: transparent;
  border: none;
  border-bottom: 1px solid transparent;
  color: #fff;
  outline: none;
  width: auto;           /* sized by JS via size= attribute */
  min-width: 1ch;
  text-align: center;
  cursor: text;          /* text cursor when hovering the number */
  padding: 0;
  transition: border-color 0.15s;
  pointer-events: auto;  /* allow hover cursor; mousedown bubbles up to pill */
}
.rev-pill:not(:focus-within) .pill-input {
  /* Not yet editing — pass mousedown through to pill for drag,
     but still show text cursor to hint the number is editable */
  cursor: text;
}
.pill-input:focus {
  cursor: text;
  border-bottom-color: rgba(255,255,255,0.55);
}
.pill-input::-webkit-inner-spin-button,
.pill-input::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
.pill-input { -moz-appearance: textfield; }

.pill-arrows {
  display: flex;
  flex-direction: column;
  /* collapsed — takes zero space until focused */
  width: 0;
  overflow: hidden;
  opacity: 0;
  pointer-events: none;
  transition: width 0.15s, opacity 0.15s;
}
/* expand when the pill's input is focused */
.rev-pill:focus-within .pill-arrows,
.rev-pill-out:focus-within .pill-arrows {
  width: 16px;
  opacity: 1;
  pointer-events: auto;
}
.pill-arrow {
  background: none;
  border: none;
  color: rgba(255,255,255,0.7);
  cursor: pointer;
  padding: 1px 3px;
  font-size: 8px;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
}
.pill-arrow:hover { color: #fff; }

/* ── Controls bar ── */
.timeline-controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 36px 14px;
  border-top: 1px solid #eee;
  flex-shrink: 0;
  gap: 12px;
}

.ctrl-group {
  display: flex;
  align-items: center;
  gap: 5px;
}

.ctrl-label {
  font-size: 11px;
  color: #999;
  font-weight: 600;
  letter-spacing: 0.03em;
  margin-right: 2px;
  white-space: nowrap;
}

.ctrl-btn {
  padding: 4px 10px;
  font-size: 11px;
  font-weight: 500;
  border: 1px solid #ddd;
  background: #f7f7f7;
  border-radius: 4px;
  cursor: pointer;
  color: #555;
  transition: all 0.12s;
  white-space: nowrap;
  line-height: 1.4;
}
.ctrl-btn:hover { background: #eaeaea; color: #222; border-color: #ccc; }
.ctrl-btn.active { background: #2ecc71; border-color: #27ae60; color: #fff; }

.nudge-btn {
  width: 28px;
  height: 26px;
  border: 1px solid #ddd;
  background: #f7f7f7;
  border-radius: 4px;
  cursor: pointer;
  font-size: 18px;
  font-weight: 300;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #444;
  line-height: 1;
  transition: all 0.12s;
}
.nudge-btn:hover { background: #eaeaea; color: #111; border-color: #ccc; }

.ctrl-separator {
  width: 1px;
  height: 18px;
  background: #ddd;
  margin: 0 4px;
  flex-shrink: 0;
}

.icon-btn {
  width: 28px;
  height: 26px;
  border: 1px solid #ddd;
  background: #f7f7f7;
  border-radius: 4px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #666;
  font-size: 12px;
  transition: all 0.12s;
}
.icon-btn:hover { background: #eaeaea; color: #222; border-color: #ccc; }
.icon-btn.active { background: #e8f4fd; border-color: #3498db; color: #2980b9; }

/* ── Filter popup ── */
.filter-btn-wrap {
  position: relative;
  display: flex;
  align-items: center;
}

.filter-popup {
  position: absolute;
  bottom: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%);
  min-width: 230px;
  background: #fff;
  border: 1px solid #ddd;
  border-radius: 8px;
  box-shadow: 0 6px 24px rgba(0,0,0,0.14);
  padding: 10px 0 8px;
  z-index: 200;
  display: none;
  flex-direction: column;
  gap: 0;
}
.filter-popup.open {
  display: flex;
}
/* caret arrow pointing down to the filter button */
.filter-popup::after {
  content: '';
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  border: 6px solid transparent;
  border-top-color: #ddd;
  pointer-events: none;
}
.filter-popup::before {
  content: '';
  position: absolute;
  top: calc(100% - 1px);
  left: 50%;
  transform: translateX(-50%);
  border: 6px solid transparent;
  border-top-color: #fff;
  pointer-events: none;
  z-index: 1;
}

.filter-popup-title {
  font-size: 10px;
  font-weight: 700;
  color: #aaa;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 0 14px 6px;
  border-bottom: 1px solid #f0f0f0;
  margin-bottom: 4px;
}

.filter-option {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 7px 14px;
  cursor: pointer;
  transition: background 0.1s;
  user-select: none;
}
.filter-option:hover { background: #f7f7f7; }

.filter-option input[type="checkbox"] {
  margin-top: 2px;
  accent-color: #2ecc71;
  width: 14px;
  height: 14px;
  flex-shrink: 0;
  cursor: pointer;
}

.filter-option-label {
  display: flex;
  flex-direction: column;
  gap: 1px;
}
.filter-option-name {
  font-size: 12px;
  font-weight: 600;
  color: #222;
  line-height: 1.3;
}
.filter-option-desc {
  font-size: 10px;
  color: #999;
  line-height: 1.3;
}

/* Published tick marks on the track */
.tick.published {
  width: 2px;
  height: 8px;
  background: #27ae60;
  border-radius: 1px;
  opacity: 0.85;
  z-index: 2;
}
.tick.published.dot {
  width: 6px;
  height: 8px;
  border-radius: 2px;
  background: #27ae60;
  margin-left: -3px;
  opacity: 0.9;
}

/* ── Orange (out) thumb — diff mode ── */
.thumb-out {
  position: absolute;
  top: 36px;
  height: 64px;
  width: 20px;
  transform: translateX(-50%);
  cursor: grab;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: center;
}
.thumb-out:active { cursor: grabbing; }

.thumb-out-bar {
  width: 6px;
  height: 100%;
  background: #e67e22;
  border-radius: 3px;
  box-shadow: 0 0 10px rgba(230,126,34,0.6);
  pointer-events: none;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Drag tooltip */
.drag-tooltip {
  position: absolute;
  top: -8px;            /* sits just above the track-wrapper top */
  transform: translate(-50%, -100%);
  background: #1e1e1e;
  color: #f0f0f0;
  border-radius: 8px;
  padding: 7px 11px;
  font-size: 11px;
  line-height: 1.5;
  white-space: nowrap;
  box-shadow: 0 4px 16px rgba(0,0,0,0.45);
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.12s;
  z-index: 30;
}
.drag-tooltip.visible {
  opacity: 1;
}
.drag-tooltip::after {
  content: '';
  position: absolute;
  bottom: -5px;
  left: 50%;
  transform: translateX(-50%);
  border: 5px solid transparent;
  border-bottom: 0;
  border-top-color: #1e1e1e;
}
.drag-tooltip-row:first-child {
  font-weight: 600;
  color: #fff;
}
.drag-tooltip-row:last-child {
  color: #aaa;
}

/* Grab dots — single column of 3 dots centered on the bar */
.grab-dots {
  width: 2px;
  height: 2px;
  border-radius: 50%;
  background: rgba(255,255,255,0.6);
  box-shadow:
    0px -5px 0 rgba(255,255,255,0.6),
    0px  5px 0 rgba(255,255,255,0.6);
  pointer-events: none;
  flex-shrink: 0;
}

/* Orange pill — detached above the orange thumb bar */
/* Orange pill — below the thumb bar, mirroring green pill gap above */
.rev-pill-out {
  position: absolute;
  top: 106px;
  height: 26px;
  transform: translateX(-50%);
  background: #e67e22;
  border-radius: 13px;
  display: flex;
  align-items: center;
  padding: 0 8px;        /* tight — fits text only */
  box-shadow: 0 2px 8px rgba(230,126,34,0.4);
  cursor: default;
  white-space: nowrap;
  user-select: none;
  z-index: 11;
  transition: padding 0.15s;
}
.rev-pill-out:focus-within {
  padding: 0 4px 0 10px;
}

/* Blue range highlight on track */
.range-highlight {
  position: absolute;
  top: 0; bottom: 0;
  background: rgba(42, 122, 226, 0.637);
  border-radius: 4px;
  pointer-events: none;
  z-index: 1;
}

/* Show Differences button */
.show-diff-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 5px 14px;
  background: rgb(63, 81, 181);
  border: none;
  border-radius: 6px;
  color: #fff;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
  white-space: nowrap;
}
.show-diff-btn:hover { background: rgb(48, 63, 159); }
.show-diff-btn i { font-size: 13px; }

.mark-published-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 5px 14px;
  background: rgb(63, 81, 181);
  border: none;
  border-radius: 6px;
  color: #fff;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
  white-space: nowrap;
}
.mark-published-btn:hover { background: rgb(48, 63, 159); }
.mark-published-btn i { font-size: 13px; }

/* Nudge color labels */
.nudge-label-green { color: #2ecc71; font-weight: 700; font-size: 11px; }
.nudge-label-orange { color: #e67e22; font-weight: 700; font-size: 11px; }

/* Elements only visible in diff mode */
.diff-only { display: none !important; }
.diff-mode .diff-only { display: flex !important; }

/* Elements only visible in history mode */
.history-only { display: flex !important; }
.diff-mode .history-only { display: none !important; }
