* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: sans-serif;
    background-color: #ffffff;
    color: #333;
    overflow: hidden;
    touch-action: none; /* タッチによるズームを無効化 */
}

#graph-container {
    width: 100vw;
    height: 100vh;
    position: relative;
    overflow: hidden;
    background-color: #ffffff;
    touch-action: none; /* タッチによるズームを無効化 */
}

#time-limit-control {
    position: fixed;
    bottom: 20px;
    right: 20px;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 6px;
    max-width: min(520px, calc(100vw - 40px));
    background-color: rgba(255, 255, 255, 0.95);
    padding: 8px 16px;
    border-radius: 4px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
    font-size: 14px;
    z-index: 1000;
}

#time-limit-control label {
    color: #999;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 4px;
}

#time-limit-control .control-row {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
}

#time-limit-control .control-title {
    min-width: 7em;
    color: #666;
    font-weight: 600;
}

#time-limit-control .control-label {
    color: #999;
}

#time-limit-control .control-note {
    color: #888;
    font-size: 12px;
    line-height: 1.5;
}

#time-limit-control .station-input {
    flex: 1;
    min-width: 10em;
    padding: 4px 8px;
    border: 1px solid #ccc;
    border-radius: 2px;
    font-size: 14px;
    background-color: #fff;
    color: #333;
}

#time-limit-control .station-input:focus {
    outline: none;
    border-color: #999;
}

#time-limit {
    width: 60px;
    padding: 4px 8px;
    border: 1px solid #ccc;
    border-radius: 2px;
    font-size: 14px;
    background-color: #fff;
    color: #999;
    text-align: center;
}

#time-limit:focus {
    outline: none;
    border-color: #999;
}

#line-select-button {
    padding: 4px 12px;
    background-color: #fff;
    border: 1px solid #ccc;
    border-radius: 2px;
    font-size: 14px;
    color: #999;
    cursor: pointer;
    font-weight: 500;
}

#line-select-button:hover {
    border-color: #999;
    background-color: #f5f5f5;
}

#line-select-panel {
    position: fixed;
    bottom: 70px;
    right: 20px;
    width: 250px;
    max-height: 400px;
    background-color: rgba(255, 255, 255, 0.95);
    border-radius: 4px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
    z-index: 1001;
    display: flex;
    flex-direction: column;
}

#line-select-panel.hidden {
    display: none;
}

#line-select-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    border-bottom: 1px solid #e0e0e0;
    font-size: 14px;
    font-weight: 600;
    color: #333;
}

#close-panel {
    background: none;
    border: none;
    font-size: 20px;
    color: #999;
    cursor: pointer;
    padding: 0;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
}

#close-panel:hover {
    color: #333;
}

#line-list {
    overflow-y: auto;
    max-height: 350px;
    padding: 8px 0;
}

.line-item {
    display: flex;
    align-items: center;
    padding: 8px 16px;
    cursor: pointer;
    gap: 8px;
}

.line-item:hover {
    background-color: #f5f5f5;
}

.select-all-item {
    background-color: #fafafa;
    font-weight: 600;
}

.select-all-item:hover {
    background-color: #f0f0f0;
}

.line-item input[type="checkbox"] {
    cursor: pointer;
    width: 16px;
    height: 16px;
}

.line-item label {
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 1;
    margin: 0;
}

.line-color-indicator {
    width: 20px;
    height: 3px;
    border-radius: 1px;
}

.line-name {
    font-size: 13px;
    color: #333;
}

#graph {
    width: 100%;
    height: 100%;
    display: block;
}

/* ノードのスタイル */
.node circle {
    stroke: #fff;
    stroke-width: 1px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.node circle:hover {
    stroke-width: 2px;
    filter: brightness(1.2);
}

.node.selected circle {
    stroke: #808080;
    stroke-width: 2px;
}

.node text {
    font-size: 8px;
    font-weight: bold;
    pointer-events: none;
    text-anchor: middle;
    fill: #444444;
    text-shadow: 1px 1px 2px white, -1px -1px 2px white, 1px -1px 2px white, -1px 1px 2px white;
}

.node-label {
    font-size: 8px;
    font-weight: bold;
    pointer-events: none;
    text-anchor: middle;
    fill: #444444;
    text-shadow: 1px 1px 2px white, -1px -1px 2px white, 1px -1px 2px white, -1px 1px 2px white;
}

/* リンクのスタイル */
.link {
    fill: none;
    stroke-width: 1.5px;
    opacity: 0.7;
    transition: opacity 0.3s ease;
    vector-effect: non-scaling-stroke;
}

.link:hover {
    opacity: 1;
    stroke-width: 2.5px;
}

/* リンクラベルのスタイル */
.link-label {
    font-size: 7px;
    font-weight: 600;
    fill: #cccccc;
    pointer-events: none;
    text-shadow: 1px 1px 3px white, -1px -1px 3px white, 1px -1px 3px white, -1px 1px 3px white;
    user-select: none;
}

/* マーカー（矢印） */
marker {
    fill: inherit;
}

/* ツールチップ */
.tooltip {
    position: absolute;
    padding: 10px;
    background-color: rgba(0, 0, 0, 0.8);
    color: white;
    border-radius: 5px;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.3s ease;
    font-size: 14px;
    z-index: 1000;
}

.tooltip.show {
    opacity: 1;
}

/* レスポンシブ対応 */
@media (max-width: 768px) {
    .node text,
    .node-label {
        font-size: 7px;
    }

    .link-label {
        font-size: 6px;
    }

    #time-limit-control {
        font-size: 12px;
    }

    #time-limit {
        width: 50px;
        font-size: 12px;
    }
}

/* 所要時間の前提（乗り換え時間などを含まない）の注意書き */
#time-limit-control .control-caution {
    color: #777;
    border-top: 1px solid #eee;
    padding-top: 4px;
}

/* 見方の3つの選択肢の説明（選んでいるものを濃く太く） */
#view-description .view-option {
    color: #aaa;
}

#view-description .view-option.current {
    color: #444;
    font-weight: 600;
}

/* 選択肢とボタンをひとまとまりにする（折り返しても項目名の列に回り込まず、選択肢の左端にそろう） */
#time-limit-control .control-options {
    display: flex;
    flex: 1;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;
}

/* 選択肢が折り返して2行になる行では、項目名を1行目にそろえる */
#time-limit-control .control-row:has(.control-options) {
    align-items: flex-start;
}

#time-limit-control .control-row:has(.control-options) .control-title {
    line-height: 1.6;
}

/* 「駅表示」のトグルスイッチ（チェックボックスを隠し、つまみが左右に動くスイッチとして描く） */
#time-limit-control .switch {
    position: relative;
    cursor: pointer;
    gap: 8px;
}

#time-limit-control .switch input {
    position: absolute;
    opacity: 0;
    width: 1px;
    height: 1px;
}

#time-limit-control .switch-track {
    position: relative;
    flex: none;
    width: 36px;
    height: 20px;
    border-radius: 10px;
    background-color: #ccc;
    transition: background-color 0.2s ease;
}

#time-limit-control .switch-track::after {
    content: '';
    position: absolute;
    top: 2px;
    left: 2px;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background-color: #fff;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
    transition: transform 0.2s ease;
}

#time-limit-control .switch input:checked + .switch-track {
    background-color: #666;
}

#time-limit-control .switch input:checked + .switch-track::after {
    transform: translateX(16px);
}

#time-limit-control .switch input:focus-visible + .switch-track {
    outline: 2px solid #999;
    outline-offset: 2px;
}

/* 駅表示オフ：出発駅以外の駅を隠す（クラスは #graph-container に付けるので、描き直しても保たれる） */
#graph-container.hide-stations .node:not(.selected) {
    display: none;
}

/* 駅表示オフでも、探している駅は出す */
#graph-container.hide-stations .node.focused {
    display: inline;
}

/* 出発駅（中心）と探している駅の駅名は大きく */
#graph-container .node.selected text.node-name,
#graph-container .node.focused text.node-name {
    font-size: 14px;
    fill: #222;
}

/* 表示中の駅の検索（左上に浮かせる。「時間を横軸で比較」の上端の分数ラベルにかからないよう少し下げる） */
#find-box {
    position: fixed;
    top: 44px;
    left: 16px;
    width: min(260px, calc(100vw - 32px));
    z-index: 1000;
    font-size: 14px;
}

#find-search {
    width: 100%;
    padding: 8px 10px 8px 32px;
    border: 1px solid #ccc;
    border-radius: 4px;
    font-size: 14px;
    color: #333;
    background: #fff url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 16 16'%3E%3Ccircle cx='6.5' cy='6.5' r='5' fill='none' stroke='%23999' stroke-width='1.8'/%3E%3Cline x1='10.2' y1='10.2' x2='14.5' y2='14.5' stroke='%23999' stroke-width='1.8' stroke-linecap='round'/%3E%3C/svg%3E") no-repeat 10px center;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

#find-search:focus {
    outline: none;
    border-color: #999;
}

#find-search-message:not(:empty) {
    margin-top: 4px;
    padding: 4px 10px;
    background-color: rgba(255, 255, 255, 0.95);
    border-radius: 4px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
    color: #666;
    font-size: 12px;
    line-height: 1.5;
}

/* 操作パネルのセクション（何を描くか／表示切り替え） */
#time-limit-control .control-section {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

#time-limit-control .control-section + .control-section {
    border-top: 1px solid #e5e5e5;
    padding-top: 8px;
    margin-top: 2px;
}

#time-limit-control .control-section-title {
    color: #999;
    font-size: 12px;
    font-weight: 600;
}

/* 利用手段のスイッチは横に並べる */
#time-limit-control .travel-modes {
    gap: 16px;
}

/* 使えないスイッチ（特急列車：データなし）は薄く */
#time-limit-control .switch:has(input:disabled) {
    opacity: 0.45;
    cursor: not-allowed;
}

/* 路線選択：利用手段がオフの種類の路線は選べない */
.line-item.disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.line-item.disabled label,
.line-item.disabled input {
    cursor: not-allowed;
}

/* 駅をクリックしたときの「出発駅を変更しますか？」 */
#center-confirm {
    position: fixed;
    z-index: 1100;
    max-width: 280px;
    padding: 10px 12px;
    background-color: #fff;
    border-radius: 6px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2);
    font-size: 14px;
    color: #333;
}

#center-confirm.hidden {
    display: none;
}

#center-confirm .center-confirm-title {
    font-weight: 600;
}

#center-confirm .center-confirm-buttons {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    margin-top: 10px;
}

#center-confirm button {
    padding: 4px 12px;
    border: 1px solid #ccc;
    border-radius: 3px;
    background-color: #fff;
    color: #666;
    font-size: 13px;
    cursor: pointer;
}

#center-confirm #center-confirm-ok {
    background-color: #555;
    border-color: #555;
    color: #fff;
}

/* 出典（CC BY 4.0 の表示義務）とバージョン番号（操作パネルの一番下） */
#time-limit-control .control-footer {
    display: flex;
    align-items: flex-end;
    gap: 8px;
}

#time-limit-control .control-credit {
    flex: 1;
    color: #aaa;
    font-size: 10px;
    line-height: 1.4;
}

#time-limit-control .control-version {
    color: #bbb;
    font-size: 11px;
    white-space: nowrap;
}

/* タイトル（操作パネルの一番上） */
#time-limit-control .app-title {
    font-size: 16px;
    font-weight: 700;
    color: #333;
    padding-bottom: 6px;
    border-bottom: 1px solid #e5e5e5;
}

/* 試作版の表示 */
#time-limit-control .prototype-badge {
    display: inline-block;
    margin-left: 6px;
    padding: 1px 6px;
    border: 1px solid #c62828;
    border-radius: 3px;
    color: #c62828;
    font-size: 11px;
    font-weight: 600;
    vertical-align: 2px;
}

#time-limit-control .prototype-note {
    color: #c62828;
}
