:root{
  --bg:#f6f8fb; --card:#ffffff; --text:#0f172a; --muted:#475569;
  --line:#e2e8f0; --brand:#2563eb; --brand2:#0ea5e9;
  --shadow:0 14px 35px rgba(2,6,23,.10);
  --radius:18px; --radius2:26px;
}

*{ box-sizing:border-box; }
html,body{ height:100%; }

body{
  margin:0;
  font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans JP",
               "Hiragino Sans", "Yu Gothic", "Meiryo", Arial, sans-serif;
  color:var(--text);
  background:
    radial-gradient(1200px 500px at 20% -10%, rgba(37,99,235,.16), transparent 55%),
    radial-gradient(900px 420px at 90% 0%, rgba(14,165,233,.14), transparent 55%),
    var(--bg);
  line-height:1.65;
}

a{
	color: var(--brand);
	text-decoration: none;
}
a:hover{
	text-decoration: underline;
}

img{ max-width:100%; height:auto; display:block; }

.container{ max-width:1120px; margin:0 auto; padding:22px 16px 40px; }

/* Topbar */
.topbar{
  position:sticky; top:10px; z-index:50;
  backdrop-filter: blur(12px);
  background: rgba(255,255,255,.78);
  border:1px solid var(--line);
  border-radius: var(--radius2);
  box-shadow: var(--shadow);
  padding:12px 14px;
}
.topbar-row{ display:flex; align-items:center; justify-content:space-between; gap:14px; flex-wrap:wrap; }

.brand{ display:flex; align-items:center; gap:10px; min-width:240px; }
.brand-badge{
  width:36px; height:36px; border-radius:12px;
  background: linear-gradient(135deg, var(--brand), var(--brand2));
  box-shadow: 0 12px 22px rgba(37,99,235,.25);
}
.brand-title{ display:flex; flex-direction:column; gap:2px; }
.brand-title strong{ font-size:15px; letter-spacing:.2px; }
.brand-title span{ font-size:12px; color:var(--muted); }

nav ul{ list-style:none; margin:0; padding:0; display:flex; flex-wrap:wrap; gap:8px; justify-content:flex-end; }
nav a{
  color: var(--text);
  text-decoration: none;
  display:inline-flex; align-items:center; justify-content:center;
  padding:8px 12px; border-radius:999px;
  border:1px solid var(--line); background:#fff;
  font-size:13px; font-weight:650;
  transition: transform .08s ease, background .15s ease, box-shadow .15s ease, border-color .15s ease;
}
nav a:hover{
  background:#f1f5f9; border-color:#cbd5e1;
  box-shadow:0 10px 18px rgba(2,6,23,.10);
  transform: translateY(-1px);
  text-decoration:none;
}
nav a.primary{
  background: linear-gradient(135deg, var(--brand), var(--brand2));
  border-color: transparent; color:#fff;
}
nav a.primary:hover{
  filter: brightness(1.05);
  box-shadow:0 14px 26px rgba(37,99,235,.22);
}
/* active page highlight */
nav a[aria-current="page"]{
  background: linear-gradient(135deg, var(--brand), var(--brand2));
  border-color: transparent;
  color:#fff;
}

/* Cards */
.card{
  background: var(--card);
  border:1px solid var(--line);
  border-radius: var(--radius2);
  box-shadow: var(--shadow);
  overflow:hidden;
}

/* Intro */
.intro{ margin-top:16px; padding:18px; }
.intro h1{ margin:0; font-size: clamp(22px, 2.6vw, 34px); letter-spacing:.2px; }
.intro p{
  margin:6px 0 0;
  color:var(--muted);
  font-size:14px;
  white-space: nowrap;
  overflow: hidden;          /* FIX */
  text-overflow: ellipsis;   /* FIX */
}

/* Main row: logo image (left) + search (right) */
.main-row{
  display:grid;
  grid-template-columns: 1fr 2fr; /* left ~half, right wider */
  gap: 16px;
  margin-top: 16px;
  align-items: stretch;
}
.hero-image{
  border-radius: var(--radius2);
  border:1px solid var(--line);
  overflow:hidden;
  background:#fff;
  box-shadow: var(--shadow);
  height: 100%;
  display:flex;
  align-items:center;
  justify-content:center;
  padding: 8px;
}
.hero-image img{ width:100%; height:auto; object-fit:contain; }

/* Search */
.search{ }
.search-card{ padding:16px; }
.search-title{
  display:flex; align-items:flex-start; justify-content:space-between; gap:10px; flex-wrap:wrap;
  margin-bottom: 10px;
}
.search-title h2{ margin:0; font-size:18px; }
.search-title p{ margin:2px 0 0; color:var(--muted); font-size:13px; }

.search-grid{
  display:grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  align-items:start;
}
.search-box{
  border:1px solid var(--line);
  border-radius: var(--radius);
  padding:12px;
  background:#fff;
  height: 100%;
}
.search-box label{
  display:block;
  font-size:12px;
  color:var(--muted);
  margin-bottom:6px;
  font-weight:800;
}
.search input[type="text"]{
  width: 100%;
  padding: 10px 12px;
  border:1px solid var(--line);
  border-radius: 12px;
  font-size: 15px;
  outline: none;
  background:#fff;
}
.search input[type="text"]:focus{
  border-color: rgba(37,99,235,.55);
  box-shadow: 0 0 0 3px rgba(37,99,235,.18);
}
.search button{
  width: 100%;
  margin-top: 10px;
  padding: 10px 14px;
  border:0;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--brand), var(--brand2));
  color:#fff;
  font-weight: 800;
  cursor:pointer;
  box-shadow: 0 12px 22px rgba(37,99,235,.22);
}
.search button:hover{ filter:brightness(1.05); }

/* Suggest dropdown */
#suggest{
  margin-top: 8px;
  border: 1px solid var(--line);
  border-radius: 12px;
  overflow:hidden;
  box-shadow: 0 12px 28px rgba(2,6,23,.10);
  background:#fff;
  max-width: 100%;
}
#suggest *{ font-size: 14px; }
#suggest a{ display:block; padding:10px 12px; color:var(--text); text-decoration:none; }
#suggest a:hover{ background:#f1f5f9; }

/* Viewer / Chromosomes */
.chromos{ margin-top:16px; padding:18px; }
.chromos h2{ margin:0 0 10px; font-size:18px; }
.chromobox{ margin-top: 12px; }
.chromobox label{
  display:block;
  font-size:12px;
  color:var(--muted);
  margin-bottom:8px;
  font-weight:800;
}
.chip{
  border:1px solid var(--line);
  border-radius: var(--radius);
  background:#fff;
  padding:12px;
}

/* --- tighter chromosome buttons on desktop (to avoid wrapping at 21) --- */
.chip .chr-links{
  display:flex;
  flex-wrap: nowrap;
  gap: 6px;            /* tighter than before */
  align-items:center;
  overflow-x: auto;    /* fallback if still too narrow */
  padding-bottom: 2px;
}
.chip .chr-links::-webkit-scrollbar{ height: 8px; }
.chip .chr-links::-webkit-scrollbar-thumb{ background: rgba(2,6,23,.18); border-radius: 999px; }
.chip .chr-links::-webkit-scrollbar-track{ background: rgba(2,6,23,.06); border-radius: 999px; }

.chip .chr-links a{
  min-width: 28px;     /* smaller */
  padding: 7px 10px;    /* smaller */
  font-size: 16px;     /* smaller */
  line-height: 1;
  border-radius: 999px;
  border: 1px solid rgba(37,99,235,.16);
  background: rgba(37,99,235,.08);
  color: var(--text);
  font-weight: 800;
  text-decoration:none;
  transition: background .15s ease, border-color .15s ease, transform .06s ease;
}
.chip .chr-links a:hover{
  background: rgba(37,99,235,.12);
  border-color: rgba(37,99,235,.28);
  transform: translateY(-1px);
}

/* Sections */
.section{ padding:18px; }
.section h3{ margin:0 0 8px; font-size:18px; }
.section p{ margin:0 0 12px; color:var(--muted); font-size:14px; }

.news{
  margin:0;
  padding-left:18px;
  color:var(--muted);
  font-size:14px;
}
.news li{
  margin:10px 0;
  white-space: normal;
  overflow: visible;
  text-overflow: clip;
  word-break: break-word;
}

/* Stats bottom */
.stats{ margin-top:16px; padding: 16px; }
.stats h2{ margin:0 0 10px; font-size:18px; }
.kpis{ display:grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.kpi{
  padding:12px;
  border-radius: var(--radius);
  border:1px solid var(--line);
  background: linear-gradient(180deg, #fff, #fbfdff);
}
.kpi .label{ font-size:12px; color:var(--muted); margin-bottom:6px; }
.kpi .value{ font-size:20px; font-weight:850; letter-spacing:.2px; }

footer{ margin-top:22px; padding:14px 16px; color:var(--muted); font-size:13px; text-align:center; }
footer a{ color: var(--brand); }

/* Responsive */
@media (max-width: 980px){
  .main-row{ grid-template-columns: 1fr; }
  nav ul{ justify-content:flex-start; }
  .intro p{
    white-space: normal;
    overflow: visible;
    text-overflow: clip;
  }
  .search-grid{ grid-template-columns: 1fr; }
  .search button{ width:auto; }
}

/* On small screens: allow wrapping for viewer */
@media (max-width: 720px){
  .chip .chr-links{ flex-wrap: wrap; overflow-x: visible; }
  .chip .chr-links a{ min-width: 38px; padding: 6px 9px; font-size: 13px; }
}

@media (max-width: 520px){
  .kpis{ grid-template-columns:1fr; }
  nav a{ padding:8px 10px; font-size:12.5px; }
}

/* ===== Tables: keep inside card ===== */
.card.section{
  overflow-x: auto;                 /* カード内で横スクロール */
  -webkit-overflow-scrolling: touch;
}

/* repository の table（class="tblc"）に効く */
table.tblc{
  width: 100% !important;           /* width="500px" を上書き */
  max-width: 100%;
  border-collapse: collapse;
}

/* セルが長いときの挙動（基本は折り返し許可） */
table.tblc th, table.tblc td{
  padding: 8px 10px;
  vertical-align: top;
}

/* HTMLに nowrap があるので、上書きして折り返し可能にする（効く環境が多い） */
table.tblc td[nowrap], table.tblc th[nowrap]{
  white-space: normal !important;
}

/* ただし Accession ID などは折り返したくない場合：最初の列だけは折り返し禁止 */
table.tblc td:first-child, table.tblc th:first-child{
  white-space: nowrap !important;
}

.table-wrap{
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
}
.table-wrap table.tblc{
  margin: 0;
  width: 100% !important;
}

