/* 全体的なリセットと基本設定 */
* {
    box-sizing: border-box; /* パディングとボーダーを要素の幅と高さに含める */
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    margin: 0; /* bodyのデフォルトマージンを削除 */
    background-color: #f4f7f6;
    color: #333;
    line-height: 1.6;
    padding: 10px; /* 全体に少しパディングを追加 */
}

h1 {
    color: #2c3e50;
    text-align: center;
    margin-bottom: 30px;
    font-size: 2em; /* タイトルを少し大きく */
}

#app {
    max-width: 900px;
    margin: 30px auto;
    background-color: #ffffff;
    padding: 36px 36px 40px 36px;
    border-radius: 14px;
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.10);
}

.input-section {
    margin-bottom: 28px;
    padding-bottom: 22px;
    border-bottom: 1.5px solid #e0e0e0;
}

.input-section:last-of-type {
    border-bottom: none;
    margin-bottom: 0;
    padding-bottom: 0;
}

.input-section h2 {
    color: #34495e;
    margin-top: 0;
    margin-bottom: 18px;
    font-size: 1.25em;
    font-weight: 600;
    letter-spacing: 0.02em;
    text-align: left;
}

/* 入力行のレイアウトをFlexboxで改善 */
.input-section > div {
    display: flex; /* 子要素を横並びに */
    flex-wrap: wrap; /* 画面が狭くなったら折り返す */
    align-items: center; /* 垂直方向の中央揃え */
    margin-bottom: 10px;
}

label {
    display: inline-block;
    width: 160px;
    min-width: 120px;
    margin-right: 12px;
    font-weight: 600;
    color: #444;
    flex-shrink: 0;
    text-align: left;
    letter-spacing: 0.01em;
}

input[type="number"],
select {
    padding: 9px 14px;
    border: 1.2px solid #bfc9d1;
    border-radius: 6px;
    width: auto;
    min-width: 110px;
    max-width: 100%;
    font-size: 1.05em;
    background-color: #fff;
    cursor: pointer;
    flex-grow: 1;
    box-shadow: 0 1px 2px rgba(0,0,0,0.03);
    transition: border 0.2s;
}
input[type="number"]:focus,
select:focus {
    border: 1.5px solid #3498db;
    outline: none;
}

input[type="radio"] {
    margin-right: 5px;
    /* ラジオボタンの親要素もflexにして、ラベルとの間隔を調整 */
    display: inline-flex;
    align-items: center;
}

/* ラジオボタンのラベルがinputのすぐ隣に来るように調整 */
.input-section > div > input[type="radio"] + label {
    width: auto; /* ラジオボタンのラベルは幅を固定しない */
    margin-right: 20px; /* ラジオボタン間のスペース */
    flex-grow: 0; /* ラジオボタンのラベルは拡大しない */
}

/* ラジオボタンのグループ全体をflexで囲む場合 */
.input-section > div:has(input[type="radio"][name="sizeBase"]),
.input-section > div:has(input[type="radio"][name="designType"]),
.input-section > div:has(input[type="radio"][name="lidType"]) {
    /* justify-content: center; */ /* 中央揃えを削除 */
    flex-wrap: wrap; /* 折り返しを許可 */
    align-items: flex-start; /* 上揃え */
}

/* サイズ指定の基準セクションのスタイル調整 */
#sizeBaseSection {
    margin-top: 15px; /* 上部に少しスペース */
    padding-top: 15px; /* 上部にパディング */
    border-top: 1px dashed #eee; /* 上部に点線ボーダー */
}
#sizeBaseSection label {
    width: auto; /* ラベルの幅を自動調整 */
    margin-right: 10px;
    font-weight: normal; /* 太字を解除 */
    color: #333;
}
#sizeBaseSection > div { /* ラジオボタンの親div */
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    margin-bottom: 0; /* デフォルトのmargin-bottomをリセット */
}


button {
    display: block;
    width: 100%;
    padding: 13px 0;
    background-color: #3498db;
    color: #fff;
    border: none;
    border-radius: 6px;
    font-size: 1.13em;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s, box-shadow 0.2s;
    margin-top: 22px;
    box-shadow: 0 2px 8px rgba(52,152,219,0.07);
    letter-spacing: 0.03em;
}
button:hover {
    background-color: #217dbb;
    box-shadow: 0 4px 16px rgba(52,152,219,0.13);
}

.result-section {
    margin-top: 36px;
    padding-top: 24px;
    border-top: 1.5px dashed #b2bec3;
}
.result-section p {
    background-color: #e9f7ef;
    padding: 12px 14px;
    border-left: 5px solid #27ae60;
    margin-bottom: 10px;
    border-radius: 4px;
    font-size: 1.01em;
}
/* SVG図形・裁断図イメージの余白・テキスト見切れ対策・全体バランス調整 */
#diagramContainer {
    min-height: 140px;
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 1px 4px rgba(0,0,0,0.06);
    margin-top: 12px;
    margin-bottom: 12px;
    padding: 22px 16px 22px 24px !important;
    overflow-x: auto;
}
svg {
    background: #fff;
    border-radius: 4px;
    overflow: visible;
}

/* モバイル向け調整 */
@media (max-width: 600px) {
    #app {
        padding: 15px;
        margin: 10px auto;
    }

    .input-section h2 {
        text-align: center; /* モバイルではセクションタイトルを中央揃え */
    }

    .input-section > div {
        flex-direction: column; /* 縦方向に積み重ねる */
        align-items: flex-start; /* 左揃え */
    }

    label {
        width: 100%; /* ラベルを全幅に */
        margin-right: 0;
        margin-bottom: 5px; /* ラベルと入力欄の間にスペース */
        text-align: left; /* モバイルでもラベルは左揃え */
    }

    input[type="number"],
    select {
        width: 100%; /* 入力欄を全幅に */
        min-width: unset; /* 最小幅をリセット */
    }

    /* ラジオボタンのグループも縦に積み重ねる */
    .input-section > div:has(input[type="radio"][name="sizeBase"]),
    .input-section > div:has(input[type="radio"][name="designType"]),
    .input-section > div:has(input[type="radio"][name="lidType"]) {
        flex-direction: column;
        align-items: flex-start; /* 左揃え */
    }

    .input-section > div > input[type="radio"] + label {
        margin-right: 0;
        margin-bottom: 5px;
        width: auto; /* ラジオボタンのラベルは幅を固定しない */
    }

    /* サイズ指定の基準セクションのモバイル調整 */
    #sizeBaseSection {
        margin-top: 15px;
        padding-top: 15px;
        border-top: 1px dashed #eee;
    }
    #sizeBaseSection label {
        width: 100%; /* モバイルではラベルを全幅に */
        margin-bottom: 5px;
    }
    #sizeBaseSection > div {
        flex-direction: column; /* ラジオボタンも縦に並べる */
        align-items: flex-start;
    }


    /* ボタンは中央揃えのまま */
    button {
        margin-left: auto;
        margin-right: auto;
        width: 90%; /* 少し幅を狭める */
    }
}