/* Interactive Height Comparison Simulator Widget — scoped strictly to .hcw-card */
.hcw-card {
    --hcw-surface: #ffffff;
    --hcw-surface-subtle: #f8f9fc;
    --hcw-surface-muted: #f1f4fa;
    --hcw-ink: #1e2433;
    --hcw-muted: #646d82;
    --hcw-border: #e4e7f0;
    --hcw-accent: #5b46e5;
    --hcw-accent-soft: #eef0ff;
    --hcw-accent-hover: #4834d4;
    --hcw-radius: 14px;
    --hcw-radius-sm: 10px;
    box-sizing: border-box;
    background: var(--hcw-surface);
    color: var(--hcw-ink);
    border: 1px solid var(--hcw-border);
    border-radius: var(--hcw-radius);
    padding: 24px 26px;
    margin: 0 0 26px;
    box-shadow: 0 10px 30px rgba(15, 23, 42, 0.04);
    font-family: system-ui, -apple-system, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
    line-height: 1.5;
    overflow-wrap: anywhere;
}

.hcw-card *,
.hcw-card *::before,
.hcw-card *::after {
    box-sizing: border-box;
}

.hcw-card [hidden] {
    display: none !important;
}

/* Host container integrations */
main.ordinary-detail-taste .hcw-card {
    --hcw-accent: #6742c1;
    --hcw-accent-soft: #f2edfb;
    --hcw-accent-hover: #5633ad;
    --hcw-border: #e6e3ed;
    box-shadow: none;
    margin-bottom: 26px;
}

.paid-tool-showcase .hcw-card,
.pts-shell .hcw-card {
    --hcw-accent: #276354;
    --hcw-accent-soft: #eaf2ee;
    --hcw-accent-hover: #1d4f42;
    --hcw-border: #dfe6e2;
    margin-top: 26px;
    margin-bottom: 26px;
}

.paid-tool-showcase > .hcw-card {
    width: min(1260px, calc(100% - 80px));
    margin-inline: auto;
}

.ai-v5-main .hcw-card {
    margin-bottom: 24px;
}

[data-theme="dark"] .hcw-card {
    --hcw-surface: #151924;
    --hcw-surface-subtle: #1c2230;
    --hcw-surface-muted: #242c3d;
    --hcw-ink: #f1f5f9;
    --hcw-muted: #94a3b8;
    --hcw-border: rgba(148, 163, 184, 0.2);
    --hcw-accent: #818cf8;
    --hcw-accent-soft: rgba(129, 140, 248, 0.16);
    --hcw-accent-hover: #6366f1;
}

.hcw-sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* Header */
.hcw-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px 24px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--hcw-border);
}

.hcw-header-copy {
    min-width: 0;
    flex: 1 1 auto;
}

.hcw-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    border-radius: 999px;
    background: var(--hcw-accent-soft);
    color: var(--hcw-accent);
    font-size: 11.5px;
    font-weight: 700;
    letter-spacing: 0.02em;
    margin-bottom: 8px;
}

.hcw-title {
    margin: 0;
    color: var(--hcw-ink);
    font-size: clamp(19px, 2vw, 23px);
    font-weight: 700;
    line-height: 1.28;
    letter-spacing: -0.02em;
}

.hcw-subtitle {
    margin: 6px 0 0;
    color: var(--hcw-muted);
    font-size: 13.5px;
    line-height: 1.55;
    max-width: 78ch;
}

/* Unit Switch */
.hcw-unit-switch {
    display: inline-flex;
    flex: 0 0 auto;
    padding: 3px;
    border-radius: 10px;
    background: var(--hcw-surface-muted);
    border: 1px solid var(--hcw-border);
}

.hcw-unit-btn {
    appearance: none;
    border: 0;
    background: transparent;
    color: var(--hcw-muted);
    font: inherit;
    font-size: 13px;
    font-weight: 600;
    padding: 7px 14px;
    border-radius: 7px;
    cursor: pointer;
    transition: background-color 0.15s ease, color 0.15s ease, box-shadow 0.15s ease;
    white-space: nowrap;
}

.hcw-unit-btn.is-active {
    background: var(--hcw-surface);
    color: var(--hcw-accent);
    box-shadow: 0 1px 4px rgba(15, 23, 42, 0.08);
}

/* Toolbar & Presets */
.hcw-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 10px 16px;
    padding: 12px 0 16px;
}

.hcw-presets {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 7px;
}

.hcw-presets-label {
    font-size: 12px;
    font-weight: 600;
    color: var(--hcw-muted);
    margin-inline-end: 2px;
}

.hcw-chip,
.hcw-tool-btn {
    appearance: none;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    border-radius: 999px;
    border: 1px solid var(--hcw-border);
    background: var(--hcw-surface-subtle);
    color: var(--hcw-ink);
    font: inherit;
    font-size: 12.5px;
    font-weight: 600;
    cursor: pointer;
    transition: border-color 0.15s ease, background-color 0.15s ease, color 0.15s ease;
}

.hcw-chip:hover,
.hcw-tool-btn:hover {
    border-color: var(--hcw-accent);
    color: var(--hcw-accent);
}

.hcw-chip.is-active {
    background: var(--hcw-accent-soft);
    border-color: var(--hcw-accent);
    color: var(--hcw-accent);
}

.hcw-toolbar-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 12px;
}

.hcw-eye-toggle {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 12.5px;
    font-weight: 500;
    color: var(--hcw-muted);
    cursor: pointer;
    user-select: none;
}

.hcw-eye-toggle input {
    width: 15px;
    height: 15px;
    accent-color: var(--hcw-accent);
    cursor: pointer;
    margin: 0;
}

/* Main Grid */
.hcw-body {
    display: grid;
    grid-template-columns: minmax(310px, 385px) minmax(0, 1fr);
    gap: 20px;
    align-items: start;
}

.hcw-controls {
    display: flex;
    flex-direction: column;
    gap: 10px;
    min-width: 0;
}

.hcw-person-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
    max-height: 540px;
    overflow-y: auto;
    padding-inline-end: 2px;
}

/* Person Card */
.hcw-person-card {
    --hcw-person-color: #5b46e5;
    background: var(--hcw-surface-subtle);
    border: 1px solid var(--hcw-border);
    border-inline-start: 4px solid var(--hcw-person-color);
    border-radius: var(--hcw-radius-sm);
    padding: 11px 12px;
    display: flex;
    flex-direction: column;
    gap: 9px;
}

.hcw-person-top {
    display: flex;
    align-items: center;
    gap: 8px;
}

.hcw-person-dot {
    width: 10px;
    height: 10px;
    flex: 0 0 10px;
    border-radius: 50%;
    background: var(--hcw-person-color);
}

.hcw-name-input {
    flex: 1 1 auto;
    min-width: 0;
    padding: 5px 9px;
    border: 1px solid var(--hcw-border);
    border-radius: 7px;
    background: var(--hcw-surface);
    color: var(--hcw-ink);
    font: inherit;
    font-size: 13px;
    font-weight: 600;
}

.hcw-swatches {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    flex: 0 0 auto;
}

.hcw-swatch {
    width: 16px;
    height: 16px;
    padding: 0;
    border-radius: 50%;
    border: 2px solid transparent;
    cursor: pointer;
    opacity: 0.68;
    transition: transform 0.12s ease, opacity 0.12s ease;
}

.hcw-swatch:hover,
.hcw-swatch.is-active {
    opacity: 1;
    transform: scale(1.16);
    border-color: var(--hcw-ink);
}

.hcw-remove-btn {
    appearance: none;
    width: 26px;
    height: 26px;
    flex: 0 0 26px;
    display: inline-grid;
    place-items: center;
    border: 1px solid var(--hcw-border);
    border-radius: 6px;
    background: var(--hcw-surface);
    color: var(--hcw-muted);
    font-size: 16px;
    line-height: 1;
    cursor: pointer;
}

.hcw-remove-btn:hover {
    color: #dc2626;
    border-color: #fca5a5;
    background: #fef2f2;
}

/* Height Slider & Inputs */
.hcw-height-row {
    display: flex;
    align-items: center;
    gap: 10px;
}

.hcw-slider {
    flex: 1 1 auto;
    min-width: 0;
    height: 6px;
    accent-color: var(--hcw-person-color);
    cursor: pointer;
}

.hcw-metric-box,
.hcw-imperial-box {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    flex: 0 0 auto;
}

.hcw-num-input {
    width: 64px;
    padding: 5px 6px;
    border: 1px solid var(--hcw-border);
    border-radius: 7px;
    background: var(--hcw-surface);
    color: var(--hcw-ink);
    font: inherit;
    font-size: 13px;
    font-weight: 700;
    text-align: center;
}

.hcw-num-ft {
    width: 44px;
}

.hcw-num-in {
    width: 52px;
}

.hcw-unit-tag {
    font-size: 11.5px;
    font-weight: 600;
    color: var(--hcw-muted);
}

/* Silhouette Style Buttons */
.hcw-style-row {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 6px;
}

.hcw-style-btn {
    appearance: none;
    padding: 5px 8px;
    border-radius: 7px;
    border: 1px solid var(--hcw-border);
    background: var(--hcw-surface);
    color: var(--hcw-muted);
    font: inherit;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    text-align: center;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.hcw-style-btn.is-active {
    border-color: var(--hcw-person-color);
    color: var(--hcw-person-color);
    background: var(--hcw-surface);
    box-shadow: inset 0 0 0 1px var(--hcw-person-color);
}

/* Add Person Button */
.hcw-add-btn {
    appearance: none;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    min-height: 40px;
    padding: 8px 14px;
    border-radius: var(--hcw-radius-sm);
    border: 1.5px dashed var(--hcw-border);
    background: transparent;
    color: var(--hcw-accent);
    font: inherit;
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
    transition: border-color 0.15s ease, background-color 0.15s ease;
}

.hcw-add-btn:hover:not(:disabled) {
    border-color: var(--hcw-accent);
    background: var(--hcw-accent-soft);
}

.hcw-add-btn:disabled {
    opacity: 0.48;
    cursor: not-allowed;
}

.hcw-count-pill {
    padding: 2px 7px;
    border-radius: 999px;
    background: var(--hcw-surface-muted);
    color: var(--hcw-muted);
    font-size: 11px;
    font-weight: 600;
}

/* Visual Stage Column */
.hcw-stage-panel {
    display: flex;
    flex-direction: column;
    gap: 12px;
    min-width: 0;
}

.hcw-svg-wrap {
    position: relative;
    width: 100%;
    border: 1px solid var(--hcw-border);
    border-radius: 12px;
    background: #f6f8fd;
    overflow: hidden;
}

.hcw-svg {
    display: block;
    width: 100%;
    height: auto;
    aspect-ratio: 760 / 460;
}

/* Difference Summary Bar */
.hcw-diff-bar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 8px 16px;
    padding: 12px 15px;
    border-radius: var(--hcw-radius-sm);
    background: var(--hcw-surface-subtle);
    border: 1px solid var(--hcw-border);
}

.hcw-diff-main {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px 10px;
    min-width: 0;
}

.hcw-diff-pill {
    display: inline-flex;
    align-items: center;
    padding: 3px 10px;
    border-radius: 999px;
    background: var(--hcw-accent);
    color: #ffffff;
    font-size: 12px;
    font-weight: 700;
    white-space: nowrap;
}

.hcw-diff-headline {
    font-size: 13.5px;
    font-weight: 700;
    color: var(--hcw-ink);
}

.hcw-diff-callout {
    margin: 0;
    font-size: 12.5px;
    color: var(--hcw-muted);
}

/* Footer */
.hcw-footer {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 10px 16px;
}

.hcw-footer-primary {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.hcw-download-btn {
    appearance: none;
    display: inline-flex;
    align-items: center;
    gap: 7px;
    min-height: 40px;
    padding: 8px 16px;
    border: 0;
    border-radius: 9px;
    background: var(--hcw-accent);
    color: #ffffff;
    font: inherit;
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
    transition: background-color 0.15s ease, transform 0.1s ease;
}

.hcw-download-btn:hover:not(:disabled) {
    background: var(--hcw-accent-hover);
}

.hcw-download-btn:disabled {
    opacity: 0.65;
    cursor: wait;
}

.hcw-export-status {
    font-size: 12px;
    font-weight: 600;
    color: var(--hcw-accent);
}

.hcw-footer-links {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 12px 16px;
}

.hcw-guide-link,
.hcw-official-link {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-size: 12.5px;
    font-weight: 600;
    text-decoration: none;
}

.hcw-guide-link {
    color: var(--hcw-accent);
}

.hcw-official-link {
    color: var(--hcw-muted);
}

.hcw-guide-link:hover,
.hcw-official-link:hover {
    text-decoration: underline;
}

.hcw-card :is(a, button, input):focus-visible {
    outline: 2px solid var(--hcw-accent);
    outline-offset: 2px;
}

/* Tablet & Mobile Responsive Layout */
@media (max-width: 991px) {
    .paid-tool-showcase > .hcw-card {
        width: calc(100% - 40px);
    }

    .hcw-body {
        grid-template-columns: 1fr;
    }

    /* Place visual stage above controls on mobile/tablet so sliders update visible chart */
    .hcw-stage-panel {
        order: -1;
    }

    .hcw-person-list {
        max-height: none;
        overflow: visible;
    }
}

@media (max-width: 640px) {
    .hcw-card {
        padding: 18px 16px;
    }

    .paid-tool-showcase > .hcw-card {
        width: calc(100% - 28px);
    }

    .hcw-header {
        flex-direction: column;
        align-items: stretch;
    }

    .hcw-unit-switch {
        align-self: flex-start;
    }

    .hcw-svg-wrap {
        position: sticky;
        top: 8px;
        z-index: 4;
        box-shadow: 0 6px 18px rgba(15, 23, 42, 0.08);
    }

    .hcw-swatches {
        gap: 3px;
    }

    .hcw-swatch {
        width: 15px;
        height: 15px;
    }

    .hcw-unit-btn,
    .hcw-chip,
    .hcw-tool-btn,
    .hcw-style-btn {
        min-height: 36px;
    }
}

@media (prefers-reduced-motion: reduce) {
    .hcw-card *,
    .hcw-card *::before,
    .hcw-card *::after {
        transition: none !important;
        animation: none !important;
    }
}
