.custom-header {
    width: 100%;
    height: 76px;
    display: flex;
    align-items: center;
}

.custom-header .inner {
    margin: 0 40px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.custom-header h1 {
    margin: 0;
}

.custom-header h1 img {
    height: 40px;
    display: block;
}

.custom-header .menu-wrapper {
    display: flex;
    flex-direction: column;
    gap: 10px;
    align-items: flex-end;
}

.custom-header .menu-row {
    display: flex;
    gap: 35px;
    list-style: none;
    padding: 0;
    margin: 0;
}

.custom-header .menu-row li a {
    text-decoration: none;
    color: #333;
    font-size: 14px;
    font-weight: 600;
    position: relative;
    overflow: hidden;
    display: inline-block;
}

/* 上のメニュー行のフォントサイズ */
.custom-header .menu-row-top li a {
    font-size: 13px;
}

/* 下のメニュー行のフォントサイズ */
.custom-header .menu-row-bottom li a {
    font-size: 14px;
}

.menu-text {
    display: block;
    transition: opacity 0.3s ease-out;
}

.menu-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, #DE3545 0%, #DE5535 100%);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    color: transparent;
    clip-path: inset(0 100% 0 0);
}

.custom-header .menu-row li a:hover .menu-text {
    opacity: 0;
}

/* ▼ モバイルメニュー（1050px以下） */
.menu-toggle { display: none; }

@media (max-width: 1050px) {
    /* 1050px以下でロゴをvwベースに可変 */
    .custom-header h1 img {
        width: 18vw;
        max-width: 200px;
        min-width: 110px;
        height: auto;
    }
    /* モバイルでは左寄せ */
    .custom-header .menu-wrapper { align-items: flex-start; }
    .custom-header .inner { margin: 0 20px; }
    .menu-toggle {
        display: inline-flex;
        flex-direction: column;
        gap: 5px;
        width: 40px;
        height: 40px;
        align-items: center;
        justify-content: center;
        background: #ffffff;
        border: 1px solid #e5e5e5;
        border-radius: 8px;
        cursor: pointer;
        z-index: 1001;
    }
    .menu-toggle-bar {
        display: block;
        width: 18px;
        height: 2px;
        background: #333;
    }

    .custom-header .menu-wrapper {
        position: fixed;
        inset: 0;
        background: linear-gradient(180deg, #ffffff 0%, #fafafa 100%);
        padding: 96px 58px 28px; /* 上: ヘッダー・ボタンより下から開始／左右余白拡大 */
        display: flex;
        flex-direction: column;
        gap: 18px;
        transform: translateY(-100%);
        transition: transform 0.3s ease;
        z-index: 1001;
        overflow-y: auto;
    }

    .custom-header .menu-wrapper.is-open { transform: translateY(0); }

    /* 背景スクロール抑止用 */
    body.menu-open { overflow: hidden; }

    .custom-header .menu-panel-header {
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 12px;
        padding: 4px 0 12px 0;
        border-bottom: 1px solid #eee;
        position: sticky;
        top: 0;
        background: #fff;
        z-index: 2;
    }
    .menu-panel-logo { height: 28px; }
    .menu-close {
        width: 32px;
        height: 32px;
        border-radius: 8px;
        border: 1px solid #e5e5e5;
        background: #fff;
        color: #333;
        font-size: 18px;
        line-height: 1;
        cursor: pointer;
    }

    .custom-header .menu-row { flex-direction: column; gap: 12px; width: 100%; }
    .custom-header .menu-row li { list-style: none; }
    .custom-header .menu-row li a {
        display: block;
        width: 100%; /* 横幅を全部埋める */
        padding: 16px 4px;
        border-bottom: 1px solid #eee;
        border-radius: 0;
    }
    .custom-header .menu-row li:first-child a { border-top: 1px solid #eee; }
    .custom-header .menu-row li a:hover .menu-text { opacity: 1; }
    .custom-header .menu-row li a .menu-overlay { display: none; }

    .menu-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,0.35); z-index: 1000; }

    /* ハンバーガー → クローズアニメーション */
    .menu-toggle { position: relative; }
    .menu-toggle-bar { transition: transform 0.25s ease, opacity 0.2s ease; }
    .menu-toggle.is-open .menu-toggle-bar:nth-child(1) { transform: translateY(6px) rotate(45deg); }
    .menu-toggle.is-open .menu-toggle-bar:nth-child(2) { opacity: 0; }
    .menu-toggle.is-open .menu-toggle-bar:nth-child(3) { transform: translateY(-6px) rotate(-45deg); }
    /* menu-row-top は横並び */
    .custom-header .menu-row-top { flex-direction: row; gap: 20px; padding-top: 8px; }
    .custom-header .menu-row-top li { flex: 1; }
    .custom-header .menu-row-top li a { border-top: 1px solid #eee; text-align: center; }

    /* メニュー右下ロゴ */
    .menu-panel-brand {
        position: absolute;
        right: 20px;
        bottom: 20px;
        opacity: 0.7;
        pointer-events: none;
    }
    .menu-panel-brand img { height: 28px; width: auto; display: block; }
}

/* PC表示時はメニュー内の右下ロゴを非表示（モバイルメニュー専用の装飾） */
@media (min-width: 1051px) {
    .menu-panel-brand { display: none; }
}

/* モバイル時のみ、上部/下部の表示順序を切替 */
@media (max-width: 1050px) {
    .custom-header .menu-row-top { order: 2; }
    .custom-header .menu-row-bottom { order: 1; }
}

/* 基本：.custom-header が内包される #headbox だけをリセット */
#headbox:has(.custom-header) {
  padding: 0 !important;
  margin: 0 !important;
  background: none !important;
  text-align: left !important;
  max-width: none !important;   /* 念のためデフォも外す */
  display: block !important;
}

/* 親が 960px 以上で再度 flex/padding/max-width を指定するので同条件で潰す */
@media print, screen and (min-width: 960px) {
  #headbox:has(.custom-header) {
    display: block !important;
    align-items: initial !important;
    justify-content: initial !important;
    padding: 0 !important;
    margin: 0 !important;
    max-width: none !important;
  }
}

/* 親が 600px 以上で text-align:center, padding を入れてくるので潰す */
@media only screen and (min-width: 600px) {
  #headbox:has(.custom-header) {
    text-align: left !important;
    padding: 0 !important;
    margin: 0 !important;
  }
}

/* 親のセーフエリア余白も不要なら潰す */
@media screen and (orientation: landscape) {
  #headbox:has(.custom-header) {
    padding-left: 0 !important;
    padding-right: 0 !important;
  }
}

/* 念のため：中身を100%にしておく */
#headbox:has(.custom-header) > * { flex: 0 0 auto; }
#headbox:has(.custom-header) .custom-header { width: 100%; }
