/* リセットCSS */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

/* 基本設定 */
:root {
    /* カラーパレット */
    --primary-color: #2563eb;
    --primary-hover: #1d4ed8;
    --secondary-color: #64748b;
    --background-color: #f8fafc;
    --surface-color: #ffffff;
    --border-color: #e2e8f0;
    --text-primary: #0f172a;
    --text-secondary: #475569;
    --text-muted: #94a3b8;
    --success-color: #10b981;
    --error-color: #ef4444;
    --warning-color: #f59e0b;
    
    /* フォント */
    --font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', sans-serif;
    
    /* スペーシング */
    --spacing-xs: 0.25rem;
    --spacing-sm: 0.5rem;
    --spacing-md: 1rem;
    --spacing-lg: 1.5rem;
    --spacing-xl: 2rem;
    --spacing-2xl: 3rem;
    
    /* ボーダーラディウス */
    --radius-sm: 0.375rem;
    --radius-md: 0.5rem;
    --radius-lg: 0.75rem;
    
    /* シャドウ */
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
}

body {
    font-family: var(--font-family);
    line-height: 1.6;
    color: var(--text-primary);
    background-color: var(--background-color);
    min-height: 100vh;
}

/* コンテナ */
.container {
    max-width: 800px;
    margin: 0 auto;
    padding: 0 var(--spacing-md);
}

/* ヘッダー */
.header {
    background: linear-gradient(135deg, var(--primary-color) 0%, #3b82f6 100%);
    color: white;
    padding: var(--spacing-2xl) 0;
    text-align: center;
    box-shadow: var(--shadow-md);
}

.title {
    font-size: 2.5rem;
    font-weight: 700;
    margin-bottom: var(--spacing-sm);
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.subtitle {
    font-size: 1.125rem;
    font-weight: 400;
    opacity: 0.9;
}

/* メインコンテンツ */
.main {
    padding: var(--spacing-2xl) 0;
    min-height: calc(100vh - 200px);
}

/* フォーム */
.form {
    background: var(--surface-color);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    overflow: hidden;
}

/* セクション */
.section {
    padding: var(--spacing-2xl);
    border-bottom: 1px solid var(--border-color);
}

.section:last-child {
    border-bottom: none;
}

.section-title {
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: var(--spacing-xl);
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
}

.section-subtitle {
    font-size: 1.25rem;
    font-weight: 500;
    color: var(--text-primary);
    margin-bottom: var(--spacing-lg);
}

/* フォームグループ */
.form-group {
    margin-bottom: var(--spacing-xl);
}

.form-group.required .label::after {
    content: '';
}

.sub-group {
    margin-bottom: var(--spacing-lg);
}

.sub-group:last-child {
    margin-bottom: 0;
}

/* ラベル */
.label {
    display: block;
    font-size: 1rem;
    font-weight: 500;
    color: var(--text-primary);
    margin-bottom: var(--spacing-sm);
}

.sub-label {
    display: block;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: var(--spacing-xs);
}

.required-mark {
    color: var(--error-color);
    font-weight: 600;
}

.description {
    font-size: 0.875rem;
    color: var(--text-muted);
    margin-bottom: var(--spacing-md);
    line-height: 1.5;
}

/* 入力フィールド */
.input,
.select {
    width: 100%;
    padding: 0.75rem 1rem;
    font-size: 1rem;
    line-height: 1.5;
    color: var(--text-primary);
    background-color: var(--surface-color);
    border: 2px solid var(--border-color);
    border-radius: var(--radius-md);
    transition: all 0.2s ease;
}

.input:focus,
.select:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.input::placeholder {
    color: var(--text-muted);
}

.select {
    cursor: pointer;
}

/* カスタム入力（条件表示） */
.custom-input {
    margin-top: var(--spacing-md);
}

/* チェックボックスとラジオボタン */
.checkbox-group,
.radio-group {
    margin: var(--spacing-md) 0;
}

.checkbox-label,
.radio-label {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    font-size: 1rem;
    font-weight: 400;
    color: var(--text-primary);
    cursor: pointer;
    margin-bottom: var(--spacing-sm);
}

.checkbox-label:last-child,
.radio-label:last-child {
    margin-bottom: 0;
}

/* カスタムチェックボックス */
.checkbox-custom {
    width: 20px;
    height: 20px;
    border: 2px solid var(--border-color);
    border-radius: var(--radius-sm);
    position: relative;
    transition: all 0.2s ease;
}

input[type="checkbox"]:checked + .checkbox-custom {
    background-color: var(--primary-color);
    border-color: var(--primary-color);
}

input[type="checkbox"]:checked + .checkbox-custom::after {
    content: '✓';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: white;
    font-size: 12px;
    font-weight: 600;
}

/* カスタムラジオボタン */
.radio-custom {
    width: 20px;
    height: 20px;
    border: 2px solid var(--border-color);
    border-radius: 50%;
    position: relative;
    transition: all 0.2s ease;
}

input[type="radio"]:checked + .radio-custom {
    border-color: var(--primary-color);
}

input[type="radio"]:checked + .radio-custom::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 10px;
    height: 10px;
    background-color: var(--primary-color);
    border-radius: 50%;
}

/* 実際のinput要素を隠す */
input[type="checkbox"],
input[type="radio"] {
    display: none;
}

.radio-group {
    display: flex;
    gap: var(--spacing-lg);
}

/* セリフオプション */
.dialogue-options {
    margin-top: var(--spacing-md);
    padding: var(--spacing-md);
    background-color: #f8fafc;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
}

/* 詳細設定トグルボタン */
.toggle-btn {
    width: 100%;
    padding: var(--spacing-lg);
    background: linear-gradient(135deg, #f1f5f9 0%, #e2e8f0 100%);
    border: 2px solid var(--border-color);
    border-radius: var(--radius-lg);
    font-size: 1.125rem;
    font-weight: 500;
    color: var(--text-primary);
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--spacing-md);
}

.toggle-btn:hover {
    background: linear-gradient(135deg, #e2e8f0 0%, #cbd5e1 100%);
    border-color: var(--primary-color);
}

.toggle-icon {
    transition: transform 0.3s ease;
}

.toggle-btn.active .toggle-icon {
    transform: rotate(180deg);
}

/* 詳細設定エリア */
.advanced-settings {
    transition: all 0.3s ease;
    overflow: hidden;
}

.advanced-settings.hidden {
    max-height: 0;
    opacity: 0;
}

/* アクションボタンエリア */
.form-actions {
    padding: var(--spacing-2xl);
    text-align: center;
    background: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 100%);
}

/* 生成ボタン */
.generate-btn {
    padding: 1rem 2rem;
    font-size: 1.125rem;
    font-weight: 600;
    color: white;
    background: linear-gradient(135deg, var(--primary-color) 0%, #3b82f6 100%);
    border: none;
    border-radius: var(--radius-lg);
    cursor: pointer;
    transition: all 0.3s ease;
    display: inline-flex;
    align-items: center;
    gap: var(--spacing-sm);
    box-shadow: var(--shadow-md);
}

.generate-btn:hover {
    background: linear-gradient(135deg, var(--primary-hover) 0%, #2563eb 100%);
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.generate-btn:disabled {
    background: #9ca3af;
    cursor: not-allowed;
    transform: none;
    box-shadow: var(--shadow-sm);
}

/* 結果表示エリア */
.result-section {
    padding: var(--spacing-2xl);
    background: linear-gradient(135deg, #fefefe 0%, #f8fafc 100%);
    border-top: 1px solid var(--border-color);
}

.result-container {
    border: 2px solid var(--border-color);
    border-radius: var(--radius-lg);
    overflow: hidden;
    background: var(--surface-color);
}

.result-header {
    padding: var(--spacing-md) var(--spacing-lg);
    background: linear-gradient(135deg, #f1f5f9 0%, #e2e8f0 100%);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.char-count {
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-secondary);
}

.copy-btn {
    padding: var(--spacing-sm) var(--spacing-md);
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--primary-color);
    background: transparent;
    border: 1px solid var(--primary-color);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: var(--spacing-xs);
}

.copy-btn:hover {
    background: var(--primary-color);
    color: white;
}

.result-textarea {
    width: 100%;
    min-height: 200px;
    padding: var(--spacing-lg);
    font-size: 1rem;
    line-height: 1.6;
    color: var(--text-primary);
    background: var(--surface-color);
    border: none;
    resize: vertical;
    font-family: 'SF Mono', Monaco, 'Consolas', 'Liberation Mono', 'Courier New', monospace;
}

.result-textarea:focus {
    outline: none;
}

.copy-success {
    padding: var(--spacing-md);
    background: linear-gradient(135deg, #dcfce7 0%, #bbf7d0 100%);
    color: var(--success-color);
    font-weight: 500;
    text-align: center;
    border-top: 1px solid #a7f3d0;
    animation: fadeIn 0.3s ease;
}

/* フッター */
.footer {
    background: var(--text-primary);
    color: white;
    text-align: center;
    padding: var(--spacing-xl) 0;
    margin-top: var(--spacing-2xl);
}

.footer p {
    font-size: 0.875rem;
    opacity: 0.8;
}

/* ユーティリティクラス */
.hidden {
    display: none !important;
}

/* アニメーション */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes fadeOut {
    from {
        opacity: 1;
        transform: translateY(0);
    }
    to {
        opacity: 0;
        transform: translateY(-10px);
    }
}

@keyframes slideDown {
    from {
        max-height: 0;
        opacity: 0;
    }
    to {
        max-height: 2000px;
        opacity: 1;
    }
}

/* レスポンシブデザイン */
@media (max-width: 768px) {
    .container {
        padding: 0 var(--spacing-md);
    }
    
    .title {
        font-size: 2rem;
    }
    
    .subtitle {
        font-size: 1rem;
    }
    
    .section {
        padding: var(--spacing-lg);
    }
    
    .form-actions {
        padding: var(--spacing-lg);
    }
    
    .result-section {
        padding: var(--spacing-lg);
    }
    
    .radio-group {
        flex-direction: column;
        gap: var(--spacing-sm);
    }
    
    .result-header {
        flex-direction: column;
        gap: var(--spacing-sm);
        align-items: stretch;
    }
    
    .copy-btn {
        align-self: center;
    }
}

@media (max-width: 480px) {
    .container {
        padding: 0 var(--spacing-sm);
    }
    
    .title {
        font-size: 1.75rem;
    }
    
    .section {
        padding: var(--spacing-md);
    }
    
    .form-actions {
        padding: var(--spacing-md);
    }
    
    .result-section {
        padding: var(--spacing-md);
    }
    
    .generate-btn {
        width: 100%;
        justify-content: center;
    }
}

/* アクセシビリティ */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* フォーカス表示の改善 */
.generate-btn:focus-visible,
.copy-btn:focus-visible,
.toggle-btn:focus-visible {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
}

/* ローディング状態 */
.loading {
    opacity: 0.7;
    pointer-events: none;
}

.loading .generate-btn {
    position: relative;
}

.loading .generate-btn::after {
    content: '';
    position: absolute;
    width: 16px;
    height: 16px;
    border: 2px solid transparent;
    border-top: 2px solid white;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-left: var(--spacing-sm);
}

@keyframes spin {
    0% {
        transform: rotate(0deg);
    }
    100% {
        transform: rotate(360deg);
    }
}