html {
    /* Safari の自動拡大を無効 */
    -webkit-text-size-adjust: 100%; 
}

.ms-parent {
    display: inline-block;
    position: relative;
    vertical-align: middle;
}

.ms-drop.portal { 
    position: fixed;
    z-index: 2147483647;
    width: auto;
}

.ms-choice {
    display: flex;
    align-items: center;
    width: 100%;
    height: 26px;
    padding: 0;
    overflow: hidden;
    cursor: pointer;
    border: 1px solid #aaa;
    text-align: left;
    white-space: nowrap;
    line-height: normal;
    color: #444;
    text-decoration: none;
    -webkit-border-radius: 4px;
    -moz-border-radius: 4px;
    border-radius: 4px;
    background-color: #fff;
    -webkit-appearance: none;
    appearance: none;
}

.ms-choice::-moz-focus-inner { 
    border:0;
    padding:0; 
}

.ms-choice.disabled {
    background-color: #f4f4f4;
    background-image: none;
    border: 1px solid #ddd;
    cursor: default;
}

.ms-choice > span{
    position:absolute;
    left:8px;
    right:32px;
    top:50%;
    transform:translateY(-50%);
    white-space:nowrap;
    overflow:hidden;
    text-overflow:ellipsis;
    line-height:1.2;
  }

.ms-choice > span.placeholder {
    color: #999;
}


.ms-choice > div {
    position: absolute;
    right: 6px;
    top: 50%;
    width: 20px;
    height: 20px;
    transform: translateY(-50%);
    background: none !important;
    pointer-events: none;
  }

.ms-choice > div::after{
    content:"";
    position:absolute; left:50%; top:50%;
    transform:translate(-50%,-50%);
    width:0; height:0;
    border-left:6px solid transparent;
    border-right:6px solid transparent;
    border-top: 7px solid #888;   /* 矢印の色 */
}

.ms-choice > div.open::after{
    transform: translate(-50%,-50%) rotate(180deg); /* 開いた時は上向き */
}

.ms-drop {
    width: 100%;
    overflow: visible;
    display: none;
    margin-top: -1px;
    padding: 0;
    position: absolute;
    z-index: 2000;
    background: #fff;
    color: #000;
    border: 1px solid #aaa;
    -webkit-border-radius: 4px;
    -moz-border-radius: 4px;
    border-radius: 4px;
}

.ms-drop ul{
    max-height: 250px;
    overflow: auto;
    margin: 0;
    padding: 5px 0;
}

.ms-drop ul > li {
    margin:0;
}

.ms-drop ul > li .disabled {
    opacity: .35;
    filter: Alpha(Opacity=35);
}

.ms-drop ul > li.multiple {
    float: none !important;
    width: auto !important;
    display: block;
}

.ms-drop ul > li.multiple label {
    width: 100%;
    display: block;
    white-space: nowrap;
    overflow-x: auto;
    overflow-y: hidden;
    text-overflow: clip;
}

.ms-drop ul > li.group {
    clear: both;
}

.ms-drop ul > li:hover {
    background: #f5f8ff;
}

.ms-drop ul > li.selected { 
    background: #e6f0ff; 
}

.ms-drop ul > li label {
    display:block;
    padding: 6px 8px;
    background: transparent;
    white-space: nowrap;
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    touch-action: auto;
}

.ms-drop ul > li label::-webkit-scrollbar {
    display:none;
}

.ms-drop ul > li label span {
    display: inline-block;
    min-width: 100%;
    padding-right: 12px;
  }

.ms-drop ul > li label:focus {
    outline: 2px solid #99c2ff;
    outline-offset: 2px;
}

.ms-drop ul > li label.optgroup {
    font-weight: bold;
}

.ms-drop.bottom {
    top: 100%;
    -webkit-box-shadow: 0 4px 5px rgba(0, 0, 0, .15);
    -moz-box-shadow: 0 4px 5px rgba(0, 0, 0, .15);
    box-shadow: 0 4px 5px rgba(0, 0, 0, .15);
}

.ms-drop.top {
    bottom: 100%;
    -webkit-box-shadow: 0 -4px 5px rgba(0, 0, 0, .15);
    -moz-box-shadow: 0 -4px 5px rgba(0, 0, 0, .15);
    box-shadow: 0 -4px 5px rgba(0, 0, 0, .15);
}

.ms-drop input[type="checkbox"] {
    vertical-align: middle;
}

.ms-drop .ms-no-results {
    display: none;
}

.ms-drop.single label > input {
    position: absolute;
    opacity: 0;
    width: 0; height: 0;
    pointer-events: none;
}

.ms-drop.single label:focus {
    outline: 2px solid #99c2ff;
    outline-offset: 2px;
}

.ms-drop.single li.selected label span {
    font-weight: 600;
}

.ms-search {
    display: inline-block;
    margin: 0;
    min-height: 26px;
    padding: 4px;
    position: relative;
    white-space: nowrap;
    width: 100%;
    z-index: 10000;
}

.ms-search input {
    width: 100%;
    height: auto !important;
    min-height: 24px;
    padding: 0 20px 0 5px;
    margin: 0;
    outline: 0;
    font-family: sans-serif;
    font-size: 1em;
    border: 1px solid #aaa;
    -webkit-border-radius: 0;
    -moz-border-radius: 0;
    border-radius: 0;
    -webkit-box-shadow: none;
    -moz-box-shadow: none;
    box-shadow: none;
    background: #fff url('custom-select-1.0.0.png') no-repeat 100% -22px;
    background: url('custom-select-1.0.0.png') no-repeat 100% -22px, -webkit-gradient(linear, left bottom, left top, color-stop(0.85, white), color-stop(0.99, #eeeeee));
    background: url('custom-select-1.0.0.png') no-repeat 100% -22px, -webkit-linear-gradient(center bottom, white 85%, #eeeeee 99%);
    background: url('custom-select-1.0.0.png') no-repeat 100% -22px, -moz-linear-gradient(center bottom, white 85%, #eeeeee 99%);
    background: url('custom-select-1.0.0.png') no-repeat 100% -22px, -o-linear-gradient(bottom, white 85%, #eeeeee 99%);
    background: url('custom-select-1.0.0.png') no-repeat 100% -22px, -ms-linear-gradient(top, #ffffff 85%, #eeeeee 99%);
    background: url('custom-select-1.0.0.png') no-repeat 100% -22px, linear-gradient(top, #ffffff 85%, #eeeeee 99%);
}

.ms-search, .ms-search input {
    width:100% !important;
    max-width:100% !important;
    min-width: 0 !important;
    -webkit-box-sizing: border-box;
    -khtml-box-sizing: border-box;
    -moz-box-sizing: border-box;
    -ms-box-sizing: border-box;
    box-sizing: border-box;
}

.ms-parent, .ms-choice, .ms-drop { 
    box-sizing: border-box; 
}

.ms-parent.single .ms-choice {
    box-sizing: border-box;
    height: 34px;
    line-height: normal;
    border: 1px solid #aaa;
    border-radius: 4px;
    background: #fff;
    padding: 0 32px 0 10px;
    position: relative;
}

.ms-parent.single .ms-choice > span {
    position: absolute;
    padding-left: 8px;
    padding-right: 8px;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
    color: #444;
    left: 10px;
    right: 32px;  
    top: 50%;
    transform: translateY(-50%);
    line-height: 1.2;
}

.ms-parent.single .ms-choice > div {
    position: absolute;
    right: 8px;
    top: 50%;
    width: 20px;
    height: 20px;
    transform: translateY(-50%);
}

.ms-drop.single ul > li.selected {
    background: #e6f0ff;
}

.ms-drop.single ul > li.selected:hover,
.ms-drop.single ul > li.selected:hover > label {
    background: #d8e8ff;
}

.ms-drop.single ul > li label {
    padding: 6px 8px;
}

.ms-drop:not(.single) ul > li.selected {
    background: #f0f6ff;
}

.ms-drop:not(.single) ul > li.selected label span {
    font-weight: 600;
}

@media (hover:hover) and (pointer:fine){
    .ms-drop ul > li label{
        overflow-x: hidden;
        text-overflow: ellipsis;
    }
    .ms-drop ul > li label:hover{
        overflow-x: auto;
        text-overflow: clip;
    }
}

@media (hover: none) and (pointer: coarse), (max-width: 768px) {

    /* iOSのオートズーム回避と入力の視認性 */
    input, select, textarea, button, .ms-search input { 
        font-size: 16px; 
    }

    .ms-parent {
        display: block;
        width: 100%;
        max-width: 100%;
        min-width: 0;
        flex: 1 1 auto;
    }
  
    /* トリガーボタンのタッチサイズ＆内側余白 */
    .ms-parent.single .ms-choice{
        display: flex;
        align-items: center;
        height: 44px;
        padding: 0 12px;
    }
  
    /* テキストは絶対配置で純粋な中央寄せ（line-height 依存をやめる） */
    .ms-parent.single .ms-choice > span {
        position: static !important;
        transform: none !important;
        display: block;
        height: 100%;
        line-height: 44px;
        flex: 1 1 auto;
        min-width: 0;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        font-size: 16px;
        padding: 0;
        margin: 0;
    }
  
    /* ▼アイコンも同じ基準で中央に */
    .ms-parent.single .ms-choice > div {
        position: static !important;
        transform: none !important;
        margin-top: 0;
        width: 40px;
        height: 100%;
        display: flex;
        align-items: center;
        justify-content: center;
        pointer-events: none;
    }

    .ms-parent.single .ms-choice > div::after{
        position: static !important;
        transform: none !important;
        display: inline-block;
        border-left-width: 6px;
        border-right-width: 6px;
        border-top-width: 6px;
    }
  
    /* ドロップ内の行のタップしやすさ */
    .ms-drop ul > li label,
    .ms-drop.single ul > li label { 
        padding: 10px 12px; 
    }
}