.ai-support-section {
    padding: var(--spacing-md) 0;
    background: var(--color-bg);
}

.ai-support-section .container {
    max-width: var(--container-width);
    margin: 0 auto;
    padding: 0 var(--container-padding);
}

.ai-support-section .section-header {
    margin-bottom: var(--spacing-sm);
}

.ai-support-section .section-title {
    font-size: clamp(1.6rem, 2.3vw, 1.9rem);
}

.ai-assistant-wrapper {
    width: 100%;
}

.ai-assistant-panel {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 0.35rem;
    padding: 0.4rem 0;
    position: relative;
    overflow: hidden;
}

.ai-assistant-panel.has-background-layer > *:not(.ai-assistant-background) {
    position: relative;
    z-index: 2;
}

.ai-assistant-background {
    position: absolute;
    inset: 0;
    z-index: 1;
    pointer-events: none;
    overflow: hidden;
    opacity: 0;
    transition: opacity 0.6s ease;
}

.ai-assistant-background[data-state="active"] {
    opacity: 1;
}

.ai-assistant-background::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(180deg, rgba(15, 23, 42, 0.15), rgba(30, 41, 59, 0.1));
    backdrop-filter: blur(1px);
    z-index: 0;
}

.ai-assistant-background-text {
    position: absolute;
    inset: -18% -8% -38% -8%;
    display: flex;
    flex-direction: column;
    gap: 1.2rem;
    font-family: 'Fira Code', 'Consolas', 'Monaco', 'Courier New', 'Menlo', monospace;
    font-size: clamp(0.4rem, 0.85vw, 0.65rem);
    line-height: 1.3;
    letter-spacing: 0.06em;
    white-space: pre;
    text-transform: none;
    z-index: 1;
    will-change: transform;
    animation: ai-assistant-background-pan 36s steps(120, end) infinite;
    text-align: right;
    direction: rtl;
    font-weight: 400;
    font-variant-ligatures: none;
    font-feature-settings: "liga" 0;
}

.ai-assistant-background-track {
    opacity: 1;
    white-space: pre;
    overflow-wrap: normal;
    margin: 0;
    padding: 0;
    text-align: right;
    direction: ltr;
    font-variant-ligatures: none;
    font-feature-settings: "liga" 0;
    tab-size: 2;
    font-family: 'Fira Code', 'Consolas', 'Monaco', 'Courier New', 'Menlo', monospace;
}

.ai-assistant-background-track .code-line {
    display: block;
    white-space: pre;
}

@keyframes ai-assistant-background-pan {
    0% {
        transform: translateY(0);
    }
    100% {
        transform: translateY(-50%);
    }
}

.ai-assistant-header {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    background: rgba(255, 255, 255, 0.02);
    padding: 0.4rem 0.6rem;
    border-radius: var(--radius-md);
    backdrop-filter: blur(1px);
}

.ai-assistant-toggle {
    font-family: var(--font-secondary);
    font-size: 0.8rem;
    font-weight: 700;
    color: #fff;
    padding: 0.4rem 1rem;
    border-radius: var(--radius-full);
    border: none;
    background: linear-gradient(135deg, var(--color-primary), var(--color-primary-dark));
    cursor: pointer;
    transition: all var(--transition-fast);
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
}

.ai-assistant-toggle:hover:not(:disabled) {
    background: linear-gradient(135deg, var(--color-primary-dark), var(--color-primary));
    transform: translateY(-1px);
}

.ai-assistant-toggle:disabled {
    opacity: 0.65;
    cursor: default;
}

.ai-assistant-toggle.is-complete {
    background: linear-gradient(135deg, #22c55e, #16a34a);
    box-shadow: 0 0 0 1px rgba(34, 197, 94, 0.35);
    cursor: default;
    pointer-events: none;
}

.ai-assistant-status {
    font-family: var(--font-secondary);
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--color-text-muted);
    padding: 0.3rem 0.55rem;
    border-radius: var(--radius-full);
    background: rgba(148, 163, 184, 0.05);
    border: 1px solid rgba(148, 163, 184, 0.12);
    backdrop-filter: blur(1px);
}

.ai-assistant-status[data-state="loading"] {
    color: var(--color-primary);
    background: rgba(52, 152, 219, 0.05);
    border-color: rgba(52, 152, 219, 0.12);
}

.ai-assistant-status[data-state="ready"] {
    color: var(--color-accent);
    background: rgba(46, 204, 113, 0.05);
    border-color: rgba(46, 204, 113, 0.12);
}

.ai-assistant-status[data-state="error"] {
    color: var(--color-secondary);
    background: rgba(231, 76, 60, 0.05);
    border-color: rgba(231, 76, 60, 0.12);
}

.ai-assistant-suggestions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.3rem;
    padding: 0.3rem 0.6rem;
    background: rgba(255, 255, 255, 0.01);
    border-radius: var(--radius-md);
    backdrop-filter: blur(0.5px);
}

.ai-assistant-suggestion {
    display: inline-flex;
    align-items: center;
    padding: 0.35rem 0.65rem;
    border-radius: var(--radius-full);
    background: rgba(52, 152, 219, 0.05);
    color: var(--color-primary);
    font-family: var(--font-secondary);
    font-size: 0.74rem;
    font-weight: 600;
    border: 1px solid rgba(52, 152, 219, 0.12);
    cursor: pointer;
    transition: all var(--transition-fast);
    backdrop-filter: blur(1px);
}

.ai-assistant-suggestion:hover {
    background: rgba(52, 152, 219, 0.08);
    border-color: rgba(52, 152, 219, 0.2);
}

.ai-assistant-input-row {
    display: flex;
    gap: var(--spacing-sm);
    align-items: stretch;
    flex-wrap: wrap;
    row-gap: 0.35rem;
}

.ai-assistant-input {
    flex: 1;
    display: flex;
    border: 1px solid rgba(148, 163, 184, 0.3);
    border-radius: var(--radius-md);
    overflow: hidden;
    background: rgba(255, 255, 255, 0.9);
    box-shadow: inset 0 1px 2px rgba(15, 23, 42, 0.05);
}

.ai-assistant-input .search-input {
    border: none;
    border-radius: 0;
    background: transparent;
}

.ai-assistant-input .search-input:focus {
    box-shadow: none;
}

.ai-assistant-input .search-btn {
    border-radius: 0;
    min-width: 48px;
    background: linear-gradient(135deg, var(--color-primary), var(--color-primary-dark));
    color: #fff;
}

.ai-assistant-input .search-btn:hover {
    background: linear-gradient(135deg, var(--color-primary-dark), var(--color-primary));
}

.ai-assistant-output {
    border: 1px solid rgba(148, 163, 184, 0.25);
    border-radius: var(--radius-md);
    background: rgba(255, 255, 255, 0.95);
    padding: 0.55rem var(--spacing-sm);
    height: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    position: relative;
    opacity: 0;
    visibility: hidden;
    transition: height 0.45s ease, opacity 0.35s ease;
}

.ai-assistant-output-inner {
    flex: 1;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: rgba(52, 152, 219, 0.4) transparent;
}

.ai-assistant-output-inner::-webkit-scrollbar {
    width: 6px;
}

.ai-assistant-output-inner::-webkit-scrollbar-thumb {
    background: rgba(52, 152, 219, 0.35);
    border-radius: var(--radius-full);
}

.ai-assistant-placeholder {
    font-family: var(--font-primary);
    font-size: 0.82rem;
    color: var(--color-text-muted);
    line-height: 1.6;
}

.ai-assistant-answer {
    font-family: var(--font-primary);
    font-size: 0.9rem;
    line-height: 1.75;
    color: var(--color-text);
    display: grid;
    gap: 0.5rem;
}

.ai-assistant-answer p {
    margin: 0;
    word-break: break-word;
}

.ai-assistant-answer strong {
    font-weight: 700;
    color: #1e293b;
    background: linear-gradient(135deg, rgba(52, 152, 219, 0.1), rgba(52, 152, 219, 0.05));
    padding: 0.1em 0.2em;
    border-radius: 3px;
}

.ai-assistant-answer em {
    font-style: italic;
    color: #475569;
}

.ai-assistant-loading {
    display: grid;
    justify-items: center;
    align-content: start;
    gap: 0.4rem;
    padding: 0.5rem 0.25rem;
    color: var(--color-text);
}

.ai-assistant-spinner {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    border: 2px solid rgba(148, 163, 184, 0.35);
    border-top-color: var(--color-primary);
    animation: ai-assistant-spin 0.9s linear infinite;
}

@keyframes ai-assistant-spin {
    to { transform: rotate(360deg); }
}

.ai-assistant-progress {
    position: relative;
    width: 100%;
    height: 4px;
    border-radius: var(--radius-full);
    background: rgba(148, 163, 184, 0.25);
    overflow: hidden;
}

.ai-assistant-progress::after {
    content: '';
    position: absolute;
    top: 0;
    bottom: 0;
    left: -40%;
    width: 40%;
    background: linear-gradient(90deg, transparent, var(--color-primary), transparent);
    animation: ai-assistant-progress-indeterminate 1.2s ease-in-out infinite;
    filter: saturate(1.2);
}

@keyframes ai-assistant-progress-indeterminate {
    0% { left: -40%; }
    50% { left: 60%; }
    100% { left: 100%; }
}

.ai-assistant-panel[data-state="loading"] .ai-assistant-output {
    position: relative;
}

.ai-assistant-panel[data-state="loading"] .ai-assistant-output::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(180deg, rgba(15, 23, 42, 0.03), rgba(30, 41, 59, 0.06));
    backdrop-filter: blur(1px);
    pointer-events: none;
}

.ai-assistant-status[data-state="loading"] {
    animation: ai-assistant-status-pulse 1.2s ease-in-out infinite;
}

@keyframes ai-assistant-status-pulse {
    0% { box-shadow: 0 0 0 0 rgba(52, 152, 219, 0.28); }
    70% { box-shadow: 0 0 0 6px rgba(52, 152, 219, 0); }
    100% { box-shadow: 0 0 0 0 rgba(52, 152, 219, 0); }
}

.ai-assistant-cancel {
    margin-top: 0.1rem;
    font-family: var(--font-secondary);
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--color-text);
    padding: 0.28rem 0.7rem;
    border-radius: var(--radius-full);
    border: 1px solid rgba(148, 163, 184, 0.35);
    background: rgba(255, 255, 255, 0.85);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.ai-assistant-cancel:hover {
    background: #fff;
    border-color: rgba(148, 163, 184, 0.5);
}

.ai-assistant-answer code {
    font-family: var(--font-code);
    font-size: 0.85em;
    background: rgba(148, 163, 184, 0.15);
    padding: 0.15em 0.35em;
    border-radius: 3px;
    color: #c7254e;
    font-weight: 500;
}

.ai-assistant-answer del {
    text-decoration: line-through;
    opacity: 0.6;
    color: var(--color-text-muted);
}

.ai-assistant-answer ul,
.ai-assistant-answer ol {
    margin: 0;
    padding-left: 1.2rem;
    display: grid;
    gap: 0.3rem;
}

.ai-assistant-answer li {
    line-height: 1.6;
}

.ai-assistant-callout {
    font-weight: 600;
    color: var(--color-primary);
    letter-spacing: 0.02em;
}

.ai-assistant-links {
    margin-top: 0.35rem;
    padding-top: 0.25rem;
    border-top: 1px solid var(--color-border-light);
}

.ai-assistant-links-title {
    font-family: var(--font-secondary);
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--color-text-muted);
    margin-bottom: 0.2rem;
}

.ai-assistant-links ul {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.ai-assistant-links a {
    color: var(--color-primary);
    font-size: 0.8rem;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 0.2rem;
}

.ai-assistant-links a::after {
    content: '↗';
    font-size: 0.7rem;
    opacity: 0.6;
}

.ai-assistant-links a:hover {
    color: var(--color-primary-dark);
    text-decoration: underline;
}

.ai-assistant-footnote {
    font-family: var(--font-secondary);
    font-size: 0.72rem;
    color: var(--color-text-muted);
    display: flex;
    justify-content: space-between;
    margin-top: 0.35rem;
}

/* 展開アニメーション（有効時に高さを伸ばす） */
.ai-assistant-panel.is-expanded .ai-assistant-output {
    height: 360px;
    opacity: 1;
    visibility: visible;
}

@media (min-width: 768px) {
    .ai-assistant-panel.is-expanded .ai-assistant-output {
        height: 420px;
    }
}