:root{
  --bg: #ffffff;
  --fg: #111827;
  --muted: #6b7280;
  --card: #f8fafc;
  --border: #e5e7eb;
  --accent: #2563eb;
  --accent-fg:#ffffff;
  --danger:#b91c1c;
  --code:#111827;
  --mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  --radius:14px;
  --shadow: 0 10px 25px rgba(0,0,0,.06);
  /* 部分表示のバナーと、終端が見つからない印。以前は未定義で背景が透けていた */
  --warning-bg: #fff8e6;
  --warning-fg: #7a4f00;
}
:root.dark{
  --bg:#0f172a;
  --fg:#f1f5f9;
  --muted:#94a3b8;
  --card:#1e293b;
  --border:#334155;
  --accent:#3b82f6;
  --accent-fg:#ffffff;
  --danger:#ef4444;
  --code:#f8fafc;
  --shadow: 0 12px 28px rgba(0,0,0,.4);
  --warning-bg: #3a2c12;
  --warning-fg: #f0d9b5;
}
*{box-sizing:border-box}
html,body{height:100%}
body{
  margin:0; background:var(--bg); color:var(--fg); font:16px/1.55 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", "Apple Color Emoji","Segoe UI Emoji";
}

/* Header */
.app-header{
  position:sticky; top:0; z-index:10;
  background:var(--bg);
  border-bottom:1px solid var(--border);
  display:flex;
  flex-direction:column;
  align-items:center;
}
.app-header > div:first-child {
  display:flex; 
  align-items:center; 
  justify-content:center;
  padding:14px 18px;
  width:100%;
  position: relative;
}
.brand{display:flex; align-items:center; gap:12px}
.logo{width:36px; height:36px; object-fit:contain}
.titles h1{margin:0; font-size:18px}
.subtitle{margin:2px 0 0; color:var(--muted); font-size:13px}
.header-actions{
  display:flex; 
  gap:10px; 
  align-items:center;
  position: absolute;
  right: 18px;
  top: 50%;
  transform: translateY(-50%);
}
.btn{
  border:1px solid var(--border); 
  background:var(--card); 
  color:var(--fg);
  padding:10px 14px; 
  border-radius:10px; 
  cursor:pointer; 
  box-shadow:var(--shadow);
  font-size:14px;
  font-weight:500;
  transition:all 0.2s ease;
}
.btn:hover:not(:disabled){
  transform:translateY(-1px);
  box-shadow:0 12px 28px rgba(0,0,0,0.12);
}
.btn:active:not(:disabled){
  transform:translateY(0);
}
.btn.primary{
  background:var(--accent); 
  color:var(--accent-fg); 
  border-color:transparent;
}
.btn.primary:hover:not(:disabled){
  background:color-mix(in srgb, var(--accent) 90%, black);
}
.btn.danger{
  background:transparent; 
  color:var(--danger); 
  border-color:var(--danger);
}
.btn.danger:hover:not(:disabled){
  background:var(--danger);
  color:white;
}
.btn:disabled{
  opacity:.6; 
  cursor:not-allowed;
}
.btn.btn-sm{
  padding:6px 10px;
  font-size:13px;
}

/* Badge */
.badge{
  display:inline-block;
  padding:2px 8px;
  border-radius:6px;
  font-size:12px;
  font-weight:500;
  background:rgba(59,130,246,0.15);
  color:var(--accent);
}
:root.dark .badge{
  background:rgba(59,130,246,0.2);
  color:#93c5fd;
}

/* Checkbox styling */
input[type="checkbox"] {
  width:16px;
  height:16px;
  cursor:pointer;
  accent-color:var(--accent);
}
input[type="checkbox"]:hover {
  transform:scale(1.1);
}
.icon-btn{background:transparent; border:0; cursor:pointer; color:var(--fg); font-size:16px}

.theme-toggle{display:flex; align-items:center; gap:6px; cursor:pointer}
.toggle-ui{display:inline-block; width:40px; height:24px; background:var(--border); border-radius:999px; position:relative}
.theme-toggle input{display:none}
.theme-toggle input:checked + .toggle-ui::after{left:20px}
.toggle-ui::after{
  content:""; position:absolute; top:3px; left:3px; width:18px; height:18px; border-radius:50%;
  background:var(--bg); box-shadow:0 2px 6px rgba(0,0,0,.25);
}
.toggle-text{font-size:12px; color:var(--muted)}

/* Layout */
.layout{
  display:flex;
  flex-direction:column;
  gap:0;
  padding:20px 40px;
  margin:0 auto;
}
.left-pane{
  background:var(--card); border:1px solid var(--border); border-radius:var(--radius); padding:18px; box-shadow:var(--shadow);
  min-height:72vh; display:flex; flex-direction:column; gap:14px;
}
.pane-head{
  display:flex; 
  flex-direction:column; 
  gap:12px;
  margin-bottom:8px;
}
.pane-head h2{
  margin:0;
  font-size:18px;
  font-weight:600;
}
.filters{
  display:flex; 
  gap:10px; 
  align-items:center;
  flex-wrap:wrap;
}
.filters input[type="search"]{
  flex:1;
  min-width:200px;
  padding:10px 12px;
  border:1px solid var(--border);
  border-radius:10px;
  background:var(--bg);
  color:var(--fg);
  font-size:14px;
}
.filters input[type="search"]:focus{
  outline:none;
  border-color:var(--accent);
  box-shadow:0 0 0 3px rgba(37,99,235,0.1);
}
.filters select{
  padding:8px 12px;
  border:1px solid var(--border);
  border-radius:10px;
  background:var(--bg);
  color:var(--fg);
  font-size:14px;
  cursor:pointer;
}
.filters select:focus{
  outline:none;
  border-color:var(--accent);
}
.inline{display:inline-flex; gap:6px; align-items:center}

.sig-table-wrap{
  overflow:auto; 
  border:1px solid var(--border); 
  border-radius:12px; 
  background:var(--bg);
  height:550px;
}
.sig-table{
  width:100%; 
  border-collapse:separate;
  border-spacing:0;
  font-size:14px;
}
.sig-table thead th{
  position:sticky; 
  top:0; 
  background:var(--card); 
  color:var(--muted); 
  text-align:left; 
  padding:12px 10px;
  border-bottom:2px solid var(--border);
  font-weight:600;
  font-size:12px;
  text-transform:uppercase;
  letter-spacing:0.5px;
  z-index:1;
}
.sig-table tbody td{
  padding:10px;
  border-bottom:1px solid var(--border);
  vertical-align:middle;
}
.sig-table tbody tr:hover{
  background:rgba(37,99,235,0.04);
}
.sig-table tbody tr[data-id]:hover{
  cursor:pointer;
}
.sig-table tbody tr.selected{
  background:rgba(37,99,235,0.08);
}
.sig-table tbody td.name{
  font-weight:500;
}
.sig-table tbody td code{
  font-family:var(--mono);
  font-size:12px;
  background:rgba(0,0,0,0.05);
  padding:2px 6px;
  border-radius:4px;
}
:root.dark .sig-table tbody td code{
  background:rgba(255,255,255,0.1);
  color:var(--code);
}
.sig-actions{
  display:flex; 
  gap:10px; 
  margin-top:12px;
  padding-top:12px;
  border-top:1px solid var(--border);
}
.sig-actions .btn{
  flex:1;
  font-size:14px;
}

/* Main Navigation Tabs */
.main-tabs{
  display:flex;
  gap:0;
  background:var(--bg);
  padding:0 20px;
  overflow-x:auto;
  scrollbar-width:none;
  justify-content:center;
  width:100%;
}
.main-tabs::-webkit-scrollbar{
  display:none;
}
.main-tab{
  padding:12px 20px;
  border:0;
  background:transparent;
  color:var(--muted);
  cursor:pointer;
  font-weight:500;
  font-size:14px;
  transition:all 0.2s ease;
  border-bottom:3px solid transparent;
  white-space:nowrap;
}
.main-tab:hover{
  background:rgba(59,130,246,0.08);
  color:var(--fg);
}
:root.dark .main-tab:hover{
  background:rgba(59,130,246,0.15);
}
.main-tab.active{
  color:var(--accent);
  border-bottom-color:var(--accent);
  background:rgba(59,130,246,0.05);
}
:root.dark .main-tab.active{
  background:rgba(59,130,246,0.12);
  color:#93c5fd;
}

/* Content Area */
.tab-panels{
  background:var(--card);
  border:1px solid var(--border);
  border-radius:var(--radius);
  box-shadow:var(--shadow);
  margin-top:20px;
}
.tab-panel{
  display:none;
  padding:32px;
  min-height:600px;
}
.tab-panel.active{
  display:block;
}

.drop-area{
  min-height:280px;
  display:flex;
  flex-direction:column;
  align-items:center;
  justify-content:center;
  border:2px dashed var(--border);
  border-radius:16px;
  padding:32px;
  background:var(--card);
  cursor:pointer;
  transition:all .3s ease;
  position: relative;
}
.drop-area:hover{
  border-color:var(--accent);
  background:rgba(37,99,235,.04);
}
.drop-area.drag{
  border-color:var(--accent);
  background:rgba(37,99,235,.08);
  transform: scale(1.02);
}
.drop-area:focus{outline:2px solid var(--accent)}
.drop-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  text-align: center;
}
.drop-icon {
  color: var(--muted);
  opacity: 0.5;
  transition: all 0.3s ease;
}
.drop-area:hover .drop-icon {
  color: var(--accent);
  opacity: 0.8;
}
.drop-title{
  font-size:18px;
  font-weight:600;
  margin:0;
  color: var(--fg);
}
.drop-or {
  font-size: 14px;
  color: var(--muted);
  margin: 0;
}
.drop-area .btn {
  margin: 0;
}
.muted{color:var(--muted)} .small{font-size:12px}

.inspect-controls{display:flex; gap:10px; align-items:center; margin:12px 0}
/* Legacy progress styles - keeping for compatibility but overridden by enhanced styles below */

.inspect-grid{
  display:grid; 
  grid-template-columns: 1fr 1.4fr; 
  gap:24px;
  margin-top:16px;
}
@media (max-width: 1200px) {
  .inspect-grid {
    grid-template-columns: 1fr;
    gap: 16px;
  }
}
.hits, .hex{
  background:var(--bg); border:1px solid var(--border); border-radius:12px; padding:12px; overflow:auto;
}
.hits-table{width:100%; border-collapse:collapse; font-size:13px}
.hits-table thead th{position:sticky; top:0; background:var(--card); color:var(--muted); text-align:left; padding:8px; border-bottom:1px solid var(--border)}
.hits-table tbody td{padding:8px; border-top:1px solid var(--border)}
.hits-table tbody tr{
  cursor:pointer;
  transition:background-color 0.2s ease;
}
.hits-table tbody tr:hover{
  background:rgba(37,99,235,0.06);
}
.hits-table tbody tr.selected{
  background:rgba(37,99,235,0.12);
  border-left:3px solid var(--accent);
}
.hits-table tbody tr.selected:hover{
  background:rgba(37,99,235,0.16);
}
:root.dark .hits-table tbody tr:hover{
  background:rgba(59,130,246,0.15);
}
:root.dark .hits-table tbody tr.selected{
  background:rgba(59,130,246,0.2);
  border-left:3px solid #93c5fd;
}
:root.dark .hits-table tbody tr.selected:hover{
  background:rgba(59,130,246,0.25);
}

/* Hit note styling */
.hit-note {
  font-size: 12px;
  color: var(--muted);
  font-style: italic;
  max-width: 180px;
  word-wrap: break-word;
  line-height: 1.3;
}

/* Form tooltips and labels */
.sig-form label[title]::after {
  content: '';
  margin-left: 4px;
}

.checkbox-label {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  padding: 8px 0;
}

.checkbox-label input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: var(--accent);
  cursor: pointer;
}

.checkbox-text {
  font-weight: 500;
  color: var(--fg);
  user-select: none;
}

/* Tab description styling */
.tab-description {
  background: var(--card);
  padding: 12px 16px;
  border-radius: 8px;
  border-left: 3px solid var(--accent);
  margin: 0 0 20px 0;
  font-size: 14px;
  line-height: 1.5;
  color: var(--muted);
}

.hex-toolbar{display:flex; gap:8px; align-items:center; margin-bottom:8px}
.hex-toolbar .grow{flex:1}
.hexview{
  font-family:var(--mono); 
  font-size:13px;
  border:1px solid var(--border); 
  border-radius:12px; 
  padding:12px; 
  height:450px; 
  overflow:auto; 
  background:var(--bg); 
  color:var(--code);
  line-height:1.4;
}

.hex-row{
  display:flex;
  padding:4px 0;
  border-bottom:1px solid rgba(0,0,0,0.05);
  font-family:var(--mono);
}

:root.dark .hex-row{
  border-bottom:1px solid rgba(255,255,255,0.08);
}

.hex-off{
  width:88px;
  color:var(--muted);
  font-weight:500;
  flex-shrink:0;
  padding-right:16px;
}

.hex-data{
  min-width:550px;
  flex:1;
  padding-right:16px;
  word-spacing:2px;
}

.hex-ascii{
  width:200px;
  flex-shrink:0;
  color:var(--muted);
}
.hex-row .hi{
  background:rgba(34,197,94,.25); 
  border-radius:3px; 
  padding:1px 2px;
  color:var(--code);
  font-weight:600;
  box-shadow:0 0 0 1px rgba(34,197,94,.4);
  position:relative;
}

.hex-row .hi::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 3px;
  height: 100%;
  background: rgba(34,197,94,.7);
  border-radius: 1px 0 0 1px;
}

:root.dark .hex-row .hi{
  background:rgba(34,197,94,.35);
  color:#ffffff;
  font-weight:600;
  box-shadow:0 0 0 1px rgba(34,197,94,.6);
  position:relative;
}

:root.dark .hex-row .hi::before {
  background: rgba(34,197,94,.8);
}

.sig-form .form-grid{
  display:grid; 
  grid-template-columns: repeat(2, minmax(0,1fr)); 
  gap:16px;
}
@media (max-width: 900px) {
  .sig-form .form-grid {
    grid-template-columns: 1fr;
  }
}
.sig-form .form-grid .span-2{grid-column: span 2}
.sig-form input, .sig-form select, .sig-form textarea{
  width:100%; padding:8px 10px; border:1px solid var(--border); border-radius:10px; background:var(--bg); color:var(--fg)
}
.form-actions{display:flex; gap:8px; margin-top:8px}
.preview-box{margin-top:12px; background:var(--bg); border:1px solid var(--border); border-radius:12px; padding:10px}

.dictio-grid, .settings-grid{
  display:grid; 
  grid-template-columns: repeat(3, minmax(0,1fr)); 
  gap:20px;
}
@media (max-width: 1000px) {
  .dictio-grid, .settings-grid {
    grid-template-columns: 1fr;
  }
}
.box{background:var(--bg); border:1px solid var(--border); border-radius:12px; padding:12px}

/* Dictionary I/O Export Actions */
.export-actions {
  margin-top: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* Settings box layout - vertical alignment for better spacing usage */
.settings-grid .box .inline {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 6px;
  margin-bottom: 12px;
}

.settings-grid .box .inline:last-child {
  margin-bottom: 0;
}

/* Settings specific layouts */
.setting-select {
  flex-direction: row !important;
  justify-content: flex-start;
  align-items: center !important;
  gap: 12px;
}

.setting-select span {
  font-weight: 500;
}

.setting-checkbox {
  flex-direction: row !important;
  align-items: center !important;
  gap: 8px !important;
}

.setting-checkbox input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: var(--accent);
  cursor: pointer;
}

.setting-checkbox span {
  font-weight: 500;
  cursor: pointer;
  user-select: none;
}

/* Keyboard shortcuts 2-column layout */
.keyboard-shortcuts-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  margin-top: 8px;
}

.shortcuts-column h5 {
  margin: 0 0 8px 0;
  font-size: 14px;
  font-weight: 600;
  color: var(--fg);
  border-bottom: 1px solid var(--border);
  padding-bottom: 4px;
}

.shortcuts-column .kbd-list {
  margin: 0;
  padding: 0;
}

/* Mobile responsive: stack shortcuts vertically */
@media (max-width: 768px) {
  .keyboard-shortcuts-grid {
    grid-template-columns: 1fr;
    gap: 16px;
  }
}

/* Settings content in accordion */
.settings-content {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.settings-content .inline {
  margin-bottom: 0;
}

.kbd-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.kbd-list li {
  margin-bottom: 6px;
  padding: 0;
}

.kbd-list kbd{
  border:1px solid var(--border); background:var(--bg); padding:2px 6px; border-radius:6px; font-family:var(--mono)
}

/* Help Details Accordion */
.help-details{
  margin-top:20px;
  border:1px solid var(--border);
  border-radius:12px;
  overflow:hidden;
}
.help-details summary{
  padding:16px 20px;
  background:var(--card);
  cursor:pointer;
  font-weight:500;
  border-bottom:1px solid var(--border);
  user-select:none;
  transition:background-color 0.2s ease;
  list-style:none;
}
.help-details summary:hover{
  background:rgba(59,130,246,0.05);
}
:root.dark .help-details summary:hover{
  background:rgba(59,130,246,0.1);
}
.help-details[open] summary{
  background:rgba(59,130,246,0.08);
  color:var(--accent);
  border-bottom:none;
}
:root.dark .help-details[open] summary{
  background:rgba(59,130,246,0.15);
  color:#93c5fd;
}
.help-details summary::marker{
  display:none !important;
  content:"";
}
.help-details summary::-webkit-details-marker{
  display:none !important;
}
.help-details summary::-moz-list-bullet{
  display:none !important;
}
.help-details summary::before{
  content:"▶";
  display:inline-block;
  margin-right:8px;
  transition:transform 0.2s ease;
}
.help-details[open] summary::before{
  transform:rotate(90deg);
}
.help-content{
  padding:20px;
  background:var(--bg);
}
.help-content p{
  margin:0 0 12px 0;
  line-height:1.6;
}
.help-content p:last-of-type{
  margin-bottom:16px;
}
.info-box{
  background:rgba(59,130,246,0.05);
  border:1px solid rgba(59,130,246,0.15);
  border-radius:8px;
  padding:16px;
  margin-top:16px;
}
:root.dark .info-box{
  background:rgba(59,130,246,0.1);
  border:1px solid rgba(59,130,246,0.25);
}
.info-box h5{
  margin:0 0 12px 0;
  color:var(--accent);
  font-size:14px;
  font-weight:600;
}
:root.dark .info-box h5{
  color:#93c5fd;
}
.info-box ul{
  margin:0;
  padding-left:20px;
}
.info-box li{
  margin-bottom:6px;
  line-height:1.5;
}

/* ========================================
   Responsive Design - Mobile First Approach
   ======================================== */

/* Touch-friendly base styles */
@media (max-width: 1024px) {
  .btn {
    padding: 12px 16px;
    min-height: 44px;
    font-size: 15px;
  }
  .btn.btn-sm {
    padding: 8px 12px;
    min-height: 36px;
    font-size: 13px;
  }
  input, select, textarea {
    min-height: 44px;
    padding: 10px 12px;
    font-size: 16px; /* Prevents iOS zoom */
  }
}

/* Tablet optimizations */
@media (max-width: 1024px) {
  .layout {
    padding: 16px 20px;
  }
  .inspect-grid {
    grid-template-columns: 1fr;
    gap: 16px;
  }
  .hexview {
    height: 300px;
  }
}

/* Mobile optimizations */
@media (max-width: 768px) {
  body {
    font-size: 15px;
    line-height: 1.6;
  }
  
  /* Header mobile layout */
  .app-header > div:first-child {
    flex-direction: column;
    gap: 16px;
    padding: 16px;
    align-items: center;
    justify-content: center;
    position: static;
  }
  .brand {
    align-self: center;
  }
  .header-actions {
    position: static;
    transform: none;
    width: 100%;
    justify-content: center;
  }
  
  /* Mobile tab navigation */
  .main-tabs {
    padding: 0 8px;
    overflow-x: auto;
    scrollbar-width: none;
    -ms-overflow-style: none;
    justify-content: flex-start;
    gap: 4px;
  }
  .main-tabs::-webkit-scrollbar {
    display: none;
  }
  .main-tab {
    padding: 12px 16px;
    font-size: 14px;
    white-space: nowrap;
    flex-shrink: 0;
    min-width: auto;
  }
  
  /* Content area mobile */
  .layout {
    padding: 12px 16px;
  }
  .tab-panel {
    padding: 20px 16px;
  }
  
  /* Mobile filters */
  .filters {
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
  }
  .filters input[type="search"] {
    min-width: 100%;
    font-size: 16px;
  }
  .filters select {
    font-size: 16px;
  }
  
  /* Mobile form improvements */
  .sig-form .form-grid {
    grid-template-columns: 1fr;
    gap: 16px;
  }
  .sig-form .form-grid .span-2 {
    grid-column: span 1;
  }
  
  /* Mobile settings grid */
  .settings-grid, .dictio-grid {
    grid-template-columns: 1fr;
    gap: 16px;
  }
}

/* Footer */
footer{
  margin: 22px 0;
  display: flex;
  justify-content: center;
  align-items: center;
  width: 100%;
}
.footer{
  margin: 0 auto; 
  padding: 12px 16px; 
  border-top: 1px solid var(--border); 
  color: var(--muted); 
  text-align: center;
  width: 100%;
  box-sizing: border-box;
}

/* Footer links styling */
.footer a {
  color: var(--accent);
  text-decoration: underline;
  transition: color 0.2s ease;
}

.footer a:hover {
  color: color-mix(in srgb, var(--accent) 80%, white);
  text-decoration: underline;
}

.footer a:visited {
  color: var(--accent);
}

/* Dark mode footer link improvements */
:root.dark .footer a {
  color: #60a5fa; /* Lighter blue for better visibility */
}

:root.dark .footer a:hover {
  color: #93c5fd; /* Even lighter on hover */
}

:root.dark .footer a:visited {
  color: #a78bfa; /* Purple tint for visited links */
}

/* Loading Overlay */
.loading-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0,0,0,0.5);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  backdrop-filter: blur(4px);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s ease, visibility 0.3s ease;
}
.loading-overlay.active {
  opacity: 1;
  visibility: visible;
}
.loading-spinner {
  width: 50px;
  height: 50px;
  border: 4px solid rgba(255,255,255,0.2);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}
@keyframes spin {
  to { transform: rotate(360deg); }
}
.loading-text {
  color: white;
  margin-top: 20px;
  font-size: 16px;
  font-weight: 500;
}

/* Drop Area Loading State */
.drop-area.loading {
  pointer-events: none;
  opacity: 0.7;
}
.drop-area.loading .drop-content::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: 30px;
  height: 30px;
  margin: -15px 0 0 -15px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  z-index: 1;
}

/* Progress Bar Animations */
.progress-wrap {
  position: relative;
  height: 28px;
  background: var(--border);
  border-radius: 14px;
  overflow: hidden;
  box-shadow: inset 0 2px 4px rgba(0,0,0,0.1);
  min-width: 280px;
  border: 1px solid var(--border);
}
.progress-bar {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), color-mix(in srgb, var(--accent) 80%, white));
  border-radius: 14px;
  transition: width 0.2s ease-out;
  position: relative;
  overflow: hidden;
  min-width: 0;
}
.progress-bar::after {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(
    90deg,
    transparent,
    rgba(255,255,255,0.3),
    transparent
  );
  animation: shimmer 2s infinite;
}
@keyframes shimmer {
  0% { transform: translateX(-100%); }
  100% { transform: translateX(100%); }
}
@keyframes pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.02); }
}
.progress-text {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  color: white;
  font-weight: 600;
  font-size: 13px;
  text-shadow: 0 1px 2px rgba(0,0,0,0.5);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 90%;
  z-index: 1;
  line-height: 1.2;
}

/* Button Loading State */
.btn.loading {
  position: relative;
  color: transparent;
  pointer-events: none;
}
.btn.loading::after {
  content: "";
  position: absolute;
  width: 16px;
  height: 16px;
  top: 50%;
  left: 50%;
  margin: -8px 0 0 -8px;
  border: 2px solid rgba(255,255,255,0.3);
  border-top-color: white;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

/* Modals */
.modal{border:0; border-radius:14px; padding:0; background:var(--card); color:var(--fg); width:min(900px, 95vw)}
.modal::backdrop{background:rgba(0,0,0,.45)}
.modal .modal-head{display:flex; align-items:center; justify-content:space-between; padding:12px 14px; border-bottom:1px solid var(--border)}
.modal .modal-body{padding:12px 14px}
.modal .modal-actions{display:flex; gap:8px; padding:12px 14px; border-top:1px solid var(--border)}
.modal .hexview.small{height:220px}

/* Responsive */
/* Mobile table improvements */
@media (max-width: 768px) {
  .sig-table-wrap {
    height: 400px;
    border-radius: 8px;
  }
  .sig-table {
    font-size: 13px;
  }
  .sig-table thead th {
    padding: 8px 6px;
    font-size: 11px;
  }
  .sig-table tbody td {
    padding: 8px 6px;
  }
  .sig-table tbody td code {
    font-size: 11px;
    word-break: break-all;
  }
  
  /* Hide less important columns on mobile */
  .sig-table th:nth-child(3),
  .sig-table td:nth-child(3),
  .sig-table th:nth-child(5),
  .sig-table td:nth-child(5) {
    display: none;
  }
  
  /* Hits table mobile */
  .hits-table {
    font-size: 13px;
  }
  .hits-table th:nth-child(3),
  .hits-table td:nth-child(3),
  .hits-table th:nth-child(4),
  .hits-table td:nth-child(4) {
    display: none;
  }
}

/* Mobile HEX viewer improvements */
@media (max-width: 768px) {
  .hexview {
    font-size: 12px;
    height: 350px;
    border-radius: 8px;
  }
  .hex-row {
    padding: 2px 0;
  }
  .hex-off {
    width: 70px;
    font-size: 11px;
    padding-right: 8px;
  }
  .hex-data {
    min-width: 250px;
    font-size: 11px;
    word-spacing: 1px;
    padding-right: 8px;
  }
  .hex-ascii {
    width: 120px;
    font-size: 11px;
  }
  
  /* Hex toolbar mobile */
  .hex-toolbar {
    flex-wrap: wrap;
    gap: 8px;
  }
  .hex-toolbar label {
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 0;
  }
  .hex-toolbar .grow {
    flex: 1 1 200px;
    min-width: 200px;
  }
  .hex-toolbar input {
    width: 100%;
  }
  .hex-toolbar button {
    flex-shrink: 0;
  }
}

/* Very small mobile screens - vertical hex toolbar */
@media (max-width: 480px) {
  .hex-toolbar {
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
  }
  .hex-toolbar .grow {
    flex: none;
  }
}

/* Mobile controls and buttons */
@media (max-width: 768px) {
  .inspect-controls {
    flex-direction: column;
    gap: 12px;
    align-items: stretch;
  }
  .inspect-controls label {
    display: flex;
    flex-direction: column;
    gap: 6px;
  }
  .inspect-controls select {
    font-size: 16px;
  }
  
  .sig-actions {
    flex-direction: column;
    gap: 12px;
  }
  .sig-actions .btn {
    flex: none;
  }
  
  .form-actions {
    flex-direction: column;
    gap: 12px;
  }
  
  /* Progress bar mobile */
  .progress-wrap {
    min-width: 100%;
    height: 32px;
    border-radius: 16px;
  }
  .progress-text {
    font-size: 13px;
  }
}

/* Drop area mobile improvements */
@media (max-width: 768px) {
  .drop-area {
    min-height: 200px;
    padding: 24px 16px;
    border-radius: 12px;
    margin-bottom: 16px;
  }
  .drop-content {
    gap: 12px;
  }
  .drop-icon {
    width: 40px;
    height: 40px;
  }
  .drop-title {
    font-size: 16px;
  }
  .drop-or {
    font-size: 13px;
  }
}

/* Mobile modal improvements */
@media (max-width: 768px) {
  .modal {
    width: 95vw;
    max-height: 90vh;
    margin: 5vh auto;
  }
  .modal .modal-head {
    padding: 16px;
  }
  .modal .modal-body {
    padding: 16px;
    max-height: 60vh;
    overflow-y: auto;
  }
  .modal .modal-actions {
    padding: 16px;
    flex-direction: column;
    gap: 12px;
  }
}

/* Small mobile devices */
@media (max-width: 480px) {
  .app-header > div:first-child {
    padding: 12px;
    position: static;
  }
  .header-actions {
    position: static;
    transform: none;
  }
  .main-tab {
    padding: 10px 12px;
    font-size: 13px;
  }
  .layout {
    padding: 8px 12px;
  }
  .tab-panel {
    padding: 16px 12px;
  }
  
  .hexview {
    height: 300px;
    font-size: 11px;
  }
  .hex-data {
    min-width: 200px;
  }
  .hex-ascii {
    width: 100px;
  }
  
  .btn {
    padding: 14px 16px;
    font-size: 14px;
  }
}

/* Landscape mobile optimizations */
@media (max-width: 768px) and (orientation: landscape) {
  .hexview {
    height: 250px;
  }
  .drop-area {
    min-height: 150px;
    padding: 20px 16px;
  }
}

/* High DPI mobile displays */
@media (max-width: 768px) and (-webkit-min-device-pixel-ratio: 2) {
  .hex-row .hi {
    box-shadow: 0 0 0 1px rgba(34,197,94,.8);
  }
  :root.dark .hex-row .hi {
    box-shadow: 0 0 0 1px rgba(34,197,94,.9);
  }
}

/* Mobile context menu */
.mobile-context-menu {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: fadeIn 0.2s ease;
}

.context-menu-backdrop {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(2px);
}

.context-menu-content {
  position: relative;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px;
  margin: 20px;
  max-width: 320px;
  width: 100%;
  box-shadow: var(--shadow);
  animation: slideUp 0.3s ease;
}

.context-menu-content h3 {
  margin: 0 0 12px 0;
  font-size: 16px;
  color: var(--fg);
}

.context-menu-content p {
  margin: 8px 0;
  color: var(--muted);
  font-size: 14px;
}

.context-menu-actions {
  display: flex;
  gap: 12px;
  margin-top: 16px;
}

.context-menu-actions .btn {
  flex: 1;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

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

/* Mobile hints and helpers */
.mobile-tab-hint {
  display: none;
  text-align: center;
  padding: 8px 16px;
  background: rgba(59,130,246,0.1);
  border-bottom: 1px solid var(--border);
}
.mobile-tab-hint .hint-text {
  font-size: 12px;
  color: var(--muted);
  font-style: italic;
}

.desktop-hint {
  display: inline;
}
.mobile-hint {
  display: none;
}

@media (max-width: 768px) {
  .mobile-tab-hint {
    display: block;
    animation: fadeInDown 0.5s ease 2s both;
  }
  .desktop-hint {
    display: none;
  }
  .mobile-hint {
    display: inline;
  }
}

@keyframes fadeInDown {
  0% {
    opacity: 0;
    transform: translateY(-10px);
  }
  50% {
    opacity: 1;
    transform: translateY(0);
  }
  100% {
    opacity: 0;
    transform: translateY(-10px);
  }
}

/* Mobile scroll indicators */
@media (max-width: 768px) {
  .main-tabs {
    position: relative;
  }
  .main-tabs::after {
    content: '';
    position: absolute;
    right: 0;
    top: 0;
    bottom: 0;
    width: 20px;
    background: linear-gradient(to right, transparent, var(--bg));
    pointer-events: none;
    z-index: 1;
  }
}

/* HEX Context Menu */
.hex-context-menu {
  position: fixed;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 12px 32px rgba(0,0,0,0.12), 0 4px 8px rgba(0,0,0,0.08);
  padding: 6px 0;
  min-width: 200px;
  z-index: 9999;
  font-size: 13px;
  opacity: 0;
  visibility: hidden;
  transform: scale(0.9) translateY(-8px);
  transition: all 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
  backdrop-filter: blur(8px);
}

.hex-context-menu.show {
  opacity: 1;
  visibility: visible;
  transform: scale(1) translateY(0);
}

:root.dark .hex-context-menu {
  box-shadow: 0 16px 40px rgba(0,0,0,0.6), 0 4px 12px rgba(0,0,0,0.3);
  backdrop-filter: blur(12px);
}

.hex-context-menu-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  cursor: pointer;
  transition: all 0.15s ease;
  white-space: nowrap;
  color: var(--fg);
  position: relative;
  margin: 0 4px;
  border-radius: 8px;
}

.hex-context-menu-item:hover {
  background: rgba(59,130,246,0.12);
  transform: translateX(2px);
}

:root.dark .hex-context-menu-item:hover {
  background: rgba(59,130,246,0.2);
}

.hex-context-menu-item.disabled {
  opacity: 0.5;
  cursor: not-allowed;
  pointer-events: none;
}

.hex-context-menu-item .icon {
  width: 16px;
  height: 16px;
  opacity: 0.8;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
}

.hex-context-menu-item .shortcut {
  margin-left: auto;
  font-size: 11px;
  opacity: 0.5;
  font-family: var(--mono);
  background: rgba(0,0,0,0.1);
  padding: 2px 6px;
  border-radius: 4px;
  font-weight: 500;
}

:root.dark .hex-context-menu-item .shortcut {
  background: rgba(255,255,255,0.1);
}

.hex-context-menu-item .info-detail {
  margin-left: auto;
  font-size: 11px;
  font-family: var(--mono);
  color: var(--accent);
  font-weight: 600;
  background: rgba(59,130,246,0.1);
  padding: 2px 6px;
  border-radius: 4px;
}

.hex-context-menu-separator {
  height: 1px;
  background: var(--border);
  margin: 4px 0;
}

/* HEX Copy Buttons */
.hex-copy-buttons {
  display: flex;
  gap: 4px;
  margin-right: 12px;
}

.btn-copy {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 6px 10px;
  font-size: 12px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--fg);
  cursor: pointer;
  transition: all 0.15s ease;
  min-width: auto;
}

.btn-copy:not(:disabled):hover {
  background: var(--accent);
  color: var(--accent-fg);
  border-color: var(--accent);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(59,130,246,0.3);
}

.btn-copy:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  background: var(--card);
  color: var(--muted);
}

.btn-copy .icon {
  font-size: 12px;
}

.btn-copy .text {
  font-weight: 500;
  font-size: 11px;
}

:root.dark .btn-copy:not(:disabled):hover {
  box-shadow: 0 4px 16px rgba(59,130,246,0.4);
}

/* 以前ここには「浮遊コピーUIを強制的に隠す」ルールが3つあった。
   対象の要素は全タブ・走査後を測っても0件で、唯一効いていたのは
   自分のコンテキストメニューを display:none !important で殺すことだった。
   属性セレクタ（[style*="position:fixed"] など）は将来の要素も巻き込むため、
   根本（JS側の掃除処理と style 属性）を除いたうえで、まとめて削除した。 */


/* Mobile responsiveness for hex toolbar */
@media (max-width: 768px) {
  .hex-toolbar {
    flex-wrap: wrap;
    gap: 8px;
  }
  
  .hex-copy-buttons {
    order: -1;
    margin-right: 0;
    margin-bottom: 4px;
  }
  
  .btn-copy .text {
    display: none;
  }
  
  .btn-copy {
    padding: 8px;
    min-width: 36px;
    justify-content: center;
  }
}

/* Compact layout for smaller screens */
@media (max-width: 480px) {
  .hex-copy-buttons {
    gap: 2px;
  }
  
  .btn-copy {
    padding: 6px;
    min-width: 32px;
  }
}

/* HEX Selection Styles */
.hex-selected {
  background: rgba(147,51,234,0.2) !important;
  border-radius: 2px;
  outline: 1px solid rgba(147,51,234,0.5);
  position: relative;
  z-index: 1;
}

:root.dark .hex-selected {
  background: rgba(147,51,234,0.3) !important;
  outline: 1px solid rgba(147,51,234,0.6);
}

/* When both signature highlight and selection are applied, prioritize selection */
.hex-byte.hex-selected.hi,
.hex-ascii-char.hex-selected.hi {
  background: rgba(147,51,234,0.25) !important;
  outline: 2px solid rgba(147,51,234,0.6);
  box-shadow: 0 0 0 1px rgba(34,197,94,0.3), 0 0 8px rgba(147,51,234,0.2);
}

:root.dark .hex-byte.hex-selected.hi,
:root.dark .hex-ascii-char.hex-selected.hi {
  background: rgba(147,51,234,0.35) !important;
  outline: 2px solid rgba(147,51,234,0.7);
  box-shadow: 0 0 0 1px rgba(34,197,94,0.4), 0 0 10px rgba(147,51,234,0.3);
}

.hex-row {
  position: relative;
  user-select: none;
}

.hex-byte {
  display: inline-block;
  cursor: pointer;
  padding: 1px 2px;
  border-radius: 2px;
  transition: background-color 0.1s ease;
}

.hex-byte:hover {
  background: rgba(59,130,246,0.1);
}

.hex-ascii-char {
  display: inline-block;
  cursor: pointer;
  padding: 1px;
  border-radius: 2px;
  transition: background-color 0.1s ease;
}

.hex-ascii-char:hover {
  background: rgba(59,130,246,0.1);
}

/* Selection range styling */
.hex-selection-start {
  border-left: 2px solid var(--accent);
}

.hex-selection-end {
  border-right: 2px solid var(--accent);
}

/* Toast animations */
@keyframes slideInRight {
  from {
    transform: translateX(100%);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}

@keyframes slideOutRight {
  from {
    transform: translateX(0);
    opacity: 1;
  }
  to {
    transform: translateX(100%);
    opacity: 0;
  }
}

/* File Information Panel */
.file-info-panel {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 20px;
  box-shadow: var(--shadow);
}

.file-info-panel h3 {
  margin: 0 0 16px 0;
  font-size: 18px;
  color: var(--fg);
  display: flex;
  align-items: center;
  gap: 8px;
}

.file-info-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 20px;
}

.file-info-basic,
.file-info-hashes,
.file-info-analysis {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 16px;
}

.file-info-basic h4,
.file-info-hashes h4,
.file-info-analysis h4 {
  margin: 0 0 12px 0;
  font-size: 14px;
  font-weight: 600;
  color: var(--fg);
  display: flex;
  align-items: center;
  gap: 8px;
}

.info-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
  min-height: 24px;
}

.info-label {
  font-size: 13px;
  color: var(--muted);
  min-width: 80px;
  flex-shrink: 0;
}

.info-value {
  font-size: 13px;
  color: var(--fg);
  font-family: var(--mono);
  flex: 1;
  word-break: break-all;
}

.hash-value {
  position: relative;
}

.hash-loading,
.entropy-loading {
  color: var(--muted);
  font-style: italic;
  font-family: system-ui;
}

.btn-copy-hash {
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 4px 6px;
  cursor: pointer;
  font-size: 12px;
  color: var(--muted);
  transition: all 0.2s ease;
  flex-shrink: 0;
}

.btn-copy-hash:hover {
  background: var(--accent);
  color: var(--accent-fg);
  transform: scale(1.1);
}

.hash-status {
  font-size: 11px;
  color: var(--muted);
  font-weight: 400;
  margin-left: 8px;
}

.hash-status.completed {
  color: #22c55e;
}

.hash-status.error {
  color: var(--danger);
}

/* File size formatting */
.size-bytes {
  color: var(--muted);
  font-size: 12px;
  margin-left: 8px;
}

/* Entropy bar visualization */
.entropy-bar {
  display: flex;
  align-items: center;
  gap: 8px;
}

.entropy-value {
  min-width: 40px;
}

.entropy-visual {
  height: 4px;
  background: var(--border);
  border-radius: 2px;
  flex: 1;
  overflow: hidden;
}

.entropy-fill {
  height: 100%;
  background: linear-gradient(90deg, #22c55e, #eab308, #ef4444);
  transition: width 0.3s ease;
}

/* Format detection badges */
.format-badge {
  display: inline-block;
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 500;
  margin-right: 4px;
}

.format-badge.high-confidence {
  background: rgba(34, 197, 94, 0.1);
  color: #22c55e;
  border: 1px solid rgba(34, 197, 94, 0.3);
}

.format-badge.medium-confidence {
  background: rgba(234, 179, 8, 0.1);
  color: #eab308;
  border: 1px solid rgba(234, 179, 8, 0.3);
}

.format-badge.low-confidence {
  background: rgba(156, 163, 175, 0.1);
  color: var(--muted);
  border: 1px solid var(--border);
}

/* Exif checker link styles */
.exif-check-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  background: linear-gradient(135deg, #667eea, #764ba2);
  color: white;
  text-decoration: none;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 500;
  transition: all 0.2s ease;
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.exif-check-link:hover {
  background: linear-gradient(135deg, #5a6fd8, #6a4190);
  transform: translateY(-1px);
  box-shadow: 0 4px 8px rgba(0,0,0,0.15);
  color: white;
}

.exif-icon {
  font-size: 14px;
}

.exif-text {
  white-space: nowrap;
}

.external-icon {
  font-size: 12px;
  opacity: 0.8;
}

/* Mobile file info panel */
@media (max-width: 768px) {
  .file-info-grid {
    grid-template-columns: 1fr;
    gap: 16px;
  }
  
  .file-info-panel {
    padding: 16px;
    margin-bottom: 16px;
  }
  
  .info-row {
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
  }
  
  .info-label {
    min-width: auto;
  }
  
  .btn-copy-hash {
    align-self: flex-end;
    margin-top: 4px;
  }
  
  .exif-check-link {
    font-size: 12px;
    padding: 4px 8px;
    gap: 4px;
  }
  
  .exif-text {
    font-size: 11px;
  }
}

/* Animation for panel show/hide */
.file-info-panel.show {
  animation: slideDown 0.3s ease;
}

@keyframes slideDown {
  from {
    opacity: 0;
    transform: translateY(-20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes slideInUp {
  from {
    opacity: 0;
    transform: translateX(-50%) translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
  }
}

@media (max-width: 1080px){
  .layout{grid-template-columns:1fr}
  .inspect-grid{grid-template-columns:1fr}
}

/* Footer responsive design */
@media (max-width: 768px) {
  footer {
    margin: 16px 0;
    padding: 0 16px;
  }
  
  .footer {
    padding: 8px 12px;
    font-size: 14px;
    line-height: 1.4;
  }
}

/* Performance optimizations for large file handling */
.progress-wrap {
  /* Performance optimization for animations */
  will-change: transform;
  contain: layout style paint;
}

.progress-bar {
  /* GPU acceleration for smooth animations */
  transform: translateZ(0);
  will-change: width;
  transition: width 0.2s ease-out; /* Faster, smoother transition */
}

.hexview {
  /* Enable hardware acceleration for smooth scrolling */
  transform: translateZ(0);
  will-change: scroll-position;
  /* Optimize for frequent repaints */
  contain: layout style paint;
}

.loading-overlay {
  /* Optimize loading overlay rendering */
  will-change: opacity;
  contain: layout style paint;
}

.hex-context-menu {
  /* Performance optimizations */
  will-change: opacity, visibility;
  contain: layout style paint;
  backface-visibility: hidden;
  transition: opacity 0.1s ease, visibility 0.1s ease; /* Faster transitions */
}

/* Performance warning styles for large files */
.hex-partial-info {
  font-family: inherit;
  z-index: 10;
  position: relative;
}

.hex-partial-info button {
  background: rgba(255, 255, 255, 0.2);
  border: 1px solid rgba(255, 255, 255, 0.3);
  color: inherit;
  border-radius: 3px;
  padding: 2px 6px;
  cursor: pointer;
  font-size: inherit;
}

.hex-partial-info button:hover {
  background: rgba(255, 255, 255, 0.3);
}

/* Mobile performance optimizations */
@media (max-width: 768px) {
  .hexview {
    /* Reduce complexity on mobile devices */
    contain: layout style;
    /* Disable some heavy effects on mobile */
    will-change: auto;
  }
  
  .tab-panel {
    /* Enable hardware acceleration for smooth tab switching */
    transform: translateZ(0);
    will-change: transform;
  }
  
  /* Reduce animation complexity on mobile */
  .btn {
    transition: none;
  }
  .btn:hover:not(:disabled) {
    transform: none;
    box-shadow: var(--shadow);
  }
}


/* 終端の照合結果。見つからないときだけ目立たせる */
.hit-trailer{
  white-space: nowrap;
}

.hit-trailer.trailer-missing{
  color: var(--warning-fg, #b3831f);
  font-weight: 700;
}

/* 表の中央寄せ（以前は style 属性で書かれていた） */
.cell-center{
  text-align: center;
}

/* 大容量ファイルの部分表示バナー（以前は style 属性で書かれていた） */
.hex-partial-banner{
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  padding: 8px;
  margin-bottom: 8px;
  border-radius: 4px;
  background: var(--warning-bg);
  color: var(--warning-fg);
  font-size: 12px;
}

/* ダブルタップの拡大抑止（document の touchend を使わない） */
button, .btn, .main-tab, label{
  touch-action: manipulation;
}

/* 割合が分からないときの進捗表示 */
.progress-bar.indeterminate{
  width: 40% !important;
  animation: msi-indeterminate 1.2s ease-in-out infinite;
}

@keyframes msi-indeterminate{
  0%   { margin-left: 0; }
  50%  { margin-left: 60%; }
  100% { margin-left: 0; }
}

/* 表の列幅（以前は style 属性で書かれていた。CSPの style-src-attr に触れる） */
.col-w60{ width: 60px; }
.col-w80{ width: 80px; }
.col-w100{ width: 100px; }
.col-min180{ min-width: 180px; }
.col-min250{ min-width: 250px; }
.mt-8{ margin-top: 8px; }

/* 進捗バーは幅0から始める */
.progress-bar{ width: 0; }

/* 以前は style 属性で指定していたもの */
.hash-text{ word-break: break-all; }
.entropy-label{ font-size: 11px; color: var(--muted); }
.hex-scroller{ position: relative; }
.hex-content{ position: absolute; top: 0; left: 0; width: 100%; }

/* コントラストの是正。いずれも計算して選んだ色。
   バッジは 4.35 しかなく、完了ラベルと高信頼度バッジは 2.1〜2.3 だった。 */
.badge{
  color: #1d4ed8;   /* 薄青の地の上で 5.64 */
}

.hash-status.completed{
  color: #15803d;   /* 白の上で 5.02 */
}

.format-badge.high-confidence{
  color: #15803d;   /* 薄緑の地の上で 4.60 */
}

.format-badge.medium-confidence{
  color: #7a5b00;   /* 薄黄の地の上で読める濃さ */
}

/* ダークで白文字を載せるボタンの地色。--accent のままだと 3.68 */
:root.dark .btn.primary{
  background: #2563eb;   /* 白文字で 5.17 */
  border-color: #2563eb;
}

/* 操作要素の当たり判定をそろえる */
.btn,
select,
input[type="text"],
input[type="number"],
input[type="search"],
.main-tab{
  min-height: 44px;
}

.btn-copy-hash{
  min-width: 44px;
  min-height: 44px;
}

/* 辞書I/Oの2列組みが、狭い画面で押し広げられていた */
.dictio-grid{
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 260px), 1fr));
}

/* ダークでは上の濃い緑が沈む。地が #0f172a なので明るい側へ振る */
:root.dark .hash-status.completed{
  color: #4ade80;   /* 濃紺の上で 8.2 */
}

:root.dark .format-badge.high-confidence{
  color: #4ade80;
}

:root.dark .format-badge.medium-confidence{
  color: #fbbf24;
}

:root.dark .badge{
  color: #93c5fd;
}

/* ボタンの見た目をしたリンクと、幅の足りない選択肢 */
.exif-check-link{
  min-height: 44px;
  box-sizing: border-box;
}

#hexWidth{
  min-width: 64px;
}

/* ファイル選択欄は既定の幅が327pxあり、狭い画面で箱を押し広げていた */
#importFile,
input[type="file"]{
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
}

/* ダークの削除ボタンは濃紺の上で 3.89 しかなかった */
:root.dark .btn.danger{
  color: #f87171;   /* 5.29 */
}

/* 一覧のチェックボックスは 16px だった。WCAG 2.2 の 2.5.8（AA）は 24px を求める */
#sigTbody input[type="checkbox"],
.sig-table input[type="checkbox"],
thead input[type="checkbox"],
#filterEnabled,
#f_enabled,
#setAutosave,
#setFollowOS{
  width: 24px;
  height: 24px;
}

/* 幅100%の選択肢が枠からわずかにはみ出していた */
select,
input[type="text"],
input[type="number"],
input[type="search"]{
  max-width: 100%;
  box-sizing: border-box;
}

/* 言語の切り替え。テーマの切り替えと同じ高さにそろえる */
.lang-toggle{
  min-height: 36px;
  padding: 6px 12px;
  white-space: nowrap;
}

/* HEXビューのツールバー。1440pxの画面でもボタンの文字が折り返していた。
   縮まない要素にはそれを伝え、伸びるのはジャンプ欄だけにする */
.hex-toolbar{
  flex-wrap: wrap;
}
.hex-toolbar .btn,
.hex-toolbar > label > span{
  white-space: nowrap;
}
.hex-toolbar #jumpPrev,
.hex-toolbar #jumpNext,
.hex-toolbar #jumpGo,
.hex-toolbar .hex-copy-buttons,
.hex-toolbar > label:not(.grow){
  flex: 0 0 auto;
}
.hex-toolbar .grow{
  flex: 1 1 220px;
  min-width: 180px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

/* HEX行がビューの幅を超え、ASCII欄が隠れていた。
   16進の欄は中身のぶんだけ取り、余りをASCII欄に回す */
.hex-data{
  min-width: 0;
  width: max-content;
  flex: 0 0 auto;
}
.hex-ascii{
  flex: 1 1 auto;
  width: auto;
  min-width: 0;
}
@media (min-width: 1201px){
  /* HEXビューの側を広くする。ヒット一覧は6列で足りる */
  .inspect-grid{ grid-template-columns: 1fr 1.6fr; }
}

/* HEXビューの検索バー。Ctrl+F と右クリックメニューから開く */
.hex-find{
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: 8px;
  padding: 8px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--card);
}
.hex-find[hidden]{ display: none; }
.hex-find input[type="search"]{
  flex: 1 1 200px;
  min-width: 140px;
}
.hex-find .btn{ flex: 0 0 auto; }
.hex-find-count{
  font-size: 13px;
  color: var(--muted);
  white-space: nowrap;
  min-width: 64px;
}
.hex-find-count.warn{ color: var(--warning-fg); }

/* 検索で当たった位置。ヒット由来のハイライトとは別の色にする */
.hex-byte.found,
.hex-char.found{
  background: #fde68a;
  color: #713f12;
  border-radius: 3px;
}
.hex-byte.found-current,
.hex-char.found-current{
  background: #f59e0b;
  color: #1c1917;
  font-weight: 700;
}
:root.dark .hex-byte.found,
:root.dark .hex-char.found{
  background: #78350f;
  color: #fde68a;
}
:root.dark .hex-byte.found-current,
:root.dark .hex-char.found-current{
  background: #f59e0b;
  color: #1c1917;
}

/* HEXビューのトースト（以前は style.cssText で組み立てていた） */
.hex-toast{
  position: fixed;
  top: 20px;
  right: 20px;
  background: var(--card);
  color: var(--fg);
  border: 1px solid var(--border);
  padding: 12px 16px;
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
  z-index: 10001;
  font-size: 14px;
  max-width: 300px;
  animation: slideInRight 0.3s ease;
}
.hex-toast.leaving{
  animation: slideOutRight 0.3s ease;
}

/* 終端の後ろに付いたデータの知らせ */
.appended-panel{
  margin-top: 12px;
  padding: 12px 14px;
  border: 1px solid var(--warning-fg, #b3831f);
  border-radius: 10px;
  background: var(--warning-bg, #fff8e6);
}
.appended-panel[hidden]{ display: none; }
.appended-panel p{ margin: 6px 0; }
.appended-heading{
  color: var(--warning-fg, #b3831f);
  display: block;
  margin-bottom: 4px;
}
.appended-actions{
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 10px;
}
:root.dark .appended-panel{
  background: #2a2010;
  border-color: #b45309;
}
:root.dark .appended-heading{ color: #fbbf24; }

/* 実行ファイルが別の拡張子で置かれているときの、強い注意 */
.ext-danger{
  color: var(--danger);
  font-weight: 700;
}
:root.dark .ext-danger{ color: #f87171; }

/* 一括チェック */
.batch-drop{ min-height: 0; padding: 20px; }
.batch-controls{
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
  margin: 14px 0;
}
.batch-status{
  flex: 1 1 200px;
  color: var(--muted);
  font-size: 14px;
}
.batch-table-wrap{ overflow-x: auto; }
.batch-table{
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.batch-table th,
.batch-table td{
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
  text-align: left;
  vertical-align: top;
}
.batch-table th{
  position: sticky;
  top: 0;
  background: var(--card);
  white-space: nowrap;
}
.batch-table td.mono{
  font-family: var(--mono);
  font-size: 12px;
  word-break: break-all;
}
.batch-table td.num{ text-align: right; white-space: nowrap; }
.batch-flag-ng{ color: var(--danger); font-weight: 700; }
.batch-flag-warn{ color: var(--warning-fg, #b3831f); font-weight: 700; }
.batch-flag-ok{ color: #15803d; }
:root.dark .batch-flag-ok{ color: #4ade80; }
:root.dark .batch-flag-ng{ color: #f87171; }
:root.dark .batch-flag-warn{ color: #fbbf24; }

/* 後ろにデータがあるが、そこから何も見つからなかったとき。枠を目立たせない */
.appended-panel.quiet{
  border-color: var(--border);
  background: var(--card);
}
.appended-panel.quiet .appended-heading{
  color: var(--fg);
}

/* エントロピーの分布 */
.entropy-panel{
  margin-top: 16px;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--card);
}
.entropy-panel[hidden]{ display: none; }
.entropy-panel h3{ margin: 0 0 6px; }
.entropy-chart{
  margin: 10px 0;
  width: 100%;
  overflow-x: auto;
}
.entropy-chart svg{ display: block; width: 100%; height: auto; }
/* 分布のグラフの棒。fileinfo.js が作る全体のバー（.entropy-bar）とは別物なので
   名前を分けている。同じ名前にしていて、数え間違いの元になった */
.entropy-block{ cursor: pointer; }
.entropy-block:hover{ opacity: .75; }
.entropy-block.band-flat{ fill: #94a3b8; }
.entropy-block.band-low{ fill: #38bdf8; }
.entropy-block.band-text{ fill: #22c55e; }
.entropy-block.band-mixed{ fill: #f59e0b; }
.entropy-block.band-high{ fill: #ef4444; }
.entropy-axis{ fill: var(--muted); font-size: 10px; }
.entropy-grid{ stroke: var(--border); stroke-width: 1; }
.entropy-legend{
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  font-size: 12px;
  color: var(--muted);
  margin-top: 6px;
}
.entropy-legend span.swatch{
  display: inline-block;
  width: 12px;
  height: 12px;
  border-radius: 3px;
  margin-right: 4px;
  vertical-align: -1px;
}

/* 凡例の色見本。棒と同じ色を使う */
.entropy-legend .swatch.band-flat{ background: #94a3b8; }
.entropy-legend .swatch.band-low{ background: #38bdf8; }
.entropy-legend .swatch.band-text{ background: #22c55e; }
.entropy-legend .swatch.band-mixed{ background: #f59e0b; }
.entropy-legend .swatch.band-high{ background: #ef4444; }
