/* Excel replica — the sheet: virtualized cells, headers, selection chrome,
 * marching ants, fill handle, in-cell editor, reference chips. */

#canvas .cell {
  position: absolute;
  padding: 0 3px;
  font-family: var(--cell-font);
  font-size: calc(11px * var(--zoom, 1));
  line-height: 1.18;
  color: #1c1c1c;
  background: #fff;
  white-space: pre;
  overflow: hidden;
  display: flex; align-items: center;
}
#canvas .cell.hL { justify-content: flex-start; text-align: left; }
#canvas .cell.hR { justify-content: flex-end; text-align: right; }
#canvas .cell.hC { justify-content: center; text-align: center; }
#canvas .cell.vT { align-items: flex-start; }
#canvas .cell.vB { align-items: flex-end; }
#canvas .cell.wrap { white-space: normal; word-wrap: break-word; }

/* selected range wash */
#canvas .cell.inSel { }
#overlayLayer .selwash {
  position: absolute; z-index: 0;
  background: rgba(33,115,70,.10);
  pointer-events: none;
}

/* headers */
.hd {
  position: absolute;
  display: flex; align-items: center; justify-content: center;
  font-family: var(--ui-font);
  font-size: calc(11px * var(--zoom, 1));
  color: #4d4a46;
  background: linear-gradient(#fdfdfd,#f1efee);
  border-right: 1px solid #b6b3ae;
  border-bottom: 1px solid #b6b3ae;
  overflow: hidden; user-select: none;
}
.colhd { height: 100%; }
.rowhd { width: 100%; justify-content: flex-end !important; padding-right: 5px; }
.colhd.active, .rowhd.active { background: var(--xl-green); color: #fff; font-weight: 600; border-color: var(--xl-green-dark); }
.colhd.insel:not(.active), .rowhd.insel:not(.active) {
  background: linear-gradient(#e9f2ec,#d8e8de); color: #275136; font-weight: 600;
}
.colhd.hiddenmark::after, .rowhd.hiddenmark::after {
  content: ""; margin-left: 2px;
  border-left: 4px solid transparent; border-right: 4px solid transparent; border-top: 5px solid #999;
}
.filter-arrow {
  position: absolute; right: 1px; bottom: 1px;
  width: 12px; height: 12px;
  background: #fff; outline: 1px solid #98a89f; border-radius: 2px;
  display: inline-flex; align-items: center; justify-content: center;
  cursor: default;
}
.filter-arrow.applied { outline-color: var(--xl-green); background: #dff0e6; }
#colStrip .resizer, #gridWrap .rsz-col {
  position: absolute; top: 0; right: -2.5px; width: 5px; height: 100%;
  cursor: col-resize; z-index: 5;
}
#rowStrip .row-resizer {
  position: absolute; left: 0; bottom: -2.5px; height: 5px; width: 100%;
  cursor: row-resize; z-index: 5;
}

/* selection borders drawn on overlay */
.selrect { position: absolute; pointer-events: none; }
.selrect.border { border: 1px solid var(--xl-green); box-shadow: inset 0 0 0 .5px rgba(255,255,255,.55); }
.selrect.dragging { opacity: .75; }

/* active cell cursor */
.activerect {
  position: absolute; pointer-events: none;
  border: 2px solid #fff;
  outline: 1px solid var(--xl-green);
  box-shadow: 0 0 0 1px rgba(33,115,70,.35), inset 0 0 0 1px rgba(33,115,70,.35);
}

/* fill handle + rubber band */
.fillhandle {
  position: absolute;
  width: 7px; height: 7px;
  background: var(--xl-green);
  border: 1px solid #fff;
  right: -4.5px; bottom: -4.5px;
  cursor: crosshair;
  z-index: 3;
  box-shadow: 0 0 2px rgba(0,0,0,.25);
}
.rubberband {
  position: absolute;
  border: 1px dashed #21734699;
  background: rgba(33,115,70,.05);
  pointer-events: none;
}

/* marching ants (copy/cut) — four animated edges */
.marching-ants { position: absolute; pointer-events: none; z-index: 2; }
.marching-ants .edge {
  position: absolute;
  background-repeat: repeat-x;
  animation: antsmarch .45s linear infinite;
  --antcolA: #1c1c1c; --antcolB: #ffffff;
}
.marching-ants.cut .edge { --antcolA: #14607c; }
@keyframes antsmarch { to { background-position-x: -8px; } }
.marching-ants .corner-fix { position: absolute; }

/* ghost rectangle while drag-moving */
.drop-ghost {
  position: absolute;
  border: 1.5px dashed #444;
  background: rgba(120,120,120,.08);
  pointer-events: none; z-index: 2;
}

/* resize guide */
.resize-guide { position: absolute; background: #8ecdb1; width: 1px; pointer-events: none; z-index: 6; }
.resize-guide.h { height: 1px; width: auto; }

/* ------------------------- in-cell editor -------------------------------- */
#celleditor {
  position: absolute;
  z-index: 30;
  min-width: 24px;
  background: #fff;
  font-family: var(--cell-font);
  font-size: calc(11px * var(--zoom, 1));
  line-height: 1.2;
  color: #111;
  border: none;
  outline: 2px solid var(--xl-green);
  outline-offset: -1px;
  box-shadow: 0 2px 8px rgba(0,0,0,.28);
  white-space: pre;
  overflow: hidden;
  padding: 0 3px;
  display: none;
  caret-color: #1a66c2;
}
#celleditor.wraplong { white-space: normal; word-break: break-word; }

/* function autocomplete dropdown */
#acdropdown {
  position: absolute;
  z-index: 40;
  background: #fff;
  border: 1px solid #b9b6b1;
  box-shadow: 0 6px 18px rgba(0,0,0,.22);
  font-family: var(--ui-font);
  font-size: 12px;
  max-height: 152px; overflow-y: auto;
  min-width: 190px;
  display: none;
}
#acdropdown .ac-item {
  display: flex; gap: 7px; padding: 2px 8px 2px 6px; cursor: pointer;
  line-height: 17px;
}
#acdropdown .ac-item .acname { font-weight: 600; color: #23272b; }
#acdropdown .ac-item .acdesc { color: #767270; overflow: hidden; text-overflow: ellipsis; }
#acdropdown .ac-item.sel { background: #1a66c2; color: #fff; }
#acdropdown .ac-item.sel .acdesc { color: #dbe7f7; }

/* function hint bar under editor while typing inside () */
#fnhint {
  position: absolute; z-index: 40;
  background: #ffffcf; border: 1px solid #cdc96a;
  font-family: Consolas, Menlo, monospace; font-size: 11.5px;
  padding: 1.5px 6px; color: #33321a;
  display: none; max-width: 420px; white-space: nowrap; overflow: hidden;
}
#fnhint b { color: #10267c; }
#fnhint .cur { text-decoration: underline; font-weight: 700; }

/* colored reference chips on grid while formula-editing */
.refchip { position: absolute; pointer-events: none; z-index: 1; }
.refchip A { background: rgba(31,111,235,.14); border: 1.5px solid #1f6feb; }
.refchip B { background: rgba(16,124,16,.14); border: 1.5px solid #107c10; }
.refchip C { background: rgba(140,10,150,.13); border: 1.5px solid #8c0a96; }
.refchip D { background: rgba(201,64,14,.13); border: 1.5px solid #c9400e; }
.refchip E { background: rgba(14,110,110,.15); border: 1.5px solid #0e6e6e; }
.refchip.filled::after {
  content: ""; position: absolute; inset: 0;
}

/* CRT-flavored edit-commit flash (design territory: snappy micro-motion) */
@keyframes editflash {
  0%   { box-shadow: inset 0 0 0 60px rgba(90,200,140,0); filter: brightness(1); }
  22%  { box-shadow: inset 0 0 0 60px rgba(90,200,140,.20); filter: brightness(1.06); }
  34%  { box-shadow: inset 0 0 0 60px rgba(90,200,140,.06); filter: brightness(.985); }
  100% { box-shadow: inset 0 0 0 60px rgba(90,200,140,0); filter: brightness(1); }
}
.cell.commit-flash { animation: editflash 170ms steps(6) both; }

/* error cell indicator triangle */
.errtri {
  position: absolute; right: 0; top: 0;
  width: 0; height: 0;
  border-top: 7px solid #c0392b;
  border-left: 7px solid transparent;
}
.note-mark { position:absolute;left:0;top:0;width:0;height:0;border-top:6px solid #ce8a2c;border-right:6px solid transparent;}

/* frozen pane dividers */
.freeze-vline, .freeze-hline {
  position: absolute; z-index: 5; pointer-events: none;
  background: #c9d4cd;
  box-shadow: 1px 0 3px rgba(80,110,95,.18);
}
.freeze-hline { box-shadow: 0 1px 3px rgba(80,110,95,.18); }

/* hidden row/col col strip marks handled by headers */

/* overlay is a viewport-aligned float across the whole grid wrap */
#overlayLayer { position: absolute; inset: 0; pointer-events: none; z-index: 20; }
#gridScroller { position:absolute; inset:0; }
#overlayLayer > * { pointer-events: auto; }
.frzpane { display: none; }

/* hairline gridlines drawn per-cell */
#canvas.gridlines-on .cell { box-shadow: inset -1px 0 0 var(--grid-line), inset 0 -1px 0 var(--grid-line); }
#canvas.nogridlines .cell { box-shadow: none; }

/* keep resize grab-zones fully inside their clipped headers */
#colStripInner .resizer, #gridWrap .rsz-col { right: 0 !important; width: 4px; }
#rowStripInner .row-resizer { bottom: 0 !important; height: 4px; }
