.qbc-section {
    --qbc-surface:     #ffffff;
    --qbc-panel:       #faf8f6;
    --qbc-track:       #f3efeb;
    --qbc-line:        #e5dfd9;
    --qbc-text:        #1f1b18;
    --qbc-muted:       #6e655f;
    --qbc-soft:        #9c928b;
    --qbc-accent:      #8c523e;
    --qbc-accent-soft: #f5ece8;
    --qbc-sec:         #6b705c;
    --qbc-sec-soft:    #f2f3ef;
    padding: 20px 0;
    color: var(--qbc-text);
    font-family: var(--font, "Inter", Arial, sans-serif);
}

.qbc-section *,
.qbc-section *::before,
.qbc-section *::after {
    box-sizing: border-box;
}

.qbc-section [hidden] {
    display: none !important;
}

.qbc-wrap {
    width: 100%;
    max-width: 1160px;
    margin: 0 auto;
    padding: 0 24px;
}

.qbc-sr {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: -1px;
    padding: 0;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.qbc-sr-copy {
    position: fixed;
    top: 0;
    left: 0;
    opacity: 0;
    pointer-events: none;
}

/* Shell */
.qbc {
    overflow: hidden;
    background: var(--qbc-surface);
    border: 1px solid var(--qbc-line);
    border-radius: 16px;
    box-shadow: 0 4px 24px rgba(31, 27, 24, 0.06);
}

/* Top bar */
.qbc-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 10px 16px;
    background: #fcfbfa;
    border-bottom: 1px solid var(--qbc-line);
}

.qbc-bar-left {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    min-width: 0;
}

.qbc-seg {
    display: inline-flex;
    gap: 3px;
    padding: 3px;
    background: var(--qbc-track);
    border: 1px solid var(--qbc-line);
    border-radius: 10px;
    max-width: 100%;
}

.qbc-seg-btn {
    flex: 0 0 auto;
    padding: 5px 12px;
    font-family: inherit;
    font-size: 0.8rem;
    font-weight: 600;
    line-height: 1.2;
    color: var(--qbc-muted);
    white-space: nowrap;
    cursor: pointer;
    background: transparent;
    border: 0;
    border-radius: 7px;
    transition: background 0.15s, color 0.15s, box-shadow 0.15s;
}

.qbc-seg-btn:hover {
    color: var(--qbc-text);
}

.qbc-seg-btn.is-active {
    color: #ffffff;
    background: var(--qbc-accent);
    box-shadow: 0 2px 6px rgba(140, 82, 62, 0.28);
}

.qbc-dd {
    display: none;
}

.qbc-select {
    height: 36px;
    padding: 0 28px 0 10px;
    font-family: inherit;
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--qbc-text);
    background-color: var(--qbc-track);
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%236e655f' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 8px center;
    border: 1px solid var(--qbc-line);
    border-radius: 10px;
    appearance: none;
    -webkit-appearance: none;
    cursor: pointer;
}

.qbc-select--full {
    width: 100%;
    height: 44px;
    background-color: var(--qbc-surface);
    font-size: 0.875rem;
}

.qbc-reset {
    padding: 6px 12px;
    font-family: inherit;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--qbc-muted);
    background: var(--qbc-surface);
    border: 1px solid var(--qbc-line);
    border-radius: 8px;
    cursor: pointer;
    flex-shrink: 0;
    transition: background 0.15s, color 0.15s;
}

.qbc-reset:hover {
    background: var(--qbc-accent-soft);
    color: var(--qbc-accent);
}

.qbc-seg-btn:focus-visible,
.qbc-select:focus-visible,
.qbc-reset:focus-visible,
.qbc-step:focus-visible,
.qbc-copy:focus-visible {
    outline: 2px solid var(--qbc-accent);
    outline-offset: 2px;
}

/* Two-column body */
.qbc-body {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
}

/* Left: inputs */
.qbc-inputs {
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 16px;
}

.qbc-row-2 {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 12px;
}

.qbc-card {
    overflow: hidden;
    background: var(--qbc-surface);
    border: 1px solid var(--qbc-line);
    border-radius: 12px;
}

.qbc-card-body {
    padding: 12px 14px;
}

.qbc-label {
    display: block;
    margin-bottom: 6px;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--qbc-muted);
}

/* Stepper */
.qbc-stepper {
    display: flex;
    align-items: stretch;
    height: 44px;
    overflow: hidden;
    background: var(--qbc-surface);
    border: 1px solid var(--qbc-line);
    border-radius: 10px;
    transition: border-color 0.15s, box-shadow 0.15s;
}

.qbc-stepper:focus-within {
    border-color: var(--qbc-accent);
    box-shadow: 0 0 0 3px rgba(140, 82, 62, 0.14);
}

.qbc-step {
    flex: 0 0 42px;
    font-family: inherit;
    font-size: 1.1rem;
    font-weight: 600;
    line-height: 1;
    color: var(--qbc-text);
    cursor: pointer;
    background: var(--qbc-panel);
    border: 0;
    transition: background 0.15s;
}

.qbc-step:first-child {
    border-right: 1px solid var(--qbc-line);
}

.qbc-step:last-child {
    border-left: 1px solid var(--qbc-line);
}

.qbc-step:hover {
    background: var(--qbc-track);
}

.qbc-input {
    flex: 1 1 auto;
    min-width: 0;
    padding: 0 6px;
    font-family: inherit;
    font-size: 1.0625rem;
    font-weight: 700;
    color: var(--qbc-text);
    text-align: center;
    background: transparent;
    border: 0;
    outline: 0;
    font-variant-numeric: tabular-nums;
}

.qbc-hint {
    margin: 2px 0 0;
    font-size: 0.75rem;
    line-height: 1.55;
    color: var(--qbc-muted);
    text-align: center;
}

/* Right: result */
.qbc-result {
    display: flex;
    flex-direction: column;
    min-width: 0;
    padding: 16px;
    background: var(--qbc-panel);
    border-left: 1px solid var(--qbc-line);
}

.qbc-result-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 12px;
}

.qbc-result-title {
    margin: 0;
    font-size: 0.875rem;
    font-weight: 700;
    color: var(--qbc-text);
}

.qbc-copy {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 6px 11px;
    font-family: inherit;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--qbc-text);
    cursor: pointer;
    background: var(--qbc-surface);
    border: 1px solid var(--qbc-line);
    border-radius: 8px;
    transition: background 0.15s, color 0.15s;
}

.qbc-copy:hover:not(:disabled) {
    background: var(--qbc-accent-soft);
    color: var(--qbc-accent);
}

.qbc-copy:disabled {
    cursor: not-allowed;
    color: var(--qbc-soft);
}

.qbc-icon {
    display: block;
    flex: 0 0 auto;
}

/* Empty state */
.qbc-empty {
    display: flex;
    flex: 1 1 auto;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 10px;
    min-height: 220px;
    text-align: center;
}

.qbc-empty-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 42px;
    height: 42px;
    color: var(--qbc-accent);
    background: var(--qbc-accent-soft);
    border-radius: 12px;
}

.qbc-empty-text {
    margin: 0;
    font-size: 0.875rem;
    line-height: 1.5;
    color: var(--qbc-muted);
}

/* Output */
.qbc-value {
    display: flex;
    align-items: baseline;
    gap: 6px;
    margin: 0;
    line-height: 1;
}

.qbc-value-num {
    font-size: clamp(2rem, 5vw, 2.75rem);
    font-weight: 800;
    letter-spacing: -0.03em;
    color: var(--qbc-accent);
    font-variant-numeric: tabular-nums;
}

.qbc-value-unit {
    font-size: 1rem;
    font-weight: 700;
    color: var(--qbc-muted);
}

.qbc-meta {
    margin: 6px 0 0;
    font-size: 0.75rem;
    color: var(--qbc-muted);
}

/* Stats */
.qbc-stats {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px;
    margin: 14px 0 0;
}

.qbc-stat {
    padding: 10px;
    background: var(--qbc-surface);
    border: 1px solid var(--qbc-line);
    border-radius: 10px;
}

.qbc-stat dt {
    margin: 0 0 3px;
    font-size: 0.6875rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: var(--qbc-muted);
}

.qbc-stat dd {
    margin: 0;
    font-size: 0.9375rem;
    font-weight: 700;
    color: var(--qbc-text);
    font-variant-numeric: tabular-nums;
}

/* Table */
.qbc-table {
    width: 100%;
    margin-top: 14px;
    border-collapse: separate;
    border-spacing: 0;
    background: var(--qbc-surface);
    border: 1px solid var(--qbc-line);
    border-radius: 10px;
    overflow: hidden;
    font-variant-numeric: tabular-nums;
}

.qbc-table th,
.qbc-table td {
    padding: 8px 12px;
    font-size: 0.8125rem;
    border-bottom: 1px solid var(--qbc-line);
}

.qbc-table thead th {
    font-size: 0.6875rem;
    font-weight: 700;
    color: var(--qbc-muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    background: var(--qbc-panel);
    text-align: left;
}

.qbc-table thead th:last-child,
.qbc-table tbody td {
    text-align: right;
}

.qbc-table tbody th {
    text-align: left;
    font-weight: 600;
    color: var(--qbc-muted);
}

.qbc-table tbody td {
    font-weight: 700;
    color: var(--qbc-text);
}

.qbc-table tbody tr:last-child th,
.qbc-table tbody tr:last-child td {
    border-bottom: 0;
}

/* Responsive */
@media (max-width: 860px) {
    .qbc-body {
        grid-template-columns: minmax(0, 1fr);
    }

    .qbc-result {
        border-top: 1px solid var(--qbc-line);
        border-left: 0;
    }

    .qbc-empty {
        min-height: 180px;
    }
}

@media (max-width: 768px) {
    .qbc-wrap {
        padding: 0 10px;
    }
}

@media (max-width: 680px) {
    .qbc-seg--dir {
        display: none;
    }

    .qbc-dd {
        display: block;
        flex: 1 1 0;
        min-width: 0;
    }

    .qbc-dd .qbc-select,
    .qbc-select--preset {
        flex: 1 1 0;
        min-width: 0;
        width: 100%;
    }

    .qbc-bar-left {
        flex: 1 1 auto;
        flex-wrap: nowrap;
        gap: 6px;
    }
}

@media (max-width: 600px) {
    .qbc-section {
        padding: 14px 0;
    }

    .qbc-bar {
        padding: 10px;
        gap: 6px;
    }

    .qbc-row-2 {
        grid-template-columns: 1fr;
    }

    .qbc-inputs,
    .qbc-result {
        padding: 12px;
        gap: 10px;
    }

    .qbc-stats {
        gap: 6px;
    }

    .qbc-stat {
        padding: 8px;
    }
}


/* Seam direction diagrams */
.qbx-fig {
    display: block;
    margin-top: 14px;
}

.qbx-fig-bg {
    fill: #f5ece8;
    stroke: #8c523e;
    stroke-width: 1.5;
}

.qbx-fig-seam {
    stroke: #8c523e;
    stroke-width: 1.5;
    stroke-dasharray: 4 3;
}

.qbx-fig text {
    fill: #8c523e;
    font-size: 12px;
    font-weight: 700;
    text-anchor: middle;
    dominant-baseline: middle;
}
