:root{
  --bg:#f5f7fb;
  --panel:#fff;
  --text:#172033;
  --muted:#667085;
  --line:#e5e9f1;
  --blue:#315efb;
  --blue-soft:#eef2ff;
  --green:#137a4b;
  --shadow:0 8px 30px rgba(26,39,72,.07);
}

*{box-sizing:border-box}

body{
  margin:0;
  background:var(--bg);
  color:var(--text);
  font-family:Inter,ui-sans-serif,system-ui,-apple-system,BlinkMacSystemFont,"Segoe UI",sans-serif;
}

.topbar{
  display:flex;
  justify-content:space-between;
  gap:28px;
  padding:28px max(28px,calc((100vw - 1480px)/2));
  background:#101828;
  color:#fff;
}

.topbar h1{
  margin:8px 0 5px;
  font-size:25px;
}

.topbar p{
  max-width:760px;
  margin:0;
  color:#cbd5e1;
  line-height:1.55;
}

.back{
  color:#b9c7ff;
  text-decoration:none;
  font-size:13px;
  font-weight:700;
}

.model-card{
  min-width:250px;
  align-self:center;
  padding:13px 15px;
  border:1px solid rgba(255,255,255,.14);
  border-radius:12px;
  background:rgba(255,255,255,.06);
}

.model-card span,
.model-card small{
  display:block;
  color:#cbd5e1;
  font-size:11px;
}

.model-card strong{
  display:block;
  margin:5px 0 2px;
  font-size:13px;
  overflow-wrap:anywhere;
}

.page{
  max-width:1480px;
  margin:0 auto;
  padding:28px;
}

.panel{
  background:var(--panel);
  border:1px solid var(--line);
  border-radius:15px;
  box-shadow:var(--shadow);
  overflow:hidden;
}

.search-panel{
  padding:20px;
}

.panel-title{
  display:flex;
  align-items:flex-start;
  justify-content:space-between;
  gap:20px;
  padding:18px 20px;
  border-bottom:1px solid var(--line);
}

.search-panel .panel-title{
  padding:0 0 15px;
  border:0;
}

.panel-title h2{
  margin:0 0 4px;
  font-size:16px;
}

.panel-title p{
  margin:0;
  color:var(--muted);
  font-size:12px;
  line-height:1.45;
}

textarea{
  width:100%;
  resize:vertical;
  min-height:150px;
  padding:15px;
  border:1px solid #cfd6e4;
  border-radius:10px;
  outline:none;
  color:var(--text);
  background:#fff;
  font:inherit;
  line-height:1.6;
}

textarea:focus{
  border-color:var(--blue);
  box-shadow:0 0 0 3px rgba(49,94,251,.11);
}

.search-actions{
  display:flex;
  align-items:center;
  gap:9px;
  flex-wrap:wrap;
  margin-top:13px;
}

button{
  border:0;
  border-radius:9px;
  padding:10px 14px;
  background:var(--blue);
  color:#fff;
  font-weight:800;
  cursor:pointer;
}

button.secondary{
  background:#eef1f6;
  color:#344054;
}

button:disabled{
  opacity:.55;
  cursor:wait;
}

#searchStatus{
  color:var(--muted);
  font-size:12px;
}

.results{
  margin-top:20px;
}

.hidden{
  display:none;
}

.formula{
  display:flex;
  flex-wrap:wrap;
  justify-content:flex-end;
  gap:6px;
}

.formula span{
  border:1px solid #d8dffd;
  border-radius:999px;
  padding:5px 8px;
  background:var(--blue-soft);
  color:#3446a1;
  font-size:10px;
  font-weight:800;
}

.ontology-results{
  padding:10px 20px 20px;
}

.ontology-card{
  display:grid;
  grid-template-columns:58px minmax(260px,1fr) 180px 180px;
  gap:14px;
  align-items:start;
  padding:16px 0;
  border-bottom:1px solid var(--line);
}

.ontology-card:last-child{
  border-bottom:0;
}

.rank{
  width:42px;
  height:42px;
  display:grid;
  place-items:center;
  border-radius:12px;
  background:#101828;
  color:#fff;
  font-size:16px;
  font-weight:900;
}

.ontology-main h3{
  margin:0 0 3px;
  font-size:15px;
}

.meta{
  color:var(--muted);
  font-size:11px;
}

.score-number{
  margin-bottom:7px;
  font-size:21px;
  font-weight:900;
}

.score-bar{
  height:7px;
  overflow:hidden;
  border-radius:999px;
  background:#edf0f5;
}

.score-bar > i{
  display:block;
  height:100%;
  border-radius:inherit;
  background:var(--blue);
}

.component-list{
  display:grid;
  grid-template-columns:1fr 1fr;
  gap:4px 10px;
  margin-top:8px;
  color:var(--muted);
  font-size:10px;
}

.why{
  margin-top:10px;
  display:flex;
  flex-wrap:wrap;
  gap:5px;
}

.why span{
  max-width:260px;
  overflow:hidden;
  text-overflow:ellipsis;
  white-space:nowrap;
  padding:4px 7px;
  border-radius:7px;
  background:#f2f4f7;
  color:#475467;
  font-size:10px;
}

.term-grid{
  display:grid;
  grid-template-columns:1fr 1fr;
  gap:20px;
  margin-top:20px;
}

.term-results{
  padding:8px 18px 18px;
}

.term-row{
  display:grid;
  grid-template-columns:38px minmax(0,1fr) 82px;
  gap:10px;
  align-items:center;
  padding:11px 0;
  border-bottom:1px solid var(--line);
}

.term-row:last-child{
  border-bottom:0;
}

.term-rank{
  color:#98a2b3;
  font-weight:900;
  text-align:center;
}

.term-title{
  min-width:0;
}

.term-title strong{
  display:block;
  overflow:hidden;
  text-overflow:ellipsis;
  white-space:nowrap;
  font-size:12px;
}

.term-title small{
  display:block;
  margin-top:3px;
  overflow:hidden;
  text-overflow:ellipsis;
  white-space:nowrap;
  color:var(--muted);
  font-size:10px;
}

.term-score{
  text-align:right;
  color:var(--green);
  font-size:12px;
  font-weight:900;
}

.empty{
  padding:24px 0;
  color:var(--muted);
  text-align:center;
  font-size:12px;
}

.error{
  color:#b42318 !important;
}

@media(max-width:1000px){
  .topbar{
    flex-direction:column;
  }

  .model-card{
    min-width:0;
  }

  .ontology-card{
    grid-template-columns:50px 1fr;
  }

  .ontology-score,
  .ontology-components{
    grid-column:2;
  }

  .term-grid{
    grid-template-columns:1fr;
  }
}

@media(max-width:620px){
  .page{
    padding:14px;
  }

  .topbar{
    padding:22px 18px;
  }

  .panel-title{
    flex-direction:column;
  }

  .formula{
    justify-content:flex-start;
  }
}
