/* ————————————————————————————————————————
   CARDS
   ———————————————————————————————————————— */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border-strong);
    border-radius: 10px;
    padding: var(--s-6);
    position: relative;
}

.card + .card {
    margin-top: var(--s-4);
}


/* ————————————————————————————————————————
   GRID
   ———————————————————————————————————————— */
.grid {
    display: grid;
    gap: var(--s-4);
}

.g-2 { grid-template-columns: 1fr; }
.g-3 { grid-template-columns: 1fr; }
.g-4 { grid-template-columns: 1fr; }

@media (min-width: 580px) {
    .g-2 { grid-template-columns: repeat(2, 1fr); }
    .g-3 { grid-template-columns: repeat(2, 1fr); }
    .g-4 { grid-template-columns: repeat(2, 1fr); }
}

@media (min-width: 900px) {
    .g-3 { grid-template-columns: repeat(3, 1fr); }
}

@media (min-width: 1000px) {
    .g-4 { grid-template-columns: repeat(4, 1fr); }
}

/* Reset card margin inside grids */
.grid > .card + .card {
    margin-top: 0;
}


/* ————————————————————————————————————————
   TYPOGRAPHY
   ———————————————————————————————————————— */
.h-lg {
    font-size: var(--t-xl);
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: -0.015em;
    line-height: 1.3;
}

.h-md {
    font-size: var(--t-lg);
    font-weight: 600;
    color: var(--accent);
    letter-spacing: -0.01em;
    line-height: 1.35;
}

/* Card heading with underline separator */
.h-md-ruled {
    font-size: var(--t-lg);
    font-weight: 600;
    color: var(--accent);
    letter-spacing: -0.01em;
    line-height: 1.35;
    padding-bottom: var(--s-3);
    border-bottom: 1px solid var(--border);
}

.h-sm {
    font-size: var(--t-md);
    font-weight: 600;
    color: var(--text-primary);
    line-height: 1.4;
}

.label {
    font-size: var(--t-xs);
    font-weight: 500;
    color: var(--text-tertiary);
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

.body {
    font-size: var(--t-base);
    color: var(--text-secondary);
    line-height: 1.6;
}

.small {
    font-size: var(--t-sm);
    color: var(--text-secondary);
    line-height: 1.55;
}

.tiny {
    font-size: var(--t-xs);
    color: var(--text-tertiary);
    line-height: 1.5;
}

.mono {
    font-family: var(--mono);
    font-size: var(--t-sm);
}

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


/* ————————————————————————————————————————
   CALLOUT — dark featured block
   ———————————————————————————————————————— */
.callout {
    background: var(--bg-dark);
    color: var(--text-inverse);
    border-radius: var(--r-lg);
    padding: var(--s-6) var(--s-8);
}

.callout-title {
    font-size: var(--t-xl);
    font-weight: 700;
    color: var(--text-inverse);
    margin-bottom: var(--s-3);
}

.callout-body {
    font-size: var(--t-base);
    color: var(--text-dark-body);
    line-height: 1.7;
}

.callout-body strong {
    font-weight: 600;
    color: var(--text-inverse);
}

.callout-cite {
    font-size: var(--t-xs);
    color: var(--text-tertiary);
    margin-top: var(--s-4);
}

/* — Light callout variant (for inline notes) — */
.callout-light {
    background: var(--bg-callout);
    border-left: 3px solid var(--accent);
    border-radius: var(--r-md);
    padding: var(--s-5) var(--s-6);
    color: var(--text-primary);
}

.callout-light .callout-title {
    font-size: var(--t-md);
    color: var(--text-primary);
}

.callout-light .callout-body {
    color: var(--text-secondary);
}

.callout-light .callout-body strong {
    color: var(--text-primary);
}

.callout-light .callout-cite {
    color: var(--text-tertiary);
}


/* ————————————————————————————————————————
   CARD ICON
   ———————————————————————————————————————— */
.card-icon {
    width: 20px;
    height: 20px;
    color: var(--accent);
    margin-bottom: var(--s-3);
}


/* ————————————————————————————————————————
   BADGE
   ———————————————————————————————————————— */
.badge {
    display: inline-block;
    font-size: 10px;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    padding: 2px 6px;
    border-radius: var(--r-sm);
    line-height: 1.3;
}

.badge-default {
    background: var(--accent-subtle);
    color: var(--accent);
}

.badge-accent {
    background: var(--accent);
    color: var(--text-inverse);
}

.badge-pin {
    position: absolute;
    top: var(--s-3);
    right: var(--s-3);
}

.badge-warn {
    color: var(--negative);
    font-size: var(--t-xs);
    font-weight: 500;
}


/* ————————————————————————————————————————
   LISTS
   ———————————————————————————————————————— */
.ul {
    list-style: none;
    padding: 0;
}

.ul li {
    font-size: var(--t-sm);
    color: var(--text-secondary);
    padding: var(--s-2) 0;
    border-bottom: 1px solid var(--border);
    line-height: 1.5;
}

.ul li:last-child {
    border-bottom: none;
}

.ol {
    list-style: decimal;
    padding-left: var(--s-5);
}

.ol li {
    font-size: var(--t-sm);
    color: var(--text-secondary);
    padding: var(--s-1) 0;
    line-height: 1.55;
}

.check-list {
    list-style: none;
    padding: 0;
}

.check-list li {
    display: flex;
    align-items: flex-start;
    gap: var(--s-2);
    font-size: var(--t-sm);
    color: var(--text-secondary);
    padding: var(--s-1) 0;
    line-height: 1.55;
}

.check-mark {
    width: 15px;
    height: 15px;
    color: var(--positive);
    flex-shrink: 0;
    margin-top: 3px;
}

.disc-list {
    list-style: disc;
    padding-left: var(--s-5);
}

.disc-list li {
    font-size: var(--t-sm);
    color: var(--text-secondary);
    padding: var(--s-1) 0;
    line-height: 1.55;
}

.dark-block .disc-list li,
.dark-inner .disc-list li {
    color: var(--text-dark-body);
}


/* ————————————————————————————————————————
   ACCORDION
   ———————————————————————————————————————— */
.accordion + .accordion {
    margin-top: var(--s-2);
}

.acc-trigger {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--s-4);
    width: 100%;
    padding: var(--s-3) var(--s-4);
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    background: var(--bg-card);
    font-family: var(--sans);
    font-size: var(--t-base);
    font-weight: 500;
    color: var(--text-primary);
    text-align: left;
    cursor: pointer;
    transition: background var(--ease);
}

.acc-trigger:hover {
    background: var(--bg-hover);
}

.acc-left {
    display: flex;
    align-items: center;
    gap: var(--s-3);
}

.acc-icon {
    width: 16px;
    height: 16px;
    color: var(--text-tertiary);
    flex-shrink: 0;
}

.acc-chevron {
    width: 14px;
    height: 14px;
    color: var(--text-tertiary);
    transition: transform 200ms ease;
    flex-shrink: 0;
}

.accordion.is-open .acc-trigger {
    border-bottom-left-radius: 0;
    border-bottom-right-radius: 0;
    border-bottom-color: var(--border);
}

.accordion.is-open .acc-chevron {
    transform: rotate(180deg);
}

.acc-body {
    display: none;
    padding: var(--s-5);
    border: 1px solid var(--border);
    border-top: none;
    border-radius: 0 0 var(--r-lg) var(--r-lg);
    background: var(--bg-card);
}

.accordion.is-open .acc-body {
    display: block;
}


/* ————————————————————————————————————————
   FORMS
   ———————————————————————————————————————— */
.form-group + .form-group {
    margin-top: var(--s-4);
}

.form-label {
    display: block;
    font-size: var(--t-sm);
    font-weight: 500;
    color: var(--text-primary);
    margin-bottom: var(--s-1);
}

.form-hint {
    font-size: var(--t-xs);
    color: var(--text-tertiary);
    margin-bottom: var(--s-1);
}

.form-input {
    width: 100%;
    padding: 7px var(--s-3);
    border: 1px solid var(--border-strong);
    border-radius: var(--r-md);
    background: var(--bg-input);
    font-family: var(--sans);
    font-size: var(--t-base);
    color: var(--text-primary);
    transition: border-color var(--ease), box-shadow var(--ease);
    line-height: 1.5;
}

.form-input:focus {
    outline: none;
    border-color: var(--border-focus);
    box-shadow: 0 0 0 3px var(--accent-subtle);
}

.range-slider {
    width: 100%;
    accent-color: var(--accent);
    height: 4px;
    cursor: pointer;
}

.range-labels {
    display: flex;
    justify-content: space-between;
    font-family: var(--mono);
    font-size: var(--t-xs);
    color: var(--text-tertiary);
    margin-top: var(--s-1);
}

.range-val {
    font-weight: 600;
    color: var(--text-primary);
}


/* ————————————————————————————————————————
   RESULT DISPLAY
   ———————————————————————————————————————— */
.result {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    padding-top: var(--s-4);
    margin-top: var(--s-4);
    border-top: 1px solid var(--border);
}

.result-label {
    font-size: var(--t-xs);
    font-weight: 500;
    color: var(--text-tertiary);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.result-value {
    font-size: var(--t-xl);
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: -0.02em;
    font-family: var(--mono);
}


/* ————————————————————————————————————————
   CHART
   ———————————————————————————————————————— */
.chart-wrap {
    position: relative;
    width: 100%;
    height: 280px;
}

@media (min-width: 768px) {
    .chart-wrap {
        height: 320px;
    }
}


/* ————————————————————————————————————————
   SPLIT LAYOUT
   ———————————————————————————————————————— */
.split {
    display: flex;
    flex-direction: column;
    gap: var(--s-8);
}

@media (min-width: 900px) {
    .split {
        flex-direction: row;
        align-items: flex-start;
    }

    .split-side {
        width: 320px;
        flex-shrink: 0;
    }

    .split-main {
        flex: 1;
        min-width: 0;
    }
}


/* ————————————————————————————————————————
   TWO-COL CONTENT
   ———————————————————————————————————————— */
.cols {
    display: grid;
    grid-template-columns: 1fr;
    gap: var(--s-5);
}

@media (min-width: 580px) {
    .cols {
        grid-template-columns: 1fr 1fr;
    }
}


/* ————————————————————————————————————————
   DARK BLOCK (charcoal featured sections)
   ———————————————————————————————————————— */
.dark-block {
    background: var(--bg-dark);
    color: var(--text-inverse);
    border-radius: var(--r-lg);
    padding: var(--s-6);
}

.dark-block .h-md {
    color: var(--text-dark-body);
}

.dark-block .h-sm,
.dark-inner .h-sm {
    color: var(--text-inverse);
}

.dark-block .small,
.dark-block .tiny,
.dark-block p {
    color: var(--text-dark-body);
}

.dark-block strong {
    color: var(--text-inverse);
}

.dark-block .stat-value {
    color: var(--text-inverse);
}

.dark-block .stat-label {
    color: var(--text-dark-body);
}

.dark-block .stat-desc {
    color: var(--text-dark-body);
}

.dark-inner {
    background: var(--bg-dark-alt);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: var(--r-md);
    padding: var(--s-5);
}

.dark-inner li {
    color: var(--text-dark-body);
}

.dark-inner strong {
    color: var(--text-inverse);
}

/* — Light tinted variant (for inside accordions etc.) — */
.tinted {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    padding: var(--s-5);
}


/* ————————————————————————————————————————
   CODE BLOCK
   ———————————————————————————————————————— */
.code {
    background: var(--bg-code);
    border: 1px solid var(--border);
    border-radius: var(--r-md);
    padding: var(--s-3) var(--s-4);
    font-family: var(--mono);
    font-size: var(--t-sm);
    color: var(--text-primary);
    line-height: 1.7;
    overflow-x: auto;
}


/* ————————————————————————————————————————
   SCHEDULE GRID (travel)
   ———————————————————————————————————————— */
.schedule {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: var(--s-1);
    text-align: center;
    font-family: var(--mono);
    font-size: var(--t-xs);
}

.schedule-day {
    padding: var(--s-2) var(--s-1);
    border-radius: var(--r-sm);
    line-height: 1.4;
}

.schedule-biz {
    background: var(--accent);
    color: var(--text-inverse);
}

.schedule-off {
    background: var(--bg-dark-alt);
    color: var(--text-tertiary);
}

/* Inside dark blocks, adjust schedule */
.dark-block .schedule-off {
    background: rgba(255, 255, 255, 0.06);
    color: var(--text-tertiary);
}


/* ————————————————————————————————————————
   NOTE (left-bar callout, smaller)
   ———————————————————————————————————————— */
.note {
    background: var(--bg-callout);
    border-left: 2px solid var(--border-strong);
    border-radius: 0 var(--r-sm) var(--r-sm) 0;
    padding: var(--s-3) var(--s-4);
    font-size: var(--t-sm);
    font-style: italic;
    color: var(--text-secondary);
    line-height: 1.55;
}


/* ————————————————————————————————————————
   EXAMPLE BLOCK
   ———————————————————————————————————————— */
.example {
    background: var(--bg-secondary);
    padding: var(--s-4);
    border-radius: var(--r-md);
    border: 1px solid var(--border);
}

.example-label {
    font-size: var(--t-xs);
    font-weight: 600;
    color: var(--text-tertiary);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-bottom: var(--s-2);
}


/* ————————————————————————————————————————
   CALCULATOR WELL
   ———————————————————————————————————————— */
.calc-well {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    padding: var(--s-5);
}


/* ————————————————————————————————————————
   DIVIDER
   ———————————————————————————————————————— */
.divider {
    border: none;
    border-top: 1px solid var(--border);
    margin: var(--s-6) 0;
}


/* ————————————————————————————————————————
   SPACING HELPERS
   ———————————————————————————————————————— */
.mb-2  { margin-bottom: var(--s-2); }
.mb-3  { margin-bottom: var(--s-3); }
.mb-4  { margin-bottom: var(--s-4); }
.mb-5  { margin-bottom: var(--s-5); }
.mb-6  { margin-bottom: var(--s-6); }
.mb-8  { margin-bottom: var(--s-8); }
.mb-10 { margin-bottom: var(--s-10); }
.mt-3  { margin-top: var(--s-3); }
.mt-4  { margin-top: var(--s-4); }
.mt-5  { margin-top: var(--s-5); }
.mt-6  { margin-top: var(--s-6); }

/* Flex column card */
.flex-col {
    display: flex;
    flex-direction: column;
}

.flex-between {
    justify-content: space-between;
}

.flex-1 {
    flex: 1;
}


/* ————————————————————————————————————————
   ORG CHART / STRUCTURE DIAGRAM
   (CSS-only entity hierarchy visualization)
   ———————————————————————————————————————— */
.org {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0;
    padding: var(--s-6) var(--s-2);
    overflow-x: auto;
}

.org-node {
    background: var(--bg-card);
    border: 1px solid var(--border-strong);
    border-radius: var(--r-md);
    padding: var(--s-3) var(--s-5);
    text-align: center;
    font-size: var(--t-sm);
    font-weight: 500;
    color: var(--text-primary);
    position: relative;
    min-width: 160px;
    line-height: 1.4;
}

.org-node-sub {
    font-size: var(--t-xs);
    color: var(--text-tertiary);
    font-weight: 400;
    display: block;
    margin-top: 2px;
}

.org-node-accent {
    background: var(--accent);
    color: var(--text-inverse);
    border-color: var(--accent);
}

.org-node-accent .org-node-sub {
    color: rgba(255, 255, 255, 0.7);
}

.org-node-dark {
    background: var(--bg-dark);
    color: var(--text-inverse);
    border-color: var(--bg-dark);
}

.org-node-dark .org-node-sub {
    color: var(--text-dark-body);
}

.org-node-muted {
    background: var(--bg-secondary);
    border: 1px dashed var(--border-strong);
    color: var(--text-secondary);
}

.org-connector {
    width: 2px;
    height: 24px;
    background: var(--border-strong);
    flex-shrink: 0;
}

.org-branch {
    display: flex;
    gap: var(--s-4);
    align-items: flex-start;
    position: relative;
    flex-wrap: wrap;
    justify-content: center;
}

.org-branch::before {
    content: '';
    position: absolute;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    height: 2px;
    background: var(--border-strong);
}

.org-arm {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0;
}

.org-arm .org-connector {
    height: 20px;
}

/* Horizontal connector between branches */
.org-hline {
    position: relative;
    display: flex;
    justify-content: center;
    width: 100%;
    height: 24px;
}

.org-hline::after {
    content: '';
    position: absolute;
    top: 50%;
    height: 2px;
    background: var(--border-strong);
}

.org-hline-2::after { left: 25%; right: 25%; }
.org-hline-3::after { left: 16%; right: 16%; }
.org-hline-4::after { left: 12%; right: 12%; }
.org-hline-5::after { left: 10%; right: 10%; }


/* ————————————————————————————————————————
   DATA TABLE
   ———————————————————————————————————————— */
.table-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
}

.table {
    width: 100%;
    border-collapse: collapse;
    font-size: var(--t-sm);
    line-height: 1.5;
}

.table th {
    background: var(--bg-secondary);
    font-weight: 600;
    color: var(--text-primary);
    text-align: left;
    padding: var(--s-3) var(--s-4);
    border-bottom: 1px solid var(--border-strong);
    white-space: nowrap;
}

.table td {
    padding: var(--s-3) var(--s-4);
    color: var(--text-secondary);
    border-bottom: 1px solid var(--border);
    vertical-align: top;
}

.table tr:last-child td {
    border-bottom: none;
}

.table tr:hover td {
    background: var(--bg-hover);
}

.table .cell-accent {
    color: var(--accent);
    font-weight: 600;
}

.table .cell-positive {
    color: var(--positive);
    font-weight: 500;
}

.table .cell-negative {
    color: var(--negative);
    font-weight: 500;
}

.table .cell-mono {
    font-family: var(--mono);
    font-size: var(--t-xs);
}


/* ————————————————————————————————————————
   STAT CARDS (key figures)
   ———————————————————————————————————————— */
.stat {
    text-align: center;
    padding: var(--s-5);
}

.stat-value {
    font-family: var(--mono);
    font-size: var(--t-2xl);
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: -0.02em;
    line-height: 1.2;
}

.stat-label {
    font-size: var(--t-xs);
    color: var(--text-tertiary);
    margin-top: var(--s-1);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.stat-desc {
    font-size: var(--t-xs);
    color: var(--text-secondary);
    margin-top: var(--s-2);
    line-height: 1.4;
}


/* ————————————————————————————————————————
   TABS (for sub-navigation within sections)
   ———————————————————————————————————————— */
.tabs {
    display: flex;
    gap: 0;
    border-bottom: 1px solid var(--border);
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.tab-btn {
    padding: var(--s-3) var(--s-5);
    border: none;
    background: none;
    font-family: var(--sans);
    font-size: var(--t-sm);
    font-weight: 500;
    color: var(--text-tertiary);
    cursor: pointer;
    white-space: nowrap;
    border-bottom: 2px solid transparent;
    margin-bottom: -1px;
    transition: color var(--ease), border-color var(--ease);
}

.tab-btn:hover {
    color: var(--text-secondary);
}

.tab-btn.is-active {
    color: var(--accent);
    border-bottom-color: var(--accent);
    font-weight: 600;
}

.tab-panel {
    display: none;
    padding-top: var(--s-5);
}

.tab-panel.is-active {
    display: block;
}


/* ————————————————————————————————————————
   FLOW ARROW (between structure elements)
   ———————————————————————————————————————— */
.flow-row {
    display: flex;
    align-items: center;
    gap: var(--s-3);
    flex-wrap: wrap;
    justify-content: center;
}

.flow-arrow {
    width: 20px;
    height: 20px;
    color: var(--text-tertiary);
    flex-shrink: 0;
}


/* ————————————————————————————————————————
   PILL / TAG
   ———————————————————————————————————————— */
.pill {
    display: inline-block;
    font-size: 10px;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 999px;
    letter-spacing: 0.03em;
}

.pill-green {
    background: rgba(61, 122, 63, 0.1);
    color: var(--positive);
}

.pill-red {
    background: rgba(181, 74, 50, 0.1);
    color: var(--negative);
}

.pill-blue {
    background: rgba(91, 127, 165, 0.1);
    color: var(--info);
}

.pill-tan {
    background: var(--accent-subtle);
    color: var(--accent);
}


/* ————————————————————————————————————————
   SECTION NUMBER (for long-form sections)
   ———————————————————————————————————————— */
.section-num {
    font-family: var(--mono);
    font-size: var(--t-xs);
    color: var(--text-tertiary);
    margin-bottom: var(--s-2);
}


/* ————————————————————————————————————————
   WARNING / CAUTION BLOCK
   ———————————————————————————————————————— */
.warning {
    background: rgba(181, 74, 50, 0.05);
    border-left: 3px solid var(--negative);
    border-radius: var(--r-md);
    padding: var(--s-4) var(--s-5);
    font-size: var(--t-sm);
    color: var(--text-secondary);
    line-height: 1.55;
}

.warning strong {
    color: var(--negative);
    font-weight: 600;
}

/* Info block */
.info-block {
    background: rgba(91, 127, 165, 0.05);
    border-left: 3px solid var(--info);
    border-radius: var(--r-md);
    padding: var(--s-4) var(--s-5);
    font-size: var(--t-sm);
    color: var(--text-secondary);
    line-height: 1.55;
}


/* ————————————————————————————————————————
   COMPARISON COLUMNS
   ———————————————————————————————————————— */
.vs {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    gap: var(--s-4);
    align-items: start;
}

@media (max-width: 580px) {
    .vs {
        grid-template-columns: 1fr;
    }
    .vs-divider { display: none; }
}

.vs-divider {
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: var(--t-sm);
    font-weight: 700;
    color: var(--text-tertiary);
    padding-top: var(--s-8);
}


/* ————————————————————————————————————————
   A11Y
   ———————————————————————————————————————— */
.sr-only {
    position: absolute;
    width: 1px; height: 1px;
    padding: 0; margin: -1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    border: 0;
}

:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

/* Hide number input spinners */
input[type="number"]::-webkit-inner-spin-button,
input[type="number"]::-webkit-outer-spin-button {
    -webkit-appearance: none;
    margin: 0;
}
input[type="number"] {
    -moz-appearance: textfield;
}


/* ————————————————————————————————————————
   BRACKET BAR (tax calculator)
   ———————————————————————————————————————— */
.bracket-bar {
    display: flex;
    border-radius: var(--r-md);
    overflow: hidden;
    height: 32px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
}

.bracket-seg {
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 0;
    transition: width 300ms ease;
}

.bracket-seg span {
    font-family: var(--mono);
    font-size: 10px;
    font-weight: 600;
    color: #fff;
    text-shadow: 0 1px 2px rgba(0,0,0,0.3);
    white-space: nowrap;
}


/* ————————————————————————————————————————
   FORM CHECKBOX
   ———————————————————————————————————————— */
.form-check {
    display: flex;
    align-items: flex-start;
    gap: var(--s-2);
    font-size: var(--t-sm);
    color: var(--text-secondary);
    cursor: pointer;
    line-height: 1.5;
    margin-top: var(--s-2);
}

.form-check input[type="checkbox"] {
    accent-color: var(--accent);
    margin-top: 3px;
    flex-shrink: 0;
}


/* ————————————————————————————————————————
   AI CHAT
   ———————————————————————————————————————— */

/* Desktop: contained within the content area */
.chat-container {
    display: flex;
    flex-direction: column;
    height: calc(100vh - 200px);
    min-height: 500px;
    border: 1px solid var(--border-strong);
    border-radius: var(--r-lg);
    overflow: hidden;
    background: var(--bg-card);
}

/* Mobile: full-screen takeover — edge-to-edge, no gaps */
@media (max-width: 767px) {
    /* Remove all padding from main when chat is active */
    .chat-section.is-active {
        margin: calc(-1 * var(--s-6)) calc(-1 * var(--s-4));
    }

    /* Hide the section head on mobile for chat — go straight to chat */
    .chat-section.is-active .section-head {
        display: none;
    }

    .chat-container {
        height: calc(100vh - 52px); /* 52px = mobile nav toggle height */
        height: calc(100dvh - 52px); /* Dynamic viewport for mobile browsers */
        min-height: 0;
        border: none;
        border-radius: 0;
    }
}

/* Messages area */
.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: var(--s-5);
    display: flex;
    flex-direction: column;
    gap: var(--s-4);
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
}

@media (max-width: 767px) {
    .chat-messages {
        padding: var(--s-3);
        gap: var(--s-3);
    }
}

/* Message row */
.chat-msg {
    display: flex;
    gap: var(--s-3);
    max-width: 85%;
    animation: enter 200ms ease;
}

.chat-user {
    align-self: flex-end;
    flex-direction: row-reverse;
}

.chat-ai {
    align-self: flex-start;
}

@media (max-width: 767px) {
    .chat-msg {
        max-width: 94%;
        gap: var(--s-2);
    }

    .chat-ai {
        max-width: 96%;
    }
}

/* Avatars */
.chat-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

@media (max-width: 767px) {
    .chat-avatar {
        width: 28px;
        height: 28px;
    }
}

.chat-ai .chat-avatar {
    background: var(--accent);
}

.chat-user .chat-avatar {
    background: var(--bg-dark);
}

.chat-avatar-icon {
    width: 16px;
    height: 16px;
    color: var(--text-inverse);
}

@media (max-width: 767px) {
    .chat-avatar-icon {
        width: 14px;
        height: 14px;
    }
}

/* Bubbles */
.chat-bubble {
    padding: var(--s-3) var(--s-4);
    border-radius: 18px;
    font-size: var(--t-sm);
    line-height: 1.55;
    color: var(--text-primary);
    word-break: break-word;
}

@media (max-width: 767px) {
    .chat-bubble {
        padding: 10px 14px;
        border-radius: 16px;
        font-size: 14px;
        line-height: 1.5;
    }
}

.chat-ai .chat-bubble {
    background: var(--bg-secondary);
    border-bottom-left-radius: 4px;
}

.chat-user .chat-bubble {
    background: var(--accent);
    color: var(--text-inverse);
    border-bottom-right-radius: 4px;
}

.chat-bubble p {
    color: inherit;
    font-size: inherit;
}

.chat-bubble strong {
    font-weight: 600;
    color: inherit;
}

.chat-bubble ul, .chat-bubble ol {
    color: inherit;
}

.chat-bubble li {
    color: inherit;
}

/* Typing indicator */
.chat-typing .typing-dots {
    display: flex;
    gap: 5px;
    padding: 6px 0;
}

.typing-dots span {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--text-tertiary);
    animation: typingBounce 1.4s infinite both;
}

.typing-dots span:nth-child(2) { animation-delay: 0.2s; }
.typing-dots span:nth-child(3) { animation-delay: 0.4s; }

@keyframes typingBounce {
    0%, 80%, 100% { transform: translateY(0); opacity: 0.4; }
    40% { transform: translateY(-6px); opacity: 1; }
}

/* Input area — pinned to bottom */
.chat-input-wrap {
    border-top: 1px solid var(--border);
    padding: var(--s-3) var(--s-4);
    background: var(--bg-card);
}

@media (max-width: 767px) {
    .chat-input-wrap {
        padding: var(--s-3);
        padding-bottom: max(var(--s-3), env(safe-area-inset-bottom));
    }
}

.chat-input-row {
    display: flex;
    gap: var(--s-2);
    align-items: flex-end;
}

.chat-input {
    flex: 1;
    padding: 10px 14px;
    border: 1px solid var(--border-strong);
    border-radius: 20px;
    background: var(--bg-input);
    font-family: var(--sans);
    font-size: 16px;
    color: var(--text-primary);
    resize: none;
    line-height: 1.5;
    max-height: 120px;
    transition: border-color var(--ease);
}

.chat-input:focus {
    outline: none;
    border-color: var(--border-focus);
    box-shadow: 0 0 0 3px var(--accent-subtle);
}

.chat-input::placeholder {
    color: var(--text-tertiary);
    font-size: var(--t-sm);
}

@media (max-width: 767px) {
    .chat-input {
        font-size: 16px; /* Prevents iOS zoom */
        padding: 10px 14px;
        border-radius: 20px;
    }

    .chat-input::placeholder {
        font-size: 14px;
    }
}

/* Send button */
.chat-send {
    width: 42px;
    height: 42px;
    border: none;
    border-radius: 50%;
    background: var(--accent);
    color: var(--text-inverse);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: background var(--ease), transform 100ms ease;
    -webkit-tap-highlight-color: transparent;
}

.chat-send:hover {
    background: var(--accent-hover);
}

.chat-send:active {
    transform: scale(0.92);
}

.chat-send-icon {
    width: 18px;
    height: 18px;
}

.chat-disclaimer {
    font-size: 11px;
    color: var(--text-tertiary);
    margin-top: var(--s-2);
    text-align: center;
}

@media (max-width: 767px) {
    .chat-disclaimer {
        font-size: 10px;
        margin-top: 4px;
    }
}

/* RTL support */
html[dir="rtl"] .chat-user {
    flex-direction: row;
}

html[dir="rtl"] .chat-ai {
    flex-direction: row-reverse;
}

html[dir="rtl"] .chat-ai .chat-bubble {
    border-bottom-left-radius: 18px;
    border-bottom-right-radius: 4px;
}

html[dir="rtl"] .chat-user .chat-bubble {
    border-bottom-right-radius: 18px;
    border-bottom-left-radius: 4px;
}
