@font-face { font-family: "Titillium Web"; src: url("fonts/TitilliumWeb-Regular.ttf") format("truetype"); font-weight: 400; font-style: normal; }
@font-face { font-family: "Titillium Web"; src: url("fonts/TitilliumWeb-SemiBold.ttf") format("truetype"); font-weight: 600; font-style: normal; }
@font-face { font-family: "Titillium Web"; src: url("fonts/TitilliumWeb-Bold.ttf") format("truetype"); font-weight: 700; font-style: normal; }
@font-face { font-family: "Titillium Web"; src: url("fonts/TitilliumWeb-Italic.ttf") format("truetype"); font-weight: 400; font-style: italic; }

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 15px; }
body { font-family: "Titillium Web", "Segoe UI", sans-serif; background: #f4f5f7; color: #1a1a1a; min-height: 100vh; display: flex; flex-direction: column; }

#topbar { display: flex; align-items: center; gap: 1.2rem; padding: 0.5rem 1.2rem; background: #003C71; color: #fff; }
#topbar h1 { font-size: 1.1rem; font-weight: 700; letter-spacing: 0.01em; white-space: nowrap; }
#tab-bar { display: flex; gap: 0; margin-left: 1.5rem; }
.tab-btn { background: rgba(255,255,255,0.12); color: rgba(255,255,255,0.75); border: none; padding: 0.4rem 1.2rem; font-family: inherit; font-size: 0.82rem; font-weight: 600; cursor: pointer; border-radius: 4px 4px 0 0; transition: background 0.15s, color 0.15s; }
.tab-btn:hover { background: rgba(255,255,255,0.2); color: #fff; }
.tab-btn.active { background: #f4f5f7; color: #003C71; }
#corpus-stats { font-size: 0.75rem; color: rgba(255,255,255,0.7); display: flex; gap: 0.6rem; margin-left: auto; flex-wrap: wrap; }
.stat-item { background: rgba(255,255,255,0.12); padding: 2px 8px; border-radius: 3px; }

.view { display: none; flex: 1; overflow: hidden; }
.view.active { display: flex; }

#view-corpus { flex: 1; overflow: hidden; }
#sidebar { width: 340px; min-width: 280px; max-width: 420px; overflow-y: auto; background: #fff; border-right: 1px solid #d0d0d0; display: flex; flex-direction: column; }
#viewer { flex: 1; display: flex; flex-direction: column; overflow: hidden; background: #f4f5f7; }

#filters { padding: 0.6rem; border-bottom: 1px solid #e0e0e0; }
#filters h2 { font-size: 0.82rem; margin-bottom: 0.4rem; color: #003C71; font-weight: 600; }
#filters label { display: block; font-size: 0.78rem; color: #555; margin-bottom: 0.3rem; }
#filters select { width: 100%; background: #fff; color: #1a1a1a; border: 1px solid #bbb; border-radius: 3px; padding: 3px 6px; font-size: 0.78rem; }
#btn-filter { margin-top: 0.5rem; width: 100%; padding: 5px; background: #003C71; color: #fff; border: none; border-radius: 3px; cursor: pointer; font-size: 0.78rem; font-weight: 600; }
#btn-filter:hover { background: #002a52; }

.multi-select { position: relative; }
.multi-select-toggle { width: 100%; background: #fff; color: #1a1a1a; border: 1px solid #bbb; border-radius: 3px; padding: 3px 6px; font-size: 0.78rem; text-align: left; cursor: pointer; display: flex; justify-content: space-between; align-items: center; font-family: inherit; }
.multi-select-toggle::after { content: "\25BC"; font-size: 0.6rem; color: #888; }
.multi-options { display: none; position: absolute; top: 100%; left: 0; right: 0; max-height: 220px; overflow-y: auto; background: #fff; border: 1px solid #bbb; border-top: none; border-radius: 0 0 3px 3px; z-index: 100; box-shadow: 0 4px 12px rgba(0,0,0,0.1); }
.multi-options.open { display: block; }
.multi-options label { display: flex; align-items: center; gap: 5px; padding: 3px 8px; font-size: 0.76rem; cursor: pointer; }
.multi-options label:hover { background: #eef1f5; }
.multi-options input[type="checkbox"] { accent-color: #003C71; }

#det-list-section { flex: 1; overflow-y: auto; padding: 0.4rem; border-bottom: 1px solid #e0e0e0; }
#det-list-section h2 { font-size: 0.82rem; color: #003C71; margin-bottom: 0.3rem; font-weight: 600; }
#det-count { font-size: 0.75rem; color: #888; }
#det-list { list-style: none; }
#det-list li { padding: 5px 8px; border-radius: 3px; cursor: pointer; font-size: 0.78rem; line-height: 1.4; margin-bottom: 2px; border-left: 3px solid transparent; }
#det-list li:hover { background: #eef1f5; }
#det-list li.active { background: #dce5ef; border-left-color: #003C71; }
#det-list li .det-marker { color: #8b2252; font-weight: 600; }
#det-list li .det-source { color: #888; font-size: 0.72rem; display: block; }
#det-list li .det-ctx { color: #666; font-size: 0.7rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: block; max-width: 100%; }

#det-pagination { display: flex; align-items: center; justify-content: space-between; padding: 0.3rem 0.4rem; }
#det-pagination button { background: #eef1f5; border: 1px solid #ccc; color: #333; padding: 3px 10px; border-radius: 3px; cursor: pointer; font-size: 0.75rem; }
#det-pagination button:disabled { opacity: 0.35; cursor: default; }
#page-info { font-size: 0.72rem; color: #888; }

#source-details { padding: 0.4rem; }
#source-details summary { font-size: 0.82rem; color: #003C71; cursor: pointer; font-weight: 600; }
#source-list { list-style: none; max-height: 200px; overflow-y: auto; margin-top: 0.3rem; }
#source-list li { padding: 3px 6px; font-size: 0.75rem; cursor: pointer; border-radius: 3px; display: flex; justify-content: space-between; }
#source-list li:hover { background: #eef1f5; }
#source-list li .src-chars { color: #888; font-size: 0.68rem; }

#viewer-header { padding: 0.5rem 1rem; border-bottom: 1px solid #d0d0d0; background: #fff; display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 0.5rem; }
#viewer-title { font-size: 0.9rem; font-weight: 600; flex: 1; color: #1a1a1a; }
#viewer-nav { display: flex; align-items: center; gap: 0.4rem; }
#viewer-nav button { background: #eef1f5; border: 1px solid #ccc; color: #333; padding: 3px 10px; border-radius: 3px; cursor: pointer; font-size: 0.78rem; }
#viewer-nav button:disabled { opacity: 0.35; cursor: default; }
#nav-info { font-size: 0.75rem; color: #888; min-width: 60px; text-align: center; }
#layer-toggles { display: flex; gap: 0.7rem; font-size: 0.78rem; color: #444; }
#layer-toggles label { display: flex; align-items: center; gap: 3px; cursor: pointer; }
.swatch { display: inline-block; width: 10px; height: 10px; border-radius: 2px; }
.swatch-x { background: #a8c8e8; }
.swatch-y { background: #a8dcc0; }
.swatch-m { background: #dda8c0; }

.expand-bar { text-align: center; padding: 2px; }
.expand-bar button { background: #eef1f5; border: 1px solid #ccc; color: #666; padding: 2px 18px; border-radius: 3px; cursor: pointer; font-size: 0.72rem; }
.expand-bar button:disabled { opacity: 0.35; cursor: default; }

#text-viewport { flex: 0 1 auto; max-height: 55vh; overflow-y: auto; padding: 1.2rem 2rem; font-family: "Georgia", "Times New Roman", "Palatino Linotype", serif; font-size: 0.95rem; line-height: 1.75; white-space: pre-wrap; word-break: break-word; background: #fff; border: 1px solid #ddd; margin: 0.5rem 1rem; border-radius: 3px; }

.hl-x { background: #d0e4f7; border-radius: 2px; }
.hl-y { background: #c8edda; border-radius: 2px; }
.hl-marker { background: #f0cedd; border-radius: 2px; font-weight: 600; }

body.layer-x-off .hl-x { background: none; }
body.layer-y-off .hl-y { background: none; }
body.layer-m-off .hl-marker { background: none; font-weight: normal; }

.hl-active { outline: 2px solid #003C71; outline-offset: 1px; border-radius: 2px; }

.placeholder { color: #888; text-align: center; padding: 3rem; font-size: 0.88rem; }

#det-card { flex-shrink: 0; padding: 0.6rem 1rem; border-top: 1px solid #d0d0d0; background: #fafafa; overflow-y: auto; max-height: 35vh; }
#det-card.hidden { display: none; }
#det-card h3 { font-size: 0.85rem; color: #003C71; margin-bottom: 0.3rem; font-weight: 600; }
#det-card-table { width: 100%; font-size: 0.75rem; border-collapse: collapse; }
#det-card-table td { padding: 2px 6px; vertical-align: top; color: #333; }
#det-card-table td:first-child { color: #777; white-space: nowrap; width: 110px; }

#review-section { margin-top: 0.4rem; }
#review-section h4 { font-size: 0.78rem; color: #555; margin-bottom: 0.2rem; font-weight: 600; }
#review-history { font-size: 0.72rem; color: #777; margin-bottom: 0.3rem; }
.review-badge { display: inline-block; padding: 1px 6px; border-radius: 3px; font-size: 0.7rem; font-weight: 600; }
.review-badge.confirmed { background: #d4edda; color: #155724; }
.review-badge.rejected { background: #f8d7da; color: #721c24; }
.review-badge.uncertain { background: #fff3cd; color: #856404; }
#review-form { display: flex; gap: 0.3rem; align-items: center; flex-wrap: wrap; }
#review-form select, #review-form input { background: #fff; color: #1a1a1a; border: 1px solid #bbb; border-radius: 3px; padding: 3px 6px; font-size: 0.75rem; font-family: inherit; }
#review-form input { flex: 1; min-width: 120px; }
#btn-review { background: #003C71; color: #fff; border: none; border-radius: 3px; padding: 4px 12px; cursor: pointer; font-size: 0.75rem; font-weight: 600; }
#btn-review:hover { background: #002a52; }

#view-libera { flex-direction: column; padding: 1.5rem 2.5rem; max-width: 960px; margin: 0 auto; width: 100%; gap: 1rem; }
#view-libera h2 { font-size: 1rem; color: #003C71; font-weight: 600; }
#view-libera p.subtitle { font-size: 0.82rem; color: #666; margin-bottom: 0.2rem; }
#paste-text { width: 100%; min-height: 140px; resize: vertical; background: #fff; color: #1a1a1a; border: 1px solid #bbb; border-radius: 3px; padding: 0.8rem; font-size: 0.9rem; font-family: "Georgia", "Times New Roman", serif; line-height: 1.65; }
#paste-text:focus { outline: 2px solid #003C71; outline-offset: -1px; border-color: #003C71; }
#paste-filter-row { display: flex; gap: 1.5rem; align-items: flex-end; flex-wrap: wrap; }
.paste-filter-group { display: flex; flex-direction: column; gap: 0.2rem; }
.paste-filter-group .multi-select { min-width: 220px; }
.paste-filter-label { font-size: 0.78rem; color: #555; font-weight: 600; }
.paste-channel-label { display: flex; align-items: center; gap: 4px; padding: 5px 0; color: #888; }
.paste-channel-label input[type="checkbox"] { accent-color: #003C71; }
#btn-paste-detect { padding: 8px 24px; background: #003C71; color: #fff; border: none; border-radius: 3px; cursor: pointer; font-size: 0.85rem; font-weight: 600; font-family: inherit; align-self: flex-start; }
#btn-paste-detect:hover { background: #002a52; }
#btn-paste-detect:disabled { opacity: 0.5; cursor: default; }
#paste-results { font-size: 0.82rem; color: #555; }
#paste-det-list { list-style: none; margin-top: 0.5rem; }
#paste-det-list li { padding: 6px 10px; border-left: 3px solid #003C71; background: #f8f9fb; margin-bottom: 4px; border-radius: 0 3px 3px 0; font-size: 0.8rem; }
#paste-det-list .pd-marker { color: #8b2252; font-weight: 600; }
#paste-det-list .pd-ctx { color: #555; font-size: 0.75rem; display: block; }
#paste-viewport { padding: 1.2rem 2rem; font-family: "Georgia", "Times New Roman", "Palatino Linotype", serif; font-size: 0.95rem; line-height: 1.75; white-space: pre-wrap; word-break: break-word; background: #fff; border: 1px solid #ddd; border-radius: 3px; display: none; }

#footer { padding: 0.5rem 1rem; background: #003C71; text-align: center; font-size: 0.72rem; color: rgba(255,255,255,0.65); }

::-webkit-scrollbar { width: 7px; }
::-webkit-scrollbar-track { background: #f0f0f0; }
::-webkit-scrollbar-thumb { background: #c0c0c0; border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: #a0a0a0; }
