/*
 * Narrow-screen repairs for reference templates.
 * Kept outside generated page styles so rebuilds do not erase the fixes.
 *
 * @author xewex
 */

@media (max-width: 1024px) {
    .xewex-metagraf-llm .repo-body {
        grid-template-columns: minmax(0, 1fr);
        min-height: 0;
    }

    .xewex-metagraf-llm .file-tree {
        max-width: 100%;
        max-height: 280px;
        border-right: 0;
        border-bottom: 1px solid #1a1a1a;
    }

    .xewex-metagraf-llm .code-viewer,
    .xewex-metagraf-llm .code-body {
        width: 100%;
        max-width: 100%;
        min-width: 0;
    }
}

@media (max-width: 640px) {
    .xewex-home #seg-business .hero h1 {
        font-size: clamp(2.25rem, 11vw, 2.5rem);
        line-height: 1.04;
        letter-spacing: -.035em;
    }

    .xewex-home .cmd-palette-overlay {
        padding: max(76px, 10vh) 10px 18px;
    }

    .xewex-home .cmd-palette {
        width: 100%;
        max-width: 100%;
        border-radius: 14px;
    }

    .xewex-home .cmd-input-row {
        gap: 8px;
        padding: 14px 12px;
    }

    .xewex-home .cmd-input-row input {
        min-width: 0;
        font-size: .9rem;
    }

    .xewex-home .cmd-input-row kbd {
        flex: 0 0 auto;
        padding: 3px 5px;
        font-size: .6rem;
    }

    .xewex-home .cmd-list {
        padding: 6px;
    }

    .xewex-home .cmd-item {
        gap: 9px;
        min-width: 0;
        padding: 12px 10px;
        font-size: .9rem;
    }

    .xewex-home .cmd-item > span:nth-child(2) {
        min-width: 0;
        overflow-wrap: anywhere;
    }

    .xewex-home .cmd-item .c-icon {
        width: 30px;
        height: 30px;
        font-size: .9rem;
    }

    .xewex-home .cmd-item .c-hint {
        flex: 0 0 auto;
        font-size: .64rem;
    }

    .xewex-gov #process .section-head h2 {
        font-size: 1.85rem;
        line-height: 1.08;
        letter-spacing: -.025em;
    }

    .xewex-gov .process-steps {
        grid-template-columns: minmax(0, 1fr);
    }

    .xewex-gov .process-step {
        min-width: 0;
        padding: 32px 24px;
        border-right: 1px solid #1a1a1a;
    }

    .xewex-gov .process-step .step-num {
        margin-bottom: 20px;
    }

    .xewex-hell9000 .voice-panel {
        gap: 24px;
        min-width: 0;
        padding: 42px 16px 28px;
        overflow: hidden;
    }

    .xewex-hell9000 .voice-status-block {
        width: 100%;
        min-width: 0;
    }

    .xewex-hell9000 .voice-status {
        width: min(100%, 230px);
        min-width: 0;
        padding: 9px 10px;
        font-size: .64rem;
        letter-spacing: .16em;
        white-space: normal;
    }

    .xewex-hell9000 .voice-hint {
        width: min(100%, 230px);
        min-height: 0;
        font-size: .62rem;
        line-height: 1.6;
        letter-spacing: .1em;
        overflow-wrap: anywhere;
    }

    .xewex-metagraf-llm .repo {
        width: 100%;
        max-width: 100%;
        min-width: 0;
        overflow: hidden;
    }

    .xewex-metagraf-llm .repo-header {
        flex-direction: column;
        align-items: stretch;
        padding: 18px 14px !important;
    }

    .xewex-metagraf-llm .repo-title-wrap {
        flex-wrap: wrap;
        gap: 8px;
        min-width: 0;
    }

    .xewex-metagraf-llm .repo-title {
        min-width: 0;
        overflow-wrap: anywhere;
    }

    .xewex-metagraf-llm .repo-badge {
        flex: 0 0 auto;
    }

    .xewex-metagraf-llm .repo-meta {
        display: grid;
        grid-template-columns: minmax(0, 1fr);
        gap: 10px 14px;
        padding: 12px 14px;
        overflow-wrap: anywhere;
    }

    .xewex-metagraf-llm .repo-meta-item {
        min-width: 0;
        white-space: nowrap;
    }

    .xewex-metagraf-llm #repo .repo-actions,
    .xewex-metagraf-llm #repo .repo-btn {
        width: 100%;
    }

    .xewex-metagraf-llm #repo .repo-btn {
        justify-content: center;
    }

    .xewex-metagraf-llm .code-tabs,
    .xewex-metagraf-llm .install-tabs {
        max-width: 100%;
    }

    .xewex-metagraf-llm #repo .code-tabs {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        overflow: visible;
    }

    .xewex-metagraf-llm #repo .code-tab {
        justify-content: center;
        min-width: 0;
        width: 100%;
        padding: 12px 5px;
        font-size: .65rem;
        border-bottom: 1px solid #1a1a1a;
    }

    .xewex-metagraf-llm .code-head {
        align-items: flex-start;
        padding: 12px 14px;
    }

    .xewex-metagraf-llm .code-head .ch-path,
    .xewex-metagraf-llm .code-head .ch-meta {
        width: 100%;
        min-width: 0;
    }

    .xewex-metagraf-llm .readme-content {
        max-width: 100%;
        padding: 20px 16px;
        overflow-wrap: anywhere;
    }

    .xewex-metagraf-llm #repo #codeBody {
        max-width: 100%;
        padding: 14px 0;
        overflow-x: hidden;
    }

    .xewex-metagraf-llm #repo #codeBody > div {
        width: 100%;
        max-width: 100%;
        min-width: 0 !important;
    }

    .xewex-metagraf-llm #repo #codeBody pre {
        min-width: 0;
        padding: 0 10px;
        white-space: pre-wrap;
        overflow-wrap: anywhere;
        word-break: break-word;
    }

    .xewex-metagraf-llm #repo #codeBody .code-line {
        grid-template-columns: 28px minmax(0, 1fr);
        min-width: 0;
        width: 100%;
        padding: 0 10px;
    }

    .xewex-metagraf-llm #repo #codeBody .line-num {
        margin-right: 10px;
        padding-right: 10px;
        font-size: .68rem;
    }

    .xewex-metagraf-llm #repo #codeBody .line-code {
        min-width: 0;
        font-size: .72rem;
        line-height: 1.65;
        white-space: pre-wrap;
        overflow-wrap: anywhere;
        word-break: break-word;
    }

    .xewex-metagraf-llm .install-tabs {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        overflow: visible;
    }

    .xewex-metagraf-llm .install-tab {
        display: flex;
        align-items: center;
        justify-content: center;
        min-width: 0;
        padding: 12px 6px;
        font-size: .68rem;
        border-bottom: 1px solid #1a1a1a;
    }

    .xewex-metagraf-llm .install-body {
        flex-direction: column;
        align-items: stretch;
        gap: 14px;
        padding: 16px 14px;
    }

    .xewex-metagraf-llm .install-body code {
        width: 100%;
        max-width: 100%;
        font-size: .76rem;
    }

    .xewex-metagraf-llm .install-copy,
    .xewex-metagraf-llm #quickstart .repo-actions,
    .xewex-metagraf-llm #quickstart .repo-btn {
        width: 100%;
        justify-content: center;
    }

    .xewex-metagraf-llm #quickstart .repo-title-wrap {
        width: 100%;
    }

    .xewex-metagraf-llm #quickstartCode {
        max-width: 100%;
        padding: 14px 0 !important;
        overflow-x: hidden;
    }

    .xewex-metagraf-llm #quickstartCode .code-line {
        grid-template-columns: 28px minmax(0, 1fr);
        min-width: 0;
        padding: 0 10px;
    }

    .xewex-metagraf-llm #quickstartCode .line-num {
        margin-right: 10px;
        padding-right: 10px;
        font-size: .68rem;
    }

    .xewex-metagraf-llm #quickstartCode .line-code {
        min-width: 0;
        font-size: .72rem;
        line-height: 1.65;
        white-space: pre-wrap;
        overflow-wrap: anywhere;
        word-break: break-word;
    }
}

@media (max-width: 480px) {
    .xewex-gov .dashboard-preview {
        padding: 24px 14px;
    }

    .xewex-gov .dash-status {
        max-width: 100%;
        font-size: .62rem;
        letter-spacing: .1em;
        line-height: 1.5;
    }

    .xewex-gov .metric-grid {
        grid-template-columns: minmax(0, 1fr);
    }

    .xewex-gov .metric-item {
        min-width: 0;
        padding: 26px 20px;
    }

    .xewex-gov .metric-item .m-value {
        font-size: 2.15rem;
    }

    .xewex-hell9000 .voice-orb {
        width: 140px;
        height: 140px;
    }
}
