/* カラーパレット定義 */
:root {
    /* プライマリカラー（赤系） - Tungaloyブランドカラー */
    --color-primary: #D40025;
    --color-primary-dark: #B30020;
    --color-primary-light: #FF6B6B;
    --color-primary-pale: #FFE8ED;
    
    /* セカンダリカラー（グレー系） */
    --color-secondary: #2B2B2B;
    --color-text-primary: #333333;
    --color-text-secondary: #4D4D4D;
    --color-text-muted: #666666;
    
    /* 背景色 */
    --color-bg-light: #F7F7F7;
    --color-bg-white: #FFFFFF;
    
    /* ボーダー */
    --color-border: #DDDDDD;
    --color-border-light: #E1E1E1;
}

body {
    margin:0;
    position:relative;
    padding-bottom:150px;
    font-family: 'Titillium Web', sans-serif;
}

h1 h2 h3 {
    font-family: 'Titillium Web', sans-serif;
}

.p {
    font-family: 'Titillium Web', sans-serif;
}

.span {
    font-family: 'Titillium Web', sans-serif;
}

/* ヘッダー */
header {
    position: static;
    width: 100%;
    height: 60px;
    background-color: #2b2b2b;
}

.header_inner {
    margin:0 auto;
    max-width:1000px;
    height:60px;
    display:flex;
}
.header_inner img {
    width:100px;
}
.header_inner h1 {
    color:#fff;
    align-self: center;
    padding-left:20px;
}
.header_inner select {
    height:60%;
    margin-left:auto;
    align-self: center;
    background: #2b2b2b;
    color: #fff;
    border: 1px solid #666;
    padding: 0px 20px;
    border-radius: 6px;
}

/* 入力エリア・候補出力エリア */
.displaynone {
    display:none!important;
}
.displayblock {
    display:block!important;
}
.search_wrapper {
    max-width:1000px;
    margin:0 auto;
}
.explanation {
    font-size:16px;
    font-weight:600;
    margin-top:50px;
}
.explanation a {
    color: var(--color-primary);
    transition: color 0.3s;
}

.explanation a:hover {
    color: var(--color-primary-dark);
}
.search_area {
    margin-top:30px;
    padding:1em 2.5em;
    background:#f7f7f7;
}
.section_title {
    color:#4d4d4d;
    margin:0 0 0.5em 0;
}
.dimention_title {
    position:relative;
    display:flex;
}
.dimention_title h3 {
    font-size:15px;
    font-weight:400;
    color:#4d4d4d;
    margin:0 0 0 10px;
}
.open_btn {
    cursor: pointer;
    width:21px;
    border:1px solid #000;
    background-color:#fff;
}
.open_btn::before {
    content: '';
    position: absolute;
    top: 51%;
    left: 11px;
    transform: translate(-50%,-50%) rotate(90deg);
    background-color: #000;
    width: 2px;
    height: 15px;
}
.open_btn::after {
    content: '';
    position: absolute;
    top: 51%;
    left: 11px;
    transform: translate(-50%,-50%);
    background-color: #000;
    width: 2px;
    height: 15px;
}
.close_btn {
    cursor: pointer;
    width:21px;
    border:1px solid #000;
    background-color:#fff;
}
.close_btn::before {
    content: '';
    position: absolute;
    top: 51%;
    left: 11px;
    transform: translate(-50%,-50%) rotate(90deg);
    background-color: #000;
    width: 2px;
    height: 15px;
}
.dimention_area {
    display:flex;
    background-color:#fff;
    overflow: hidden;
    height: 0;
    opacity: 0;
    transition: height 0.5s ease, opacity 0.5s ease;
}
.dimention_area.show {
    height: auto;
    opacity: 1;
}
.dimention_item p {
    margin:15px 0 0 75px;
    font-size:18px;
    font-weight:bold;
}
.dimention_item img {
    width:70%;
}
.search_form {
    display:flex;
    margin-top:20px;
}
.search_form p {
    margin:20px 0 10px;
}
.form_parts {
    width: -webkit-fill-available;
    margin: 0 auto;
}
.form_parts_1 {
    border-right:1px solid #e9e9e9;
}
.form_parts_2 {
    border-right:1px solid #e9e9e9;
}
.form_item {
    height:7em;
    width: 75%;
    margin: 0 auto;
}
.help_flex {
    display:flex;
}
.form_item h3 {
    font-size: 100%;
    font-weight: 700;
    color: #4d4d4d;
    width:90%;
}
.input_select {
    border: none;
    width: 100%;
    height: 40px;
    /* appearance: none; */
    background-color: #fff;
    padding: 10px;
    font-size: 1rem;
    border-bottom: 1px solid #ccc;
    box-sizing: border-box;
    cursor: pointer;
}
.input_select:focus {
    border-bottom: 1px solid var(--color-primary);
    outline: none;
}
.input_txt {
    border: none;
    width: 100%;
    height: 40px;
    /* appearance: none; */
    background-color: #fff;
    padding: 10px;
    font-size: 1rem;
    border-bottom: 1px solid #ccc;
    box-sizing: border-box;
    cursor: text;
}
.input_txt:focus-visible {
    border-bottom: 1px solid var(--color-primary);
    outline:none;
}
input:invalid {
    border: 1px solid var(--color-primary);
    background: var(--color-primary-pale);
}
.caution {
    font-size:0.7em;
    margin-top:5px;
    color: #4d4d4d;
}
.pitch_error {
    font-size:0.7em;
    font-weight:bold;
    color: var(--color-primary);
}
.button_area {
    margin-top:30px;
}
.submit_button {
    display: block;
    color: #fff;
    background-color: var(--color-primary);
    font-size: 1rem;
    text-decoration: none;
    border-radius: 4px !important;
    width: 250px;
    height: 50px;
    line-height: 50px;
    text-align: center;
    font-weight: 700;
    cursor: pointer;
    margin: 0 auto;
    border:none;
    transition: all 0.3s;
}

.submit_button:hover {
    background-color: var(--color-primary-dark);
    box-shadow: 0 4px 12px rgba(212, 0, 37, 0.3);
}
.result_txt {
    padding:20px 0;
}
.result_txt a {
    color: var(--color-primary);
    transition: color 0.3s;
}

.result_txt a:hover {
    color: var(--color-primary-dark);
}
.result_area {
    display:flex;
}
.result_item {
    width:30%;
    margin-right:1.5em;
    text-align:center;
}
.select_button {
    display: inline-block;
    padding: 5% 0;
    border: 1px solid #e3e3e3;
    /* border-radius: 5px; */
    cursor: pointer;
    background-color: #fff;
    position:relative;
}
.select_button::after {
    position: absolute;
    content: "";
    bottom: -1px;
    right: -1px;
    width: 0;
    height: 0;
    border-bottom: 15px solid var(--color-primary);
    border-left: 15px solid transparent;
    transition: .3s;
}
.select_button:hover {
    border: 1px solid var(--color-primary);
    transition: .3s;
}
.result_image {
    width:90%;
}
.result_title {
    font-weight:bold;
}
.result_inner p {
    font-size:1.1em;
    text-align:left;
    margin-left:5%;
}
/* 工具詳細・プログラムエリア */
.detail_area {
    max-width:1000px;
    margin:50px auto;
}
.detail_item {
    display:flex;
    flex-flow: wrap;
    margin-top:50px;
}
.detail_title {
    width:100%;
    border-left: 3px solid var(--color-primary);
    padding-left:5px;
}
.tool_image {
    width:50%;
}
.tool_image img {
    max-width:100%;
}
.tool_detail {
    margin-left:1em;
}
.tool_detail table {
    background-color:#f1f1f1;
    border-collapse: collapse;
    width:100%;
}
.tool_detail td {
    padding:10px 20px;
    border-bottom:1px solid #fff;
}
.tool_detail a {
    color: var(--color-primary);
    transition: color 0.3s;
}

.tool_detail a:hover {
    color: var(--color-primary-dark);
}

.pass_prot_area {
    display:flex;
    position:relative;
}
.pass_detail_area {
    display: block;
    width: 45%;
    margin-left: 1em;
}
.pass_detail img {
    width:100%;
}
.pass_prot_1 {
    position:absolute;
    left:30px;
    top:154px;
}
.pass_prot_2 {
    position:absolute;
    left:30px;
    top:85px;
}
.pass_prot_3 {
    position:absolute;
    left:30px;
    top:14px;
}

.program_area {
    width:50%;
}
.program_title {
    display:flex;
}

.program_title img {
    width:15%;
    vertical-align: middle;
}
.program_title button {
    align-self: center;
    margin-right: 10px;
    width: 70%;
    height:40px;
    background-color:#f1f1f1;
    border: 1px solid #e1e1e1;
    padding: 5px;
    cursor: pointer;
}
.copy_area {
    padding: 5px 10px;
    border: 1px solid #d1d1d1;
    margin-top: 0;
    max-height: 600px;
    overflow-y: auto;
    box-sizing: border-box;
}
.program_attention {
    font-size:14px;
}

/* 規格選択とねじ寸法図の横並びコンテナ */
.standard_and_diagram_container {
    display: flex;
    gap: 30px;
    align-items: flex-start;
    flex-wrap: nowrap;
    margin-bottom: 20px;
}

.standard_selection_section {
    flex: 1 1 auto;
    min-width: 300px;
    max-width: 60%;
}

/* 手動入力フォームを規格選択の下に表示 */
.manual_input_inline {
    margin-top: 20px;
}

.manual_input_inline h3 {
    margin-top: 15px;
    margin-bottom: 10px;
}

/* 入力項目を2列グリッドレイアウトに */
.thread_inputs_vertical {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 15px 20px;
    width: 100%;
}

/* ねじ深さを2列目の1行目に配置 */
.thread_inputs_vertical .form_item:nth-child(3) {
    grid-column: 2;
    grid-row: 1;
}

/* 呼び径を1列目の1行目に */
.thread_inputs_vertical .form_item:nth-child(1) {
    grid-column: 1;
    grid-row: 1;
}

/* ピッチを1列目の2行目に */
.thread_inputs_vertical .form_item:nth-child(2) {
    grid-column: 1;
    grid-row: 2;
}

/* 下穴径(4番目の要素)を2列目の2行目に */
.thread_inputs_vertical .form_item:nth-child(4) {
    grid-column: 2;
    grid-row: 2;
}

.diagram_section {
    flex: 0 0 300px;
    width: 300px;
    min-width: 250px;
    margin: 0;
}

.thread_diagram_display {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 10px;
    background-color: #f7f7f7;
    border-radius: 8px;
}

.thread_diagram_display svg {
    width: 100%;
    height: auto;
    max-width: 100%;
}

/* ねじ仕様入力エリア - 規格選択と同じ幅に制限 */
.thread_inputs {
    width: 100%;
    max-width: 500px;
}

#manual_input_form .thread_inputs,
#rc_select_form .thread_inputs {
    max-width: 500px;
}

.thread_diagram {
    flex: 0 0 300px;
    width: 300px;
    min-width: 250px;
    margin: 0;
}

.thread_diagram svg {
    width: 100%;
    height: auto;
    max-width: 100%;
}

/* フッター */
footer {
    width: 100%;
    height:150px;
    background-color:#2b2b2b;
    color:#fff;
    position: absolute;
    bottom:0;
}
.footer_inner {
    max-width:1000px;
    margin:0 auto;
    text-align:center;
    padding:30px;
}
.footer_inner a {
    color:#fff;
    text-decoration: none;
    margin:0 50px;
}
@media (max-width: 1100px) {
    .header_inner {
        max-width:900px;
    }
    .search_wrapper {
        max-width:900px;
    }
    .detail_area {
        max-width:900px;
    }
    .footer_inner {
        max-width:900px;
    }
    .tool_detail {
        margin:0;
    }
    .pass_detail_area {
        margin-left:1em;
    }
    .pass_prot_1 {
        position:absolute;
        left:5px;
        top:135px;
    }
    .pass_prot_2 {
        position:absolute;
        left:5px;
        top:72px;
    }
    .pass_prot_3 {
        position:absolute;
        left:5px;
        top:9px;
    }
    .program_title button {
        width:90%;
    }
}
@media (max-width: 950px) {
    .header_inner {
        max-width:750px;
    }
    .search_wrapper {
        max-width:750px;
    }
    .detail_area {
        max-width:750px;
    }
    .footer_inner {
        max-width:750px;
    }
    .tool_image {
        width:40%;
    }
    .tool_detail {
        margin:0;
    }
    .pass_prot_1 {
        position:absolute;
        font-size:14px;
        left:0px;
        top:108px;
    }
    .pass_prot_2 {
        position:absolute;
        font-size:14px;
        left:0px;
        top:60px;
    }
    .pass_prot_3 {
        position:absolute;
        font-size:14px;
        left:0px;
        top:7px;
    }
    .program_title {
        flex-flow:wrap;
        justify-content: space-between;
    }
    .program_title button {
        width:48%;
        margin:0 0 10px 0;
        height:50px;
    }
    .program_title img {
        width:10%;
    }
}
@media (max-width: 550px) {
    header {
        height:100px;
    }
    .header_inner {
        padding:0 3%;
        height:100px;
        align-items:center;
    }
    .header_inner h1 {
        font-size:20px;
    }
    .search_wrapper {
        margin:0 3%;
    }
    .section_title {
        padding: 1em 1em 0 1.3em;
    }
    .dimention_area {
        flex-flow: wrap;
    }
    .dimention_item p {
        margin:15px 0 0 25px;
    }
    .dimention_item img {
        width:100%;
    }
    /* 規格選択とねじ寸法図のモバイル最適化 */
    .standard_and_diagram_container {
        flex-direction: column;
        flex-wrap: wrap;
    }
    
    .standard_selection_section {
        min-width: 100%;
        max-width: 100%;
    }
    
    .thread_inputs_vertical {
        grid-template-columns: 1fr;
        width: 100%;
    }
    
    /* モバイルでは通常の縦並び */
    .thread_inputs_vertical .form_item:nth-child(1),
    .thread_inputs_vertical .form_item:nth-child(2),
    .thread_inputs_vertical .form_item:nth-child(3),
    .thread_inputs_vertical .form_item:nth-child(4) {
        grid-column: 1;
        grid-row: auto;
    }
    
    .diagram_section {
        flex: 1 0 100%;
        width: 100%;
        max-width: 100%;
        margin: 20px auto 0;
    }
    
    .thread_diagram_display {
        padding: 10px 5px;
    }
    
    /* ねじ仕様入力のモバイル最適化 */
    .thread_inputs {
        min-width: 100%;
        max-width: 100%;
    }
    
    .thread_diagram {
        flex: 1 0 100%;
        width: 100%;
        max-width: 100%;
        padding: 0 10px;
        margin: 20px auto 0;
    }
    
    .thread_diagram svg {
        max-width: 100%;
    }
    .search_form {
        flex-flow:wrap;
    }
    .form_parts {
        width:100%;
    }
    .form_parts_1,.form_parts_2 {
        border:0;
    }
    .form_item {
        width:100%;
    }
    .result_area {
        flex-flow:wrap;
    }
    .result_item {
        width:100%;
        margin-right:0;
    }
    .detail_area {
        margin:0 3%;
    }
    .tool_image {
        width:100%;
    }
    .tool_image img {
        max-width:100%;
    }
    .tool_detail {
        margin-left:0;
    }
    .pass_detail_area {
        margin-left:0;
        width:100%;
    }
    .pass_prot_1 {
        position:absolute;
        left:1%;
        top:48%;
    }
    .pass_prot_2 {
        position:absolute;
        left:1%;
        top:26%;
    }
    .pass_prot_3 {
        position:absolute;
        left:1%;
        top:4%;
    }
    .program_area {
        width:100%;
    }
    .program_title {
        flex-flow:wrap;
        justify-content:space-between;
    }
    .program_title button {
        width:48%;
        height:50px;
        margin:0 0 10px 0;
    }
    .copy_area {
        max-height: 300px;
    }
    .footer_flex {
        display:flex;
        flex-flow:wrap;
    }
    .footer_inner {
        background-color:#2b2b2b;
    }
    .footer_inner a {
        width:100%;
        margin:10px 0;
    }
}
@media (max-width: 400px) {
    /* 375px以下の小画面用の追加調整 */
    .diagram_section {
        flex: 1 0 100%;
        width: 100%;
        max-width: 100%;
        padding: 0 5px;
    }
    
    .thread_diagram_display {
        padding: 5px;
    }
    
    .thread_diagram {
        flex: 1 0 100%;
        width: 100%;
        max-width: 100%;
        padding: 0 5px;
    }
    .header_inner h1 {
        font-size:16px;
        padding-left:10px;
    }
    .form_item {
        width:90%;
    }
}
/* �c�[���`�b�v�X�^�C�� */
.tooltip-container {
    position: relative;
    display: inline-block;
}

.tooltip-icon {
    display: inline-block;
    width: 16px;
    height: 16px;
    background-color: #2196F3;
    color: white;
    border-radius: 50%;
    text-align: center;
    line-height: 16px;
    font-size: 12px;
    font-weight: bold;
    cursor: help;
    margin-left: 4px;
    vertical-align: middle;
}

.tooltip-content {
    visibility: hidden;
    opacity: 0;
    position: absolute;
    z-index: 1000;
    bottom: 125%;
    left: 50%;
    transform: translateX(-50%);
    background-color: #333;
    color: #fff;
    padding: 10px 12px;
    border-radius: 6px;
    font-size: 13px;
    line-height: 1.5;
    width: 250px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    transition: opacity 0.3s, visibility 0.3s;
    white-space: normal;
    text-align: left;
}

.tooltip-content::after {
    content: "";
    position: absolute;
    top: 100%;
    left: 50%;
    margin-left: -5px;
    border-width: 5px;
    border-style: solid;
    border-color: #333 transparent transparent transparent;
}

.tooltip-container:hover .tooltip-content {
    visibility: visible;
    opacity: 1;
}

/* モバイル対応 */
@media (max-width: 768px) {
    .tooltip-content {
        width: 200px;
        font-size: 12px;
    }
}

/* ==============================================
   Gコードヘルプモーダル
   ============================================== */
.gcode-help-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    z-index: 10000;
    justify-content: center;
    align-items: center;
}

.gcode-help-modal.active {
    display: flex;
}

.gcode-modal-content {
    background: var(--color-bg-white);
    border-radius: 8px;
    max-width: 800px;
    max-height: 90vh;
    overflow-y: auto;
    padding: 30px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
}

.gcode-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.gcode-modal-header h3 {
    margin: 0;
    color: var(--color-text-primary);
}

.gcode-modal-close {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: var(--color-text-muted);
    padding: 0;
    width: 30px;
    height: 30px;
    transition: color 0.2s;
}

.gcode-modal-close:hover {
    color: var(--color-text-primary);
}

.gcode-modal-body {
    display: grid;
    gap: 20px;
}

.gcode-section h4 {
    color: var(--color-primary);
    margin-bottom: 10px;
    border-bottom: 2px solid var(--color-primary);
    padding-bottom: 5px;
}

.gcode-table {
    width: 100%;
    border-collapse: collapse;
}

.gcode-table th,
.gcode-table td {
    padding: 8px;
    text-align: left;
    border: 1px solid var(--color-border);
}

.gcode-table th {
    background: var(--color-bg-light);
    font-weight: 600;
}

.gcode-table tr:nth-child(even) {
    background: #fafafa;
}

.gcode-table td:first-child {
    font-weight: bold;
}

.gcode-color-red {
    color: #ff4444;
}

.gcode-color-green {
    color: #44ff44;
}

.gcode-color-blue {
    color: #4444ff;
}

.gcode-color-magenta {
    color: #ff44ff;
}

.gcode-params-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
    font-size: 14px;
}

.gcode-param-item {
    padding: 8px;
    background: var(--color-bg-light);
    border-radius: 4px;
}

.gcode-feature-box {
    background: var(--color-primary-pale);
    padding: 15px;
    border-radius: 6px;
    border-left: 4px solid var(--color-primary);
}

.gcode-feature-box h4 {
    color: var(--color-text-primary);
    margin: 0 0 10px 0;
    border: none;
    padding: 0;
}

.gcode-feature-box ul {
    margin: 0;
    padding-left: 20px;
    line-height: 1.8;
}

.gcode-feature-box .highlight-green {
    color: #00cc00;
    font-weight: bold;
}

.gcode-feature-box .highlight-red {
    color: #cc0000;
    font-weight: bold;
}

/* mm/inch切り替えボタンのスタイル */
.step_header_with_unit_toggle {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1em;
}

.unit_toggle_button_group {
    display: flex;
    gap: 0;
    border: 2px solid var(--color-primary);
    border-radius: 6px;
    overflow: hidden;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.unit_toggle_btn {
    padding: 8px 20px;
    font-size: 14px;
    font-weight: 600;
    border: none;
    background-color: #fff;
    color: var(--color-primary);
    cursor: pointer;
    transition: all 0.3s ease;
    outline: none;
    min-width: 60px;
}

.unit_toggle_btn:not(:last-child) {
    border-right: 2px solid var(--color-primary);
}

.unit_toggle_btn:hover:not(.active) {
    background-color: var(--color-primary-pale);
}

.unit_toggle_btn.active {
    background-color: var(--color-primary);
    color: #fff;
    font-weight: 700;
}

.unit_toggle_btn:active {
    transform: scale(0.98);
}

@media (max-width: 768px) {
    .step_header_with_unit_toggle {
        flex-direction: column;
        align-items: flex-start;
        gap: 15px;
    }
    
    .unit_toggle_button_group {
        align-self: flex-end;
    }
}

/* ==============================================
   3Dビューポートコントロール（ズームボタン）
   ============================================== */
.zoom_controls {
    display: flex;
    gap: 5px;
    margin-left: 10px;
}

.btn_zoom {
    padding: 6px 12px;
    font-size: 16px;
    min-width: 40px;
    background: var(--color-bg-white);
    border: 1px solid var(--color-border);
    transition: all 0.2s;
}

.btn_zoom:hover {
    background: var(--color-primary-pale);
    border-color: var(--color-primary);
    transform: scale(1.05);
}

.btn_zoom:active {
    transform: scale(0.95);
}

