/* --- 共通設定：モダンで清潔感のあるデザイン --- */
:root {
    --primary-color: #2c3e50;
    --accent-color: #27ae60;
    --bg-color: #f8f9fa;
    --output-bg: #e9ecef;
}

body {
    font-family: "Helvetica Neue", Arial, "Hiragino Kaku Gothic ProN", "Hiragino Sans", sans-serif;
    background-color: var(--bg-color);
    color: var(--primary-color);
    line-height: 1.6;
    margin: 0;
    padding: 20px;
}

h1 {
    text-align: center;
    font-size: 1.5rem;
    margin-bottom: 20px;
}

h3 {
    border-left: 5px solid var(--accent-color);
    padding-left: 10px;
    margin-top: 30px;
}

/* --- レイアウト：Flexboxで柔軟に --- */
.input-row, .output-row {
    display: flex;
    flex-wrap: wrap; /* 狭くなると折り返す */
    gap: 15px;
    margin-bottom: 5px;
}

.input-item, .output-item {
    flex: 1;
    min-width: 200px; /* PCでは横並び、スマホでは自動で縦に */
    display: flex;
    flex-direction: column;
}

/* --- 入力欄のデザイン --- */
label {
    font-size: 0.85rem;
    font-weight: bold;
    margin-bottom: 0px;
}

input {
    padding: 10px;
    border: 1px solid #ced4da;
    border-radius: 6px;
    font-size: 16px; /* 理由: iPhoneでの自動ズーム防止 */
}

input[readonly] {
    background-color: var(--output-bg);
    border-color: #dee2e6;
    color: #495057;
}

/* --- ボタン：押しやすく目立つように --- */
#calc-button {
    width: 100%;
    padding: 15px;
    background-color: var(--accent-color);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 1.1rem;
    font-weight: bold;
    cursor: pointer;
    margin: 20px 0;
    transition: background 0.3s;
}

#calc-button:active {
    background-color: #1e8449;
}

/* --- 結果エリア --- */
#result-area {
    border-radius: 10px;
    text-align: center;
    font-weight: bold;
    font-size: 1.2rem;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
}

#result-val {
    font-size: 2rem;
    color: var(--accent-color);
    display: block;
}

/* --- 理由: ヘッダーの「場所取り」をやめさせ、ボタンを浮かせる --- */
.main-header {
    position: fixed;   /* 画面に対して固定して浮かせる */
    top: 10px;         /* 画面上端からの距離 */
    right: 10px;       /* 画面右端からの距離 */
    width: auto;       /* 横幅を全体に広げない */
    height: auto;      /* 高さを確保させない */
    background: transparent;
    z-index: 1000;
    padding: 0;        /* 余計な余白をカット */
    pointer-events: none; /* 下にある計算機の邪魔をしない */
}

/* --- 役割: 右上に配置する正方形のハンバーガーボタン --- */
.menu-btn {
    width: 40px;  /* 正方形のサイズ */
    height: 40px;
    background: #2c3e50; /* ボタンの背景色 */
    border-radius: 4px;  /* 少し角を丸く */
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    pointer-events: auto; /* ボタンだけはクリック可能にする */
    gap: 5px; /* 三本線の間隔 */
}

/* 役割: ボタン内の三本線のデザインを再調整 */
.menu-btn span {
    display: block;
    width: 24px; /* 線の長さ */
    height: 2px; /* 線の太さ */
    background: white;
    transition: 0.3s;
}

/* メニューの各項目に対する設定 */
.side-menu li { /* あなたのクラス名に合わせて調整してください */
    font-size: 12px;        /* 3. 文字をわずかに小さくして「可読性」と「収まり」を両立 */
}

/* 理由: .main-header 内に文字がないので、タイトル用の設定は不要 */
.header-title {
    display: none;
}

.menu-btn span:nth-child(1) { top: 0; }
.menu-btn span:nth-child(2) { top: 8px; }
.menu-btn span:nth-child(3) { top: 16px; }

/* --- 役割: サイドメニューを「右外」に隠す --- */
.side-menu {
    position: fixed;
    top: 0;
    left: auto;    /* leftの設定を解除 */
    right: -260px; /* 右側に追い出す */
    width: 250px;
    height: 100%;
    background: white;
    box-shadow: -2px 0 10px rgba(0,0,0,0.3); /* 影を左向きに出す */
    z-index: 2000;
    transition: 0.4s;
    padding-top: 60px;
}

/* 理由: JSで 'active' がついた時、右端（right:0）に戻す */
.side-menu.active {
    right: 0;
    left: auto;
}

.side-menu ul {
    list-style: none;
    padding: 0;
}

.side-menu li {
    padding: 15px 25px;
    border-bottom: 1px solid #eee;
}

.side-menu a {
    text-decoration: none;
    color: #333;
    font-weight: bold;
    display: block;
}

/* --- 役割: メニューが開いている間の背景暗転 --- */
.menu-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.5);
    z-index: 1500;
}

.menu-overlay.active {
    display: block;
}

/* --- 理由: スマホ（600px以下）で「2列」かつ「横スクロールなし」を実現する --- */
@media (max-width: 600px) {
    body {
        padding: 10px;
    }

    h1 {
        font-size: 1.1rem;
        margin-bottom: 15px;
    }

    /* 役割: 横並びを維持し、2つの項目が画面幅に収まるように調整 */
    .input-row, .output-row {
        display: flex !important; /* 強制的に横並び */
        flex-direction: row;      /* 縦ではなく横 */
        flex-wrap: nowrap;        /* 折り返さない */
        gap: 8px;                 /* 項目間の隙間を少し狭く */
        margin-bottom: 12px;
    }

    /* 役割: 各項目の幅を「画面の半分（から隙間を引いた分）」に固定 */
    .input-item, .output-item {
        flex: 1;
        width: calc(50% - 4px) !important; 
        min-width: 0;             /* Flexboxの崩れ防止 */
    }

    /* 理由: ラベルが2列だと重なりやすいため、少し小さくして1行に収める */
    label {
        font-size: 0.7rem !important;
        white-space: nowrap;      /* 改行させない */
        overflow: hidden;         /* はみ出たら隠す */
        text-overflow: ellipsis;  /* 長い場合は「...」にする */
    }

    /* 役割: 入力欄をタップしやすく、かつコンパクトに */
    input {
        width: 100% !important;
        box-sizing: border-box;
        font-size: 16px !important; /* ズーム防止 */
        padding: 8px 4px !important; /* 少し高さを抑えて2列のバランスを取る */
    }

    #calc-button {
        padding: 15px !important;
        font-size: 1rem !important;
    }
}