/*    NOTATION GRID — The Heart of the UI
   ═══════════════════════════════════════════════════════════════════════ */
.notation-section {
  background: var(--bg-glass);
  border: 1px solid rgba(243, 185, 108, 0.15);
  border-radius: var(--radius-lg);
  overflow: hidden;
  margin-bottom: 40px;
  transition: all var(--transition-normal);
  animation: sectionFadeIn 0.35s ease forwards;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
}

.notation-section:hover {
  border-color: rgba(243, 185, 108, 0.3);
  box-shadow: 0 12px 48px rgba(0, 0, 0, 0.4);
  transform: translateY(-2px);
}


/* ─── Section Header ───────────────────────────────────────────────── */
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  gap: 10px 12px;
  flex-wrap: wrap;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--grid-border);
}

.section-header-left {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  flex: 1;
}

.section-header-right {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: flex-end;
}

.layakari-generator-group {
  display: flex;
  align-items: center;
  border: 1.5px solid var(--grid-border-strong);
  border-radius: 999px;
  background: var(--bg-elevated);
  overflow: hidden;
  height: 32px;
  width: 220px;
  transition: all var(--transition-fast);
}

.layakari-generator-group:hover {
  border-color: var(--accent-primary);
}

.layakari-generator-group select {
  box-sizing: border-box;
  flex: 1 1 0%;
  min-width: 0;
  display: block !important;
  text-align: center !important;
  text-align-last: center !important;
  border: none;
  border-right: 1.5px solid var(--grid-border-strong);
  background: transparent url('data:image/svg+xml;utf8,<svg fill="none" stroke="%238b7d6b" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path d="M6 9l6 6 6-6"/></svg>') no-repeat right 8px center;
  background-size: 10px;
  padding: 0 24px 0 12px;
  font-size: 0.78rem;
  font-weight: 500;
  height: 32px;
  line-height: 32px; /* Matches internal height for vertical centering */
  outline: none;
  cursor: pointer;
  color: var(--text-primary);
  appearance: none;
  -webkit-appearance: none;
}

.btn-generate-layakari {
  box-sizing: border-box;
  flex: 1 1 0%;
  min-width: 0;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  text-align: center !important;
  gap: 4px;
  border: none;
  background: var(--bg-secondary);
  color: var(--text-primary);
  font-size: 0.78rem;
  font-weight: 600;
  padding: 0;
  height: 100%;
  line-height: 1; /* Ensures flex centering is not offset by inherited line-height */
  cursor: pointer;
  transition: all var(--transition-fast);
  white-space: nowrap;
}

.btn-generate-layakari:hover {
  background: var(--accent-primary);
  color: #fff;
}

.btn-action-danger {
  color: var(--text-muted);
}

.btn-action-danger:hover {
  color: var(--danger) !important;
  background: rgba(231, 76, 60, 0.1) !important;
}

.section-type-badge {
  font-size: 0.68rem;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: var(--radius-xs);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  white-space: nowrap;
  font-family: var(--font-system);
}

.section-type-badge.mukh {
  background: rgba(243, 185, 108, 0.12);
  color: var(--accent-sam);
  border: 1px solid rgba(243, 185, 108, 0.20);
}

.section-type-badge.palta {
  background: rgba(42, 157, 143, 0.12);
  color: var(--accent-khali);
  border: 1px solid rgba(42, 157, 143, 0.20);
}

.section-type-badge.tihai {
  background: rgba(196, 120, 50, 0.12);
  color: var(--accent-taali);
  border: 1px solid rgba(196, 120, 50, 0.20);
}

.section-type-badge.dohra {
  background: rgba(74, 144, 217, 0.12);
  color: var(--info);
  border: 1px solid rgba(74, 144, 217, 0.20);
}

.section-type-badge.custom {
  background: rgba(176, 167, 142, 0.08);
  color: var(--text-secondary);
  border: 1px solid rgba(176, 167, 142, 0.15);
}

.section-label-input {
  background: transparent;
  border: 1px solid transparent;
  color: var(--text-primary);
  font-size: 0.88rem;
  font-weight: 600;
  padding: 3px 7px;
  border-radius: var(--radius-sm);
  outline: none;
  font-family: inherit;
  flex: 1;
  max-width: 360px;
  min-width: 180px;
  transition: all var(--transition-fast);
}

.section-label-input:hover {
  border-color: var(--grid-border);
}

.section-label-input:focus {
  border-color: var(--accent-primary);
  background: var(--bg-secondary);
}


/* ─── Notation Table ───────────────────────────────────────────────── */
.notation-table-wrapper {
  overflow-x: auto;
  padding: 8px 12px 12px;
}

.notation-table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
  min-width: 560px;
}


/* ─── Matra Numbers Row (the top header) ───────────────────────────── */
.markers-row th {
  padding: 5px 4px;
  font-size: 0.70rem;
  font-weight: 600;
  color: var(--text-muted);
  border-bottom: 2px solid var(--grid-border-strong);
  background: var(--bg-secondary);
  position: relative;
  text-align: center;
}

.markers-row th.vibhaag-start {
  border-left: 2.5px solid var(--grid-vibhaag);
}

.matra-num {
  color: var(--text-muted);
  font-size: 0.66rem;
  font-weight: 500;
  font-family: var(--font-mono, ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, monospace);
  font-variant-numeric: tabular-nums lining-nums;
  -webkit-font-feature-settings: "tnum" 1, "lnum" 1;
  font-feature-settings: "tnum" 1, "lnum" 1;
}


/* ─── Marker Badges (Sam/Taali/Khali) ─────────────────────────────── */
.marker-badge {
  display: inline-flex;
  margin: 0 auto;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  font-size: 0.70rem;
  font-weight: 700;
  line-height: 1;
  padding: 0;
  font-variant-numeric: tabular-nums lining-nums;
  -webkit-font-feature-settings: "tnum" 1, "lnum" 1;
  font-feature-settings: "tnum" 1, "lnum" 1;
  letter-spacing: -0.01em;
}

.marker-badge.sam {
  background: var(--accent-sam);
  color: #ffffff;
  box-shadow: none;
}

.marker-badge.taali {
  background: var(--accent-taali);
  color: #ffffff;
  box-shadow: none;
}

.marker-badge.khali {
  background: var(--accent-khali);
  color: #fff;
}

.marker-legend-tooltip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  margin-left: 6px;
  cursor: help;
  vertical-align: middle;
  opacity: 0.6;
  transition: all var(--transition-fast);
}

.marker-legend-tooltip:hover {
  opacity: 1;
  color: var(--accent-primary);
  transform: scale(1.1);
}


/* ─── Avartan Row (Bols Content) ──────────────────────────────────── */
.avartan-row td {
  border-bottom: 1px solid var(--grid-border);
}

.matra-cell {
  container-type: inline-size;
  padding: 8px 5px;
  text-align: center;
  vertical-align: top;
  cursor: pointer;
  transition: all var(--transition-fast);
  position: relative;
  min-height: 44px;
  height: auto;
  font-family: var(--font-system);
  font-size: var(--grid-font-size, 1.0rem) !important;
  font-weight: 500;
  overflow: visible;
  white-space: nowrap;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

.matra-cell:nth-child(even) {
  background-color: rgba(243, 185, 108, 0.02);
}

.matra-cell:hover {
  background: var(--grid-cell-hover);
  box-shadow: inset 0 0 12px rgba(243, 185, 108, 0.12);
}

.matra-cell.cell-active {
  background: var(--grid-cell-active);
  box-shadow: inset 0 0 0 2px var(--accent);
  z-index: 5;
}

/* Dynamic Marker-Specific Glows */
.matra-cell.cell-active-sam {
  box-shadow: 
    inset 0 0 0 2.5px var(--accent-sam),
    0 0 20px var(--accent-sam-glow);
  background: var(--accent-sam-glow);
}

.matra-cell.cell-active-taali {
  box-shadow: 
    inset 0 0 0 2.5px var(--accent-taali),
    0 0 15px var(--accent-taali-glow);
  background: var(--accent-taali-glow);
}

.matra-cell.cell-active-khali {
  box-shadow: 
    inset 0 0 0 2.5px var(--accent-khali),
    0 0 15px var(--accent-khali-glow);
  background: var(--accent-khali-glow);
}

/* ─── Multi-Select ─────────────────────────────────────────────────── */
.matra-cell.cell-selected {
  background: rgba(249, 115, 22, 0.15);
  box-shadow: inset 0 0 0 1.5px rgba(249, 115, 22, 0.5);
  z-index: 4;
}

.matra-cell.cell-selected:hover {
  background: rgba(249, 115, 22, 0.22);
}

.matra-cell.has-manual-highlight::after {
  content: '';
  position: absolute;
  top: 6px;
  right: 6px;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--text-accent, var(--accent-primary));
  box-shadow: 0 0 0 2px rgba(216, 90, 48, 0.14);
  pointer-events: none;
}

.bol-highlight-token.is-highlighted {
  display: inline-block;
  padding: 0 2px;
  border-radius: 4px;
  background: rgba(216, 90, 48, 0.12);
  color: var(--text-accent, var(--accent-primary));
  font-weight: 700;
  text-decoration: underline;
  text-decoration-thickness: 1.5px;
  text-underline-offset: 3px;
}

/* Floating Multi-Select Toolbar */
.multi-select-toolbar {
  position: fixed;
  z-index: 1000;
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 6px 10px;
  background: rgba(30, 22, 12, 0.92);
  border: 1px solid rgba(249, 115, 22, 0.35);
  border-radius: 10px;
  box-shadow:
    0 8px 32px rgba(0, 0, 0, 0.45),
    0 0 0 1px rgba(0, 0, 0, 0.15),
    0 0 24px rgba(249, 115, 22, 0.08);
  animation: toolbar-pop 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
  pointer-events: auto;
}

@keyframes toolbar-pop {
  0% { opacity: 0; transform: translateY(6px) scale(0.95); }
  100% { opacity: 1; transform: translateY(0) scale(1); }
}

.multi-select-toolbar .toolbar-badge {
  font-size: 0.72rem;
  font-weight: 600;
  color: rgba(249, 115, 22, 0.9);
  padding: 3px 8px;
  background: rgba(249, 115, 22, 0.1);
  border-radius: 6px;
  white-space: nowrap;
  margin-right: 4px;
  letter-spacing: 0.02em;
}

.multi-select-toolbar .toolbar-divider {
  width: 1px;
  height: 20px;
  background: rgba(243, 185, 108, 0.15);
  margin: 0 2px;
}

.multi-select-toolbar .toolbar-btn {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 5px 10px;
  border: none;
  background: transparent;
  color: rgba(255, 255, 255, 0.75);
  font-size: 0.75rem;
  font-weight: 500;
  font-family: inherit;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.15s ease;
  white-space: nowrap;
}

.multi-select-toolbar .toolbar-btn:hover {
  background: rgba(249, 115, 22, 0.15);
  color: #f3b96c;
}

.multi-select-toolbar .toolbar-btn:active {
  background: rgba(249, 115, 22, 0.25);
  transform: scale(0.96);
}

.multi-select-toolbar .toolbar-btn svg {
  flex-shrink: 0;
  opacity: 0.8;
}

.multi-select-toolbar .toolbar-btn:hover svg {
  opacity: 1;
}

.multi-select-toolbar .toolbar-btn.toolbar-btn--danger {
  color: rgba(239, 68, 68, 0.8);
}

.multi-select-toolbar .toolbar-btn.toolbar-btn--danger:hover {
  background: rgba(239, 68, 68, 0.12);
  color: #f87171;
}

.multi-select-toolbar .toolbar-btn.toolbar-btn--swap {
  color: rgba(167, 139, 250, 0.85);
}

.multi-select-toolbar .toolbar-btn.toolbar-btn--swap:hover {
  background: rgba(167, 139, 250, 0.12);
  color: #c4b5fd;
}

.multi-select-toolbar .toolbar-btn.toolbar-btn--highlight {
  color: rgba(250, 170, 120, 0.88);
}

.multi-select-toolbar .toolbar-btn.toolbar-btn--highlight:hover,
.multi-select-toolbar .toolbar-btn.toolbar-btn--highlight.is-active {
  background: rgba(216, 90, 48, 0.14);
  color: #ffb58d;
}

/* Bol Entry Animation */
@keyframes bol-pop {
  0% { transform: scale(0.94); opacity: 0.7; }
  50% { transform: scale(1.05); }
  100% { transform: scale(1); opacity: 1; }
}

.matra-cell.bol-updated .bol-content {
  animation: bol-pop 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.matra-cell.vibhaag-start {
  border-left: 2.5px solid var(--grid-vibhaag);
}

.matra-cell.sam-column {
  background: var(--accent-sam-glow);
}

.matra-cell.sam-column:hover {
  background: rgba(243, 185, 108, 0.10);
}


/* ─── Symbols Row (चिन्ह / Markers below bols) ────────────────────── */
.symbols-row td {
  border-bottom: 2px solid var(--grid-border-strong);
}

.symbol-cell {
  padding: 3px 4px;
  text-align: center;
  vertical-align: middle;
  height: 26px;
}

.symbol-cell.vibhaag-start {
  border-left: 2.5px solid var(--grid-vibhaag);
}


/* ─── Row Actions ──────────────────────────────────────────────────── */
.row-actions {
  max-width: 74px;
  padding: 3px;
  text-align: center;
  border-bottom: 1px solid var(--grid-border);
  opacity: 0;
  transition: opacity var(--transition-fast);
}

.avartan-row:hover .row-actions,
.avartan-row:hover+.symbols-row .row-actions {
  opacity: 1;
}

.btn-row-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  max-width: 22px;
  height: 22px;
  border: none;
  border-radius: 100px;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.btn-row-action:hover {
  background: var(--bg-elevated);
  color: var(--text-primary);
}

.btn-row-action:disabled {
  opacity: 0.25;
  cursor: not-allowed;
}


/* ─── Avartan Block Header (Label + Actions) ─────────────────────── */
.avartan-block {
  position: relative;
  transition: box-shadow var(--transition-normal), border-color var(--transition-normal);
  border-radius: var(--radius-sm);
}

.avartan-block-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 4px 12px;
  opacity: 0;
  transition: opacity var(--transition-normal);
}

.avartan-block:hover .avartan-block-header,
.avartan-block.has-custom-wrap .avartan-block-header,
.avartan-block.has-wrap-popover-open .avartan-block-header {
  opacity: 1;
}

@media (hover: none), (max-width: 768px) {
  .avartan-block-header {
    opacity: 1;
  }
}

.avartan-header-left {
  display: flex;
  align-items: center;
  gap: 8px;
}

.avartan-label {
  font-size: 0.68rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.avartan-actions {
  display: flex;
  align-items: center;
  gap: 4px;
}

.btn-avartan-action {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  border: 1px solid transparent;
  border-radius: var(--radius-xs);
  background: transparent;
  color: var(--text-muted);
  font-size: 0.66rem;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition-fast);
  font-family: inherit;
  white-space: nowrap;
}

.btn-avartan-action:hover {
  background: var(--bg-elevated);
  border-color: var(--grid-border);
  color: var(--text-primary);
}

.btn-avartan-action--danger:hover {
  background: rgba(231, 76, 60, 0.08);
  border-color: rgba(231, 76, 60, 0.25);
  color: var(--danger);
}

.btn-avartan-action:disabled {
  opacity: 0.2;
  cursor: not-allowed;
}

.btn-avartan-action svg {
  flex-shrink: 0;
}

.btn-avartan-wrap.is-custom {
  background: var(--accent-subtle);
  border-color: var(--accent-sam-glow);
  color: var(--accent-primary);
  font-weight: 600;
}

.btn-avartan-wrap.is-active {
  background: var(--bg-elevated);
  border-color: var(--grid-border);
  color: var(--text-primary);
}

.btn-avartan-wrap .wrap-pill-icon {
  opacity: 0.8;
  flex-shrink: 0;
}

.btn-avartan-wrap .wrap-pill-chevron {
  opacity: 0.6;
  flex-shrink: 0;
  transition: transform 0.18s ease;
}

.btn-avartan-wrap.is-active .wrap-pill-chevron {
  transform: rotate(180deg);
}

/* ─── Avartan Target Highlight (Quick Entry) ─────────────────────── */
.avartan-block.avartan-target-highlight {
  box-shadow: inset 0 0 0 2px var(--accent-primary), 0 0 16px rgba(212, 148, 58, 0.15);
  border-radius: var(--radius-sm);
}

.avartan-block.avartan-target-highlight .avartan-block-header {
  opacity: 1;
}

.avartan-block.avartan-target-highlight .avartan-label {
  color: var(--accent-primary);
}

/* ─── Quick Entry Context Indicator ──────────────────────────────── */
.qe-context-indicator {
  display: none;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  font-size: 0.72rem;
  color: var(--accent-primary);
  font-weight: 500;
  background: var(--bg-secondary); border: 1px solid var(--border-strong);
  border-radius: var(--radius-xs);
  letter-spacing: 0.01em;
}

.qe-context-indicator strong {
  color: var(--text-primary);
  font-weight: 600;
}

.qe-context-indicator svg {
  color: var(--accent-primary);
  opacity: 0.7;
}

/* ─── Quick Entry Pulse Animation ────────────────────────────────── */
@keyframes qePulse {
  0% { box-shadow: 0 0 0 0 rgba(212, 148, 58, 0.25); }
  50% { box-shadow: 0 0 0 4px rgba(212, 148, 58, 0.12); }
  100% { box-shadow: 0 0 0 0 rgba(212, 148, 58, 0); }
}

.quick-entry-bar.qe-pulse {
  animation: qePulse 0.8s ease-out;
  border-color: rgba(243, 185, 108, 0.30);
}


/* ─── Bol Content Styling ──────────────────────────────────────────── */
.bol-content {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  overflow: visible;
  white-space: nowrap !important;
}

.bol-content.empty {
  color: var(--text-muted);
  opacity: 0.25;
  font-size: 1.1rem;
  justify-content: center;
}

.bol-content.thah {
  font-weight: 600;
  color: var(--text-primary);
  font-size: clamp(0.65rem, 25cqi, var(--grid-font-size, 1.0rem)) !important;
  letter-spacing: -0.015em;
  white-space: nowrap !important;
  line-height: 1.35;
  text-rendering: optimizeLegibility;
}

/* Multi-bol grouping (Dugun / Tigun / Chaugun) */
.bol-group {
  display: inline-flex;
  flex-direction: column;
  align-items: stretch;
  width: fit-content;
  max-width: none;
  min-width: 0;
  margin: 0 auto;
  white-space: nowrap !important;
}

.bol-group-inner {
  display: inline-flex;
  gap: 0;
  flex-wrap: nowrap !important;
  white-space: nowrap !important;
  justify-content: center;
  width: fit-content;
  max-width: none;
  min-width: 0;
  padding: 0 4px;
  line-height: 1.35;
}

.grouped-bol {
  display: inline-block;
  font-size: clamp(0.65rem, 25cqi, var(--grid-font-size, 1.0rem)) !important;
  font-weight: 500;
  color: var(--text-primary);
  white-space: nowrap !important;
  max-width: none;
  line-height: 1.35;
  letter-spacing: -0.02em;
  text-rendering: optimizeLegibility;
}

/* Bracket underneath grouped bols */
.bol-bracket {
  width: 100%;
  height: 6px;
  min-width: 0;
  margin-top: 1px;
  border: 1.2px solid var(--accent-taali);
  border-top: none;
  border-radius: 0 0 5px 5px;
  opacity: 0.65;
}





/* ─── Add Buttons ──────────────────────────────────────────────────── */
.section-footer-actions {
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: center;
  gap: 16px;
  width: 100%;
  border-top: 1px solid var(--grid-border);
  box-sizing: border-box;
  flex-wrap: wrap;
  padding: 4px 0;
}

.btn-add-avartan, .btn-insert-section-inline {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  flex: 0 0 auto;
  width: auto;
  padding: 10px 0;
  margin: 0;
  border: none;
  border-radius: 0;
  background: transparent;
  font-size: 0.75rem;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition-fast);
  font-family: inherit;
  color: var(--text-muted);
  box-sizing: border-box;
  outline: none;
  -webkit-appearance: none;
}

.btn-add-avartan:hover, .btn-insert-section-inline:hover {
  background: var(--bg-secondary);
  color: var(--text-primary);
}

.btn-insert-section-inline {
  border-left: none;
}

.add-section-bar {
  display: flex;
  justify-content: center;
  padding: 8px 0 40px;
}

.add-section-split-btn {
  display: inline-flex;
  position: relative;
  border: 2px solid var(--grid-border);
  border-radius: 100px;
  overflow: hidden;
  transition: all var(--transition-normal);
  background: transparent;
}

.add-section-split-btn:hover {
  border-color: var(--accent-primary);
  border-style: solid;
  background: rgba(212, 148, 58, 0.04);
  box-shadow: none;
}

.add-section-split-btn:hover .btn-add-section-primary {
  color: var(--accent-primary);
}

.btn-add-section-primary {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 9px 12px 9px 18px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-size: 0.8rem;
  font-weight: 500;
  cursor: pointer;
  font-family: inherit;
  transition: color var(--transition-normal);
}


/* ═══════════════════════════════════════════════════════════════════════
   ANIMATIONS
   ═══════════════════════════════════════════════════════════════════════ */
@keyframes sectionFadeIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ═══════════════════════════════════════════════════════════════════════
   Bayan Modulation Floating Apple Pill (P/F/G/C Stamps)
   ═══════════════════════════════════════════════════════════════════════ */
.apple-floating-pill {
  position: absolute;
  bottom: calc(100% + 14px);
  left: 50%;
  transform: translateX(-50%) translateY(0) scale(1);
  transform-origin: center bottom;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 44px;
  padding: 4px 10px;
  border-radius: 9999px;
  background: var(--bg-tertiary, #FFFDF9);
  border: 1px solid var(--border-strong, rgba(226, 212, 196, 0.85));
  box-shadow: 0 10px 32px rgba(0, 0, 0, 0.14), 0 2px 8px rgba(0, 0, 0, 0.04);
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  user-select: none;
  box-sizing: border-box;
  z-index: 250;
  transition: opacity 0.22s cubic-bezier(0.16, 1, 0.3, 1), transform 0.26s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  opacity: 1;
  pointer-events: auto;
  white-space: nowrap;
}

.apple-floating-pill.is-collapsed {
  opacity: 0;
  pointer-events: none;
  transform: translateX(-50%) translateY(14px) scale(0.92);
  transition: opacity 0.18s ease-in, transform 0.18s ease-in;
}

[data-theme="dark"] .apple-floating-pill {
  background: rgba(28, 28, 30, 0.94);
  border-color: rgba(255, 255, 255, 0.14);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.45), 0 2px 8px rgba(0, 0, 0, 0.2);
}

.apple-floating-pill .pill-label {
  font-family: var(--font-system);
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted, #8a7a6d);
  padding: 0 4px;
}

.apple-floating-pill .pill-divider {
  width: 1px;
  height: 18px;
  background: var(--grid-border, rgba(0, 0, 0, 0.1));
  margin: 0 2px;
}

[data-theme="dark"] .apple-floating-pill .pill-divider {
  background: rgba(255, 255, 255, 0.12);
}

.apple-floating-pill button {
  min-height: 0 !important;
}

.pill-toggle-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px !important;
  height: 28px !important;
  min-width: 28px !important;
  max-width: 28px !important;
  min-height: 28px !important;
  max-height: 28px !important;
  border-radius: 50% !important;
  border: none;
  background: transparent;
  color: var(--text-muted, #8a7a6d);
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  padding: 0 !important;
  outline: none;
  position: relative;
  flex-shrink: 0;
  box-sizing: border-box !important;
}

.pill-toggle-btn:hover {
  background: transparent !important;
  color: var(--accent-primary, #C85A32);
}

[data-theme="dark"] .pill-toggle-btn:hover {
  background: transparent !important;
  color: #f97316;
}

.pill-expanded-content {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.pill-stamp-item {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px !important;
  height: 28px !important;
  min-height: 28px !important;
  max-height: 28px !important;
  border-radius: 9999px !important;
  font-family: var(--font-system);
  font-size: 0.74rem;
  font-weight: 600;
  cursor: grab;
  transition: all 0.18s cubic-bezier(0.16, 1, 0.3, 1);
  border: 1px solid transparent;
  background: transparent;
  outline: none;
  box-sizing: border-box !important;
  flex-shrink: 0;
}

.pill-stamp-item .stamp-letter {
  font-weight: 800;
}

.pill-stamp-item .stamp-label {
  font-size: 0.72rem;
  font-weight: 600;
}

.pill-stamp-item:hover {
  transform: translateY(-2px) scale(1.04);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.pill-stamp-item:active {
  transform: scale(0.96);
  cursor: grabbing;
}

.pill-stamp-item.active {
  box-shadow: 0 0 0 2px var(--bg-card, #FFFDF9), 0 0 0 4px currentColor;
}

/* Stamp Specific Themes matching user screenshot */
.pill-stamp-item[data-stamp="P"] {
  background: rgba(99, 102, 241, 0.09);
  color: #4f46e5;
  border-color: rgba(99, 102, 241, 0.28);
}
[data-theme="dark"] .pill-stamp-item[data-stamp="P"] {
  background: rgba(99, 102, 241, 0.18);
  color: #818cf8;
  border-color: rgba(99, 102, 241, 0.38);
}

.pill-stamp-item[data-stamp="F"] {
  background: rgba(16, 185, 129, 0.09);
  color: #059669;
  border-color: rgba(16, 185, 129, 0.28);
}
[data-theme="dark"] .pill-stamp-item[data-stamp="F"] {
  background: rgba(16, 185, 129, 0.18);
  color: #34d399;
  border-color: rgba(16, 185, 129, 0.38);
}

.pill-stamp-item[data-stamp="G"] {
  background: rgba(217, 119, 6, 0.09);
  color: #d97706;
  border-color: rgba(217, 119, 6, 0.28);
}
[data-theme="dark"] .pill-stamp-item[data-stamp="G"] {
  background: rgba(217, 119, 6, 0.18);
  color: #fbbf24;
  border-color: rgba(217, 119, 6, 0.38);
}

.pill-stamp-item[data-stamp="C"] {
  background: rgba(219, 39, 119, 0.09);
  color: #db2777;
  border-color: rgba(219, 39, 119, 0.28);
}
[data-theme="dark"] .pill-stamp-item[data-stamp="C"] {
  background: rgba(219, 39, 119, 0.18);
  color: #f472b6;
  border-color: rgba(219, 39, 119, 0.38);
}

.pill-stamp-item[data-stamp="HINT"] {
  background: rgba(200, 90, 50, 0.09);
  color: var(--accent-primary, #C85A32);
  border-color: rgba(200, 90, 50, 0.28);
}
[data-theme="dark"] .pill-stamp-item[data-stamp="HINT"] {
  background: rgba(249, 115, 22, 0.18);
  color: #fb923c;
  border-color: rgba(249, 115, 22, 0.38);
}
.pill-stamp-item[data-stamp="HINT"]:hover {
  background: rgba(200, 90, 50, 0.16);
  border-color: rgba(200, 90, 50, 0.45);
}
[data-theme="dark"] .pill-stamp-item[data-stamp="HINT"]:hover {
  background: rgba(249, 115, 22, 0.26);
  border-color: rgba(249, 115, 22, 0.55);
}

.pill-stamp-item[data-stamp="ERASE"] {
  background: transparent !important;
  color: var(--text-muted, #71717a);
  border-color: rgba(0, 0, 0, 0.1);
}
[data-theme="dark"] .pill-stamp-item[data-stamp="ERASE"] {
  background: transparent !important;
  color: #a1a1aa;
  border-color: rgba(255, 255, 255, 0.12);
}
.pill-stamp-item[data-stamp="ERASE"]:hover {
  background: transparent !important;
  color: #dc2626;
  border-color: rgba(220, 38, 38, 0.4);
}

/* Entry Bar Pencil Trigger Button */
.qe-pencil-trigger {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  padding: 0 12px;
  height: 28px;
  min-height: 28px !important;
  max-height: 28px !important;
  line-height: 26px;
  border-radius: 9999px !important;
  border: 1px solid var(--border-color, rgba(226, 212, 196, 0.85));
  background: var(--bg-tertiary, #FFFDF9);
  color: var(--text-secondary, #665);
  font-size: 0.72rem;
  font-family: inherit;
  font-weight: 600;
  cursor: pointer;
  position: relative;
  transition: all 0.18s cubic-bezier(0.16, 1, 0.3, 1);
  box-sizing: border-box;
  flex-shrink: 0;
}

.qe-pencil-trigger:hover {
  background: var(--bg-secondary, rgba(0, 0, 0, 0.05));
  border-color: var(--accent-primary, #C85A32);
  color: var(--accent-primary, #C85A32);
}

.qe-pencil-trigger.active {
  background: rgba(200, 90, 50, 0.12);
  border-color: var(--accent-primary, #C85A32);
  color: var(--accent-primary, #C85A32);
  font-weight: 600;
}

[data-theme="dark"] .qe-pencil-trigger {
  background: var(--bg-tertiary, #141414);
  border-color: rgba(255, 255, 255, 0.12);
}

.qe-pencil-trigger .active-indicator-dot {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  border: 1.5px solid var(--bg-tertiary, #FFFDF9);
  display: none;
}

.qe-pencil-trigger.has-active-tool .active-indicator-dot {
  display: block;
}





/* Corner Badges inside Matra Cells */
.stroke-mod-badge {
  position: absolute;
  top: 3px;
  right: 3px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  font-size: 9px;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  pointer-events: none;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12);
  z-index: 3;
  transition: transform 0.15s cubic-bezier(0.16, 1, 0.3, 1);
}

.stroke-mod-badge.mod-P {
  background: #e0e7ff;
  color: #3730a3;
  border: 1px solid #a5b4fc;
}
[data-theme="dark"] .stroke-mod-badge.mod-P {
  background: rgba(99, 102, 241, 0.25);
  color: #a5b4fc;
  border-color: #6366f1;
}

.stroke-mod-badge.mod-F {
  background: #d1fae5;
  color: #065f46;
  border: 1px solid #6ee7b7;
}
[data-theme="dark"] .stroke-mod-badge.mod-F {
  background: rgba(16, 185, 129, 0.25);
  color: #6ee7b7;
  border-color: #10b981;
}

.stroke-mod-badge.mod-G {
  background: #fef3c7;
  color: #92400e;
  border: 1px solid #fcd34d;
}
[data-theme="dark"] .stroke-mod-badge.mod-G {
  background: rgba(245, 158, 11, 0.25);
  color: #fcd34d;
  border-color: #f59e0b;
}

.stroke-mod-badge.mod-C {
  background: #ffe4e6;
  color: #9f1239;
  border: 1px solid #fda4af;
}
[data-theme="dark"] .stroke-mod-badge.mod-C {
  background: rgba(236, 72, 153, 0.25);
  color: #fda4af;
  border-color: #ec4899;
}

/* Drag Over Highlight for Cells */
.matra-cell.stamp-drag-over {
  background-color: rgba(200, 90, 50, 0.12) !important;
  outline: 2px dashed var(--accent-primary, #C85A32) !important;
  outline-offset: -2px;
}

/* When Stamp Tool is Active (cursor crosshair) */
body.stamp-tool-active .matra-cell {
  cursor: crosshair !important;
}
body.stamp-tool-active .matra-cell:hover {
  background-color: rgba(200, 90, 50, 0.08);
}

/* Apple Hint Sheet Animations & Dark Mode */
@keyframes appleHintFadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes appleHintScaleUp {
  from { opacity: 0; transform: scale(0.94); }
  to { opacity: 1; transform: scale(1); }
}

[data-theme="dark"] .apple-hint-modal {
  background: rgba(30, 28, 26, 0.96) !important;
  border-color: rgba(255, 255, 255, 0.12) !important;
  box-shadow: 0 28px 64px rgba(0, 0, 0, 0.6), 0 4px 16px rgba(0, 0, 0, 0.3) !important;
}

[data-theme="dark"] .apple-hint-modal textarea {
  background: rgba(20, 18, 16, 0.8) !important;
  border-color: rgba(255, 255, 255, 0.15) !important;
  color: #fff !important;
}

