/* ★はみ出し防止の最重要コード */
*, *::before, *::after {
	box-sizing: border-box;
}

/* 全体・レイアウト設定 */
body, html { margin: 0; padding: 0; font-family: 'Helvetica Neue', Arial, sans-serif; height: 100vh; display: flex; flex-direction: column; background-color: #f4f6f9; overflow: hidden; }

/* ヘッダー */
.global-header { background: #0056b3; color: white; padding: 15px 25px; box-shadow: 0 2px 4px rgba(0,0,0,0.1); z-index: 10; flex-shrink: 0; }
.global-header h1 { margin: 0; font-size: 20px; font-weight: bold; letter-spacing: 1px; }

/* スマホ用警告バナー */
.mobile-warning { display: none; background: #fff3cd; color: #856404; padding: 12px 20px; border-bottom: 1px solid #ffeeba; align-items: center; justify-content: space-between; font-size: 13px; z-index: 11; flex-shrink: 0; width: 100%; }
.mobile-warning-content { display: flex; align-items: flex-start; gap: 10px; }
.mobile-warning-content p { margin: 0; line-height: 1.4; }
#close-mobile-warning { background: rgba(0,0,0,0.05); color: #856404; border: 1px solid rgba(0,0,0,0.1); padding: 6px 12px; border-radius: 4px; font-size: 12px; cursor: pointer; flex-shrink: 0; margin-left: 10px;}
#close-mobile-warning:hover { background: rgba(0,0,0,0.1); }

/* フッター */
.global-footer { background: #343a40; color: #adb5bd; padding: 15px 20px; text-align: center; font-size: 13px; z-index: 10; flex-shrink: 0; }
.footer-links { margin-bottom: 8px; }
.footer-links a { color: #adb5bd; text-decoration: none; margin: 0 12px; transition: color 0.2s; }
.footer-links a:hover { color: #fff; text-decoration: underline; }
.copyright { font-size: 12px; }

/* メインコンテンツ */
.main-content { flex: 1; position: relative; overflow: hidden; display: flex; flex-direction: column; }
.screen { display: none; flex: 1; flex-direction: column; overflow: hidden; }
.screen.active { display: flex; }

/* 汎用コンテナ */
.container { margin: auto; background: #fff; padding: 40px; border-radius: 8px; box-shadow: 0 4px 12px rgba(0,0,0,0.1); text-align: center; max-height: 90vh; overflow-y: auto; width: 100%; }
.top-container { max-width: 600px; }
.result-container { max-width: 1000px; height: 100%; display: flex; flex-direction: column; }

/* 入力フォーム周り */
.input-group { display: flex; margin-top: 20px; width: 100%; }
input[type="url"], input[type="text"], textarea { padding: 12px; border: 1px solid #ccc; border-radius: 4px; font-size: 14px; width: 100%; }
.input-group input[type="url"] { border-radius: 4px 0 0 4px; }
.form-group { text-align: left; margin-bottom: 15px; }
.form-group label { display: block; font-weight: bold; margin-bottom: 5px; font-size: 14px; color: #333; }
.full-width-textarea { height: 150px; resize: vertical; margin-bottom: 15px; font-family: monospace; }
.full-width-btn { width: 100%; }
.manual-desc { font-size: 14px; text-align: left; margin-bottom: 15px; color: #555; }

/* 共通ボタン設定 */
button { padding: 12px 24px; border: none; background: #0056b3; color: white; cursor: pointer; font-size: 16px; transition: 0.3s; font-weight: bold; border-radius: 4px; white-space: nowrap; }
button:hover { background: #004494; }
#start-btn-auto { border-radius: 0 4px 4px 0; width: auto; }
.secondary-btn { background: #6c757d; }
.secondary-btn:hover { background: #5a6268; }

/* トップ画面のタブとアナウンス */
.input-tabs { display: flex; margin-bottom: 20px; border-bottom: 2px solid #ddd; }
.input-tab { flex: 1; background: transparent; color: #6c757d; font-size: 15px; padding: 12px; border-radius: 0; box-shadow: none; font-weight: bold; }
.input-tab:hover { background: #f8f9fa; color: #333; }
.input-tab.active { color: #0056b3; border-bottom: 3px solid #0056b3; margin-bottom: -2px; }
.input-panel { display: none; }
.input-panel.active { display: block; animation: fadeIn 0.3s ease; }
.notice-box { margin-top: 25px; padding: 15px; background: #fff3cd; color: #856404; border-left: 4px solid #ffeeba; border-radius: 4px; font-size: 13px; text-align: left; line-height: 1.6; }

@keyframes fadeIn { from { opacity: 0; transform: translateY(5px); } to { opacity: 1; transform: translateY(0); } }

/* 診断画面ツールバー */
.header-toolbar { background: #fff; padding: 12px 20px; display: flex; justify-content: space-between; align-items: center; border-bottom: 1px solid #ddd; flex-shrink: 0; }
.header-toolbar h2 { margin: 0; font-size: 16px; color: #333; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; flex: 1; margin-right: 15px; }
.header-toolbar a { color: #0056b3; text-decoration: none; }

/* ワークスペース */
.workspace { display: flex; flex: 1; overflow: hidden; }

/* 左側プレビュー＆ソースコードエリア */
.preview-area { flex: 1; display: flex; flex-direction: column; background: #fff; min-height: 0; }
.view-toggle { display: flex; justify-content: space-between; align-items: center; background: #f8f9fa; border-bottom: 1px solid #ddd; padding-right: 15px; }
.view-tabs { display: flex; flex: 1; }
.view-btn { padding: 12px 20px; background: transparent; border: none; color: #6c757d; border-bottom: 3px solid transparent; border-radius: 0; font-weight: bold; cursor: pointer; transition: 0.2s; font-size: 14px; box-shadow: none; }
.view-btn:hover { background: #e9ecef; color: #333; }
.view-btn.active { color: #0056b3; border-bottom: 3px solid #0056b3; background: #fff; margin-bottom: -1px; }

/* コード整形ボタン */
.format-btn { background-color: #6f42c1; color: white; border: none; padding: 6px 12px; border-radius: 4px; font-size: 12px; cursor: pointer; font-weight: bold; transition: 0.2s; white-space: nowrap; }
.format-btn:hover { background-color: #59339d; }

.view-container { display: none; flex: 1; overflow: hidden; background: #eaeded; }
.view-container.active { display: flex; flex-direction: column; }
iframe { width: 100%; height: 100%; border: none; background: #fff; }

#source-code-display { flex: 1; width: 100%; height: 100%; resize: none; background: #1e1e1e; color: #d4d4d4; font-family: 'Consolas', 'Courier New', monospace; font-size: 14px; border: none; padding: 20px; outline: none; box-sizing: border-box; white-space: pre; overflow: auto; line-height: 1.5; }

/* サイドバー（コンパネ） */
.sidebar { width: 420px; background: #fff; border-left: 1px solid #ddd; display: flex; flex-direction: column; flex-shrink: 0; }
.step-header { padding: 15px 20px; border-bottom: 1px solid #eee; background: #fafafa; display: flex; justify-content: space-between; align-items: center; }
.step-header h3 { margin: 0; font-size: 16px; }
.progress { font-weight: bold; color: #0056b3; }
.check-content { flex: 1; padding: 20px; overflow-y: auto; }
.step-controls { padding: 15px 20px; border-top: 1px solid #eee; display: flex; justify-content: space-between; background: #fafafa; }
.step-controls button { width: 48%; border-radius: 4px; }
button:disabled { background: #ccc; cursor: not-allowed; }

/* バッジと説明 */
.badge { display: inline-block; padding: 4px 8px; background: #e9ecef; border-radius: 4px; font-size: 12px; margin-bottom: 10px; margin-right: 5px; }
.level-A { background: #d1e7dd; color: #0f5132; }
.level-AA { background: #fff3cd; color: #664d03; }
.level-AAA { background: #f8d7da; color: #842029; }
.check-title { font-size: 18px; margin: 0 0 15px 0; color: #333; line-height: 1.4; }
.check-desc { font-size: 14px; line-height: 1.6; color: #555; background: #f8f9fa; padding: 15px; border-radius: 6px; }

/* 自動診断・判定エリア */
.auto-check-area { margin-top: 20px; padding-top: 20px; border-top: 1px dashed #ccc; }
.diagnostic-btn { background-color: #17a2b8; width: 100%; margin-bottom: 15px; border-radius: 4px; }
.diagnostic-btn:hover { background-color: #138496; }
.diagnostic-result { display: none; padding: 15px; background-color: #e9ecef; border-radius: 4px; font-size: 14px; line-height: 1.5; border-left: 4px solid #17a2b8; }

.judgment-area { margin-top: 20px; padding-top: 20px; border-top: 1px solid #eee; }
.judgment-title { font-size: 14px; font-weight: bold; margin-bottom: 10px; color: #333; }
.judgment-options { display: flex; gap: 8px; margin-bottom: 5px; }
.judgment-label { flex: 1; text-align: center; background: #f8f9fa; border: 1px solid #ddd; padding: 12px 5px; border-radius: 4px; cursor: pointer; font-size: 13px; font-weight: bold; transition: 0.2s; color: #555; display: flex; align-items: center; justify-content: center; }
.judgment-label:hover { background: #e2e6ea; }
.judgment-label input[type="radio"] { display: none; }
.judgment-label.selected-pass { background: #d1e7dd; border-color: #badbcc; color: #0f5132; }
.judgment-label.selected-fail { background: #f8d7da; border-color: #f5c2c7; color: #842029; }
.judgment-label.selected-na { background: #e2e3e5; border-color: #d3d6d8; color: #41464b; }

/* 結果画面テーブル */
.result-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; }
.result-actions button { margin-left: 10px; }
.copy-btn { background: #28a745; }
.table-wrapper { overflow-y: auto; flex: 1; border: 1px solid #ddd; background: #fff; }
.result-table { width: 100%; border-collapse: collapse; text-align: left; font-size: 14px; }
.result-table th, .result-table td { border: 1px solid #ddd; padding: 12px; }
.result-table th { background: #f4f6f9; position: sticky; top: 0; z-index: 2; box-shadow: 0 1px 0 #ddd; }
.res-pass { color: #0f5132; font-weight: bold; }
.res-fail { color: #842029; font-weight: bold; }
.res-na { color: #41464b; }
.res-none { color: #ccc; }

/* モーダル */
.modal-overlay { display: none; position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.6); z-index: 1000; justify-content: center; align-items: center; padding: 20px; box-sizing: border-box;}
.modal-overlay.active { display: flex; animation: fadeIn 0.2s ease; }
.modal-box { background: #fff; width: 100%; max-width: 700px; max-height: 80vh; border-radius: 8px; box-shadow: 0 4px 20px rgba(0,0,0,0.2); display: flex; flex-direction: column; position: relative; }
.modal-box h2 { margin: 0; padding: 20px; border-bottom: 1px solid #eee; font-size: 18px; background: #f8f9fa; border-radius: 8px 8px 0 0; }
.modal-content { padding: 20px; overflow-y: auto; flex: 1; font-size: 14px; line-height: 1.6; color: #444; }
.modal-content h3 { font-size: 16px; margin: 20px 0 10px; color: #222; border-left: 4px solid #0056b3; padding-left: 10px; }
.modal-close { position: absolute; top: 15px; right: 20px; font-size: 24px; color: #888; cursor: pointer; line-height: 1; }

/* ==========================================
   ★スマートフォン用 レスポンシブ対応
   ========================================== */
@media (max-width: 768px) {
	/* PC推奨バナーを表示（確実に見せるために important を付与） */
	.mobile-warning { display: flex !important; }

	/* 全体のスクロール設定（スマホは縦並びにしてスクロールさせる） */
	body, html { height: auto; overflow: visible; }
	.main-content { overflow: visible; }
	.screen { height: auto; min-height: calc(100vh - 100px); }

	/* コンテナ幅を画面いっぱいに */
	.container { padding: 20px; width: 100%; border-radius: 0; box-shadow: none; max-height: none; }
	
	/* 入力フォームの縦積み */
	.input-group { flex-direction: column; }
	.input-group input[type="url"] { border-radius: 4px; margin-bottom: 10px; }
	#start-btn-auto { border-radius: 4px; width: 100%; }
	.input-tabs { flex-direction: column; border-bottom: none; }
	.input-tab { border-bottom: 1px solid #ddd; border-radius: 4px; margin-bottom: 5px; }
	.input-tab.active { border-bottom: 1px solid #0056b3; background: #eef5ff; }

	/* 診断画面の縦積み（プレビューが上、コンパネが下） */
	.workspace { flex-direction: column; overflow: visible; }
	.preview-area { min-height: 50vh; border-bottom: 2px solid #0056b3; flex: none; }
	.sidebar { width: 100%; flex: none; border-left: none; }
	
	/* ボタンやタブの押しやすさ改善 */
	.header-toolbar { flex-direction: column; align-items: flex-start; gap: 10px; }
	.header-toolbar h2 { margin-right: 0; margin-bottom: 5px; }
	#back-btn { width: 100%; }
	.view-toggle { flex-direction: column; padding-right: 0; }
	.view-tabs { width: 100%; }
	.view-btn { flex: 1; text-align: center; }
	.format-btn { margin: 10px; width: calc(100% - 20px); }
	
	/* 判定ボタンを縦に */
	.judgment-options { flex-direction: column; gap: 10px; }
	.judgment-label { padding: 15px; }
	
	/* 結果画面テーブルの横スクロール対応 */
	.result-header { flex-direction: column; gap: 15px; align-items: stretch; }
	.result-actions { display: flex; flex-direction: column; gap: 10px; }
	.result-actions button { margin-left: 0; width: 100%; }
	.table-wrapper { overflow-x: auto; }
	.result-table { min-width: 600px; }
}