/* 全体のスタイル */
html {
    scroll-behavior: auto;
}
body {
    font-family: 'Noto Sans JP', 'Inter', sans-serif;
    overscroll-behavior-y: contain;
    background-color: #f0f4f8; /* 全体の背景色 */
    font-size: 16px; /* 基本のフォントサイズ */
    color: #374151; /* Tailwind: text-gray-700 基本の文字色 */
}

/* タブボタンスタイル */
.tab-button.active {
    border-bottom-width: 2px;
    --tw-border-opacity: 1;
    border-color: rgb(59 130 246 / var(--tw-border-opacity));
    color: rgb(37 99 235 / var(--tw-border-opacity));
    background-color: white;
    font-weight: 600;
}
.tab-button {
    padding-top: 0.75rem;
    padding-bottom: 0.75rem;
    padding-left: 1rem;
    padding-right: 1rem;
    white-space: nowrap;
    font-size: 0.875rem;
    font-weight: 500;
    border-bottom-width: 2px;
    border-color: transparent;
}
.tab-button:not(.active):hover {
    --tw-text-opacity: 1;
    color: rgb(55 65 81 / var(--tw-text-opacity));
    border-color: rgb(209 213 219 / var(--tw-text-opacity));
}
/* huffman-hamming.html 内のタブボタン用 (アクティブ状態) */
.page-sub-tab.active-sub-tab { /* 例: ハフマン/ハミング切り替え */
    border-color: rgb(59 130 246 / 1); /* Tailwind: border-blue-600 */
    color: rgb(37 99 235 / 1);      /* Tailwind: text-blue-700 */
    background-color: white;
    font-weight: 600;
}
/* huffman-hamming.html 内のハミング符号表示用タブ (アクティブ状態) */
.hamming-display-tab.active-hamming-inner-tab {
    border-color: rgb(59 130 246 / 1); /* Tailwind: border-blue-600 */
    color: rgb(37 99 235 / 1);      /* Tailwind: text-blue-700 */
    font-weight: 600;
}


/* ページ上部の固定情報ブロック */
.page-top-header {
    background-color: #ffffff;
    padding: 1.5rem;
    border-radius: 0.75rem;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    margin-bottom: 1.5rem;
}
.page-top-header h1 {
    font-size: 1.875rem;
    font-weight: 700;
    color: #1e3a8a;
    text-align: center;
}
.page-top-header .subtitle {
    font-size: 0.875rem;
    color: #4b5563;
    text-align: center;
    margin-top: 0.25rem;
}
.page-top-header .page-title-main {
    font-size: 1.5rem;
    font-weight: 600;
    color: #1e40af;
    margin-top: 1rem;
    text-align: center;
}

/* 説明文ブロックのスタイル */
.description-block {
    background-color: #ffffff;
    padding: 1.5rem;
    border-radius: 0.75rem;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    margin-bottom: 1.5rem;
}
.description-block .introduction-text {
    font-size: 0.95rem;
    color: #374151;
    line-height: 1.6;
    text-align: left;
}
.description-block .introduction-text + .introduction-text {
    margin-top: 1rem;
}
.description-block .usage-note {
    font-size: 0.875rem;
    color: #4b5563;
    margin-top: 1rem;
    padding: 0.75rem;
    background-color: #eef2ff;
    border-left: 4px solid #4f46e5;
    border-radius: 0.25rem;
}

/* 学習ステップのカードコンテナ (index.html用) */
.card-container {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1.5rem;
    margin-bottom: 1.5rem;
}

@media (min-width: 768px) {
    .card-container {
        grid-template-columns: repeat(2, 1fr);
    }
    .card-full-width {
        grid-column: span 2 / span 2;
    }
}

/* フォーム要素の共通スタイル */
textarea,
select,
.event-row input[type="text"],
.input-row input[type="text"],
.input-field
 {
    border: 1px solid #D1D5DB;
    padding: 0.5rem;
    border-radius: 0.375rem;
    width: 100%;
    font-size: 0.9rem;
    color: #374151;
}
textarea {
    min-height: 100px; /* Slightly reduced default min-height for textareas */
}
textarea#userInputMessage { /* message.html & balance.html */
    min-height: auto;
    padding: 0.625rem;
}
textarea#huffmanInputText { /* huffman.html */
    min-height: 80px; /* Specific height for huffman input */
}


select {
    background-color: white;
}

.event-row button,
.input-row button
{
    padding: 0.5rem 0.75rem;
    border-radius: 0.375rem;
    background-color: #EF4444;
    color: white;
    transition: background-color 0.2s;
    font-size: 0.8rem;
}
.event-row button:hover,
.input-row button:hover {
    background-color: #DC2626;
}

.color-swatch {
    width: 20px; height: 20px; border-radius: 4px; display: inline-block;
    margin-right: 8px; vertical-align: middle; border: 1px solid #ccc;
}

.custom-scrollbar::-webkit-scrollbar { width: 8px; }
.custom-scrollbar::-webkit-scrollbar-track { background: #f1f1f1; border-radius: 10px; }
.custom-scrollbar::-webkit-scrollbar-thumb { background: #888; border-radius: 10px; }
.custom-scrollbar::-webkit-scrollbar-thumb:hover { background: #555; }

#treeCanvas, /* self-information.html */
#huffmanTreeCanvas /* huffman.html */
{
    border: 1px solid #e5e7eb; border-radius: 0.375rem; background-color: #f9fafb;
    max-width: 100%; height: auto; display: block; /* from huffman.html */
}


.result-section-base {
    padding: 1rem; border: 1px solid #e5e7eb; border-radius: 0.375rem;
    background-color: #f9fafb; margin-bottom: 0.75rem;
    line-height: 1.7;
}

.result-section-base table,
.detail-box table,
#huffmanFreqTableContainer table /* huffman.html */
{
    width: 100%;
    border-collapse: collapse;
    margin-top: 0.5rem;
    font-size: 0.875rem;
}
.result-section-base th,
.result-section-base td,
.detail-box th,
.detail-box td,
#huffmanFreqTableContainer th, /* huffman.html */
#huffmanFreqTableContainer td /* huffman.html */
{
    border: 1px solid #e2e8f0;
    padding: 8px;
    text-align: left;
    vertical-align: top;
}
#huffmanFreqTableContainer th, /* huffman.html specific alignment */
#huffmanFreqTableContainer td {
    padding-left: 0.5rem; /* px-2 */
    padding-right: 0.5rem; /* px-2 */
    padding-top: 0.25rem; /* py-1 */
    padding-bottom: 0.25rem; /* py-1 */
}
#huffmanFreqTableContainer th.text-right, /* huffman.html specific alignment */
#huffmanFreqTableContainer td.text-right {
    text-align: right;
}
.result-section-base th,
.detail-box th,
#huffmanFreqTableContainer thead /* huffman.html */
{
    background-color: #f1f5f9;
    font-weight: 600;
}


#statsArea h4,
#entropyResultsArea h4,
#resultsArea h4,
.sim-section h3,
#theorySectionDisplay h3,
.content-section h2 /* Generic section title for huffman/hamming */
{
    font-weight: 600; margin-top: 1.25rem; margin-bottom: 0.75rem; font-size: 1.125rem; color: #1d4ed8;
}
.content-section h2 { /* Override for huffman/hamming main titles */
    font-size: 1.25rem; /* text-xl */
    color: #374151; /* text-gray-700 */
    margin-bottom: 0.5rem; /* mb-2 */
}

#statsArea p,
#entropyResultsArea p,
#resultsArea p,
.sim-section p,
#theorySectionDisplay p
{
    margin-bottom: 0.6rem; color: #4B5563;
    line-height: 1.6;
}
#theorySectionDisplay ul {
    list-style-position: inside;
    list-style-type: disc;
    margin-left: 1rem;
    font-size: 0.875rem;
}


#statsArea ul { list-style-position: inside; }
#statsArea li { margin-bottom: 1rem; padding-left:0.5rem; border-left: 3px solid transparent;}
#statsArea li ul { margin-left: 1.25rem; margin-top: 0.25rem;}
#statsArea li ul li { font-size: 0.9375rem; margin-bottom: 0.25rem; border-left: none; padding-left: 0;}

#resultsArea ul { list-style-position: inside; margin-left: 0.5rem;}
#resultsArea li { margin-bottom: 0.25rem; }

.error-message { color: #DC2626; font-weight: bold; margin-bottom: 1rem; padding: 0.75rem; border: 1px solid #FCA5A5; background-color: #FEF2F2; border-radius: 0.375rem;}
.warning-message { color: #D97706; font-weight: bold; margin-bottom: 1rem; padding: 0.75rem; border: 1px solid #FCD34D; background-color: #FFFBEB; border-radius: 0.375rem;}
.success-message { color: #065F46; font-weight: bold; margin-bottom: 1rem; padding: 0.75rem; border: 1px solid #6EE7B7; background-color: #F0FDFA; border-radius: 0.375rem;}
.info-message { color: #1D4ED8; font-weight: bold; margin-bottom: 1rem; padding: 0.75rem; border: 1px solid #93C5FD; background-color: #EFF6FF; border-radius: 0.375rem;}

.katex { font-size: 1.1em; }
.katex-display { margin: 0.75em 0; }


.sim-section {
    background-color: white;
    padding: 1.5rem;
    border-radius: 0.75rem;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    margin-bottom: 1.5rem;
    position: relative;
}
.sim-section h2 {
    font-size: 1.5rem;
    font-weight: 600;
    color: #1e3a8a;
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid #93c5fd;
}

.bit-stream,
.bit-stream-display
{
    font-family: 'Menlo', 'Monaco', 'Courier New', monospace;
    word-break: break-all;
    background-color: #eef2ff;
    padding: 0.75rem;
    border-radius: 0.375rem;
    border: 1px solid #c7d2fe;
    max-height: 200px;
    overflow-y: auto;
    font-size: 0.8rem;
    line-height: 1.6;
}
.bit-stream-blocks,
.bit-block-container
{
    display: flex;
    flex-wrap: wrap;
    font-family: 'Menlo', 'Monaco', 'Courier New', monospace;
    gap: 6px;
    padding: 0.5rem 0;
    font-size: 0.75rem;
}
.bit-block {
    background-color: #e0e7ff;
    color: #3730a3;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 0.875rem;
    display: inline-block;
}
.bit-block.data-bit {
    background-color: #dbeafe;
    color: #1e40af;
}

.error-bit {
    color: #ef4444;
    font-weight: bold;
    text-decoration: underline;
    background-color: #fee2e2;
    padding: 0 1px;
    border-radius: 2px;
}
.corrected-bit {
    color: #16a34a;
    font-weight: bold;
    border: 1px solid #16a34a;
    background-color: #dcfce7;
    padding: 0 1px;
    border-radius: 2px;
}
.detail-box {
    background-color: #f8fafc;
    border: 1px solid #e2e8f0;
    padding: 0.75rem;
    border-radius: 0.375rem;
    margin-top: 0.5rem;
    font-size: 0.875rem;
}
pre {
    white-space: pre-wrap;
    word-wrap: break-word;
    background-color: #f3f4f6;
    padding: 0.5rem;
    border-radius: 0.25rem;
    font-size: 0.8rem;
}

#step-transmission-noise.has-arrow::before {
    content: '';
    position: absolute;
    left: 15px;
    top: 5%;
    bottom: 5%;
    width: 30px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='%23777777'%3E%3Cpath d='M12 20l-7-8h5V4h4v8h5l-7 8z'/%3E%3C/svg%3E");
    background-repeat: repeat-y;
    background-position: center top;
    background-size: 30px 30px;
    opacity: 0.5;
    z-index: 0;
}
#step-transmission-noise .transmission-content {
    margin-left: 55px;
}

.quiz-container {
    margin-top: 1.5rem;
    padding-top: 1rem;
    border-top: 1px dashed #ccc;
}
.quiz-question {
    font-weight: 600;
    margin-bottom: 0.75rem;
}
.quiz-choices button {
    background-color: #e9e9ed;
    color: #333;
    border: 1px solid #caced3;
    padding: 0.5rem 1rem;
    margin: 0.25rem;
    border-radius: 0.375rem;
    cursor: pointer;
    transition: background-color 0.2s;
}
.quiz-choices button:hover {
    background-color: #d1d1d6;
}
.quiz-choices button:disabled {
    background-color: #f3f4f6;
    color: #9ca3af;
    cursor: not-allowed;
}
#executeStepButton {
    margin-top: 1rem;
    background-color: #2563eb;
    color: white;
    font-weight: 600;
    padding: 0.5rem 1.5rem;
    border-radius: 0.375rem;
    box-shadow: 0 1px 2px 0 rgba(0,0,0,0.05);
}
#executeStepButton:hover {
    background-color: #1d4ed8;
}
 #executeStepButton:disabled {
    background-color: #9ca3af;
    cursor: not-allowed;
}
.reset-button-final-area {
    margin-top: 1.5rem;
    padding-top: 1rem;
    border-top: 1px dashed #ccc;
    text-align: center;
}

.value-display { font-weight: bold; color: #1d4ed8; }
.status-success { color: #16a34a; font-weight: bold; }
.status-failure { color: #dc2626; font-weight: bold; }
.warning-text { color: #f59e0b; }

#theoryChartContainer {
    margin-top: 1.5rem;
    padding: 1rem;
    background-color: #f9fafb;
    border-radius: 0.5rem;
    border: 1px solid #e5e7eb;
    min-height: 350px;
}
#sliderCalculations p { margin-bottom: 0.25rem; }
input[type="range"] {
    width: 100%;
    cursor: pointer;
}

/* Huffman specific styles from huffman-hamming.html */
.huffman-result-display-area {
    font-family: 'Menlo', 'Monaco', 'Courier New', monospace;
    line-height: 1.6;
}
.huffman-result-section { /* This might need to be distinct from .result-section-base if padding/margin differs */
    white-space: pre-wrap;
    word-wrap: break-word;
    padding: 0.5rem;
    border: 1px solid #e5e7eb;
    border-radius: 0.375rem;
    background-color: #f9fafb;
    margin-bottom: 0.75rem;
}
.huffman-result-section.scrollable {
    max-height: 150px;
    overflow-y: auto;
}
.huffman-result-section span.char-segment,
.huffman-result-section span.code-segment {
    color: white;
    padding: 1px 3px;
    border-radius: 3px;
    margin-right: 1px;
}
.huffman-result-section span.code-segment {
    margin-right: 4px;
}
.tooltip { /* Huffman tooltip */
    position: absolute; background-color: rgba(0,0,0,0.75); color: white;
    padding: 5px 10px; border-radius: 4px; font-size: 0.875rem;
    pointer-events: none; white-space: pre-wrap; z-index: 1000;
    opacity: 0; transition: opacity 0.2s;
}


/* Hamming specific styles from huffman-hamming.html */
.bit-square {
    width: 28px; height: 28px; display: flex; align-items: center; justify-content: center;
    border: 1px solid #ccc; margin: 1px; font-weight: bold; border-radius: 4px;
    font-size: 0.8rem;
}
.bit-label-square {
    width: 28px; height: 20px; display: flex; align-items: center; justify-content: center;
    margin: 1px; font-weight: normal; border-radius: 4px;
    font-size: 0.75rem; color: #4A5568; /* Tailwind: text-gray-600 */
}
.bit-1 { background-color: white; color: black; }
.bit-0 { background-color: black; color: white; }
.highlight-error { border: 3px solid red !important; }
.highlight-corrected { border: 3px solid green !important; }
.highlight-data { border: 3px solid blue !important; }

/* Main page tabs (Overview, Info, Entropy, etc.) are handled by .tab-button */
/* Sub-tabs for Huffman/Hamming page itself */
.page-sub-nav { /* Container for Huffman/Hamming tabs */
    margin-bottom: 1rem; /* mb-4 */
    border-bottom: 1px solid #d1d5db; /* border-b border-gray-300 */
}
.page-sub-nav nav { /* The flex container for tab buttons */
    display: flex;
    gap: 0.25rem; /* space-x-1 */
    margin-bottom: -1px; /* -mb-px */
}
.page-sub-tab { /* Individual Huffman/Hamming tab buttons */
    color: #6b7280; /* text-gray-500 */
    /* hover:text-gray-700 hover:border-gray-300 */
    white-space: nowrap;
    padding-top: 0.75rem;    /* py-3 */
    padding-bottom: 0.75rem; /* py-3 */
    padding-left: 1rem;      /* px-4 */
    padding-right: 1rem;     /* px-4 */
    border-bottom-width: 2px;
    border-color: transparent; /* Default */
    font-weight: 500;        /* font-medium */
    font-size: 0.875rem;     /* text-sm */
    border-top-left-radius: 0.375rem;  /* rounded-t-md */
    border-top-right-radius: 0.375rem; /* rounded-t-md */
    cursor: pointer;
}
.page-sub-tab:hover {
    color: #374151; /* hover:text-gray-700 */
    border-color: #d1d5db; /* hover:border-gray-300 */
}

/* Hamming inner display tabs (Visualization / Matrix) */
.hamming-inner-nav { /* Container for Vis/Mat tabs */
    margin-bottom: 1rem; /* mb-4 */
    border-bottom: 1px solid #e5e7eb; /* border-b border-gray-200 */
}
.hamming-inner-nav nav {
    display: flex;
    gap: 0.25rem; /* space-x-1 */
    margin-bottom: -1px; /* -mb-px */
}
.hamming-display-tab { /* Individual Vis/Mat tab buttons */
    white-space: nowrap;
    padding-bottom: 0.5rem; /* pb-2 */
    padding-left: 0.75rem;  /* px-3 */
    padding-right: 0.75rem; /* px-3 */
    border-bottom-width: 2px;
    border-color: transparent; /* Default */
    font-weight: 500; /* font-medium */
    font-size: 0.875rem; /* text-sm */
    cursor: pointer;
    color: #6b7280; /* Default text color */
}
.hamming-display-tab:hover {
    color: #374151; /* Default hover text color */
    border-color: #d1d5db; /* Default hover border color */
}

/* Content area for each main tab (Huffman/Hamming) */
.main-tab-content { display: none; }
.main-tab-content.active { display: block; }

/* Content area for Hamming inner tabs */
.hamming-display-tab-content { display: none; }
.hamming-display-tab-content.active { display: block; }

.bsc-layout {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1.5rem;
    margin: 1rem 0;
    flex-wrap: wrap; /* スマホでも縦並びに対応 */
}

.bsc-text {
    flex: 1;
    min-width: 250px;
    font-size: 0.95rem;
    line-height: 1.6;
    color: #374151;
}

.bsc-image {
    flex: 0 0 auto;
    text-align: center;
}

.bsc-image img {
    max-width: 100%;
    height: auto;
    border: 1px solid #d1d5db;
    border-radius: 0.5rem;
    background-color: #fff;
    padding: 0.5rem;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}
/* 説明文ブロック内のリンクスタイル */
.description-block .introduction-text a {
    color: #2563eb; /* 青色 (Tailwind blue-600) */
    text-decoration: underline; /* 下線を追加 */
    transition: color 0.2s; /* 色の変化を滑らかに */
}

.description-block .introduction-text a:hover {
    color: #1d4ed8; /* 少し濃い青色 (Tailwind blue-700) */
}