/* --- System Variables --- */
:root {
    --bg-color: #0d0d0d;
    --panel-bg: rgba(20, 20, 20, 0.9);
    --accent-blue: #00d1ff;
    --error-red: #ff4b5c;
    --success-green: #00ff41;
    --warning-yellow: #f1fa8c;
    --border-color: rgba(0, 209, 255, 0.25);
    --font-mono: 'JetBrains Mono', 'Share Tech Mono', monospace;
    --text-main: #e0e0e0;
    --code-green: #00ff41;
}

/* --- Global Reset & Base --- */
* { box-sizing: border-box; }

body {
    background-color: var(--bg-color);
    background-image: 
        linear-gradient(var(--border-color) 1px, transparent 1px),
        linear-gradient(90deg, var(--border-color) 1px, transparent 1px);
    background-size: 30px 30px;
    color: var(--text-main);
    font-family: var(--font-mono);
    margin: 0;
    padding: 20px;
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}

/* --- Layout Components --- */
.diagnostic-container {
    max-width: 1100px;
    margin: 0 auto;
    background: var(--panel-bg);
    backdrop-filter: blur(12px);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    box-shadow: 0 0 40px rgba(0, 0, 0, 0.7);
    padding: 24px;
}

.main-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 2px solid var(--border-color);
    padding-bottom: 15px;
    margin-bottom: 20px;
}

.logo h1 {
    margin: 0;
    font-size: 1.6rem;
    color: var(--accent-blue);
    text-shadow: 0 0 15px rgba(0, 209, 255, 0.4);
    letter-spacing: 2px;
}

/* --- Input Area --- */
.input-area {
    position: relative;
    margin-bottom: 15px;
}

textarea, .file-drop-zone, .url-input-zone {
    width: 100%;
    height: 120px;
    background: #000;
    border: 1px solid #222;
    color: var(--code-green);
    padding: 15px;
    font-family: var(--font-mono);
    font-size: 13px;
    outline: none;
    transition: border-color 0.3s;
}

textarea:focus { border-color: var(--accent-blue); }

/* --- Tab Navigation --- */
.tab-group {
    display: flex;
    gap: 2px;
    margin-bottom: 5px;
}

.tab-btn {
    background: transparent;
    border: 1px solid var(--border-color);
    color: #555;
    padding: 8px 18px;
    font-size: 0.75rem;
    font-weight: 600;
    cursor: pointer;
    text-transform: uppercase;
    transition: all 0.3s ease;
}

.tab-btn.active {
    color: var(--accent-blue);
    background: rgba(0, 209, 255, 0.1);
    border-color: var(--accent-blue);
    border-bottom: 3px solid var(--accent-blue);
    text-shadow: 0 0 8px var(--accent-blue);
}

/* --- Diagnostic Header (Improved) --- */
.diagnostic-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin: 25px 0 10px;
    padding: 10px 15px;
    background: linear-gradient(90deg, rgba(0, 209, 255, 0.1) 0%, transparent 100%);
    border-left: 4px solid var(--accent-blue);
}

.diagnostic-header h3 {
    font-size: 0.85rem;
    letter-spacing: 2px;
    color: var(--text-main);
    margin: 0;
    display: flex;
    align-items: center;
}

#errorCount {
    display: inline-block;
    min-width: 1.5em;
    text-align: center;
    font-weight: 800;
    font-size: 1.2rem;
    margin: 0 8px;
    color: var(--accent-blue);
    transition: 0.3s;
}

#errorCount.has-error {
    color: var(--error-red);
    text-shadow: 0 0 12px var(--error-red);
    animation: alert-pulse 1s infinite alternate;
}

.header-gear::before {
    content: "⚙";
    display: inline-block;
    font-size: 1.1rem;
    color: var(--accent-blue);
    animation: spin 4s infinite linear;
}

/* --- Source Inspector (Core View) --- */
.code-viewer {
    background: #050505;
    border: 1px solid var(--border-color);
    max-height: 900px;
    overflow: auto;
    position: relative;
}

.code-line {
    display: flex;
    width: 100%;
    border-bottom: 1px solid rgba(255, 255, 255, 0.02);
    scroll-margin-top: 60px;
}

.line-number {
    width: 55px;
    min-width: 55px;
    background: #111;
    color: #444;
    text-align: right;
    padding-right: 12px;
    font-size: 11px;
    font-weight: bold;
    border-right: 2px solid #222;
    user-select: none;
    line-height: 1.8;
}

.line-content {
    flex-grow: 1;
    color: #f8f8f2;
    white-space: pre-wrap;
    word-break: break-all;
    font-size: 13px;
    padding-left: 12px;
    line-height: 1.8;
}

/* Error Row States */
.code-line.error-row {
    background: rgba(255, 75, 92, 0.08) !important;
}

.error-row .line-number {
    background: var(--error-red);
    color: #fff;
    border-right-color: var(--error-red);
}

/* --- Diagnostic Log Items --- */
.log-item {
    padding: 6px 10px;
    border-bottom: 1px solid rgba(255,255,255,0.03);
    font-size: 0.85rem;
}

.ln-link {
    color: var(--warning-yellow);
    text-decoration: none;
    font-weight: bold;
    border-bottom: 1px dashed var(--warning-yellow);
    cursor: pointer;
    margin-right: 8px;
}

.ln-link:hover {
    background: var(--warning-yellow);
    color: #000;
}

/* --- Animations --- */
@keyframes alert-pulse {
    from { filter: brightness(1); }
    to { filter: brightness(1.5); }
}

@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

/* --- Syntax Colors --- */
.hljs-tag { color: #ff79c6; }
.hljs-attr { color: #50fa7b; }
.hljs-string { color: var(--warning-yellow); }
.hljs-comment { color: #6272a4; }
.hljs-bracket { color: var(--accent-blue); }

.hidden { display: none !important; }

/* ログアイテムのテキストが変な位置で改行されないようにする */
.log-item {
    display: flex;         /* 行番号とメッセージを横並びに */
    align-items: center;   /* 垂直方向の中央揃え */
    gap: 12px;            /* 間隔を広めに確保 */
    padding: 8px 15px;
    white-space: nowrap;   /* 基本は改行させない */
}

.error-text {
    /* もし幅が狭くなった時でも、「が」で不自然に切れないようにする設定 */
    white-space: normal;   /* テキスト量が多い場合は自然に折り返す */
    word-break: keep-all;  /* 単語の途中（助詞の前など）でなるべく切らない */
    overflow-wrap: break-word;
}

.ln-link {
    flex-shrink: 0;        /* 行番号ラベルが圧縮されないように固定 */
    min-width: 80px;       /* 行番号エリアの幅を確保 */
}

.code-viewer-wrap {
    border: 1px solid rgba(0, 209, 255, 0.2);
    background: rgba(10, 15, 25, 0.8);
    position: relative;
    margin-top: 20px;
}

/* 見出し全体のデザイン */
.inspector-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: linear-gradient(90deg, rgba(0, 209, 255, 0.1) 0%, transparent 100%);
    padding: 10px 15px;
    border-bottom: 1px solid rgba(0, 209, 255, 0.3);
    position: relative;
    overflow: hidden;
}

/* 左側のメインタイトル */
.header-main {
    display: flex;
    align-items: center;
    gap: 10px;
}

.terminal-prompt {
    color: #00d1ff;
    font-family: 'Share Tech Mono', monospace;
    font-weight: bold;
    animation: blink 1s step-end infinite;
}

.inspector-header h3 {
    margin: 0;
    font-family: 'Share Tech Mono', monospace;
    font-size: 1.1rem;
    color: #00d1ff;
    letter-spacing: 2px;
    text-transform: uppercase;
    text-shadow: 0 0 8px rgba(0, 209, 255, 0.5);
}

/* 右側のサブテキスト（装飾用） */
.header-sub {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.75rem;
    color: rgba(0, 209, 255, 0.5);
}

/* スキャンラインのようなアニメーション装飾 */
.scan-line {
    position: absolute;
    top: 0;
    left: -100%;
    width: 50%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(0, 209, 255, 0.05), transparent);
    animation: scan 4s linear infinite;
}

@keyframes scan {
    0% { left: -100%; }
    100% { left: 200%; }
}

@keyframes blink {
    50% { opacity: 0; }
}

/* 行番号エリア：視認性特化型 */
.line-number {
    text-align: right;
    padding-right: 15px;
    margin-right: 15px;
    
    /* はっきりとした配色：白に近いグレーでコントラストを確保 */
    color: #e0e6ed; 
    
    /* ぼやけを排除：シャドウを消し、アンチエイリアスを調整 */
    text-shadow: none !important;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    
    /* フォント：数字の判別がしやすい実用的な等幅フォント */
    font-family: 'JetBrains Mono', 'Cascadia Code', 'Courier New', monospace;
    font-size: 0.9rem;
    font-weight: 500; /* 太すぎず細すぎず */
    
    /* 垂直線は少し落ち着かせて数字を主役にする */
    border-right: 2px solid rgba(255, 255, 255, 0.15);
    
    user-select: none;
    opacity: 1; /* 透過させない */
}

/* エラー行の数字：ここも「ぼやけ」を消してはっきりさせる */
.error-row .line-number {
    color: #ffffff;
    background-color: rgba(255, 0, 85, 0.4); /* 背景に色をつけて行全体を強調 */
    border-right-color: #ff0055;
    text-shadow: none !important;
}

/* ホバー時の挙動を少しだけ分かりやすく */
.code-line:hover .line-number {
    color: #ffffff;
    border-right-color: #00d1ff;
}

/* URL入力ゾーン全体のコンテナ */
.url-input-zone {
    background: rgba(0, 209, 255, 0.05);
    border: 1px dashed rgba(0, 209, 255, 0.3);
    padding: 20px;
    margin: 10px 0;
    position: relative;
    overflow: hidden;
}

/* URLフィールド自体のデザイン */
#urlField {
    width: 100%;
    background: #0a0f19;
    border: 1px solid #e0e6ed;
    border-left: 4px solid #00d1ff; /* 左側にアクセントライン */
    padding: 12px 15px 12px 40px; /* アイコン分の余白 */
    color: #ffffff;
    font-family: 'JetBrains Mono', monospace;
    font-size: 1rem;
    outline: none;
    transition: all 0.3s ease;
    box-shadow: inset 0 0 10px rgba(0, 0, 0, 0.5);
}

/* 入力中（フォーカス時）のエフェクト */
#urlField:focus {
    border-color: #00d1ff;
    box-shadow: 0 0 15px rgba(0, 209, 255, 0.2), inset 0 0 5px rgba(0, 209, 255, 0.1);
    background: #0d1526;
}

/* URL入力欄の前にアイコンを表示する装飾 */
.url-input-zone::before {
    content: "LINK";
    position: absolute;
    left: 30px;
    top: 50%;
    transform: translateY(-50%);
    font-family: 'Share Tech Mono', monospace;
    font-size: 0.7rem;
    color: #00d1ff;
    pointer-events: none;
    z-index: 1;
    opacity: 0.7;
}

/* ローディング・スキャン演出（装飾用） */
.url-input-zone::after {
    content: "";
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 2px;
    background: linear-gradient(90deg, transparent, #00d1ff, transparent);
    animation: url-scan 3s infinite;
    opacity: 0.3;
}

@keyframes url-scan {
    0% { transform: translateX(-100%); }
    100% { transform: translateX(100%); }
}

/* 非表示状態（hiddenクラス）の制御 */
.hidden {
    display: none !important;
}

/* アクションバー全体のレイアウト */
.action-bar {
    display: flex;
    justify-content: space-between; /* 左右両端に配置 */
    align-items: flex-start;      /* 上揃え（バナーが大きいため） */
    gap: 20px;
    margin-top: 20px;
    padding: 15px;
    background: rgba(0, 209, 255, 0.03);
    border: 1px solid rgba(0, 209, 255, 0.1);
    position: relative;
}

/* ボタンのグループ（左側） */
.button-group {
    display: flex;
    gap: 15px;
    flex-wrap: wrap; /* 画面が狭い時に折り返しを許可 */
    width:100%;
}

/* バナーエリア（右側） */
.ad-banner {
    width: 300px;
    height: 250px;
    min-width: 300px; /* サイズを固定 */
    background: #050a14;
    border: 2px solid rgba(0, 209, 255, 0.2);
    box-shadow: 0 0 15px rgba(0, 0, 0, 0.5);
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* バナーが広告エリアだとわかるような装飾（任意） */
/*
.ad-banner::before {
    content: "SPONSORED";
    position: absolute;
    top: -10px;
    right: 10px;
    background: #00d1ff;
    color: #050a14;
    font-size: 0.6rem;
    font-family: 'Share Tech Mono', monospace;
    padding: 2px 6px;
    font-weight: bold;
}
*/

/* 診断インジケーターのコンテナ */
.diagnostic-monitor {
    margin: 20px 0;
    background: #050a14;
    border-left: 5px solid #00d1ff;
    border-top: 1px solid rgba(0, 209, 255, 0.2);
    border-bottom: 1px solid rgba(0, 209, 255, 0.2);
    border-right: 1px solid rgba(0, 209, 255, 0.2);
    padding: 15px 20px;
    position: relative;
    overflow: hidden;
}

/* タイトル部分 */
.monitor-label {
    display: block;
    font-family: 'Share Tech Mono', monospace;
    font-size: 0.7rem;
    color: rgba(0, 209, 255, 0.6);
    letter-spacing: 2px;
    margin-bottom: 5px;
}

/* メインのステータス表示 */
.monitor-main {
    display: flex;
    align-items: baseline;
    gap: 10px;
    font-family: 'Share Tech Mono', monospace;
    font-size: 1.2rem;
}

.status-label, .error-label {
    font-size: 0.8rem;
    color: #e0e6ed;
    opacity: 0.7;
}

/* 数値部分の強調（青く光らせる） */
#statusValue, #errorCount {
    color: #00d1ff;
    font-weight: bold;
    text-shadow: 0 0 10px rgba(0, 209, 255, 0.4);
}

/* エラー時の赤色変化用 */
#statusValue.error, .has-error #errorCount {
    color: #ff0055 !important;
    text-shadow: 0 0 10px rgba(255, 0, 85, 0.6) !important;
}

/* 背景に流れるデコレーションテキスト */
.monitor-bg-text {
    position: absolute;
    right: 10px;
    bottom: -5px;
    font-family: 'Share Tech Mono', monospace;
    font-size: 2.5rem;
    color: rgba(0, 209, 255, 0.03);
    pointer-events: none;
    font-style: italic;
}

/* 区切り線 */
.separator {
    color: rgba(255, 255, 255, 0.1);
    margin: 0 10px;
}

/* 結果セクション全体の基本サイズを抑制 */
#resultSection {
    font-size: 0.85rem; /* 約13.6px */
    color: #e0e6ed;
}

/* ログアイテムのテキストサイズ */
.log-item {
    font-size: 0.8rem; /* 少し小さくして情報を詰め込む */
    padding: 6px 12px; /* 余白も少しタイトに */
}

.error-text {
    line-height: 1.4;
    letter-spacing: 0.02em;
}

/* ソースインスペクター内のコードテキスト */
.line-content {
    font-size: 0.85rem; /* 等幅フォントが読みやすいサイズ */
    line-height: 1.5;
}

/* 行番号のサイズ調整 */
.line-number {
    font-size: 0.75rem; /* 数字はさらに一回り小さくして目立たせない */
    width: 50px;
}

/* 各パネルの見出し（SOURCE INSPECTORなど） */
.inspector-header h3, 
.code-viewer-wrap h3 {
    font-size: 0.9rem;
    letter-spacing: 1px;
}

/* モニターエリア内の小さなラベル */
.monitor-label, 
.status-label, 
.error-label {
    font-size: 0.65rem; /* 補助情報は極小サイズに */
    text-transform: uppercase;
}

/* コード表示エリアのテキストサイズを強制的に絞り込む */
.line-content {
    font-size: 0.75rem !important; /* 12px相当までサイズダウン */
    line-height: 1.4;
    font-family: 'JetBrains Mono', monospace;
    white-space: pre-wrap; /* 長い1行も折り返して表示 */
    word-break: break-all;
}

/* ハイライト用のスパン要素も親のサイズに従わせる */
.line-content span {
    font-size: inherit; /* 親である .line-content のサイズ(0.75rem)を強制継承 */
    letter-spacing: 0;
}

/* 特に行番号とコードのバランスを調整 */
.line-number {
    font-size: 0.7rem; /* 数字も連動して小さく */
    padding-top: 2px;  /* 文字が小さくなった分、位置を微調整 */
}

/* 全体のハイライトを無効化（白に統一） */
.line-content {
    color: #ffffff !important;
    font-size: 0.75rem !important;
    text-shadow: none !important;
}

/* hljs系のクラスが残っていてもすべて白にする */
.line-content span {
    color: #ffffff !important;
    font-weight: normal !important;
}

/* エラー行自体の背景を暗い赤に */
.error-row {
    background: rgba(255, 0, 85, 0.15) !important;
    position: relative;
}

/* エラー行のテキスト全体を少し強調 */
.error-row .line-content {
    color: #ffb3c1 !important; /* エラー行は少しピンクがかった白に */
}

/* ログ内の「問題のタグ名」だけを真っ赤に光らせる */
.error-tag-name {
    color: #ff0055;
    font-weight: bold;
    text-shadow: 0 0 8px rgba(255, 0, 85, 0.5);
    font-family: 'JetBrains Mono', monospace;
}

/* ログアイテムの調整 */
.log-item {
    border-left: 3px solid transparent;
}

.log-item:has(.error-text) {
    border-left-color: #ff0055;
    background: rgba(255, 0, 85, 0.05);
}

/* ソースコード全体：装飾なしの白 */
.line-content {
    color: #ffffff !important;
    font-size: 0.75rem;
    text-shadow: none !important;
}

/* エラー行全体の背景色は「なし」にする（または極めて薄くする） */
.error-row {
    background: transparent !important; 
}

/* 問題のタグだけを赤くハイライト */
.error-highlight {
    color: #ff0055 !important; /* ビビッドな赤 */
    font-weight: bold;
    text-shadow: 0 0 10px rgba(255, 0, 85, 0.8); /* 異常事態を知らせる発光 */
    padding: 0 2px;
    background: rgba(255, 0, 85, 0.1); /* ほんの少しだけ背景を赤らめる */
    border: 1px solid rgba(255, 0, 85, 0.3);
    border-radius: 2px;
}

/* ログリスト内のタグ名も統一 */
.error-tag-name {
    color: #ff0055;
    font-weight: bold;
    text-decoration: underline;
}

/* デフォルトのスタイル（必要に応じて） */
.value {
    transition: color 0.3s ease; /* 色の変化を滑らかに */
}

/* エラー検知時の赤色 */
.is-error {
    color: #ff4d4d !important; /* ネオンレッド */
    text-shadow: 0 0 8px rgba(255, 77, 77, 0.6); /* 軽く光らせる */
}

/* 正常時の色（お好みで） */
.is-stable {
    color: #00f2ff !important; /* ネオンブルー */
    text-shadow: 0 0 8px rgba(0, 242, 255, 0.6);
}

/* コンテンツの出し分け */
.tab-content {
    display: none; /* 基本は非表示 */
}
.tab-content.active {
    display: flex; /* activeクラスがついたものだけ表示 */
    align-items: center;
    gap: 10px;
}

/* タブボタンの装飾（GEAR風） */
.tab-switcher {
    display: flex;
    gap: 5px;
    margin-bottom: 15px;
    border-bottom: 1px solid #333;
}
.tab-btn {
    background: transparent;
    border: 1px solid #444;
    border-bottom: none;
    color: #888;
    padding: 8px 15px;
    cursor: pointer;
    font-size: 12px;
    transition: all 0.3s;
}
.tab-btn.active {
    background: #222;
    color: #00f2ff; /* 正常時の色と合わせる */
    border-color: #00f2ff;
    box-shadow: 0 0 10px rgba(0, 242, 255, 0.2);
}


@media screen and (max-width:768px){

    .ad-banner{
        display:none;
    }

}

/* --- システムログ用：ステータスランプの明滅アニメーション --- */
@keyframes log-blink {
    0%, 100% { opacity: 0.4; filter: brightness(0.8); }
    50% { opacity: 1; filter: brightness(1.2); box-shadow: 0 0 12px #2ecc71; }
}