/* ---------- Our own form controls (from book-forms controls.js) ---------- */

.ac-select {
    display: inline-flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    width: 100%;
    min-height: var(--ac-control-h);
    padding: 9px 12px;
    background: var(--white);
    border: 1px solid var(--border-gray);
    border-radius: 8px;
    font: inherit;
    font-size: 0.9rem;
    color: var(--primary);
    cursor: pointer;
    text-align: left;
}

.ac-select:hover {
    border-color: var(--border-strong);
}

.ac-select--open,
.ac-select:focus-visible {
    border-color: var(--primary);
    outline: none;
    box-shadow: 0 0 0 3px rgba(0, 0, 0, 0.08);
}

.ac-select__label {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.ac-select--empty .ac-select__label {
    color: var(--text-faint);
}

.ac-select__caret {
    flex: 0 0 auto;
    color: var(--text-gray);
}

.ac-pop {
    position: absolute;
    z-index: 500;
    background: var(--white);
    border: 1px solid var(--border-gray);
    border-radius: 10px;
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.14);
    padding: 6px;
    max-width: 420px;
}

.ac-pop__search {
    width: 100%;
    padding: 7px 9px;
    margin-bottom: 6px;
    border: 1px solid var(--border-gray);
    border-radius: 7px;
    font: inherit;
    font-size: 0.88rem;
}

.ac-pop__search:focus {
    outline: none;
    border-color: var(--primary);
}

.ac-pop__list {
    max-height: 260px;
    overflow-y: auto;
}

.ac-pop__item {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 10px;
    width: 100%;
    padding: 7px 9px;
    background: none;
    border: 0;
    border-radius: 7px;
    font: inherit;
    font-size: 0.88rem;
    color: var(--primary);
    cursor: pointer;
    text-align: left;
}

.ac-pop__item:hover {
    background: var(--light-gray);
}

.ac-pop__item--on {
    font-weight: 600;
    color: var(--primary);
}

.ac-pop__item--off,
.ac-pop__item--off:hover {
    color: var(--text-faint);
    background: none;
    cursor: not-allowed;
}

.ac-pop__item--multi {
    justify-content: flex-start;
}

.ac-pop__item--multi .ac-pop__text {
    flex: 1 1 auto;
}

.ac-pop__tick {
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
    color: var(--accent);
    visibility: hidden;
}

.ac-pop__item--on .ac-pop__tick {
    visibility: visible;
}

.ac-pop__note,
.ac-pop__empty {
    color: var(--text-gray);
    font-size: 0.8rem;
}

.ac-pop__empty {
    padding: 10px 9px;
}

.ac-pop__group {
    padding: 8px 9px 3px;
    font-size: 0.68rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--text-faint);
}

.ac-pop__group:not(:first-child) {
    margin-top: 4px;
    border-top: 1px solid var(--border-gray);
}

.ac-input {
    width: 100%;
    height: var(--ac-control-h);
    min-height: var(--ac-control-h);
    padding: 9px 12px;
    background: var(--white);
    border: 1px solid var(--border-gray);
    border-radius: 8px;
    font: inherit;
    font-size: 0.9rem;
    line-height: 1.4;
    color: var(--primary);
}

.ac-input:hover {
    border-color: var(--border-strong);
}

.ac-input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(0, 0, 0, 0.08);
}

.ac-input::placeholder {
    color: var(--text-faint);
}

.ac-input--area {
    height: auto;
    resize: vertical;
    line-height: 1.55;
}

.ac-check {
    display: inline-flex;
    align-items: center;
    gap: 9px;
    cursor: pointer;
    font-size: 0.9rem;
    user-select: none;
}

.ac-check__box {
    flex: 0 0 auto;
    width: 18px;
    height: 18px;
    border: 1px solid var(--border-strong);
    border-radius: 5px;
    background: var(--white);
    position: relative;
    transition: background 0.12s, border-color 0.12s;
}

.ac-check__box::after {
    content: "";
    position: absolute;
    left: 5px;
    top: 1px;
    width: 5px;
    height: 10px;
    border: solid var(--white);
    border-width: 0 2px 2px 0;
    transform: rotate(45deg) scale(0.6);
    opacity: 0;
    transition: opacity 0.12s, transform 0.12s;
}

.ac-check.is-on .ac-check__box {
    background: var(--primary);
    border-color: var(--primary);
}

.ac-check.is-on .ac-check__box::after {
    opacity: 1;
    transform: rotate(45deg) scale(1);
}

.ac-check__box:focus-visible {
    outline: none;
    box-shadow: 0 0 0 3px var(--accent-ring);
}

.ac-check.is-off {
    cursor: default;
}

.ac-check__note {
    color: var(--text-gray);
    font-size: 0.8rem;
}

/* ---------- One answer of a few: choice cards and a list of dots (controls.js radios) ---------- */

.ac-choices { display: flex; flex-direction: column; gap: 8px; }
.ac-choice {
    display: block;
    padding: 12px 14px;
    background: var(--white);
    border: 1px solid var(--border-strong);
    border-radius: 10px;
    cursor: pointer;
    transition: border-color 0.12s, box-shadow 0.12s, background 0.12s;
    outline: none;
}
.ac-choice:hover { border-color: var(--text-faint); }
.ac-choice:focus-visible { box-shadow: 0 0 0 3px rgba(0, 0, 0, 0.12); }
.ac-choice__main { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.ac-choice__title { font-size: 0.9rem; font-weight: 600; line-height: 1.4; color: var(--primary); }
.ac-choice__note { font-size: 0.8rem; line-height: 1.45; color: var(--text-gray); }
.ac-choices--default .ac-choice.is-on { border-color: var(--primary); box-shadow: 0 0 0 1px var(--primary); }
.ac-choices--default .ac-choice.is-on:focus-visible { box-shadow: 0 0 0 1px var(--primary), 0 0 0 4px rgba(0, 0, 0, 0.12); }
.ac-choices--filled .ac-choice.is-on { background: var(--primary); border-color: var(--primary); color: var(--white); }
.ac-choices--filled .ac-choice.is-on .ac-choice__title,
.ac-choices--filled .ac-choice.is-on .ac-choice__note { color: var(--white); }
.ac-choices--filled .ac-choice.is-on .ac-choice__note { opacity: 0.8; }
.ac-choices--accent .ac-choice.is-on { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-ring); }
.ac-choice.is-off { cursor: default; opacity: 0.72; }
.ac-choice.is-off:hover { border-color: var(--border-strong); }

.ac-dots { display: flex; flex-direction: column; gap: 8px; }
.ac-dot { display: flex; align-items: flex-start; gap: 9px; font-size: 0.9rem; line-height: 1.4; cursor: pointer; outline: none; }
.ac-dot__mark {
    flex: 0 0 auto;
    width: 18px;
    height: 18px;
    margin-top: 1px;
    border: 1px solid var(--border-strong);
    border-radius: 50%;
    background: var(--white);
    position: relative;
    transition: border-color 0.12s;
}
.ac-dot__mark::after {
    content: "";
    position: absolute;
    inset: 4px;
    border-radius: 50%;
    background: var(--primary);
    transform: scale(0);
    transition: transform 0.12s;
}
.ac-dot:hover .ac-dot__mark { border-color: var(--text-faint); }
.ac-dot.is-on .ac-dot__mark { border-color: var(--primary); }
.ac-dot.is-on .ac-dot__mark::after { transform: scale(1); }
.ac-dots--accent .ac-dot.is-on .ac-dot__mark { border-color: var(--accent); }
.ac-dots--accent .ac-dot__mark::after { background: var(--accent); }
.ac-dot:focus-visible .ac-dot__mark { box-shadow: 0 0 0 3px var(--accent-ring); }
.ac-dot__main { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.ac-dot__note { font-size: 0.8rem; color: var(--text-gray); }
.ac-dot.is-off { cursor: default; opacity: 0.6; }

/* ---------- A date (controls.js date) ---------- */

.ac-date { position: relative; display: flex; align-items: center; width: 100%; min-width: 0; }
.ac-date--calendar .ac-date__input { padding-right: 40px; }
.ac-date__btn {
    position: absolute;
    right: 4px;
    top: 50%;
    transform: translateY(-50%);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border: 0;
    border-radius: 6px;
    background: none;
    color: var(--text-gray);
    cursor: pointer;
}
.ac-date__btn:hover, .ac-date--open .ac-date__btn { color: var(--primary); background: var(--light-gray); }
.ac-date__btn:disabled { cursor: default; opacity: 0.5; background: none; }
.ac-date--selects { display: grid; grid-template-columns: minmax(64px, 0.7fr) minmax(0, 1.4fr) minmax(76px, 0.9fr); gap: 6px; }
.ac-cal {
    position: fixed;
    z-index: 600;
    width: 268px;
    max-width: calc(100vw - 24px);
    padding: 10px;
    background: var(--white);
    border: 1px solid var(--border-gray);
    border-radius: 10px;
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.14);
    font-size: 0.85rem;
}
.ac-cal__head { display: flex; align-items: center; justify-content: space-between; gap: 6px; margin-bottom: 6px; }
.ac-cal__title { font-weight: 700; font-size: 0.88rem; }
.ac-cal__nav { width: 30px; height: 30px; color: var(--primary); }
.ac-cal__grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 2px; }
.ac-cal__wd { text-align: center; font-size: 0.7rem; font-weight: 600; color: var(--text-faint); padding: 4px 0; }
.ac-cal__day {
    height: 32px;
    border: 0;
    border-radius: 7px;
    background: none;
    font: inherit;
    font-size: 0.85rem;
    color: var(--primary);
    cursor: pointer;
}
.ac-cal__day:hover { background: var(--light-gray); }
.ac-cal__day:focus-visible { outline: none; box-shadow: 0 0 0 2px var(--primary) inset; }
.ac-cal__day.is-today { font-weight: 700; text-decoration: underline; text-underline-offset: 3px; }
.ac-cal__day.is-on { background: var(--primary); color: var(--white); }
.ac-cal__foot { display: flex; justify-content: flex-end; margin-top: 8px; padding-top: 8px; border-top: 1px solid var(--border-gray); }

/* ---------- Narrow screens ---------- */

@media (max-width: 1440px) {
    .content { padding: 24px; }
}

@media (max-width: 860px) {
    .grid { grid-template-columns: minmax(0, 1fr); }
    .panel { padding: 24px; }
}

@media (max-width: 768px) {
    :root { --sidebar-width: 64px; }

    .nav-item__label,
    .nav-item__soon,
    .brand__name,
    .nav-group__header,
    .sidebar-toggle {
        display: none;
    }

    .sidebar .brand,
    .nav-item,
    .nav-group__items .nav-item {
        padding-left: 0;
        padding-right: 0;
        justify-content: center;
        gap: 0;
    }

    .nav-group ~ .nav-group {
        margin-top: 10px;
        padding-top: 10px;
        border-top: 1px solid rgba(255, 255, 255, 0.12);
    }

    .topbar { padding: 0 16px; }
    .stage-badge { display: none; }
    .content { padding: 16px; }
    .home h2 { font-size: 1.7rem; }
    .progress { display: none; }
    .form-bar { padding: 10px 12px; }
}

.stim-edit__row .icon-only {
    height: var(--ac-control-h);
}

/* ---------- Segments: explicit 100% and the "i" window (SA-012) ---------- */

.seg-summary__head h2 {
    display: flex;
    align-items: center;
    gap: 6px;
}

/* A round "i" beside a title: the icon button of the kit, shrunk to the line. */
.info-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 26px;
    height: 26px;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: none;
    color: var(--text-gray);
    cursor: pointer;
    transition: var(--transition);
}

.info-btn .icon { width: 19px; height: 19px; }
.info-btn:hover { background: var(--light-gray); color: var(--accent-dark); }
.info-btn:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--accent-ring); }

/* Inline, not flex: the definition is a sentence and should wrap like one,
   with the size running on after it. */
.seg-market {
    margin: 0 0 10px;
    line-height: 1.5;
    font-size: 0.86rem;
    color: var(--text-gray);
}

.seg-market > span + span { margin-left: 6px; }
.seg-market__label { font-weight: 700; color: var(--primary); }
.seg-market__def { color: var(--ink-soft); }
.seg-market__def--none { color: var(--text-gray); font-style: italic; }
.seg-market__size { font-weight: 700; color: var(--primary); white-space: nowrap; }
.seg-market__range { font-size: 0.78rem; color: var(--text-faint); white-space: nowrap; }

/* SA-024: what changed since the last estimate (only then can it be recalculated),
   and the versions of the estimate under the bar. */
.seg-changes {
    margin: 0 0 12px;
    padding: 8px 12px;
    border-left: 3px solid var(--accent);
    background: var(--accent-wash);
    border-radius: 6px;
    font-size: 0.82rem;
    color: var(--ink-soft);
}
.seg-changes[hidden] { display: none; }
.seg-changes__line { margin: 0; line-height: 1.5; }
.seg-changes__line + .seg-changes__line { margin-top: 4px; }
.seg-changes__line b { color: var(--primary); font-weight: 700; }

.seg-versions { margin-top: 12px; font-size: 0.8rem; color: var(--text-gray); line-height: 1.5; }
.seg-versions[hidden] { display: none; }
.seg-versions p { margin: 0; }
.seg-versions__head b { color: var(--primary); font-weight: 700; }
.seg-versions__spread { margin-top: 2px !important; }
.seg-versions__link {
    margin-left: 8px;
    padding: 0;
    border: 0;
    background: none;
    font: inherit;
    font-weight: 600;
    color: var(--accent-dark);
    cursor: pointer;
}
.seg-versions__link:hover { text-decoration: underline; }
.seg-versions__link:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--accent-ring); border-radius: 4px; }

.seg-info {
    display: flex;
    flex-direction: column;
    gap: 22px;
    max-width: 880px;
    font-size: 0.9rem;
    line-height: 1.55;
    color: var(--ink-soft);
}

.seg-info__section + .seg-info__section {
    padding-top: 18px;
    border-top: 1px solid var(--border-gray);
}

.seg-info__h {
    margin-bottom: 8px;
    font-size: 0.78rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--text-gray);
}

.seg-info__p { margin: 0 0 8px; }
.seg-info__p:last-child { margin-bottom: 0; }
.seg-info__muted { color: var(--text-gray); font-size: 0.85rem; }
.seg-info__strong { font-weight: 700; color: var(--primary); }

.seg-info__quote {
    padding-left: 12px;
    border-left: 3px solid var(--accent);
    font-size: 1rem;
    font-weight: 600;
    color: var(--primary);
}

.seg-info__size {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px 12px;
    margin: 0 0 8px;
    color: var(--text-gray);
}

.seg-info__size b { font-size: 1.1rem; color: var(--primary); }

.seg-info__list {
    margin: 0 0 8px;
    padding-left: 20px;
}

.seg-info__list li + li { margin-top: 4px; }

/* A read-only table inside a scrolling dialog: no sticky head (it slid over
   the text above), no row hover promising a click, and the reasons wrap. */
.seg-info__table { width: 100%; font-size: 0.86rem; }
.seg-info__table th { position: static; padding: 9px 12px; }
.seg-info__table td { vertical-align: top; padding: 10px 12px; }
.seg-info__table .seg-info__why { white-space: normal; min-width: 320px; }
.seg-info__table tbody tr { cursor: default; }
.seg-info__table tbody tr:hover { background: none; }
.seg-info__table .seg-legend__dot { display: inline-block; }
.seg-info__table .num { white-space: nowrap; }
.seg-info__why { color: var(--text-gray); font-size: 0.84rem; }
.seg-info__rest td { color: var(--text-gray); }

/* SA-027: the category assumption's control, cross-checks, the card's sources line. */
.seg-cat {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: 10px;
    margin-top: 8px;
}
.seg-cat .ac-select { min-width: 200px; }
.seg-cat__nums { display: flex; gap: 8px; }
.seg-cat__nums[hidden] { display: none; }
.seg-cat__num { display: flex; flex-direction: column; gap: 2px; font-size: 0.78rem; }
.seg-cat__num input { width: 84px; }
.seg-info__scroll { max-width: 100%; overflow-x: auto; }
.seg-info__table--wrap td:not(.num) { white-space: normal; }
.seg-info__table .seg-info__note { white-space: normal; min-width: 150px; color: var(--text-gray); font-size: 0.84rem; }
.seg-cross { margin-top: 6px; color: var(--text-faint); font-size: 0.8rem; }
.seg-info__table td .badge { margin-left: 6px; }
.seg-info__table a { color: var(--primary); text-decoration: underline; text-decoration-color: var(--border-gray); }
.seg__sources { display: flex; align-items: center; gap: 4px; margin-top: 6px; }

/* ---------- A note that opens on click (tip.js, SA-012) ---------- */

/* Whatever has a note looks pressable: a pointer, and a hover that answers. */
.has-tip { cursor: pointer; }
.has-tip:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--accent-ring); }
.chip.has-tip { transition: var(--transition); }
.chip.has-tip:hover,
.chip.has-tip--open { border-color: var(--primary); background: var(--light-gray); }
.badge.has-tip:hover,
.badge.has-tip--open { box-shadow: 0 0 0 2px var(--accent-ring); }
.seg-bar__part.has-tip:hover,
.seg-bar__part.has-tip--open { filter: brightness(0.88); }

.tip-icon {
    display: inline-flex;
    vertical-align: -2px;
    margin-left: 6px;
    color: var(--text-gray);
}

.tip-icon:hover,
.tip-icon.has-tip--open { color: var(--accent-dark); }

/* 2026-10-17: «Not applied» of a funnel block — an orange «i». */
.tip-icon.tip-icon--warn { color: var(--accent); }

.tip-pop {
    /* Fixed, placed by tip.js inside the window: max-width by the amount of text (260 / 360 / 480 px), max-height
       the window's; above dialogs (.ac-dialog__back 400) and the other popups. */
    position: fixed;
    z-index: 1100;
    box-sizing: border-box;
    display: flex;
    width: max-content;
    max-width: min(360px, calc(100vw - 24px));
    max-height: calc(100vh - 24px);
    padding: 12px 6px 12px 14px;
    background: var(--white);
    border: 1px solid var(--border-gray);
    border-radius: 10px;
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.14);
    font-size: 0.82rem;
    line-height: 1.5;
    color: var(--ink-soft);
}

.tip-pop[hidden] { display: none; }
.tip-pop__body { min-width: 0; flex: 1 1 auto; overflow-y: auto; overscroll-behavior: contain; padding-right: 28px; overflow-wrap: anywhere; }
.tip-pop__close {
    position: absolute;
    top: 8px;
    right: 8px;
    display: inline-flex;
    padding: 3px;
    border: 0;
    border-radius: 4px;
    background: none;
    color: var(--text-faint);
    cursor: pointer;
}

.tip-pop__close:hover { color: var(--primary); background: var(--light-gray); }

.tip-pop__title {
    margin-bottom: 6px;
    font-weight: 700;
    color: var(--primary);
}

.tip-pop__row {
    display: grid;
    grid-template-columns: 76px 1fr;
    gap: 8px;
}

.tip-pop__key { color: var(--text-faint); }
.tip-pop__row + .tip-pop__row { margin-top: 3px; }
.tip-pop__line { margin: 6px 0 0; }
.tip-pop__row + .tip-pop__line { margin-top: 8px; }
.tip-pop__note { margin: 8px 0 0; font-size: 0.76rem; color: var(--text-gray); }
/* A hint on hover and focus (tip.js hint — what a title was): the same box, no ×, one line of text. */
.tip-pop--hint { padding: 7px 11px; pointer-events: none; }
.tip-pop--hint .tip-pop__body { padding-right: 0; }
.tip-pop--hint .tip-pop__line { margin: 0; }
/* Why a button cannot be pressed now: one quiet line beside it (tip.js why). */
.why-off { font-size: 0.8rem; color: var(--text-gray); }

