/* ==========================================================================
   ESSENCE TABLE ENHANCEMENTS (Design A grid)
   Presentation-only layer for #resultsTable. Every rule is gated by a class
   that js/essence_table_enhancements.js puts on the table from the user's
   settings (Configuration > Table Enhancements): .etx-on = "New table UI" is
   on, the rest follow the individual switches. Switching "New table UI" off
   removes every class and returns the classic table. Cell text, cell count
   and click handlers are never touched. Flat 2.0: no shadows on controls, no
   gradients, no transforms on controls.
   ========================================================================== */

#resultsTable {
    --etx-fs: var(--table-font-size);
    --etx-line: #cfd8c6;
    --etx-now: rgba(151, 184, 129, 0.14);
    --etx-grp-bg: #f7f9f5;
    --etx-grp-fg: #9ca3af;
    /* Design A surfaces + tones (DESIGN.md palette) */
    --etx-card: #ffffff;
    --etx-rule: #eef2ef;
    --etx-rule2: #e2e8f0;
    --etx-tx: #1f2937;
    --etx-tx2: #4b5563;
    --etx-mut: #9ca3af;
    --etx-sage: #97B881;
    --etx-coral: #E88D78;
    --etx-ocean: #8FB8CA;
    --etx-lav: #C4B5D4;
    --etx-sun: #ECD489;
    --etx-ess-bg: #e3edde;
    --etx-ess-fg: #5f8449;
    --etx-py-bg: #fbe3dd;
    --etx-py-fg: #b8573f;
    --etx-pm-bg: #e3eff4;
    --etx-pm-fg: #4f7d90;
    --etx-run-bg: rgba(143, 184, 202, 0.16);
    --etx-run-bd: rgba(143, 184, 202, 0.42);
    --etx-pin-bg: rgba(196, 181, 212, 0.26);
    --etx-pin-bd: rgba(158, 143, 176, 0.45);
    --etx-chal-bg: rgba(232, 141, 120, 0.15);
    --etx-chal-bd: rgba(232, 141, 120, 0.42);
    --etx-pc-bg: rgba(143, 184, 202, 0.18);
    --etx-pc-bd: rgba(109, 148, 166, 0.40);
    --etx-mst-bg: rgba(196, 181, 212, 0.34);
    --etx-mst-fg: #76668a;
}
html.dark #resultsTable {
    --etx-line: #3a4535;
    --etx-now: rgba(168, 204, 143, 0.13);
    --etx-grp-bg: var(--dark-surface, #1b1f23);
    --etx-grp-fg: var(--dark-text-muted, #9aa39d);
    --etx-card: var(--dark-card, #20252a);
    --etx-rule: var(--dark-border-soft, #2d3532);
    --etx-rule2: var(--dark-border, #39413f);
    --etx-tx: var(--dark-text, #f2f4ef);
    --etx-tx2: var(--dark-text-secondary, #c4cbc5);
    --etx-mut: var(--dark-text-muted, #9aa39d);
    --etx-ess-bg: rgba(168, 204, 143, 0.20);
    --etx-ess-fg: var(--dark-primary, #a8cc8f);
    --etx-py-bg: rgba(240, 160, 138, 0.20);
    --etx-py-fg: var(--dark-accent, #f0a08a);
    --etx-pm-bg: rgba(155, 201, 217, 0.18);
    --etx-pm-fg: var(--dark-info, #9bc9d9);
    --etx-run-bg: rgba(155, 201, 217, 0.13);
    --etx-run-bd: rgba(155, 201, 217, 0.35);
    --etx-pin-bg: rgba(196, 181, 212, 0.18);
    --etx-pin-bd: rgba(196, 181, 212, 0.40);
    --etx-chal-bg: rgba(240, 160, 138, 0.14);
    --etx-chal-bd: rgba(240, 160, 138, 0.38);
    --etx-pc-bg: rgba(155, 201, 217, 0.14);
    --etx-pc-bd: rgba(155, 201, 217, 0.36);
    --etx-mst-bg: rgba(196, 181, 212, 0.24);
    --etx-mst-fg: #dfcceb;
}

/* ---------- Table size (S / M / L). M keeps the original look. ---------- */
#resultsTable.etx-size-s { --etx-fs: min(var(--table-font-size), 13px); }
#resultsTable.etx-size-l { --etx-fs: max(var(--table-font-size), 16px); }

#resultsTable.etx-size-s th:not(:first-child),
#resultsTable.etx-size-s td:not(:first-child) {
    min-width: 34px;
    padding: 0.3rem 0.15rem !important;
    font-size: var(--etx-fs) !important;
}
#resultsTable.etx-size-l th:not(:first-child),
#resultsTable.etx-size-l td:not(:first-child) {
    min-width: 66px;
    padding: 0.7rem 0.5rem !important;
    font-size: var(--etx-fs) !important;
}

/* Small size on phones: let the sticky label column shrink so more years fit. */
@media (max-width: 640px) {
    #resultsTable.etx-size-s th:first-child,
    #resultsTable.etx-size-s thead th:first-child.sticky,
    #resultsTable.etx-size-s td:first-child {
        min-width: 88px !important;
        width: 96px !important;
        max-width: 112px !important;
        padding-left: 0.5rem !important;
        padding-right: 0.35rem !important;
        font-size: 12px !important;
        white-space: normal;
        line-height: 1.15;
    }
}

/* ---------- Design A frame: neutral header, quiet label column, row rules only ---------- */
#resultsTable.etx-on thead th:not(:first-child) {
    background-color: var(--etx-card);
    color: var(--etx-mut);
    background-image: none;
    font-size: calc(var(--etx-fs) * 0.8) !important;
    font-weight: 600;
    border-bottom: 1px solid var(--etx-rule2);
}
#resultsTable.etx-on thead th:first-child {
    background-color: var(--etx-card) !important;
    background-image: none !important;
    color: var(--etx-mut) !important;
    text-shadow: none !important;
    font-size: 10px !important;
    font-weight: 700 !important;
    letter-spacing: 0.08em !important;
    text-transform: uppercase;
    border-right: 1px solid var(--etx-rule2) !important;
    border-bottom: 1px solid var(--etx-rule2);
}
/* dark-mode.css paints the header with gradients (and the corner Coral); keep it neutral */
html.dark #resultsTable.etx-on thead th:first-child.sticky,
html.dark #resultsTable.etx-on thead th:first-child { background: var(--etx-card) !important; }
html.dark #resultsTable.etx-on thead th:not(:first-child) { background: var(--etx-card) !important; }
#resultsTable.etx-on tr[data-category="age"] td:not(:first-child) {
    color: var(--etx-tx);
    font-family: Quicksand, Poppins, sans-serif;
    font-weight: 700;
}
#resultsTable.etx-on tbody td:first-child {
    background-color: var(--etx-card) !important;
    background-image: none !important;
    color: var(--etx-tx2) !important;
    font-weight: 600 !important;
    border-right: 1px solid var(--etx-rule2) !important;
}
#resultsTable.etx-on tbody tr[data-category="personalMonth"] td:first-child { color: var(--etx-mut) !important; }
#resultsTable.etx-on tbody tr { border-bottom-color: var(--etx-rule); }
/* Row rules only (no column lines), except the four number rows, which keep their original cells. */
#resultsTable.etx-on tbody tr:not([data-category="hiddenEssence"]):not([data-category="essence"]):not([data-category="personalYear"]):not([data-category="personalMonth"]) td:not(:first-child):not(.border-x-sage):not(.border-x-coral) { border-right-color: transparent; }
/* Without group headers, a tone rail on the label tells the groups apart. */
#resultsTable.etx-on:not(.etx-grouped) tr[data-etx-grp="transit"] td:first-child { box-shadow: inset 3px 0 0 var(--etx-ocean); }
#resultsTable.etx-on:not(.etx-grouped) tr[data-etx-grp="essence"] td:first-child { box-shadow: inset 3px 0 0 var(--etx-sage); }
#resultsTable.etx-on:not(.etx-grouped) tr[data-etx-grp="cycles"] td:first-child { box-shadow: inset 3px 0 0 var(--etx-lav); }
#resultsTable.etx-on:not(.etx-grouped) tr[data-etx-grp="months"] td:first-child { box-shadow: inset 3px 0 0 var(--etx-sun); }

/* ---------- Design A card: plain flat card, no accent bar, no edge fade ---------- */
#essenceChartHeader:has(#resultsTable.etx-on) {
    background: #ffffff !important;
    border: 1px solid #e2e8f0 !important;
    border-radius: 20px !important;
    box-shadow: none !important;
}
html.dark #essenceChartHeader:has(#resultsTable.etx-on) {
    background: var(--dark-card, #20252a) !important;
    border-color: var(--dark-border, #39413f) !important;
}
#essenceChartHeader:has(#resultsTable.etx-on) > .essence-shell-accent { display: none; }
#essenceChartHeader:has(#resultsTable.etx-on) .essence-table-scroll { background: transparent; }
#essenceChartHeader:has(#resultsTable.etx-on) .essence-table-scroll::after { display: none; }
#essenceChartHeader:has(#resultsTable.etx-on) .table-container { -webkit-mask-image: none; mask-image: none; }

/* ---------- Header block: Year line + Age line read as one two-line header ---------- */
#resultsTable.etx-on thead th:not(:first-child) { border-bottom-color: transparent; }
#resultsTable.etx-on tr[data-category="age"] td:not(:first-child) {
    background-color: var(--etx-card);
    border-bottom: 1px solid var(--etx-rule2) !important;
}
#resultsTable.etx-on tr[data-category="age"] td:first-child {
    font-size: 10px !important;
    font-weight: 700 !important;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--etx-mut) !important;
    border-bottom: 1px solid var(--etx-rule2) !important;
}
/* The current column's header carries a NOW tag. */
#resultsTable.etx-on thead th.etx-now { padding-top: 15px !important; }
#resultsTable.etx-on thead th.etx-now::before {
    content: "NOW";
    position: absolute;
    top: 3px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 8px;
    font-weight: 800;
    letter-spacing: 0.12em;
    line-height: 1;
    color: #fff;
    pointer-events: none;
}

/* ---------- Label column widths (desktop / tablet / phone) ---------- */
#resultsTable.etx-on th:first-child,
#resultsTable.etx-on td:first-child {
    min-width: 160px !important;
    width: 160px;
    max-width: 160px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
#resultsTable.etx-on .etx-gbtn { white-space: nowrap; }
/* Group names run across the row (like the design) instead of clipping in the label column. */
#resultsTable.etx-on tr.etx-group th:first-child { overflow: visible; }
#resultsTable.etx-on tr.etx-group .etx-gbtn {
    width: max-content;
    min-width: 100%;
    position: relative;
    z-index: 1;
    background: var(--etx-grp-bg);
}
@media (max-width: 1023.98px) {
    #resultsTable.etx-on th:first-child,
    #resultsTable.etx-on td:first-child { min-width: 120px !important; width: 120px; max-width: 120px; }
}
/* Phone: 80px column with short labels (First, Father, Hidden, P. Year, Jan...). The full
   text stays in the cell for everything that reads it; only its rendering is swapped. */
@media (max-width: 640px) {
    #resultsTable.etx-on th:first-child,
    #resultsTable.etx-on thead th:first-child.sticky,
    #resultsTable.etx-on td:first-child {
        min-width: 80px !important;
        width: 80px !important;
        max-width: 80px !important;
        padding-left: 8px !important;
        padding-right: 4px !important;
        white-space: nowrap;
    }
    #resultsTable.etx-on tbody td:first-child[data-etx-short] { font-size: 0 !important; }
    #resultsTable.etx-on tbody td:first-child[data-etx-short] > * { display: none; }
    /* ::before, because ::after already draws the sticky column's edge shadow */
    #resultsTable.etx-on tbody td:first-child[data-etx-short]::before {
        content: attr(data-etx-short);
        position: static;
        display: inline;
        width: auto;
        height: auto;
        background: none;
        font-size: 11px;
        letter-spacing: 0.01em;
    }
    #resultsTable.etx-on tr[data-category="age"] td:first-child[data-etx-short]::before { font-size: 10px; }
    /* global mobile rule gives every button 44px; group rows stay compact (32px) */
    #resultsTable.etx-on tr.etx-group .etx-gbtn { min-height: 32px !important; height: 32px; }
    #resultsTable.etx-on tr.etx-group th { height: 32px; padding-top: 0 !important; padding-bottom: 0 !important; }
}

/* ---------- Personal Year cycle dividers (a new 1-9 cycle starts where PY = 1) ---------- */
#resultsTable.etx-cyc td.etx-cyc,
#resultsTable.etx-cyc th.etx-cyc {
    border-left: 2px solid color-mix(in srgb, var(--etx-coral) 55%, var(--etx-rule2));
}

/* ---------- Fade the past: one translucent overlay (see updateFade) ---------- */
.table-container { position: relative; }
#etxFade {
    position: absolute;
    top: 0;
    display: none;
    z-index: 15;
    pointer-events: none;
    background: rgba(255, 255, 255, 0.5);
}
html.dark #etxFade { background: rgba(20, 24, 28, 0.5); }

/* ---------- Transit letter runs: one rounded block behind the cells of a run ---------- */
#resultsTable.etx-runs td.etx-r-in:not(.etx-r-last) { border-right-color: transparent; }
#resultsTable.etx-runs td.etx-r-in.etx-r-hide {
    color: transparent !important;
    font-size: 0 !important;
}
#resultsTable.etx-runs td.etx-r-in { position: relative; z-index: 0; }
#resultsTable.etx-runs td.etx-r-in:not(.etx-now) { background-color: transparent !important; }
html.dark #resultsTable.etx-runs tr[data-category="transitLetter"] td.etx-r-in:not(.etx-now) { background-color: transparent !important; }
#resultsTable.etx-runs td.etx-r-in::before {
    content: "";
    position: absolute;
    z-index: -1;
    top: 4px;
    bottom: 4px;
    left: 0;
    right: 0;
    background: var(--etx-run-bg);
    border-top: 1px solid var(--etx-run-bd);
    border-bottom: 1px solid var(--etx-run-bd);
    pointer-events: none;
}
#resultsTable.etx-runs td.etx-r-first::before { left: 3px; border-left: 1px solid var(--etx-run-bd); border-radius: 8px 0 0 8px; }
#resultsTable.etx-runs td.etx-r-last::before { right: 3px; border-right: 1px solid var(--etx-run-bd); border-radius: 0 8px 8px 0; }
#resultsTable.etx-runs td.etx-r-in:not(.etx-r-last)::before { right: -1px; } /* bridge the collapsed cell border */
#resultsTable.etx-runs td.etx-r-in.etx-span-now::before { border-color: var(--etx-sage); }
/* A one-year letter reads as a small block of its own. */
#resultsTable.etx-runs.etx-pills tr[data-category="transitLetter"] td:not(.etx-r-in) .etx-letter {
    display: inline-block;
    min-width: 1.6em;
    padding: 0.1em 0.3em;
    border-radius: 7px;
    background: var(--etx-run-bg);
    border: 1px solid var(--etx-run-bd);
    line-height: 1.3;
}

/* ---------- Pinnacle / Challenge / Period Cycle bands ---------- */
#resultsTable.etx-bands td.etx-b-in:not(.etx-b-last) { border-right-color: transparent; }
#resultsTable.etx-bands td.etx-b-in.etx-b-hide {
    color: transparent !important;
    font-size: 0 !important;
}
#resultsTable.etx-bands tr[data-category="pinnacle"] { --etx-b-bg: var(--etx-pin-bg); --etx-b-bd: var(--etx-pin-bd); }
#resultsTable.etx-bands tr[data-category="challenge"] { --etx-b-bg: var(--etx-chal-bg); --etx-b-bd: var(--etx-chal-bd); }
#resultsTable.etx-bands tr[data-category="periodCycle"] { --etx-b-bg: var(--etx-pc-bg); --etx-b-bd: var(--etx-pc-bd); }
#resultsTable.etx-bands tr[data-category="pinnacle"] td:not(:first-child),
#resultsTable.etx-bands tr[data-category="challenge"] td:not(:first-child),
#resultsTable.etx-bands tr[data-category="periodCycle"] td:not(:first-child) {
    position: relative;
    z-index: 0;
    background-color: transparent !important;
    border-bottom: 1px solid var(--etx-rule) !important;
    color: var(--etx-tx) !important;
    font-family: Quicksand, Poppins, sans-serif;
    font-weight: 700 !important;
}
#resultsTable.etx-bands.etx-nowrail tr[data-category="pinnacle"] td.etx-now:not(:first-child),
#resultsTable.etx-bands.etx-nowrail tr[data-category="challenge"] td.etx-now:not(:first-child),
#resultsTable.etx-bands.etx-nowrail tr[data-category="periodCycle"] td.etx-now:not(:first-child) {
    background-color: var(--etx-now) !important;
}
#resultsTable.etx-bands td.etx-b-in::before {
    content: "";
    position: absolute;
    z-index: -1;
    top: 4px;
    bottom: 4px;
    left: 0;
    right: 0;
    background: var(--etx-b-bg);
    border-top: 1px solid var(--etx-b-bd);
    border-bottom: 1px solid var(--etx-b-bd);
    pointer-events: none;
}
#resultsTable.etx-bands td.etx-b-first::before { left: 3px; border-left: 1px solid var(--etx-b-bd); border-radius: 8px 0 0 8px; }
#resultsTable.etx-bands td.etx-b-last::before { right: 3px; border-right: 1px solid var(--etx-b-bd); border-radius: 0 8px 8px 0; }
#resultsTable.etx-bands td.etx-b-in:not(.etx-b-last)::before { right: -1px; } /* bridge the collapsed cell border */
/* Inside a band the band itself marks the highlighted period, so the per-cell outline /
   jump shadow is dropped (the crosshair tint still shows). */
#resultsTable.etx-bands tr[data-category="pinnacle"] td.etx-b-in,
#resultsTable.etx-bands tr[data-category="challenge"] td.etx-b-in,
#resultsTable.etx-bands tr[data-category="periodCycle"] td.etx-b-in { outline: none !important; }
#resultsTable.etx-bands tr[data-category="pinnacle"] td.etx-b-in,
#resultsTable.etx-bands tr[data-category="challenge"] td.etx-b-in,
#resultsTable.etx-bands tr[data-category="periodCycle"] td.etx-b-in { box-shadow: none !important; }
/* The band holding the highlighted column: Sage in Birthday mode, Coral in Calendar mode. */
#resultsTable.etx-bands td.etx-b-in.etx-span-now::before { border-color: var(--etx-sage); }
#resultsTable.etx-bands.etx-calmode td.etx-b-in.etx-span-now::before { border-color: var(--etx-coral); }
/* Label: the period's number, then its name and ages beside it. */
#resultsTable.etx-bands td.etx-b-label { z-index: 2; font-weight: 800 !important; }
#resultsTable.etx-bands td.etx-b-label::after {
    content: attr(data-etx-range);
    position: absolute;
    top: 50%;
    left: calc(50% + 0.85em);
    transform: translateY(-50%);
    font-family: Poppins, sans-serif;
    font-size: 10px;
    font-weight: 600;
    letter-spacing: 0.01em;
    color: var(--etx-tx2);
    white-space: nowrap;
    pointer-events: none;
}

/* ---------- Essence / Personal Year emphasis ---------- */
#resultsTable.etx-emph tr[data-category="essence"] td:not(:first-child) {
    font-size: calc(var(--etx-fs) * 1.3) !important;
    font-weight: 800;
    padding-top: 0.45rem !important;
    padding-bottom: 0.45rem !important;
}
#resultsTable.etx-emph tr[data-category="personalYear"] td:not(:first-child) {
    font-size: calc(var(--etx-fs) * 1.12) !important;
    font-weight: 700;
}
#resultsTable.etx-on.etx-emph tr[data-category="essence"] td:first-child,
#resultsTable.etx-on.etx-emph tr[data-category="personalYear"] td:first-child { color: var(--etx-tx) !important; }

/* ---------- Now column rail (after cycle dividers so its edges win) ---------- */
#resultsTable.etx-nowrail td.etx-now:not(.etx-now-own):not(.sticky) { background-color: var(--etx-now); }
html.dark #resultsTable.etx-nowrail td.etx-now:not(.etx-now-own):not(.sticky) { background-color: var(--etx-now) !important; }
#resultsTable.etx-nowrail td.etx-now,
#resultsTable.etx-nowrail th.etx-now {
    border-left: 1.5px solid var(--primary-color, #97B881);
    border-right: 1.5px solid var(--primary-color, #97B881);
}

/* ---------- Crosshair: one strip over the hovered column (see setColumnHover) ----------
   z-index 40: above the hovered cell (30) and the sticky header (10), below the sticky
   label column (200) it must never cover. */
#etxCross {
    position: absolute;
    top: 0;
    display: none;
    z-index: 40;
    pointer-events: none;
    background: rgba(143, 184, 202, 0.20);
}
html.dark #etxCross { background: rgba(155, 201, 217, 0.16); }

/* ---------- Row groups: tone rail, caret, label and a row count ---------- */
#resultsTable tr.etx-group th {
    background: var(--etx-grp-bg);
    padding: 0;
    height: 28px;
    text-align: left;
    border-bottom: 1px solid var(--etx-rule, #eef2ef);
    font-size: 10px !important;
}
#resultsTable tr.etx-group th,
#resultsTable tr.etx-group th:first-child,
#resultsTable tr.etx-group th:first-child.sticky { background: var(--etx-grp-bg) !important; color: var(--etx-grp-fg) !important; }
html.dark #resultsTable tr.etx-group th,
html.dark #resultsTable tr.etx-group th:first-child { background: var(--etx-grp-bg) !important; }
#resultsTable tr.etx-group th:first-child.sticky { z-index: 200 !important; }
#resultsTable tr.etx-g-transit { --etx-gtone: var(--etx-ocean); }
#resultsTable tr.etx-g-essence { --etx-gtone: var(--etx-sage); }
#resultsTable tr.etx-g-cycles { --etx-gtone: var(--etx-lav); }
#resultsTable tr.etx-g-months { --etx-gtone: var(--etx-sun); }
#resultsTable tr.etx-group th:first-child { box-shadow: inset 3px 0 0 var(--etx-gtone, var(--etx-sage)); }
.etx-gbtn {
    all: unset;
    box-sizing: border-box;
    display: flex;
    align-items: center;
    gap: 0.45rem;
    width: 100%;
    min-height: 28px;
    padding: 0 0.6rem 0 0.75rem;
    cursor: pointer;
    font-family: Poppins, sans-serif;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--etx-grp-fg);
}
.etx-gbtn:focus-visible { outline: 3px solid #8FB8CA; outline-offset: -3px; }
.etx-caret {
    flex: 0 0 auto;
    width: 0;
    height: 0;
    border: 4px solid transparent;
    border-top-color: currentColor;
    border-bottom-width: 0;
}
#resultsTable tr.etx-shut .etx-caret {
    border: 4px solid transparent;
    border-left-color: currentColor;
    border-right-width: 0;
}
.etx-gcount {
    margin-left: auto;
    padding: 0 6px;
    border-radius: 6px;
    background: var(--etx-card, #fff);
    border: 1px solid var(--etx-rule2, #e2e8f0);
    font-weight: 600;
    letter-spacing: 0;
    line-height: 16px;
}
.etx-gcount:empty { display: none; }
#resultsTable tr.etx-collapsed { display: none !important; }
#resultsTable.etx-pmnear tr.etx-far { display: none !important; }

/* ---------- Keyboard focus on the scroller ---------- */
.table-container:focus-visible { outline: 3px solid #8FB8CA; outline-offset: -3px; }

/* ---------- Minimap: Pinnacle strip + one Essence tick per year ---------- */
#etxMinimap {
    position: relative;
    display: flex;
    height: 34px;
    margin: 10px 16px 6px;
    border-radius: 8px;
    cursor: pointer;
    touch-action: none;
    user-select: none;
}
.etx-mseg {
    position: absolute;
    top: 0;
    height: 18px;
    display: flex;
    align-items: center;
    padding-left: 6px;
    overflow: hidden;
    white-space: nowrap;
    font-size: 10px;
    font-weight: 700;
    color: #4b5563;
    border-radius: 5px;
    background: rgba(196, 181, 212, 0.30);
    border-right: 2px solid #fff;
}
.etx-mseg-now { background: rgba(232, 141, 120, 0.28); }
.etx-mticks { position: absolute; left: 0; right: 0; bottom: 2px; height: 11px; }
.etx-mtick {
    position: absolute;
    top: 0;
    bottom: 0;
    border-right: 1px solid #fff;
    border-radius: 2px;
    background: #e2e8f0;
}
.etx-mtick.etx-d1 { background: color-mix(in srgb, #97B881 70%, #fff); }
.etx-mtick.etx-d2 { background: color-mix(in srgb, #8FB8CA 70%, #fff); }
.etx-mtick.etx-d3 { background: color-mix(in srgb, #C5AF6B 70%, #fff); }
.etx-mtick.etx-d4 { background: color-mix(in srgb, #EBA07E 70%, #fff); }
.etx-mtick.etx-d5 { background: color-mix(in srgb, #9E8FB0 70%, #fff); }
.etx-mtick.etx-d6 { background: color-mix(in srgb, #E88D78 70%, #fff); }
.etx-mtick.etx-d7 { background: color-mix(in srgb, #6D94A6 70%, #fff); }
.etx-mtick.etx-d8 { background: color-mix(in srgb, #C97E5E 70%, #fff); }
.etx-mtick.etx-d9 { background: color-mix(in srgb, #7da066 70%, #fff); }
.etx-mnow { position: absolute; top: 0; bottom: 0; width: 2px; background: #1f2937; border-radius: 2px; pointer-events: none; }
.etx-mview {
    position: absolute;
    top: -3px;
    bottom: -3px;
    border: 2px solid #6D94A6;
    background: rgba(143, 184, 202, 0.14);
    border-radius: 7px;
    pointer-events: none;
}
html.dark .etx-mseg { color: #c3cbbd; background: rgba(196, 181, 212, 0.18); border-right-color: var(--dark-card, #20252a); }
html.dark .etx-mseg-now { background: rgba(240, 160, 138, 0.22); }
html.dark .etx-mtick { border-right-color: var(--dark-card, #20252a); background: #2d3532; }
html.dark .etx-mtick.etx-d1 { background: color-mix(in srgb, #97B881 65%, #20252a); }
html.dark .etx-mtick.etx-d2 { background: color-mix(in srgb, #8FB8CA 65%, #20252a); }
html.dark .etx-mtick.etx-d3 { background: color-mix(in srgb, #C5AF6B 65%, #20252a); }
html.dark .etx-mtick.etx-d4 { background: color-mix(in srgb, #EBA07E 65%, #20252a); }
html.dark .etx-mtick.etx-d5 { background: color-mix(in srgb, #9E8FB0 65%, #20252a); }
html.dark .etx-mtick.etx-d6 { background: color-mix(in srgb, #E88D78 65%, #20252a); }
html.dark .etx-mtick.etx-d7 { background: color-mix(in srgb, #6D94A6 65%, #20252a); }
html.dark .etx-mtick.etx-d8 { background: color-mix(in srgb, #C97E5E 65%, #20252a); }
html.dark .etx-mtick.etx-d9 { background: color-mix(in srgb, #7da066 65%, #20252a); }
html.dark .etx-mnow { background: #f2f4ef; }
html.dark .etx-mview { border-color: #9bc9d9; background: rgba(155, 201, 217, 0.14); }

/* ---------- Hover peek ---------- */
#etxPeek {
    position: fixed;
    top: 0;
    left: 0;
    z-index: 9999;
    display: none;
    min-width: 190px;
    max-width: 260px;
    padding: 10px 12px;
    border-radius: 12px;
    background: #fff;
    border: 1px solid #cfd8c6;
    color: #1f2937;
    font-size: 12px;
    line-height: 1.4;
    pointer-events: none;
}
#etxPeek b { display: block; margin-bottom: 4px; font-family: Quicksand, Poppins, sans-serif; font-size: 14px; }
#etxPeek div { display: flex; justify-content: space-between; gap: 12px; }
#etxPeek div span { color: #6b7280; }
#etxPeek em { display: block; margin-top: 6px; font-style: normal; font-size: 11px; color: #6b7280; }
html.dark #etxPeek { background: #1a2017; border-color: #3a4535; color: #eef2ea; }
html.dark #etxPeek div span, html.dark #etxPeek em { color: #97a191; }

/* ---------- Configuration panel segmented control ---------- */
.etx-seg {
    min-height: 44px;
    padding: 0 16px;
    border: 1px solid #cfd8c6;
    background-color: #fff;
    color: #374151;
    font-size: 0.8rem;
    font-weight: 600;
    border-radius: 10px;
    box-shadow: none;
    transition: background-color 0.15s ease, border-color 0.15s ease;
}
.etx-seg:hover { background-color: #f0f7ec; border-color: #97B881; }
.etx-seg.etx-seg-on { background-color: #97B881; border-color: #97B881; color: #14210d; }
.etx-seg:focus-visible { outline: 3px solid #8FB8CA; outline-offset: 2px; }
html.dark .etx-seg { background-color: #1a2017; border-color: #3a4535; color: #eef2ea; }
html.dark .etx-seg:hover { background-color: rgba(151, 184, 129, 0.14); }
html.dark .etx-seg.etx-seg-on { background-color: #a8c795; border-color: #a8c795; color: #10170c; }

@media print { #etxMinimap, #etxPeek, #etxCross { display: none !important; } }

/* ---------- Pills (Essence, Personal Year, Personal Months): original colours ---------- */
#resultsTable.etx-pills .etx-chip {
    display: inline-grid;
    place-items: center;
    min-width: 1.9em;
    height: 1.9em;
    padding: 0 0.3em;
    border-radius: 9px;
    font-family: Quicksand, Poppins, sans-serif;
    font-weight: 700;
    line-height: 1;
}
#resultsTable.etx-pills tr[data-category="personalMonth"] .etx-chip {
    min-width: 1.9em;
    height: 1.9em;
    font-size: 1.05em;
    font-weight: 600;
}
#resultsTable.etx-pills .etx-n1, #resultsTable.etx-pills .etx-n7 { background: #fdf2f0; color: #c45f49; }
#resultsTable.etx-pills .etx-n2, #resultsTable.etx-pills .etx-n8 { background: #E8F3F8; color: #4f7d90; }
#resultsTable.etx-pills .etx-n3, #resultsTable.etx-pills .etx-n9 { background: #FBF7E6; color: #8f7a2c; }
#resultsTable.etx-pills .etx-n4 { background: #f0f7ec; color: #5f8449; }
#resultsTable.etx-pills .etx-n5 { background: #FBF2ED; color: #a85f3f; }
#resultsTable.etx-pills .etx-n6 { background: #F5F0F9; color: #76668a; }
html.dark #resultsTable.etx-pills .etx-n1, html.dark #resultsTable.etx-pills .etx-n7 { background: rgba(232, 141, 120, 0.18); color: #f0a090; }
html.dark #resultsTable.etx-pills .etx-n2, html.dark #resultsTable.etx-pills .etx-n8 { background: rgba(155, 201, 217, 0.16); color: #9bc9d9; }
html.dark #resultsTable.etx-pills .etx-n3, html.dark #resultsTable.etx-pills .etx-n9 { background: rgba(240, 214, 143, 0.16); color: #f0d68f; }
html.dark #resultsTable.etx-pills .etx-n4 { background: rgba(151, 184, 129, 0.18); color: #a8c795; }
html.dark #resultsTable.etx-pills .etx-n5 { background: rgba(235, 160, 126, 0.18); color: #eeb094; }
html.dark #resultsTable.etx-pills .etx-n6 { background: rgba(196, 181, 212, 0.18); color: #dfcceb; }

/* The pill carries the colour, so the cell itself stays neutral (inline colours from the
   renderer are overridden); the Now column keeps the rail tint. */
#resultsTable.etx-pills tr[data-category="essence"] td:not(:first-child),
#resultsTable.etx-pills tr[data-category="personalYear"] td:not(:first-child),
#resultsTable.etx-pills tr[data-category="personalMonth"] td:not(:first-child) {
    background-color: transparent !important;
}
#resultsTable.etx-pills.etx-nowrail tr[data-category="essence"] td.etx-now:not(:first-child),
#resultsTable.etx-pills.etx-nowrail tr[data-category="personalYear"] td.etx-now:not(:first-child),
#resultsTable.etx-pills.etx-nowrail tr[data-category="personalMonth"] td.etx-now:not(:first-child) {
    background-color: var(--etx-now) !important;
}
/* Highlights move from the cell outline onto the pill itself. */
#resultsTable.etx-pills td.border-x-sage .etx-chip { outline: 2px solid var(--primary-color, #97B881); outline-offset: 0; }
#resultsTable.etx-pills td.border-x-coral .etx-chip { outline: 2px solid var(--secondary-color, #E88D78); outline-offset: 0; }
#resultsTable.etx-pills.etx-nowrail tr[data-category="essence"] td.border-x-sage,
#resultsTable.etx-pills.etx-nowrail tr[data-category="essence"] td.border-x-coral,
#resultsTable.etx-pills.etx-nowrail tr[data-category="personalYear"] td.border-x-sage,
#resultsTable.etx-pills.etx-nowrail tr[data-category="personalYear"] td.border-x-coral,
#resultsTable.etx-pills.etx-nowrail tr[data-category="personalMonth"] td.border-x-sage,
#resultsTable.etx-pills.etx-nowrail tr[data-category="personalMonth"] td.border-x-coral,
#resultsTable.etx-pills.etx-nowrail tr[data-category="transitLetter"] td.border-x-sage,
#resultsTable.etx-pills.etx-nowrail tr[data-category="hiddenEssence"] td.border-x-sage {
    outline: none;
    border-radius: 0;
}

/* Hidden Essence: the Sage highlight wraps the number itself. */
#resultsTable.etx-pills .etx-hid {
    display: inline-block;
    padding: 0.15em 0.45em;
    border-radius: 9px;
}
#resultsTable.etx-pills td.border-x-sage .etx-hid { outline: 2px solid var(--primary-color, #97B881); outline-offset: 0; }

/* ---------- Transit letters ---------- */
#resultsTable.etx-pills .etx-letter {
    font-family: Quicksand, Poppins, sans-serif;
    font-weight: 800;
    font-size: 1.1em;
    letter-spacing: 0.02em;
    color: var(--etx-tx);
}
#resultsTable.etx-pills .etx-letter[data-etx-val]::after {
    content: attr(data-etx-val);
    margin-left: 3px;
    vertical-align: middle;
    font-family: Poppins, sans-serif;
    font-size: 0.62em;
    font-weight: 600;
    color: var(--etx-mut);
}
#resultsTable.etx-pills td.etx-now .etx-letter { color: var(--primary-dark, #5f8449); }
#resultsTable.etx-pills td.etx-r-hide .etx-letter { display: none; }
html.dark #resultsTable.etx-pills td.etx-now .etx-letter { color: #b9d6a6; }

/* ---------- Hidden Essence: quiet number, the pill row below is the focus ---------- */
#resultsTable.etx-pills tr[data-category="hiddenEssence"] td:not(:first-child) { background-color: transparent !important; color: #6b7280; font-weight: 500; }
#resultsTable.etx-pills.etx-nowrail tr[data-category="hiddenEssence"] td.etx-now:not(:first-child) { background-color: var(--etx-now) !important; color: var(--primary-dark, #5f8449); font-weight: 700; }
html.dark #resultsTable.etx-pills tr[data-category="hiddenEssence"] td:not(:first-child) { color: #97a191; }

/* ==========================================================================
   ESSENCE CHART TOOLBAR, DOCK AND DISPLAY DRAWER (Design A)
   Toolbar + dock markup comes from renderEssenceChart() (#quickNavContainer,
   #chartLegend); the drawer from js/essence_display_drawer.js. Flat 2.0: solid
   colours, 1px borders, no shadows, no gradients, no transforms on controls.
   Phone = below 640px (Tailwind sm).
   ========================================================================== */
.etb-topbar,
.etb-dock,
.edd {
    --etb-card: #ffffff;
    --etb-surface: #f7f9f5;
    --etb-line: #e2e8f0;
    --etb-tx: #1f2937;
    --etb-tx2: #4b5563;
    --etb-mut: #9ca3af;
    --etb-sage: var(--primary-color, #97B881);
    --etb-sage-d: var(--primary-dark, #7da066);
    --etb-sage-l: var(--primary-light, #f0f7ec);
    --etb-coral: var(--secondary-color, #E88D78);
    --etb-coral-d: var(--secondary-dark, #d67560);
    --etb-coral-l: var(--secondary-light, #fdf2f0);
    --etb-focus: var(--ocean-dark, #6D94A6);
}
html.dark .etb-topbar,
html.dark .etb-dock,
html.dark .edd {
    --etb-card: var(--dark-card);
    --etb-surface: var(--dark-surface);
    --etb-line: var(--dark-border);
    --etb-tx: var(--dark-text);
    --etb-tx2: var(--dark-text-secondary);
    --etb-mut: var(--dark-text-muted);
    --etb-sage-d: var(--dark-primary);
    --etb-sage-l: rgba(168, 204, 143, 0.16);
    --etb-coral-d: var(--dark-accent);
    --etb-coral-l: rgba(240, 160, 138, 0.16);
    --etb-focus: var(--dark-focus);
}

/* ---------- top bar ---------- */
.etb-topbar.essence-chart-topbar {
    padding: 12px 16px !important;
    background: var(--etb-surface) !important;
    border-color: var(--etb-line) !important;
}
.etb {
    display: flex;
    align-items: center;
    gap: 16px;
    min-width: 0;
}
#quickNavContainer > .etb > div { border-radius: 0 !important; }
.etb [hidden] { display: none !important; }
.etb-id {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
    flex: 1 1 auto;
}
.etb-av {
    width: 40px;
    height: 40px;
    border-radius: 12px;
    background: var(--etb-sage);
    color: #fff;
    display: grid;
    place-items: center;
    font: 700 14px/1 Quicksand, Poppins, sans-serif;
    flex-shrink: 0;
}
.etb-id-t { min-width: 0; flex: 1 1 auto; }
.etb-name {
    font: 700 16px/1.25 Quicksand, Poppins, sans-serif;
    color: var(--etb-tx);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.etb-meta {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 2px 6px;
    margin-top: 2px;
    font-size: 12px;
    color: var(--etb-mut);
}
.etb-num {
    font-weight: 700;
    font-size: 11px;
    line-height: 18px;
    padding: 0 8px;
    border-radius: 9999px;
    background: var(--etb-sage-l);
    color: var(--etb-sage-d);
    border: 1px solid rgba(151, 184, 129, 0.35);
}
.etb-ctrl {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    flex-wrap: wrap;
    gap: 8px;
    min-width: 0;
}
.etb-sep {
    width: 1px;
    height: 22px;
    background: var(--etb-line);
    flex-shrink: 0;
}

/* segmented controls (row sets, S / M / L) */
.etb-seg,
.edd-seg {
    display: inline-flex;
    gap: 2px;
    padding: 3px;
    border-radius: 12px;
    background: var(--etb-surface);
    border: 1px solid var(--etb-line);
    flex-shrink: 0;
}
.etb-seg button,
.edd-seg button {
    height: 30px;
    min-height: 30px !important;
    padding: 0 12px;
    border-radius: 9px;
    border: 1px solid transparent;
    background-color: transparent;
    color: var(--etb-tx2);
    font-size: 12px;
    font-weight: 600;
    white-space: nowrap;
    box-shadow: none;
    transition: background-color 0.15s ease, border-color 0.15s ease;
}
.etb-seg button:hover,
.edd-seg button:hover { background-color: var(--etb-card); }
.etb-seg button[aria-pressed="true"],
.edd-seg button[aria-pressed="true"] {
    background-color: var(--etb-card);
    border-color: var(--etb-line);
    color: var(--etb-tx);
}
.edd-seg button:disabled { cursor: not-allowed; }

/* chips + buttons */
.etb-chip,
.etb-btn,
.etb-icon,
.edd-x,
.edd-reset {
    height: 36px;
    min-height: 36px !important;
    border-radius: 12px;
    border: 1px solid var(--etb-line);
    background-color: var(--etb-card);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    font-size: 12px;
    font-weight: 600;
    flex-shrink: 0;
    box-shadow: none;
    transition: background-color 0.15s ease, border-color 0.15s ease;
}
.etb-chip { min-width: 36px; padding: 0 10px; color: var(--etb-mut); }
.etb-chip svg,
.etb-btn svg,
.etb-icon svg,
.edd-x svg,
.edd-reset svg { width: 16px; height: 16px; }
.etb-chip:hover { border-color: var(--etb-sage); color: var(--etb-sage-d); }
.etb-chip[aria-pressed="true"] {
    background-color: var(--etb-sage-l);
    border-color: rgba(151, 184, 129, 0.55);
    color: var(--etb-sage-d);
}
.etb-chip-coral:hover { border-color: var(--etb-coral); color: var(--etb-coral-d); }
.etb-chip-coral[aria-pressed="true"] {
    background-color: var(--etb-coral-l);
    border-color: rgba(232, 141, 120, 0.55);
    color: var(--etb-coral-d);
}
.etb-btn,
.edd-reset { padding: 0 14px; color: var(--etb-tx); }
.etb-btn:hover,
.edd-reset:hover { border-color: var(--etb-sage); background-color: var(--etb-sage-l); }
.edd-reset:disabled { opacity: 0.5; cursor: not-allowed; }
.etb-icon,
.edd-x { width: 36px; padding: 0; color: var(--etb-tx2); }
.etb-icon { display: none; }
.etb-icon:hover,
.edd-x:hover { border-color: var(--etb-sage); color: var(--etb-sage-d); }
.etb-chip:focus-visible,
.etb-btn:focus-visible,
.etb-icon:focus-visible,
.etb-seg button:focus-visible,
.edd button:focus-visible,
.edd input[type="range"]:focus-visible {
    outline: 2px solid var(--etb-focus);
    outline-offset: 2px;
}

/* the four existing row toggles keep their ids/colours; only size and shape here */
.etb-tools { display: flex; gap: 6px; flex-shrink: 0; }
.etb-tools .essence-toolbar-chip {
    width: 36px !important;
    min-width: 36px !important;
    height: 36px !important;
    padding: 0 !important;
    border-radius: 12px !important;
    box-shadow: none !important;
}

/* collapsible search: icon until opened. Collapsed, the input stays focusable
   (1px, transparent) so "/" and Ctrl+K can still focus #jumpToInput. */
.etb-qs { position: relative; display: flex; align-items: center; flex-shrink: 0; }
.etb-qs-box {
    position: absolute;
    top: 0;
    right: 0;
    width: 1px;
    height: 1px;
    overflow: hidden;
    opacity: 0;
    pointer-events: none;
    display: flex;
    align-items: center;
    gap: 6px;
}
.etb-qs-open .etb-qs-btn,
.etb-qs:has(input:focus) .etb-qs-btn { display: none; }
.etb-qs-open .etb-qs-box,
.etb-qs:has(input:focus) .etb-qs-box {
    position: static;
    width: 240px;
    height: 36px;
    overflow: visible;
    opacity: 1;
    pointer-events: auto;
    padding: 0 4px 0 10px;
    border-radius: 12px;
    border: 1px solid var(--etb-sage);
    background-color: var(--etb-card);
    color: var(--etb-mut);
}
.etb-qs-open .etb-qs-box:focus-within { outline: 2px solid rgba(151, 184, 129, 0.35); outline-offset: 1px; }
.etb-qs-box > svg { width: 15px; height: 15px; flex-shrink: 0; }
#quickNavContainer .etb-qs-box input {
    flex: 1 1 auto;
    min-width: 0;
    height: 32px;
    min-height: 0 !important;
    padding: 0;
    border: 0;
    outline: none;
    background: transparent;
    box-shadow: none;
    font-size: 12px;
    color: var(--etb-tx);
}
.etb-qs-box input::placeholder { color: var(--etb-mut); }
.etb-qs-x {
    width: 28px;
    height: 28px;
    min-height: 28px !important;
    display: grid;
    place-items: center;
    border: 0;
    border-radius: 8px;
    background-color: transparent;
    color: var(--etb-mut);
    flex-shrink: 0;
    transition: background-color 0.15s ease;
}
.etb-qs-x:hover { background-color: var(--etb-surface); color: var(--etb-tx); }
.etb-qs-x svg { width: 15px; height: 15px; }

/* ---------- bottom dock: legend only ---------- */
.etb-dock {
    display: flex;
    align-items: center;
    padding: 10px 18px;
    border-top: 1px solid var(--etb-line);
    background: var(--etb-surface);
}
.etb-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 6px 16px;
    font-size: 11px;
    color: var(--etb-tx2);
}
.etb-legend span { display: inline-flex; align-items: center; gap: 6px; cursor: help; white-space: nowrap; }
.etb-swatch { width: 10px; height: 10px; border-radius: 50%; display: inline-block; flex-shrink: 0; }
.etb-swatch-sage { background: var(--etb-sage); }
.etb-swatch-coral { background: var(--etb-coral); }
.etb-swatch-ring { border-radius: 3px; border: 2px solid var(--etb-sage); }

/* ---------- Display drawer ---------- */
.edd {
    position: fixed;
    inset: 0;
    z-index: 1500;
    display: flex;
    justify-content: flex-end;
}
.edd[hidden] { display: none; }
.edd-bg { position: absolute; inset: 0; background: rgba(15, 23, 42, 0.38); }
.edd-panel {
    position: relative;
    width: 400px;
    max-width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    background: var(--etb-card);
    border-left: 1px solid var(--etb-line);
    color: var(--etb-tx);
}
.edd-h {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 16px 18px;
    border-bottom: 1px solid var(--etb-line);
}
.edd-h > div { flex: 1 1 auto; min-width: 0; }
.edd-h h3 { margin: 0; font: 700 18px/1.3 Quicksand, Poppins, sans-serif; color: var(--etb-tx); }
.edd-h p { margin: 2px 0 0; font-size: 12px; color: var(--etb-mut); }
.edd-b { flex: 1 1 auto; overflow-y: auto; overscroll-behavior: contain; padding: 4px 18px 18px; }
.edd-f {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 12px 18px;
    border-top: 1px solid var(--etb-line);
    font-size: 11px;
    color: var(--etb-mut);
}
.edd-master {
    margin: 12px 0 4px;
    padding: 2px 12px;
    border-radius: 14px;
    background: var(--etb-sage-l);
    border: 1px solid rgba(151, 184, 129, 0.3);
}
.edd-sec { padding: 14px 0 6px; border-bottom: 1px dashed var(--etb-line); }
.edd-sec:last-child { border-bottom: 0; }
.edd-sec h4 {
    margin: 0 0 6px;
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--etb-mut);
}
.edd-sec h4 svg { width: 13px; height: 13px; }
.edd-off { opacity: 0.55; }
.edd-row {
    position: relative;
    display: flex;
    align-items: center;
    gap: 10px;
    min-height: 44px;
    padding: 8px 0;
    cursor: pointer;
}
/* !important: style_essence.css forces label { display: block !important } on mobile */
.edd .edd-row { display: flex !important; }
.edd-static { cursor: default; }
.edd .edd-col { display: block !important; }
.edd-dis { cursor: not-allowed; }
.edd-t { flex: 1 1 auto; min-width: 0; }
.edd-t b { display: block; font-size: 13px; font-weight: 600; color: var(--etb-tx); }
.edd-t small { display: block; font-size: 11px; line-height: 1.35; color: var(--etb-mut); }
.edd kbd {
    font: 600 10px/1 ui-monospace, Menlo, monospace;
    padding: 3px 6px;
    border-radius: 6px;
    background: var(--etb-surface);
    border: 1px solid var(--etb-line);
    color: var(--etb-mut);
}
.edd-in { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.edd-sw {
    display: block;
    position: relative;
    width: 40px;
    height: 24px;
    border-radius: 9999px;
    background: var(--etb-line);
    flex-shrink: 0;
    transition: background-color 0.15s ease;
}
.edd-sw::after {
    content: "";
    position: absolute;
    top: 3px;
    left: 3px;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: #fff;
    transition: left 0.15s ease;
}
.edd-in:checked + .edd-sw { background: var(--etb-sage); }
.edd-in:checked + .edd-sw::after { left: 19px; }
.edd-in:focus-visible + .edd-sw { outline: 2px solid var(--etb-focus); outline-offset: 2px; }
.edd-in:disabled + .edd-sw { opacity: 0.5; }
.edd-seg-wide { display: flex; width: 100%; }
.edd-seg-wide button { flex: 1 1 0; }
.edd-font { display: flex; align-items: center; gap: 10px; padding-top: 8px; font-size: 11px; color: var(--etb-tx2); }
.edd-font input { flex: 1 1 auto; accent-color: var(--etb-sage); }
.edd-font .edd-font-lg { font-size: 15px; font-weight: 700; }
.edd-font output { width: 28px; text-align: right; font-weight: 700; font-size: 12px; color: var(--etb-tx); }
.edd-keys { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 14px; font-size: 12px; color: var(--etb-tx2); }
.edd-keys span { display: flex; align-items: center; justify-content: space-between; gap: 6px; }

/* ---------- responsive toolbar: sized by the chart card, not the viewport
   (the sidebar makes the card much narrower than the window) ---------- */
.etb-topbar { container-type: inline-size; container-name: etb; }
@container etb (max-width: 1180px) {
    .etb { flex-wrap: wrap; }
    .etb-ctrl { width: 100%; justify-content: flex-start; }
    .etb-ctrl > .etb-btn { margin-left: auto; }
}
/* phone-width card: one rail of icon-only chips */
@container etb (max-width: 599.98px) {
    .etb { flex-direction: column; align-items: stretch; gap: 10px; }
    .etb-hide-phone { display: none !important; }
    .etb-only-phone { display: inline-flex !important; }
    .etb-icon { width: 40px; height: 40px; min-height: 40px !important; }
    .etb-tl { display: none; }
    /* every chip shares the row evenly so the whole rail fits without scrolling */
    .etb-ctrl {
        position: relative;
        flex-wrap: nowrap;
        justify-content: space-between;
        gap: 6px;
        overflow-x: auto;
        scrollbar-width: none;
    }
    .etb-ctrl::-webkit-scrollbar { display: none; }
    .etb-tools { display: contents; }
    .etb-ctrl .etb-chip,
    .etb-tools .essence-toolbar-chip {
        flex: 1 1 0;
        width: auto !important;
        min-width: 32px !important;
        max-width: 48px;
        height: 40px !important;
        min-height: 40px !important;
        padding: 0 !important;
    }
    .etb-qs { position: static; flex: 1 1 0; min-width: 32px; max-width: 48px; }
    .etb-qs .etb-qs-btn { width: 100%; max-width: none; }
    .etb-qs-open .etb-qs-box,
    .etb-qs:has(input:focus) .etb-qs-box {
        position: absolute;
        top: 0;
        bottom: 0;
        left: 0;
        right: 0;
        width: auto;
        height: auto;
        z-index: 5;
    }
}

/* No container queries (iOS 15, Safari <= 16.3): the same phone rail, keyed off the viewport.
   Dead in every modern browser. The :has() variant is skipped — .etb-qs-open covers it. */
@supports not (container-type: inline-size) {
    @media (max-width: 639.98px) {
        .etb { flex-direction: column; align-items: stretch; gap: 10px; }
        .etb-hide-phone { display: none !important; }
        .etb-only-phone { display: inline-flex !important; }
        .etb-icon { width: 40px; height: 40px; min-height: 40px !important; }
        .etb-tl { display: none; }
        .etb-ctrl {
            position: relative;
            flex-wrap: nowrap;
            justify-content: space-between;
            gap: 6px;
            overflow-x: auto;
            scrollbar-width: none;
        }
        .etb-ctrl::-webkit-scrollbar { display: none; }
        .etb-tools { display: contents; }
        .etb-ctrl .etb-chip,
        .etb-tools .essence-toolbar-chip {
            flex: 1 1 0;
            width: auto !important;
            min-width: 32px !important;
            max-width: 48px;
            height: 40px !important;
            min-height: 40px !important;
            padding: 0 !important;
        }
        .etb-qs { position: static; flex: 1 1 0; min-width: 32px; max-width: 48px; }
        .etb-qs .etb-qs-btn { width: 100%; max-width: none; }
        .etb-qs-open .etb-qs-box {
            position: absolute;
            top: 0;
            bottom: 0;
            left: 0;
            right: 0;
            width: auto;
            height: auto;
            z-index: 5;
        }
    }
}

/* ---------- phone viewport: tighter top bar, no dock, drawer becomes a bottom sheet ---------- */
@media (max-width: 639.98px) {
    .etb-topbar.essence-chart-topbar { padding: 12px !important; }
    .etb-dock { display: none; }
    .edd { align-items: flex-end; justify-content: stretch; }
    .edd-panel {
        width: 100%;
        height: auto;
        max-height: 88vh;
        border-left: 0;
        border-top: 1px solid var(--etb-line);
        border-radius: 20px 20px 0 0;
    }
    .edd-panel::before {
        content: "";
        display: block;
        width: 40px;
        height: 4px;
        margin: 8px auto 0;
        border-radius: 4px;
        background: var(--etb-line);
    }
}
@media (prefers-reduced-motion: reduce) {
    .edd-sw,
    .edd-sw::after,
    .etb-chip,
    .etb-btn,
    .etb-seg button { transition: none; }
}

/* ---------- Essence read-outs: Hidden Essence flags, Essence = Personal Year, length badge ----------
   Marks only (ESSENCE_TABLE_ENH.annotateEssence). Each one is gated by its own table class. */
#resultsTable.etx-on {
    --etx-flag-kd: #d9715a;
    --etx-flag-ms: #8b6fb0;
    --etx-dual: #c79a2e;
    --etx-run-ink: #7b8794;
}
html.dark #resultsTable.etx-on {
    --etx-flag-kd: #f0a090;
    --etx-flag-ms: #cdb6e6;
    --etx-dual: #f0d68f;
    --etx-run-ink: #94a3b8;
}
#resultsTable.etx-flags td.etx-flag-kd,
#resultsTable.etx-flags td.etx-flag-ms,
#resultsTable.etx-essruns td.etx-ess-start { position: relative; }
#resultsTable.etx-flags td.etx-flag-kd::after,
#resultsTable.etx-flags td.etx-flag-ms::after {
    content: "";
    position: absolute;
    top: 3px;
    right: 3px;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--etx-flag-kd);
    pointer-events: none;
}
#resultsTable.etx-flags td.etx-flag-ms::after { background: var(--etx-flag-ms); border-radius: 1px; transform: rotate(45deg); }
#resultsTable.etx-flags td.etx-flag-kd { color: var(--etx-flag-kd); font-weight: 700; }
#resultsTable.etx-flags td.etx-flag-ms { color: var(--etx-flag-ms); font-weight: 700; }

/* Essence = Personal Year: one bar under both cells of the column. */
#resultsTable.etx-duality tr[data-category="essence"] td.etx-dual,
#resultsTable.etx-duality tr[data-category="personalYear"] td.etx-dual {
    box-shadow: inset 0 -3px 0 var(--etx-dual);
}

/* "4y" on the first year of an Essence that lasts two years or more. */
#resultsTable.etx-essruns td.etx-ess-start::after {
    content: attr(data-etx-run);
    position: absolute;
    top: 1px;
    left: 2px;
    font-size: 8px;
    font-weight: 700;
    line-height: 1;
    letter-spacing: 0.02em;
    color: var(--etx-run-ink);
    pointer-events: none;
}
@media print {
    #resultsTable.etx-essruns td.etx-ess-start::after,
    #resultsTable.etx-flags td.etx-flag-kd::after,
    #resultsTable.etx-flags td.etx-flag-ms::after { display: none; }
}
