/* HTML Container Generator */

.hdg-shell {
    box-sizing: border-box;
    width: 100%;
    min-width: 0;
    max-width: 1220px;
    margin: 0 auto;
    padding: 88px 24px 96px;
    --hdg-surface: #ffffff;
    --hdg-surface-soft: #fbfbf8;
    --hdg-surface-muted: #f4f4ee;
    --hdg-text: #202124;
    --hdg-text-muted: #606468;
    --hdg-border: #ddded6;
    --hdg-border-soft: #ecece4;
    --hdg-accent: #284b44;
    --hdg-accent-hover: #1f3934;
    --hdg-accent-muted: #e8f1ec;
    --hdg-error: #b32525;
    --hdg-radius-sm: 0.5rem;
    --hdg-radius-md: 0.5rem;
    color: var(--hdg-text);
}

.hdg-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 24px;
    margin-bottom: 24px;
    padding-bottom: 22px;
    border-bottom: 1px solid var(--hdg-border-soft);
}

.hdg-header .page-desc {
    max-width: 760px;
}

.hdg-grid {
    display: grid;
    grid-template-columns: minmax(18rem, 22rem) minmax(0, 1fr);
    gap: 20px;
    align-items: start;
    min-width: 0;
}

.hdg-workspace {
    display: grid;
    gap: 18px;
    min-width: 0;
}

.hdg-card {
    min-width: 0;
    overflow: hidden;
    background: var(--hdg-surface);
    border: 1px solid var(--hdg-border);
    border-radius: var(--hdg-radius-md);
    box-shadow: 0 12px 32px rgba(39, 43, 37, 0.06);
}

.hdg-controls {
    padding: 0 14px 14px;
}

.hdg-inspector-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin: 0 -14px 14px;
    border-bottom: 1px solid var(--hdg-border-soft);
    background: var(--hdg-surface-soft);
    padding: 12px 14px;
}

.hdg-inspector-head h2,
.hdg-inspector-head p {
    margin: 0;
}

.hdg-inspector-head h2 {
    font-size: 0.95rem;
    font-weight: 850;
}

.hdg-inspector-head p {
    color: var(--hdg-text-muted);
    font-size: 0.75rem;
}

.hdg-group {
    border: 0;
    margin: 0;
    padding: 0;
}

.hdg-group + .hdg-group {
    margin-top: 14px;
    padding-top: 14px;
    border-top: 1px solid var(--hdg-border-soft);
}

.hdg-group legend,
.hdg-details summary {
    color: var(--hdg-text);
    font-size: 0.75rem;
    font-weight: 800;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.hdg-group legend {
    margin-bottom: 9px;
}

.hdg-details summary {
    cursor: pointer;
    list-style-position: outside;
}

.hdg-details .hdg-field:first-of-type {
    margin-top: 14px;
}

.hdg-field-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
}

.hdg-field-grid-single {
    grid-template-columns: 1fr;
}

.hdg-field-grid + .hdg-field,
.hdg-field + .hdg-field,
.hdg-field-grid + .hdg-field-grid {
    margin-top: 9px;
}

.hdg-field {
    display: grid;
    gap: 4px;
    min-width: 0;
}

.hdg-check-field {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    margin-bottom: 9px;
    border: 1px solid var(--hdg-border-soft);
    border-radius: var(--hdg-radius-sm);
    background: var(--hdg-accent-muted);
    padding: 0.52rem 0.65rem;
    color: var(--hdg-text);
    font-size: 0.875rem;
    font-weight: 800;
}

.hdg-check-field input {
    width: 1rem;
    height: 1rem;
    accent-color: var(--hdg-accent);
}

.hdg-field > span,
.hdg-unit-field > span {
    color: var(--hdg-text-muted);
    font-size: 0.6875rem;
    font-weight: 800;
    letter-spacing: 0.015em;
}

.hdg-field input,
.hdg-field select,
.hdg-field textarea {
    width: 100%;
    min-width: 0;
    border: 1px solid var(--hdg-border);
    border-radius: var(--hdg-radius-sm);
    background: #fff;
    color: var(--hdg-text);
    font: inherit;
    font-size: 0.8125rem;
    min-height: 2.125rem;
    padding: 0.42rem 0.6rem;
    outline: none;
    transition: background 0.15s, border-color 0.15s, box-shadow 0.15s;
}

.hdg-field textarea {
    min-height: 4.75rem;
    resize: vertical;
    line-height: 1.45;
}

.hdg-field input:focus,
.hdg-field select:focus,
.hdg-field textarea:focus,
.hdg-btn:focus-visible {
    border-color: var(--hdg-accent);
    box-shadow: 0 0 0 3px rgba(40, 75, 68, 0.13);
}

.hdg-unit-row {
    display: grid;
    grid-template-columns: minmax(3.8rem, 1fr) 3.85rem;
    gap: 5px;
}

.hdg-unit-row select[data-hdg-unit-keyword] {
    grid-column: 1 / -1;
}

.hdg-color-row {
    display: grid;
    grid-template-columns: 2.35rem minmax(0, 1fr);
    align-items: center;
    gap: 7px;
}

.hdg-color-row input[type="color"] {
    height: 2.125rem;
    padding: 0.1875rem;
}

.hdg-color-row output {
    color: var(--hdg-text);
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 0.8125rem;
}

.hdg-error {
    color: var(--hdg-error);
    font-size: 0.6875rem;
    line-height: 1.25;
}

.hdg-error:empty {
    display: none;
}

.hdg-card-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    min-height: 3.75rem;
    padding: 13px 16px;
    border-bottom: 1px solid var(--hdg-border-soft);
    background: var(--hdg-surface-soft);
    border-radius: var(--hdg-radius-md) var(--hdg-radius-md) 0 0;
}

.hdg-code-actions {
    display: flex;
    align-items: end;
    justify-content: flex-end;
    gap: 10px;
    min-width: 0;
}

.hdg-field-inline {
    align-items: center;
    display: flex;
    gap: 0.5rem;
}

.hdg-field-inline select {
    width: auto;
    min-width: 8.5rem;
}

.hdg-card-head h2 {
    margin: 0;
    font-size: 1rem;
    font-weight: 800;
}

.hdg-card-head .hdg-btn {
    justify-self: start;
}

.hdg-card-head span {
    color: var(--hdg-text-muted);
    font-size: 0.8125rem;
}

.hdg-preview-canvas {
    min-width: 0;
    min-height: 330px;
    padding: 28px;
    background:
        linear-gradient(45deg, rgba(0, 0, 0, 0.035) 25%, transparent 25%),
        linear-gradient(-45deg, rgba(0, 0, 0, 0.035) 25%, transparent 25%),
        linear-gradient(45deg, transparent 75%, rgba(0, 0, 0, 0.035) 75%),
        linear-gradient(-45deg, transparent 75%, rgba(0, 0, 0, 0.035) 75%);
    background-color: #fafaf8;
    background-position: 0 0, 0 8px, 8px -8px, -8px 0;
    background-size: 16px 16px;
    border-radius: 0 0 var(--hdg-radius-md) var(--hdg-radius-md);
    overflow: auto;
}

.hdg-preview-canvas > * {
    max-width: 100%;
}

.hdg-preview-canvas img {
    height: auto;
}

.hdg-code {
    width: 100%;
    min-width: 0;
    max-width: 100%;
    min-height: 230px;
    max-height: 430px;
    margin: 0;
    border-bottom: 1px solid var(--hdg-border-soft);
    padding: 16px;
    overflow: auto;
    background: #fbfbf8;
    color: #24292f;
    font-size: 0.875rem;
    line-height: 1.55;
}

.hdg-code code {
    display: block;
    min-width: 0;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    overflow-wrap: anywhere;
    white-space: pre-wrap;
}

.hdg-copy-status {
    min-height: 2.35rem;
    margin: 0;
    padding: 0.55rem 16px 0.7rem;
    color: var(--hdg-text-muted);
    font-size: 0.8125rem;
}

.hdg-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px solid transparent;
    border-radius: var(--hdg-radius-sm);
    min-height: 2.125rem;
    padding: 0.42rem 0.75rem;
    font: inherit;
    font-size: 0.875rem;
    font-weight: 800;
    cursor: pointer;
    transition: background 0.15s, color 0.15s, border-color 0.15s, transform 0.15s;
}

.hdg-btn:hover {
    transform: translateY(-1px);
}

.hdg-btn-primary {
    background: var(--hdg-accent);
    color: #fff;
}

.hdg-btn-primary:hover {
    background: var(--hdg-accent-hover);
    color: #fff;
}

.hdg-btn-secondary {
    background: var(--hdg-surface);
    border-color: var(--hdg-border);
    color: var(--hdg-text);
}

.hdg-btn-secondary:hover {
    background: var(--hdg-surface-muted);
}

@media (max-width: 920px) {
    .hdg-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 640px) {
    .hdg-shell {
        padding: 72px 16px;
    }

    .hdg-header {
        display: grid;
        gap: 16px;
    }

    .hdg-field-grid {
        grid-template-columns: 1fr;
    }

    .hdg-preview-canvas {
        min-height: 240px;
        padding: 16px;
    }

    .hdg-card-head {
        align-items: flex-start;
        display: grid;
    }

    .hdg-code-actions,
    .hdg-field-inline {
        align-items: stretch;
        display: grid;
        width: 100%;
    }

    .hdg-field-inline select {
        width: 100%;
    }
}

@media (prefers-reduced-motion: reduce) {
    .hdg-btn,
    .hdg-field input,
    .hdg-field select,
    .hdg-field textarea {
        transition: none;
    }

    .hdg-btn:hover {
        transform: none;
    }
}
