body {
    /* フォント設定: Inter を優先し、一般的なSans-serifフォールバック */
    font-family: 'Inter', 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    line-height: 1.8; /* 行間を広げて読みやすく */
    color: #333; /* 基本テキスト色 */
    background-color: #f0f2f5; /* 背景色 */
    margin: 0;
    padding: 20px;
    display: flex;
    justify-content: center; /* コンテンツを水平中央に配置 */
    align-items: flex-start; /* コンテンツを上揃え */
    min-height: 100vh; /* 最小ビューポート高さを確保 */
    box-sizing: border-box; /* paddingがwidthに影響しないように */
}

.container {
    background: #fff; /* コンテナの背景色 */
    padding: 30px;
    border-radius: 12px; /* 角を丸く */
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.1); /* 影 */
    max-width: 900px; /* 最大幅 */
    width: 100%; /* 幅を100%に設定 */
    display: flex;
    flex-direction: column; /* 要素を縦に並べる */
    gap: 25px; /* セクション間のスペース */
}

/* 各セクションのカードスタイル */
.card {
    background: #fff;
    border-radius: 10px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
    padding: 20px;
    border: 1px solid #e0e0e0;
}

h1, h2 {
    color: #2c3e50; /* 見出しの色 */
    text-align: center;
    margin-bottom: 25px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px; /* アイコンとテキストの間のスペース */
    font-weight: 700; /* 太字 */
}

h2 {
    font-size: 1.5rem; /* H2のサイズ調整 */
    margin-top: 0;
    margin-bottom: 20px;
}

label {
    display: block; /* ブロック要素として表示 */
    margin-bottom: 8px;
    font-weight: bold;
    color: #555;
    font-size: 0.95rem;
}

textarea, input[type="text"] {
    width: calc(100% - 22px); /* パディングとボーダーを考慮した幅 */
    padding: 11px;
    margin-bottom: 15px;
    border: 1px solid #ccc;
    border-radius: 6px;
    font-size: 1rem;
    min-height: 100px; /* textareaの最小高さを設定 */
    resize: vertical; /* 縦方向のみリサイズ可能 */
    box-sizing: border-box; /* パディングとボーダーをwidthに含める */
    transition: border-color 0.2s ease, box-shadow 0.2s ease; /* フォーカス時のアニメーション */
}

input[type="text"] {
    min-height: auto; /* inputの高さは自動 */
    height: auto;
}

textarea:focus, input[type="text"]:focus {
    border-color: #007bff; /* フォーカス時のボーダー色 */
    box-shadow: 0 0 0 3px rgba(0, 123, 255, 0.25); /* フォーカス時のシャドウ */
    outline: none; /* デフォルトのアウトラインを削除 */
}

/* ボタンのグループ化 (印刷・PDFダウンロードボタン用) */
.button-group {
    display: flex;
    justify-content: center; /* ボタンを中央に配置 */
    gap: 15px; /* ボタン間のスペース */
    margin-top: 20px;
    flex-wrap: wrap; /* 小さい画面でボタンを折り返す */
}

button {
    padding: 12px 25px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 1rem;
    font-weight: 600;
    transition: background-color 0.3s ease, transform 0.2s ease, box-shadow 0.2s ease; /* ホバー・クリック時のアニメーション */
    display: flex;
    align-items: center;
    gap: 8px;
    justify-content: center;
    width: auto;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1); /* ボタンの影 */
}

button:hover {
    transform: translateY(-1px); /* 少し上に移動 */
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.15); /* 影を強調 */
}

button:active {
    transform: translateY(0); /* クリック時に元の位置に戻る */
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.primary-btn {
    background-color: #007bff; /* プライマリボタンの色 */
    color: white;
}

.primary-btn:hover {
    background-color: #0056b3; /* ホバー時の色 */
}

.secondary-btn {
    background-color: #6c757d; /* セカンダリボタンの色 */
    color: white;
}

.secondary-btn:hover {
    background-color: #5a6268; /* ホバー時の色 */
}

button:disabled {
    background-color: #cccccc; /* 無効時の色 */
    cursor: not-allowed; /* カーソル変更 */
    transform: none; /* アニメーション無効化 */
    box-shadow: none;
}

.kanji-grid {
    display: grid;
    /* 150pxを最小幅とし、利用可能なスペースに合わせて自動調整 */
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 15px;
    margin-bottom: 20px;
    padding: 15px;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    background-color: #fcfcfc;
    max-height: 400px; /* 高さを制限しスクロール可能にする */
    overflow-y: auto; /* 縦方向のみスクロールバー表示 */
}

.kanji-item {
    display: flex;
    flex-direction: column; /* チェックボックスと読み入力欄を縦に並べる */
    align-items: flex-start; /* 左寄せ */
    gap: 8px;
    background-color: #e8f5fd;
    padding: 12px 15px;
    border-radius: 8px;
    border: 1px solid #b3e0ff;
    transition: background-color 0.2s ease, border-color 0.2s ease;
}

.kanji-item:hover {
    background-color: #dbeeff;
    border-color: #80caff;
}

.kanji-item input[type="checkbox"] {
    margin-right: 8px;
    transform: scale(1.1); /* チェックボックスのサイズ調整 */
    align-self: flex-start; /* チェックボックスを左寄せ */
    width: auto; /* チェックボックスの幅を自動に */
    margin-bottom: 0; /* 下マージンをなくす */
}

.kanji-item label {
    display: flex;
    align-items: center;
    font-size: 1.1rem;
    font-weight: 600;
    color: #0056b3;
    margin-bottom: 0; /* ラベルの下マージンをなくす */
}

.kanji-item .kanji-display {
    margin-left: 5px; /* チェックボックスとの間隔 */
}

.kanji-item .yomi-input {
    width: calc(100% - 10px); /* 親要素にフィットさせ、パディング考慮 */
    padding: 7px;
    font-size: 0.95rem;
    margin-top: 5px;
    margin-bottom: 0;
    border-radius: 4px;
    border: 1px solid #aaddff;
    background-color: #f0f8ff; /* 読み入力欄の背景色 */
}

.test-output-area {
    border: 1px solid #ddd;
    padding: 25px; /* パディングを増やす */
    min-height: 400px; /* プレビューエリアの最小高さ */
    background-color: #fff;
    border-radius: 8px;
    white-space: pre-wrap; /* 改行を保持 */
    font-size: 1.15rem; /* フォントサイズ調整 */
    line-height: 2.2; /* 行間を広げて読みやすく */
    margin-bottom: 25px;
    box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.05); /* 内部シャドウ */
    color: #212529; /* テキストの色 */
}

.test-output-area h2, .test-output-area h3 {
    text-align: left; /* 印刷時に見出しを左寄せ */
    margin-bottom: 15px;
    color: #0056b3;
    font-weight: 700;
    gap: 0; /* アイコンがないのでギャップなし */
}

.test-output-area h3 {
    font-size: 1.25rem;
    border-bottom: 2px solid #007bff; /* 下線 */
    padding-bottom: 5px;
    margin-top: 30px;
}

.test-output-area .placeholder-text {
    text-align: center;
    color: #888;
    padding-top: 100px;
    font-size: 1rem;
}

/* フォームグループのスタイル */
.form-group {
    margin-bottom: 15px;
}

/* ラジオボタングループのスタイル */
.radio-group {
    display: flex;
    flex-wrap: wrap; /* 折り返し */
    gap: 20px;
    justify-content: center;
    margin-bottom: 20px;
}

.radio-group label {
    display: flex;
    align-items: center;
    cursor: pointer;
    font-weight: normal; /* デフォルトのフォントウェイト */
    color: #333;
    margin-bottom: 0;
}

.radio-group input[type="radio"] {
    transform: scale(1.2); /* ラジオボタンのサイズ調整 */
    margin-right: 8px;
    cursor: pointer;
    width: auto; /* ラジオボタンの幅を自動に */
    margin-bottom: 0;
}


/* 印刷用スタイル */
@media print {
    body {
        background-color: #fff; /* 印刷時は白背景 */
        margin: 0;
        padding: 0;
    }
    .container {
        box-shadow: none; /* 影を非表示 */
        padding: 0;
        margin: 0;
        max-width: none;
        gap: 0; /* 印刷時にセクション間のギャップをなくす */
    }
    .input-section,
    .manual-add-section,
    .test-type-selection,
    .kanji-selection-section,
    .button-group { /* ボタン全体を非表示 */
        display: none;
    }
    .test-preview-section {
        width: 100%;
        padding: 0;
        box-shadow: none;
        border: none;
    }
    .test-output-area {
        border: none;
        min-height: auto;
        padding: 0;
        font-size: 14pt; /* 印刷時に読みやすいフォントサイズ */
        line-height: 2.5; /* 印刷時に行間を広げる */
        box-shadow: none;
        background-color: transparent;
    }
    .test-output-area h1,
    .test-output-area h2,
    .test-output-area h3 {
        text-align: left;
        margin-bottom: 10px;
        font-size: 20pt;
        color: #000; /* 印刷時は黒色 */
        border-bottom: none;
        padding-bottom: 0;
    }
    .test-output-area h3 {
        font-size: 16pt;
        margin-top: 20px;
    }
    .test-output-area .placeholder-text {
        display: none; /* 印刷時にプレースホルダーテキストを非表示 */
    }
}

/* モバイル対応 */
@media (max-width: 768px) {
    body {
        padding: 10px;
    }
    .container {
        padding: 15px;
        gap: 15px;
    }
    h1 {
        font-size: 1.8rem;
    }
    h2 {
        font-size: 1.3rem;
    }
    textarea, input[type="text"] {
        width: calc(100% - 20px); /* モバイルでの幅調整 */
    }
    button {
        width: 100%; /* モバイルではボタンをフル幅に */
        padding: 10px 15px;
    }
    .kanji-grid {
        grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); /* モバイルで調整 */
        gap: 10px;
        padding: 10px;
    }
    .kanji-item {
        padding: 10px 12px;
    }
    .kanji-item label {
        font-size: 1rem;
    }
    .kanji-item .yomi-input {
        font-size: 0.9rem;
    }
    .test-output-area {
        padding: 15px;
        font-size: 1rem;
        line-height: 1.8;
    }
    .radio-group {
        flex-direction: column; /* ラジオボタンを縦に並べる */
        align-items: flex-start;
    }
    .button-group {
        flex-direction: column; /* モバイルではボタンを縦に並べる */
        gap: 10px;
    }
}

